Browse Source

Version 2.4.1 Fixed 1.13 material fixed whitelist commands notworking

properly
master
pintux98 6 years ago
parent
commit
f56164b5b1
  1. 2
      MultiArena-TheBridge/.settings/org.eclipse.core.resources.prefs
  2. 2
      MultiArena-TheBridge/config.yml
  3. 2
      MultiArena-TheBridge/plugin.yml
  4. 8
      MultiArena-TheBridge/src/cx/sfy/TheBridge/Main.java
  5. 12
      MultiArena-TheBridge/src/cx/sfy/TheBridge/cmds/SetupCMD.java
  6. 750
      MultiArena-TheBridge/src/cx/sfy/TheBridge/game/Game.java
  7. 754
      MultiArena-TheBridge/src/cx/sfy/TheBridge/game/GameDuo.java
  8. 38
      MultiArena-TheBridge/src/cx/sfy/TheBridge/game/GameFour.java
  9. 42
      MultiArena-TheBridge/src/cx/sfy/TheBridge/listeners/PlayerListener.java
  10. 6
      MultiArena-TheBridge/src/cx/sfy/TheBridge/listeners/SetupListener.java
  11. 30
      MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/GameManager.java
  12. 14
      MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/ScoreboardManager.java
  13. 10
      MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/SignManager.java
  14. 10
      MultiArena-TheBridge/src/cx/sfy/TheBridge/menus/GameMenu.java
  15. 8
      MultiArena-TheBridge/src/cx/sfy/TheBridge/menus/TeamMenu.java
  16. 307
      MultiArena-TheBridge/src/cx/sfy/TheBridge/team/Team.java
  17. 180
      MultiArena-TheBridge/src/cx/sfy/TheBridge/team/TeamDuo.java
  18. 7
      MultiArena-TheBridge/src/cx/sfy/TheBridge/utils/PaperOnly.java

2
MultiArena-TheBridge/.settings/org.eclipse.core.resources.prefs

@ -1,5 +1,5 @@
eclipse.preferences.version=1
encoding//src/cx/sfy/TheBridge/game/Game.java=UTF-8
encoding//src/cx/sfy/TheBridge/game/GameDuo.java=UTF-8
encoding//src/cx/sfy/TheBridge/game/GameFour.java=UTF-8
encoding//src/cx/sfy/TheBridge/kit/Hotbar.java=UTF-8
encoding//src/cx/sfy/TheBridge/listeners/PlayerListener.java=UTF-8

2
MultiArena-TheBridge/config.yml

@ -10,7 +10,7 @@ chat:
ingame: "<teamColor>[<teamName>] <player>: &7<msg>"
global: "&6[GLOBAL] <teamColor> <teamName> <player>: &7<msg>"
commands:
enabled: true
whitelist: true
list:
- /myCommand
archievements:

2
MultiArena-TheBridge/plugin.yml

@ -1,6 +1,6 @@
main: cx.sfy.TheBridge.Main
name: TheBridge
version: 2.4.0
version: 2.4.1
authors: [Stefatorus, pintux98, Leonardo0013YT]
softdepend: [PlaceholderAPI, LeaderHeads, FastAsyncWorldEdit, WorldEdit]
commands:

8
MultiArena-TheBridge/src/cx/sfy/TheBridge/Main.java

