GUI + Refactoring Refactoring Refactoring
Dieser Commit ist enthalten in:
Ursprung
60edef1c80
Commit
c2da2498f7
@ -26,17 +26,17 @@ import java.io.File;
|
||||
|
||||
public class FightSystem extends JavaPlugin {
|
||||
|
||||
public static final String PREFIX = "§6Arena§8» ";
|
||||
public static final String PREFIX = "§eArena§8» ";
|
||||
|
||||
private static FightSystem plugin;
|
||||
private Scoreboard scoreboard;
|
||||
private WaterRemover waterRemover;
|
||||
private static Scoreboard scoreboard;
|
||||
private static WaterRemover waterRemover;
|
||||
|
||||
private static FightState fightState;
|
||||
public int fightTime = 0;
|
||||
private static FightState fightState = FightState.SETUP;
|
||||
private static int fightTime = 0;
|
||||
|
||||
|
||||
public boolean entern = false;
|
||||
private static boolean entern = false;
|
||||
|
||||
private final File kits = new File("plugins/" + this.getName(), "kits.data");
|
||||
private final FileConfiguration getKitData = YamlConfiguration.loadConfiguration(kits);
|
||||
@ -49,32 +49,19 @@ public class FightSystem extends JavaPlugin {
|
||||
return getKitData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
plugin = this;
|
||||
Config.load();
|
||||
|
||||
this.scoreboard = new Scoreboard(plugin);
|
||||
this.waterRemover = new WaterRemover();
|
||||
scoreboard = new Scoreboard();
|
||||
waterRemover = new WaterRemover();
|
||||
|
||||
loadConfig();
|
||||
|
||||
KitManager.loadAllKits();
|
||||
|
||||
init();
|
||||
|
||||
fightState = FightState.SETUP;
|
||||
Countdown countdown = new Countdown(Config.NoPlayerOnlineDuration, new FinishNoPlayersOnline());
|
||||
countdown.startTimer(getPlugin());
|
||||
|
||||
TechHider.init();
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
|
||||
}
|
||||
|
||||
private void init() {
|
||||
PluginManager pm = Bukkit.getPluginManager();
|
||||
pm.registerEvents(new PlayerJoinListener(), plugin);
|
||||
pm.registerEvents(new PlayerQuitListener(), plugin);
|
||||
@ -103,8 +90,17 @@ public class FightSystem extends JavaPlugin {
|
||||
getCommand("accept").setExecutor(new AcceptCommand());
|
||||
getCommand("decline").setExecutor(new DeclineCommand());
|
||||
getCommand("ready").setExecutor(new ReadyCommand());
|
||||
getCommand("kit").setExecutor(new KitCommand());
|
||||
|
||||
Countdown countdown = new Countdown(Config.NoPlayerOnlineDuration, new FinishNoPlayersOnline());
|
||||
countdown.startTimer(getPlugin());
|
||||
|
||||
TechHider.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {}
|
||||
|
||||
private void loadConfig() {
|
||||
if(!new File("plugins/" + this.getName() + "/kits.data").exists()) {
|
||||
saveKitData();
|
||||
@ -193,7 +189,7 @@ public class FightSystem extends JavaPlugin {
|
||||
return;
|
||||
fightState = FightState.SPECTATE;
|
||||
Countdown.cancelAllTimers();
|
||||
Bukkit.getScheduler().cancelTask(WinconditionTechKO.taskID);
|
||||
Bukkit.getScheduler().cancelTask(WinconditionTechKO.getTaskID());
|
||||
|
||||
setAllPlayersGM(GameMode.SPECTATOR);
|
||||
for(Player p : Bukkit.getOnlinePlayers()){
|
||||
@ -245,4 +241,12 @@ public class FightSystem extends JavaPlugin {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void setFightTime(int fightTime) {
|
||||
FightSystem.fightTime = fightTime;
|
||||
}
|
||||
|
||||
public static void setEntern(boolean entern) {
|
||||
FightSystem.entern = entern;
|
||||
}
|
||||
}
|
||||
|
@ -5,13 +5,15 @@ import de.warking.hunjy.MySQL.UserGroup;
|
||||
import de.warking.hunjy.MySQL.WarkingUser;
|
||||
import me.yaruma.fightsystem.FightSystem;
|
||||
import me.yaruma.fightsystem.fight.Fight;
|
||||
import me.yaruma.fightsystem.fight.FightPlayer;
|
||||
import me.yaruma.fightsystem.fight.FightState;
|
||||
import me.yaruma.fightsystem.fight.FightTeam;
|
||||
import me.yaruma.fightsystem.kit.Kit;
|
||||
import me.yaruma.fightsystem.kit.KitManager;
|
||||
import me.yaruma.fightsystem.utils.Config;
|
||||
import org.bukkit.Bukkit;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -37,20 +39,34 @@ public class AkCommand implements CommandExecutor {
|
||||
Commands.declineInvitation(player);
|
||||
else if(args[0].equalsIgnoreCase("leave"))
|
||||
Commands.leaveTeam(player);
|
||||
else if(args[0].equalsIgnoreCase("leader")){
|
||||
if(!Fight.getBlueTeam().hasTeamLeader()){
|
||||
FightPlayer fightPlayer = new FightPlayer(player, false);
|
||||
Fight.getBlueTeam().setLeader(fightPlayer);
|
||||
else if(args[0].equalsIgnoreCase("leader")) {
|
||||
if (!Fight.getBlueTeam().hasTeamLeader()) {
|
||||
Fight.getBlueTeam().setLeader(Fight.getBlueTeam().addMember(player));
|
||||
player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + Fight.getBlueTeam().getName());
|
||||
|
||||
} else if(!Fight.getRedTeam().hasTeamLeader()){
|
||||
FightPlayer fightPlayer = new FightPlayer(player, false);
|
||||
Fight.getBlueTeam().setLeader(fightPlayer);
|
||||
} else if (!Fight.getRedTeam().hasTeamLeader()) {
|
||||
Fight.getRedTeam().setLeader(Fight.getRedTeam().addMember(player));
|
||||
player.sendMessage(FightSystem.PREFIX + "§aDu bist nun Leader von " + Fight.getRedTeam().getName());
|
||||
|
||||
} else
|
||||
player.sendMessage(FightSystem.PREFIX + "§cEs sind bereits zwei Leader vorhanden!");
|
||||
}else if(args[0].equalsIgnoreCase("schem") || args[0].equalsIgnoreCase("schemlist")){
|
||||
|
||||
//TEXT COMPONENTS
|
||||
TextComponent publicList = new TextComponent("PUBLIC");
|
||||
publicList.setColor(ChatColor.YELLOW);
|
||||
publicList.setBold(true);
|
||||
publicList.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§ePublic Liste...").create()));
|
||||
publicList.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ak schemlist public"));
|
||||
|
||||
TextComponent privateList = new TextComponent("PRIVATE");
|
||||
privateList.setColor(ChatColor.YELLOW);
|
||||
privateList.setBold(true);
|
||||
privateList.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§ePrivate Liste...").create()));
|
||||
privateList.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ak schemlist 0"));
|
||||
//TEXT COMPONENTS
|
||||
|
||||
player.spigot().sendMessage(publicList);
|
||||
player.spigot().sendMessage(privateList);
|
||||
}else
|
||||
Commands.sendHelp(player);
|
||||
break;
|
||||
@ -58,52 +74,9 @@ public class AkCommand implements CommandExecutor {
|
||||
if(args[0].equalsIgnoreCase("invite")){
|
||||
Commands.invite(player, args[1]);
|
||||
}else if(args[0].equalsIgnoreCase("remove")){
|
||||
if(FightSystem.getFightState() == FightState.SETUP) {
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||
if(fightTeam != null) {
|
||||
Player target = Bukkit.getPlayer(args[1]);
|
||||
if(target != null) {
|
||||
FightPlayer fightPlayer = fightTeam.getFightPlayer(player);
|
||||
if(fightPlayer.isLeader() && fightTeam.isPlayerInTeam(target)){
|
||||
fightTeam.removePlayer(target);
|
||||
player.sendMessage(FightSystem.PREFIX + "§aDu hast den Spieler §6" + target.getName() + " §aaus dem Team entfernt!");
|
||||
target.sendMessage(FightSystem.PREFIX + "§cDu wurdest aus deinem Team entfernt!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Commands.kick(player, args[1]);
|
||||
}else if(args[0].equalsIgnoreCase("kit")) {
|
||||
if(FightSystem.getFightState() != FightState.SETUP) {
|
||||
player.sendMessage(FightSystem.PREFIX + "§cDu kannst dein Kit nicht mehr wechseln!");
|
||||
return false;
|
||||
}
|
||||
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||
if(fightTeam == null){
|
||||
player.sendMessage(FightSystem.PREFIX + "§cDu bist in keinem Team!");
|
||||
return false;
|
||||
}
|
||||
|
||||
Kit kit = KitManager.getKitByName(args[1]);
|
||||
if(kit == null){
|
||||
player.sendMessage(FightSystem.PREFIX + "§cDieses Kit existiert nicht!");
|
||||
return false;
|
||||
}
|
||||
|
||||
FightPlayer fightPlayer = fightTeam.getFightPlayer(player);
|
||||
if(
|
||||
(fightPlayer.isLeader() && !kit.isLeaderAllowed()) ||
|
||||
(!fightPlayer.isLeader() && !kit.isMemberAllowed())
|
||||
){
|
||||
player.sendMessage(FightSystem.PREFIX + "§cDu darfst dieses Kit nicht verwenden!");
|
||||
return false;
|
||||
}
|
||||
|
||||
//TODO: Owns Kit
|
||||
|
||||
Fight.getFightPlayer(player).setKit(kit);
|
||||
player.sendMessage(FightSystem.PREFIX + "§aDu hast nun das Kit §6" + args[1] + "§a!");
|
||||
|
||||
Commands.kit(player, args[1]);
|
||||
} else if(args[0].equalsIgnoreCase("addkit")){
|
||||
if(WarkingUser.get(player.getUniqueId()).getUserGroup() != UserGroup.Developer){
|
||||
Commands.sendHelp(player);
|
||||
@ -167,7 +140,6 @@ public class AkCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
fightTeam.setSchematic(schem);
|
||||
Fight.getPlayerTeam(player).broadcast(FightSystem.PREFIX + "Schematic §6" + args[1] + " §8wird für den Kampf verwendet!");
|
||||
}else
|
||||
Commands.sendHelp(player);
|
||||
break;
|
||||
|
@ -5,12 +5,14 @@ import me.yaruma.fightsystem.fight.Fight;
|
||||
import me.yaruma.fightsystem.fight.FightPlayer;
|
||||
import me.yaruma.fightsystem.fight.FightState;
|
||||
import me.yaruma.fightsystem.fight.FightTeam;
|
||||
import me.yaruma.fightsystem.utils.Config;
|
||||
import me.yaruma.fightsystem.kit.Kit;
|
||||
import me.yaruma.fightsystem.kit.KitManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Commands {
|
||||
class Commands {
|
||||
|
||||
private Commands(){}
|
||||
|
||||
private static void errNoTeam(Player p){
|
||||
p.sendMessage(FightSystem.PREFIX + "§cDu bist in keinem Team!");
|
||||
@ -60,7 +62,7 @@ public class Commands {
|
||||
private static Player checkGetPlayer(Player p, String t){
|
||||
Player target = Bukkit.getPlayer(t);
|
||||
if(target == null) {
|
||||
p.sendMessage(FightSystem.PREFIX + "§cDer Spieler ist nicht online!");
|
||||
p.sendMessage(FightSystem.PREFIX + "§cDer Spieler ist nicht in der Arena!");
|
||||
}
|
||||
return target;
|
||||
}
|
||||
@ -85,11 +87,9 @@ public class Commands {
|
||||
return;
|
||||
|
||||
FightPlayer leader = team.getLeader();
|
||||
team.addMember(p);
|
||||
p.setGameMode(GameMode.ADVENTURE);
|
||||
p.teleport(team.getSpawn());
|
||||
p.sendMessage(FightSystem.PREFIX + "§aDu bist Team " + team.getName() + " §abeigetreten!");
|
||||
leader.sendMessage(FightSystem.PREFIX + "§aDer Spieler §6" + p.getName() + " §aist deinem Team beigetreten!");
|
||||
leader.sendMessage(FightSystem.PREFIX + "§aDer Spieler §e" + p.getName() + " §aist deinem Team beigetreten!");
|
||||
team.addMember(p);
|
||||
}
|
||||
|
||||
static void declineInvitation(Player p){
|
||||
@ -101,9 +101,9 @@ public class Commands {
|
||||
return;
|
||||
|
||||
FightPlayer leader = team.getLeader();
|
||||
team.getInvited().remove(p);
|
||||
p.sendMessage(FightSystem.PREFIX + "§aDu hast die Einladung von " + team.getName() + " §aabgelehnt!");
|
||||
leader.sendMessage(FightSystem.PREFIX + "§cDer Spieler §6" + p.getName() + " §chat deine Einladung abgelehnt!");
|
||||
leader.sendMessage(FightSystem.PREFIX + "§cDer Spieler §e" + p.getName() + " §chat deine Einladung abgelehnt!");
|
||||
team.getInvited().remove(p);
|
||||
}
|
||||
|
||||
static void leaveTeam(Player p){
|
||||
@ -114,10 +114,8 @@ public class Commands {
|
||||
if(fightTeam == null)
|
||||
return;
|
||||
|
||||
fightTeam.removePlayer(p);
|
||||
p.setGameMode(GameMode.SPECTATOR);
|
||||
p.teleport(Config.SpecSpawn);
|
||||
p.sendMessage(FightSystem.PREFIX + "§aDu hast das Team " + fightTeam.getName() + " §averlassen!");
|
||||
fightTeam.removePlayer(p);
|
||||
}
|
||||
|
||||
static void invite(Player p, String invited){
|
||||
@ -137,7 +135,7 @@ public class Commands {
|
||||
return;
|
||||
|
||||
if(Fight.getPlayerTeam(target) != null) {
|
||||
p.sendMessage(FightSystem.PREFIX + "§cDer Spieler §6" + target.getName() + " §cist bereits in einem Team!");
|
||||
p.sendMessage(FightSystem.PREFIX + "§cDer Spieler §e" + target.getName() + " §cist bereits in einem Team!");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -146,23 +144,78 @@ public class Commands {
|
||||
return;
|
||||
}
|
||||
|
||||
target.sendMessage(FightSystem.PREFIX + "§aDu wurdest in das Team von §e" + p.getName() + " §aeingeladen!");
|
||||
p.sendMessage(FightSystem.PREFIX + "§aDu hast den Spieler §e" + target.getName() + " §ain dein Team eingeladen!");
|
||||
fightTeam.getInvited().add(target);
|
||||
target.sendMessage(FightSystem.PREFIX + "§aDu wurdest in das Team von §6" + p.getName() + " §aeingeladen!");
|
||||
p.sendMessage(FightSystem.PREFIX + "§aDu hast den Spieler §6" + target.getName() + " §ain dein Team eingeladen!");
|
||||
GUI.invitation(p, target);
|
||||
}
|
||||
|
||||
static void kick(Player p, String kicked){
|
||||
if(!checkSetupOver(p))
|
||||
return;
|
||||
|
||||
FightTeam fightTeam = checkGetTeam(p);
|
||||
if(fightTeam == null)
|
||||
return;
|
||||
|
||||
FightPlayer fightPlayer = checkGetLeader(p);
|
||||
if(fightPlayer == null)
|
||||
return;
|
||||
|
||||
Player target = checkGetPlayer(p, kicked);
|
||||
if(target == null)
|
||||
return;
|
||||
|
||||
if(!fightTeam.isPlayerInTeam(target)){
|
||||
p.sendMessage(FightSystem.PREFIX + "§cDer Spieler " + target.getName() + " §cist nicht in deinem Team§c!");
|
||||
return;
|
||||
}
|
||||
|
||||
p.sendMessage(FightSystem.PREFIX + "§aDu hast den Spieler §e" + target.getName() + " §aaus dem Team entfernt!");
|
||||
target.sendMessage(FightSystem.PREFIX + "§cDu wurdest aus dem Team entfernt!");
|
||||
fightTeam.removePlayer(target);
|
||||
}
|
||||
|
||||
static void kit(Player p, String kitName){
|
||||
if(!checkSetupOver(p))
|
||||
return;
|
||||
|
||||
FightPlayer fightPlayer = checkGetPlayer(p);
|
||||
if(fightPlayer == null)
|
||||
return;
|
||||
|
||||
Kit k = KitManager.getKitByName(kitName);
|
||||
if(k == null){
|
||||
p.sendMessage(FightSystem.PREFIX + "§cDieses Kit gibt es nicht!");
|
||||
return;
|
||||
}
|
||||
|
||||
if((fightPlayer.isLeader() && !k.isLeaderAllowed()) ||
|
||||
(!fightPlayer.isLeader() && !k.isMemberAllowed())){
|
||||
p.sendMessage(FightSystem.PREFIX + "§cDu darfst dieses Kit nicht verwenden!");
|
||||
return;
|
||||
}
|
||||
|
||||
p.sendMessage(FightSystem.PREFIX + "§aDu spielst nun mit dem Kit §e" + kitName + "§a!");
|
||||
fightPlayer.setKit(k);
|
||||
}
|
||||
|
||||
static void sendHelp(Player p) {
|
||||
p.sendMessage(FightSystem.PREFIX + "§7Hilfe für das Kampfsystem");
|
||||
p.sendMessage("§8/§6ak help §8- §7Zeigt diese Hilfeseite");
|
||||
p.sendMessage("§8/§6ak leader §8- §7Tritt einem Team als Leader bei");
|
||||
p.sendMessage("§8/§6ak kit <Kit> §8- §7Wähle ein Kit");
|
||||
p.sendMessage("§8/§6ak schem <Schematic> §8- §7Setze deine Schematic");
|
||||
p.sendMessage("§8/§6ready §8- §7Setzt das eigene Team auf bereit");
|
||||
p.sendMessage("§8/§6invite [Spieler] §8- §7Lade den Spieler in dein Team bei");
|
||||
p.sendMessage("§8/§6accept §8- §7Einladung annehmen");
|
||||
p.sendMessage("§8/§6decline §8- §7Einladung ablehnen");
|
||||
p.sendMessage("§8/§6leave §8- §7Team verlassen");
|
||||
p.sendMessage("§8/§eak help §8- §7Zeigt diese Hilfeseite");
|
||||
|
||||
FightPlayer fightPlayer = Fight.getFightPlayer(p);
|
||||
if(fightPlayer == null){
|
||||
p.sendMessage("§8/§eaccept §8- §7Einladung annehmen");
|
||||
p.sendMessage("§8/§edecline §8- §7Einladung ablehnen");
|
||||
}else{
|
||||
if(fightPlayer.isLeader()){
|
||||
p.sendMessage("§8/§eak schem §8<§eSchematic§8> - §7Setze deine Schematic");
|
||||
p.sendMessage("§8/§eready §8- §7Setzt das eigene Team auf bereit");
|
||||
p.sendMessage("§8/§einvite §8<§eSpieler§8> - §7Lade einen Spieler in dein Team ein");
|
||||
}
|
||||
p.sendMessage("§8/§ekit §8<§eKit§8> - §7Wähle ein Kit");
|
||||
p.sendMessage("§8/§eleave §8- §7Team verlassen");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,30 +1,90 @@
|
||||
package me.yaruma.fightsystem.commands;
|
||||
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
import de.warking.hunjy.MySQL.Schematic;
|
||||
import de.warking.hunjy.MySQL.WarkingUser;
|
||||
import javafx.util.Pair;
|
||||
import me.yaruma.fightsystem.FightSystem;
|
||||
import me.yaruma.fightsystem.fight.Fight;
|
||||
import me.yaruma.fightsystem.fight.FightPlayer;
|
||||
import me.yaruma.fightsystem.fight.FightTeam;
|
||||
import me.yaruma.fightsystem.kit.Kit;
|
||||
import me.yaruma.fightsystem.kit.KitManager;
|
||||
import me.yaruma.fightsystem.utils.Config;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GUI {
|
||||
|
||||
public static void invitation(Player p, Player target){
|
||||
private GUI(){}
|
||||
|
||||
static void invitation(Player p, Player target){
|
||||
SWInventory inv = new SWInventory(target, 9, "Einladung von " + p.getName());
|
||||
inv.setItem(0, Material.INK_SACK, (byte)10, "§aAnnehmen", () ->{
|
||||
target.performCommand("ak accept");
|
||||
inv.setItem(0, Material.INK_SACK, (byte)10, "§aAnnehmen", (ClickType click) ->{
|
||||
target.performCommand("accept");
|
||||
target.closeInventory();
|
||||
});
|
||||
inv.setItem(8, Material.INK_SACK, (byte)1, "§cAblehnen", () ->{
|
||||
target.performCommand("ak decline");
|
||||
inv.setItem(8, Material.INK_SACK, (byte)1, "§cAblehnen", (ClickType click) ->{
|
||||
target.performCommand("decline");
|
||||
target.closeInventory();
|
||||
});
|
||||
inv.addCloseCallback(() ->{
|
||||
inv.addCloseCallback((ClickType click) ->{
|
||||
if(Fight.getInvitedTeam(target) != null){
|
||||
target.sendMessage(FightSystem.PREFIX + "§7Tippe §8/§aaccept§7, um die Einladung §aanzunehmen");
|
||||
target.sendMessage(FightSystem.PREFIX + "§7Tippe §8/§cdecline§7, um die Einladung §cabzulehnen");
|
||||
}
|
||||
});
|
||||
inv.setCallback(-999, target::closeInventory);
|
||||
inv.setCallback(-999, (ClickType click) -> target.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
|
||||
public static void kitSelection(Player p){
|
||||
FightPlayer fightPlayer = Fight.getFightPlayer(p);
|
||||
List<Pair<SWItem, Kit>> iconList = new ArrayList<>();
|
||||
|
||||
List<Kit> kitList = KitManager.getKits(fightPlayer.isLeader());
|
||||
for(Kit k : kitList){
|
||||
iconList.add(new Pair<>(new SWItem(Material.LEATHER_CHESTPLATE, k.getName(), null, !k.isMemberAllowed(), null), k));
|
||||
}
|
||||
|
||||
SWListInv<Kit> inv = new SWListInv<>(p, "Kitauswahl", (ClickType click, Kit k) -> {
|
||||
p.performCommand("kit " + k.getName());
|
||||
p.closeInventory();
|
||||
}, iconList);
|
||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
|
||||
public static void preSchemDialog(Player p){
|
||||
SWInventory inv = new SWInventory(p, 9, Config.GameName + "-Auswahl");
|
||||
inv.setItem(8, Material.REDSTONE, "§eÖffentliches " + Config.GameName, (ClickType click) -> schemDialog(p, true));
|
||||
if(Schematic.getSchemsOfType(p.getUniqueId(), Config.SchematicType).isEmpty()){
|
||||
inv.setItem(0, Material.INK_SACK, (byte)8, "§7Keine privaten " + Config.GameName + " vorhanden", (ClickType click)->{});
|
||||
}else{
|
||||
inv.setItem(8, Material.CAULDRON_ITEM, "§ePrivates " + Config.GameName, (ClickType click) -> schemDialog(p, false));
|
||||
}
|
||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
|
||||
private static void schemDialog(Player p, boolean publicSchems){
|
||||
List<Pair<SWItem, Schematic>> schems;
|
||||
if(publicSchems)
|
||||
schems = SWListInv.getSchemList(0, Config.SchematicType);
|
||||
else
|
||||
schems = SWListInv.getSchemList(WarkingUser.get(p.getUniqueId()).getId(), Config.SchematicType);
|
||||
SWListInv<Schematic> inv = new SWListInv<>(p, Config.GameName + "-Auswahl", (ClickType click, Schematic s) -> {
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(p);
|
||||
fightTeam.setSchematic(s);
|
||||
p.closeInventory();
|
||||
}, schems);
|
||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||
inv.open();
|
||||
}
|
||||
}
|
||||
|
23
src/me/yaruma/fightsystem/commands/KitCommand.java
Normale Datei
23
src/me/yaruma/fightsystem/commands/KitCommand.java
Normale Datei
@ -0,0 +1,23 @@
|
||||
package me.yaruma.fightsystem.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class KitCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(args.length != 1)
|
||||
GUI.kitSelection(player);
|
||||
else{
|
||||
Commands.kit(player, args[0]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -11,19 +11,12 @@ public class FightPlayer {
|
||||
private boolean isOut;
|
||||
private Kit kit;
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof Player))
|
||||
return false;
|
||||
Player comp = (Player)obj;
|
||||
return this.player.getUniqueId().equals(comp.getUniqueId());
|
||||
}
|
||||
|
||||
public void sendMessage(String message) {
|
||||
if (this.player != null && this.player.isOnline())
|
||||
this.player.sendMessage(message);
|
||||
}
|
||||
|
||||
public FightPlayer(Player player, boolean isOut) {
|
||||
FightPlayer(Player player, boolean isOut) {
|
||||
this.player = player;
|
||||
this.isOut = isOut;
|
||||
kit = KitManager.getKitByName(Config.MemberDefault);
|
||||
@ -42,7 +35,8 @@ public class FightPlayer {
|
||||
}
|
||||
|
||||
public boolean isLeader() {
|
||||
return Fight.getPlayerTeam(player).getLeader().getPlayer() == player;
|
||||
FightPlayer leader = Fight.getPlayerTeam(player).getLeader();
|
||||
return leader != null && leader.getPlayer() == player;
|
||||
}
|
||||
|
||||
public Kit getKit() {
|
||||
|
@ -19,10 +19,12 @@ import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -32,9 +34,9 @@ import java.util.List;
|
||||
public class FightTeam {
|
||||
|
||||
private FightPlayer leader;
|
||||
private final ArrayList<FightPlayer> players;
|
||||
private final List<FightPlayer> players = new ArrayList<>();
|
||||
private boolean ready;
|
||||
private final ArrayList<Player> invited;
|
||||
private final List<Player> invited = new ArrayList<>();
|
||||
private final String name;
|
||||
private final String prefix;
|
||||
private Schematic schematic;
|
||||
@ -44,8 +46,6 @@ public class FightTeam {
|
||||
private final boolean rotate;
|
||||
|
||||
public FightTeam(String Name, String Prefix, Location Spawn, Vector Paste, boolean Rotate) {
|
||||
players = new ArrayList<>();
|
||||
invited = new ArrayList<>();
|
||||
spawn = Spawn;
|
||||
paste = Paste;
|
||||
name = Name;
|
||||
@ -69,7 +69,7 @@ public class FightTeam {
|
||||
}
|
||||
|
||||
public boolean allPlayersOut() {
|
||||
for(FightPlayer fightPlayer : this.players) {
|
||||
for(FightPlayer fightPlayer : players) {
|
||||
if(!fightPlayer.isOut())
|
||||
return false;
|
||||
}
|
||||
@ -77,7 +77,7 @@ public class FightTeam {
|
||||
}
|
||||
|
||||
public boolean isPlayerInTeam(Player player) {
|
||||
for(FightPlayer fightPlayer : this.players) {
|
||||
for(FightPlayer fightPlayer : players) {
|
||||
if(fightPlayer.getPlayer().equals(player))
|
||||
return true;
|
||||
}
|
||||
@ -97,21 +97,37 @@ public class FightTeam {
|
||||
}
|
||||
}
|
||||
|
||||
public void addMember(Player player) {
|
||||
public FightPlayer addMember(Player player) {
|
||||
FightPlayer fightPlayer = new FightPlayer(player, false);
|
||||
players.add(fightPlayer);
|
||||
invited.remove(player);
|
||||
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
player.teleport(spawn);
|
||||
player.getInventory().setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
|
||||
return fightPlayer;
|
||||
}
|
||||
|
||||
public void removePlayer(Player player) {
|
||||
FightPlayer fightPlayer = getFightPlayer(player);
|
||||
if(fightPlayer == null){
|
||||
System.out.println("FightPlayer == null! : " + player.getName());
|
||||
if(fightPlayer == null)
|
||||
return;
|
||||
}
|
||||
|
||||
players.remove(fightPlayer);
|
||||
if(fightPlayer.isLeader())
|
||||
fightPlayer.getPlayer().getInventory().clear();
|
||||
if(fightPlayer.equals(leader) && FightSystem.getFightState() == FightState.SETUP){
|
||||
this.leader = null;
|
||||
if(!players.isEmpty()) {
|
||||
setLeader(players.get(0));
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §e" + leader.getPlayer().getName() + " §aist nun Leader von Team " + getName() + "§a!");
|
||||
}else{
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cTeam " + getName() + " §chat keine Spieler mehr.\n Arena schließt...");
|
||||
Bukkit.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
player.teleport(Config.SpecSpawn);
|
||||
}
|
||||
|
||||
public boolean hasTeamLeader() {
|
||||
@ -125,12 +141,13 @@ public class FightTeam {
|
||||
public void setLeader(FightPlayer leader) {
|
||||
this.leader = leader;
|
||||
leader.setKit(KitManager.getKitByName(Config.LeaderDefault));
|
||||
if(!this.players.contains(leader)){
|
||||
this.players.add(leader);
|
||||
}
|
||||
Inventory inventory = leader.getPlayer().getInventory();
|
||||
inventory.setItem(3, new ItemBuilder(Material.INK_SACK, (short) 10).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
|
||||
inventory.setItem(5, new ItemBuilder(Material.INK_SACK, (short) 1).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§4Abbrechen").build());
|
||||
inventory.setItem(7, new ItemBuilder(Material.CAULDRON_ITEM).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§e" + Config.GameName + " wählen").build());
|
||||
}
|
||||
|
||||
public ArrayList<FightPlayer> getPlayers() {
|
||||
public List<FightPlayer> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
||||
@ -164,6 +181,8 @@ public class FightTeam {
|
||||
|
||||
public void setSchematic(Schematic schematic){
|
||||
this.schematic = schematic;
|
||||
broadcast(FightSystem.PREFIX + "§7Das §e" + Config.GameName + " " + schematic.getSchemName() + " §7wird für den Kampf verwendet!");
|
||||
leader.getPlayer().getInventory().clear(7);
|
||||
if(Fight.getOpposite(this).hasSchematic()){
|
||||
pasteSchematic();
|
||||
Fight.getOpposite(this).pasteSchematic();
|
||||
@ -196,7 +215,7 @@ public class FightTeam {
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<Player> getInvited() {
|
||||
public List<Player> getInvited() {
|
||||
return invited;
|
||||
}
|
||||
|
||||
|
@ -12,13 +12,13 @@ public class Kit {
|
||||
private ItemStack[] inventory;
|
||||
private ItemStack[] armor;
|
||||
|
||||
public Kit(String name, int price, boolean leaderAllowed, boolean memberAllowed, ItemStack[] Armor, ItemStack[] Inventory) {
|
||||
public Kit(String name, int price, boolean leaderAllowed, boolean memberAllowed, ItemStack[] armor, ItemStack[] inventory) {
|
||||
this.name = name;
|
||||
this.price = price;
|
||||
this.leaderAllowed = leaderAllowed;
|
||||
this.memberAllowed = memberAllowed;
|
||||
inventory = Inventory;
|
||||
armor = Armor;
|
||||
this.inventory = inventory;
|
||||
this.armor = armor;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
@ -86,4 +86,18 @@ public class KitManager {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<Kit> getKits(boolean leader){
|
||||
List<Kit> kits = new ArrayList<>();
|
||||
if(leader){
|
||||
for (Kit k : loadedKits)
|
||||
if (k.isLeaderAllowed())
|
||||
kits.add(k);
|
||||
}else{
|
||||
for (Kit k : loadedKits)
|
||||
if (k.isMemberAllowed())
|
||||
kits.add(k);
|
||||
}
|
||||
return kits;
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package me.yaruma.fightsystem.listener;
|
||||
|
||||
import me.yaruma.fightsystem.FightSystem;
|
||||
import me.yaruma.fightsystem.commands.GUI;
|
||||
import me.yaruma.fightsystem.fight.Fight;
|
||||
import me.yaruma.fightsystem.fight.FightPlayer;
|
||||
import me.yaruma.fightsystem.fight.FightState;
|
||||
import me.yaruma.fightsystem.fight.FightTeam;
|
||||
import me.yaruma.fightsystem.utils.Config;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -23,13 +23,15 @@ public class PlayerInteractListener implements Listener {
|
||||
if(instance.getFightState() == FightState.SETUP &&
|
||||
event.getItem() != null &&
|
||||
Fight.getPlayerTeam(player) != null) {
|
||||
Material material = event.getItem().getType();
|
||||
ItemMeta itemMeta = event.getItem().getItemMeta();
|
||||
String displayName = itemMeta.getDisplayName();
|
||||
event.setCancelled(true);
|
||||
|
||||
FightPlayer fightPlayer = Fight.getPlayerTeam(player).getFightPlayer(player);
|
||||
if(fightPlayer.isLeader() && material == Material.INK_SACK) {
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||
if(displayName.equals("§e" + Config.GameName + " wählen")){
|
||||
GUI.preSchemDialog(player);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (displayName) {
|
||||
case "§cNicht bereit":
|
||||
@ -42,13 +44,12 @@ public class PlayerInteractListener implements Listener {
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team von §a" + fightTeam.getLeader().getPlayer().getName() + " §6hat den Kampf abgebrochen! \n Server stoppt...");
|
||||
Bukkit.shutdown();
|
||||
break;
|
||||
default:
|
||||
event.setCancelled(true);
|
||||
case "§eKit wählen":
|
||||
GUI.kitSelection(player);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -2,20 +2,12 @@ package me.yaruma.fightsystem.listener;
|
||||
|
||||
import me.yaruma.fightsystem.FightSystem;
|
||||
import me.yaruma.fightsystem.fight.Fight;
|
||||
import me.yaruma.fightsystem.fight.FightPlayer;
|
||||
import me.yaruma.fightsystem.fight.FightState;
|
||||
import me.yaruma.fightsystem.fight.FightTeam;
|
||||
import me.yaruma.fightsystem.utils.Config;
|
||||
import me.yaruma.fightsystem.utils.countdown.Countdown;
|
||||
import me.yaruma.fightsystem.utils.countdown.CountdownType;
|
||||
import me.yaruma.fightsystem.utils.countdown.FinishSetupOver;
|
||||
import me.yaruma.fightsystem.utils.inventory.SetupItems;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -24,85 +16,38 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class PlayerJoinListener implements Listener {
|
||||
|
||||
private final FightSystem instance = FightSystem.getPlugin();
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerJoin(PlayerJoinEvent event) {
|
||||
event.setJoinMessage(null);
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
player.setHealth(20);
|
||||
player.setFoodLevel(20);
|
||||
player.getInventory().clear();
|
||||
|
||||
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||
|
||||
if (fightTeam == null) {
|
||||
|
||||
//TEXT COMPONENTS
|
||||
TextComponent publicList = new TextComponent("PUBLIC");
|
||||
publicList.setColor(ChatColor.GOLD);
|
||||
publicList.setBold(true);
|
||||
publicList.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§ePublic Liste...").create()));
|
||||
publicList.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ak schemlist public"));
|
||||
|
||||
TextComponent privateList = new TextComponent("PRIVATE");
|
||||
privateList.setColor(ChatColor.GOLD);
|
||||
privateList.setBold(true);
|
||||
privateList.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§ePrivate Liste...").create()));
|
||||
privateList.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ak schemlist 0"));
|
||||
//TEXT COMPONENTS
|
||||
|
||||
if(!Fight.getRedTeam().hasTeamLeader()) {
|
||||
Fight.getRedTeam().setLeader(new FightPlayer(player, false));
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
player.spigot().sendMessage(publicList);
|
||||
player.spigot().sendMessage(privateList);
|
||||
player.teleport(Config.TeamRedSpawn);
|
||||
SetupItems.giveSetupItems(player);
|
||||
} else if(!Fight.getBlueTeam().hasTeamLeader()) {
|
||||
Fight.getBlueTeam().setLeader(new FightPlayer(player, false));
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
player.spigot().sendMessage(publicList);
|
||||
player.spigot().sendMessage(privateList);
|
||||
player.teleport(Config.TeamBlueSpawn);
|
||||
SetupItems.giveSetupItems(player);
|
||||
if(!Fight.getRedTeam().hasTeamLeader() && FightSystem.getFightState() == FightState.SETUP) {
|
||||
Fight.getRedTeam().setLeader(Fight.getRedTeam().addMember(player));
|
||||
} else if(!Fight.getBlueTeam().hasTeamLeader() && FightSystem.getFightState() == FightState.SETUP) {
|
||||
Fight.getBlueTeam().setLeader(Fight.getBlueTeam().addMember(player));
|
||||
} else {
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
player.teleport(Config.SpecSpawn);
|
||||
}
|
||||
} else {
|
||||
FightPlayer fightPlayer = fightTeam.getFightPlayer(player);
|
||||
|
||||
if(instance.getFightState() == FightState.SETUP) {
|
||||
if(fightTeam == Fight.redTeam) {
|
||||
player.teleport(Config.TeamRedSpawn);
|
||||
} else
|
||||
player.teleport(Config.TeamBlueSpawn);
|
||||
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
Countdown.cancelTimerType(CountdownType.NO_PLAYERS_ONLINE);
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §6" + fightPlayer.getPlayer().getName() + " §aist dem Kampf beigetreten!");
|
||||
} else {
|
||||
player.teleport(fightTeam.getSpawn());
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
if(fightTeam == Fight.redTeam)
|
||||
player.teleport(Config.TeamRedSpawn);
|
||||
else
|
||||
player.teleport(Config.TeamBlueSpawn);
|
||||
}
|
||||
}
|
||||
|
||||
if(Fight.getRedTeam().hasTeamLeader() && Fight.getBlueTeam().hasTeamLeader() && instance.getFightState() == FightState.SETUP) {
|
||||
if(Fight.getRedTeam().getLeader().getPlayer() == player || Fight.getBlueTeam().getLeader().getPlayer() == player) {
|
||||
if(Fight.getRedTeam().hasTeamLeader() && Fight.getBlueTeam().hasTeamLeader() && FightSystem.getFightState() == FightState.SETUP
|
||||
&& (Fight.getRedTeam().getLeader().getPlayer() == player || Fight.getBlueTeam().getLeader().getPlayer() == player)) {
|
||||
Countdown.cancelTimerType(CountdownType.NO_PLAYERS_ONLINE);
|
||||
Countdown countdown = new Countdown(Config.SetupDuration, new FinishSetupOver());
|
||||
countdown.startTimer(instance);
|
||||
}
|
||||
new Countdown(Config.SetupDuration, new FinishSetupOver()).startTimer(FightSystem.getPlugin());
|
||||
}
|
||||
|
||||
instance.getScoreboard().setAutoScoreboard(20*10, player);
|
||||
FightSystem.getPlugin().getScoreboard().setAutoScoreboard(20*10, player);
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,22 +18,13 @@ public class PlayerQuitListener implements Listener {
|
||||
event.setQuitMessage(null);
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if(Fight.getPlayerTeam(player) == null) return;
|
||||
FightTeam fightTeam = Fight.getPlayerTeam(player);
|
||||
if(fightTeam == null)
|
||||
return;
|
||||
|
||||
FightState fightState = FightSystem.getPlugin().getFightState();
|
||||
FightState fightState = FightSystem.getFightState();
|
||||
if(fightState == FightState.SETUP){
|
||||
fightTeam.removePlayer(player);
|
||||
|
||||
if(fightTeam.isPlayerLeader(player)){
|
||||
if(!fightTeam.getPlayers().isEmpty()) {
|
||||
fightTeam.setLeader(fightTeam.getPlayers().get(0));
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §6" + fightTeam.getLeader().getPlayer().getName() + " §aist nun Leader von Team " + fightTeam.getName() + "§a!");
|
||||
}else{
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Team " + fightTeam.getName() + " hat keine Spieler mehr.\n Server stoppt...");
|
||||
Bukkit.shutdown();
|
||||
}
|
||||
}
|
||||
}else if(fightState == FightState.PRE_RUNNING || fightState == FightState.RUNNING){
|
||||
fightTeam.getFightPlayer(player).setOut(true);
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler §6" + player.getName() + " §chat den Kampf verlassen!");
|
||||
|
@ -1,7 +1,7 @@
|
||||
package me.yaruma.fightsystem.listener;
|
||||
|
||||
import me.yaruma.fightsystem.FightSystem;
|
||||
import me.yaruma.fightsystem.fight.Fight;
|
||||
import me.yaruma.fightsystem.fight.FightTeam;
|
||||
import me.yaruma.fightsystem.utils.Config;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -10,19 +10,13 @@ import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
|
||||
public class PlayerRespawnListener implements Listener {
|
||||
|
||||
private final FightSystem instance = FightSystem.getPlugin();
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerRespawn(PlayerRespawnEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if(Fight.getPlayerTeam(player) != null) {
|
||||
if(Fight.getPlayerTeam(player) == Fight.redTeam) {
|
||||
event.setRespawnLocation(Config.TeamRedSpawn);
|
||||
} else
|
||||
event.setRespawnLocation(Config.TeamBlueSpawn);
|
||||
} else
|
||||
FightTeam team = Fight.getPlayerTeam(player);
|
||||
if(team == null)
|
||||
event.setRespawnLocation(Config.SpecSpawn);
|
||||
else
|
||||
event.setRespawnLocation(team.getSpawn());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -9,11 +9,9 @@ import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
|
||||
public class ProjectileLaunchListener implements Listener {
|
||||
|
||||
FightSystem instance = FightSystem.getPlugin();
|
||||
|
||||
@EventHandler
|
||||
public void handleProjectileLaunch(ProjectileLaunchEvent event) {
|
||||
if(instance.getFightState() != FightState.RUNNING) {
|
||||
if(FightSystem.getFightState() != FightState.RUNNING) {
|
||||
event.setCancelled(true);
|
||||
if(event.getEntity().getShooter() instanceof Player){
|
||||
Player player = (Player) event.getEntity().getShooter();
|
||||
@ -21,6 +19,4 @@ public class ProjectileLaunchListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
package me.yaruma.fightsystem.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemBuilder {
|
||||
|
||||
private final ItemStack item;
|
||||
@ -43,7 +43,7 @@ public class ItemBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder addLore(ArrayList<String> lore) {
|
||||
public ItemBuilder addLore(List<String> lore) {
|
||||
meta.setLore(lore);
|
||||
return this;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import com.google.common.primitives.Bytes;
|
||||
import me.yaruma.fightsystem.FightSystem;
|
||||
import me.yaruma.fightsystem.fight.Fight;
|
||||
import me.yaruma.fightsystem.fight.FightTeam;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -37,7 +38,8 @@ public class TechHider {
|
||||
private static int redMaxX;
|
||||
private static int redMinZ;
|
||||
private static int redMaxZ;
|
||||
private static int obfuscateShift4;
|
||||
private static short obfuscateShift4;
|
||||
private static final short fullBitmask = 0x1FFF;
|
||||
private static Material obfuscateMaterial;
|
||||
|
||||
public static void init(){
|
||||
@ -57,7 +59,7 @@ public class TechHider {
|
||||
redMaxX = max / 16 + (max % 16 > 0 ? 1 : 0);
|
||||
max = Config.TeamRedCornerZ + Config.SchemsizeZ;
|
||||
redMaxZ = max / 16 + (max % 16 > 0 ? 1 : 0);
|
||||
obfuscateShift4 = Config.ObfuscateWith << 4;
|
||||
obfuscateShift4 = (short)(Config.ObfuscateWith << 4);
|
||||
//noinspection deprecation
|
||||
obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith);
|
||||
|
||||
@ -128,18 +130,17 @@ public class TechHider {
|
||||
i += readVarIntLength(Bytes.toArray(newData), i);
|
||||
i += dataArrayLength * 8;
|
||||
}else{
|
||||
System.out.println("Chunk with global palette!");
|
||||
int dataArrayLength = readVarInt(Bytes.toArray(newData), i);
|
||||
i += readVarIntLength(Bytes.toArray(newData), i);
|
||||
int arrayEnd = dataArrayLength * 8 + i;
|
||||
int bitsOver = 8; //9 bits (id) + 4 bits (metadata)
|
||||
final int globalMask = 0x000001FF;
|
||||
final byte replacement = 0x01;
|
||||
while(i < arrayEnd){
|
||||
int blockId = (newData.get(i++) & (globalMask >> 9 - bitsOver)) << 9-bitsOver;
|
||||
int blockId = (newData.get(i++) & (0x1FF >> 9 - bitsOver)) << 9-bitsOver;
|
||||
blockId += newData.get(i) >> bitsOver-1;
|
||||
if(Config.HiddenBlocks.contains(blockId)){
|
||||
System.out.println("Hidden Block found!");
|
||||
int bytei = newData.get(i);
|
||||
|
||||
}
|
||||
bitsOver -= 5; // 13-8
|
||||
if(bitsOver < 1){
|
||||
@ -255,6 +256,11 @@ public class TechHider {
|
||||
}
|
||||
}
|
||||
|
||||
private static void reloadChunks(){
|
||||
Player p = Bukkit.getPlayer("Lixfel");
|
||||
|
||||
}
|
||||
|
||||
private static int readVarInt(byte[] array, int startPos) {
|
||||
int numRead = 0;
|
||||
int result = 0;
|
||||
|
@ -1,36 +1,21 @@
|
||||
package me.yaruma.fightsystem.utils;
|
||||
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.util.EditSessionBuilder;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import de.warking.hunjy.MySQL.Schematic;
|
||||
import de.warking.hunjy.MySQL.SchematicType;
|
||||
import de.warking.hunjy.MySQL.WarkingUser;
|
||||
import me.yaruma.fightsystem.FightSystem;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class WorldEdit {
|
||||
|
||||
private WorldEdit(){}
|
||||
|
||||
public static void replace(Player player, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
|
||||
World weWorld = new BukkitWorld(player.getWorld());
|
||||
EditSession editSession = new EditSessionBuilder(weWorld).fastmode(true).build();
|
||||
@ -43,68 +28,12 @@ public class WorldEdit {
|
||||
targetBedrock.add(new BaseBlock(7));
|
||||
|
||||
try {
|
||||
int tnt = editSession.replaceBlocks(cuboidSelection.getRegionSelector().getRegion(), targetObsidian, new BaseBlock(46));
|
||||
int slime = editSession.replaceBlocks(cuboidSelection.getRegionSelector().getRegion(), targetBedrock, new BaseBlock(165));
|
||||
editSession.replaceBlocks(cuboidSelection.getRegionSelector().getRegion(), targetObsidian, new BaseBlock(46));
|
||||
editSession.replaceBlocks(cuboidSelection.getRegionSelector().getRegion(), targetBedrock, new BaseBlock(165));
|
||||
|
||||
editSession.flushQueue();
|
||||
} catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void pasteSchematic(File file, World world, Vector vector, boolean allowUndo, boolean pasteAir, AffineTransform affineTransform) {
|
||||
try {
|
||||
FaweAPI.load(file).paste(world, vector, allowUndo, pasteAir, affineTransform).flushQueue();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static int countBlocks(Player player, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, BaseBlock baseBlock) {
|
||||
World weWorld = new BukkitWorld(player.getWorld());
|
||||
EditSession editSession = new EditSessionBuilder(weWorld).fastmode(true).build();
|
||||
CuboidSelection cuboidSelection = new CuboidSelection(player.getWorld(), new Location(player.getWorld(), minX, minY, minZ), new Location(player.getWorld(), maxX, maxY, maxZ));
|
||||
Set<BaseBlock> target = new HashSet<>();
|
||||
target.add(baseBlock);
|
||||
try {
|
||||
return editSession.countBlocks(cuboidSelection.getRegionSelector().getRegion(), target);
|
||||
} catch (IncompleteRegionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void sendPlayerScheamticList(File folder, int currentPage, int filesPerPage, Player player) {
|
||||
File[] listOfFiles = folder.listFiles();
|
||||
|
||||
int pages = listOfFiles.length / filesPerPage;
|
||||
int currPage = currentPage;
|
||||
if(currPage > pages) {
|
||||
currPage = 0;
|
||||
}
|
||||
|
||||
for(int i = currPage * filesPerPage; i < (currPage * filesPerPage) + filesPerPage; i++) {
|
||||
|
||||
TextComponent schematics = new TextComponent(listOfFiles[i].toString());
|
||||
schematics.setColor(ChatColor.AQUA);
|
||||
schematics.setBold(true);
|
||||
|
||||
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Schematic benutzen...").create()));
|
||||
schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "")); //COMMAND MISSING
|
||||
|
||||
player.spigot().sendMessage(schematics);
|
||||
|
||||
|
||||
TextComponent nextPage = new TextComponent("Naechste Seite");
|
||||
nextPage.setColor(ChatColor.RED);
|
||||
|
||||
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Naechste Seite...").create()));
|
||||
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "")); //COMMAND MISSING
|
||||
|
||||
player.spigot().sendMessage(nextPage);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class Countdown {
|
||||
break;
|
||||
}
|
||||
time--;
|
||||
if(countdownCallback instanceof FinishTimeOver) FightSystem.getPlugin().fightTime = time;
|
||||
if(countdownCallback instanceof FinishTimeOver) FightSystem.setFightTime(time);
|
||||
}, 0, 20);
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
package me.yaruma.fightsystem.utils.countdown;
|
||||
|
||||
interface CountdownCallback {
|
||||
|
||||
String countdownCounting();
|
||||
void countdownFinished();
|
||||
CountdownType getType();
|
||||
|
||||
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class FinishNoneEntern implements CountdownCallback {
|
||||
|
||||
@Override
|
||||
public void countdownFinished() {
|
||||
FightSystem.getPlugin().entern = true;
|
||||
FightSystem.getPlugin().setEntern(true);
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§aEntern ist nun erlaubt!");
|
||||
}
|
||||
|
||||
|
@ -1,18 +0,0 @@
|
||||
package me.yaruma.fightsystem.utils.inventory;
|
||||
|
||||
import me.yaruma.fightsystem.utils.ItemBuilder;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class SetupItems {
|
||||
|
||||
public static void giveSetupItems(Player player) {
|
||||
Inventory inventory = player.getInventory();
|
||||
inventory.setItem(3, new ItemBuilder(Material.INK_SACK, (short) 10).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
|
||||
inventory.setItem(5, new ItemBuilder(Material.INK_SACK, (short) 1).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§4Abbrechen").build());
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -17,14 +17,14 @@ public class Scoreboard {
|
||||
private final org.bukkit.scoreboard.Scoreboard scoreboard;
|
||||
private final Objective objective;
|
||||
|
||||
public Scoreboard(FightSystem instance) {
|
||||
public Scoreboard() {
|
||||
ScoreboardManager scoreboardManager = Bukkit.getScoreboardManager();
|
||||
this.scoreboard = scoreboardManager.getNewScoreboard();
|
||||
this.objective = scoreboard.registerNewObjective("AAA", "BBB");
|
||||
}
|
||||
|
||||
public void setAutoScoreboard(int delay, Player player) {
|
||||
int taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(FightSystem.getPlugin(), new Runnable() {
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(FightSystem.getPlugin(), new Runnable() {
|
||||
|
||||
private int index = 0;
|
||||
|
||||
@ -61,8 +61,8 @@ public class Scoreboard {
|
||||
if (Config.Entern)
|
||||
objective.getScore("§7Entern: " + (FightSystem.getPlugin().isEntern() ? "§aja" : "§cnein")).setScore(2);
|
||||
if (Config.PercentSystem){
|
||||
objective.getScore("§eSchaden ROT: §c" + (Math.round(100.0 * WinconditionPercentSystem.getRedPercent()) / 100) + "%").setScore(1);
|
||||
objective.getScore("§eSchaden BLAU: §c" + (Math.round(100.0 * WinconditionPercentSystem.getBluePercent()) / 100) + "%").setScore(0);
|
||||
objective.getScore(Fight.getRedTeam().getPrefix() + "Schaden: §c" + (Math.round(100.0 * WinconditionPercentSystem.getRedPercent()) / 100.0) + "%").setScore(1);
|
||||
objective.getScore(Fight.getBlueTeam().getPrefix() + "Schaden: §c" + (Math.round(100.0 * WinconditionPercentSystem.getBluePercent()) / 100.0) + "%").setScore(0);
|
||||
}
|
||||
index = 0;
|
||||
}
|
||||
|
@ -39,11 +39,8 @@ public class WinconditionPercentSystem implements Listener {
|
||||
if(destroyPercent >= Config.PercentWin) {
|
||||
FightSystem.getPlugin().setSpectateState(Fight.blueTeam);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//Team Red
|
||||
if(Region.isInRange(entity.getLocation(), Config.TeamRedCornerX, Config.TeamRedCornerY, Config.TeamRedCornerZ, Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ, Config.BorderFromSchematic)) {
|
||||
}else if(Region.isInRange(entity.getLocation(), Config.TeamRedCornerX, Config.TeamRedCornerY, Config.TeamRedCornerZ, Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ, Config.BorderFromSchematic)) {
|
||||
redDestroyedBlocks = redDestroyedBlocks + event.blockList().size();
|
||||
double doubleRedDestroyedBlocks = redDestroyedBlocks;
|
||||
double destroyPercent = doubleRedDestroyedBlocks * 100 / schematicSize;
|
||||
@ -51,7 +48,6 @@ public class WinconditionPercentSystem implements Listener {
|
||||
if(destroyPercent >= Config.PercentWin) {
|
||||
FightSystem.getPlugin().setSpectateState(Fight.redTeam);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ public class WinconditionTechKO {
|
||||
|
||||
private static HashSet<Location> teamRedWater = new HashSet<>();
|
||||
private static HashSet<Location> teamBlueWater = new HashSet<>();
|
||||
public static int taskID;
|
||||
private static int taskID;
|
||||
|
||||
public static void addWater() {
|
||||
if(!Config.TechKO) return;
|
||||
@ -63,12 +63,12 @@ public class WinconditionTechKO {
|
||||
}
|
||||
|
||||
if(teamRedWater.isEmpty()) {
|
||||
Bukkit.getScheduler().cancelTask(taskID);
|
||||
Bukkit.getScheduler().cancelTask(getTaskID());
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + Config.TeamRedPrefix + Config.TeamRedName + " §6ist Tech K.O.!");
|
||||
FightSystem.getPlugin().setSpectateState(Fight.getBlueTeam());
|
||||
FightSystem.getPlugin().getWaterRemover().stop();
|
||||
} else if(teamBlueWater.isEmpty()) {
|
||||
Bukkit.getScheduler().cancelTask(taskID);
|
||||
Bukkit.getScheduler().cancelTask(getTaskID());
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + Config.TeamBluePrefix + Config.TeamBlueName + " §6ist Tech K.O.!");
|
||||
FightSystem.getPlugin().setSpectateState(Fight.getRedTeam());
|
||||
FightSystem.getPlugin().getWaterRemover().stop();
|
||||
@ -88,7 +88,7 @@ public class WinconditionTechKO {
|
||||
}
|
||||
}
|
||||
if(teamRedWater.isEmpty()) {
|
||||
Bukkit.getScheduler().cancelTask(taskID);
|
||||
Bukkit.getScheduler().cancelTask(getTaskID());
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + Config.TeamRedPrefix + Config.TeamRedName + " §6ist Tech K.O.!");
|
||||
FightSystem.getPlugin().setSpectateState(Fight.getBlueTeam());
|
||||
FightSystem.getPlugin().getWaterRemover().stop();
|
||||
@ -103,7 +103,7 @@ public class WinconditionTechKO {
|
||||
}
|
||||
}
|
||||
if(teamBlueWater.isEmpty()) {
|
||||
Bukkit.getScheduler().cancelTask(taskID);
|
||||
Bukkit.getScheduler().cancelTask(getTaskID());
|
||||
Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + Config.TeamBluePrefix + Config.TeamBlueName + " §6ist Tech K.O.!");
|
||||
FightSystem.getPlugin().setSpectateState(Fight.getRedTeam());
|
||||
FightSystem.getPlugin().getWaterRemover().stop();
|
||||
@ -112,7 +112,10 @@ public class WinconditionTechKO {
|
||||
|
||||
public static void startAutoChecker() {
|
||||
if(!Config.TechKO) return;
|
||||
taskID = Bukkit.getScheduler().scheduleAsyncRepeatingTask(FightSystem.getPlugin(), WinconditionTechKO::addWater, 0, 20*20);
|
||||
taskID = Bukkit.getScheduler().scheduleAsyncRepeatingTask(FightSystem.getPlugin(), WinconditionTechKO::addWater, 400, 400);
|
||||
}
|
||||
|
||||
public static int getTaskID() {
|
||||
return taskID;
|
||||
}
|
||||
}
|
||||
|
@ -11,3 +11,4 @@ commands:
|
||||
leave:
|
||||
invite:
|
||||
ready:
|
||||
kit:
|
In neuem Issue referenzieren
Einen Benutzer sperren