From fac373b5be69e3a530f58ca2ac7c6f696fdf1754 Mon Sep 17 00:00:00 2001 From: Yaruma3341 Date: Sat, 13 Apr 2019 22:01:56 +0200 Subject: [PATCH] hotfixes; split up public and private list; Signed-off-by: Yaruma3341 --- .../fightsystem/commands/AkCommand.java | 14 ++++++++-- .../yaruma/fightsystem/fight/FightTeam.java | 11 ++++++-- .../listener/PlayerJoinListener.java | 27 +++++++++++++++++-- 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/src/me/yaruma/fightsystem/commands/AkCommand.java b/src/me/yaruma/fightsystem/commands/AkCommand.java index 94ec98c..91c51d4 100644 --- a/src/me/yaruma/fightsystem/commands/AkCommand.java +++ b/src/me/yaruma/fightsystem/commands/AkCommand.java @@ -173,8 +173,18 @@ public class AkCommand implements CommandExecutor { FightTeam fightTeam = Fight.getPlayerTeam(player); if(fightTeam != null) { if(fightTeam.getFightPlayer(player).isLeader()) { - Fight.getPlayerTeam(player).sendPlayerSchematicList(Integer.parseInt(args[1]), 15, player, Config.SchematicType); - return false; + if(args[0].equalsIgnoreCase("public")) { + Fight.getPlayerTeam(player).sendPlayerSchematicList(false, Integer.parseInt(args[1]), 15, player, Config.SchematicType); + return false; + } else { + int page; + try { + page = Integer.parseInt(args[1]); + } catch (NumberFormatException ex) { + return false; + } + Fight.getPlayerTeam(player).sendPlayerSchematicList(false, page, 15, player, Config.SchematicType); + } } } } catch (NumberFormatException ex) { diff --git a/src/me/yaruma/fightsystem/fight/FightTeam.java b/src/me/yaruma/fightsystem/fight/FightTeam.java index d13a3fd..f0e8658 100644 --- a/src/me/yaruma/fightsystem/fight/FightTeam.java +++ b/src/me/yaruma/fightsystem/fight/FightTeam.java @@ -205,9 +205,16 @@ public class FightTeam { } - public void sendPlayerSchematicList(int currentPage, int filesPerPage, Player player, SchematicType schematicType) { - List preSchematicList = Schematic.getSchemsAccessibleByUser(player.getUniqueId()); + public void sendPlayerSchematicList(boolean publicSchematics, int currentPage, int filesPerPage, Player player, SchematicType schematicType) { + + List preSchematicList; List schematicList = new ArrayList<>(); + if(publicSchematics) { + preSchematicList = Schematic.getSchemsOfType(0, schematicType); + } else { + preSchematicList = Schematic.getSchemsAccessibleByUser(player.getUniqueId()); + } + for(Schematic s : preSchematicList) { if(s.getSchemType() == schematicType) schematicList.add(s); diff --git a/src/me/yaruma/fightsystem/listener/PlayerJoinListener.java b/src/me/yaruma/fightsystem/listener/PlayerJoinListener.java index ad4cccc..cbfa9dd 100644 --- a/src/me/yaruma/fightsystem/listener/PlayerJoinListener.java +++ b/src/me/yaruma/fightsystem/listener/PlayerJoinListener.java @@ -10,6 +10,11 @@ import me.yaruma.fightsystem.utils.countdown.Countdown; import me.yaruma.fightsystem.utils.countdown.CountdownType; import me.yaruma.fightsystem.utils.countdown.FinishSetupOver; import me.yaruma.fightsystem.utils.inventory.SetupItems; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.entity.Player; @@ -32,14 +37,32 @@ public class PlayerJoinListener implements Listener { player.getInventory().clear(); if (Fight.getPlayerTeam(player) == null) { + + //TEXT COMPONENTS + TextComponent publicList = new TextComponent("public"); + publicList.setColor(ChatColor.GOLD); + publicList.setBold(true); + publicList.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§ePublic Liste...").create())); + publicList.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ak schemlist public")); + + TextComponent privateList = new TextComponent("private"); + publicList.setColor(ChatColor.GOLD); + publicList.setBold(true); + publicList.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§ePrivate Liste...").create())); + publicList.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ak schemlist 0")); + + publicList.addExtra(privateList); + player.spigot().sendMessage(publicList); + //TEXT COMPONENTS + if(!Fight.getRedTeam().hasTeamLeader()) { Fight.getRedTeam().setLeader(new FightPlayer(player, false)); - Fight.getRedTeam().sendPlayerSchematicList(0, 15, player, Config.SchematicType); player.setGameMode(GameMode.ADVENTURE); + player.spigot().sendMessage(publicList); } else if(!Fight.getBlueTeam().hasTeamLeader()) { Fight.getBlueTeam().setLeader(new FightPlayer(player, false)); - Fight.getBlueTeam().sendPlayerSchematicList(0, 15, player, Config.SchematicType); player.setGameMode(GameMode.ADVENTURE); + player.spigot().sendMessage(publicList); } else { player.setGameMode(GameMode.SPECTATOR); player.teleport(Config.SpecSpawn);