Redid all commands, Added Party chat and added Settingsmenu

This commit is contained in:
Luca 2021-11-23 13:33:01 +01:00
parent 03512ae139
commit e11fdd3931
35 changed files with 459 additions and 46 deletions

View File

@ -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));
}

View File

@ -43,9 +43,9 @@ public class ArenaCommand implements CommandExecutor {
player.sendMessage(CC.translate("&7⚫ &9/arena setTeamBMax <arena> &7- &eSet team B max"));
player.sendMessage(CC.translate("&7⚫ &9/arena setDeadZone <arena> <amount> &7- &eSet the dead zone"));
player.sendMessage(CC.translate("&7⚫ &9/arena setBuildMax <arena> <amount> &7- &eSet the build max"));
player.sendMessage(CC.translate("&7⚫ &9/arena setPlayerGenerator <arena> <&7- &eSet the player's generator"));
player.sendMessage(CC.translate("&7⚫ &9/arena setDiamondGenerator <arena> <&7- &eSet the diamond generator"));
player.sendMessage(CC.translate("&7⚫ &9/arena setEmeraldGenerator <arena> <&7- &eSet the emerald generator"));
player.sendMessage(CC.translate("&7⚫ &9/arena setTeamGenerator <arena> &7- &eSet the team's generator"));
player.sendMessage(CC.translate("&7⚫ &9/arena setDiamondGenerator <arena> &7- &eSet the diamond generator"));
player.sendMessage(CC.translate("&7⚫ &9/arena setEmeraldGenerator <arena> &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;

View File

@ -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 <args> <arena>"));
return;
}
Arena arena = this.main.getArenaManager().getArena(args[1]);
if (arena == null) {

View File

@ -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 <args> <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"));
}
}

View File

@ -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 <args> <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 <name> <copies>"));
}
} else {
player.sendMessage(CC.translate("&cUsage: /arena generate <name> <copies>"));
player.sendMessage(CC.translate("&cThis arena does not exist"));
}
}

View File

@ -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 <args> <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"));
}

View File

@ -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 <args> <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"));
}
}

View File

@ -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 <args> <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"));
}
}

View File

@ -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 <args> <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"));
}
}

View File

@ -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 <args> <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"));
}
}

View File

@ -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 <args> <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"));
}
}

View File

@ -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 <args> <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"));
}
}

View File

@ -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 <args> <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"));
}
}

View File

@ -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 <args> <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"));
}
}

View File

@ -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 <args> <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"));
}
}

View File

@ -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 <args> <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"));
}
}

View File

@ -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 <args> <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"));
}
}

View File

@ -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 <args> <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"));
}
}

View File

@ -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 <args> <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"));
}
}

View File

@ -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 <args> <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"));
}
}

View File

@ -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 <args> <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"));
}
}

View File

@ -27,7 +27,7 @@ public class LevelCommand implements CommandExecutor {
player.sendMessage(CC.translate(" &c/level add <player> <amount>"));
player.sendMessage(CC.translate(" &c/level remove <player> <amount>"));
} else {
switch (args[0]) {
switch (args[0].toLowerCase()) {
case "set":
new SetCommand().executeAs(sender, cmd, label, args);

View File

@ -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<String> getTabCompletions(CommandSender sender, Command cmd, String label, String[] args) {
List<String> tabCompletions = new ArrayList<String>();
return tabCompletions;
}
}

View File

@ -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 <player> &7- &eJoin a party"));
player.sendMessage(CC.translate("&7⚫ &9/party join <player> &7- &eJoin a party"));
player.sendMessage(CC.translate("&7⚫ &9/party accept <player> &7- &eAccept a party invitation"));
player.sendMessage(CC.translate("&7⚫ &9/party invite <player> &7- &eInvite a player to a party"));
player.sendMessage(CC.translate("&7⚫ &9/party remove <player> &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;
}
}

View File

@ -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<String> getTabCompletions(CommandSender sender, Command cmd, String label, String[] args) {
List<String> tabCompletions = new ArrayList<String>();
return tabCompletions;
}
}

View File

@ -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<String> getTabCompletions(CommandSender sender, Command cmd, String label, String[] args) {
List<String> tabCompletions = new ArrayList<String>();
return tabCompletions;
}
}

View File

@ -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;
}
}

View File

@ -27,7 +27,7 @@ public class XpCommand implements CommandExecutor {
player.sendMessage(CC.translate(" &c/xp add <player> <amount>"));
player.sendMessage(CC.translate(" &c/xp remove <player> <amount>"));
} else {
switch (args[0]) {
switch (args[0].toLowerCase()) {
case "set":
new SetCommand().executeAs(sender, cmd, label, args);

View File

@ -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);

View File

@ -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());
}
}
}

View File

@ -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());
}
}

View File

@ -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) {

View File

@ -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<Integer, Button> getButtons(Player player) {
Map<Integer, Button> 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<String> lore;
private final String command;
@Override
public ItemStack getButtonItem(Player player) {
List<String> 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);
}
}
}

View File

@ -6,4 +6,5 @@ import lombok.Data;
public class PlayerSettings {
private boolean scoreboardEnabled = true;
private boolean partyChatEnabled = false;
}

View File

@ -10,4 +10,6 @@ commands:
level:
xp:
party:
arena:
p:
arena:
toggle: