From 2a6f28b935ac40a505dc064335442cf50d5d5584 Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Thu, 21 Nov 2019 16:09:58 +0100 Subject: [PATCH 1/7] implemented schematic locking --- .../src/de/steamwar/fightsystem/FightSystem.java | 2 +- .../de/steamwar/fightsystem/commands/AkCommand.java | 12 +++++++++++- .../de/steamwar/fightsystem/commands/Commands.java | 6 +++--- .../fightsystem/countdown/TechKOCountdown.java | 4 ++-- .../src/de/steamwar/fightsystem/fight/Fight.java | 8 ++++++++ .../src/de/steamwar/fightsystem/fight/FightTeam.java | 12 ++++++++++-- .../fightsystem/listener/PlayerChatListener.java | 2 +- .../steamwar/fightsystem/utils/FightScoreboard.java | 2 +- .../winconditions/EventTeamOffWincondition.java | 2 +- .../winconditions/WinconditionAllDead.java | 4 ++-- .../winconditions/WinconditionCaptainDead.java | 4 ++-- .../winconditions/WinconditionWaterTechKO.java | 2 +- 12 files changed, 43 insertions(+), 17 deletions(-) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java index 01378c7..b9c863e 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java @@ -148,7 +148,7 @@ public class FightSystem extends JavaPlugin { Bukkit.broadcastMessage(" "); if(winFightTeam != null) { - Bukkit.broadcastMessage(PREFIX + "§aDas Team " + winFightTeam.getName() + " §ahat gewonnen!"); + Bukkit.broadcastMessage(PREFIX + "§aDas Team " + winFightTeam.getColoredName() + " §ahat gewonnen!"); } else { Bukkit.broadcastMessage(PREFIX + "§aKein Team hat gewonnen!"); } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/AkCommand.java b/FightSystem_Main/src/de/steamwar/fightsystem/commands/AkCommand.java index f19cfa3..709a875 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/commands/AkCommand.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/commands/AkCommand.java @@ -83,7 +83,17 @@ public class AkCommand implements CommandExecutor { player.sendMessage(FightSystem.PREFIX + "§cDu musst eine Seitenzahl angeben!"); return false; } - }else + } else if(args[0].equalsIgnoreCase("lockschem")) { + String teamName = args[1]; + FightTeam fightTeam = Fight.getTeamByName(teamName); + + if(fightTeam == null) { + player.sendMessage(FightSystem.PREFIX + "§cDieses Team existiert nicht!"); + return false; + } + fightTeam.getSchematic().setSchemType(SchematicType.Normal); + player.sendMessage(FightSystem.PREFIX + "Schematic von " + fightTeam.getColoredName() + "§cgepserrt!"); + } else Commands.sendHelp(player); break; case 3: diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/Commands.java b/FightSystem_Main/src/de/steamwar/fightsystem/commands/Commands.java index 1426932..25f6a83 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/commands/Commands.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/commands/Commands.java @@ -87,7 +87,7 @@ class Commands { return; FightPlayer leader = team.getLeader(); - p.sendMessage(FightSystem.PREFIX + "§aDu bist Team " + team.getName() + " §abeigetreten!"); + p.sendMessage(FightSystem.PREFIX + "§aDu bist Team " + team.getColoredName() + " §abeigetreten!"); leader.sendMessage(FightSystem.PREFIX + "§aDer Spieler §e" + p.getName() + " §aist deinem Team beigetreten!"); team.addMember(p); } @@ -101,7 +101,7 @@ class Commands { return; FightPlayer leader = team.getLeader(); - p.sendMessage(FightSystem.PREFIX + "§aDu hast die Einladung von " + team.getName() + " §aabgelehnt!"); + p.sendMessage(FightSystem.PREFIX + "§aDu hast die Einladung von " + team.getColoredName() + " §aabgelehnt!"); leader.sendMessage(FightSystem.PREFIX + "§cDer Spieler §e" + p.getName() + " §chat deine Einladung abgelehnt!"); team.getInvited().remove(p); } @@ -114,7 +114,7 @@ class Commands { if(fightTeam == null) return; - p.sendMessage(FightSystem.PREFIX + "§aDu hast das Team " + fightTeam.getName() + " §averlassen!"); + p.sendMessage(FightSystem.PREFIX + "§aDu hast das Team " + fightTeam.getColoredName() + " §averlassen!"); fightTeam.removePlayer(p); } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/TechKOCountdown.java b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/TechKOCountdown.java index b70a0b9..04e747d 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/TechKOCountdown.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/TechKOCountdown.java @@ -17,12 +17,12 @@ public class TechKOCountdown extends Countdown { @Override final String countdownCounting() { - return "bis " + team.getName() + " §7einen Schuss abgegeben haben muss!"; + return "bis " + team.getColoredName() + " §7einen Schuss abgegeben haben muss!"; } @Override void countdownFinished() { - Bukkit.broadcastMessage(FightSystem.PREFIX + team.getName() + "§7 ist §eTech K§8.§eO§8.!"); + Bukkit.broadcastMessage(FightSystem.PREFIX + team.getColoredName() + "§7 ist §eTech K§8.§eO§8.!"); FightSystem.setSpectateState(Fight.getOpposite(team)); } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java index e1fbc94..77e0e46 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java @@ -66,4 +66,12 @@ public class Fight { public static void setLevel(int level) { Bukkit.getServer().getOnlinePlayers().forEach(player -> player.setLevel(level)); } + + public static FightTeam getTeamByName(String name) { + if(redTeam.getName().equalsIgnoreCase(name)) + return redTeam; + if(blueTeam.getName().equalsIgnoreCase(name)) + return blueTeam; + return null; + } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java index d6d7dff..6f17de9 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -149,9 +149,9 @@ public class FightTeam implements IFightTeam{ this.leader = null; if(!players.isEmpty()) { setLeader(players.iterator().next()); - Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §e" + leader.getPlayer().getName() + " §aist nun Leader von Team " + getName() + "§a!"); + Bukkit.broadcastMessage(FightSystem.PREFIX + "§aDer Spieler §e" + leader.getPlayer().getName() + " §aist nun Leader von Team " + getColoredName() + "§a!"); }else if(!Config.event()){ - FightSystem.shutdown(FightSystem.PREFIX + "§cTeam " + getName() + " §chat keine Spieler mehr.\n Arena schließt..."); + FightSystem.shutdown(FightSystem.PREFIX + "§cTeam " + getColoredName() + " §chat keine Spieler mehr.\n Arena schließt..."); }else{ setLeader(null); } @@ -286,6 +286,10 @@ public class FightTeam implements IFightTeam{ } public String getName() { + return name; + } + + public String getColoredName() { return prefix + name; } @@ -293,6 +297,10 @@ public class FightTeam implements IFightTeam{ return prefix; } + public Schematic getSchematic() { + return schematic; + } + public Location getSpawn() { return spawn; } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PlayerChatListener.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/PlayerChatListener.java index 8b6957a..db8adb1 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PlayerChatListener.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/PlayerChatListener.java @@ -19,7 +19,7 @@ public class PlayerChatListener extends BasicListener { FightTeam fightTeam = Fight.getPlayerTeam(player); if(fightTeam != null) { - String teamName = fightTeam.getName(); + String teamName = fightTeam.getColoredName(); if(message.startsWith(Config.TeamChatDetection)) { fightTeam.broadcast(teamName + " " + player.getName() + "» " + message.substring(1)); } else { diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/FightScoreboard.java b/FightSystem_Main/src/de/steamwar/fightsystem/utils/FightScoreboard.java index 5b37a6a..4b985f3 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/utils/FightScoreboard.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/utils/FightScoreboard.java @@ -47,7 +47,7 @@ public class FightScoreboard { } private static void teamScoreboard(FightTeam fightTeam){ - objective.setDisplayName(fightTeam.getName()); + objective.setDisplayName(fightTeam.getColoredName()); fightTeam.getPlayers().forEach(fp -> { if(fp.isLiving()) objective.getScore(fightTeam.getPrefix() + fp.getPlayer().getName()).setScore((int) fp.getPlayer().getHealth()); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java index ce03f7a..0347f0d 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java @@ -14,7 +14,7 @@ public class EventTeamOffWincondition { private void teamOff(FightTeam team){ if(team.allPlayersOut()){ - Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + team.getName() + " §6ist Offline!"); + Bukkit.broadcastMessage(FightSystem.PREFIX + "§6Das Team " + team.getColoredName() + " §6ist Offline!"); FightSystem.setSpectateState(Fight.getOpposite(team)); } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java index 747dc29..1549a49 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java @@ -25,7 +25,7 @@ public class WinconditionAllDead extends PlayerWincondition { FightTeam fightTeam = Fight.getPlayerTeam(player); if(fightTeam.allPlayersOut()) { - Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer letzte Spieler aus " + fightTeam.getPrefix() + fightTeam.getName() + " §cist gestorben!"); + Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer letzte Spieler aus " + fightTeam.getPrefix() + fightTeam.getColoredName() + " §cist gestorben!"); FightSystem.setSpectateState(Fight.getOpposite(fightTeam)); } } @@ -39,7 +39,7 @@ public class WinconditionAllDead extends PlayerWincondition { FightTeam fightTeam = Fight.getPlayerTeam(player); if(fightTeam.allPlayersOut()) { - Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer letzte Spieler aus §6" + fightTeam.getPrefix() + fightTeam.getName() + " §chat den Kampf verlassen!"); + Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer letzte Spieler aus §6" + fightTeam.getPrefix() + fightTeam.getColoredName() + " §chat den Kampf verlassen!"); FightSystem.setSpectateState(Fight.getOpposite(fightTeam)); } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java index 4352b13..f8c4956 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java @@ -25,7 +25,7 @@ public class WinconditionCaptainDead extends PlayerWincondition { FightTeam fightTeam = Fight.getPlayerTeam(player); if(fightTeam.isPlayerLeader(player)) { - Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von " + fightTeam.getPrefix() + fightTeam.getName() + " §cist gestorben!"); + Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von " + fightTeam.getPrefix() + fightTeam.getColoredName() + " §cist gestorben!"); FightSystem.setSpectateState(Fight.getOpposite(fightTeam)); } } @@ -39,7 +39,7 @@ public class WinconditionCaptainDead extends PlayerWincondition { FightTeam fightTeam = Fight.getPlayerTeam(player); if(fightTeam.isPlayerLeader(player)) { - Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von " + fightTeam.getPrefix() + fightTeam.getName() + " §chat den Kampf verlassen!"); + Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Leader von " + fightTeam.getPrefix() + fightTeam.getColoredName() + " §chat den Kampf verlassen!"); FightSystem.setSpectateState(Fight.getOpposite(fightTeam)); } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java index a7ba9ac..6ea2d29 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java @@ -79,7 +79,7 @@ public class WinconditionWaterTechKO { private static void checkEmpty(FightTeam team, Set teamWater){ if(teamWater.isEmpty()){ - Bukkit.broadcastMessage(FightSystem.PREFIX + "§eDas Team " + team.getName() + " §eist Tech K.O.!"); + Bukkit.broadcastMessage(FightSystem.PREFIX + "§eDas Team " + team.getColoredName() + " §eist Tech K.O.!"); Bukkit.getScheduler().runTask(FightSystem.getPlugin(), () -> FightSystem.setSpectateState(Fight.getOpposite(team))); } } From f0797c041dff6249b1fd4ba1158c7a149997b347 Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Thu, 21 Nov 2019 16:20:57 +0100 Subject: [PATCH 2/7] added new comment to lock schematic --- .../de/steamwar/fightsystem/FightSystem.java | 1 + .../fightsystem/commands/AkCommand.java | 10 ------ .../commands/LockschemCommand.java | 31 +++++++++++++++++++ FightSystem_Main/src/plugin.yml | 3 +- 4 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java index b9c863e..51dd3a1 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java @@ -69,6 +69,7 @@ public class FightSystem extends JavaPlugin { getCommand("ready").setExecutor(new ReadyCommand()); getCommand("ak").setExecutor(new AkCommand()); getCommand("leader").setExecutor(new LeaderCommand()); + getCommand("lockschem").setExecutor(new LockschemCommand()); if(Config.event()) { new EventJoinListener(); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/AkCommand.java b/FightSystem_Main/src/de/steamwar/fightsystem/commands/AkCommand.java index 709a875..d98aaf1 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/commands/AkCommand.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/commands/AkCommand.java @@ -83,16 +83,6 @@ public class AkCommand implements CommandExecutor { player.sendMessage(FightSystem.PREFIX + "§cDu musst eine Seitenzahl angeben!"); return false; } - } else if(args[0].equalsIgnoreCase("lockschem")) { - String teamName = args[1]; - FightTeam fightTeam = Fight.getTeamByName(teamName); - - if(fightTeam == null) { - player.sendMessage(FightSystem.PREFIX + "§cDieses Team existiert nicht!"); - return false; - } - fightTeam.getSchematic().setSchemType(SchematicType.Normal); - player.sendMessage(FightSystem.PREFIX + "Schematic von " + fightTeam.getColoredName() + "§cgepserrt!"); } else Commands.sendHelp(player); break; diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java b/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java new file mode 100644 index 0000000..54b8e24 --- /dev/null +++ b/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java @@ -0,0 +1,31 @@ +package de.steamwar.fightsystem.commands; + +import de.steamwar.fightsystem.FightSystem; +import de.steamwar.fightsystem.fight.Fight; +import de.steamwar.fightsystem.fight.FightTeam; +import de.steamwar.sql.SchematicType; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class LockschemCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + Player player = (Player) sender; + if(!(sender instanceof Player)) { + if(args.length == 1) { + String teamName = args[1]; + FightTeam fightTeam = Fight.getTeamByName(teamName); + + if(fightTeam == null) { + player.sendMessage(FightSystem.PREFIX + "§cDieses Team existiert nicht!"); + return false; + } + fightTeam.getSchematic().setSchemType(SchematicType.Normal); + player.sendMessage(FightSystem.PREFIX + "Schematic von " + fightTeam.getColoredName() + "§cgepserrt!"); + } + } + return false; + } +} diff --git a/FightSystem_Main/src/plugin.yml b/FightSystem_Main/src/plugin.yml index 2064fea..3291afc 100644 --- a/FightSystem_Main/src/plugin.yml +++ b/FightSystem_Main/src/plugin.yml @@ -13,4 +13,5 @@ commands: ready: kit: remove: - leader: \ No newline at end of file + leader: + lockschem: \ No newline at end of file From cc18882a52fd485ee767c51c16ac4936fb974d2d Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Thu, 21 Nov 2019 16:23:02 +0100 Subject: [PATCH 3/7] hotfix --- .../src/de/steamwar/fightsystem/commands/LockschemCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java b/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java index 54b8e24..c69a39c 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java @@ -13,7 +13,7 @@ public class LockschemCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { Player player = (Player) sender; - if(!(sender instanceof Player)) { + if(sender instanceof Player) { if(args.length == 1) { String teamName = args[1]; FightTeam fightTeam = Fight.getTeamByName(teamName); From c6efe8a5f45ae9ea0e55d9e9347f99b8a1e41fc6 Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Thu, 21 Nov 2019 19:40:59 +0100 Subject: [PATCH 4/7] code cleanup --- .../commands/LockschemCommand.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java b/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java index c69a39c..b63b6d2 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java @@ -4,6 +4,8 @@ import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.sql.SchematicType; +import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.UserGroup; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -13,8 +15,20 @@ public class LockschemCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { Player player = (Player) sender; - if(sender instanceof Player) { - if(args.length == 1) { + if(!(sender instanceof Player)) { + return false; + } + SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); + UserGroup userGroup = steamwarUser.getUserGroup(); + + if(userGroup != UserGroup.Admin && + userGroup != UserGroup.Developer && + userGroup != UserGroup.Moderator && + userGroup != UserGroup.Supporter) + return false; + + switch (args.length) { + case 1: String teamName = args[1]; FightTeam fightTeam = Fight.getTeamByName(teamName); @@ -24,7 +38,6 @@ public class LockschemCommand implements CommandExecutor { } fightTeam.getSchematic().setSchemType(SchematicType.Normal); player.sendMessage(FightSystem.PREFIX + "Schematic von " + fightTeam.getColoredName() + "§cgepserrt!"); - } } return false; } From c6459884a04485f9c23800a956e53a97802f80c6 Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Sat, 23 Nov 2019 20:50:21 +0100 Subject: [PATCH 5/7] code cleanup; bugfix --- .../commands/LockschemCommand.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java b/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java index b63b6d2..a28d0c9 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java @@ -27,18 +27,24 @@ public class LockschemCommand implements CommandExecutor { userGroup != UserGroup.Supporter) return false; - switch (args.length) { - case 1: - String teamName = args[1]; - FightTeam fightTeam = Fight.getTeamByName(teamName); - if(fightTeam == null) { - player.sendMessage(FightSystem.PREFIX + "§cDieses Team existiert nicht!"); - return false; - } - fightTeam.getSchematic().setSchemType(SchematicType.Normal); - player.sendMessage(FightSystem.PREFIX + "Schematic von " + fightTeam.getColoredName() + "§cgepserrt!"); + if(args.length == 1) { + String teamName = args[0]; + FightTeam fightTeam = Fight.getTeamByName(teamName); + + if(fightTeam == null) { + player.sendMessage(FightSystem.PREFIX + "§cDieses Team existiert nicht!"); + return false; + } + fightTeam.getSchematic().setSchemType(SchematicType.Normal); + player.sendMessage(FightSystem.PREFIX + "Schematic von " + fightTeam.getColoredName() + " §cgesperrt!"); + return false; } + sendHelp(player); return false; } + + private void sendHelp(Player player) { + player.sendMessage(FightSystem.PREFIX + "/lockschem [TEAM]"); + } } From 284542e23d188ebc31ad4affdda948ec1af455df Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Sat, 23 Nov 2019 20:55:28 +0100 Subject: [PATCH 6/7] hotfix --- .../src/de/steamwar/fightsystem/commands/LockschemCommand.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java b/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java index a28d0c9..ed08e02 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java @@ -14,10 +14,11 @@ import org.bukkit.entity.Player; public class LockschemCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - Player player = (Player) sender; if(!(sender instanceof Player)) { return false; } + Player player = (Player) sender; + SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); UserGroup userGroup = steamwarUser.getUserGroup(); From feb7939ee74763723347a70417171e91e63efa5c Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Sat, 23 Nov 2019 22:08:04 +0100 Subject: [PATCH 7/7] code cleanup --- .../commands/LockschemCommand.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java b/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java index ed08e02..99fa2e3 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java @@ -14,9 +14,8 @@ import org.bukkit.entity.Player; public class LockschemCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if(!(sender instanceof Player)) { + if(!(sender instanceof Player)) return false; - } Player player = (Player) sender; SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); @@ -29,19 +28,20 @@ public class LockschemCommand implements CommandExecutor { return false; - if(args.length == 1) { - String teamName = args[0]; - FightTeam fightTeam = Fight.getTeamByName(teamName); - - if(fightTeam == null) { - player.sendMessage(FightSystem.PREFIX + "§cDieses Team existiert nicht!"); - return false; - } - fightTeam.getSchematic().setSchemType(SchematicType.Normal); - player.sendMessage(FightSystem.PREFIX + "Schematic von " + fightTeam.getColoredName() + " §cgesperrt!"); + if(args.length != 1) { + sendHelp(player); return false; } - sendHelp(player); + + String teamName = args[0]; + FightTeam fightTeam = Fight.getTeamByName(teamName); + + if(fightTeam == null) { + player.sendMessage(FightSystem.PREFIX + "§cDieses Team existiert nicht!"); + return false; + } + fightTeam.getSchematic().setSchemType(SchematicType.Normal); + player.sendMessage(FightSystem.PREFIX + "Schematic von " + fightTeam.getColoredName() + " §cgesperrt!"); return false; }