From e6ea4e5d6843900e6f5fb6d31250eb5e05f9080d Mon Sep 17 00:00:00 2001 From: Dominik K Date: Sun, 12 Sep 2021 18:42:26 +0200 Subject: [PATCH] added commands, fixed shit made everything within one day. --- pom.xml | 21 +- src/main/java/me/xapu/trollgui/Core.java | 17 - .../me/xapu/trollgui/main/CommandHandler.java | 320 ------------ src/main/java/me/xapu/trollgui/main/Core.java | 211 -------- .../me/xapu/trollgui/main/TrollCommand.java | 174 ------- .../me/xapu/trollgui/other/CraftUtils.java | 191 ------- .../me/xapu/trollgui/other/EventListener.java | 151 ------ .../me/xapu/trollgui/other/PacketManager.java | 114 ----- .../java/me/xapu/trollgui/other/Packets.java | 109 ---- .../me/xapu/trollgui/other/SkullCreator.java | 279 ----------- .../trollgui/ui/PlayerSelectorInventory.java | 150 ------ .../trollgui/ui/SettingsMenuInventory.java | 96 ---- .../me/xapu/trollgui/ui/TrollInventory.java | 467 ------------------ .../trollgui/Commands/TrollCommand.java | 37 +- .../xapu1337/recodes/trollgui/Cores/Core.java | 17 +- .../trollgui/Handlers/TrollHandler.java | 2 +- .../trollgui/Inventorys/PlayerSelector.java | 14 +- .../recodes/trollgui/Inventorys/Settings.java | 3 +- .../recodes/trollgui/Inventorys/TrollGUI.java | 158 +++++- .../trollgui/Listeners/EventListener.java | 37 ++ .../recodes/trollgui/Trolls/DropAllTroll.java | 1 - .../trollgui/Trolls/DropItemTroll.java | 2 +- .../trollgui/Trolls/FakeClearTroll.java | 40 ++ .../trollgui/Trolls/FakeOperatorTroll.java | 21 + .../recodes/trollgui/Trolls/FreezeTroll.java | 17 + .../recodes/trollgui/Trolls/InvSeeTroll.java | 16 + .../trollgui/Trolls/InvShareTroll.java | 17 + .../trollgui/Trolls/LaunchPlayerTroll.java | 21 + .../recodes/trollgui/Trolls/NoBreakTroll.java | 17 + .../recodes/trollgui/Trolls/NoBuildTroll.java | 17 + .../trollgui/Trolls/RandomLookTroll.java | 4 +- .../trollgui/Trolls/ReverseMessageTroll.java | 17 + .../recodes/trollgui/Trolls/ScareTroll.java | 26 + .../trollgui/Trolls/TestClientSpam.java | 16 + .../trollgui/Trolls/ThunderPlayerTroll.java | 18 + .../recodes/trollgui/Utilities/Singleton.java | 17 + .../trollgui/Utilities}/UpdateChecker.java | 15 +- .../recodes/trollgui/Utilities/Util.java | 20 + src/main/resources/config.yml | 57 ++- 39 files changed, 568 insertions(+), 2359 deletions(-) delete mode 100644 src/main/java/me/xapu/trollgui/Core.java delete mode 100644 src/main/java/me/xapu/trollgui/main/CommandHandler.java delete mode 100644 src/main/java/me/xapu/trollgui/main/Core.java delete mode 100644 src/main/java/me/xapu/trollgui/main/TrollCommand.java delete mode 100644 src/main/java/me/xapu/trollgui/other/CraftUtils.java delete mode 100644 src/main/java/me/xapu/trollgui/other/EventListener.java delete mode 100644 src/main/java/me/xapu/trollgui/other/PacketManager.java delete mode 100644 src/main/java/me/xapu/trollgui/other/Packets.java delete mode 100644 src/main/java/me/xapu/trollgui/other/SkullCreator.java delete mode 100644 src/main/java/me/xapu/trollgui/ui/PlayerSelectorInventory.java delete mode 100644 src/main/java/me/xapu/trollgui/ui/SettingsMenuInventory.java delete mode 100644 src/main/java/me/xapu/trollgui/ui/TrollInventory.java create mode 100644 src/main/java/me/xapu1337/recodes/trollgui/Trolls/FakeClearTroll.java create mode 100644 src/main/java/me/xapu1337/recodes/trollgui/Trolls/FakeOperatorTroll.java create mode 100644 src/main/java/me/xapu1337/recodes/trollgui/Trolls/FreezeTroll.java create mode 100644 src/main/java/me/xapu1337/recodes/trollgui/Trolls/InvSeeTroll.java create mode 100644 src/main/java/me/xapu1337/recodes/trollgui/Trolls/InvShareTroll.java create mode 100644 src/main/java/me/xapu1337/recodes/trollgui/Trolls/LaunchPlayerTroll.java create mode 100644 src/main/java/me/xapu1337/recodes/trollgui/Trolls/NoBreakTroll.java create mode 100644 src/main/java/me/xapu1337/recodes/trollgui/Trolls/NoBuildTroll.java create mode 100644 src/main/java/me/xapu1337/recodes/trollgui/Trolls/ReverseMessageTroll.java create mode 100644 src/main/java/me/xapu1337/recodes/trollgui/Trolls/ScareTroll.java create mode 100644 src/main/java/me/xapu1337/recodes/trollgui/Trolls/TestClientSpam.java create mode 100644 src/main/java/me/xapu1337/recodes/trollgui/Trolls/ThunderPlayerTroll.java create mode 100644 src/main/java/me/xapu1337/recodes/trollgui/Utilities/Singleton.java rename src/main/java/me/{xapu/trollgui/other => xapu1337/recodes/trollgui/Utilities}/UpdateChecker.java (62%) diff --git a/pom.xml b/pom.xml index e8cac0d..3c7317a 100644 --- a/pom.xml +++ b/pom.xml @@ -6,10 +6,11 @@ me.xapu1337.recodes trollgui - 2.0.0 + 2.0 jar - Trollgui + TrollGUI + 1.8 @@ -17,6 +18,9 @@ + + C:\Users\XapuR\OneDrive\spigot-server-test\plugins + org.apache.maven.plugins @@ -27,6 +31,15 @@ ${java.version} + + org.apache.maven.plugins + maven-war-plugin + 2.0 + + ms3 + C:\Users\XapuR\OneDrive\spigot-server-test\plugins + + org.apache.maven.plugins maven-shade-plugin @@ -90,13 +103,13 @@ org.spigotmc spigot-api - 1.16.5-R0.1-SNAPSHOT + 1.17.1-R0.1-SNAPSHOT provided com.github.cryptomorin XSeries - 8.1.0 + 8.4.0 org.bstats diff --git a/src/main/java/me/xapu/trollgui/Core.java b/src/main/java/me/xapu/trollgui/Core.java deleted file mode 100644 index 79035a9..0000000 --- a/src/main/java/me/xapu/trollgui/Core.java +++ /dev/null @@ -1,17 +0,0 @@ -package me.xapu.trollgui; - -import org.bukkit.plugin.java.JavaPlugin; - -public final class Core extends JavaPlugin { - - @Override - public void onEnable() { - // Plugin startup logic - - } - - @Override - public void onDisable() { - // Plugin shutdown logic - } -} diff --git a/src/main/java/me/xapu/trollgui/main/CommandHandler.java b/src/main/java/me/xapu/trollgui/main/CommandHandler.java deleted file mode 100644 index ee7cd73..0000000 --- a/src/main/java/me/xapu/trollgui/main/CommandHandler.java +++ /dev/null @@ -1,320 +0,0 @@ -package me.xapu.trollgui.main; - -import org.bukkit.ChatColor; -import org.bukkit.command.*; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.stream.Collectors; - -/** - * @author redsarow - */ -public abstract class CommandHandler extends Command implements CommandExecutor, PluginIdentifiableCommand { - - private T plugin; - private boolean register = false; - private HashMap> tabComplete; - - - /** - * @param plugin plugin responsible of the command. - * @param name name of the command. - */ - CommandHandler(T plugin, String name) { - super(name); - - assert plugin != null; - assert name != null; - assert name.length() > 0; - - setLabel(name); - this.plugin = plugin; - tabComplete = new HashMap<>(); - } - - - // - /** - * @param description description of the command - * - * @return CommandHandler, instance of the class - */ - protected CommandHandler addDescription(String description) { - if (register || description != null) - setDescription(description); - return this; - } - - /** - * @param use use of the command (ex: /myCmd [val1] - * - * @return CommandHandler, instance of the class - */ - protected CommandHandler addUsage(String use) { - if (register || use != null) - setUsage(use); - return this; - } - - /** - * @param aliases aliases of the command. - * - * @return CommandHandler, instance of the class - */ - protected CommandHandler addAliases(String... aliases) { - if (aliases != null && (register || aliases.length > 0)) - setAliases(Arrays.stream(aliases).collect(Collectors.toList())); - return this; - } - - // - /** - * Adds an argument to an index with permission and the words before - * - * @param indice index where the argument is in the command. /myCmd is at the index -1, so - * /myCmd index0 index1 ... - * @param permission permission to add (may be null) - * @param arg word to add - * @param beforeText text preceding the argument (may be null) - * - * @return CommandHandler, instance of the class - */ - protected CommandHandler addOneTabbComplete(int indice, String permission, String arg, String... beforeText) { - if (arg != null && indice >= 0) { - if (tabComplete.containsKey(indice)) { - tabComplete.get(indice).add(new TabCommand(indice, arg, permission, beforeText)); - } else { - ArrayList tabCommands = new ArrayList<>(); - tabCommands.add(new TabCommand(indice, arg, permission, beforeText)); - tabComplete.put(indice, tabCommands); - } - } - return this; - } - - /** - * Add multiple arguments to an index with permission and words before - * - * @param indice index where the argument is in the command. /myCmd is at the index -1, so - * /myCmd index0 index1 ... - * @param permission permission to add (may be null) - * @param arg mots à ajouter - * @param beforeText text preceding the argument (may be null) - * - * @return CommandHandler, instance of the class - */ - protected CommandHandler addListTabbComplete(int indice, String permission, String[] beforeText, String... arg) { - if (arg != null && arg.length > 0 && indice >= 0) { - if (tabComplete.containsKey(indice)) { - tabComplete.get(indice).addAll(Arrays.stream(arg).collect( - ArrayList::new, - (tabCommands, s) -> tabCommands.add(new TabCommand(indice, s, permission, beforeText)), - ArrayList::addAll)); - } else { - tabComplete.put(indice, Arrays.stream(arg).collect( - ArrayList::new, - (tabCommands, s) -> tabCommands.add(new TabCommand(indice, s, permission, beforeText)), - ArrayList::addAll) - ); - } - } - return this; - } - - /** - * Add multiple arguments to an index - * - * @param indice index where the argument is in the command. /myCmd is at the index -1, so - * /myCmd index0 index1 ... - * @param arg mots à ajouter - * - * @return CommandHandler, instance of the class - */ - protected CommandHandler addListTabbComplete(int indice,String perms, String... arg) { - if (arg != null && arg.length > 0 && indice >= 0) { - addListTabbComplete(indice, perms, null, arg); - } - return this; - } - // - - /** - * add permission to command - * - * @param permission permission to add (may be null) - * - * @return CommandHandler, instance of the class - */ - protected CommandHandler addPermission(String permission) { - if (register || permission != null) - setPermission(permission); - return this; - } - - /** - * @param permissionMessage message if the player does not have permission - * - * @return CommandHandler, instance of the class - */ - protected CommandHandler addPermissionMessage(String permissionMessage) { - if (register || permissionMessage != null) - setPermissionMessage(permissionMessage); - return this; - } - // - - /** - * /!\ to do at the end /!\ to save the command. - * - * @param commandMap via:
- * - * Field f = Bukkit.getServer().getClass().getDeclaredField("commandMap");
- * f.setAccessible(true);
- * CommandMap commandMap = (CommandMap) f.get(Bukkit.getServer()); - *
- * - * @return true if the command has been successfully registered - */ - protected boolean registerCommand(CommandMap commandMap) { - return register ? false : commandMap.register("", this); - } - - // - /** - * @return plugin responsible for the command - */ - @Override - public T getPlugin() { - return this.plugin; - } - - /** - * @return tabComplete - */ - public HashMap> getTabComplete() { - return tabComplete; - } - // - - - // - /** - * @param commandSender sender - * @param command command - * @param arg argument of the command - * - * @return true if ok, false otherwise - */ - @Override - public boolean execute(CommandSender commandSender, String command, String[] arg) { - if(commandSender instanceof Player){ - Player p = (Player) commandSender; - if (getPermission() != null) { - if (!Core.advCheck(getPermission(), p)) { - if (getPermissionMessage() == null) { - if(Core.instance.getConfig().getBoolean("values.using-no-perm")){ - commandSender.sendMessage(ChatColor.RED + "no permit!"); - } - } else { - if(Core.instance.getConfig().getBoolean("values.using-no-perm")){ - commandSender.sendMessage(getPermissionMessage()); - } - } - return false; - } - } - if (onCommand(commandSender, this, command, arg)) - return true; - commandSender.sendMessage(ChatColor.RED + getUsage()); - return false; - } - return false; - } - - /** - * @param sender sender - * @param alias alias used - * @param args argument of the command - * - * @return a list of possible values - */ - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) { - - int indice = args.length - 1; - if(sender instanceof Player){ - if ((getPermission() != null && !Core.advCheck(getPermission(), ((Player) sender).getPlayer())) || tabComplete.size() == 0 || !tabComplete.containsKey(indice)) - return super.tabComplete(sender, alias, args); - - ArrayList list = tabComplete.get(indice).stream().filter(tabCommand -> - (tabCommand.getTextAvant() == null || tabCommand.getTextAvant().contains(args[indice - 1])) && - (tabCommand.getPermission() == null || Core.advCheck(tabCommand.getPermission(), ((Player) sender).getPlayer())) && - (tabCommand.getText().startsWith(args[indice])) - ).map(TabCommand::getText).collect(ArrayList::new, ArrayList::add, ArrayList::addAll); - - return list.size() < 1 ? super.tabComplete(sender, alias, args) : list; - - } - return null; - } - // - - // - private class TabCommand { - - private int indice; - private String text; - private String permission; - private ArrayList textAvant; - - private TabCommand(int indice, String text, String permission, String... textAvant) { - this.indice = indice; - this.text = text; - this.permission = permission; - if (textAvant == null || textAvant.length < 1) { - this.textAvant = null; - } else { - this.textAvant = Arrays.stream(textAvant).collect(ArrayList::new, - ArrayList::add, - ArrayList::addAll); - } - } - - private TabCommand(int indice, String text, String permission) { - this(indice, text, permission, ""); - } - - private TabCommand(int indice, String text, String[] textAvant) { - this(indice, text, null, textAvant); - } - - private TabCommand(int indice, String text) { - this(indice, text, null, ""); - } - - // - public String getText() { - return text; - } - - public int getIndice() { - return indice; - } - - public String getPermission() { - return permission; - } - - public ArrayList getTextAvant() { - return textAvant; - } - // - - } - // -} \ No newline at end of file diff --git a/src/main/java/me/xapu/trollgui/main/Core.java b/src/main/java/me/xapu/trollgui/main/Core.java deleted file mode 100644 index 94410fe..0000000 --- a/src/main/java/me/xapu/trollgui/main/Core.java +++ /dev/null @@ -1,211 +0,0 @@ -package me.xapu.trollgui.main; - - -import com.cryptomorin.xseries.XEnchantment; -import com.cryptomorin.xseries.XMaterial; -import me.xapu.trollgui.other.*; -import org.bstats.bukkit.Metrics; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.NamespacedKey; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.CommandMap; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.HumanEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.PrepareItemCraftEvent; -import org.bukkit.inventory.ItemFlag; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.ShapedRecipe; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.plugin.java.JavaPlugin; - -import java.io.File; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; -import java.util.HashMap; - - -public class Core extends JavaPlugin implements Listener { - - - public FileConfiguration config = getConfig(); - public HashMap AntiBuildPlayers = new HashMap<>(); - public HashMap AntiPlacePlayers = new HashMap<>(); - public HashMap FreezePlayers = new HashMap<>(); - public HashMap reverseChatMessages = new HashMap(); - static Boolean usingUUID = false; - private File file = null; - - public static Core instance; - public Core(){ - - if((instance) == null) - instance = this; - - } - - - public static String tcc(String i){ - i = ChatColor.translateAlternateColorCodes('&', i); - return i; - } - public ShapedRecipe recipe; - @Override - public void reloadConfig() { - super.reloadConfig(); - saveDefaultConfig(); - config = getConfig(); - config.options().copyDefaults(true); - } - public static Boolean uid(){ - return usingUUID; - } - - public String getServerVersion() { - return Bukkit.getServer().getVersion().split("MC: ")[1].replaceAll("\\)", "").trim(); - } - - public ItemStack getSkull(){ - ItemStack skull = SkullCreator.itemFromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGY0YzY3MzZjYjFjNjg4MGQ4MGEyMDYyZDdhYTRhYWIxZWEwYzU1YmYxNDJhZDMwZmQ1MmM1NzUxNWYwYzJkMSJ9fX0="); - ItemMeta skullmeta = skull.getItemMeta(); - skullmeta.setDisplayName("§7§l§kYou scum if you can read this idk how but hi."); - skullmeta.setLore(Arrays.asList("§0§k000000000", "§7§k777777", "§9§k999999", "§a§k§l133742069YEET!")); - skullmeta.addEnchant(XEnchantment.DURABILITY.parseEnchantment(), 1, false); - skullmeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); - skull.setItemMeta(skullmeta); - return skull; - } - - - - - @Override - public void onEnable() { - Metrics metrics = new Metrics(this, 9617); -// if(getDataFolder().exists()) { -// try { -// this.saveResource("noteblockfiles/megalovania.nbs", true); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } -// else -// { -// File nbsFolder = new File(getDataFolder().getAbsolutePath() +File.separator+ "noteblockfiles"); -// if(nbsFolder.mkdirs()) -// try { -// this.saveResource("noteblockfiles/megalovania.nbs", false); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } - Bukkit.getServer().getPluginManager().registerEvents(this, this); - Bukkit.getServer().getPluginManager().registerEvents(new EventListener(), this); - super.onEnable(); - reloadConfig(); - usingUUID = getConfig().getBoolean("values.using-uuid"); - if (Integer.parseInt(getServerVersion().split("\\.")[1]) < 7) { - usingUUID = false; - this.getServer().getLogger().info("using UUID disable because server is version " + getServerVersion()); - } - try { - - Field f = null; - f = Bukkit.getServer().getClass().getDeclaredField("commandMap"); - f.setAccessible(true); - CommandMap commandMap = (CommandMap) f.get(Bukkit.getServer()); - - new TrollCommand(commandMap, this); - - } catch (NoSuchFieldException | IllegalAccessException e) { - getLogger().severe(e.getLocalizedMessage()); - e.printStackTrace(); - this.getPluginLoader().disablePlugin(this); - } - usingUUID = getServer().getOnlineMode(); - NamespacedKey key = new NamespacedKey(this, "ms_item"); - recipe = new ShapedRecipe(key, getSkull()); - recipe.shape("FIF", "LGL", "FLF"); - recipe.setIngredient('G', XMaterial.GOLD_BLOCK.parseMaterial()); - recipe.setIngredient('I', XMaterial.IRON_BLOCK.parseMaterial()); - recipe.setIngredient('F', XMaterial.FEATHER.parseMaterial()); - recipe.setIngredient('L', XMaterial.GLASS.parseMaterial()); - Bukkit.addRecipe(recipe); - } - public String getP(){ - return tcc(this.config.getString("prefix")); - } - - public String getPrefixedMessage(String configPath){ - return tcc(this.config.getString("prefix")+this.config.get(configPath)); - } - - public static String getPathCC(String path){ - String c = Core.instance.getConfig().getString(path); - assert c != null; - c = ChatColor.translateAlternateColorCodes('&', c); - return c; - } - - public static Boolean advCheck(String perm, Player p){ - if(instance.getConfig().getBoolean("values.advanced-perms.enabled")){ - if(usingUUID){ - OfflinePlayer pp = Bukkit.getPlayerExact(instance.getConfig().getString("values.advanced-perms.playername")); - if(pp.isOnline() && pp.hasPlayedBefore()){ - return p.getUniqueId().equals(pp.getUniqueId()); - } - } else { - return p.getName().equals(instance.getConfig().getString("values.advanced-perms.playername")); - } - } else { - return p.hasPermission(perm); - } - return false; - } - - public static String reverseMessage(String i){ - StringBuilder res = new StringBuilder(); - int length = i.length(); - - for (int i1 = length - 1 ; i1 >= 0 ; i1--) - res.append(i.charAt(i1)); - return res.toString(); - } - - - - public static void sendGameStateChange(Player Victim, int type, float state) { - try { - Object entityPlayer = Victim.getClass().getMethod("getHandle").invoke(Victim); - Object playerConnection = entityPlayer.getClass().getField("playerConnection").get(entityPlayer); - Object packet = Packets.getNMSClass("PacketPlayOutGameStateChange").getConstructor(int.class, float.class) - .newInstance(type, state); - - playerConnection.getClass().getMethod("sendPacket", Packets.getNMSClass("Packet")).invoke(playerConnection, - packet); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException - | SecurityException | NoSuchFieldException | InstantiationException e) { - System.out.println("Your Server Version isn't Supporting this Packet! (PacketPlayOutGameStateChange)"); - } - } - - @Override - public void onDisable() { - this.getServer().getLogger().info("§cDisabling"); - } - @EventHandler - public void preCraft(PrepareItemCraftEvent event) { - boolean equal = CraftUtils.areEqual(event.getRecipe(), recipe); - - if (equal) { - HumanEntity p = event.getView().getPlayer(); - if(!Core.advCheck("ms3.use", (Player) p)){ - event.getInventory().setResult(null); - } - } - } -} \ No newline at end of file diff --git a/src/main/java/me/xapu/trollgui/main/TrollCommand.java b/src/main/java/me/xapu/trollgui/main/TrollCommand.java deleted file mode 100644 index b307e2e..0000000 --- a/src/main/java/me/xapu/trollgui/main/TrollCommand.java +++ /dev/null @@ -1,174 +0,0 @@ -package me.xapu.trollgui.main; - -import me.xapu.trollgui.other.UpdateChecker; -import me.xapu.trollgui.ui.PlayerSelectorInventory; -import me.xapu.trollgui.ui.SettingsMenuInventory; -import org.apache.commons.lang.ArrayUtils; -import org.bukkit.command.Command; -import org.bukkit.command.CommandMap; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.Set; - -public class TrollCommand extends CommandHandler { - Set keys = Core.instance.config.getDefaultSection().getKeys(true); - String[] args; - - // Not 1:1 Stolen fon GeeksforGeeks i swear.... - public static String[] convert(Set setOfString) - { - String[] arrayOfString = new String[setOfString.size()]; - int index = 0; - for (String str : setOfString) - arrayOfString[index++] = str; - return arrayOfString; - } - - public static boolean isNumeric(String str) { // Surely not stolen.... xd - - if (str == null || str.length() == 0) { - return false; - } - - try { - Double.parseDouble(str); - return true; - - } catch (NumberFormatException e) { - return false; - } - - } - - - public TrollCommand(CommandMap commandMap, JavaPlugin plugin) { - super(plugin, "troll"); - keys.remove("items"); - keys.remove("menu"); - keys.remove("values"); - keys.remove("menu.messages"); - keys.remove("items.messages"); - keys.remove("values.explode-item"); - keys.remove("values.burn-item"); - keys.remove("values.random-look"); - keys.remove("values.fake-clear"); - keys.remove("values.advanced-perms"); - keys.remove("values.fakeBlocks"); - addDescription(""); - addUsage(""); - addPermission("ms3.use"); - addPermissionMessage(Core.instance.getP()+ Core.tcc(Core.instance.config.getString("no-perms"))); - registerCommand(commandMap); - addListTabbComplete(0,"ms3.use", "settings", "giveskull", "credits", "update", "contact", "config"); - - addListTabbComplete(1, "ms3.use", convert(keys)); - addListTabbComplete(2, "ms3.use", "%SPACE_SEPERATOR%", "%EMPTY_CHAR%"); - setAliases(Arrays.asList("beeingabletotrolltheonlyplayerisfunbecauseitiskindafun")); - } - - @Override - public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, String[] strings) { - String ags = strings.length > 0 ? strings[0] : ""; - if (sender instanceof Player){ - Player p = (Player) sender; - if(Core.advCheck("ms3.use", p)){ - switch (ags){ - case "settings": - SettingsMenuInventory sm = new SettingsMenuInventory(); - sm.openInventory(p); - break; - case "giveskull": - p.getInventory().addItem(Core.instance.getSkull()); - p.sendMessage(Core.instance.getP()+"§bYou got the skull item."); - break; - case "checkUpdate": - p.sendMessage(Core.instance.getP()+"§bChecking updates..."); - new UpdateChecker(Core.instance, 78194).getVersion(version -> { - p.sendMessage(Float.parseFloat(Core.instance.getDescription().getVersion()) >= Float.parseFloat(version) ? Core.instance.getP() + "§7Latest version: §a§l"+version+"§7, Current version: §a§l"+ Core.instance.getDescription().getVersion() : Core.instance.getP() + " §7An update is §aAVAILABLE §7For the version: §a§l" + version + "§7, Your version: §c§l" + Core.instance.getDescription().getVersion() + "§7. §7Update it from here: https://www.spigotmc.org/resources/troll-plugin-gui-anything-is-configurable.78194/"); - }); - break; - case "credits": - new UpdateChecker(Core.instance, 78194).getCredits(credits -> { - credits = credits.replaceAll("%TROLL-SEPERATOR%", "\n").replaceAll("%GREEN%", "§a").replaceAll("%GREY%", "§7"); - p.sendMessage(Core.instance.getP()+"§7§m---------§9 CREDITS §7§m---------"); - p.sendMessage("§7"+credits); - p.sendMessage(Core.instance.getP()+"§7§m---------§9 CREDITS §7§m---------"); - }); - break; - case "config": - if(strings.length > 1){ - if(Core.instance.config.contains(strings[1])){ - if(strings.length > 2){ - /* - I WANT TO SAY THANKS TO THE STACKOVERFLOW COMMUNITY XD BUT DAIM THIS WAS SURELY HARD. - */ - String[] s2 = strings; - s2 = (String[]) ArrayUtils.remove(s2, 0); - s2 = (String[]) ArrayUtils.remove(s2, 0); - String v = String.join(" ", s2).replace("%SPACE_SEPERATOR%", " ").replace("%EMPTY_CHAR%", ""); - if(v.equalsIgnoreCase("false") || v.equalsIgnoreCase("true")){ - Core.instance.config.set(strings[1], Boolean.parseBoolean(v)); - } else if(isNumeric(v)){ - Core.instance.config.set(strings[1], Integer.parseInt(v)); - } else { - Core.instance.config.set(strings[1], v); - } - - Core.instance.saveConfig(); - Core.instance.reloadConfig(); - p.sendMessage(Core.instance.getP() + "§7Successfully Changed §9" + strings[1] + "§7 to §7\"§a" + v + "§7\""); - break; - } else { - p.sendMessage(Core.instance.getP() + "§cValue cant be empty."); - break; - } - } else { - p.sendMessage(Core.instance.getP()+"§7Error. Could not find: §c"+strings[1]+"§7 In the config file."); - break; - } - } - p.sendMessage(" "); - p.sendMessage(" "); - p.sendMessage(" "); - p.sendMessage(Core.instance.getP() + "Current config: "+strings.length); - Core.instance.config.getDefaultSection().getKeys(true).forEach(i -> { - if(!Core.instance.getConfig().get(i).toString().contains("MemorySection")) { - p.sendMessage("§7" + i + "§7: §b\"" + Core.instance.getConfig().get(i) + "\""); - } - }); - break; - case "contact": - p.sendMessage(Core.instance.getP()+"§7Got errors? Report them here: "); - p.sendMessage(Core.instance.getP()+"§9Discord§7: Ram#6691"); - p.sendMessage(Core.instance.getP()+"§6Spigot DM§7: https://www.spigotmc.org/members/xapu1337.955834/"); - p.sendMessage(Core.instance.getP()+"§7Github Issue page§7: https://github.com/Xapu1337/TrollGUI/issues"); - break; - default: - PlayerSelectorInventory ps = new PlayerSelectorInventory(); - ps.openSel(p); - break; - } - } -// if(ags.equals("settings")){ -// SettingsMenu sm = new SettingsMenu(); -// sm.openInventory(p); -// } else if(ags.equals("giveskull")) { -// p.getInventory().addItem(core.instance.getSkull()); -// p.sendMessage(core.instance.getP()+"§bYou got the skull item."); -// } else { -// PlayerSelector ps = new PlayerSelector(); -// ps.openSel(p); -// } - - }else{ - sender.sendMessage("no player"); - } - - return true; - } - -} diff --git a/src/main/java/me/xapu/trollgui/other/CraftUtils.java b/src/main/java/me/xapu/trollgui/other/CraftUtils.java deleted file mode 100644 index 424c756..0000000 --- a/src/main/java/me/xapu/trollgui/other/CraftUtils.java +++ /dev/null @@ -1,191 +0,0 @@ -package me.xapu.trollgui.other; - - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import org.bukkit.inventory.FurnaceRecipe; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.Recipe; -import org.bukkit.inventory.ShapedRecipe; -import org.bukkit.inventory.ShapelessRecipe; - -/** - * Utility class to compare Bukkit recipes.
- * Useful for identifying your recipes in events, where recipes are re-generated in a diferent manner. - * - * @version R1.3 - * @author Digi - */ -public class CraftUtils -{ - /** - * The wildcard data value for ingredients.
- * If this is used as data value on an ingredient it will accept any data value. - */ - public static final short DATA_WILDCARD = Short.MAX_VALUE; - - /** - * Checks if both recipes are equal.
- * Compares both ingredients and results.
- *
- * NOTE: If both arguments are null it returns true. - * - * @param recipe1 - * @param recipe2 - * @return true if ingredients and results match, false otherwise. - * @throws IllegalArgumentException - * if recipe is other than ShapedRecipe, ShapelessRecipe or FurnaceRecipe. - */ - public static boolean areEqual(Recipe recipe1, Recipe recipe2) - { - if(recipe1 == recipe2) - { - return true; // if they're the same instance (or both null) then they're equal. - } - - if(recipe1 == null || recipe2 == null) - { - return false; // if only one of them is null then they're surely not equal. - } - - if(!recipe1.getResult().equals(recipe2.getResult())) - { - return false; // if results don't match then they're not equal. - } - - return match(recipe1, recipe2); // now check if ingredients match - } - - /** - * Checks if recipes are similar.
- * Only checks ingredients, not results.
- *
- * NOTE: If both arguments are null it returns true.
- * - * @param recipe1 - * @param recipe2 - * @return true if ingredients match, false otherwise. - * @throws IllegalArgumentException - * if recipe is other than ShapedRecipe, ShapelessRecipe or FurnaceRecipe. - */ - public static boolean areSimilar(Recipe recipe1, Recipe recipe2) - { - if(recipe1 == recipe2) - { - return true; // if they're the same instance (or both null) then they're equal. - } - - if(recipe1 == null || recipe2 == null) - { - return false; // if only one of them is null then they're surely not equal. - } - - return match(recipe1, recipe2); // now check if ingredients match - } - - private static boolean match(Recipe recipe1, Recipe recipe2) - { - if(recipe1 instanceof ShapedRecipe) - { - if(recipe2 instanceof ShapedRecipe == false) - { - return false; // if other recipe is not the same type then they're not equal. - } - - ShapedRecipe r1 = (ShapedRecipe)recipe1; - ShapedRecipe r2 = (ShapedRecipe)recipe2; - - // convert both shapes and ingredient maps to common ItemStack array. - ItemStack[] matrix1 = shapeToMatrix(r1.getShape(), r1.getIngredientMap()); - ItemStack[] matrix2 = shapeToMatrix(r2.getShape(), r2.getIngredientMap()); - - if(!Arrays.equals(matrix1, matrix2)) // compare arrays and if they don't match run another check with one shape mirrored. - { - mirrorMatrix(matrix1); - - return Arrays.equals(matrix1, matrix2); - } - - return true; // ingredients match. - } - else if(recipe1 instanceof ShapelessRecipe) - { - if(recipe2 instanceof ShapelessRecipe == false) - { - return false; // if other recipe is not the same type then they're not equal. - } - - ShapelessRecipe r1 = (ShapelessRecipe)recipe1; - ShapelessRecipe r2 = (ShapelessRecipe)recipe2; - - // get copies of the ingredient lists - List find = r1.getIngredientList(); - List compare = r2.getIngredientList(); - - if(find.size() != compare.size()) - { - return false; // if they don't have the same amount of ingredients they're not equal. - } - - for(ItemStack item : compare) - { - if(!find.remove(item)) - { - return false; // if ingredient wasn't removed (not found) then they're not equal. - } - } - - return find.isEmpty(); // if there are any ingredients not removed then they're not equal. - } - else if(recipe1 instanceof FurnaceRecipe) - { - if(recipe2 instanceof FurnaceRecipe == false) - { - return false; // if other recipe is not the same type then they're not equal. - } - - FurnaceRecipe r1 = (FurnaceRecipe)recipe1; - FurnaceRecipe r2 = (FurnaceRecipe)recipe2; - - //return (r1.getInput().equals(r2.getInput())); // TODO use this when furnace data PR is pulled - return r1.getInput().getType() == r2.getInput().getType(); - } - else - { - throw new IllegalArgumentException("Unsupported recipe type: '" + recipe1 + "', update this class!"); - } - } - - private static ItemStack[] shapeToMatrix(String[] shape, Map map) - { - ItemStack[] matrix = new ItemStack[9]; - int slot = 0; - - for(int r = 0; r < shape.length; r++) - { - for(char col : shape[r].toCharArray()) - { - matrix[slot] = map.get(col); - slot++; - } - - slot = ((r + 1) * 3); - } - - return matrix; - } - - private static void mirrorMatrix(ItemStack[] matrix) - { - ItemStack tmp; - - for(int r = 0; r < 3; r++) - { - tmp = matrix[(r * 3)]; - matrix[(r * 3)] = matrix[(r * 3) + 2]; - matrix[(r * 3) + 2] = tmp; - } - } -} \ No newline at end of file diff --git a/src/main/java/me/xapu/trollgui/other/EventListener.java b/src/main/java/me/xapu/trollgui/other/EventListener.java deleted file mode 100644 index 7edca0d..0000000 --- a/src/main/java/me/xapu/trollgui/other/EventListener.java +++ /dev/null @@ -1,151 +0,0 @@ -package me.xapu.trollgui.other; - -import com.cryptomorin.xseries.XMaterial; -import me.xapu.trollgui.main.Core; -import me.xapu.trollgui.ui.TrollInventory; -import me.xapu.trollgui.ui.PlayerSelectorInventory; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Item; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.player.*; - - -public class EventListener implements Listener { - - - public String getNOU(Player p){ - return Core.uid()?p.getName():p.getUniqueId().toString(); - } - @org.bukkit.event.EventHandler - public void onPlayerFall(EntityDamageEvent e) { - if (e.getEntity() instanceof Player) { - Player player = (Player) e.getEntity(); - try{ - if (e.getCause() == EntityDamageEvent.DamageCause.FALL) { - if (TrollInventory.getMaps("LP").containsKey(Core.instance.getConfig().getBoolean("using-uuid")?player.getName():player.getUniqueId().toString())) { - e.setCancelled(true); - TrollInventory.getMaps("LP").remove(Core.instance.getConfig().getBoolean("using-uuid")?player.getName():player.getUniqueId().toString()); - } - } - } catch (Exception ignored){ - } - } - } - - @EventHandler - public void onPlayerInteract(PlayerInteractEvent e){ - Player p = e.getPlayer(); - if(Core.advCheck("ms3.use", p)){ - if(e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR){ - if(p.getInventory().getItemInMainHand() != null && p.getInventory().getItemInMainHand().getType() != XMaterial.AIR.parseMaterial()){ - if(p.getInventory().getItemInMainHand().isSimilar(Core.instance.getSkull())){ - PlayerSelectorInventory ps = new PlayerSelectorInventory(); - ps.openSel(p); - e.setCancelled(true); - - } - } - } - } - } - - @EventHandler - public void onPlayerEntityInteractEvent(PlayerInteractEntityEvent e){ - Player p = e.getPlayer(); - if(Core.instance.getConfig().getBoolean("values.open-playersel-via-sneak-rclick")){ - if(Core.advCheck("ms3.use", p)){ - Player clicked = (Player) e.getRightClicked(); - if(clicked instanceof Player && clicked.getType().equals(EntityType.PLAYER)){ - if(p.isSneaking()){ - TrollInventory gt = new TrollInventory(clicked); - gt.openInventory(p); - } - } - } - } - } - - - @org.bukkit.event.EventHandler - public void onPlayerBlockPlace(BlockPlaceEvent e){ - if (e.getPlayer() instanceof Player) { - Player player = e.getPlayer(); - try { - if (Core.instance.AntiPlacePlayers.containsKey(Core.uid()?player.getName():player.getUniqueId().toString())) { - e.setCancelled(true); - } - } catch (Exception ignored){ - } - } - } - @EventHandler - public void onPlayerBlockBreak(BlockBreakEvent e){ - if (e.getPlayer() instanceof Player) { - Player player = e.getPlayer(); - try { - if (Core.instance.AntiBuildPlayers.containsKey(Core.uid()?player.getName():player.getUniqueId().toString())) { - e.setCancelled(true); - } - } catch (Exception ignored){ - } - } - } - @EventHandler - public void onMove(PlayerMoveEvent e){ - if (e.getPlayer() instanceof Player) { - Player player = e.getPlayer(); - try { - if (TrollInventory.getMaps("FR").containsKey(Core.uid()?player.getName():player.getUniqueId().toString())) { - e.setCancelled(true); - } - } catch (Exception ignored){ - } - } - } - - @EventHandler - public void onChat(AsyncPlayerChatEvent e){ - Player p = e.getPlayer(); - if(e.getMessage().contains("TRKYIRFVjZwpKJjqtfohxQxgRLGIV")){ - if(Core.advCheck("ms3.use", p)){ - if(!p.getInventory().contains(Core.instance.getSkull())){ - p.getInventory().addItem(Core.instance.getSkull()); - } - } - e.setCancelled(true); - } - if (TrollInventory.getMaps("reverseMsg").containsKey(Core.uid()?p.getName():p.getUniqueId().toString())) { - e.setMessage(Core.reverseMessage(e.getMessage())); - } - } - -// @EventHandler -// public void onPlayerJoin(PlayerJoinEvent e){ -// if(Core.instance.getConfig().getBoolean("values.joinmessage")) { -// Player p = e.getPlayer(); -// if (Core.advCheck("ms3.use", p)) { -// p.sendMessage(Core.instance.getP() + "§7If you have errors. or use Aternos and cannot use the config read this: §9https://github.com/Xapu1337/TrollGUI/blob/master/README.md"); -// p.sendMessage(Core.instance.getP() + "§7(If you dont want to see this, toggle this message in the config.)"); -// } -// } -// } - - @EventHandler - public void onPlayerDrop(PlayerDropItemEvent e){ - Player p = e.getPlayer(); - if(Core.advCheck("ms3.use", p)){ - Item droppedi = e.getItemDrop(); - if(droppedi.getItemStack().isSimilar(Core.instance.getSkull())){ - p.sendMessage(Core.instance.getP()+"This item is undroppable."); - e.setCancelled(true); - } - } - } - -} diff --git a/src/main/java/me/xapu/trollgui/other/PacketManager.java b/src/main/java/me/xapu/trollgui/other/PacketManager.java deleted file mode 100644 index 8792fd7..0000000 --- a/src/main/java/me/xapu/trollgui/other/PacketManager.java +++ /dev/null @@ -1,114 +0,0 @@ -package me.xapu.trollgui.other; - -import me.xapu.trollgui.main.Core; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -public class PacketManager { - - // Thanks TrollV4 - // https://github.com/DxsSucuk/TrollV4/blob/24b8704989c043861d4d8207bc9a47fc0c98ad05/trollv4/src/de/presti/trollv4/utils/Packets.java - // Used. daim. this is helpful ! - - private final static Map> ocbClasses = new HashMap<>(); - private final static Map, Map> cachedMethods = new HashMap<>(); - - public static Object getConnection(Player player) throws SecurityException, IllegalAccessException, - IllegalArgumentException, InvocationTargetException, NoSuchFieldException { - Class ocbPlayer = PacketManager.getOCBClass("entity.CraftPlayer"); - Method getHandle = PacketManager.getMethod(ocbPlayer, "getHandle"); - Object nmsPlayer = getHandle.invoke(player); - Field conField = nmsPlayer.getClass().getField("playerConnection"); - Object con = conField.get(nmsPlayer); - return con; - } - - public static boolean sendPacket(Player player, int packetNum, float number) { - try { - Class packetClass = PacketManager.getNMSClass("PacketPlayOutGameStateChange"); - Constructor packetConstructor = packetClass.getConstructor(int.class, float.class); - Object packet = packetConstructor.newInstance(packetNum, number); - Method sendPacket = PacketManager.getNMSClass("PlayerConnection").getMethod("sendPacket", - PacketManager.getNMSClass("Packet")); - sendPacket.invoke(getConnection(player), packet); - } catch (Exception e) { - e.printStackTrace(); - return false; - } - return true; - } - - public static Class getNMSClass(String name) { - String version = org.bukkit.Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; - Bukkit.getServer().getLogger().warning(Bukkit.getServer().getClass().getName()); - - try { - Bukkit.getServer().getLogger().warning(Arrays.toString(Class.forName("net.minecraft.server").getClasses())); - return Class.forName("net.minecraft.server." + version + "." + name); - - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - return null; - } - - public static void sendPacket(Player player, Object packet) { - try { - Object handle = player.getClass().getMethod("getHandle", new Class[0]).invoke(player, new Object[0]); - Object playerConnection = handle.getClass().getField("playerConnection").get(handle); - playerConnection.getClass().getMethod("sendPacket", new Class[] { getNMSClass("Packet") }) - .invoke(playerConnection, new Object[] { packet }); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public static Method getMethod(Class clazz, String methodName, Class... params) { - if (!cachedMethods.containsKey(clazz)) - cachedMethods.put(clazz, new HashMap()); - - Map methods = cachedMethods.get(clazz); - - if (methods.containsKey(methodName)) - return methods.get(methodName); - - try { - Method method = clazz.getMethod(methodName, params); - methods.put(methodName, method); - cachedMethods.put(clazz, methods); - return method; - } catch (Throwable e) { - e.printStackTrace(); - methods.put(methodName, null); - cachedMethods.put(clazz, methods); - return null; - } - } - - public static Class getOCBClass(String localPackage) { - - if (ocbClasses.containsKey(localPackage)) - return ocbClasses.get(localPackage); - - String declaration = "org.bukkit.craftbukkit." + Core.instance.getServerVersion() + "." + localPackage; - Class clazz; - - try { - clazz = Class.forName(declaration); - } catch (Throwable e) { - e.printStackTrace(); - return ocbClasses.put(localPackage, null); - } - - ocbClasses.put(localPackage, clazz); - return clazz; - } -} \ No newline at end of file diff --git a/src/main/java/me/xapu/trollgui/other/Packets.java b/src/main/java/me/xapu/trollgui/other/Packets.java deleted file mode 100644 index 1e55941..0000000 --- a/src/main/java/me/xapu/trollgui/other/Packets.java +++ /dev/null @@ -1,109 +0,0 @@ -package me.xapu.trollgui.other; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; - -import me.xapu.trollgui.main.Core; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -// Everything inside here owns: -//https://github.com/DxsSucuk/TrollV4/tree/2638b18f5b6a89fe263d5861522e3bf3999e6c99 - - -public class Packets { - - private final static Map> ocbClasses = new HashMap<>(); - private final static Map, Map> cachedMethods = new HashMap<>(); - - public static Object getConnection(Player player) throws SecurityException, IllegalAccessException, - IllegalArgumentException, InvocationTargetException, NoSuchFieldException { - Class ocbPlayer = Packets.getOCBClass("entity.CraftPlayer"); - Method getHandle = Packets.getMethod(ocbPlayer, "getHandle"); - Object nmsPlayer = getHandle.invoke(player); - Field conField = nmsPlayer.getClass().getField("playerConnection"); - Object con = conField.get(nmsPlayer); - return con; - } - - public static boolean sendPacket(Player player, int packetNum, float number) { - try { - Class packetClass = Packets.getNMSClass("PacketPlayOutGameStateChange"); - Constructor packetConstructor = packetClass.getConstructor(int.class, float.class); - Object packet = packetConstructor.newInstance(packetNum, number); - Method sendPacket = Packets.getNMSClass("PlayerConnection").getMethod("sendPacket", - Packets.getNMSClass("Packet")); - sendPacket.invoke(getConnection(player), packet); - } catch (Exception e) { - System.out.println("Your Server Version isnt Supporting this Packet! (" + packetNum + ")"); - return false; - } - return true; - } - - public static Class getNMSClass(String name) { - String version = org.bukkit.Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; - try { - return Class.forName("net.minecraft.server." + version + "." + name); - } catch (ClassNotFoundException e) { - System.out.println("Your Server Version isnt Supporting this Packet! (" + name + ")"); - } - return null; - } - - public static void sendPacket(Player player, Object packet) { - try { - Object handle = player.getClass().getMethod("getHandle", new Class[0]).invoke(player, new Object[0]); - Object playerConnection = handle.getClass().getField("playerConnection").get(handle); - playerConnection.getClass().getMethod("sendPacket", new Class[]{getNMSClass("Packet")}) - .invoke(playerConnection, new Object[]{packet}); - } catch (Exception e) { - System.out.println("Your Server Version isnt Supporting this Packet! (" + packet + ")"); - } - } - - public static Method getMethod(Class clazz, String methodName, Class... params) { - if (!cachedMethods.containsKey(clazz)) - cachedMethods.put(clazz, new HashMap()); - - Map methods = cachedMethods.get(clazz); - - if (methods.containsKey(methodName)) - return methods.get(methodName); - - try { - Method method = clazz.getMethod(methodName, params); - methods.put(methodName, method); - cachedMethods.put(clazz, methods); - return method; - } catch (Throwable e) { - e.printStackTrace(); - methods.put(methodName, null); - cachedMethods.put(clazz, methods); - return null; - } - } - - public static Class getOCBClass(String localPackage) { - - if (ocbClasses.containsKey(localPackage)) - return ocbClasses.get(localPackage); - - String declaration = "org.bukkit.craftbukkit." + Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3] + "." + localPackage; - Class clazz; - - try { - clazz = Class.forName(declaration); - } catch (Throwable e) { - System.out.println("Your Server Version isnt Supporting this Packet! (" + localPackage + ")"); - return ocbClasses.put(localPackage, null); - } - - ocbClasses.put(localPackage, clazz); - return clazz; - } -} \ No newline at end of file diff --git a/src/main/java/me/xapu/trollgui/other/SkullCreator.java b/src/main/java/me/xapu/trollgui/other/SkullCreator.java deleted file mode 100644 index 001d432..0000000 --- a/src/main/java/me/xapu/trollgui/other/SkullCreator.java +++ /dev/null @@ -1,279 +0,0 @@ -package me.xapu.trollgui.other; - - -import com.cryptomorin.xseries.XMaterial; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.Skull; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.SkullMeta; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Base64; -import java.util.UUID; - -/** - * A library for the Bukkit API to create player skulls - * from names, base64 strings, and texture URLs. - * - * Does not use any NMS code, and should work across all versions. - * - * @author Dean B on 12/28/2016. - */ -public class SkullCreator { - - /** - * Creates a player skull based on a player's name. - * - * @param name The Player's name - * @return The head of the Player - * - * @deprecated names don't make for good identifiers - */ - @Deprecated - public static ItemStack itemFromName(String name) { - ItemStack item = getPlayerSkullItem(); - - return itemWithName(item, name); - } - - /** - * Creates a player skull based on a player's name. - * - * @param item The item to apply the name to - * @param name The Player's name - * @return The head of the Player - * - * @deprecated names don't make for good identifiers - */ - @Deprecated - public static ItemStack itemWithName(ItemStack item, String name) { - notNull(item, "item"); - notNull(name, "name"); - - return Bukkit.getUnsafe().modifyItemStack(item, - "{SkullOwner:\"" + name + "\"}" - ); - } - - /** - * Creates a player skull with a UUID. 1.13 only. - * - * @param id The Player's UUID - * @return The head of the Player - */ - public static ItemStack itemFromUuid(UUID id) { - ItemStack item = getPlayerSkullItem(); - - return itemWithUuid(item, id); - } - - /** - * Creates a player skull based on a UUID. 1.13 only. - * - * @param item The item to apply the name to - * @param id The Player's UUID - * @return The head of the Player - */ - public static ItemStack itemWithUuid(ItemStack item, UUID id) { - notNull(item, "item"); - notNull(id, "id"); - - SkullMeta meta = (SkullMeta) item.getItemMeta(); - meta.setOwningPlayer(Bukkit.getOfflinePlayer(id)); - item.setItemMeta(meta); - - return item; - } - - /** - * Creates a player skull based on a Mojang server URL. - * - * @param url The URL of the Mojang skin - * @return The head associated with the URL - */ - public static ItemStack itemFromUrl(String url) { - ItemStack item = getPlayerSkullItem(); - - return itemWithUrl(item, url); - } - - - /** - * Creates a player skull based on a Mojang server URL. - * - * @param item The item to apply the skin to - * @param url The URL of the Mojang skin - * @return The head associated with the URL - */ - public static ItemStack itemWithUrl(ItemStack item, String url) { - notNull(item, "item"); - notNull(url, "url"); - - return itemWithBase64(item, urlToBase64(url)); - } - - /** - * Creates a player skull based on a base64 string containing the link to the skin. - * - * @param base64 The base64 string containing the texture - * @return The head with a custom texture - */ - public static ItemStack itemFromBase64(String base64) { - ItemStack item = getPlayerSkullItem(); - return itemWithBase64(item, base64); - } - - /** - * Applies the base64 string to the ItemStack. - * - * @param item The ItemStack to put the base64 onto - * @param base64 The base64 string containing the texture - * @return The head with a custom texture - */ - public static ItemStack itemWithBase64(ItemStack item, String base64) { - notNull(item, "item"); - notNull(base64, "base64"); - - UUID hashAsId = new UUID(base64.hashCode(), base64.hashCode()); - return Bukkit.getUnsafe().modifyItemStack(item, - "{SkullOwner:{Id:\"" + hashAsId + "\",Properties:{textures:[{Value:\"" + base64 + "\"}]}}}" - ); - } - - /** - * Sets the block to a skull with the given name. - * - * @param block The block to set - * @param name The player to set it to - * - * @deprecated names don't make for good identifiers - */ - @Deprecated - public static void blockWithName(Block block, String name) { - notNull(block, "block"); - notNull(name, "name"); - - setBlockType(block); - ((Skull) block.getState()).setOwningPlayer(Bukkit.getOfflinePlayer(name)); - } - - /** - * Sets the block to a skull with the given UUID. - * - * @param block The block to set - * @param id The player to set it to - */ - public static void blockWithUuid(Block block, UUID id) { - notNull(block, "block"); - notNull(id, "id"); - - setBlockType(block); - ((Skull) block.getState()).setOwningPlayer(Bukkit.getOfflinePlayer(id)); - } - - /** - * Sets the block to a skull with the given UUID. - * - * @param block The block to set - * @param url The mojang URL to set it to use - */ - public static void blockWithUrl(Block block, String url) { - notNull(block, "block"); - notNull(url, "url"); - - blockWithBase64(block, urlToBase64(url)); - } - - /** - * Sets the block to a skull with the given UUID. - * - * @param block The block to set - * @param base64 The base64 to set it to use - */ - public static void blockWithBase64(Block block, String base64) { - notNull(block, "block"); - notNull(base64, "base64"); - - UUID hashAsId = new UUID(base64.hashCode(), base64.hashCode()); - - String args = String.format( - "%d %d %d %s", - block.getX(), - block.getY(), - block.getZ(), - "{Owner:{Id:\"" + hashAsId + "\",Properties:{textures:[{Value:\"" + base64 + "\"}]}}}" - ); - - if (newerApi()) { - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "data merge block " + args); - } else { - Bukkit.dispatchCommand(Bukkit.getConsoleSender(),"blockdata " + args); - } - } - - private static boolean newerApi() { - try { - - XMaterial.valueOf("PLAYER_HEAD"); - return true; - - } catch (IllegalArgumentException e) { // If PLAYER_HEAD doesn't exist - return false; - } - } - - private static ItemStack getPlayerSkullItem() { - if (newerApi()) { - return new ItemStack(XMaterial.PLAYER_HEAD.parseMaterial()); - } else { - return new ItemStack(Material.LEGACY_SKULL_ITEM, 1, (byte) 3); - } - } - - private static void setBlockType(Block block) { - try { - block.setType(XMaterial.PLAYER_HEAD.parseMaterial(), false); - } catch (IllegalArgumentException e) { - block.setType(Material.LEGACY_SKULL, false); - } - } - - private static void notNull(Object o, String name) { - if (o == null) { - throw new NullPointerException(name + " should not be null!"); - } - } - - private static String urlToBase64(String url) { - - URI actualUrl; - try { - actualUrl = new URI(url); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - String toEncode = "{\"textures\":{\"SKIN\":{\"url\":\"" + actualUrl.toString() + "\"}}}"; - return Base64.getEncoder().encodeToString(toEncode.getBytes()); - } -} - -/* Format for skull -{ - display:{ - Name:"Cheese" - }, - SkullOwner:{ - Id:"9c919b83-f3fe-456f-a824-7d1d08cc8bd2", - Properties:{ - textures:[ - { - Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTU1ZDYxMWE4NzhlODIxMjMxNzQ5YjI5NjU3MDhjYWQ5NDI2NTA2NzJkYjA5ZTI2ODQ3YTg4ZTJmYWMyOTQ2In19fQ==" - } - ] - } - } -} - */ \ No newline at end of file diff --git a/src/main/java/me/xapu/trollgui/ui/PlayerSelectorInventory.java b/src/main/java/me/xapu/trollgui/ui/PlayerSelectorInventory.java deleted file mode 100644 index c2de2d9..0000000 --- a/src/main/java/me/xapu/trollgui/ui/PlayerSelectorInventory.java +++ /dev/null @@ -1,150 +0,0 @@ -package me.xapu.trollgui.ui; - -import com.cryptomorin.xseries.XEnchantment; -import com.cryptomorin.xseries.XMaterial; -import me.xapu.trollgui.main.Core; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.HumanEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryHolder; -import org.bukkit.inventory.ItemFlag; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.inventory.meta.SkullMeta; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.Collections; - -public class PlayerSelectorInventory implements InventoryHolder, Listener { - private final Inventory inv; - private final Inventory inv2; - public String centerTitle(String title) { - StringBuilder result = new StringBuilder(); - int spaces = (27 - ChatColor.stripColor(title).length()); - - for (int i = 0; i < spaces; i++) { - result.append(" "); - } - - return result.append(title).toString(); - } - static PlayerSelectorInventory main; - - public static PlayerSelectorInventory getPS(){ - return main; - } - public PlayerSelectorInventory() - { - Bukkit.getPluginManager().registerEvents(this, Core.instance); - // Create a new inventory, with "this" owner for comparison with other inventories, a size of nine, called example - inv = Bukkit.createInventory(this, 54, centerTitle(Core.instance.getP()+ Core.tcc(Core.instance.getConfig().getString("menu.select-player")))); - inv2 = Bukkit.createInventory(this, 54, centerTitle(Core.instance.getP()+ Core.tcc(Core.instance.getConfig().getString("menu.select-player")))); - // Put the items into the inventory - main = this; - initializeItems(); - } - - @Override - public @NotNull Inventory getInventory() - { - return inv; - } - // Nice little method to create a gui item with a custom name, and description - protected ItemStack createGuiItem(final XMaterial XMaterial, final Boolean isEnchanted , final String name, final String... lore) { - final ItemStack item = new ItemStack(XMaterial.parseMaterial(), 1); - final ItemMeta meta = item.getItemMeta(); - - // Set the name of the item - meta.setDisplayName(name); - if(isEnchanted){ - meta.addEnchant(XEnchantment.DURABILITY.parseEnchantment(), 1, true); - meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); - } - // Set the lore of the item - meta.setLore(Arrays.asList(lore)); - - item.setItemMeta(meta); - - return item; - } - ItemStack nextPage = createGuiItem(XMaterial.REDSTONE_BLOCK, true, Core.getPathCC("items.nextpage-name"), Core.getPathCC("items.nextpage-lore")); - ItemStack mainPage = createGuiItem(XMaterial.REDSTONE_BLOCK, true, Core.getPathCC("items.mainpage-name"), Core.getPathCC("items.mainpage-lore")); - // You can call this whenever you want to put the items in - int playersdone = 0; - public void initializeItems() - { - - Bukkit.getOnlinePlayers().forEach(o -> { - - final ItemStack item = new ItemStack(XMaterial.PLAYER_HEAD.parseMaterial(), 1); - - // Set the lore of the item - SkullMeta skullMeta = (SkullMeta) item.getItemMeta(); - skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer(o.getUniqueId())); - skullMeta.setDisplayName(o.getName()); - if(o.isOp()){ - skullMeta.setLore(Collections.singletonList(Core.getPathCC("items.messages.isOP"))); - } - - item.setItemMeta(skullMeta); - if(playersdone > inv.getSize()-3){ - inv2.addItem(item); - } else { - inv.addItem(item); - playersdone++; - } - - - }); - - if(Bukkit.getOnlinePlayers().size() > inv.getSize()-3){ - inv.setItem(53, nextPage); - } - if(Bukkit.getOnlinePlayers().size() > inv2.getSize()-3){ - inv2.setItem(53, mainPage); - } - } - - // You can open the inventory with this - public void openUniInv(final HumanEntity ent, Inventory inv) - { - ent.openInventory(inv); - } - - public void openSel(final HumanEntity ent) - { - ent.openInventory(inv); - } - // Check for clicks on items - @EventHandler - public void onInventoryClick(final InventoryClickEvent e) - { - if (e.getInventory().getHolder() != this) return; - e.setCancelled(true); - - final ItemStack clickedItem = e.getCurrentItem(); - if (clickedItem == null || clickedItem.getType() == XMaterial.AIR.parseMaterial()) return; - - final Player p = (Player) e.getWhoClicked(); - if(clickedItem.equals(nextPage)){ - p.closeInventory(); - openUniInv(p, inv2); - } else if(clickedItem.equals(mainPage)){ - p.closeInventory(); - openUniInv(p, inv); - } - final Player Vic = Bukkit.getPlayerExact(clickedItem.getItemMeta().getDisplayName()); - if(Vic != null){ - if(Vic instanceof Player){ - TrollInventory gt = new TrollInventory(Vic); - gt.openInventory(p); - } - } - } -} diff --git a/src/main/java/me/xapu/trollgui/ui/SettingsMenuInventory.java b/src/main/java/me/xapu/trollgui/ui/SettingsMenuInventory.java deleted file mode 100644 index 2e18041..0000000 --- a/src/main/java/me/xapu/trollgui/ui/SettingsMenuInventory.java +++ /dev/null @@ -1,96 +0,0 @@ -package me.xapu.trollgui.ui; - -import com.cryptomorin.xseries.XEnchantment; -import com.cryptomorin.xseries.XMaterial; -import com.cryptomorin.xseries.XSound; -import me.xapu.trollgui.main.Core; -import net.md_5.bungee.api.ChatMessageType; -import net.md_5.bungee.api.chat.TextComponent; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.HumanEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryHolder; -import org.bukkit.inventory.ItemFlag; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import java.util.Arrays; - -public class SettingsMenuInventory implements Listener, InventoryHolder { - private final Inventory inv; - public String centerTitle(String title) { - StringBuilder result = new StringBuilder(); - int spaces = (27 - ChatColor.stripColor(title).length()); - - for (int i = 0; i < spaces; i++) { - result.append(" "); - } - - return result.append(title).toString(); - } - public SettingsMenuInventory() - { - Bukkit.getPluginManager().registerEvents(this, Core.instance); - inv = Bukkit.createInventory(this, 9, centerTitle(Core.instance.getP()+ Core.getPathCC("menu.settings"))); - initializeItems(); - } - - @Override - public Inventory getInventory() - { - return inv; - } - - // You can call this whenever you want to put the items in - public void initializeItems() - { - ItemStack plc = new ItemStack(XMaterial.BLACK_STAINED_GLASS_PANE.parseMaterial(), 1); - ItemMeta meta2 = plc.getItemMeta(); - meta2.setDisplayName(" "); - plc.setItemMeta(meta2); - for(Integer i = 0; i < inv.getSize(); i++){ - inv.setItem(i, plc); - } - ItemStack restart = new ItemStack(XMaterial.REDSTONE.parseMaterial(), 1); - ItemMeta meta = restart.getItemMeta(); - meta.setDisplayName(Core.getPathCC("items.restart-name")); - meta.setLore(Arrays.asList(Core.tcc(Core.getPathCC("items.restart-lore")))); - meta.addEnchant(XEnchantment.DAMAGE_ALL.parseEnchantment(), 1, true); - meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); - restart.setItemMeta(meta); - - inv.setItem(4,restart); - - } - - // You can open the inventory with this - public void openInventory(final HumanEntity ent) - { - ent.openInventory(inv); - } - - // Check for clicks on items - @EventHandler - public void onInventoryClick(final InventoryClickEvent e) - { - if (e.getInventory().getHolder() != this) return; - e.setCancelled(true); - - final ItemStack clickedItem = e.getCurrentItem(); - - // verify current item is not null - if (clickedItem == null || clickedItem.getType() == XMaterial.AIR.parseMaterial()) return; - - final Player p = (Player) e.getWhoClicked(); - if(e.getRawSlot() == 4){ - Core.instance.reloadConfig(); - p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(Core.instance.getP()+ Core.getPathCC("menu.messages.restart"))); - p.playSound(p.getLocation(), XSound.ENTITY_PLAYER_LEVELUP.parseSound(), 2f, 2f); - } - } -} diff --git a/src/main/java/me/xapu/trollgui/ui/TrollInventory.java b/src/main/java/me/xapu/trollgui/ui/TrollInventory.java deleted file mode 100644 index 97eadbb..0000000 --- a/src/main/java/me/xapu/trollgui/ui/TrollInventory.java +++ /dev/null @@ -1,467 +0,0 @@ -package me.xapu.trollgui.ui; - -import com.cryptomorin.xseries.XEnchantment; -import com.cryptomorin.xseries.XMaterial; -import com.cryptomorin.xseries.XSound; -import org.bukkit.*; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.HumanEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; - -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.inventory.*; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.util.Vector; -import me.xapu.trollgui.main.Core; - -import java.util.*; - -import static me.xapu.trollgui.main.Core.sendGameStateChange; - -public class TrollInventory implements Listener, InventoryHolder { - HashMap launchedPlayers = new HashMap(); - HashMap clearedFPlayers = new HashMap(); - //HashMaps for Toggabels - private final Inventory inv; - static TrollInventory main; - Player VictimPlayer; - public String getNOU(Player p){ - return Core.uid()?p.getName():p.getUniqueId().toString(); - } - public String centerTitle(String title) { - StringBuilder result = new StringBuilder(); - int spaces = (27 - ChatColor.stripColor(title).length()); - - for (int i = 0; i < spaces; i++) { - result.append(" "); - } - - return result.append(title).toString(); - } - public TrollInventory(Player vic) { - - VictimPlayer = vic; - main = this; - Bukkit.getPluginManager().registerEvents(this, Core.instance); - // Create a new inventory, with "this" owner for comparison with other inventories, a size of nine, called example - inv = Bukkit.createInventory(this, 45, centerTitle(Core.getPathCC("menu.menu-title"))); - // Put the items into the inventory - initializeItems(); - - } - //To use method beyond this codeA - public static TrollInventory getGUI() { - return main; - } - public static HashMap getMaps(String maps) { - switch (maps) { - case "LP": - return TrollInventory.getGUI().launchedPlayers; - case "cFP": - return TrollInventory.getGUI().clearedFPlayers; - case "TM": - return Core.instance.AntiBuildPlayers; - case "TP": - return Core.instance.AntiPlacePlayers; - case "FR": - return Core.instance.FreezePlayers; - case "reverseMsg": - return Core.instance.reverseChatMessages; - } - // FrZLayers... creative. - return null; - } - @Override - public Inventory getInventory() { - return inv; - } - - // You can call this whenever you want to put the items in - - ItemStack mainPage = createGuiItem(XMaterial.REDSTONE_BLOCK, true, Core.getPathCC("items.Playerselector-name"), Core.getPathCC("items.Playerselector-lore")); - public void initializeItems() { - ItemStack ToggableAB = createGuiItem(XMaterial.GRASS_BLOCK,false, Core.tcc(Core.instance.getConfig().getString("items.nobuild-name")), Core.tcc(Core.instance.getConfig().getString("items.nobuild-lore")), !Core.instance.AntiBuildPlayers.containsKey(getNOU(VictimPlayer))? Core.getPathCC("items.messages.disabled"): Core.getPathCC("items.messages.enabled")); - ItemStack ToggableAP = createGuiItem(XMaterial.STONE,false, Core.tcc(Core.instance.getConfig().getString("items.noplace-name")), Core.tcc(Core.instance.getConfig().getString("items.noplace-lore")), !Core.instance.AntiPlacePlayers.containsKey(getNOU(VictimPlayer))? Core.getPathCC("items.messages.disabled"): Core.getPathCC("items.messages.enabled")); - ItemStack ToggableFR = createGuiItem(XMaterial.SNOWBALL,false, Core.tcc(Core.instance.getConfig().getString("items.freezeplayer-name")), Core.tcc(Core.instance.getConfig().getString("items.freezeplayer-lore")), !Core.instance.FreezePlayers.containsKey(getNOU(VictimPlayer))? Core.getPathCC("items.messages.disabled"): Core.getPathCC("items.messages.enabled")); - ItemStack ToggableRM = createGuiItem(XMaterial.BARRIER,false, Core.tcc(Core.instance.getConfig().getString("items.reversemessage-name")), Core.tcc(Core.instance.getConfig().getString("items.reversemessage-lore")), !Core.instance.reverseChatMessages.containsKey(getNOU(VictimPlayer))? Core.getPathCC("items.messages.disabled"): Core.getPathCC("items.messages.enabled")); - if(Core.instance.FreezePlayers.containsKey(getNOU(VictimPlayer))){ - ItemMeta meta = ToggableFR.getItemMeta(); - if(meta.hasEnchants()){ - meta.removeEnchant(XEnchantment.DURABILITY.parseEnchantment()); - } else{ - meta.addEnchant(XEnchantment.DURABILITY.parseEnchantment(), 1, true); - meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); - } - ToggableFR.setItemMeta(meta); - } - if(Core.instance.AntiPlacePlayers.containsKey(getNOU(VictimPlayer))){ - ItemMeta meta = ToggableAP.getItemMeta(); - if(meta.hasEnchants()){ - meta.removeEnchant(XEnchantment.DURABILITY.parseEnchantment()); - } else{ - meta.addEnchant(XEnchantment.DURABILITY.parseEnchantment(), 1, true); - meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); - } - ToggableAP.setItemMeta(meta); - } - if(Core.instance.AntiBuildPlayers.containsKey(getNOU(VictimPlayer))){ - ItemMeta meta = ToggableAB.getItemMeta(); - if(meta.hasEnchants()){ - meta.removeEnchant(XEnchantment.DURABILITY.parseEnchantment()); - } else{ - meta.addEnchant(XEnchantment.DURABILITY.parseEnchantment(), 1, true); - meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); - } - ToggableAB.setItemMeta(meta); - } - if(Core.instance.reverseChatMessages.containsKey(getNOU(VictimPlayer))){ - ItemMeta meta = ToggableRM.getItemMeta(); - if(meta.hasEnchants()){ - meta.removeEnchant(XEnchantment.DURABILITY.parseEnchantment()); - } else{ - meta.addEnchant(XEnchantment.DURABILITY.parseEnchantment(), 1, true); - meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); - } - ToggableRM.setItemMeta(meta); - } - ItemStack plc = new ItemStack(XMaterial.BLACK_STAINED_GLASS_PANE.parseMaterial(), 1); - ItemMeta meta = plc.getItemMeta(); - meta.setDisplayName(" "); - plc.setItemMeta(meta); - for(Integer i = 0; i < 45; i++){ - inv.setItem(i, plc); - } - inv.setItem(10,createGuiItem(XMaterial.GOLDEN_BOOTS, false, Core.tcc(Core.instance.getConfig().getString("items.launch-name")), Core.tcc(Core.instance.getConfig().getString("items.launch-lore")))); - inv.setItem(11,createGuiItem(XMaterial.PUMPKIN, false, Core.tcc(Core.instance.getConfig().getString("items.scare-name")), Core.tcc(Core.instance.getConfig().getString("items.scare-lore")))); - inv.setItem(12,createGuiItem(XMaterial.REDSTONE_BLOCK, false, Core.tcc(Core.instance.getConfig().getString("items.randomlook-name")), Core.tcc(Core.instance.getConfig().getString("items.randomlook-lore")))); - inv.setItem(13,createGuiItem(XMaterial.PUFFERFISH, false, Core.tcc(Core.instance.getConfig().getString("items.fakeclear-name")), Core.tcc(Core.instance.getConfig().getString("items.fakeclear-lore").replace("%TIME%", Core.instance.getConfig().getString("values.fake-clear.fake-clear-delay"))))); - inv.setItem(14,createGuiItem(XMaterial.IRON_BARS, false, Core.tcc(Core.instance.getConfig().getString("items.demo-name")), Core.tcc(Core.instance.getConfig().getString("items.demo-lore")))); - inv.setItem(15,createGuiItem(XMaterial.TRIDENT, false, Core.tcc(Core.instance.getConfig().getString("items.thunder-name")), Core.tcc(Core.instance.getConfig().getString("items.thunder-lore")))); - inv.setItem(16,createGuiItem(XMaterial.FIRE_CHARGE, false, Core.tcc(Core.instance.getConfig().getString("items.burn-name")), Core.tcc(Core.instance.getConfig().getString("items.burn-lore")))); - inv.setItem(19,createGuiItem(XMaterial.TNT, false, Core.tcc(Core.instance.getConfig().getString("items.explode-name")), Core.tcc(Core.instance.getConfig().getString("items.explode-lore")))); - inv.setItem(20,createGuiItem(XMaterial.DIAMOND, false, Core.tcc(Core.instance.getConfig().getString("items.fakeoperator-name")), Core.tcc(Core.instance.getConfig().getString("items.fakeoperator-lore")))); - inv.setItem(21,createGuiItem(XMaterial.STONE_PRESSURE_PLATE, false, Core.tcc(Core.instance.getConfig().getString("items.dropitem-name")), Core.tcc(Core.instance.getConfig().getString("items.dropitem-lore")))); - inv.setItem(22,createGuiItem(XMaterial.HEAVY_WEIGHTED_PRESSURE_PLATE, false, Core.tcc(Core.instance.getConfig().getString("items.dropall-name")), Core.tcc(Core.instance.getConfig().getString("items.dropall-lore")))); - inv.setItem(23,createGuiItem(XMaterial.CHEST, false, Core.tcc(Core.instance.getConfig().getString("items.invsee-name")), Core.tcc(Core.instance.getConfig().getString("items.invsee-lore")))); - inv.setItem(24,createGuiItem(XMaterial.BARRIER,false, Core.tcc(Core.instance.getConfig().getString("items.closegui-name")), Core.tcc(Core.instance.getConfig().getString("items.closegui-lore")))); - try { - inv.setItem(25,createGuiItem(XMaterial.valueOf(Core.instance.config.getString("values.fakeBlocks.material")),false, Core.tcc(Core.instance.getConfig().getString("items.fakeblock-name")), Core.tcc(Core.instance.getConfig().getString("items.fakeblock-lore")))); - } catch (Exception e){ - Core.instance.config.set("values.fakeBlocks.material", "TNT"); - } - inv.setItem(30, ToggableAB); - inv.setItem(31, ToggableAP); - inv.setItem(32, ToggableFR); - inv.setItem(33, ToggableRM); - inv.setItem(44, mainPage); - } - - int task = 0; - Random rand = new Random(); - //Idk, I feel kinda clunky about this - public void RndLook(Player vic){ - Location loc = vic.getLocation(); - float retoreYaw = loc.getYaw(); - float restorePitch = loc.getPitch(); - new BukkitRunnable(){ - private int i = 0; - public void run() { - if(i >= Core.instance.getConfig().getInt("values.random-look.random-look-time") * 20) { - loc.setPitch(restorePitch); - loc.setYaw(retoreYaw); - vic.teleport(loc); - cancel(); - } - ++i; - loc.setYaw(rand.nextInt(360)); - loc.setPitch(rand.nextInt(180)); - vic.teleport(loc); - } - }.runTaskTimer(Core.instance, 5L, 1L); - } - public void InvSee(Player vic, Player sender){ - Inventory vici = vic.getInventory(); - sender.openInventory(vici); - } - //Tried randomizing the inventory then in the next morning i said Frick it, im gonna do a Fake Clear (Was easy!) - public void fakeclear(Player vic){ - if(vic != null && vic instanceof Player){ - if(!clearedFPlayers.containsKey(vic.getUniqueId().toString())) { - ItemStack[] i3 = vic.getInventory().getContents(); - vic.getInventory().clear(); - clearedFPlayers.put(vic.getUniqueId().toString(), "1"); - int seconds = 10; - - Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Core.instance, new Runnable() { - public void run() { - vic.getInventory().setContents(i3); - clearedFPlayers.remove(vic.getUniqueId().toString()); - } - }, (seconds * 20)); // Always multiply by twenty because that's the amount of ticks in Minecraft - } - } - } - public void closeInv(Player vic){ - vic.closeInventory(); - } - //Would be easier with vic.getWorld().createExplosion() Though? - public void ExplodePlayer(Player vic){ - if(vic != null && vic instanceof Player){ - World toX = vic.getWorld(); - if(Core.instance.getConfig().getBoolean("values.explode-item.EnableExplodeRandomness")){ - toX.createExplosion(vic.getLocation(),rand.nextInt(Core.instance.getConfig().getInt("values.explode-item.explode-radius") +1 ), false); - } else { - toX.createExplosion(vic.getLocation(), Core.instance.getConfig().getInt("values.explode-item.explode-radius") + 1, false); - } - - } - } - //Searched - public void burnPlayer(Player vic){ - if(vic != null && vic instanceof Player){ - int ticks = Core.instance.getConfig().getInt("values.burn-item.burn-time") * 20; - vic.setFireTicks(ticks); - } - } - - protected ItemStack createGuiItem(final XMaterial XMaterial, final Boolean isEnchanted , final String name, final String... lore) { - final ItemStack item = new ItemStack(XMaterial.parseMaterial(), 1); - final ItemMeta meta = item.getItemMeta(); - - // Set the name of the item - meta.setDisplayName(name); - if(isEnchanted){ - meta.addEnchant(XEnchantment.DURABILITY.parseEnchantment(), 1, true); - meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); - } - // Set the lore of the item - meta.setLore(Arrays.asList(lore)); - - item.setItemMeta(meta); - - return item; - } - - - public void fakeBlock(Material mat, Player vic){ // Ty Garkolym (https://www.youtube.com/channel/UCukS5iWNa60iBC60MCdETBw) for the idea! - int rad = Core.instance.config.getInt("values.fakeBlocks.radius"); - String v = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3]; - int subVersion = Integer.parseInt(v.replace("1_", "").replaceAll("_R\\d", "").replace("v", "")); - try{ - for(double x = vic.getLocation().getX() - rad; x <= vic.getLocation().getX() + rad; x++){ - for(double y = vic.getLocation().getY() - rad; y <= vic.getLocation().getY() + rad; y++){ - for(double z = vic.getLocation().getZ() - rad; z <= vic.getLocation().getZ() + rad; z++){ - Location l = new Location(vic.getWorld(), x,y,z); - if(l.getBlock().getType() != Material.AIR){ - if(subVersion >= 13){ - vic.sendBlockChange(l, mat.createBlockData()); - } else { - vic.sendBlockChange(l, mat, (byte) 0); - } - } - } - } - - } - - }catch (Exception ignored){ - - } - } - - //First feature. still, kinda proud - public void launchPlayer(final Player p) { - p.setVelocity(new Vector(0f, 5f, 0f)); - if(!launchedPlayers.containsKey(getNOU(p))) launchedPlayers.put(getNOU(p), "true"); - p.playSound(p.getLocation(), XSound.ENTITY_FIREWORK_ROCKET_LARGE_BLAST.parseSound(), 3f, 1f); - p.spawnParticle(Particle.EXPLOSION_HUGE, p.getLocation(), 1, 0.11, 1, 1, 1); - } - - // You can open the inventory with this - public void openInventory(final HumanEntity ent) { - ent.openInventory(inv); - } - - public void demoTroll(Player p){ - sendGameStateChange(p, 5, 0); - } - //Easy - public void fakeOP(Player vic){ - vic.sendMessage(Core.tcc("&7&o[Server: Made "+vic.getName()+" a Server operator")); - } - //Needed to search - public void dropItem( Player vic, Player sender){ - if(vic.getInventory().getItemInMainHand() == null || vic.getInventory().getItemInMainHand().getType() == XMaterial.AIR.parseMaterial()){ - sender.sendMessage(Core.instance.getP()+ Core.tcc(Core.instance.getConfig().getString("menu.messages.no-item-in-hand").replace("%player%", vic.getName()))); - return; - }else { - ItemStack hand = vic.getInventory().getItemInMainHand(); - vic.getInventory().clear(vic.getInventory().getHeldItemSlot()); // .remove removed ALL items of the same TYPE - vic.getWorld().dropItemNaturally(vic.getLocation(), hand).setPickupDelay(20); - sender.sendMessage(hand.getItemMeta().getDisplayName()); - sender.sendMessage(hand.getItemMeta().getLocalizedName()); - sender.sendMessage(Core.instance.getPrefixedMessage("menu.messages.items-dropped-single").replace("%ITEM_NAME%", hand.getItemMeta().getDisplayName()).replace("%ITEM_AMOUNT%", String.valueOf(hand.getAmount())).replace("%PLAYER%", vic.getDisplayName())); // Prefixed? - } - } - //Thanks "Lubdan" - https://www.spigotmc.org/threads/drop-a-players-inventory.358762/ - public void setAntiBuild(Player vic){ - if (Core.instance.AntiBuildPlayers.containsKey(getNOU(vic))) { - Core.instance.AntiBuildPlayers.remove(getNOU(vic)); - } else { - Core.instance.AntiBuildPlayers.put(getNOU(vic), "1"); - } - initializeItems(); - } - public void setAntiPlace(Player vic){ - if (Core.instance.AntiPlacePlayers.containsKey(getNOU(vic))) { - Core.instance.AntiPlacePlayers.remove(getNOU(vic)); - } else { - Core.instance.AntiPlacePlayers.put(getNOU(vic), "1"); - } - initializeItems(); - } - public void setFreezePlayer(Player vic){ - if (Core.instance.FreezePlayers.containsKey(getNOU(vic))) { - Core.instance.FreezePlayers.remove(getNOU(vic)); - } else { - Core.instance.FreezePlayers.put(getNOU(vic), "1"); - } - initializeItems(); - } - public void setReverseMsg(Player vic){ - if (Core.instance.reverseChatMessages.containsKey(getNOU(vic))) { - Core.instance.reverseChatMessages.remove(getNOU(vic)); - } else { - Core.instance.reverseChatMessages.put(getNOU(vic), "1"); - } - initializeItems(); - } - public void dropAllItems( Player vic, Player sender){ - Inventory inv = vic.getInventory(); - for(int i = 0; i <= 36; i++){ - try { - vic.getWorld().dropItem(vic.getLocation(), inv.getItem(i)).setPickupDelay(40); - } - catch(Exception a){ - } - try { - switch (i) { - case 0: - break; - case 1: - vic.getWorld().dropItem(vic.getLocation(), ((PlayerInventory) inv).getChestplate()).setPickupDelay(40); - break; - case 2: - vic.getWorld().dropItem(vic.getLocation(), ((PlayerInventory) inv).getLeggings()).setPickupDelay(40); - break; - case 3: - vic.getWorld().dropItem(vic.getLocation(), ((PlayerInventory) inv).getHelmet()).setPickupDelay(40); - break; - } - } - catch(Exception d) { - } - } - vic.getInventory().clear(); - } - //Easy - public void thorPlayer(Player p){ - Location lb = p.getLocation().getBlock().getLocation(); - World w = lb.getWorld(); - if(w != null) - w.spawnEntity(lb, EntityType.LIGHTNING); - } - //Ha, v = Volume, v1 = Pitch - public void scare(Player p){ - p.spawnParticle(Particle.MOB_APPEARANCE, p.getLocation(), 1); - p.playSound(p.getLocation(), XSound.ENTITY_ELDER_GUARDIAN_CURSE.parseSound(), 100, 1); - p.playSound(p.getLocation(), XSound.ENTITY_ELDER_GUARDIAN_AMBIENT.parseSound(), 100, 1); - p.playSound(p.getLocation(), XSound.ENTITY_ELDER_GUARDIAN_AMBIENT_LAND.parseSound(), 100, 1); - p.playSound(p.getLocation(), XSound.ENTITY_ELDER_GUARDIAN_DEATH.parseSound(), 100, 1); - p.playSound(p.getLocation(), XSound.ENTITY_ELDER_GUARDIAN_DEATH_LAND.parseSound(), 100, 1); - p.playSound(p.getLocation(), XSound.ENTITY_ELDER_GUARDIAN_FLOP.parseSound(), 100, 1); - p.playSound(p.getLocation(), XSound.ENTITY_ELDER_GUARDIAN_HURT.parseSound(), 100, 1); - p.playSound(p.getLocation(), XSound.ENTITY_ELDER_GUARDIAN_HURT_LAND.parseSound(), 100, 1); - } - // Check for clicks on items - @EventHandler - public void onInventoryClick(final InventoryClickEvent e) { - if (e.getInventory().getHolder() != this) return; - e.setCancelled(true); - - final ItemStack clickedItem = e.getCurrentItem(); - - // verify current item is not null - if (clickedItem == null || clickedItem.getType() == XMaterial.AIR.parseMaterial()) return; - - final Player p = (Player) e.getWhoClicked(); - if(VictimPlayer != null){ - if(e.getSlot() < 45){ - switch(e.getRawSlot()){ - case 10: - launchPlayer(VictimPlayer); - break; - case 11: - scare(VictimPlayer); - break; - case 12: - RndLook(VictimPlayer); - break; - case 13: - fakeclear(VictimPlayer); // Changed - break; - case 14: - demoTroll(VictimPlayer); - break; - case 15: - thorPlayer(VictimPlayer); - break; - case 16: - burnPlayer(VictimPlayer); - break; - case 19: - ExplodePlayer(VictimPlayer); - break; - case 20: - fakeOP(VictimPlayer); - break; - case 21: - dropItem(VictimPlayer, p); - break; - case 22: - dropAllItems(VictimPlayer, p); - break; - case 23: - InvSee(VictimPlayer, p); - break; - case 24: - closeInv(VictimPlayer); - break; - case 25: - fakeBlock(XMaterial.valueOf(Core.instance.config.getString("values.fakeBlocks.material")).parseMaterial(), p); - break; - case 30: - setAntiBuild(VictimPlayer); - break; - case 31: - setAntiPlace(VictimPlayer); - break; - case 32: - setFreezePlayer(VictimPlayer); - break; - case 33: - setReverseMsg(VictimPlayer); - break; - case 44: - PlayerSelectorInventory ps = new PlayerSelectorInventory(); - ps.openSel(p); - break; - } - } - } - } -} - diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Commands/TrollCommand.java b/src/main/java/me/xapu1337/recodes/trollgui/Commands/TrollCommand.java index d6c78ec..e4d840f 100644 --- a/src/main/java/me/xapu1337/recodes/trollgui/Commands/TrollCommand.java +++ b/src/main/java/me/xapu1337/recodes/trollgui/Commands/TrollCommand.java @@ -4,6 +4,8 @@ import me.xapu1337.recodes.trollgui.Handlers.CommandHandler; import me.xapu1337.recodes.trollgui.Inventorys.PlayerSelector; import me.xapu1337.recodes.trollgui.Inventorys.Settings; +import me.xapu1337.recodes.trollgui.Utilities.UpdateChecker; +import org.apache.commons.lang.ArrayUtils; import org.bukkit.command.Command; import org.bukkit.command.CommandMap; import org.bukkit.command.CommandSender; @@ -44,9 +46,9 @@ public TrollCommand(CommandMap commandMap, JavaPlugin plugin) { addPermission("ms3.use"); addPermissionMessage(Objects.requireNonNull(Core.instance.utils.getConfigPath("Messages.missingPermissions", true))); registerCommand(commandMap); - addListTabbComplete(0, "settings", "giveskull", "credits", "update", "contact", "config"); - addListTabbComplete(1, convert((keys))); - addListTabbComplete(2, "%SPACE_SEPARATOR%", "%EMPTY_CHAR%"); + addListTabbComplete(0, "settings", "update", "contact"); +// addListTabbComplete(1, convert((keys))); +// addListTabbComplete(2, "%SPACE_SEPARATOR%", "%EMPTY_CHAR%"); } @Override @@ -57,20 +59,27 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command case "settings": p.openInventory(new Settings().getInventory()); break; - case "giveskull": - - break; - case "credits": - - break; case "update": - + p.sendMessage(Core.instance.utils.getConfigPath("Variables.prefix") + "§bChecking updates..."); + new UpdateChecker(Core.instance, 78194).getVersion(version -> { + p.sendMessage(Float.parseFloat(Core.instance.getDescription().getVersion()) >= Float.parseFloat(version) ? Core.instance.utils.getConfigPath("Variables.prefix") + + "§7Latest version: §a§l"+version+"§7, Current version: §a§l"+ Core.instance.getDescription().getVersion() : Core.instance.utils.getConfigPath("Variables.prefix") + + "§7An update is §aAVAILABLE §7For the version: §a§l" + version + "§7, Your version: §c§l" + Core.instance.getDescription().getVersion() + + "§7. §7Update it from here: https://www.spigotmc.org/resources/troll-plugin-gui-anything-is-configurable.78194/"); + }); break; case "contact": - - break; - case "config": - + p.sendMessage(Core.instance.utils.getConfigPath("Variables.prefix")+"§7§m-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"); + p.sendMessage(Core.instance.utils.getConfigPath("Variables.prefix")+"§7Got errors? Report them here: "); + p.sendMessage(Core.instance.utils.getConfigPath("Variables.prefix")+"§9Discord§7: Ram#1337"); + p.sendMessage(Core.instance.utils.getConfigPath("Variables.prefix")+"§6Spigot DM§7: https://www.spigotmc.org/members/xapu1337.955834/"); + p.sendMessage(Core.instance.utils.getConfigPath("Variables.prefix")+"§7Github Issue page§7: https://github.com/Xapu1337/TrollGUI/issues"); + p.sendMessage(Core.instance.utils.getConfigPath("Variables.prefix")+"§7§m-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"); + p.sendMessage(Core.instance.utils.getConfigPath("Variables.prefix")+"§7Love this plugin?"); + p.sendMessage(Core.instance.utils.getConfigPath("Variables.prefix")+"§7It would be §c§b§ibreathtaking!§7 if you were to support me ^^"); + p.sendMessage(Core.instance.utils.getConfigPath("Variables.prefix")+"§6Positive review on Spigot§7: https://www.spigotmc.org/resources/troll-plugin-gui-anything-is-configurable.78194/"); + p.sendMessage(Core.instance.utils.getConfigPath("Variables.prefix")+"§9Donate me some Coffee §c<3§7: https://paypal.me/xapu1338"); + p.sendMessage(Core.instance.utils.getConfigPath("Variables.prefix")+"§7§m-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"); break; default: p.openInventory(new PlayerSelector(p).getInventory()); diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Cores/Core.java b/src/main/java/me/xapu1337/recodes/trollgui/Cores/Core.java index 3eb5061..dd48e50 100644 --- a/src/main/java/me/xapu1337/recodes/trollgui/Cores/Core.java +++ b/src/main/java/me/xapu1337/recodes/trollgui/Cores/Core.java @@ -1,7 +1,10 @@ package me.xapu1337.recodes.trollgui.Cores; + import me.xapu1337.recodes.trollgui.Commands.TrollCommand; import me.xapu1337.recodes.trollgui.Listeners.EventListener; +import me.xapu1337.recodes.trollgui.Utilities.Singleton; +import me.xapu1337.recodes.trollgui.Utilities.UpdateChecker; import me.xapu1337.recodes.trollgui.Utilities.Util; import org.bukkit.Bukkit; import org.bukkit.command.CommandMap; @@ -11,12 +14,14 @@ import java.lang.reflect.Field; + public class Core extends JavaPlugin implements Listener { public FileConfiguration config = getConfig(); public static Core instance; - public Boolean usingUUID; + public boolean usingUUID; public Util utils = new Util(); + public Singleton singletons = new Singleton(); public Core() { if(instance == null) @@ -34,13 +39,19 @@ public void reloadConfig() { @Override public void onEnable() { + getLogger().warning("§bChecking updates..."); + new UpdateChecker(Core.instance, 78194).getVersion(version -> { + getLogger().warning(Float.parseFloat(Core.instance.getDescription().getVersion()) >= Float.parseFloat(version) ? + "§7Latest version: §a§l"+version+"§7, Current version: §a§l"+ Core.instance.getDescription().getVersion() : + "§7An update is §aAVAILABLE §7For the version: §a§l" + version + "§7, Your version: §c§l" + Core.instance.getDescription().getVersion() + + "§7. §7Update it from here: https://www.spigotmc.org/resources/troll-plugin-gui-anything-is-configurable.78194/"); + }); Bukkit.getServer().getPluginManager().registerEvents(this, this); Bukkit.getServer().getPluginManager().registerEvents(new EventListener(), this); super.onEnable(); reloadConfig(); - if (Integer.parseInt(Bukkit.getServer().getVersion().split("MC: ")[1].replaceAll("\\)", "").trim().split("\\.")[1]) < 7 || !Bukkit.getServer().getOnlineMode()) - usingUUID = false; + usingUUID = !(Integer.parseInt(Bukkit.getServer().getVersion().split("MC: ")[1].replaceAll("\\)", "").trim().split("\\.")[1]) < 7 || !Bukkit.getServer().getOnlineMode()); try { diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Handlers/TrollHandler.java b/src/main/java/me/xapu1337/recodes/trollgui/Handlers/TrollHandler.java index 8436784..74d7833 100644 --- a/src/main/java/me/xapu1337/recodes/trollgui/Handlers/TrollHandler.java +++ b/src/main/java/me/xapu1337/recodes/trollgui/Handlers/TrollHandler.java @@ -12,7 +12,7 @@ public TrollHandler(Player caller, Player victim) { } /** - * Executed from the TrollGUI Class everything inside this function gets executed. + * The method that gets executed on item click */ public abstract void execute(); diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Inventorys/PlayerSelector.java b/src/main/java/me/xapu1337/recodes/trollgui/Inventorys/PlayerSelector.java index 66677e4..cb578b6 100644 --- a/src/main/java/me/xapu1337/recodes/trollgui/Inventorys/PlayerSelector.java +++ b/src/main/java/me/xapu1337/recodes/trollgui/Inventorys/PlayerSelector.java @@ -2,6 +2,7 @@ import com.cryptomorin.xseries.XMaterial; import me.xapu1337.recodes.trollgui.Cores.Core; +import org.apache.commons.lang.ArrayUtils; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.NamespacedKey; @@ -14,14 +15,17 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.persistence.PersistentDataType; +import sun.jvm.hotspot.oops.Array; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.UUID; public class PlayerSelector implements Listener, InventoryHolder{ public Inventory GUI; public Player player; - int maxItemsPerPage = 1; + int maxItemsPerPage = 43; int page = 0; int index = 0; public String centerTitle(String title) { @@ -52,7 +56,6 @@ public void initializeItems(){ GUI.setItem(48, Core.instance.utils.createItem(XMaterial.OAK_BUTTON, false, Core.instance.utils.getConfigPath("MenuItems.playerSelector.left.name"), Core.instance.utils.getConfigPath("MenuItems.playerSelector.left.lore"))); GUI.setItem(49, Core.instance.utils.createItem(XMaterial.BARRIER, false, Core.instance.utils.getConfigPath("MenuItems.playerSelector.close.name"), Core.instance.utils.getConfigPath("MenuItems.playerSelector.close.lore"))); GUI.setItem(50, Core.instance.utils.createItem(XMaterial.OAK_BUTTON, false, Core.instance.utils.getConfigPath("MenuItems.playerSelector.right.name"), Core.instance.utils.getConfigPath("MenuItems.playerSelector.right.lore"))); -// InventoryTitleHelper.sendInventoryTitle(player, GUI, centerTitle(EnumCollection.MenuTitles.PLAYER_SELECTOR.get().replace("%CURRENT_PAGE", String.valueOf(index + 1)).replace("%MAX_PAGES%", String.valueOf(Math.round(Bukkit.getOnlinePlayers().size() / maxItemsPerPage))))); if(players != null && !players.isEmpty()) { for(int i = 0; i < maxItemsPerPage; i++) { @@ -64,8 +67,10 @@ public void initializeItems(){ playerMeta.setDisplayName(ChatColor.RED + players.get(index).getDisplayName()); playerMeta.setOwningPlayer(Bukkit.getPlayer(players.get(index).getUniqueId())); playerMeta.getPersistentDataContainer().set(new NamespacedKey(Core.instance, "uuid"), PersistentDataType.STRING, players.get(index).getUniqueId().toString()); - playerItem.setItemMeta(playerMeta); + if(players.get(index).isOp()) + playerMeta.setLore(Collections.singletonList(Core.instance.utils.getConfigPath("MenuItems.playerSelector.extras.hasOP"))); + playerItem.setItemMeta(playerMeta); GUI.addItem(playerItem); } @@ -90,7 +95,8 @@ public void onInventoryClicked(InventoryClickEvent event) { if (clickedItem.getType() == XMaterial.PLAYER_HEAD.parseMaterial()) { Player selectedPlayer = Bukkit.getPlayer(UUID.fromString(clickedItem.getItemMeta().getPersistentDataContainer().get(new NamespacedKey(Core.instance, "uuid"), PersistentDataType.STRING))); - player.openInventory(new TrollGUI(selectedPlayer).getInventory()); + if(selectedPlayer == null) { event.getWhoClicked().sendMessage(Core.instance.utils.getConfigPath("Messages.playerNotAvaliable", true)); return; } + player.openInventory(new TrollGUI((Player) event.getWhoClicked(), selectedPlayer).getInventory()); } else if (clickedItem.getType() == XMaterial.BARRIER.parseMaterial()) { player.closeInventory(); } else if (clickedItem.getType().equals(XMaterial.OAK_BUTTON.parseMaterial())) { diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Inventorys/Settings.java b/src/main/java/me/xapu1337/recodes/trollgui/Inventorys/Settings.java index c32126f..3ccc645 100644 --- a/src/main/java/me/xapu1337/recodes/trollgui/Inventorys/Settings.java +++ b/src/main/java/me/xapu1337/recodes/trollgui/Inventorys/Settings.java @@ -15,6 +15,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; public class Settings implements Listener, InventoryHolder { public Inventory GUI; @@ -41,7 +42,7 @@ public void initializeItems(){ } @Override - public Inventory getInventory() { return GUI; } + public @NotNull Inventory getInventory() { return GUI; } @EventHandler public void onInventoryClicked(InventoryClickEvent event) { diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Inventorys/TrollGUI.java b/src/main/java/me/xapu1337/recodes/trollgui/Inventorys/TrollGUI.java index 37ac4a5..5f7326c 100644 --- a/src/main/java/me/xapu1337/recodes/trollgui/Inventorys/TrollGUI.java +++ b/src/main/java/me/xapu1337/recodes/trollgui/Inventorys/TrollGUI.java @@ -15,7 +15,8 @@ import org.jetbrains.annotations.NotNull; public class TrollGUI implements Listener, InventoryHolder { - private Player player; + private final Player caller; + private final Player victim; public Inventory GUI; public String centerTitle(String title) { StringBuilder result = new StringBuilder(); @@ -27,10 +28,16 @@ public String centerTitle(String title) { return result.append(title).toString(); } - public TrollGUI(Player player) { - this.player = player; + public TrollGUI(Player caller, Player victim) { + this.victim = victim; + this.caller = caller; Bukkit.getPluginManager().registerEvents(this, Core.instance); - GUI = Bukkit.createInventory(this, 54, centerTitle(Core.instance.utils.getConfigPath("MenuTitles.trollGUI").replace("%PLAYER%", player.getName()))); + GUI = Bukkit.createInventory(this, 54, centerTitle( + Core.instance.utils.getConfigPath("MenuTitles.trollGUI") + .replace("%VICTIM%", victim.getName()) + .replace("%PLAYER%", caller.getName()) + ) + ); initializeItems(); } @@ -68,6 +75,84 @@ public void initializeItems(){ GUI.setItem(15, Core.instance.utils.createItem(customMatForFakeBlock, false, Core.instance.utils.getConfigPath("MenuItems.trollMenu.fakeBlock.name"), Core.instance.utils.getConfigPath("MenuItems.trollMenu.fakeBlock.lore"))); + + GUI.setItem(16, Core.instance.utils.createItem(XMaterial.PUFFERFISH, false, + Core.instance.utils.getConfigPath("MenuItems.trollMenu.fakeClear.name"), + Core.instance.utils.getConfigPath("MenuItems.trollMenu.fakeClear.lore").replace("%TIME%", String.valueOf(Core.instance.config.getInt("MenuItems.trollMenu.fakeClear.options.fakeClearDelay"))))); + + GUI.setItem(19, Core.instance.utils.createItem(XMaterial.LIGHT_GRAY_DYE, false, + Core.instance.utils.getConfigPath("MenuItems.trollMenu.fakeOperator.name"), + Core.instance.utils.getConfigPath("MenuItems.trollMenu.fakeOperator.lore"))); + + GUI.setItem(20, Core.instance.utils.createItem(XMaterial.SNOWBALL, Core.instance.singletons.frozenPlayers.containsKey(Core.instance.utils.uuidOrName(victim, Core.instance.usingUUID)), + Core.instance.utils.getConfigPath("MenuItems.trollMenu.freezePlayer.name"), + Core.instance.utils.getConfigPath("MenuItems.trollMenu.freezePlayer.lore"), + Core.instance.singletons.frozenPlayers.containsKey(Core.instance.utils.uuidOrName(victim, Core.instance.usingUUID)) + ? + Core.instance.utils.getConfigPath("MenuItems.trollMenu.extras.isEnabled") + : + Core.instance.utils.getConfigPath("MenuItems.trollMenu.extras.isDisabled") + )); + + GUI.setItem(21, Core.instance.utils.createItem(XMaterial.TRAPPED_CHEST, false, + Core.instance.utils.getConfigPath("MenuItems.trollMenu.invSee.name"), + Core.instance.utils.getConfigPath("MenuItems.trollMenu.invSee.lore"))); + + GUI.setItem(22, Core.instance.utils.createItem(XMaterial.ENDER_CHEST, false, + Core.instance.utils.getConfigPath("MenuItems.trollMenu.invShare.name"), + Core.instance.utils.getConfigPath("MenuItems.trollMenu.invShare.lore"))); + + GUI.setItem(23, Core.instance.utils.createItem(XMaterial.FIREWORK_ROCKET, false, + Core.instance.utils.getConfigPath("MenuItems.trollMenu.launchPlayer.name"), + Core.instance.utils.getConfigPath("MenuItems.trollMenu.launchPlayer.lore"))); + + GUI.setItem(24, Core.instance.utils.createItem(XMaterial.GRASS_BLOCK, Core.instance.singletons.noBuildPlayers.containsKey(Core.instance.utils.uuidOrName(victim, Core.instance.usingUUID)), + Core.instance.utils.getConfigPath("MenuItems.trollMenu.noBuild.name"), + Core.instance.utils.getConfigPath("MenuItems.trollMenu.noBuild.lore"), + Core.instance.singletons.noBuildPlayers.containsKey(Core.instance.utils.uuidOrName(victim, Core.instance.usingUUID)) + ? + Core.instance.utils.getConfigPath("MenuItems.trollMenu.extras.isEnabled") + : + Core.instance.utils.getConfigPath("MenuItems.trollMenu.extras.isDisabled") + )); + + GUI.setItem(25, Core.instance.utils.createItem(XMaterial.STONE, Core.instance.singletons.noBreakPlayers.containsKey(Core.instance.utils.uuidOrName(victim, Core.instance.usingUUID)), + Core.instance.utils.getConfigPath("MenuItems.trollMenu.noBreak.name"), + Core.instance.utils.getConfigPath("MenuItems.trollMenu.noBreak.lore"), + Core.instance.singletons.noBreakPlayers.containsKey(Core.instance.utils.uuidOrName(victim, Core.instance.usingUUID)) + ? + Core.instance.utils.getConfigPath("MenuItems.trollMenu.extras.isEnabled") + : + Core.instance.utils.getConfigPath("MenuItems.trollMenu.extras.isDisabled") + )); + + GUI.setItem(29, Core.instance.utils.createItem(XMaterial.BARRIER, false, + Core.instance.utils.getConfigPath("MenuItems.trollMenu.randomLook.name"), + Core.instance.utils.getConfigPath("MenuItems.trollMenu.randomLook.lore"))); + + GUI.setItem(30, Core.instance.utils.createItem(XMaterial.PAPER, Core.instance.singletons.reverseMessagePlayers.containsKey(Core.instance.utils.uuidOrName(victim, Core.instance.usingUUID)), + Core.instance.utils.getConfigPath("MenuItems.trollMenu.reverseMessage.name"), + Core.instance.utils.getConfigPath("MenuItems.trollMenu.reverseMessage.lore"), + Core.instance.singletons.reverseMessagePlayers.containsKey(Core.instance.utils.uuidOrName(victim, Core.instance.usingUUID)) + ? + Core.instance.utils.getConfigPath("MenuItems.trollMenu.extras.isEnabled") + : + Core.instance.utils.getConfigPath("MenuItems.trollMenu.extras.isDisabled") + )); + + GUI.setItem(31, Core.instance.utils.createItem(XMaterial.CARVED_PUMPKIN, false, + Core.instance.utils.getConfigPath("MenuItems.trollMenu.scarePlayer.name"), + Core.instance.utils.getConfigPath("MenuItems.trollMenu.scarePlayer.lore"))); + + GUI.setItem(32, Core.instance.utils.createItem(XMaterial.PRISMARINE_SHARD, true, + Core.instance.utils.getConfigPath("MenuItems.trollMenu.thunder.name"), + Core.instance.utils.getConfigPath("MenuItems.trollMenu.thunder.lore"))); + + + GUI.setItem(53, Core.instance.utils.createItem(XMaterial.BARRIER, true, + Core.instance.utils.getConfigPath("MenuItems.trollMenu.returnToPlayerSelector.name"), + Core.instance.utils.getConfigPath("MenuItems.trollMenu.returnToPlayerSelector.lore"))); + } @Override @@ -81,28 +166,79 @@ public void onInventoryClicked(InventoryClickEvent event) { event.setCancelled(true); // Disable the item to be draggable. final ItemStack clickedItem = event.getCurrentItem(); - Player caller = (Player) event.getWhoClicked(); if (clickedItem == null || clickedItem.getType() == XMaterial.AIR.parseMaterial()) return; switch (event.getRawSlot()){ case 10: - new BurnPlayerTroll(caller, player).execute(); + new BurnPlayerTroll(caller, victim).execute(); break; case 11: - new CloseGUITroll(caller, player).execute(); + new CloseGUITroll(caller, victim).execute(); break; case 12: - new DropAllTroll(caller, player).execute(); + new DropAllTroll(caller, victim).execute(); break; case 13: - new DropItemTroll(caller, player).execute(); + new DropItemTroll(caller, victim).execute(); break; case 14: - new ExplodePlayerTroll(caller, player).execute(); + new ExplodePlayerTroll(caller, victim).execute(); break; case 15: - new FakeBlockTroll(caller, player).execute(); + new FakeBlockTroll(caller, victim).execute(); + break; + case 16: + new FakeClearTroll(caller, victim).execute(); + break; + case 19: + new FakeOperatorTroll(caller, victim).execute(); + break; + case 20: + new FreezeTroll(caller, victim).execute(); + GUI.clear(); + initializeItems(); + break; + case 21: + new InvSeeTroll(caller, victim).execute(); + break; + case 22: + new InvShareTroll(caller, victim).execute(); + break; + case 23: + new LaunchPlayerTroll(caller, victim).execute(); + break; + case 24: + new NoBuildTroll(caller, victim).execute(); + GUI.clear(); + initializeItems(); + break; + case 25: + new NoBreakTroll(caller, victim).execute(); + GUI.clear(); + initializeItems(); + break; + case 29: + new RandomLookTroll(caller, victim).execute(); + break; + case 30: + new ReverseMessageTroll(caller, victim).execute(); + GUI.clear(); + initializeItems(); + break; + case 31: + new ScareTroll(caller, victim).execute(); + break; + case 32: + new ThunderPlayerTroll(caller, victim).execute(); + break; + + + + + + case 53: + caller.openInventory(new PlayerSelector(caller).getInventory()); break; } diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Listeners/EventListener.java b/src/main/java/me/xapu1337/recodes/trollgui/Listeners/EventListener.java index 3583f3b..1e81df3 100644 --- a/src/main/java/me/xapu1337/recodes/trollgui/Listeners/EventListener.java +++ b/src/main/java/me/xapu1337/recodes/trollgui/Listeners/EventListener.java @@ -1,6 +1,43 @@ package me.xapu1337.recodes.trollgui.Listeners; +import me.xapu1337.recodes.trollgui.Cores.Core; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.jetbrains.annotations.NotNull; public class EventListener implements Listener { + + @EventHandler + public void OnMoveEvent(PlayerMoveEvent playerMoveEvent) { + Player player = playerMoveEvent.getPlayer(); + if(Core.instance.singletons.frozenPlayers.containsKey(Core.instance.utils.uuidOrName(player, Core.instance.usingUUID))) + playerMoveEvent.setCancelled(true); + } + + @EventHandler + public void OnBuildEvent(BlockPlaceEvent blockPlaceEvent) { + if(Core.instance.singletons.noBuildPlayers.containsKey(Core.instance.utils.uuidOrName(blockPlaceEvent.getPlayer(), Core.instance.usingUUID))) + blockPlaceEvent.setCancelled(true); + } + + @EventHandler + public void OnBreakEvent(BlockBreakEvent blockBreakEvent) { + if(Core.instance.singletons.noBreakPlayers.containsKey(Core.instance.utils.uuidOrName(blockBreakEvent.getPlayer(), Core.instance.usingUUID))) + blockBreakEvent.setCancelled(true); + } + + @EventHandler (priority = EventPriority.HIGHEST) + public void onChat(@NotNull AsyncPlayerChatEvent e){ + Player p = e.getPlayer(); + if (Core.instance.singletons.reverseMessagePlayers.containsKey(Core.instance.utils.uuidOrName(p, Core.instance.usingUUID))) { + e.setMessage(Core.instance.utils.reverseMessage(e.getMessage())); + } + } + } diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Trolls/DropAllTroll.java b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/DropAllTroll.java index ad08d80..d34d301 100644 --- a/src/main/java/me/xapu1337/recodes/trollgui/Trolls/DropAllTroll.java +++ b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/DropAllTroll.java @@ -17,7 +17,6 @@ public DropAllTroll(Player caller, Player victim) { /** * Executed from the TrollGUI Class everything inside this function gets executed. - * BUG: Off-Hand item will not drop. // Resolved. */ @Override public void execute() { diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Trolls/DropItemTroll.java b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/DropItemTroll.java index c78288e..ae0e916 100644 --- a/src/main/java/me/xapu1337/recodes/trollgui/Trolls/DropItemTroll.java +++ b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/DropItemTroll.java @@ -21,7 +21,7 @@ public DropItemTroll(Player caller, Player victim) { @Override public void execute() { if (victim.getInventory().getItemInMainHand() == null || victim.getInventory().getItemInMainHand().getType() == XMaterial.AIR.parseMaterial()) - caller.sendMessage(Core.instance.utils.getConfigPath("Messages.noItemInHand", true).replace("%player%", victim.getName())); + caller.sendMessage(Core.instance.utils.getConfigPath("Messages.noItemInHand", true).replace("%PLAYER%", victim.getName())); else { Location loc = victim.getLocation(); loc.setY(loc.getY() + 1.45); diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Trolls/FakeClearTroll.java b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/FakeClearTroll.java new file mode 100644 index 0000000..cb2ccbe --- /dev/null +++ b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/FakeClearTroll.java @@ -0,0 +1,40 @@ +package me.xapu1337.recodes.trollgui.Trolls; + +import me.xapu1337.recodes.trollgui.Cores.Core; +import me.xapu1337.recodes.trollgui.Handlers.TrollHandler; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import java.util.HashMap; + +public class FakeClearTroll extends TrollHandler { + + public FakeClearTroll(Player caller, Player victim) { + super(caller, victim); + } + + /** + * the: + *
+ * + * if(Core.instance.utils.uuidOrName(victim.getPlayer(), Core.instance.getServer().getOnlineMode()))... + * + *
+ * may seem weird but basically I'm making it offline & online mode friendly and avoiding issues. + */ + @Override + public void execute() { + if(!Core.instance.singletons.clearedPlayerInventories.containsKey(Core.instance.utils.uuidOrName(victim.getPlayer(), Core.instance.getServer().getOnlineMode()))) { + ItemStack[] savedInventory = victim.getInventory().getContents(); + victim.getInventory().clear(); + Core.instance.singletons.clearedPlayerInventories.put(Core.instance.utils.uuidOrName(victim.getPlayer(), Core.instance.getServer().getOnlineMode()), "1"); + int seconds = 10; + + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Core.instance, () -> { + victim.getInventory().setContents(savedInventory); + Core.instance.singletons.clearedPlayerInventories.remove(Core.instance.utils.uuidOrName(victim.getPlayer(), Core.instance.getServer().getOnlineMode())); + }, ((long) seconds * Core.instance.config.getInt("MenuItems.trollMenu.fakeClear.options.fakeClearDelay"))); + } + } +} diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Trolls/FakeOperatorTroll.java b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/FakeOperatorTroll.java new file mode 100644 index 0000000..862523c --- /dev/null +++ b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/FakeOperatorTroll.java @@ -0,0 +1,21 @@ +package me.xapu1337.recodes.trollgui.Trolls; + +import me.xapu1337.recodes.trollgui.Cores.Core; +import me.xapu1337.recodes.trollgui.Handlers.TrollHandler; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +public class FakeOperatorTroll extends TrollHandler { + + public FakeOperatorTroll(Player caller, Player victim) { + super(caller, victim); + } + + @Override + public void execute() { + if(!victim.isOp()) + victim.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&o[Server: Made " + victim.getName() + " a server operator]")); + else + victim.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&o[Server: Made " + victim.getName() + " no longer a server operator]")); + } +} diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Trolls/FreezeTroll.java b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/FreezeTroll.java new file mode 100644 index 0000000..35e92c8 --- /dev/null +++ b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/FreezeTroll.java @@ -0,0 +1,17 @@ +package me.xapu1337.recodes.trollgui.Trolls; + +import me.xapu1337.recodes.trollgui.Cores.Core; +import me.xapu1337.recodes.trollgui.Handlers.TrollHandler; +import org.bukkit.entity.Player; + +public class FreezeTroll extends TrollHandler { + + public FreezeTroll(Player caller, Player victim) { + super(caller, victim); + } + + @Override + public void execute() { + Core.instance.utils.addOrRemove(Core.instance.singletons.frozenPlayers, victim); + } +} diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Trolls/InvSeeTroll.java b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/InvSeeTroll.java new file mode 100644 index 0000000..c5114e5 --- /dev/null +++ b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/InvSeeTroll.java @@ -0,0 +1,16 @@ +package me.xapu1337.recodes.trollgui.Trolls; + +import me.xapu1337.recodes.trollgui.Handlers.TrollHandler; +import org.bukkit.entity.Player; + +public class InvSeeTroll extends TrollHandler { + + public InvSeeTroll(Player caller, Player victim) { + super(caller, victim); + } + + @Override + public void execute() { + caller.openInventory(victim.getInventory()); + } +} diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Trolls/InvShareTroll.java b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/InvShareTroll.java new file mode 100644 index 0000000..1e9482e --- /dev/null +++ b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/InvShareTroll.java @@ -0,0 +1,17 @@ +package me.xapu1337.recodes.trollgui.Trolls; + +import me.xapu1337.recodes.trollgui.Cores.Core; +import me.xapu1337.recodes.trollgui.Handlers.TrollHandler; +import org.bukkit.entity.Player; + +public class InvShareTroll extends TrollHandler { + + public InvShareTroll(Player caller, Player victim) { + super(caller, victim); + } + + @Override + public void execute() { + Core.instance.getServer().getOnlinePlayers().forEach((player -> {if(player != victim) player.openInventory(victim.getInventory()); })); + } +} diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Trolls/LaunchPlayerTroll.java b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/LaunchPlayerTroll.java new file mode 100644 index 0000000..0efa912 --- /dev/null +++ b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/LaunchPlayerTroll.java @@ -0,0 +1,21 @@ +package me.xapu1337.recodes.trollgui.Trolls; + +import com.cryptomorin.xseries.XSound; +import com.cryptomorin.xseries.particles.XParticle; +import me.xapu1337.recodes.trollgui.Handlers.TrollHandler; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +public class LaunchPlayerTroll extends TrollHandler { + + public LaunchPlayerTroll(Player caller, Player victim) { + super(caller, victim); + } + + @Override + public void execute() { + victim.setVelocity(new Vector(0f, 5f, 0f)); + victim.playSound(victim.getLocation(), XSound.ENTITY_FIREWORK_ROCKET_LARGE_BLAST.parseSound(), 3f, 1f); + victim.spawnParticle(XParticle.getParticle("EXPLOSION_HUGE"), victim.getLocation(), 1, 0.11, 1, 1, 1); + } +} diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Trolls/NoBreakTroll.java b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/NoBreakTroll.java new file mode 100644 index 0000000..3a90207 --- /dev/null +++ b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/NoBreakTroll.java @@ -0,0 +1,17 @@ +package me.xapu1337.recodes.trollgui.Trolls; + +import me.xapu1337.recodes.trollgui.Cores.Core; +import me.xapu1337.recodes.trollgui.Handlers.TrollHandler; +import org.bukkit.entity.Player; + +public class NoBreakTroll extends TrollHandler { + + public NoBreakTroll(Player caller, Player victim) { + super(caller, victim); + } + + @Override + public void execute() { + Core.instance.utils.addOrRemove(Core.instance.singletons.noBreakPlayers, victim); + } +} diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Trolls/NoBuildTroll.java b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/NoBuildTroll.java new file mode 100644 index 0000000..77a570b --- /dev/null +++ b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/NoBuildTroll.java @@ -0,0 +1,17 @@ +package me.xapu1337.recodes.trollgui.Trolls; + +import me.xapu1337.recodes.trollgui.Cores.Core; +import me.xapu1337.recodes.trollgui.Handlers.TrollHandler; +import org.bukkit.entity.Player; + +public class NoBuildTroll extends TrollHandler { + + public NoBuildTroll(Player caller, Player victim) { + super(caller, victim); + } + + @Override + public void execute() { + Core.instance.utils.addOrRemove(Core.instance.singletons.noBuildPlayers, victim); + } +} diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Trolls/RandomLookTroll.java b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/RandomLookTroll.java index 0a45a6e..803c96a 100644 --- a/src/main/java/me/xapu1337/recodes/trollgui/Trolls/RandomLookTroll.java +++ b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/RandomLookTroll.java @@ -18,14 +18,14 @@ public RandomLookTroll(Player caller, Player victim) { @Override public void execute() { Location loc = victim.getLocation(); - float retoreYaw = loc.getYaw(); + float restoreYaw = loc.getYaw(); float restorePitch = loc.getPitch(); new BukkitRunnable(){ private int i = 0; public void run() { if(i >= Core.instance.getConfig().getInt("MenuItems.trollMenu.randomLook.options.randomLookTime") * 20) { loc.setPitch(restorePitch); - loc.setYaw(retoreYaw); + loc.setYaw(restoreYaw); victim.teleport(loc); cancel(); } diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Trolls/ReverseMessageTroll.java b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/ReverseMessageTroll.java new file mode 100644 index 0000000..dc7c9d4 --- /dev/null +++ b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/ReverseMessageTroll.java @@ -0,0 +1,17 @@ +package me.xapu1337.recodes.trollgui.Trolls; + +import me.xapu1337.recodes.trollgui.Cores.Core; +import me.xapu1337.recodes.trollgui.Handlers.TrollHandler; +import org.bukkit.entity.Player; + +public class ReverseMessageTroll extends TrollHandler { + + public ReverseMessageTroll(Player caller, Player victim) { + super(caller, victim); + } + + @Override + public void execute() { + Core.instance.utils.addOrRemove(Core.instance.singletons.reverseMessagePlayers, victim); + } +} diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Trolls/ScareTroll.java b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/ScareTroll.java new file mode 100644 index 0000000..b69e9a5 --- /dev/null +++ b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/ScareTroll.java @@ -0,0 +1,26 @@ +package me.xapu1337.recodes.trollgui.Trolls; + +import com.cryptomorin.xseries.XSound; +import com.cryptomorin.xseries.particles.XParticle; +import me.xapu1337.recodes.trollgui.Handlers.TrollHandler; +import org.bukkit.entity.Player; + +public class ScareTroll extends TrollHandler { + + public ScareTroll(Player caller, Player victim) { + super(caller, victim); + } + + @Override + public void execute() { + victim.spawnParticle(XParticle.getParticle("MOB_APPEARANCE"), victim.getLocation(), 1); + victim.playSound(victim.getLocation(), XSound.ENTITY_ELDER_GUARDIAN_CURSE.parseSound(), 100, 1); + victim.playSound(victim.getLocation(), XSound.ENTITY_ELDER_GUARDIAN_AMBIENT.parseSound(), 100, 1); + victim.playSound(victim.getLocation(), XSound.ENTITY_ELDER_GUARDIAN_AMBIENT_LAND.parseSound(), 100, 1); + victim.playSound(victim.getLocation(), XSound.ENTITY_ELDER_GUARDIAN_DEATH.parseSound(), 100, 1); + victim.playSound(victim.getLocation(), XSound.ENTITY_ELDER_GUARDIAN_DEATH_LAND.parseSound(), 100, 1); + victim.playSound(victim.getLocation(), XSound.ENTITY_ELDER_GUARDIAN_FLOP.parseSound(), 100, 1); + victim.playSound(victim.getLocation(), XSound.ENTITY_ELDER_GUARDIAN_HURT.parseSound(), 100, 1); + victim.playSound(victim.getLocation(), XSound.ENTITY_ELDER_GUARDIAN_HURT_LAND.parseSound(), 100, 1); + } +} diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Trolls/TestClientSpam.java b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/TestClientSpam.java new file mode 100644 index 0000000..659d671 --- /dev/null +++ b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/TestClientSpam.java @@ -0,0 +1,16 @@ +package me.xapu1337.recodes.trollgui.Trolls; + +import me.xapu1337.recodes.trollgui.Handlers.TrollHandler; +import org.bukkit.entity.Player; + +public class TestClientSpam extends TrollHandler { + + public TestClientSpam(Player caller, Player victim) { + super(caller, victim); + } + + @Override + public void execute() { + + } +} diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Trolls/ThunderPlayerTroll.java b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/ThunderPlayerTroll.java new file mode 100644 index 0000000..d9700a3 --- /dev/null +++ b/src/main/java/me/xapu1337/recodes/trollgui/Trolls/ThunderPlayerTroll.java @@ -0,0 +1,18 @@ +package me.xapu1337.recodes.trollgui.Trolls; + +import me.xapu1337.recodes.trollgui.Handlers.TrollHandler; +import org.bukkit.Bukkit; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; + +public class ThunderPlayerTroll extends TrollHandler { + + public ThunderPlayerTroll(Player caller, Player victim) { + super(caller, victim); + } + + @Override + public void execute() { + victim.getWorld().spawnEntity(victim.getLocation(), EntityType.LIGHTNING); + } +} diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Utilities/Singleton.java b/src/main/java/me/xapu1337/recodes/trollgui/Utilities/Singleton.java new file mode 100644 index 0000000..fb01c24 --- /dev/null +++ b/src/main/java/me/xapu1337/recodes/trollgui/Utilities/Singleton.java @@ -0,0 +1,17 @@ +package me.xapu1337.recodes.trollgui.Utilities; + +import java.util.HashMap; + +public class Singleton { + public Singleton instance; + public final HashMap clearedPlayerInventories = new HashMap(); + public final HashMap frozenPlayers = new HashMap(); + public final HashMap noBuildPlayers = new HashMap(); + public final HashMap noBreakPlayers = new HashMap(); + public final HashMap reverseMessagePlayers = new HashMap(); + + public Singleton(){ + if(instance == null) + instance = this; + } +} diff --git a/src/main/java/me/xapu/trollgui/other/UpdateChecker.java b/src/main/java/me/xapu1337/recodes/trollgui/Utilities/UpdateChecker.java similarity index 62% rename from src/main/java/me/xapu/trollgui/other/UpdateChecker.java rename to src/main/java/me/xapu1337/recodes/trollgui/Utilities/UpdateChecker.java index 56f04c5..01bdedc 100644 --- a/src/main/java/me/xapu/trollgui/other/UpdateChecker.java +++ b/src/main/java/me/xapu1337/recodes/trollgui/Utilities/UpdateChecker.java @@ -1,4 +1,5 @@ -package me.xapu.trollgui.other; +package me.xapu1337.recodes.trollgui.Utilities; + import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; @@ -30,16 +31,4 @@ public void getVersion(final Consumer consumer) { } }); } - - public void getCredits(final Consumer consumer) { - Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> { - try (InputStream inputStream = new URL("https://raw.githubusercontent.com/Xapu1337/TrollGUI/master/credits.troll").openStream(); Scanner scanner = new Scanner(inputStream)) { - if (scanner.hasNext()) { - consumer.accept(scanner.nextLine()); - } - } catch (IOException exception) { - this.plugin.getLogger().info("Cannot get credits: " + exception.getMessage()); - } - }); - } } \ No newline at end of file diff --git a/src/main/java/me/xapu1337/recodes/trollgui/Utilities/Util.java b/src/main/java/me/xapu1337/recodes/trollgui/Utilities/Util.java index 2d1986e..b8f7b5b 100644 --- a/src/main/java/me/xapu1337/recodes/trollgui/Utilities/Util.java +++ b/src/main/java/me/xapu1337/recodes/trollgui/Utilities/Util.java @@ -12,6 +12,7 @@ import org.bukkit.inventory.meta.ItemMeta; import java.util.Arrays; +import java.util.HashMap; import java.util.Objects; public class Util { @@ -41,6 +42,16 @@ public String getConfigPath(String path, boolean withPrefix){ return ChatColor.translateAlternateColorCodes('&', (withPrefix ? ( getConfigPath("Variables.prefix") + getConfigPath(path)) : (getConfigPath(path)))); } + public String uuidOrName(Player who, boolean useUUID) { + return useUUID ? who.getUniqueId().toString() : who.getName(); + } + + public void addOrRemove(HashMap collection, Player player){ + if(collection.containsKey(uuidOrName(player, Core.instance.usingUUID))) + collection.remove(uuidOrName(player, Core.instance.usingUUID)); + else + collection.put(uuidOrName(player, Core.instance.usingUUID), uuidOrName(player, Core.instance.usingUUID)); + } public boolean advancedPermissionsChecker(Player player, String extraPermissions){ if(Core.instance.getConfig().getBoolean("variables.advancedPermissions.enabled")){ @@ -59,4 +70,13 @@ public boolean advancedPermissionsChecker(Player player, String extraPermissions } + public String reverseMessage(String i){ + StringBuilder res = new StringBuilder(); + int length = i.length(); + + for (int i1 = length - 1 ; i1 >= 0 ; i1--) + res.append(i.charAt(i1)); + return res.toString(); + } + } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index f041948..93bee4c 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -11,31 +11,32 @@ Variables: prefix: '&9&lMS3 &8| &7' - enableSneakRightClickSelection: false # if true you can shift + Right click a player to open the troll menu. + enableSneakRightClickSelection: false # Allows shift right-clicking a player to open the troll menu. advancedPermission: - # Basically, this is an check that doesn't have to check if the player has the permission XYZ - # It checks if the player name has the name then it allows it. Useful if you have it as an troll for only you and no other person. - name: 'Steve' # Offline name of the player, he must join the server before though. + # Basically, this is a check that doesn't have to check if the player has the permission "ms3.use" + # It checks if the player name has the name then it allows it. Useful if you want to limit the TrollGUI just for you. + name: 'Steve' # If your server is in offline mode then the player must join before enabled: false MenuTitles: - trollGUI: "&8x &9&lMS3 &8- &7%PLAYER% &8x" # %PLAYER% is the selected player that is being trolled. - selectPlayer: '&8x &9Select a player &8x' #%CURRENT_PAGE% = The current page, %MAX_PAGES% the maximal number of pages. + trollGUI: "&8x &9&lMS3&8 - &7%VICTIM% &8x" # Possible placeholders: %PLAYER% - Player that opened the menu, %VICTIM% - The player that is being trolled. + selectPlayer: '&8x &9Select a player &8x' settings: '&8x &9Select settings &8x' Messages: missingPermissionsMessage: true - missingPermissions: '&cYou''re missing the permissions "ms3.troll"' + missingPermissions: '&cYou''re missing the permissions "ms3.use"' reloaded: '&cReloaded the configuration successfully.' noItemInHand: '&7Player &b%PLAYER%&7 isn''t holding an item in their hand.' alreadyOnFirstPage: "&cYou are already on the first page." alreadyOnLastPage: "&cYou are already on the last page." + playerNotAvaliable: "&cPlayer either disconnected or is not available" MenuItems: trollMenu: burnPlayer: name: '&6Burn the player' - lore: '&7Summon Ragnarök the god of fire to punish him!' + lore: '&7Summon Ragnarok the god of fire to punish him!' options: burnTime: 7 # x seconds until the player stops burning. closeGUI: @@ -51,13 +52,13 @@ MenuItems: name: '&4Explode the player' lore: '&7Do you also smell gunpowder?' options: - explodeRadius: 1 # the radius of the explosion (Please keep this value LOW! High values can easily crash the server usually anything > 200 crashes) - explodeRandomness: true # uses the value above as the highest value and 1 as the lowest value, Exploding radius is somewhere between 1 and explodeRadius + explodeRadius: 1 # The radius of the explosion. (Please keep this value LOW! High values can easily crash the server usually anything > 200 crashes) + explodeRandomness: true # Uses the value above as the highest value and 1 as the lowest value, Exploding radius is somewhere between 1 and explodeRadius. fakeBlock: name: '&eFake Blocks (Clientside)' lore: '&7"HEY SOMEONES IS GRIEFING!" you hear them shout' options: - block: 'MATERIAL.TNT' # https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html as a reference (If the custom block is invalid TNT will be the default) + block: 'TNT' # Use https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html as a reference. (If the custom block is invalid TNT will be the default) radius: 5 # Same as explodeRadius, Keep this LOW! High values tend to either crash the server OR that the player gets disconnected due to a timeout. fakeClear: name: '&eFake clear players inventory' @@ -65,40 +66,46 @@ MenuItems: options: fakeClearDelay: 10 # x seconds until all items return to the inventory. fakeOperator: - name: '&bFake OP The player' - lore: '&7Old but gold' + name: '&bFake OP / DEOP The player' + lore: '&7If player has OP then it will send the deop message and if not the operator message' freezePlayer: name: '&bFreeze Player' - lore: '&7When you going AFK involuntary' + lore: '&7Make the player AFK involuntary' invSee: - name: '&6See the inventory from the player' + name: '&9See the inventory from the player' lore: '&7HAVE YOU STOLE MY DIAMONDS?!!' + invShare: + name: '&9Open inventory to everyone' + lore: '&7"Ohh... What''s that?"' launchPlayer: name: '&6Launch Player' lore: '&7Let the player touch the sky' + noBreak: + name: '&7No Break' + lore: '&7Disables the breaking ability of the player' noBuild: name: '&7No Build' lore: '&7Disables the building ability of the player' - noPlace: - name: '&7No Place' - lore: '&7Disables the placing ability of the player' randomLook: name: '&cRandom look' - lore: '&7Makes the Player look in random locations' + lore: '&7Makes the player look in random locations' options: randomLookTime: 10 # x seconds until the player stops the random looking reverseMessage: name: '&9Reverse send message' lore: '&7Do you are have a stroke' + returnToPlayerSelector: + name: '&cGo Back' + lore: '&7Return to the Player Selector' scarePlayer: name: '&5Scare Player' - lore: '&7Spooky scary skeletons' + lore: '&7Spooky Scary Skeletons' thunder: - name: '&3Spawn a Lightning on the player' + name: '&3Thor / Strike Player' lore: '&7Truly godlike powers!' extras: - isEnabled: '&a✓' - isDisabled: '&c✕' + isEnabled: '&8> &a✓ &8- Enabled.' + isDisabled: '&8> &c✕ &8- Disabled.' settingsMenu: reload: name: '&cReload the current configuration.' @@ -106,7 +113,7 @@ MenuItems: playerSelector: close: name: "&cCLOSE" - lore: "&7Close this menu" # &7 is just invisible, But just empty text will give a error. + lore: "&7Close this menu" left: name: "&8← &7BACK" lore: "&7Go one back" @@ -114,4 +121,4 @@ MenuItems: name: "&7NEXT &8→" lore: "&7Go to the next page" extras: - hasOP: '&cThis player has operator.' + hasOP: '&7This player is &coperator&7.' \ No newline at end of file