@ -20,8 +20,8 @@ import cx.sfy.TheBridge.controllers.WorldController;
import cx.sfy.TheBridge.database.Cosmeticbase;
import cx.sfy.TheBridge.database.Database;
import cx.sfy.TheBridge.database.PlayerStat;
import cx.sfy.TheBridge.game.Game;
import cx.sfy.TheBridge.game.Game.State;
import cx.sfy.TheBridge.game.GameDuo;
import cx.sfy.TheBridge.game.GameDuo.State;
import cx.sfy.TheBridge.game.GameFour;
import cx.sfy.TheBridge.game.GameFour.FState;
import cx.sfy.TheBridge.game.InventoryData;
@ -190,7 +190,7 @@ public class Main extends JavaPlugin {
new BukkitRunnable() {
@Override
public void run() {
for (Game game : getGM().getGames()) {
for (GameDuo game : getGM().getGames()) {
if (game.isState(State.WAITING) || game.isState(State.STARTING) || game.isState(State.PREGAME)) {
game.updateGame();
}
@ -225,7 +225,7 @@ public class Main extends JavaPlugin {
pd.restore();
}
}
for (Game gamef : getGM().getGames()) {
for (GameDuo gamef : getGM().getGames()) {
for (PlayerData pd : gamef.getPD().values()) {
pd.restore();
}

12
MultiArena-TheBridge/src/cx/sfy/TheBridge/cmds/SetupCMD.java

@ -17,8 +17,8 @@ import org.bukkit.inventory.ItemStack;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.fanciful.FancyMessage;
import cx.sfy.TheBridge.game.Game;
import cx.sfy.TheBridge.game.Game.State;
import cx.sfy.TheBridge.game.GameDuo;
import cx.sfy.TheBridge.game.GameDuo.State;
import cx.sfy.TheBridge.game.GameFour;
import cx.sfy.TheBridge.game.GameFour.FState;
import cx.sfy.TheBridge.utils.ItemBuilder;
@ -152,8 +152,8 @@ public class SetupCMD implements CommandExecutor {
}
switch (args[1].toLowerCase()) {
case "normal":
for (final Game game : plugin.getGM().getGames()) {
Game g = null;
for (final GameDuo game : plugin.getGM().getGames()) {
GameDuo g = null;
int alto = 0;
if (game.isState(State.FINISH) || game.isState(State.INGAME) || game.isState(State.RESTARTING) || game.isState(State.PREGAME)) continue;
if (game.getPlayers() == game.getMax()) continue;
@ -295,7 +295,7 @@ public class SetupCMD implements CommandExecutor {
return true;
}
if (plugin.getGM().getGameByPlayer(p) != null) {
final Game game = plugin.getGM().getGameByPlayer(p);
final GameDuo game = plugin.getGM().getGameByPlayer(p);
plugin.getGM().removePlayerGame(p, game);
return true;
}
@ -350,7 +350,7 @@ public class SetupCMD implements CommandExecutor {
return true;
}
if (plugin.getGM().getGameByName(name100) != null) {
final Game game = plugin.getGM().getGameByName(name100);
final GameDuo game = plugin.getGM().getGameByName(name100);
if (game.getPlayers() >= game.getMax()) {
p.sendMessage(plugin.getLang().get("messages.gameFull"));
return true;

750
MultiArena-TheBridge/src/cx/sfy/TheBridge/game/Game.java

@ -1,753 +1,5 @@
package cx.sfy.TheBridge.game;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.database.PlayerStat;
import cx.sfy.TheBridge.hologram.TruenoHologram;
import cx.sfy.TheBridge.hologram.TruenoHologramAPI;
import cx.sfy.TheBridge.team.Team;
import cx.sfy.TheBridge.utils.CenterMessage;
import cx.sfy.TheBridge.utils.ItemBuilder;
import cx.sfy.TheBridge.utils.Utils;
public class Game {
private final Main plugin;
private final HashMap<ChatColor, Team> teams;
private final HashMap<Player, ChatColor> teamPlayer;
private final ArrayList<Player> players;
private final HashMap<Player, PlayerData> pd = new HashMap<>();
private final HashMap<Player, Integer> goals = new HashMap<>();
private final HashMap<Player, Integer> kills = new HashMap<>();
private final ArrayList<TruenoHologram> holograms = new ArrayList<>();
private final ArrayList<Location> build = new ArrayList<>();
private final ArrayList<Location> placed = new ArrayList<>();
private final String name;
private final String mode;
private final int min;
private final int max;
private final int teamSize;
private int starting;
private int prestart;
private int restart;
private final Location lobby;
private final Location spect;
private BukkitTask start;
private BukkitTask prestarts;
private State state;
int time = 0;
int tick = 0;
public Game(Main plugin, String name, int min, int max, int teamSize, int starting, int prestart, int restart,
Location lobby, Location spect, Location buildMin, Location buildMax, Location spawnsRed,
Location spawnsBlue, ArrayList<Location> portalRed, ArrayList<Location> portalBlue, Location respawnsRed,
Location respawnsBlue, Location hRed, Location hBlue) {
this.plugin = plugin;
this.starting = starting;
this.prestart = prestart;
this.restart = restart;
this.max = max;
this.min = min;
this.teamSize = teamSize;
this.mode = teamSize + "v" + teamSize;
this.name = name;
this.lobby = lobby;
this.spect = spect;
this.teamPlayer = new HashMap<>();
this.teams = new HashMap<>();
this.players = new ArrayList<>();
final int gn = Math.min(buildMin.getBlockX(), buildMax.getBlockX());
final int gn2 = Math.max(buildMin.getBlockX(), buildMax.getBlockX());
final int gn3 = Math.min(buildMin.getBlockZ(), buildMax.getBlockZ());
final int gn4 = Math.max(buildMin.getBlockZ(), buildMax.getBlockZ());
final int gn5 = Math.min(buildMin.getBlockY(), buildMax.getBlockY());
final int gn6 = Math.max(buildMin.getBlockY(), buildMax.getBlockY());
for (int i = gn; i <= gn2; ++i)
for (int j = gn5; j <= gn6; ++j)
for (int k = gn3; k <= gn4; ++k) {
final Location location3 = new Location(buildMin.getWorld(), i, j, k);
build.add(location3);
}
this.teams.put(ChatColor.BLUE, new Team(plugin.getConfig().getString("names.blue"), ChatColor.BLUE, Color.BLUE,
respawnsBlue, spawnsBlue, portalBlue, hBlue));
this.teams.put(ChatColor.RED, new Team(plugin.getConfig().getString("names.red"), ChatColor.RED, Color.RED,
respawnsRed, spawnsRed, portalRed, hRed));
setState(State.WAITING);
updateSign();
}
public void checkCancel() {
if (isState(State.STARTING) && players.size() <= getMin()) {
if (start != null)
start.cancel();
if (prestarts != null)
prestarts.cancel();
setState(State.WAITING);
starting = 30;
updateSign();
for (final Player on : players)
updateSB(on);
}
}
public void updateSB(Player p) {
plugin.getSB().update(p);
}
public void updateSign() {
plugin.getSIM().updateGameSign(this);
}
public void addPlayer(Player p) {
pd.put(p, new PlayerData(p));
Utils.setCleanPlayer(p);
players.add(p);
kills.put(p, 0);
goals.put(p, 0);
new BukkitRunnable() {
@Override
public void run() {
givePlayerItems(p);
}
}.runTaskLater(plugin, 20);
p.teleport(getLobby());
updateSign();
if (isState(State.WAITING) || isState(State.STARTING))
for (final Player on : players) {
on.sendMessage(plugin.getLang().get("messages.join").replaceAll("<player>", p.getName())
.replaceAll("<players>", String.valueOf(players.size()))
.replaceAll("<max>", String.valueOf(getMax())));
on.playSound(on.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.join")), 1.0f, 1.0f);
updateSB(on);
}
}
public void removePlayer(Player p) {
Utils.setCleanPlayer(p);
pd.get(p).restore();
removeAllPlayerTeam(p);
players.remove(p);
if (isState(State.WAITING) || isState(State.STARTING))
for (final Player on : players) {
on.sendMessage(plugin.getLang().get("messages.quit").replaceAll("<player>", p.getName())
.replaceAll("<players>", String.valueOf(players.size()))
.replaceAll("<max>", String.valueOf(getMax())));
on.playSound(on.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.quit")), 1.0f, 1.0f);
updateSB(on);
}
else if (getTeamsAlive() == 1 && players.size() >= 1)
checkWin(p, getLastTeam(), getLastTeam().getGoals());
updateSign();
checkCancel();
}
// FIXME: Not properly giving coins
public boolean checkWin(Player w, Team team, int goals) {
if (isState(State.FINISH))
return false;
final DecimalFormat df = new DecimalFormat("#.##");
if (getTeamsAlive() <= 1 && players.size() >= 1) {
final Team win = getLastTeam();
setState(State.FINISH);
firework(getSpect(), win.getFColor());
for (final Player r : win.getTeamPlayers())
PlayerStat.getPlayerStat(r).addNormalWins();
for (final Player p : players) {
p.teleport(lobby);
updateSB(p);
plugin.getNMS().sendTitle(p, 0, 60, 0,
plugin.getLang().get("titles.win.title")
.replaceAll("<blueGoals>", String.valueOf(teams.get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(teams.get(ChatColor.RED).getGoals()))
.replaceAll("<team>", team.getTeamName()).replaceAll("<color>", team.getColor() + ""),
plugin.getLang().get("titles.win.subtitle")
.replaceAll("<blueGoals>", String.valueOf(teams.get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(teams.get(ChatColor.RED).getGoals()))
.replaceAll("<team>", team.getTeamName()).replaceAll("<color>", team.getColor() + ""));
for (final String msg : plugin.getLang().getList("messages.win"))
CenterMessage.sendCenteredMessage(p,
msg.replaceAll("&", "§").replaceAll("<player>", w.getName())
.replaceAll("<blueGoals>", String.valueOf(teams.get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(teams.get(ChatColor.RED).getGoals()))
.replaceAll("<s>", getGoals(w) > 1 ? "es" : "")
.replaceAll("<goals>", String.valueOf(getGoals(w)))
.replaceAll("<health>", df.format(w.getHealth())).replaceAll("<heart>", "❤")
.replaceAll("<color>", "" + team.getColor())
.replaceAll("<team>", win.getTeamName().toUpperCase()));
}
new BukkitRunnable() {
@Override
public void run() {
for (final TruenoHologram th : holograms)
th.delete();
for (final Player p : spect.getWorld().getPlayers())
if (pd.containsKey(p))
plugin.getGM().removePlayerAllGames(p);
else
p.teleport(plugin.getMainLobby());
}
}.runTaskLater(plugin, 20 * 10);
new BukkitRunnable() {
@Override
public void run() {
plugin.getGM().resetNormalGame(getName());
}
}.runTaskLater(plugin, 20 * 12);
updateSign();
return true;
}
if (team.getGoals() >= goals) {
setState(State.FINISH);
final Team win = getLastTeam();
firework(getSpect(), team.getFColor());
for (final Player r : win.getTeamPlayers())
PlayerStat.getPlayerStat(r).addNormalWins();
for (final Player p : players) {
p.teleport(lobby);
plugin.getNMS().sendTitle(p, 0, 60, 0,
plugin.getLang().get("titles.win.title")
.replaceAll("<blueGoals>", String.valueOf(teams.get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(teams.get(ChatColor.RED).getGoals()))
.replaceAll("<team>", team.getTeamName()).replaceAll("<color>", team.getColor() + ""),
plugin.getLang().get("titles.win.subtitle")
.replaceAll("<blueGoals>", String.valueOf(teams.get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(teams.get(ChatColor.RED).getGoals()))
.replaceAll("<team>", team.getTeamName()).replaceAll("<color>", team.getColor() + ""));
for (final String msg : plugin.getLang().getList("messages.win"))
CenterMessage.sendCenteredMessage(p,
msg.replaceAll("&", "§").replaceAll("<player>", w.getName())
.replaceAll("<blueGoals>", String.valueOf(teams.get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(teams.get(ChatColor.RED).getGoals()))
.replaceAll("<s>", getGoals(w) > 1 ? "es" : "")
.replaceAll("<goals>", String.valueOf(getGoals(w)))
.replaceAll("<health>", df.format(w.getHealth())).replaceAll("<heart>", "❤")
.replaceAll("<color>", "" + team.getColor())
.replaceAll("<team>", team.getTeamName().toUpperCase()));
}
new BukkitRunnable() {
@Override
public void run() {
for (final Player p : spect.getWorld().getPlayers())
if (pd.containsKey(p))
plugin.getGM().removePlayerAllGames(p);
else
p.teleport(plugin.getMainLobby());
}
}.runTaskLater(plugin, 20 * 10);
new BukkitRunnable() {
@Override
public void run() {
plugin.getGM().resetNormalGame(getName());
}
}.runTaskLater(plugin, 20 * 12);
updateSign();
return true;
}
return false;
}
public void celebrateGoal(Team team, Player e) {
restart = 5;
team.addGoal();
addGoal(e);
PlayerStat.getPlayerStat(e).addNormalGoals();
if (checkWin(e, team, 5))
return;
firework(getSpect(), team.getFColor());
if (plugin.isCage()) {
for (final Team te : teams.values())
if (!te.isCage())
if (te.getTeamPlayers().get(0) != null) {
te.createCage(plugin.getCM()
.getCageByName(PlayerStat.getPlayerStat(te.getTeamPlayers().get(0)).getCage()));
te.setCage(true);
} else {
te.createCage(plugin.getCM().getCageByName(plugin.getConfig().getString("defaultCage")));
te.setCage(true);
}
} else
for (final ChatColor color : teams.keySet())
plugin.getGLM().createCage(teams.get(color).getTeamSpawn(), color);
for (final Player p : players) {
p.teleport(getTeamPlayer(p).getTeamSpawn().clone().add(0, 1, 0));
updateSB(p);
}
checkRestart(team, team.getColor(), e);
}
public void firework(Location loc, Color c1) {
time = 0;
new BukkitRunnable() {
@Override
public void run() {
final Firework fa = loc.getWorld().spawn(loc.clone().add(new Random().nextInt(5) + 1,
new Random().nextInt(1) + 1, new Random().nextInt(5) + 1), Firework.class);
final FireworkMeta fam = fa.getFireworkMeta();
final FireworkEffect.Type tipo = FireworkEffect.Type.STAR;
final Color c2 = Color.WHITE;
final FireworkEffect ef = FireworkEffect.builder().withColor(c1).withFade(c2).with(tipo).build();
fam.addEffect(ef);
fam.setPower(0);
fa.setFireworkMeta(fam);
time++;
if (time == 10)
cancel();
}
}.runTaskTimer(plugin, 0, 10);
}
public void checkRestart(Team team, ChatColor color, Player e) {
final DecimalFormat df = new DecimalFormat("#.##");
for (final Player p : players) {
Utils.setCleanPlayer(p);
p.setGameMode(GameMode.ADVENTURE);
giveKit(p, getTeamPlayer(p));
for (final String msg : plugin.getLang().getList("messages.goal"))
CenterMessage.sendCenteredMessage(p,
msg.replaceAll("&", "§").replaceAll("<player>", e.getName())
.replaceAll("<blueGoals>", String.valueOf(teams.get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(teams.get(ChatColor.RED).getGoals()))
.replaceAll("<s>", getGoals(e) > 1 ? "es" : "")
.replaceAll("<goals>", String.valueOf(getGoals(e)))
.replaceAll("<health>", df.format(e.getHealth())).replaceAll("<heart>", "❤")
.replaceAll("<color>", "" + team.getColor())
.replaceAll("<team>", team.getTeamName().toUpperCase()));
}
new BukkitRunnable() {
@Override
public void run() {
if (restart == 10 || restart == 5 || restart == 4 || restart == 3 || restart == 2)
for (final Player p : players) {
p.sendMessage(plugin.getLang().get(p, "messages.restart").replaceAll("<color>", "" + color)
.replaceAll("<player>", e.getName()).replaceAll("<time>", String.valueOf(restart))
.replaceAll("<s>", "s")
.replaceAll("<units>", plugin.getLang().get(p, "units.seconds")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.restart")), 1.0f,
1.0f);
plugin.getTM().sendReStartTitle(e, p, restart, true);
}
if (restart == 1)
for (final Player p : players) {
p.sendMessage(plugin.getLang().get(p, "messages.restart").replaceAll("<color>", "" + color)
.replaceAll("<player>", e.getName()).replaceAll("<time>", String.valueOf(restart))
.replaceAll("<s>", "").replaceAll("<units>", plugin.getLang().get(p, "units.second")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.restart")), 1.0f,
1.0f);
plugin.getTM().sendReStartTitle(e, p, restart, false);
}
if (restart == 0) {
if (plugin.isCage()) {
for (final Team team : teams.values())
if (team.isCage()) {
team.removeCage();
team.setCage(false);
}
} else
for (final ChatColor color : teams.keySet())
plugin.getGLM().removeGlass(teams.get(color).getTeamSpawn());
for (final Player p : players)
p.setGameMode(GameMode.SURVIVAL);
cancel();
}
restart--;
}
}.runTaskTimer(get(), 0, 20);
}
public void updateGame() {
tick++;
if (isState(State.WAITING) && players.size() >= getMin()) {
setState(State.STARTING);
updateSign();
for (final Player p : players)
p.setGameMode(GameMode.ADVENTURE);
}
if (isState(State.STARTING)) {
if (tick % 20 == 0)
for (final Player p : players)
updateSB(p);
if (starting == 240 || starting == 180 || starting == 120)
for (final Player p : players) {
p.sendMessage(plugin.getLang().get(p, "messages.starting")
.replaceAll("<time>", String.valueOf(starting / 60))
.replaceAll("<units>", plugin.getLang().get(p, "units.minutes")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.starting")), 1.0f,
1.0f);
plugin.getTM().sendStartTitle(p, starting, true);
}
else if (starting == 60)
for (final Player p : players) {
p.sendMessage(plugin.getLang().get(p, "messages.starting")
.replaceAll("<time>", String.valueOf(starting / 60))
.replaceAll("<units>", plugin.getLang().get(p, "units.minute")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.starting")), 1.0f,
1.0f);
plugin.getTM().sendStartTitle(p, starting, true);
}
else if (starting == 30 || starting == 15 || starting == 10 || starting == 5 || starting == 4
|| starting == 3 || starting == 2)
for (final Player p : players) {
p.sendMessage(
plugin.getLang().get(p, "messages.starting").replaceAll("<time>", String.valueOf(starting))
.replaceAll("<units>", plugin.getLang().get(p, "units.seconds")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.starting")), 1.0f,
1.0f);
plugin.getTM().sendStartTitle(p, starting, true);
}
else if (starting == 1) {
setState(State.PREGAME);
updateSign();
for (final Player p : players) {
p.sendMessage(
plugin.getLang().get(p, "messages.starting").replaceAll("<time>", String.valueOf(starting))
.replaceAll("<units>", plugin.getLang().get(p, "units.second")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.starting")), 1.0f,
1.0f);
plugin.getTM().sendStartTitle(p, starting, false);
if (getTeamPlayer(p) == null)
addRandomTeam(p);
p.getInventory().clear();
}
if (plugin.isCage()) {
for (final Team team : teams.values())
if (!team.isCage())
if (team.getTeamPlayers().get(0) != null) {
team.createCage(plugin.getCM().getCageByName(
PlayerStat.getPlayerStat(team.getTeamPlayers().get(0)).getCage()));
team.setCage(true);
} else {
team.createCage(
plugin.getCM().getCageByName(plugin.getConfig().getString("defaultCage")));
team.setCage(true);
}
} else
for (final ChatColor color : teams.keySet())
plugin.getGLM().createCage(teams.get(color).getTeamSpawn(), color);
for (final Player p : players) {
p.teleport(getTeamPlayer(p).getTeamSpawn().clone().add(0, 1, 0));
giveKit(p, getTeamPlayer(p));
}
final Location hRed = teams.get(ChatColor.RED).getHologram();
final Location hBlue = teams.get(ChatColor.BLUE).getHologram();
if (hRed != null && hBlue != null) {
for (final Player p : teams.get(ChatColor.RED).getTeamPlayers()) {
final ArrayList<String> pRed = new ArrayList<>();
final TruenoHologram phRed = TruenoHologramAPI.getNewHologram();
for (final String portal : plugin.getLang().getList("holograms.portal.you"))
pRed.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.RED)
.replaceAll("<team>", plugin.getLang().get("holograms.your")));
final ArrayList<String> pBlue = new ArrayList<>();
final TruenoHologram phBlue = TruenoHologramAPI.getNewHologram();
for (final String portal : plugin.getLang().getList("holograms.portal.enemy"))
pBlue.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.BLUE)
.replaceAll("<team>", teams.get(ChatColor.BLUE).getTeamName()));
phBlue.setupPlayerHologram(p, hBlue, pBlue);
phBlue.display();
phRed.setupPlayerHologram(p, hRed, pRed);
phRed.display();
holograms.add(phRed);
holograms.add(phBlue);
}
for (final Player p : teams.get(ChatColor.BLUE).getTeamPlayers()) {
final ArrayList<String> pRed = new ArrayList<>();
final TruenoHologram phRed = TruenoHologramAPI.getNewHologram();
for (final String portal : plugin.getLang().getList("holograms.portal.you"))
pRed.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.BLUE)
.replaceAll("<team>", plugin.getLang().get("holograms.your")));
final ArrayList<String> pBlue = new ArrayList<>();
final TruenoHologram phBlue = TruenoHologramAPI.getNewHologram();
for (final String portal : plugin.getLang().getList("holograms.portal.enemy"))
pBlue.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.RED)
.replaceAll("<team>", teams.get(ChatColor.RED).getTeamName()));
phBlue.setupPlayerHologram(p, hRed, pBlue);
phBlue.display();
phRed.setupPlayerHologram(p, hBlue, pRed);
phRed.display();
holograms.add(phRed);
holograms.add(phBlue);
}
}
teams.get(ChatColor.RED).createPortal();
teams.get(ChatColor.BLUE).createPortal();
}
starting--;
}
if (isState(State.PREGAME)) {
if (prestart == 10 || prestart == 5 || prestart == 4 || prestart == 3 || prestart == 2)
for (final Player p : players) {
p.sendMessage(
plugin.getLang().get(p, "messages.prestart").replaceAll("<time>", String.valueOf(prestart))
.replaceAll("<units>", plugin.getLang().get(p, "units.seconds")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.prestart")), 1.0f,
1.0f);
plugin.getTM().sendPreTitle(p, prestart, true);
updateSB(p);
}
else if (prestart == 1)
for (final Player p : players) {
p.sendMessage(
plugin.getLang().get(p, "messages.prestart").replaceAll("<time>", String.valueOf(prestart))
.replaceAll("<units>", plugin.getLang().get(p, "units.second")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.prestart")), 1.0f,
1.0f);
plugin.getTM().sendPreTitle(p, prestart, false);
for (final String msg : plugin.getLang().getList("messages.start"))
CenterMessage.sendCenteredMessage(p, msg.replaceAll("&", "§"));
updateSB(p);
}
else if (prestart == 0) {
setState(State.INGAME);
updateSign();
if (plugin.isCage()) {
for (final Team team : teams.values())
if (team.isCage()) {
team.removeCage();
team.setCage(false);
}
} else
for (final ChatColor color : teams.keySet())
plugin.getGLM().removeGlass(teams.get(color).getTeamSpawn());
for (final Player p : players) {
updateSB(p);
p.setGameMode(GameMode.SURVIVAL);
}
}
prestart--;
}
}
public Team getTeamPlayer(Player p) {
return teams.get(teamPlayer.get(p));
}
public void addPlayerTeam(Player p, Team t) {
t.addPlayer(p);
teamPlayer.put(p, t.getColor());
}
public void addRandomTeam(Player p) {
final Team red = teams.get(ChatColor.RED);
final Team blue = teams.get(ChatColor.BLUE);
if (red.getTeamSize() <= blue.getTeamSize()) {
red.addPlayer(p);
teamPlayer.put(p, red.getColor());
} else {
blue.addPlayer(p);
teamPlayer.put(p, blue.getColor());
}
}
public void removeAllPlayerTeam(Player p) {
for (final Team t : teams.values())
if (t.getTeamPlayers().contains(p))
t.removePlayer(p);
}
public ArrayList<Location> getBuild() {
return build;
}
public HashMap<ChatColor, Team> getTeams() {
return teams;
}
public int getTeamsAlive() {
int cantidad = 0;
for (final Team team : teams.values())
if (team.getTeamSize() > 0)
cantidad++;
return cantidad;
}
public Team getLastTeam() {
for (final Team team : teams.values())
if (team.getTeamSize() > 0)
return team;
return null;
}
public int getPlayers() {
return players.size();
}
public ArrayList<Player> getGamePlayers() {
return players;
}
public String getName() {
return this.name;
}
public int getMax() {
return this.max;
}
public String getMode() {
return mode;
}
public int getMin() {
return this.min;
}
public Main get() {
return plugin;
}
public State getState() {
return this.state;
}
public void setState(State state) {
this.state = state;
}
public boolean isState(State state) {
if (this.state == state)
return true;
return false;
}
public enum State {
WAITING, STARTING, PPGAME, PREGAME, INGAME, FINISH, RESTARTING;
}
public int getGoals(Player p) {
return goals.get(p);
}
public int getKills(Player p) {
return kills.get(p);
}
public void addGoal(Player p) {
goals.put(p, goals.get(p) + 1);
updateSB(p);
}
public void addKill(Player p) {
kills.put(p, kills.get(p) + 1);
updateSB(p);
}
public void giveKit(Player p, Team team) {
final ItemStack helmet = new ItemStack(Material.LEATHER_HELMET, 1);
final LeatherArmorMeta helmetM = (LeatherArmorMeta) helmet.getItemMeta();
helmetM.setColor(team.getFColor());
helmet.setItemMeta(helmetM);
final ItemStack peche = new ItemStack(Material.LEATHER_CHESTPLATE, 1);
final LeatherArmorMeta pecheM = (LeatherArmorMeta) peche.getItemMeta();
pecheM.setColor(team.getFColor());
peche.setItemMeta(pecheM);
final ItemStack panta = new ItemStack(Material.IRON_LEGGINGS, 1);
final ItemMeta pantaM = panta.getItemMeta();
panta.setItemMeta(pantaM);
final ItemStack boots = new ItemStack(Material.IRON_BOOTS, 1);
final ItemMeta bootsM = boots.getItemMeta();
boots.setItemMeta(bootsM);
p.getInventory().setHelmet(helmet);
p.getInventory().setChestplate(peche);
p.getInventory().setLeggings(panta);
p.getInventory().setBoots(boots);
if (PlayerStat.getPlayerStat(p).getHotbar() == null) {
final ItemStack[] items = plugin.getGM().getKit().getContents();
for (int slot = 0; slot < 35; slot++) {
final ItemStack item = items[slot];
if (item == null || item.getType() == Material.BARRIER) {
p.getInventory().setItem(slot, new ItemStack(Material.AIR));
continue;
}
if (item.getType().equals(Material.STAINED_CLAY)) {
final ItemStack item2 = new ItemStack(item.getType(), item.getAmount(), getColor(team.getFColor()));
p.getInventory().setItem(slot, item2);
continue;
}
p.getInventory().setItem(slot, item);
}
} else {
final ItemStack[] items = PlayerStat.getPlayerStat(p).getHotbar();
for (int slot = 0; slot < 35; slot++) {
final ItemStack item = items[slot];
if (item == null || item.getType() == Material.BARRIER) {
p.getInventory().setItem(slot, new ItemStack(Material.AIR));
continue;
}
if (item.getType().equals(Material.STAINED_CLAY)) {
final ItemStack item2 = new ItemStack(item.getType(), item.getAmount(), getColor(team.getFColor()));
p.getInventory().setItem(slot, item2);
continue;
}
p.getInventory().setItem(slot, item);
}
}
}
public void givePlayerItems(Player p) {
if (teamSize > 1) {
final ItemStack team = ItemBuilder.item(Material.PAPER, 1, (short) 0,
plugin.getLang().get("items.teams.nameItem"), plugin.getLang().get("items.teams.loreItem"));
p.getInventory().setItem(0, team);
}
final ItemStack leave = ItemBuilder.item(Material.BED, 1, (short) 0,
plugin.getLang().get("items.leave.nameItem"),
plugin.getLang().get("items.leave.loreItem"));
p.getInventory().setItem(8, leave);
}
public byte getColor(Color color) {
if (color.equals(Color.RED))
return 14;
if (color.equals(Color.BLUE))
return 11;
return 0;
}
public int getTeamSize() {
return teamSize;
}
public void addPlace(Location loc) {
placed.add(loc);
}
public ArrayList<Location> getPlaced() {
return placed;
}
public int getStarting() {
return starting;
}
public Location getLobby() {
return lobby;
}
public Location getSpect() {
return spect;
}
public HashMap<Player, PlayerData> getPD() {
return pd;
}
}
}

754
MultiArena-TheBridge/src/cx/sfy/TheBridge/game/GameDuo.java

@ -0,0 +1,754 @@
package cx.sfy.TheBridge.game;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.database.PlayerStat;
import cx.sfy.TheBridge.hologram.TruenoHologram;
import cx.sfy.TheBridge.hologram.TruenoHologramAPI;
import cx.sfy.TheBridge.team.TeamDuo;
import cx.sfy.TheBridge.utils.CenterMessage;
import cx.sfy.TheBridge.utils.ItemBuilder;
import cx.sfy.TheBridge.utils.Utils;
public class GameDuo {
private final Main plugin;
private final HashMap<ChatColor, TeamDuo> teams;
private final HashMap<Player, ChatColor> teamPlayer;
private final ArrayList<Player> players;
private final HashMap<Player, PlayerData> pd = new HashMap<>();
private final HashMap<Player, Integer> goals = new HashMap<>();
private final HashMap<Player, Integer> kills = new HashMap<>();
private final ArrayList<TruenoHologram> holograms = new ArrayList<>();
private final ArrayList<Location> build = new ArrayList<>();
private final ArrayList<Location> placed = new ArrayList<>();
private final String name;
private final String mode;
private final int min;
private final int max;
private final int teamSize;
private int starting;
private int prestart;
private int restart;
private final Location lobby;
private final Location spect;
private BukkitTask start;
private BukkitTask prestarts;
private State state;
int time = 0;
int tick = 0;
public GameDuo(Main plugin, String name, int min, int max, int teamSize, int starting, int prestart, int restart,
Location lobby, Location spect, Location buildMin, Location buildMax, Location spawnsRed,
Location spawnsBlue, ArrayList<Location> portalRed, ArrayList<Location> portalBlue, Location respawnsRed,
Location respawnsBlue, Location hRed, Location hBlue) {
this.plugin = plugin;
this.starting = starting;
this.prestart = prestart;
this.restart = restart;
this.max = max;
this.min = min;
this.teamSize = teamSize;
this.mode = teamSize + "v" + teamSize;
this.name = name;
this.lobby = lobby;
this.spect = spect;
this.teamPlayer = new HashMap<>();
this.teams = new HashMap<>();
this.players = new ArrayList<>();
final int gn = Math.min(buildMin.getBlockX(), buildMax.getBlockX());
final int gn2 = Math.max(buildMin.getBlockX(), buildMax.getBlockX());
final int gn3 = Math.min(buildMin.getBlockZ(), buildMax.getBlockZ());
final int gn4 = Math.max(buildMin.getBlockZ(), buildMax.getBlockZ());
final int gn5 = Math.min(buildMin.getBlockY(), buildMax.getBlockY());
final int gn6 = Math.max(buildMin.getBlockY(), buildMax.getBlockY());
for (int i = gn; i <= gn2; ++i)
for (int j = gn5; j <= gn6; ++j)
for (int k = gn3; k <= gn4; ++k) {
final Location location3 = new Location(buildMin.getWorld(), i, j, k);
build.add(location3);
}
this.teams.put(ChatColor.BLUE, new TeamDuo(plugin.getConfig().getString("names.blue"), ChatColor.BLUE, Color.BLUE,
respawnsBlue, spawnsBlue, portalBlue, hBlue));
this.teams.put(ChatColor.RED, new TeamDuo(plugin.getConfig().getString("names.red"), ChatColor.RED, Color.RED,
respawnsRed, spawnsRed, portalRed, hRed));
setState(State.WAITING);
updateSign();
}
public void checkCancel() {
if (isState(State.STARTING) && players.size() <= getMin()) {
if (start != null)
start.cancel();
if (prestarts != null)
prestarts.cancel();
setState(State.WAITING);
starting = 30;
updateSign();
for (final Player on : players)
updateSB(on);
}
}
public void updateSB(Player p) {
plugin.getSB().update(p);
}
public void updateSign() {
plugin.getSIM().updateGameSign(this);
}
public void addPlayer(Player p) {
pd.put(p, new PlayerData(p));
Utils.setCleanPlayer(p);
players.add(p);
kills.put(p, 0);
goals.put(p, 0);
new BukkitRunnable() {
@Override
public void run() {
givePlayerItems(p);
}
}.runTaskLater(plugin, 20);
p.teleport(getLobby());
updateSign();
if (isState(State.WAITING) || isState(State.STARTING))
for (final Player on : players) {
on.sendMessage(plugin.getLang().get("messages.join").replaceAll("<player>", p.getName())
.replaceAll("<players>", String.valueOf(players.size()))
.replaceAll("<max>", String.valueOf(getMax())));
on.playSound(on.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.join")), 1.0f, 1.0f);
updateSB(on);
}
}
public void removePlayer(Player p) {
Utils.setCleanPlayer(p);
pd.get(p).restore();
removeAllPlayerTeam(p);
players.remove(p);
if (isState(State.WAITING) || isState(State.STARTING))
for (final Player on : players) {
on.sendMessage(plugin.getLang().get("messages.quit").replaceAll("<player>", p.getName())
.replaceAll("<players>", String.valueOf(players.size()))
.replaceAll("<max>", String.valueOf(getMax())));
on.playSound(on.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.quit")), 1.0f, 1.0f);
updateSB(on);
}
else if (getTeamsAlive() == 1 && players.size() >= 1)
checkWin(p, getLastTeam(), getLastTeam().getGoals());
updateSign();
checkCancel();
}
// FIXME: Not properly giving coins
public boolean checkWin(Player w, TeamDuo team, int goals) {
if (isState(State.FINISH))
return false;
final DecimalFormat df = new DecimalFormat("#.##");
if (getTeamsAlive() <= 1 && players.size() >= 1) {
final TeamDuo win = getLastTeam();
setState(State.FINISH);
firework(getSpect(), win.getFColor());
for (final Player r : win.getTeamPlayers())
PlayerStat.getPlayerStat(r).addNormalWins();
for (final Player p : players) {
p.teleport(lobby);
updateSB(p);
plugin.getNMS().sendTitle(p, 0, 60, 0,
plugin.getLang().get("titles.win.title")
.replaceAll("<blueGoals>", String.valueOf(teams.get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(teams.get(ChatColor.RED).getGoals()))
.replaceAll("<team>", team.getTeamName()).replaceAll("<color>", team.getColor() + ""),
plugin.getLang().get("titles.win.subtitle")
.replaceAll("<blueGoals>", String.valueOf(teams.get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(teams.get(ChatColor.RED).getGoals()))
.replaceAll("<team>", team.getTeamName()).replaceAll("<color>", team.getColor() + ""));
for (final String msg : plugin.getLang().getList("messages.win"))
CenterMessage.sendCenteredMessage(p,
msg.replaceAll("&", "§").replaceAll("<player>", w.getName())
.replaceAll("<blueGoals>", String.valueOf(teams.get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(teams.get(ChatColor.RED).getGoals()))
.replaceAll("<s>", getGoals(w) > 1 ? "es" : "")
.replaceAll("<goals>", String.valueOf(getGoals(w)))
.replaceAll("<health>", df.format(w.getHealth())).replaceAll("<heart>", "❤")
.replaceAll("<color>", "" + team.getColor())
.replaceAll("<team>", win.getTeamName().toUpperCase()));
}
new BukkitRunnable() {
@Override
public void run() {
for (final TruenoHologram th : holograms)
th.delete();
for (final Player p : spect.getWorld().getPlayers())
if (pd.containsKey(p))
plugin.getGM().removePlayerAllGames(p);
else
p.teleport(plugin.getMainLobby());
}
}.runTaskLater(plugin, 20 * 10);
new BukkitRunnable() {
@Override
public void run() {
plugin.getGM().resetNormalGame(getName());
}
}.runTaskLater(plugin, 20 * 12);
updateSign();
return true;
}
if (team.getGoals() >= goals) {
setState(State.FINISH);
final TeamDuo win = getLastTeam();
firework(getSpect(), team.getFColor());
for (final Player r : win.getTeamPlayers())
PlayerStat.getPlayerStat(r).addNormalWins();
for (final Player p : players) {
p.teleport(lobby);
plugin.getNMS().sendTitle(p, 0, 60, 0,
plugin.getLang().get("titles.win.title")
.replaceAll("<blueGoals>", String.valueOf(teams.get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(teams.get(ChatColor.RED).getGoals()))
.replaceAll("<team>", team.getTeamName()).replaceAll("<color>", team.getColor() + ""),
plugin.getLang().get("titles.win.subtitle")
.replaceAll("<blueGoals>", String.valueOf(teams.get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(teams.get(ChatColor.RED).getGoals()))
.replaceAll("<team>", team.getTeamName()).replaceAll("<color>", team.getColor() + ""));
for (final String msg : plugin.getLang().getList("messages.win"))
CenterMessage.sendCenteredMessage(p,
msg.replaceAll("&", "§").replaceAll("<player>", w.getName())
.replaceAll("<blueGoals>", String.valueOf(teams.get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(teams.get(ChatColor.RED).getGoals()))
.replaceAll("<s>", getGoals(w) > 1 ? "es" : "")
.replaceAll("<goals>", String.valueOf(getGoals(w)))
.replaceAll("<health>", df.format(w.getHealth())).replaceAll("<heart>", "❤")
.replaceAll("<color>", "" + team.getColor())
.replaceAll("<team>", team.getTeamName().toUpperCase()));
}
new BukkitRunnable() {
@Override
public void run() {
for (final Player p : spect.getWorld().getPlayers())
if (pd.containsKey(p))
plugin.getGM().removePlayerAllGames(p);
else
p.teleport(plugin.getMainLobby());
}
}.runTaskLater(plugin, 20 * 10);
new BukkitRunnable() {
@Override
public void run() {
plugin.getGM().resetNormalGame(getName());
}
}.runTaskLater(plugin, 20 * 12);
updateSign();
return true;
}
return false;
}
public void celebrateGoal(TeamDuo team, Player e) {
restart = 5;
team.addGoal();
addGoal(e);
PlayerStat.getPlayerStat(e).addNormalGoals();
if (checkWin(e, team, 5))
return;
firework(getSpect(), team.getFColor());
if (plugin.isCage()) {
for (final TeamDuo te : teams.values())
if (!te.isCage())
if (te.getTeamPlayers().get(0) != null) {
te.createCage(plugin.getCM()
.getCageByName(PlayerStat.getPlayerStat(te.getTeamPlayers().get(0)).getCage()));
te.setCage(true);
} else {
te.createCage(plugin.getCM().getCageByName(plugin.getConfig().getString("defaultCage")));
te.setCage(true);
}
} else
for (final ChatColor color : teams.keySet())
plugin.getGLM().createCage(teams.get(color).getTeamSpawn(), color);
for (final Player p : players) {
p.teleport(getTeamPlayer(p).getTeamSpawn().clone().add(0, 1, 0));
updateSB(p);
}
checkRestart(team, team.getColor(), e);
}
public void firework(Location loc, Color c1) {
time = 0;
new BukkitRunnable() {
@Override
public void run() {
final Firework fa = loc.getWorld().spawn(loc.clone().add(new Random().nextInt(5) + 1,
new Random().nextInt(1) + 1, new Random().nextInt(5) + 1), Firework.class);
final FireworkMeta fam = fa.getFireworkMeta();
final FireworkEffect.Type tipo = FireworkEffect.Type.STAR;
final Color c2 = Color.WHITE;
final FireworkEffect ef = FireworkEffect.builder().withColor(c1).withFade(c2).with(tipo).build();
fam.addEffect(ef);
fam.setPower(0);
fa.setFireworkMeta(fam);
time++;
if (time == 10)
cancel();
}
}.runTaskTimer(plugin, 0, 10);
}
public void checkRestart(TeamDuo team, ChatColor color, Player e) {
final DecimalFormat df = new DecimalFormat("#.##");
for (final Player p : players) {
Utils.setCleanPlayer(p);
p.setGameMode(GameMode.ADVENTURE);
giveKit(p, getTeamPlayer(p));
for (final String msg : plugin.getLang().getList("messages.goal"))
CenterMessage.sendCenteredMessage(p,
msg.replaceAll("&", "§").replaceAll("<player>", e.getName())
.replaceAll("<blueGoals>", String.valueOf(teams.get(ChatColor.BLUE).getGoals()))
.replaceAll("<redGoals>", String.valueOf(teams.get(ChatColor.RED).getGoals()))
.replaceAll("<s>", getGoals(e) > 1 ? "es" : "")
.replaceAll("<goals>", String.valueOf(getGoals(e)))
.replaceAll("<health>", df.format(e.getHealth())).replaceAll("<heart>", "❤")
.replaceAll("<color>", "" + team.getColor())
.replaceAll("<team>", team.getTeamName().toUpperCase()));
}
new BukkitRunnable() {
@Override
public void run() {
if (restart == 10 || restart == 5 || restart == 4 || restart == 3 || restart == 2)
for (final Player p : players) {
p.sendMessage(plugin.getLang().get(p, "messages.restart").replaceAll("<color>", "" + color)
.replaceAll("<player>", e.getName()).replaceAll("<time>", String.valueOf(restart))
.replaceAll("<s>", "s")
.replaceAll("<units>", plugin.getLang().get(p, "units.seconds")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.restart")), 1.0f,
1.0f);
plugin.getTM().sendReStartTitle(e, p, restart, true);
}
if (restart == 1)
for (final Player p : players) {
p.sendMessage(plugin.getLang().get(p, "messages.restart").replaceAll("<color>", "" + color)
.replaceAll("<player>", e.getName()).replaceAll("<time>", String.valueOf(restart))
.replaceAll("<s>", "").replaceAll("<units>", plugin.getLang().get(p, "units.second")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.restart")), 1.0f,
1.0f);
plugin.getTM().sendReStartTitle(e, p, restart, false);
}
if (restart == 0) {
if (plugin.isCage()) {
for (final TeamDuo team : teams.values())
if (team.isCage()) {
team.removeCage();
team.setCage(false);
}
} else
for (final ChatColor color : teams.keySet())
plugin.getGLM().removeGlass(teams.get(color).getTeamSpawn());
for (final Player p : players)
p.setGameMode(GameMode.SURVIVAL);
cancel();
}
restart--;
}
}.runTaskTimer(get(), 0, 20);
}
public void updateGame() {
tick++;
if (isState(State.WAITING) && players.size() >= getMin()) {
setState(State.STARTING);
updateSign();
for (final Player p : players)
p.setGameMode(GameMode.ADVENTURE);
}
if (isState(State.STARTING)) {
if (tick % 20 == 0)
for (final Player p : players)
updateSB(p);
if (starting == 240 || starting == 180 || starting == 120)
for (final Player p : players) {
p.sendMessage(plugin.getLang().get(p, "messages.starting")
.replaceAll("<time>", String.valueOf(starting / 60))
.replaceAll("<units>", plugin.getLang().get(p, "units.minutes")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.starting")), 1.0f,
1.0f);
plugin.getTM().sendStartTitle(p, starting, true);
}
else if (starting == 60)
for (final Player p : players) {
p.sendMessage(plugin.getLang().get(p, "messages.starting")
.replaceAll("<time>", String.valueOf(starting / 60))
.replaceAll("<units>", plugin.getLang().get(p, "units.minute")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.starting")), 1.0f,
1.0f);
plugin.getTM().sendStartTitle(p, starting, true);
}
else if (starting == 30 || starting == 15 || starting == 10 || starting == 5 || starting == 4
|| starting == 3 || starting == 2)
for (final Player p : players) {
p.sendMessage(
plugin.getLang().get(p, "messages.starting").replaceAll("<time>", String.valueOf(starting))
.replaceAll("<units>", plugin.getLang().get(p, "units.seconds")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.starting")), 1.0f,
1.0f);
plugin.getTM().sendStartTitle(p, starting, true);
}
else if (starting == 1) {
setState(State.PREGAME);
updateSign();
for (final Player p : players) {
p.sendMessage(
plugin.getLang().get(p, "messages.starting").replaceAll("<time>", String.valueOf(starting))
.replaceAll("<units>", plugin.getLang().get(p, "units.second")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.starting")), 1.0f,
1.0f);
plugin.getTM().sendStartTitle(p, starting, false);
if (getTeamPlayer(p) == null)
addRandomTeam(p);
p.getInventory().clear();
}
if (plugin.isCage()) {
for (final TeamDuo team : teams.values())
if (!team.isCage())
if (team.getTeamPlayers().get(0) != null) {
team.createCage(plugin.getCM().getCageByName(
PlayerStat.getPlayerStat(team.getTeamPlayers().get(0)).getCage()));
team.setCage(true);
} else {
team.createCage(
plugin.getCM().getCageByName(plugin.getConfig().getString("defaultCage")));
team.setCage(true);
}
} else
for (final ChatColor color : teams.keySet())
plugin.getGLM().createCage(teams.get(color).getTeamSpawn(), color);
for (final Player p : players) {
p.teleport(getTeamPlayer(p).getTeamSpawn().clone().add(0, 1, 0));
giveKit(p, getTeamPlayer(p));
}
final Location hRed = teams.get(ChatColor.RED).getHologram();
final Location hBlue = teams.get(ChatColor.BLUE).getHologram();
if (hRed != null && hBlue != null) {
for (final Player p : teams.get(ChatColor.RED).getTeamPlayers()) {
final ArrayList<String> pRed = new ArrayList<>();
final TruenoHologram phRed = TruenoHologramAPI.getNewHologram();
for (final String portal : plugin.getLang().getList("holograms.portal.you"))
pRed.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.RED)
.replaceAll("<team>", plugin.getLang().get("holograms.your")));
final ArrayList<String> pBlue = new ArrayList<>();
final TruenoHologram phBlue = TruenoHologramAPI.getNewHologram();
for (final String portal : plugin.getLang().getList("holograms.portal.enemy"))
pBlue.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.BLUE)
.replaceAll("<team>", teams.get(ChatColor.BLUE).getTeamName()));
phBlue.setupPlayerHologram(p, hBlue, pBlue);
phBlue.display();
phRed.setupPlayerHologram(p, hRed, pRed);
phRed.display();
holograms.add(phRed);
holograms.add(phBlue);
}
for (final Player p : teams.get(ChatColor.BLUE).getTeamPlayers()) {
final ArrayList<String> pRed = new ArrayList<>();
final TruenoHologram phRed = TruenoHologramAPI.getNewHologram();
for (final String portal : plugin.getLang().getList("holograms.portal.you"))
pRed.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.BLUE)
.replaceAll("<team>", plugin.getLang().get("holograms.your")));
final ArrayList<String> pBlue = new ArrayList<>();
final TruenoHologram phBlue = TruenoHologramAPI.getNewHologram();
for (final String portal : plugin.getLang().getList("holograms.portal.enemy"))
pBlue.add(portal.replaceAll("&", "§").replaceAll("<color>", "" + ChatColor.RED)
.replaceAll("<team>", teams.get(ChatColor.RED).getTeamName()));
phBlue.setupPlayerHologram(p, hRed, pBlue);
phBlue.display();
phRed.setupPlayerHologram(p, hBlue, pRed);
phRed.display();
holograms.add(phRed);
holograms.add(phBlue);
}
}
teams.get(ChatColor.RED).createPortal();
teams.get(ChatColor.BLUE).createPortal();
}
starting--;
}
if (isState(State.PREGAME)) {
if (prestart == 10 || prestart == 5 || prestart == 4 || prestart == 3 || prestart == 2)
for (final Player p : players) {
p.sendMessage(
plugin.getLang().get(p, "messages.prestart").replaceAll("<time>", String.valueOf(prestart))
.replaceAll("<units>", plugin.getLang().get(p, "units.seconds")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.prestart")), 1.0f,
1.0f);
plugin.getTM().sendPreTitle(p, prestart, true);
updateSB(p);
}
else if (prestart == 1)
for (final Player p : players) {
p.sendMessage(
plugin.getLang().get(p, "messages.prestart").replaceAll("<time>", String.valueOf(prestart))
.replaceAll("<units>", plugin.getLang().get(p, "units.second")));
p.playSound(p.getLocation(), Sound.valueOf(plugin.getSounds().get("sounds.game.prestart")), 1.0f,
1.0f);
plugin.getTM().sendPreTitle(p, prestart, false);
for (final String msg : plugin.getLang().getList("messages.start"))
CenterMessage.sendCenteredMessage(p, msg.replaceAll("&", "§"));
updateSB(p);
}
else if (prestart == 0) {
setState(State.INGAME);
updateSign();
if (plugin.isCage()) {
for (final TeamDuo team : teams.values())
if (team.isCage()) {
team.removeCage();
team.setCage(false);
}
} else
for (final ChatColor color : teams.keySet())
plugin.getGLM().removeGlass(teams.get(color).getTeamSpawn());
for (final Player p : players) {
updateSB(p);
p.setGameMode(GameMode.SURVIVAL);
}
}
prestart--;
}
}
public TeamDuo getTeamPlayer(Player p) {
return teams.get(teamPlayer.get(p));
}
public void addPlayerTeam(Player p, TeamDuo t) {
t.addPlayer(p);
teamPlayer.put(p, t.getColor());
}
public void addRandomTeam(Player p) {
final TeamDuo red = teams.get(ChatColor.RED);
final TeamDuo blue = teams.get(ChatColor.BLUE);
if (red.getTeamSize() <= blue.getTeamSize()) {
red.addPlayer(p);
teamPlayer.put(p, red.getColor());
} else {
blue.addPlayer(p);
teamPlayer.put(p, blue.getColor());
}
}
public void removeAllPlayerTeam(Player p) {
for (final TeamDuo t : teams.values())
if (t.getTeamPlayers().contains(p))
t.removePlayer(p);
}
public ArrayList<Location> getBuild() {
return build;
}
public HashMap<ChatColor, TeamDuo> getTeams() {
return teams;
}
public int getTeamsAlive() {
int cantidad = 0;
for (final TeamDuo team : teams.values())
if (team.getTeamSize() > 0)
cantidad++;
return cantidad;
}
public TeamDuo getLastTeam() {
for (final TeamDuo team : teams.values())
if (team.getTeamSize() > 0)
return team;
return null;
}
public int getPlayers() {
return players.size();
}
public ArrayList<Player> getGamePlayers() {
return players;
}
public String getName() {
return this.name;
}
public int getMax() {
return this.max;
}
public String getMode() {
return mode;
}
public int getMin() {
return this.min;
}
public Main get() {
return plugin;
}
public State getState() {
return this.state;
}
public void setState(State state) {
this.state = state;
}
public boolean isState(State state) {
if (this.state == state)
return true;
return false;
}
public enum State {
WAITING, STARTING, PPGAME, PREGAME, INGAME, FINISH, RESTARTING;
}
public int getGoals(Player p) {
return goals.get(p);
}
public int getKills(Player p) {
return kills.get(p);
}
public void addGoal(Player p) {
goals.put(p, goals.get(p) + 1);
updateSB(p);
}
public void addKill(Player p) {
kills.put(p, kills.get(p) + 1);
updateSB(p);
}
public void giveKit(Player p, TeamDuo team) {
final ItemStack helmet = new ItemStack(Material.LEATHER_HELMET, 1);
final LeatherArmorMeta helmetM = (LeatherArmorMeta) helmet.getItemMeta();
helmetM.setColor(team.getFColor());
helmet.setItemMeta(helmetM);
final ItemStack peche = new ItemStack(Material.LEATHER_CHESTPLATE, 1);
final LeatherArmorMeta pecheM = (LeatherArmorMeta) peche.getItemMeta();
pecheM.setColor(team.getFColor());
peche.setItemMeta(pecheM);
final ItemStack panta = new ItemStack(Material.IRON_LEGGINGS, 1);
final ItemMeta pantaM = panta.getItemMeta();
panta.setItemMeta(pantaM);
final ItemStack boots = new ItemStack(Material.IRON_BOOTS, 1);
final ItemMeta bootsM = boots.getItemMeta();
boots.setItemMeta(bootsM);
p.getInventory().setHelmet(helmet);
p.getInventory().setChestplate(peche);
p.getInventory().setLeggings(panta);
p.getInventory().setBoots(boots);
if (PlayerStat.getPlayerStat(p).getHotbar() == null) {
final ItemStack[] items = plugin.getGM().getKit().getContents();
for (int slot = 0; slot < 35; slot++) {
final ItemStack item = items[slot];
if (item == null || item.getType() == Material.BARRIER) {
p.getInventory().setItem(slot, new ItemStack(Material.AIR));
continue;
}
if (item.getType().equals(Material.STAINED_CLAY)
|| item.getType().equals(Material.getMaterial("CLAY"))) {
final ItemStack item2 = new ItemStack(item.getType(), item.getAmount(), getColor(team.getFColor()));
p.getInventory().setItem(slot, item2);
continue;
}
p.getInventory().setItem(slot, item);
}
} else {
final ItemStack[] items = PlayerStat.getPlayerStat(p).getHotbar();
for (int slot = 0; slot < 35; slot++) {
final ItemStack item = items[slot];
if (item == null || item.getType() == Material.BARRIER) {
p.getInventory().setItem(slot, new ItemStack(Material.AIR));
continue;
}
if (item.getType().equals(Material.STAINED_CLAY)
|| item.getType().equals(Material.getMaterial("CLAY"))) {
final ItemStack item2 = new ItemStack(item.getType(), item.getAmount(), getColor(team.getFColor()));
p.getInventory().setItem(slot, item2);
continue;
}
p.getInventory().setItem(slot, item);
}
}
}
public void givePlayerItems(Player p) {
if (teamSize > 1) {
final ItemStack team = ItemBuilder.item(Material.PAPER, 1, (short) 0,
plugin.getLang().get("items.teams.nameItem"), plugin.getLang().get("items.teams.loreItem"));
p.getInventory().setItem(0, team);
}
final ItemStack leave = ItemBuilder.item(Material.BED, 1, (short) 0,
plugin.getLang().get("items.leave.nameItem"), plugin.getLang().get("items.leave.loreItem"));
p.getInventory().setItem(8, leave);
}
public byte getColor(Color color) {
if (color.equals(Color.RED))
return 14;
if (color.equals(Color.BLUE))
return 11;
return 0;
}
public int getTeamSize() {
return teamSize;
}
public void addPlace(Location loc) {
placed.add(loc);
}
public ArrayList<Location> getPlaced() {
return placed;
}
public int getStarting() {
return starting;
}
public Location getLobby() {
return lobby;
}
public Location getSpect() {
return spect;
}
public HashMap<Player, PlayerData> getPD() {
return pd;
}
}

38
MultiArena-TheBridge/src/cx/sfy/TheBridge/game/GameFour.java

@ -12,6 +12,7 @@ import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
@ -853,46 +854,51 @@ public class GameFour {
}
public void giveKit(Player p, TeamFour team) {
ItemStack peche = new ItemStack(Material.LEATHER_CHESTPLATE, 1);
LeatherArmorMeta pecheM = (LeatherArmorMeta) peche.getItemMeta();
final ItemStack helmet = new ItemStack(Material.LEATHER_HELMET, 1);
final LeatherArmorMeta helmetM = (LeatherArmorMeta) helmet.getItemMeta();
helmetM.setColor(team.getFColor());
helmet.setItemMeta(helmetM);
final ItemStack peche = new ItemStack(Material.LEATHER_CHESTPLATE, 1);
final LeatherArmorMeta pecheM = (LeatherArmorMeta) peche.getItemMeta();
pecheM.setColor(team.getFColor());
peche.setItemMeta(pecheM);
ItemStack panta = new ItemStack(Material.LEATHER_LEGGINGS, 1);
LeatherArmorMeta pantaM = (LeatherArmorMeta) panta.getItemMeta();
pantaM.setColor(team.getFColor());
final ItemStack panta = new ItemStack(Material.IRON_LEGGINGS, 1);
final ItemMeta pantaM = panta.getItemMeta();
panta.setItemMeta(pantaM);
ItemStack boots = new ItemStack(Material.LEATHER_BOOTS, 1);
LeatherArmorMeta bootsM = (LeatherArmorMeta) boots.getItemMeta();
bootsM.setColor(team.getFColor());
final ItemStack boots = new ItemStack(Material.IRON_BOOTS, 1);
final ItemMeta bootsM = boots.getItemMeta();
boots.setItemMeta(bootsM);
p.getInventory().setHelmet(helmet);
p.getInventory().setChestplate(peche);
p.getInventory().setLeggings(panta);
p.getInventory().setBoots(boots);
if (PlayerStat.getPlayerStat(p).getHotbar() == null) {
ItemStack[] items = plugin.getGM().getKit().getContents();
final ItemStack[] items = plugin.getGM().getKit().getContents();
for (int slot = 0; slot < 35; slot++) {
ItemStack item = items[slot];
final ItemStack item = items[slot];
if (item == null || item.getType() == Material.BARRIER) {
p.getInventory().setItem(slot, new ItemStack(Material.AIR));
continue;
}
if (item.getType().equals(Material.STAINED_CLAY)) {
ItemStack item2 = new ItemStack(item.getType(), item.getAmount(), getColor(team.getFColor()));
if (item.getType().equals(Material.STAINED_CLAY)
|| item.getType().equals(Material.getMaterial("CLAY"))) {
final ItemStack item2 = new ItemStack(item.getType(), item.getAmount(), getColor(team.getFColor()));
p.getInventory().setItem(slot, item2);
continue;
}
p.getInventory().setItem(slot, item);
}
} else {
ItemStack[] items = PlayerStat.getPlayerStat(p).getHotbar();
final ItemStack[] items = PlayerStat.getPlayerStat(p).getHotbar();
for (int slot = 0; slot < 35; slot++) {
ItemStack item = items[slot];
final ItemStack item = items[slot];
if (item == null || item.getType() == Material.BARRIER) {
p.getInventory().setItem(slot, new ItemStack(Material.AIR));
continue;
}
if (item.getType().equals(Material.STAINED_CLAY)) {
ItemStack item2 = new ItemStack(item.getType(), item.getAmount(), getColor(team.getFColor()));
if (item.getType().equals(Material.STAINED_CLAY)
|| item.getType().equals(Material.getMaterial("CLAY"))) {
final ItemStack item2 = new ItemStack(item.getType(), item.getAmount(), getColor(team.getFColor()));
p.getInventory().setItem(slot, item2);
continue;
}

42
MultiArena-TheBridge/src/cx/sfy/TheBridge/listeners/PlayerListener.java

@ -44,8 +44,8 @@ import org.bukkit.scheduler.BukkitRunnable;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.cages.Cage;
import cx.sfy.TheBridge.database.PlayerStat;
import cx.sfy.TheBridge.game.Game;
import cx.sfy.TheBridge.game.Game.State;
import cx.sfy.TheBridge.game.GameDuo;
import cx.sfy.TheBridge.game.GameDuo.State;
import cx.sfy.TheBridge.game.GameFour;
import cx.sfy.TheBridge.game.GameFour.FState;
import cx.sfy.TheBridge.game.InventoryData;
@ -83,11 +83,11 @@ public class PlayerListener implements Listener {
if (e.getMessage().contains("/bridges"))
return;
if (plugin.getConfig().getBoolean("commands.whitelist") == true) {
if (cmds.contains(e.getMessage()))
return;
} else if (plugin.getConfig().getBoolean("commands.whitelist") == false)
if (!cmds.contains(e.getMessage()))
e.setCancelled(true);
} else if (plugin.getConfig().getBoolean("commands.whitelist") == false)
if (cmds.contains(e.getMessage()))
e.setCancelled(true);
}
}
@ -289,9 +289,9 @@ public class PlayerListener implements Listener {
plugin.getConfig().getString("items.random.nameItem").replaceAll("&", "§"),
plugin.getConfig().getString("items.random.loreItem").replaceAll("&", "§"));
if (item.equals(random)) {
Game g = null;
GameDuo g = null;
int alto = 0;
for (final Game game : plugin.getGM().getGames()) {
for (final GameDuo game : plugin.getGM().getGames()) {
if (game.isState(State.FINISH) || game.isState(State.INGAME)
|| game.isState(State.RESTARTING) || game.isState(State.PREGAME))
continue;
@ -338,7 +338,7 @@ public class PlayerListener implements Listener {
return;
if (plugin.getSIM().getSigns().keySet().contains(e.getClickedBlock().getLocation())) {
final GameNormalSign sign = plugin.getSIM().getSigns().get(e.getClickedBlock().getLocation());
final Game game = plugin.getGM().getGameByName(sign.getGame());
final GameDuo game = plugin.getGM().getGameByName(sign.getGame());
if (game.isState(State.WAITING) || game.isState(State.STARTING)) {
if (game.getPlayers() >= game.getMax()) {
p.sendMessage(plugin.getLang().get("messages.gameFull"));
@ -370,7 +370,7 @@ public class PlayerListener implements Listener {
boolean wait = false;
final Player p = e.getPlayer();
if (plugin.getGM().getGameByPlayer(p) != null) {
final Game game = plugin.getGM().getGameByPlayer(p);
final GameDuo game = plugin.getGM().getGameByPlayer(p);
if (game.isState(State.WAITING) || game.isState(State.STARTING) || game.isState(State.FINISH))
if (p.getLocation().getY() < 30)
p.teleport(game.getLobby());
@ -462,7 +462,7 @@ public class PlayerListener implements Listener {
if (!plugin.getConfig().getBoolean("chat.enabled"))
return;
if (plugin.getGM().getGameByPlayer(p) != null) {
final Game game = plugin.getGM().getGameByPlayer(p);
final GameDuo game = plugin.getGM().getGameByPlayer(p);
e.setCancelled(true);
if (game.isState(State.WAITING) || game.isState(State.STARTING) || game.isState(State.FINISH)
|| game.isState(State.RESTARTING)) {
@ -522,7 +522,7 @@ public class PlayerListener implements Listener {
if (e.getEntity() instanceof Player) {
final Player p = (Player) e.getEntity();
if (plugin.getGM().getGameByPlayer(p) != null) {
final Game game = plugin.getGM().getGameByPlayer(p);
final GameDuo game = plugin.getGM().getGameByPlayer(p);
if (e.getCause().equals(DamageCause.FALL)) {
e.setCancelled(true);
return;
@ -749,7 +749,7 @@ public class PlayerListener implements Listener {
if (plugin.getGM().getGameByPlayer(p) == null)
if (e.getCurrentItem().getItemMeta().getDisplayName().contains("§a")) {
final String arena = e.getCurrentItem().getItemMeta().getDisplayName().replaceAll("§a", "");
final Game game = plugin.getGM().getGameByName(arena);
final GameDuo game = plugin.getGM().getGameByName(arena);
if (game.getPlayers() >= game.getMax()) {
p.sendMessage(plugin.getLang().get("messages.gameFull"));
return;
@ -784,7 +784,7 @@ public class PlayerListener implements Listener {
if (plugin.getGM().getGameByPlayer(p) != null)
if (inv.getTitle().equals(plugin.getLang().get("menus.team.title"))) {
e.setCancelled(true);
final Game game = plugin.getGM().getGameByPlayer(p);
final GameDuo game = plugin.getGM().getGameByPlayer(p);
if (e.getCurrentItem().getItemMeta().getDisplayName().contains("§9")) {
if (p.hasPermission("bridges.bypass")) {
if (game.getTeamPlayer(p) != null)
@ -1029,7 +1029,7 @@ public class PlayerListener implements Listener {
final Player p = (Player) e.getEntity();
final Player d = (Player) e.getDamager();
if (plugin.getGM().getGameByPlayer(p) != null) {
final Game game = plugin.getGM().getGameByPlayer(p);
final GameDuo game = plugin.getGM().getGameByPlayer(p);
if (game.isState(State.WAITING) || game.isState(State.STARTING) || game.isState(State.PREGAME)) {
e.setCancelled(true);
return;
@ -1067,7 +1067,7 @@ public class PlayerListener implements Listener {
final Player p = (Player) e.getEntity();
final Player d = (Player) proj.getShooter();
if (plugin.getGM().getGameByPlayer(p) != null) {
final Game game = plugin.getGM().getGameByPlayer(p);
final GameDuo game = plugin.getGM().getGameByPlayer(p);
if (game.isState(State.WAITING) || game.isState(State.STARTING)
|| game.isState(State.PREGAME)) {
e.setCancelled(true);
@ -1150,7 +1150,7 @@ public class PlayerListener implements Listener {
public void onQuit(PlayerQuitEvent e) {
final Player p = e.getPlayer();
if (plugin.getGM().getGameByPlayer(p) != null) {
final Game game = plugin.getGM().getGameByPlayer(p);
final GameDuo game = plugin.getGM().getGameByPlayer(p);
game.removePlayer(p);
if (game.getTeamsAlive() == 1)
game.checkWin(p, game.getLastTeam(), game.getLastTeam().getGoals());
@ -1177,7 +1177,7 @@ public class PlayerListener implements Listener {
public void onKick(PlayerKickEvent e) {
final Player p = e.getPlayer();
if (plugin.getGM().getGameByPlayer(p) != null) {
final Game game = plugin.getGM().getGameByPlayer(p);
final GameDuo game = plugin.getGM().getGameByPlayer(p);
game.removePlayer(p);
if (game.getTeamsAlive() == 1)
game.checkWin(p, game.getLastTeam(), game.getLastTeam().getGoals());
@ -1204,7 +1204,7 @@ public class PlayerListener implements Listener {
public void onBreak(BlockBreakEvent e) {
final Player p = e.getPlayer();
if (plugin.getGM().getGameByPlayer(p) != null) {
final Game game = plugin.getGM().getGameByPlayer(p);
final GameDuo game = plugin.getGM().getGameByPlayer(p);
if (game.isState(State.WAITING) || game.isState(State.STARTING) || game.isState(State.PREGAME)
|| game.isState(State.PREGAME) || game.isState(State.FINISH) || game.isState(State.RESTARTING))
e.setCancelled(true);
@ -1235,7 +1235,7 @@ public class PlayerListener implements Listener {
public void onPlace(BlockPlaceEvent e) {
final Player p = e.getPlayer();
if (plugin.getGM().getGameByPlayer(p) != null) {
final Game game = plugin.getGM().getGameByPlayer(p);
final GameDuo game = plugin.getGM().getGameByPlayer(p);
if (game.isState(State.WAITING) || game.isState(State.STARTING) || game.isState(State.PREGAME)
|| game.isState(State.FINISH) || game.isState(State.RESTARTING))
e.setCancelled(true);
@ -1271,7 +1271,7 @@ public class PlayerListener implements Listener {
d.getInventory().clear();
d.setHealth(d.getMaxHealth());
if (k != null) {
final Game game = plugin.getGM().getGameByPlayer(k);
final GameDuo game = plugin.getGM().getGameByPlayer(k);
if (game == null)
return;
game.addKill(k);
@ -1322,7 +1322,7 @@ public class PlayerListener implements Listener {
.replaceAll("<death>", d.getName()).replaceAll("<player>", k.getName()));
}
} else {
final Game game = plugin.getGM().getGameByPlayer(d);
final GameDuo game = plugin.getGM().getGameByPlayer(d);
d.teleport(game.getTeamPlayer(d).getTeamRespawn());
game.giveKit(d, game.getTeamPlayer(d));
if (d.getLastDamageCause() == null)

6
MultiArena-TheBridge/src/cx/sfy/TheBridge/listeners/SetupListener.java

@ -13,9 +13,9 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.game.Game;
import cx.sfy.TheBridge.game.GameDuo;
import cx.sfy.TheBridge.game.GameFour;
import cx.sfy.TheBridge.game.Game.State;
import cx.sfy.TheBridge.game.GameDuo.State;
import cx.sfy.TheBridge.game.GameFour.FState;;
public class SetupListener implements Listener {
@ -60,7 +60,7 @@ public class SetupListener implements Listener {
p.sendMessage("§cThis Game not exits.");
return;
}
Game gname = plugin.getGM().getGameByName(game);
GameDuo gname = plugin.getGM().getGameByName(game);
plugin.getSIM().createSign(e.getBlock().getLocation(), game, sign);
e.setLine(0, plugin.getLang().get("signs.normal.line-1").replaceAll("<state>", getState(gname.getState())).replaceAll("<name>", game).replaceAll("<players>", String.valueOf(gname.getPlayers())).replaceAll("<max>", String.valueOf(gname.getMax())));
e.setLine(1, plugin.getLang().get("signs.normal.line-2").replaceAll("<state>", getState(gname.getState())).replaceAll("<name>", game).replaceAll("<players>", String.valueOf(gname.getPlayers())).replaceAll("<max>", String.valueOf(gname.getMax())));

30
MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/GameManager.java

@ -12,7 +12,7 @@ import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.game.Game;
import cx.sfy.TheBridge.game.GameDuo;
import cx.sfy.TheBridge.game.GameFour;
import org.bukkit.World;
@ -23,9 +23,9 @@ import net.md_5.bungee.api.ChatColor;
public class GameManager {
private ArrayList<Game> normalGames;
private ArrayList<GameDuo> normalGames;
private ArrayList<GameFour> fourGames;
private HashMap<Player, Game> playerGame;
private HashMap<Player, GameDuo> playerGame;
private HashMap<Player, GameFour> playerGameFour;
private Inventory kit;
Main plugin;
@ -34,7 +34,7 @@ public class GameManager {
this.plugin = plugin;
this.normalGames = new ArrayList<>();
this.fourGames = new ArrayList<>();
this.playerGame = new HashMap<Player, Game>();
this.playerGame = new HashMap<Player, GameDuo>();
this.playerGameFour = new HashMap<Player, GameFour>();
this.kit = Bukkit.getServer().createInventory(null, InventoryType.PLAYER);
if (plugin.getConfig().getString("kit") == null) {
@ -66,8 +66,8 @@ public class GameManager {
}
public void resetNormalGame(String file) {
Game prev = null;
for (Game game : normalGames) {
GameDuo prev = null;
for (GameDuo game : normalGames) {
if (game.getName().equals(file)) {
prev = game;
}
@ -112,7 +112,7 @@ public class GameManager {
for (String locBlue : yml.getStringList("locations.portal.blue")) {
portalBlue.add(getStringLocation(locBlue));
}
normalGames.add(new Game(plugin, name, min, 2 * teamSize, teamSize, starting, prestart, restart, getStringLocation(lobby), getStringLocation(spect), getStringLocation(buildMin), getStringLocation(buildMax), getStringLocation(spawnsRed), getStringLocation(spawnsBlue), portalRed, portalBlue, getStringLocation(respawnsRed), getStringLocation(respawnsBlue), hRed, hBlue));
normalGames.add(new GameDuo(plugin, name, min, 2 * teamSize, teamSize, starting, prestart, restart, getStringLocation(lobby), getStringLocation(spect), getStringLocation(buildMin), getStringLocation(buildMax), getStringLocation(spawnsRed), getStringLocation(spawnsBlue), portalRed, portalBlue, getStringLocation(respawnsRed), getStringLocation(respawnsBlue), hRed, hBlue));
}
public void resetFourGame(String file) {
@ -225,7 +225,7 @@ public class GameManager {
for (String locBlue : yml.getStringList("locations.portal.blue")) {
portalBlue.add(getStringLocation(locBlue));
}
normalGames.add(new Game(plugin, name, min, 2 * teamSize, teamSize, starting, prestart, restart, getStringLocation(lobby), getStringLocation(spect), getStringLocation(buildMin), getStringLocation(buildMax), getStringLocation(spawnsRed), getStringLocation(spawnsBlue), portalRed, portalBlue, getStringLocation(respawnsRed), getStringLocation(respawnsBlue), hRed, hBlue));
normalGames.add(new GameDuo(plugin, name, min, 2 * teamSize, teamSize, starting, prestart, restart, getStringLocation(lobby), getStringLocation(spect), getStringLocation(buildMin), getStringLocation(buildMax), getStringLocation(spawnsRed), getStringLocation(spawnsBlue), portalRed, portalBlue, getStringLocation(respawnsRed), getStringLocation(respawnsBlue), hRed, hBlue));
}
if (yml.getString("mode").toLowerCase().equals("four")) {
String name = yml.getString("name");
@ -284,7 +284,7 @@ public class GameManager {
}
}
public void addPlayerGame(Player p, Game game) {
public void addPlayerGame(Player p, GameDuo game) {
playerGame.put(p, game);
game.addPlayer(p);
}
@ -294,7 +294,7 @@ public class GameManager {
game.addPlayer(p);
}
public void removePlayerGame(Player p, Game game) {
public void removePlayerGame(Player p, GameDuo game) {
game.removePlayer(p);
playerGame.remove(p);
plugin.getSB().update(p);
@ -307,7 +307,7 @@ public class GameManager {
}
public void removePlayerAllGames(Player p) {
for (Game game : normalGames) {
for (GameDuo game : normalGames) {
if (game.getGamePlayers().contains(p)) {
game.removePlayer(p);
playerGame.remove(p);
@ -326,7 +326,7 @@ public class GameManager {
}
}
public Game getGameByPlayer(Player p) {
public GameDuo getGameByPlayer(Player p) {
if (playerGame.containsKey(p)) {
return playerGame.get(p);
}
@ -340,8 +340,8 @@ public class GameManager {
return null;
}
public Game getGameByName(String name) {
for (Game game : normalGames) {
public GameDuo getGameByName(String name) {
for (GameDuo game : normalGames) {
if (game.getName().equals(name)) {
return game;
}
@ -369,7 +369,7 @@ public class GameManager {
return new Location(world, x, y, z, yaw, pitch);
}
public ArrayList<Game> getGames(){
public ArrayList<GameDuo> getGames(){
return normalGames;
}

14
MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/ScoreboardManager.java

@ -10,9 +10,9 @@ import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.game.Game;
import cx.sfy.TheBridge.game.GameDuo;
import cx.sfy.TheBridge.game.GameFour;
import cx.sfy.TheBridge.game.Game.State;
import cx.sfy.TheBridge.game.GameDuo.State;
import cx.sfy.TheBridge.game.GameFour.FState;
import cx.sfy.TheBridge.utils.ScoreboardUtil;
import me.clip.placeholderapi.PlaceholderAPI;
@ -47,7 +47,7 @@ public class ScoreboardManager {
public void createWaitingBoard(Player p) {
sb.put(p, "waiting");
Game game = plugin.getGM().getGameByPlayer(p);
GameDuo game = plugin.getGM().getGameByPlayer(p);
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
ScoreboardUtil scoreboardUtil = new ScoreboardUtil("lobby", "starting", false);
scoreboardUtil.setName(plugin.getLang().get("scoreboards.lobby-title"));
@ -62,7 +62,7 @@ public class ScoreboardManager {
public void createStartingBoard(Player p) {
sb.put(p, "starting");
Game game = plugin.getGM().getGameByPlayer(p);
GameDuo game = plugin.getGM().getGameByPlayer(p);
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
ScoreboardUtil scoreboardUtil = new ScoreboardUtil("starting", "starting", false);
scoreboardUtil.setName(plugin.getLang().get("scoreboards.starting-title"));
@ -77,7 +77,7 @@ public class ScoreboardManager {
public void createGameBoard(Player p) {
sb.put(p, "game");
Game game = plugin.getGM().getGameByPlayer(p);
GameDuo game = plugin.getGM().getGameByPlayer(p);
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
ScoreboardUtil scoreboardUtil = new ScoreboardUtil("game-normal", "starting", false);
scoreboardUtil.setName(plugin.getLang().get("scoreboards.game-normal-title"));
@ -153,7 +153,7 @@ public class ScoreboardManager {
}
} else {
if (plugin.getGM().getGameByPlayer(p) != null) {
Game game = plugin.getGM().getGameByPlayer(p);
GameDuo game = plugin.getGM().getGameByPlayer(p);
if (game.isState(State.WAITING)) {
if (sb.get(p).equals("waiting")) {
scoreboardUtil.setName(plugin.getLang().get("scoreboards.lobby-title"));
@ -238,7 +238,7 @@ public class ScoreboardManager {
}
}
public String game(Player p, String c, Game game) {
public String game(Player p, String c, GameDuo game) {
if (plugin.getPlaceholder()) {
return PlaceholderAPI.setPlaceholders(p, c
.replaceAll("<goals>", String.valueOf(game.getGoals(p)))

10
MultiArena-TheBridge/src/cx/sfy/TheBridge/managers/SignManager.java

@ -10,8 +10,8 @@ import org.bukkit.block.Sign;
import org.bukkit.configuration.ConfigurationSection;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.game.Game;
import cx.sfy.TheBridge.game.Game.State;
import cx.sfy.TheBridge.game.GameDuo;
import cx.sfy.TheBridge.game.GameDuo.State;
import cx.sfy.TheBridge.game.GameFour;
import cx.sfy.TheBridge.game.GameFour.FState;
import cx.sfy.TheBridge.signs.GameFourSign;
@ -71,7 +71,7 @@ public class SignManager {
plugin.getSigns().set("signs.normal." + game + ".loc", getLocationString(loc));
plugin.getSigns().set("signs.normal." + game + ".game", game);
gameSign.put(loc, new GameNormalSign(loc, game, getBlockFaced(loc.getBlock())));
final Game gname = plugin.getGM().getGameByName(game);
final GameDuo gname = plugin.getGM().getGameByName(game);
sign.setLine(0, plugin.getLang().get("signs.normal.line-1").replaceAll("<state>", getState(gname.getState())).replaceAll("<name>", game).replaceAll("<players>", String.valueOf(gname.getPlayers())).replaceAll("<max>", String.valueOf(gname.getMax())));
sign.setLine(1, plugin.getLang().get("signs.normal.line-2").replaceAll("<state>", getState(gname.getState())).replaceAll("<name>", game).replaceAll("<players>", String.valueOf(gname.getPlayers())).replaceAll("<max>", String.valueOf(gname.getMax())));
sign.setLine(2, plugin.getLang().get("signs.normal.line-3").replaceAll("<state>", getState(gname.getState())).replaceAll("<name>", game).replaceAll("<players>", String.valueOf(gname.getPlayers())).replaceAll("<max>", String.valueOf(gname.getMax())));
@ -93,7 +93,7 @@ public class SignManager {
plugin.getSigns().save();
}
public void updateGameSign(Game game) {
public void updateGameSign(GameDuo game) {
for (final GameNormalSign sig : gameSign.values())
if (sig.getGame().equals(game.getName())) {
final Sign sign = sig.getSign();
@ -126,7 +126,7 @@ public class SignManager {
}
@SuppressWarnings("deprecation")
public void updateBlock(Game game, Block b) {
public void updateBlock(GameDuo game, Block b) {
if (game.isState(State.WAITING))
b.setData((byte)plugin.getConfig().getInt("signs.waiting"));
if (game.isState(State.STARTING))

10
MultiArena-TheBridge/src/cx/sfy/TheBridge/menus/GameMenu.java

@ -7,8 +7,8 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.game.Game;
import cx.sfy.TheBridge.game.Game.State;
import cx.sfy.TheBridge.game.GameDuo;
import cx.sfy.TheBridge.game.GameDuo.State;
import cx.sfy.TheBridge.game.GameFour;
import cx.sfy.TheBridge.game.GameFour.FState;
import cx.sfy.TheBridge.utils.ItemBuilder;
@ -32,7 +32,7 @@ public class GameMenu {
public void openGameMenu(Player p) {
final Inventory inv = Bukkit.getServer().createInventory(null, 27, plugin.getLang().get(p, "menus.game.title"));
for (final Game game : plugin.getGM().getGames())
for (final GameDuo game : plugin.getGM().getGames())
inv.addItem(game(p, game));
p.openInventory(inv);
}
@ -44,7 +44,7 @@ public class GameMenu {
p.openInventory(inv);
}
protected ItemStack game(Player p, Game game) {
protected ItemStack game(Player p, GameDuo game) {
final ItemStack item = ItemBuilder.item(Material.STAINED_CLAY, 1, getState(game), "§a" + game.getName(), plugin.getLang().get(p, "menus.game.generalDesc").replaceAll("<players>", String.valueOf(game.getPlayers())).replaceAll("<max>", String.valueOf(game.getMax())).replaceAll("<mode>", game.getMode()).replaceAll("<state>", getState(game.getState())));
return item;
}
@ -86,7 +86,7 @@ public class GameMenu {
return "";
}
protected short getState(Game game) {
protected short getState(GameDuo game) {
if (game.isState(State.WAITING))
return (short)plugin.getConfig().getInt("signs.waiting");
if (game.isState(State.STARTING))

8
MultiArena-TheBridge/src/cx/sfy/TheBridge/menus/TeamMenu.java

@ -12,9 +12,9 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import cx.sfy.TheBridge.Main;
import cx.sfy.TheBridge.game.Game;
import cx.sfy.TheBridge.game.GameDuo;
import cx.sfy.TheBridge.game.GameFour;
import cx.sfy.TheBridge.team.Team;
import cx.sfy.TheBridge.team.TeamDuo;
import cx.sfy.TheBridge.team.TeamFour;
import cx.sfy.TheBridge.utils.ItemBuilder;
@ -49,7 +49,7 @@ public class TeamMenu {
}
public void openTeamNormalMenu(Player p) {
Game game = plugin.getGM().getGameByPlayer(p);
GameDuo game = plugin.getGM().getGameByPlayer(p);
Inventory inv = Bukkit.getServer().createInventory(null, 27, plugin.getLang().get("menus.team.title"));
new BukkitRunnable() {
@Override
@ -66,7 +66,7 @@ public class TeamMenu {
p.openInventory(inv);
}
public List<String> getLore(Team team){
public List<String> getLore(TeamDuo team){
List<String> lore = new ArrayList<String>();
for (String msg : plugin.getLang().getList("menus.team.team.loreItem")) {
if (msg.contains("<teamPlayers>")) {

307
MultiArena-TheBridge/src/cx/sfy/TheBridge/team/Team.java

@ -1,107 +1,128 @@
package cx.sfy.TheBridge.team;
import java.util.ArrayList;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.math.transform.Transform;
import cx.sfy.TheBridge.cages.Cage;
import java.io.IOException;
import java.util.ArrayList;
public abstract class Team {
private ArrayList<Player> players;
private ArrayList<Location> portal;
private Location hologram;
private Location teamSpawn;
private Location teamRespawn;
private int life;
private boolean death;
private ChatColor color;
private Color fcolor;
private String teamName;
private String ally;
private boolean cage;
private EditSession editSessionRed;
private EditSession editSessionBlue;
private EditSession editSessionYellow;
private EditSession editSessionGreen;
private Cage cages;
abstract void createCage(Cage cage);
abstract void removeCage();
public ArrayList<Player> getPlayers() {
return players;
}
public class Team {
private ArrayList<Player> players;
private ArrayList<Location> portal;
private Location hologram;
private Location spawn;
private Location respawn;
private String teamName;
private ChatColor color;
private Color fcolor;
private int goals;
private boolean cage;
private EditSession editSessionRed;
private EditSession editSessionBlue;
private Cage cages;
public Team(String teamName, ChatColor color, Color fcolor, Location respawn, Location spawn, ArrayList<Location> portal, Location hologram) {
this.color = color;
this.teamName = teamName;
this.players = new ArrayList<Player>();
this.goals = 0;
this.spawn = spawn;
this.respawn = respawn;
this.portal = portal;
this.fcolor = fcolor;
this.hologram = hologram;
this.cage = false;
}
public void createCage(Cage cage) {
cages = cage;
if (color.equals(ChatColor.RED)) {
Vector to = new Vector(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ());
BukkitWorld world = new BukkitWorld(spawn.getWorld());
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
try {
editSessionRed = ClipboardFormat.findByFile(cage.getFileRed()).load(cage.getFileRed()).paste(world, to, true, true, (Transform) null);
editSessionRed.flushQueue();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
if (color.equals(ChatColor.BLUE)) {
Vector to = new Vector(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ());
BukkitWorld world = new BukkitWorld(spawn.getWorld());
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
try {
editSessionBlue = ClipboardFormat.findByFile(cage.getFileBlue()).load(cage.getFileBlue()).paste(world, to, true, true, (Transform) null);
editSessionBlue.flushQueue();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
editSessionBlue.flushQueue();
}
});
}
public void setPlayers(ArrayList<Player> players) {
this.players = players;
}
public void removeCage() {
Vector to = new Vector(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ());
BukkitWorld world = new BukkitWorld(spawn.getWorld());
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
try {
editSessionBlue = ClipboardFormat.findByFile(cages.getClear()).load(cages.getClear()).paste(world, to, true, true, (Transform) null);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
editSessionBlue.flushQueue();
}
});
public ArrayList<Location> getPortal() {
return portal;
}
public boolean isCage() {
public void setPortal(ArrayList<Location> portal) {
this.portal = portal;
}
public Location getHologram() {
return hologram;
}
public void setHologram(Location hologram) {
this.hologram = hologram;
}
public Location getTeamSpawn() {
return teamSpawn;
}
public void setTeamSpawn(Location teamSpawn) {
this.teamSpawn = teamSpawn;
}
public Location getTeamRespawn() {
return teamRespawn;
}
public void setTeamRespawn(Location teamRespawn) {
this.teamRespawn = teamRespawn;
}
public int getLife() {
return life;
}
public void setLife(int life) {
this.life = life;
}
public boolean isDeath() {
return death;
}
public void setDeath(boolean death) {
this.death = death;
}
public ChatColor getColor() {
return color;
}
public void setColor(ChatColor color) {
this.color = color;
}
public Color getFcolor() {
return fcolor;
}
public void setFcolor(Color fcolor) {
this.fcolor = fcolor;
}
public String getTeamName() {
return teamName;
}
public void setTeamName(String teamName) {
this.teamName = teamName;
}
public String getAlly() {
return ally;
}
public void setAlly(String ally) {
this.ally = ally;
}
public boolean isCage() {
return cage;
}
@ -109,72 +130,44 @@ public class Team {
this.cage = cage;
}
public Location getHologram() {
return hologram;
public EditSession getEditSessionRed() {
return editSessionRed;
}
public String getTeamName() {
return teamName;
}
public ChatColor getColor() {
return color;
}
public Location getTeamSpawn() {
return spawn;
}
public Location getTeamRespawn() {
return respawn;
}
public Color getFColor() {
return fcolor;
}
public ArrayList<Location> getPortal() {
return portal;
}
public void createPortal() {
for (Location loc : portal) {
loc.getBlock().setType(Material.ENDER_PORTAL);
}
}
public void deletePortal() {
for (Location loc : portal) {
loc.getBlock().setType(Material.AIR);
}
}
public void addGoal() {
this.goals = this.goals + 1;
}
public int getGoals() {
return goals;
}
public void addPlayer(Player p) {
if (!players.contains(p)) {
players.add(p);
}
}
public void removePlayer(Player p) {
if (players.contains(p)) {
players.remove(p);
}
}
public ArrayList<Player> getTeamPlayers() {
return players;
}
public int getTeamSize() {
return players.size();
}
}
public void setEditSessionRed(EditSession editSessionRed) {
this.editSessionRed = editSessionRed;
}
public EditSession getEditSessionBlue() {
return editSessionBlue;
}
public void setEditSessionBlue(EditSession editSessionBlue) {
this.editSessionBlue = editSessionBlue;
}
public EditSession getEditSessionYellow() {
return editSessionYellow;
}
public void setEditSessionYellow(EditSession editSessionYellow) {
this.editSessionYellow = editSessionYellow;
}
public EditSession getEditSessionGreen() {
return editSessionGreen;
}
public void setEditSessionGreen(EditSession editSessionGreen) {
this.editSessionGreen = editSessionGreen;
}
public Cage getCages() {
return cages;
}
public void setCages(Cage cages) {
this.cages = cages;
}
}

180
MultiArena-TheBridge/src/cx/sfy/TheBridge/team/TeamDuo.java

@ -0,0 +1,180 @@
package cx.sfy.TheBridge.team;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.math.transform.Transform;
import cx.sfy.TheBridge.cages.Cage;
import java.io.IOException;
import java.util.ArrayList;
public class TeamDuo {
private ArrayList<Player> players;
private ArrayList<Location> portal;
private Location hologram;
private Location spawn;
private Location respawn;
private String teamName;
private ChatColor color;
private Color fcolor;
private int goals;
private boolean cage;
private EditSession editSessionRed;
private EditSession editSessionBlue;
private Cage cages;
public TeamDuo(String teamName, ChatColor color, Color fcolor, Location respawn, Location spawn, ArrayList<Location> portal, Location hologram) {
this.color = color;
this.teamName = teamName;
this.players = new ArrayList<Player>();
this.goals = 0;
this.spawn = spawn;
this.respawn = respawn;
this.portal = portal;
this.fcolor = fcolor;
this.hologram = hologram;
this.cage = false;
}
public void createCage(Cage cage) {
cages = cage;
if (color.equals(ChatColor.RED)) {
Vector to = new Vector(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ());
BukkitWorld world = new BukkitWorld(spawn.getWorld());
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
try {
editSessionRed = ClipboardFormat.findByFile(cage.getFileRed()).load(cage.getFileRed()).paste(world, to, true, true, (Transform) null);
editSessionRed.flushQueue();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
if (color.equals(ChatColor.BLUE)) {
Vector to = new Vector(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ());
BukkitWorld world = new BukkitWorld(spawn.getWorld());
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
try {
editSessionBlue = ClipboardFormat.findByFile(cage.getFileBlue()).load(cage.getFileBlue()).paste(world, to, true, true, (Transform) null);
editSessionBlue.flushQueue();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
editSessionBlue.flushQueue();
}
});
}
}
public void removeCage() {
Vector to = new Vector(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ());
BukkitWorld world = new BukkitWorld(spawn.getWorld());
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
try {
editSessionBlue = ClipboardFormat.findByFile(cages.getClear()).load(cages.getClear()).paste(world, to, true, true, (Transform) null);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
editSessionBlue.flushQueue();
}
});
}
public boolean isCage() {
return cage;
}
public void setCage(boolean cage) {
this.cage = cage;
}
public Location getHologram() {
return hologram;
}
public String getTeamName() {
return teamName;
}
public ChatColor getColor() {
return color;
}
public Location getTeamSpawn() {
return spawn;
}
public Location getTeamRespawn() {
return respawn;
}
public Color getFColor() {
return fcolor;
}
public ArrayList<Location> getPortal() {
return portal;
}
public void createPortal() {
for (Location loc : portal) {
loc.getBlock().setType(Material.ENDER_PORTAL);
}
}
public void deletePortal() {
for (Location loc : portal) {
loc.getBlock().setType(Material.AIR);
}
}
public void addGoal() {
this.goals = this.goals + 1;
}
public int getGoals() {
return goals;
}
public void addPlayer(Player p) {
if (!players.contains(p)) {
players.add(p);
}
}
public void removePlayer(Player p) {
if (players.contains(p)) {
players.remove(p);
}
}
public ArrayList<Player> getTeamPlayers() {
return players;
}
public int getTeamSize() {
return players.size();
}
}

7
MultiArena-TheBridge/src/cx/sfy/TheBridge/utils/PaperOnly.java

@ -1,7 +0,0 @@
package cx.sfy.TheBridge.utils;
public class PaperOnly {
}
Loading…
Cancel
Save