From e11fdd39315e1417cfc97326209ce62e36846d40 Mon Sep 17 00:00:00 2001 From: Luca Date: Tue, 23 Nov 2021 13:33:01 +0100 Subject: [PATCH] Redid all commands, Added Party chat and added Settingsmenu --- src/main/java/rip/tilly/bedwars/BedWars.java | 2 +- .../bedwars/commands/arena/ArenaCommand.java | 10 +- .../bedwars/commands/arena/CreateCommand.java | 5 + .../arena/EnableAndDisableCommand.java | 7 +- .../commands/arena/GenerateCommand.java | 19 +++- .../bedwars/commands/arena/InfoCommand.java | 51 +++++++++-- .../bedwars/commands/arena/RemoveCommand.java | 7 +- .../bedwars/commands/arena/SetACommand.java | 7 +- .../bedwars/commands/arena/SetBCommand.java | 7 +- .../commands/arena/SetBuildMaxCommand.java | 7 +- .../commands/arena/SetDeadZoneCommand.java | 7 +- .../arena/SetDiamondGeneratorCommand.java | 7 +- .../arena/SetEmeraldGeneratorCommand.java | 7 +- .../commands/arena/SetIconCommand.java | 7 +- .../bedwars/commands/arena/SetMaxCommand.java | 7 +- .../bedwars/commands/arena/SetMinCommand.java | 7 +- .../commands/arena/SetTeamAMaxCommand.java | 7 +- .../commands/arena/SetTeamAMinCommand.java | 7 +- .../commands/arena/SetTeamBMaxCommand.java | 7 +- .../commands/arena/SetTeamBMinCommand.java | 7 +- .../arena/SetTeamGeneratorCommand.java | 7 +- .../bedwars/commands/level/LevelCommand.java | 2 +- .../bedwars/commands/party/ChatCommand.java | 50 ++++++++++ .../bedwars/commands/party/PartyCommand.java | 13 ++- .../commands/toggle/PartyChatCommand.java | 32 +++++++ .../commands/toggle/ScoreboardCommand.java | 32 +++++++ .../commands/toggle/ToggleCommand.java | 35 +++++++ .../tilly/bedwars/commands/xp/XpCommand.java | 2 +- .../bedwars/listeners/InteractListener.java | 4 +- .../bedwars/listeners/PartyChatListener.java | 34 +++++++ .../bedwars/managers/CommandManager.java | 3 + .../tilly/bedwars/managers/party/Party.java | 3 +- .../bedwars/menus/settings/SettingsMenu.java | 91 +++++++++++++++++++ .../bedwars/playerdata/PlayerSettings.java | 1 + src/main/resources/plugin.yml | 4 +- 35 files changed, 459 insertions(+), 46 deletions(-) create mode 100644 src/main/java/rip/tilly/bedwars/commands/party/ChatCommand.java create mode 100644 src/main/java/rip/tilly/bedwars/commands/toggle/PartyChatCommand.java create mode 100644 src/main/java/rip/tilly/bedwars/commands/toggle/ScoreboardCommand.java create mode 100644 src/main/java/rip/tilly/bedwars/commands/toggle/ToggleCommand.java create mode 100644 src/main/java/rip/tilly/bedwars/listeners/PartyChatListener.java create mode 100644 src/main/java/rip/tilly/bedwars/menus/settings/SettingsMenu.java diff --git a/src/main/java/rip/tilly/bedwars/BedWars.java b/src/main/java/rip/tilly/bedwars/BedWars.java index c7583af..cbe979b 100644 --- a/src/main/java/rip/tilly/bedwars/BedWars.java +++ b/src/main/java/rip/tilly/bedwars/BedWars.java @@ -136,7 +136,7 @@ public final class BedWars extends JavaPlugin { Arrays.asList( new PlayerDataListener(), new RandomListeners(), new InteractListener(), new ButtonListener(), new MenuListener(), new GameStartListener(), new GameEndListener(), new WorldListener(), - new MovementListener(), new PlayerKillListener(), new DamageListener() + new MovementListener(), new PlayerKillListener(), new DamageListener(), new PartyChatListener() ).forEach(listener -> this.getServer().getPluginManager().registerEvents(listener, this)); } diff --git a/src/main/java/rip/tilly/bedwars/commands/arena/ArenaCommand.java b/src/main/java/rip/tilly/bedwars/commands/arena/ArenaCommand.java index 18c81d3..211c45e 100644 --- a/src/main/java/rip/tilly/bedwars/commands/arena/ArenaCommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/arena/ArenaCommand.java @@ -43,9 +43,9 @@ public class ArenaCommand implements CommandExecutor { player.sendMessage(CC.translate("&7⚫ &9/arena setTeamBMax &7- &eSet team B max")); player.sendMessage(CC.translate("&7⚫ &9/arena setDeadZone &7- &eSet the dead zone")); player.sendMessage(CC.translate("&7⚫ &9/arena setBuildMax &7- &eSet the build max")); - player.sendMessage(CC.translate("&7⚫ &9/arena setPlayerGenerator <&7- &eSet the player's generator")); - player.sendMessage(CC.translate("&7⚫ &9/arena setDiamondGenerator <&7- &eSet the diamond generator")); - player.sendMessage(CC.translate("&7⚫ &9/arena setEmeraldGenerator <&7- &eSet the emerald generator")); + player.sendMessage(CC.translate("&7⚫ &9/arena setTeamGenerator &7- &eSet the team's generator")); + player.sendMessage(CC.translate("&7⚫ &9/arena setDiamondGenerator &7- &eSet the diamond generator")); + player.sendMessage(CC.translate("&7⚫ &9/arena setEmeraldGenerator &7- &eSet the emerald generator")); player.sendMessage(CC.translate("&7⚫ &9/arena list &7- &eLook at all of the arenas")); player.sendMessage(CC.translate("&7⚫ &9/arena save &7- &eSave all of the arenas")); player.sendMessage(CC.translate("&7⚫ &9/arena manage &7- &eOpen the arena manage menu")); @@ -127,10 +127,10 @@ public class ArenaCommand implements CommandExecutor { break; case "list": - player.sendMessage(CC.translate("&b&lArenas List &7(&3Total: " + this.main.getArenaManager().getArenas().size() + "&7)")); + player.sendMessage(CC.translate("&9&lArenas List &7(&eTotal: " + this.main.getArenaManager().getArenas().size() + "&7)")); for (Arena arena : this.main.getArenaManager().getArenas().values()) { - player.sendMessage(CC.translate(" &7▸ &b" + arena.getName() + " &7(" + (arena.isEnabled() ? "&aEnabled" : "&cDisabled") + "&7)")); + player.sendMessage(CC.translate("&7⚫ &9" + arena.getName() + " &7(" + (arena.isEnabled() ? "&aEnabled" : "&cDisabled") + "&7)")); } break; diff --git a/src/main/java/rip/tilly/bedwars/commands/arena/CreateCommand.java b/src/main/java/rip/tilly/bedwars/commands/arena/CreateCommand.java index d053f19..0d7d626 100644 --- a/src/main/java/rip/tilly/bedwars/commands/arena/CreateCommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/arena/CreateCommand.java @@ -19,6 +19,11 @@ public class CreateCommand extends BaseCommand { public void executeAs(CommandSender sender, Command cmd, String label, String[] args) { Player player = (Player) sender; + if (args.length == 0) { + player.sendMessage(CC.translate("&cError: no arena found! /arena ")); + return; + } + Arena arena = this.main.getArenaManager().getArena(args[1]); if (arena == null) { diff --git a/src/main/java/rip/tilly/bedwars/commands/arena/EnableAndDisableCommand.java b/src/main/java/rip/tilly/bedwars/commands/arena/EnableAndDisableCommand.java index 3ea07a1..5b09d19 100644 --- a/src/main/java/rip/tilly/bedwars/commands/arena/EnableAndDisableCommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/arena/EnableAndDisableCommand.java @@ -19,6 +19,11 @@ public class EnableAndDisableCommand extends BaseCommand { public void executeAs(CommandSender sender, Command cmd, String label, String[] args) { Player player = (Player) sender; + if (args.length == 0) { + player.sendMessage(CC.translate("&cError: no arena found! /arena ")); + return; + } + Arena arena = this.main.getArenaManager().getArena(args[1]); if (arena != null) { @@ -26,7 +31,7 @@ public class EnableAndDisableCommand extends BaseCommand { player.sendMessage(arena.isEnabled() ? CC.translate("&aSuccessfully enabled the arena called &a&l" + args[1]) : CC.translate("&cSuccessfully disabled the arena called &c&l" + args[1])); } else { - player.sendMessage(CC.translate("&cThis arena does not already exist")); + player.sendMessage(CC.translate("&cThis arena does not exist")); } } diff --git a/src/main/java/rip/tilly/bedwars/commands/arena/GenerateCommand.java b/src/main/java/rip/tilly/bedwars/commands/arena/GenerateCommand.java index 0e0ec00..793f806 100644 --- a/src/main/java/rip/tilly/bedwars/commands/arena/GenerateCommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/arena/GenerateCommand.java @@ -20,14 +20,23 @@ public class GenerateCommand extends BaseCommand { public void executeAs(CommandSender sender, Command cmd, String label, String[] args) { Player player = (Player) sender; + if (args.length == 0) { + player.sendMessage(CC.translate("&cError: no arena found! /arena ")); + return; + } + Arena arena = this.main.getArenaManager().getArena(args[1]); - if (args.length == 3) { - int arenas = Integer.parseInt(args[2]); - this.main.getServer().getScheduler().runTask(this.main, new ArenaCommandRunnable(this.main, arena, arenas)); - this.main.getArenaManager().setGeneratingArenaRunnable(this.main.getArenaManager().getGeneratingArenaRunnable() + 1); + if (arena != null) { + if (args.length == 3) { + int arenas = Integer.parseInt(args[2]); + this.main.getServer().getScheduler().runTask(this.main, new ArenaCommandRunnable(this.main, arena, arenas)); + this.main.getArenaManager().setGeneratingArenaRunnable(this.main.getArenaManager().getGeneratingArenaRunnable() + 1); + } else { + player.sendMessage(CC.translate("&cUsage: /arena generate ")); + } } else { - player.sendMessage(CC.translate("&cUsage: /arena generate ")); + player.sendMessage(CC.translate("&cThis arena does not exist")); } } diff --git a/src/main/java/rip/tilly/bedwars/commands/arena/InfoCommand.java b/src/main/java/rip/tilly/bedwars/commands/arena/InfoCommand.java index 9a7efdb..a648b68 100644 --- a/src/main/java/rip/tilly/bedwars/commands/arena/InfoCommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/arena/InfoCommand.java @@ -7,9 +7,11 @@ import rip.tilly.bedwars.BedWars; import rip.tilly.bedwars.commands.BaseCommand; import rip.tilly.bedwars.game.arena.Arena; import rip.tilly.bedwars.utils.CC; +import rip.tilly.bedwars.utils.CustomLocation; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; public class InfoCommand extends BaseCommand { @@ -19,18 +21,49 @@ public class InfoCommand extends BaseCommand { public void executeAs(CommandSender sender, Command cmd, String label, String[] args) { Player player = (Player) sender; + if (args.length == 0) { + player.sendMessage(CC.translate("&cError: no arena found! /arena ")); + return; + } + Arena arena = this.main.getArenaManager().getArena(args[1]); if (arena != null) { - player.sendMessage(CC.translate("&b&lArena Information")); - player.sendMessage(CC.translate("")); - player.sendMessage(CC.translate(" &7▸ &bName: &3" + arena.getName())); - player.sendMessage(CC.translate(" &7▸ &bState: " + (arena.isEnabled() ? "&aEnabled" : "&cDisabled"))); - player.sendMessage(CC.translate(" &7▸ &b1st Spawn: &3" + Math.round(arena.getA().getX()) + "&7, &b" + Math.round(arena.getA().getY()) + "&7, &b" + Math.round(arena.getA().getZ()))); - player.sendMessage(CC.translate(" &7▸ &b2nd Spawn: &3" + Math.round(arena.getB().getX()) + "&7, &b" + Math.round(arena.getB().getY()) + "&7, &b" + Math.round(arena.getB().getZ()))); - player.sendMessage(CC.translate(" &7▸ &bMin Location: &3" + Math.round(arena.getMin().getX()) + "&7, &b" + Math.round(arena.getMin().getY()) + "&7, &b" + Math.round(arena.getMin().getZ()))); - player.sendMessage(CC.translate(" &7▸ &bMax Location: &3" + Math.round(arena.getMax().getX()) + "&7, &b" + Math.round(arena.getMax().getY()) + "&7, &b" + Math.round(arena.getMax().getZ()))); - player.sendMessage(CC.translate(" &7▸ &bAvailable Arenas: &3" + (arena.getAvailableArenas().size() == 0 ? +1 : arena.getAvailableArenas().size()))); + player.sendMessage(CC.translate(CC.chatBar)); + player.sendMessage(CC.translate("&dArena Information &7(&e" + arena.getName() + "&7)")); + player.sendMessage(CC.translate(CC.chatBar)); + player.sendMessage(CC.translate("&7⚫ &9Name: &e" + arena.getName())); + player.sendMessage(CC.translate("&7⚫ &9State: " + (arena.isEnabled() ? "&aEnabled" : "&cDisabled"))); + player.sendMessage(CC.translate("&7⚫ &91st Spawn: &e" + Math.round(arena.getA().getX()) + "&7, &e" + Math.round(arena.getA().getY()) + "&7, &e" + Math.round(arena.getA().getZ()))); + player.sendMessage(CC.translate("&7⚫ &92nd Spawn: &e" + Math.round(arena.getB().getX()) + "&7, &e" + Math.round(arena.getB().getY()) + "&7, &e" + Math.round(arena.getB().getZ()))); + player.sendMessage(CC.translate("&7⚫ &9Min Location: &e" + Math.round(arena.getMin().getX()) + "&7, &e" + Math.round(arena.getMin().getY()) + "&7, &e" + Math.round(arena.getMin().getZ()))); + player.sendMessage(CC.translate("&7⚫ &9Max Location: &e" + Math.round(arena.getMax().getX()) + "&7, &e" + Math.round(arena.getMax().getY()) + "&7, &e" + Math.round(arena.getMax().getZ()))); + player.sendMessage(CC.translate("&7⚫ &9TeamAmin Location: &e" + Math.round(arena.getTeamAmin().getX()) + "&7, &e" + Math.round(arena.getTeamAmin().getY()) + "&7, &e" + Math.round(arena.getTeamAmin().getZ()))); + player.sendMessage(CC.translate("&7⚫ &9TeamAmax Location: &e" + Math.round(arena.getTeamAmax().getX()) + "&7, &e" + Math.round(arena.getTeamAmax().getY()) + "&7, &e" + Math.round(arena.getTeamAmax().getZ()))); + player.sendMessage(CC.translate("&7⚫ &9TeamBmin Location: &e" + Math.round(arena.getTeamBmin().getX()) + "&7, &e" + Math.round(arena.getTeamBmin().getY()) + "&7, &e" + Math.round(arena.getTeamBmin().getZ()))); + player.sendMessage(CC.translate("&7⚫ &9TeamBmax Location: &e" + Math.round(arena.getTeamBmax().getX()) + "&7, &e" + Math.round(arena.getTeamBmax().getY()) + "&7, &e" + Math.round(arena.getTeamBmax().getZ()))); + player.sendMessage(CC.translate("&7⚫ &9DeadZone level: &e" + arena.getDeadZone())); + player.sendMessage(CC.translate("&7⚫ &9BuildMax level: &e" + arena.getBuildMax())); + + player.sendMessage(CC.translate("&7⚫ &9Team Generators:")); + AtomicInteger teamGen = new AtomicInteger(1); + for (CustomLocation teamGenLocations : arena.getTeamGenerators()) { + player.sendMessage(CC.translate(" &7⚫ &9#" + teamGen.getAndIncrement() + ": &e" + Math.round(teamGenLocations.getX()) + "&7, &e" + Math.round(teamGenLocations.getY()) + "&7, &e" + Math.round(teamGenLocations.getZ()))); + } + + player.sendMessage(CC.translate("&7⚫ &9Diamond Generators:")); + AtomicInteger diaGen = new AtomicInteger(1); + for (CustomLocation diaGenLocations : arena.getDiamondGenerators()) { + player.sendMessage(CC.translate(" &7⚫ &9#" + diaGen.getAndIncrement() + ": &e" + Math.round(diaGenLocations.getX()) + "&7, &e" + Math.round(diaGenLocations.getY()) + "&7, &e" + Math.round(diaGenLocations.getZ()))); + } + + player.sendMessage(CC.translate("&7⚫ &9Emerald Generators:")); + AtomicInteger emeGen = new AtomicInteger(1); + for (CustomLocation emeGenLocations : arena.getEmeraldGenerators()) { + player.sendMessage(CC.translate(" &7⚫ &9#" + emeGen.getAndIncrement() + ": &e" + Math.round(emeGenLocations.getX()) + "&7, &e" + Math.round(emeGenLocations.getY()) + "&7, &e" + Math.round(emeGenLocations.getZ()))); + } + + player.sendMessage(CC.translate("&7⚫ &9Available Arenas: &e" + (arena.getAvailableArenas().size()))); } else { player.sendMessage(CC.translate("&cThis arena does not exist")); } diff --git a/src/main/java/rip/tilly/bedwars/commands/arena/RemoveCommand.java b/src/main/java/rip/tilly/bedwars/commands/arena/RemoveCommand.java index 5f329f3..09b3a16 100644 --- a/src/main/java/rip/tilly/bedwars/commands/arena/RemoveCommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/arena/RemoveCommand.java @@ -19,6 +19,11 @@ public class RemoveCommand extends BaseCommand { public void executeAs(CommandSender sender, Command cmd, String label, String[] args) { Player player = (Player) sender; + if (args.length == 0) { + player.sendMessage(CC.translate("&cError: no arena found! /arena ")); + return; + } + Arena arena = this.main.getArenaManager().getArena(args[1]); if (arena != null) { @@ -26,7 +31,7 @@ public class RemoveCommand extends BaseCommand { player.sendMessage(CC.translate("&aSuccessfully deleted the arena called &a&l" + args[1])); } else { - player.sendMessage(CC.translate("&cThis arena does not already exist")); + player.sendMessage(CC.translate("&cThis arena does not exist")); } } diff --git a/src/main/java/rip/tilly/bedwars/commands/arena/SetACommand.java b/src/main/java/rip/tilly/bedwars/commands/arena/SetACommand.java index 48c8cec..fbb1bb1 100644 --- a/src/main/java/rip/tilly/bedwars/commands/arena/SetACommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/arena/SetACommand.java @@ -21,6 +21,11 @@ public class SetACommand extends BaseCommand { public void executeAs(CommandSender sender, Command cmd, String label, String[] args) { Player player = (Player) sender; + if (args.length == 0) { + player.sendMessage(CC.translate("&cError: no arena found! /arena ")); + return; + } + Arena arena = this.main.getArenaManager().getArena(args[1]); if (arena != null) { @@ -30,7 +35,7 @@ public class SetACommand extends BaseCommand { player.sendMessage(CC.translate("&aSuccessfully set the A position for the arena called &a&l" + args[1])); } else { - player.sendMessage(CC.translate("&cThis arena does not already exist")); + player.sendMessage(CC.translate("&cThis arena does not exist")); } } diff --git a/src/main/java/rip/tilly/bedwars/commands/arena/SetBCommand.java b/src/main/java/rip/tilly/bedwars/commands/arena/SetBCommand.java index 1e95481..0bceb30 100644 --- a/src/main/java/rip/tilly/bedwars/commands/arena/SetBCommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/arena/SetBCommand.java @@ -21,6 +21,11 @@ public class SetBCommand extends BaseCommand { public void executeAs(CommandSender sender, Command cmd, String label, String[] args) { Player player = (Player) sender; + if (args.length == 0) { + player.sendMessage(CC.translate("&cError: no arena found! /arena ")); + return; + } + Arena arena = this.main.getArenaManager().getArena(args[1]); if (arena != null) { @@ -30,7 +35,7 @@ public class SetBCommand extends BaseCommand { player.sendMessage(CC.translate("&aSuccessfully set the B position for the arena called &a&l" + args[1])); } else { - player.sendMessage(CC.translate("&cThis arena does not already exist")); + player.sendMessage(CC.translate("&cThis arena does not exist")); } } diff --git a/src/main/java/rip/tilly/bedwars/commands/arena/SetBuildMaxCommand.java b/src/main/java/rip/tilly/bedwars/commands/arena/SetBuildMaxCommand.java index 8fea078..9836af3 100644 --- a/src/main/java/rip/tilly/bedwars/commands/arena/SetBuildMaxCommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/arena/SetBuildMaxCommand.java @@ -19,6 +19,11 @@ public class SetBuildMaxCommand extends BaseCommand { public void executeAs(CommandSender sender, Command cmd, String label, String[] args) { Player player = (Player) sender; + if (args.length == 0) { + player.sendMessage(CC.translate("&cError: no arena found! /arena ")); + return; + } + Arena arena = this.main.getArenaManager().getArena(args[1]); if (arena != null) { @@ -28,7 +33,7 @@ public class SetBuildMaxCommand extends BaseCommand { player.sendMessage(CC.translate("&aSuccessfully set the build maximum for the arena called &a&l" + args[1])); } else { - player.sendMessage(CC.translate("&cThis arena does not already exist")); + player.sendMessage(CC.translate("&cThis arena does not exist")); } } diff --git a/src/main/java/rip/tilly/bedwars/commands/arena/SetDeadZoneCommand.java b/src/main/java/rip/tilly/bedwars/commands/arena/SetDeadZoneCommand.java index 7a4609d..4123ab8 100644 --- a/src/main/java/rip/tilly/bedwars/commands/arena/SetDeadZoneCommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/arena/SetDeadZoneCommand.java @@ -19,6 +19,11 @@ public class SetDeadZoneCommand extends BaseCommand { public void executeAs(CommandSender sender, Command cmd, String label, String[] args) { Player player = (Player) sender; + if (args.length == 0) { + player.sendMessage(CC.translate("&cError: no arena found! /arena ")); + return; + } + Arena arena = this.main.getArenaManager().getArena(args[1]); if (arena != null) { @@ -28,7 +33,7 @@ public class SetDeadZoneCommand extends BaseCommand { player.sendMessage(CC.translate("&aSuccessfully set the dead zone for the arena called &a&l" + args[1])); } else { - player.sendMessage(CC.translate("&cThis arena does not already exist")); + player.sendMessage(CC.translate("&cThis arena does not exist")); } } diff --git a/src/main/java/rip/tilly/bedwars/commands/arena/SetDiamondGeneratorCommand.java b/src/main/java/rip/tilly/bedwars/commands/arena/SetDiamondGeneratorCommand.java index 99b95e1..eedf9b8 100644 --- a/src/main/java/rip/tilly/bedwars/commands/arena/SetDiamondGeneratorCommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/arena/SetDiamondGeneratorCommand.java @@ -23,6 +23,11 @@ public class SetDiamondGeneratorCommand extends BaseCommand { public void executeAs(CommandSender sender, Command cmd, String label, String[] args) { Player player = (Player) sender; + if (args.length == 0) { + player.sendMessage(CC.translate("&cError: no arena found! /arena ")); + return; + } + Arena arena = this.main.getArenaManager().getArena(args[1]); if (arena != null) { @@ -41,7 +46,7 @@ public class SetDiamondGeneratorCommand extends BaseCommand { // player.sendMessage(CC.translate("&aSuccessfully set the diamond generator for the arena called &a&l" + args[1])); } else { - player.sendMessage(CC.translate("&cThis arena does not already exist")); + player.sendMessage(CC.translate("&cThis arena does not exist")); } } diff --git a/src/main/java/rip/tilly/bedwars/commands/arena/SetEmeraldGeneratorCommand.java b/src/main/java/rip/tilly/bedwars/commands/arena/SetEmeraldGeneratorCommand.java index f0b3e1a..aac73ef 100644 --- a/src/main/java/rip/tilly/bedwars/commands/arena/SetEmeraldGeneratorCommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/arena/SetEmeraldGeneratorCommand.java @@ -23,6 +23,11 @@ public class SetEmeraldGeneratorCommand extends BaseCommand { public void executeAs(CommandSender sender, Command cmd, String label, String[] args) { Player player = (Player) sender; + if (args.length == 0) { + player.sendMessage(CC.translate("&cError: no arena found! /arena ")); + return; + } + Arena arena = this.main.getArenaManager().getArena(args[1]); if (arena != null) { @@ -40,7 +45,7 @@ public class SetEmeraldGeneratorCommand extends BaseCommand { arena.getEmeraldGenerators().add(CustomLocation.fromBukkitLocation(location)); this.saveStringsGenerators(arena); } else { - player.sendMessage(CC.translate("&cThis arena does not already exist")); + player.sendMessage(CC.translate("&cThis arena does not exist")); } } diff --git a/src/main/java/rip/tilly/bedwars/commands/arena/SetIconCommand.java b/src/main/java/rip/tilly/bedwars/commands/arena/SetIconCommand.java index 0d30c81..3996aaa 100644 --- a/src/main/java/rip/tilly/bedwars/commands/arena/SetIconCommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/arena/SetIconCommand.java @@ -20,6 +20,11 @@ public class SetIconCommand extends BaseCommand { public void executeAs(CommandSender sender, Command cmd, String label, String[] args) { Player player = (Player) sender; + if (args.length == 0) { + player.sendMessage(CC.translate("&cError: no arena found! /arena ")); + return; + } + Arena arena = this.main.getArenaManager().getArena(args[1]); if (arena != null) { @@ -36,7 +41,7 @@ public class SetIconCommand extends BaseCommand { player.sendMessage(CC.translate("&cYou must be holding an item to set the arena icon")); } } else { - player.sendMessage(CC.translate("&cThis arena does not already exist")); + player.sendMessage(CC.translate("&cThis arena does not exist")); } } diff --git a/src/main/java/rip/tilly/bedwars/commands/arena/SetMaxCommand.java b/src/main/java/rip/tilly/bedwars/commands/arena/SetMaxCommand.java index 3807e9f..63d9225 100644 --- a/src/main/java/rip/tilly/bedwars/commands/arena/SetMaxCommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/arena/SetMaxCommand.java @@ -21,6 +21,11 @@ public class SetMaxCommand extends BaseCommand { public void executeAs(CommandSender sender, Command cmd, String label, String[] args) { Player player = (Player) sender; + if (args.length == 0) { + player.sendMessage(CC.translate("&cError: no arena found! /arena ")); + return; + } + Arena arena = this.main.getArenaManager().getArena(args[1]); if (arena != null) { @@ -30,7 +35,7 @@ public class SetMaxCommand extends BaseCommand { player.sendMessage(CC.translate("&aSuccessfully set the maximum position for the arena called &a&l" + args[1])); } else { - player.sendMessage(CC.translate("&cThis arena does not already exist")); + player.sendMessage(CC.translate("&cThis arena does not exist")); } } diff --git a/src/main/java/rip/tilly/bedwars/commands/arena/SetMinCommand.java b/src/main/java/rip/tilly/bedwars/commands/arena/SetMinCommand.java index 56fd6ea..cdb0544 100644 --- a/src/main/java/rip/tilly/bedwars/commands/arena/SetMinCommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/arena/SetMinCommand.java @@ -21,6 +21,11 @@ public class SetMinCommand extends BaseCommand { public void executeAs(CommandSender sender, Command cmd, String label, String[] args) { Player player = (Player) sender; + if (args.length == 0) { + player.sendMessage(CC.translate("&cError: no arena found! /arena ")); + return; + } + Arena arena = this.main.getArenaManager().getArena(args[1]); if (arena != null) { @@ -30,7 +35,7 @@ public class SetMinCommand extends BaseCommand { player.sendMessage(CC.translate("&aSuccessfully set the minimum position for the arena called &a&l" + args[1])); } else { - player.sendMessage(CC.translate("&cThis arena does not already exist")); + player.sendMessage(CC.translate("&cThis arena does not exist")); } } diff --git a/src/main/java/rip/tilly/bedwars/commands/arena/SetTeamAMaxCommand.java b/src/main/java/rip/tilly/bedwars/commands/arena/SetTeamAMaxCommand.java index c95dfb9..57fc052 100644 --- a/src/main/java/rip/tilly/bedwars/commands/arena/SetTeamAMaxCommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/arena/SetTeamAMaxCommand.java @@ -21,6 +21,11 @@ public class SetTeamAMaxCommand extends BaseCommand { public void executeAs(CommandSender sender, Command cmd, String label, String[] args) { Player player = (Player) sender; + if (args.length == 0) { + player.sendMessage(CC.translate("&cError: no arena found! /arena ")); + return; + } + Arena arena = this.main.getArenaManager().getArena(args[1]); if (arena != null) { @@ -30,7 +35,7 @@ public class SetTeamAMaxCommand extends BaseCommand { player.sendMessage(CC.translate("&aSuccessfully set the Team A maximum position for the arena called &a&l" + args[1])); } else { - player.sendMessage(CC.translate("&cThis arena does not already exist")); + player.sendMessage(CC.translate("&cThis arena does not exist")); } } diff --git a/src/main/java/rip/tilly/bedwars/commands/arena/SetTeamAMinCommand.java b/src/main/java/rip/tilly/bedwars/commands/arena/SetTeamAMinCommand.java index 7a78ddc..40ee1cd 100644 --- a/src/main/java/rip/tilly/bedwars/commands/arena/SetTeamAMinCommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/arena/SetTeamAMinCommand.java @@ -21,6 +21,11 @@ public class SetTeamAMinCommand extends BaseCommand { public void executeAs(CommandSender sender, Command cmd, String label, String[] args) { Player player = (Player) sender; + if (args.length == 0) { + player.sendMessage(CC.translate("&cError: no arena found! /arena ")); + return; + } + Arena arena = this.main.getArenaManager().getArena(args[1]); if (arena != null) { @@ -30,7 +35,7 @@ public class SetTeamAMinCommand extends BaseCommand { player.sendMessage(CC.translate("&aSuccessfully set the Team A minimum position for the arena called &a&l" + args[1])); } else { - player.sendMessage(CC.translate("&cThis arena does not already exist")); + player.sendMessage(CC.translate("&cThis arena does not exist")); } } diff --git a/src/main/java/rip/tilly/bedwars/commands/arena/SetTeamBMaxCommand.java b/src/main/java/rip/tilly/bedwars/commands/arena/SetTeamBMaxCommand.java index a84e992..a713007 100644 --- a/src/main/java/rip/tilly/bedwars/commands/arena/SetTeamBMaxCommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/arena/SetTeamBMaxCommand.java @@ -21,6 +21,11 @@ public class SetTeamBMaxCommand extends BaseCommand { public void executeAs(CommandSender sender, Command cmd, String label, String[] args) { Player player = (Player) sender; + if (args.length == 0) { + player.sendMessage(CC.translate("&cError: no arena found! /arena ")); + return; + } + Arena arena = this.main.getArenaManager().getArena(args[1]); if (arena != null) { @@ -30,7 +35,7 @@ public class SetTeamBMaxCommand extends BaseCommand { player.sendMessage(CC.translate("&aSuccessfully set the Team B maximum position for the arena called &a&l" + args[1])); } else { - player.sendMessage(CC.translate("&cThis arena does not already exist")); + player.sendMessage(CC.translate("&cThis arena does not exist")); } } diff --git a/src/main/java/rip/tilly/bedwars/commands/arena/SetTeamBMinCommand.java b/src/main/java/rip/tilly/bedwars/commands/arena/SetTeamBMinCommand.java index c5100c4..35dd12c 100644 --- a/src/main/java/rip/tilly/bedwars/commands/arena/SetTeamBMinCommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/arena/SetTeamBMinCommand.java @@ -21,6 +21,11 @@ public class SetTeamBMinCommand extends BaseCommand { public void executeAs(CommandSender sender, Command cmd, String label, String[] args) { Player player = (Player) sender; + if (args.length == 0) { + player.sendMessage(CC.translate("&cError: no arena found! /arena ")); + return; + } + Arena arena = this.main.getArenaManager().getArena(args[1]); if (arena != null) { @@ -30,7 +35,7 @@ public class SetTeamBMinCommand extends BaseCommand { player.sendMessage(CC.translate("&aSuccessfully set the Team B minimum position for the arena called &a&l" + args[1])); } else { - player.sendMessage(CC.translate("&cThis arena does not already exist")); + player.sendMessage(CC.translate("&cThis arena does not exist")); } } diff --git a/src/main/java/rip/tilly/bedwars/commands/arena/SetTeamGeneratorCommand.java b/src/main/java/rip/tilly/bedwars/commands/arena/SetTeamGeneratorCommand.java index 238ed9b..934677e 100644 --- a/src/main/java/rip/tilly/bedwars/commands/arena/SetTeamGeneratorCommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/arena/SetTeamGeneratorCommand.java @@ -23,6 +23,11 @@ public class SetTeamGeneratorCommand extends BaseCommand { public void executeAs(CommandSender sender, Command cmd, String label, String[] args) { Player player = (Player) sender; + if (args.length == 0) { + player.sendMessage(CC.translate("&cError: no arena found! /arena ")); + return; + } + Arena arena = this.main.getArenaManager().getArena(args[1]); if (arena != null) { @@ -48,7 +53,7 @@ public class SetTeamGeneratorCommand extends BaseCommand { arena.getTeamGenerators().add(CustomLocation.fromBukkitLocation(location)); this.saveStringsGenerators(arena); } else { - player.sendMessage(CC.translate("&cThis arena does not already exist")); + player.sendMessage(CC.translate("&cThis arena does not exist")); } } diff --git a/src/main/java/rip/tilly/bedwars/commands/level/LevelCommand.java b/src/main/java/rip/tilly/bedwars/commands/level/LevelCommand.java index bd07d33..bb8bb09 100644 --- a/src/main/java/rip/tilly/bedwars/commands/level/LevelCommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/level/LevelCommand.java @@ -27,7 +27,7 @@ public class LevelCommand implements CommandExecutor { player.sendMessage(CC.translate(" &c/level add ")); player.sendMessage(CC.translate(" &c/level remove ")); } else { - switch (args[0]) { + switch (args[0].toLowerCase()) { case "set": new SetCommand().executeAs(sender, cmd, label, args); diff --git a/src/main/java/rip/tilly/bedwars/commands/party/ChatCommand.java b/src/main/java/rip/tilly/bedwars/commands/party/ChatCommand.java new file mode 100644 index 0000000..f063e72 --- /dev/null +++ b/src/main/java/rip/tilly/bedwars/commands/party/ChatCommand.java @@ -0,0 +1,50 @@ +package rip.tilly.bedwars.commands.party; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import rip.tilly.bedwars.BedWars; +import rip.tilly.bedwars.commands.BaseCommand; +import rip.tilly.bedwars.managers.party.Party; +import rip.tilly.bedwars.utils.CC; + +import java.util.ArrayList; +import java.util.List; + +public class ChatCommand extends BaseCommand { + + private final BedWars plugin = BedWars.getInstance(); + + @Override + public void executeAs(CommandSender sender, Command cmd, String label, String[] args) { + Player player = (Player) sender; + + Party party = this.plugin.getPartyManager().getParty(player.getUniqueId()); + if (args.length == 1) { + player.performCommand("toggle partychat"); + return; + } else { + if (party != null) { + StringBuilder stringBuilder = new StringBuilder(); + + for (int i = 1; i < args.length; i++){ + stringBuilder.append(args[i]).append(" "); + } + + String allArgs = stringBuilder.toString().trim(); + + String message = "&9Party > &d" + player.getDisplayName() + "&f: " + allArgs; + party.broadcast(message); + } else { + player.sendMessage(CC.translate("&cYou are not in a party!")); + } + } + } + + @Override + public List getTabCompletions(CommandSender sender, Command cmd, String label, String[] args) { + List tabCompletions = new ArrayList(); + + return tabCompletions; + } +} diff --git a/src/main/java/rip/tilly/bedwars/commands/party/PartyCommand.java b/src/main/java/rip/tilly/bedwars/commands/party/PartyCommand.java index 6606343..2df1625 100644 --- a/src/main/java/rip/tilly/bedwars/commands/party/PartyCommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/party/PartyCommand.java @@ -4,13 +4,10 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import rip.tilly.bedwars.BedWars; import rip.tilly.bedwars.utils.CC; public class PartyCommand implements CommandExecutor { - private BedWars main = BedWars.getInstance(); - public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { Player player = (Player) sender; @@ -21,14 +18,14 @@ public class PartyCommand implements CommandExecutor { player.sendMessage(CC.translate("&7⚫ &9/party &7- &eParty help information")); player.sendMessage(CC.translate("&7⚫ &9/party create &7- &eCreate a party")); player.sendMessage(CC.translate("&7⚫ &9/party leave &7- &eLeave a party")); - // player.sendMessage(CC.translate("&7⚫ &9/party join &7- &eJoin a party")); + player.sendMessage(CC.translate("&7⚫ &9/party join &7- &eJoin a party")); player.sendMessage(CC.translate("&7⚫ &9/party accept &7- &eAccept a party invitation")); player.sendMessage(CC.translate("&7⚫ &9/party invite &7- &eInvite a player to a party")); player.sendMessage(CC.translate("&7⚫ &9/party remove &7- &eRemove a player from a party")); player.sendMessage(CC.translate("&7⚫ &9/party info &7- &eCheck a party's information")); player.sendMessage(CC.translate(CC.chatBar)); } else { - switch (args[0]) { + switch (args[0].toLowerCase()) { case "create": new CreateCommand().executeAs(sender, cmd, label, args); @@ -45,6 +42,7 @@ public class PartyCommand implements CommandExecutor { new AcceptCommand().executeAs(sender, cmd, label, args); break; + case "inv": case "invite": new InviteCommand().executeAs(sender, cmd, label, args); @@ -56,6 +54,11 @@ public class PartyCommand implements CommandExecutor { case "info": new InfoCommand().executeAs(sender, cmd, label, args); + break; + case "c": + case "chat": + new ChatCommand().executeAs(sender, cmd, label, args); + break; } } diff --git a/src/main/java/rip/tilly/bedwars/commands/toggle/PartyChatCommand.java b/src/main/java/rip/tilly/bedwars/commands/toggle/PartyChatCommand.java new file mode 100644 index 0000000..280e8b5 --- /dev/null +++ b/src/main/java/rip/tilly/bedwars/commands/toggle/PartyChatCommand.java @@ -0,0 +1,32 @@ +package rip.tilly.bedwars.commands.toggle; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import rip.tilly.bedwars.BedWars; +import rip.tilly.bedwars.commands.BaseCommand; +import rip.tilly.bedwars.playerdata.PlayerSettings; +import rip.tilly.bedwars.utils.CC; + +import java.util.ArrayList; +import java.util.List; + +public class PartyChatCommand extends BaseCommand { + + @Override + public void executeAs(CommandSender sender, Command cmd, String label, String[] args) { + Player player = (Player) sender; + + PlayerSettings settings = BedWars.getInstance().getPlayerDataManager().getPlayerData(player.getUniqueId()).getPlayerSettings(); + settings.setPartyChatEnabled(!settings.isPartyChatEnabled()); + + player.sendMessage(CC.translate(settings.isPartyChatEnabled() ? "&aParty Chat toggled to true!" : "&cParty Chat toggled to false!")); + } + + @Override + public List getTabCompletions(CommandSender sender, Command cmd, String label, String[] args) { + List tabCompletions = new ArrayList(); + + return tabCompletions; + } +} diff --git a/src/main/java/rip/tilly/bedwars/commands/toggle/ScoreboardCommand.java b/src/main/java/rip/tilly/bedwars/commands/toggle/ScoreboardCommand.java new file mode 100644 index 0000000..9fe7103 --- /dev/null +++ b/src/main/java/rip/tilly/bedwars/commands/toggle/ScoreboardCommand.java @@ -0,0 +1,32 @@ +package rip.tilly.bedwars.commands.toggle; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import rip.tilly.bedwars.BedWars; +import rip.tilly.bedwars.commands.BaseCommand; +import rip.tilly.bedwars.playerdata.PlayerSettings; +import rip.tilly.bedwars.utils.CC; + +import java.util.ArrayList; +import java.util.List; + +public class ScoreboardCommand extends BaseCommand { + + @Override + public void executeAs(CommandSender sender, Command cmd, String label, String[] args) { + Player player = (Player) sender; + + PlayerSettings settings = BedWars.getInstance().getPlayerDataManager().getPlayerData(player.getUniqueId()).getPlayerSettings(); + settings.setScoreboardEnabled(!settings.isScoreboardEnabled()); + + player.sendMessage(CC.translate(settings.isScoreboardEnabled() ? "&aScoreboard toggled to true!" : "&cScoreboard toggled to false!")); + } + + @Override + public List getTabCompletions(CommandSender sender, Command cmd, String label, String[] args) { + List tabCompletions = new ArrayList(); + + return tabCompletions; + } +} diff --git a/src/main/java/rip/tilly/bedwars/commands/toggle/ToggleCommand.java b/src/main/java/rip/tilly/bedwars/commands/toggle/ToggleCommand.java new file mode 100644 index 0000000..808a05d --- /dev/null +++ b/src/main/java/rip/tilly/bedwars/commands/toggle/ToggleCommand.java @@ -0,0 +1,35 @@ +package rip.tilly.bedwars.commands.toggle; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import rip.tilly.bedwars.utils.CC; + +public class ToggleCommand implements CommandExecutor { + + public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { + Player player = (Player) sender; + + if (args.length == 0) { + player.sendMessage(CC.translate("&cUsage:")); + player.sendMessage(CC.translate(" &c/toggle")); + player.sendMessage(CC.translate(" &c/toggle scoreboard")); + player.sendMessage(CC.translate(" &c/toggle partychat")); + } else { + switch (args[0].toLowerCase()) { + case "scoreboard": + new ScoreboardCommand().executeAs(sender, cmd, label, args); + + break; + case "pc": + case "partychat": + new PartyChatCommand().executeAs(sender, cmd, label, args); + + break; + } + } + + return true; + } +} diff --git a/src/main/java/rip/tilly/bedwars/commands/xp/XpCommand.java b/src/main/java/rip/tilly/bedwars/commands/xp/XpCommand.java index 70a55b7..060713e 100644 --- a/src/main/java/rip/tilly/bedwars/commands/xp/XpCommand.java +++ b/src/main/java/rip/tilly/bedwars/commands/xp/XpCommand.java @@ -27,7 +27,7 @@ public class XpCommand implements CommandExecutor { player.sendMessage(CC.translate(" &c/xp add ")); player.sendMessage(CC.translate(" &c/xp remove ")); } else { - switch (args[0]) { + switch (args[0].toLowerCase()) { case "set": new SetCommand().executeAs(sender, cmd, label, args); diff --git a/src/main/java/rip/tilly/bedwars/listeners/InteractListener.java b/src/main/java/rip/tilly/bedwars/listeners/InteractListener.java index b291cd7..88bb071 100644 --- a/src/main/java/rip/tilly/bedwars/listeners/InteractListener.java +++ b/src/main/java/rip/tilly/bedwars/listeners/InteractListener.java @@ -12,6 +12,7 @@ import org.bukkit.material.TrapDoor; import rip.tilly.bedwars.BedWars; import rip.tilly.bedwars.managers.hotbar.impl.HotbarItem; import rip.tilly.bedwars.menus.queue.PlayAGameMenu; +import rip.tilly.bedwars.menus.settings.SettingsMenu; import rip.tilly.bedwars.playerdata.PlayerData; import rip.tilly.bedwars.playerdata.PlayerState; @@ -79,7 +80,8 @@ public class InteractListener implements Listener { break; case SETTINGS_MENU: - // open settings menu + new SettingsMenu().openMenu(player); + break; case CREATE_PARTY: this.plugin.getPartyManager().createParty(player); diff --git a/src/main/java/rip/tilly/bedwars/listeners/PartyChatListener.java b/src/main/java/rip/tilly/bedwars/listeners/PartyChatListener.java new file mode 100644 index 0000000..4cbe5b0 --- /dev/null +++ b/src/main/java/rip/tilly/bedwars/listeners/PartyChatListener.java @@ -0,0 +1,34 @@ +package rip.tilly.bedwars.listeners; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import rip.tilly.bedwars.BedWars; +import rip.tilly.bedwars.managers.party.Party; +import rip.tilly.bedwars.playerdata.PlayerData; +import rip.tilly.bedwars.utils.CC; + +public class PartyChatListener implements Listener { + + private final BedWars plugin = BedWars.getInstance(); + + @EventHandler(ignoreCancelled = true) + public void onAsyncPlayerChat(AsyncPlayerChatEvent event) { + Player player = event.getPlayer(); + Party party = this.plugin.getPartyManager().getParty(player.getUniqueId()); + PlayerData playerData = this.plugin.getPlayerDataManager().getPlayerData(player.getUniqueId()); + String chatMessage = event.getMessage(); + if (party != null) { + if (playerData.getPlayerSettings().isPartyChatEnabled()) { + event.setCancelled(true); + String message = CC.translate("&9Party > &d" + player.getDisplayName() + "&f: " + chatMessage); + party.broadcast(message); + } + } else if (playerData.getPlayerSettings().isPartyChatEnabled()) { + event.setCancelled(true); + player.sendMessage(CC.translate("&cSince you are not in a party we toggled your party chat to false!")); + playerData.getPlayerSettings().setPartyChatEnabled(!playerData.getPlayerSettings().isPartyChatEnabled()); + } + } +} diff --git a/src/main/java/rip/tilly/bedwars/managers/CommandManager.java b/src/main/java/rip/tilly/bedwars/managers/CommandManager.java index 074b984..ee12c80 100644 --- a/src/main/java/rip/tilly/bedwars/managers/CommandManager.java +++ b/src/main/java/rip/tilly/bedwars/managers/CommandManager.java @@ -5,6 +5,7 @@ import rip.tilly.bedwars.commands.arena.ArenaCommand; import rip.tilly.bedwars.commands.level.LevelCommand; import rip.tilly.bedwars.commands.party.PartyCommand; import rip.tilly.bedwars.commands.setspawn.SetSpawnCommand; +import rip.tilly.bedwars.commands.toggle.ToggleCommand; import rip.tilly.bedwars.commands.xp.XpCommand; public class CommandManager { @@ -20,6 +21,8 @@ public class CommandManager { this.main.getCommand("level").setExecutor(new LevelCommand()); this.main.getCommand("xp").setExecutor(new XpCommand()); this.main.getCommand("party").setExecutor(new PartyCommand()); + this.main.getCommand("p").setExecutor(new PartyCommand()); this.main.getCommand("arena").setExecutor(new ArenaCommand()); + this.main.getCommand("toggle").setExecutor(new ToggleCommand()); } } diff --git a/src/main/java/rip/tilly/bedwars/managers/party/Party.java b/src/main/java/rip/tilly/bedwars/managers/party/Party.java index 78adfec..48c0d56 100644 --- a/src/main/java/rip/tilly/bedwars/managers/party/Party.java +++ b/src/main/java/rip/tilly/bedwars/managers/party/Party.java @@ -6,6 +6,7 @@ import org.bukkit.entity.Player; import rip.tilly.bedwars.BedWars; import rip.tilly.bedwars.game.GameTeam; import rip.tilly.bedwars.playerdata.PlayerTeam; +import rip.tilly.bedwars.utils.CC; import java.util.*; import java.util.concurrent.ThreadLocalRandom; @@ -39,7 +40,7 @@ public class Party { } public void broadcast(String message) { - this.members().forEach(member -> member.sendMessage(message)); + this.members().forEach(member -> member.sendMessage(CC.translate(message))); } private GameTeam findTeam(UUID uuid) { diff --git a/src/main/java/rip/tilly/bedwars/menus/settings/SettingsMenu.java b/src/main/java/rip/tilly/bedwars/menus/settings/SettingsMenu.java new file mode 100644 index 0000000..9a1ef28 --- /dev/null +++ b/src/main/java/rip/tilly/bedwars/menus/settings/SettingsMenu.java @@ -0,0 +1,91 @@ +package rip.tilly.bedwars.menus.settings; + +import lombok.AllArgsConstructor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import rip.tilly.bedwars.BedWars; +import rip.tilly.bedwars.playerdata.PlayerSettings; +import rip.tilly.bedwars.utils.CC; +import rip.tilly.bedwars.utils.ItemBuilder; +import rip.tilly.bedwars.utils.menu.Button; +import rip.tilly.bedwars.utils.menu.Menu; + +import java.util.*; + +public class SettingsMenu extends Menu { + + @Override + public String getTitle(Player player) { + return CC.translate("&eSelect a setting to toggle..."); + } + + @Override + public Map getButtons(Player player) { + Map buttons = new HashMap<>(); + + PlayerSettings settings = BedWars.getInstance().getPlayerDataManager().getPlayerData(player.getUniqueId()).getPlayerSettings(); + + buttons.put(11, new SettingsButton(Material.PAINTING, 0, + "&d&lToggle Scoreboard", + Arrays.asList( + " ", + "&9If enabled, you will be", + "&9able to see the scoreboard", + " ", + (settings.isScoreboardEnabled() ? " &a► " : " &7► ") + "Scoreboard enabled.", + (!settings.isScoreboardEnabled() ? " &c► " : " &7► ") + "Scoreboard disabled."), + "toggle scoreboard")); + + buttons.put(15, new SettingsButton(Material.BOOK_AND_QUILL, 0, + "&d&lToggle Party Chat", + Arrays.asList( + " ", + "&9If enabled, you will talk", + "&9in party chat", + " ", + (settings.isPartyChatEnabled() ? " &a► " : " &7► ") + "Party Chat enabled.", + (!settings.isPartyChatEnabled() ? " &c► " : " &7► ") + "Party Chat disabled."), + "toggle partychat")); + + fillEmptySlots(buttons, new ItemBuilder(Material.STAINED_GLASS_PANE).durability(7).name(" ").build()); + + return buttons; + } + + @Override + public int getSize() { + return 3 * 9; + } + + @AllArgsConstructor + private class SettingsButton extends Button { + + private final Material material; + private final int data; + private final String name; + private final List lore; + private final String command; + + @Override + public ItemStack getButtonItem(Player player) { + List loreList = new ArrayList<>(); + + loreList.addAll(lore); + + return new ItemBuilder(material) + .durability(data) + .name(name) + .lore(loreList) + .hideFlags() + .build(); + } + + @Override + public void clicked(Player player, int slot, ClickType clickType, int hotbarButton) { + playNeutral(player); + player.performCommand(command); + } + } +} diff --git a/src/main/java/rip/tilly/bedwars/playerdata/PlayerSettings.java b/src/main/java/rip/tilly/bedwars/playerdata/PlayerSettings.java index 5e9a056..c087b96 100644 --- a/src/main/java/rip/tilly/bedwars/playerdata/PlayerSettings.java +++ b/src/main/java/rip/tilly/bedwars/playerdata/PlayerSettings.java @@ -6,4 +6,5 @@ import lombok.Data; public class PlayerSettings { private boolean scoreboardEnabled = true; + private boolean partyChatEnabled = false; } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index f303537..99d053f 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -10,4 +10,6 @@ commands: level: xp: party: - arena: \ No newline at end of file + p: + arena: + toggle: \ No newline at end of file