From 4f25888fdb968ae89da8ddafe705b5ba30563ebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Aubrecht?= Date: Thu, 1 Jul 2021 09:42:47 +0200 Subject: [PATCH] v2.5 - Added bStats: https://bstats.org/plugin/bukkit/ToolKit/11896 - Added shortcuts for gamemodes: - gmc - gms - gma - gmsp - Added thor troll --- README.md | 13 +++- pom.xml | 32 ++++++-- src/main/java/cz/qery/toolkit/Main.java | 33 ++++++--- src/main/java/cz/qery/toolkit/Scripts.java | 74 ++++++++++++------- .../cz/qery/toolkit/commands/Aliases.java | 61 +++++++++++++++ .../cz/qery/toolkit/commands/ToolKit.java | 2 +- .../java/cz/qery/toolkit/commands/Troll.java | 46 ++++++------ src/main/resources/plugin.yml | 60 +++++++++------ 8 files changed, 230 insertions(+), 91 deletions(-) create mode 100644 src/main/java/cz/qery/toolkit/commands/Aliases.java diff --git a/README.md b/README.md index 740c123..72f61b6 100644 --- a/README.md +++ b/README.md @@ -2,21 +2,25 @@

-[![Version](https://img.shields.io/badge/version-v2.3-informational.svg)](https://github.com/czQery/ToolKit/releases) +[![Version](https://img.shields.io/badge/version-v2.5-informational.svg)](https://github.com/czQery/ToolKit/releases) [![Releases](https://img.shields.io/badge/download-1.17-brightgreen.svg)](https://github.com/czQery/ToolKit/releases/latest/download/ToolKit.jar) ## Commands | Command | Permission | Protection | Description | | ----------------- | --------------------- | ------------------------- | --------------------------------------------- | -| /crash | toolkit.crash | toolkit.crash.bypass | Lag/Crash players game | +| /crasher | toolkit.crasher | toolkit.crasher.bypass | Lag/Crash players game | | /crawl | toolkit.crawl | null | Allows the player to crawl | | /sit | toolkit.sit | null | Allows the player to sit down | | /skick | toolkit.skick | toolkit.skick.bypass | Badlion users cannot exit kick screen | | /troll | toolkit.troll | toolkit.troll.bypass | Just troll command :) | | /toolkit | null | null | Show info about plugin | -| /pinfo | toolkit.pinfo | null | Show info about player (even their client) | -| /rp | toolkit.rp | null | Set player resource pack | +| /pinfo | toolkit.pinfo | null | Show info about player (even their client) | +| /rp | toolkit.rp | null | Set player's resource pack | +| /gmc | toolkit.gmc | null | Switch player's gamemode to CREATIVE | +| /gms | toolkit.gms | null | Switch player's gamemode to SURVIVAL | +| /gma | toolkit.gma | null | Switch player's gamemode to ADVENTURE | +| /gmsp | toolkit.gmsp | null | Switch player's gamemode to SPECTATOR | ## Trolls @@ -28,6 +32,7 @@ - Freeze - FakeOp - Flip +- Thor - FakeDemo (soon) ## Events diff --git a/pom.xml b/pom.xml index 97ba6ba..c8d3a43 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ cz.qery ToolKit - 2.4 + 2.5 jar ToolKit @@ -16,7 +16,7 @@ 1.8 UTF-8 - qery.cz + github.com/czQery/ToolKit @@ -33,6 +33,14 @@ org.apache.maven.plugins maven-shade-plugin 3.2.4 + + + + org.bstats + cz.qery.toolkit + + + package @@ -60,16 +68,28 @@ https://papermc.io/repo/repository/maven-public/ - sonatype - https://oss.sonatype.org/content/groups/public/ + spigot-repo + https://hub.spigotmc.org/nexus/content/groups/public/ - com.destroystokyo.paper + io.papermc.paper paper-api - 1.16.5-R0.1-SNAPSHOT + 1.17-R0.1-SNAPSHOT + provided + + + org.bstats + bstats-bukkit + 2.2.1 + compile + + + org.spigotmc + spigot + 1.17-R0.1-SNAPSHOT provided diff --git a/src/main/java/cz/qery/toolkit/Main.java b/src/main/java/cz/qery/toolkit/Main.java index 6aa47fc..2fcc157 100644 --- a/src/main/java/cz/qery/toolkit/Main.java +++ b/src/main/java/cz/qery/toolkit/Main.java @@ -2,29 +2,34 @@ import cz.qery.toolkit.commands.*; import cz.qery.toolkit.events.*; +import org.bstats.bukkit.Metrics; import org.bukkit.Bukkit; import org.bukkit.event.HandlerList; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.messaging.Messenger; +import java.util.Objects; + public final class Main extends JavaPlugin { @Override public void onEnable() { loadConfiguration(); - String b = this.getConfig().getString("color.bracket"); - String n = this.getConfig().getString("color.name"); - + Objects.requireNonNull(getCommand("crash")).setExecutor(new Crash()); + Objects.requireNonNull(getCommand("crawl")).setExecutor(new Crawl()); + Objects.requireNonNull(getCommand("toolkit")).setExecutor(new ToolKit()); + Objects.requireNonNull(getCommand("skick")).setExecutor(new SKick()); + Objects.requireNonNull(getCommand("sit")).setExecutor(new Sit()); + Objects.requireNonNull(getCommand("troll")).setExecutor(new Troll()); + Objects.requireNonNull(getCommand("pinfo")).setExecutor(new PInfo()); + Objects.requireNonNull(getCommand("rp")).setExecutor(new RP()); - getCommand("crash").setExecutor(new Crash()); - getCommand("crawl").setExecutor(new Crawl()); - getCommand("toolkit").setExecutor(new ToolKit()); - getCommand("skick").setExecutor(new SKick()); - getCommand("sit").setExecutor(new Sit()); - getCommand("troll").setExecutor(new Troll()); - getCommand("pinfo").setExecutor(new PInfo()); - getCommand("rp").setExecutor(new RP()); + //Aliases + Objects.requireNonNull(getCommand("gmc")).setExecutor(new Aliases()); + Objects.requireNonNull(getCommand("gms")).setExecutor(new Aliases()); + Objects.requireNonNull(getCommand("gma")).setExecutor(new Aliases()); + Objects.requireNonNull(getCommand("gmsp")).setExecutor(new Aliases()); new Interact(this); new Join(this); @@ -43,6 +48,12 @@ public void onEnable() { ms.registerOutgoingPluginChannel(this, "fml:handshake"); ms.registerOutgoingPluginChannel(this, "fml:loginwrapper"); ms.registerOutgoingPluginChannel(this, "fml:play"); + + + + //bStats + int pluginId = 11896; + Metrics metrics = new Metrics(this, pluginId); } public void loadConfiguration() { diff --git a/src/main/java/cz/qery/toolkit/Scripts.java b/src/main/java/cz/qery/toolkit/Scripts.java index bb745b0..8310c4e 100644 --- a/src/main/java/cz/qery/toolkit/Scripts.java +++ b/src/main/java/cz/qery/toolkit/Scripts.java @@ -19,54 +19,76 @@ public static void bCheck(Player p) { int y = p.getLocation().getBlockY(); int z = p.getLocation().getBlockZ(); - Location d1 = new Location(world, x, y-1, z); - Location d2 = new Location(world, x, y-2, z); + Location d1 = new Location(world, x, y - 1, z); + Location d2 = new Location(world, x, y - 2, z); if (p.isOnGround()) { if (p.getLocation().getY() % 1 > 0.25) { p.setMetadata("crawl", new FixedMetadataValue(plugin, false)); - p.sendMessage(Tools.chat(b+"["+n+"CRAWL"+b+"]"+t+" Crawl mode has been turned &cOFF"+t+"!")); - Location loc = new Location(p.getWorld(), p.getLocation().getBlockX(), p.getLocation().getBlockY()+1, p.getLocation().getBlockZ()); - if (loc.getBlock().getType() == Material.BARRIER){loc.getBlock().setType(Material.AIR);} + p.sendMessage(Tools.chat(b + "[" + n + "CRAWL" + b + "]" + t + " Crawl mode has been turned &cOFF" + t + "!")); + Location loc = new Location(p.getWorld(), p.getLocation().getBlockX(), p.getLocation().getBlockY() + 1, p.getLocation().getBlockZ()); + if (loc.getBlock().getType() == Material.BARRIER) { + loc.getBlock().setType(Material.AIR); + } } } if (d1.getBlock().isEmpty() && d2.getBlock().isEmpty()) { p.setMetadata("crawl", new FixedMetadataValue(plugin, false)); - p.sendMessage(Tools.chat(b+"["+n+"CRAWL"+b+"]"+t+" Crawl mode has been turned &cOFF"+t+"!")); - Location loc = new Location(p.getWorld(), p.getLocation().getBlockX(), p.getLocation().getBlockY()+1, p.getLocation().getBlockZ()); - if (loc.getBlock().getType() == Material.BARRIER){loc.getBlock().setType(Material.AIR);} + p.sendMessage(Tools.chat(b + "[" + n + "CRAWL" + b + "]" + t + " Crawl mode has been turned &cOFF" + t + "!")); + Location loc = new Location(p.getWorld(), p.getLocation().getBlockX(), p.getLocation().getBlockY() + 1, p.getLocation().getBlockZ()); + if (loc.getBlock().getType() == Material.BARRIER) { + loc.getBlock().setType(Material.AIR); + } } for (int i = 1; i < 3; i++) { if (i == 2) { - Location l0 = new Location(world, x, y+i, z); - if (l0.getBlock().getType() == Material.BARRIER){l0.getBlock().setType(Material.AIR);} + Location l0 = new Location(world, x, y + i, z); + if (l0.getBlock().getType() == Material.BARRIER) { + l0.getBlock().setType(Material.AIR); + } + } + Location l1 = new Location(world, x + 1, y + i, z); + if (l1.getBlock().getType() == Material.BARRIER) { + l1.getBlock().setType(Material.AIR); } - Location l1 = new Location(world, x+1, y+i, z); - if (l1.getBlock().getType() == Material.BARRIER){l1.getBlock().setType(Material.AIR);} // - Location l2 = new Location(world, x-1, y+i, z); - if (l2.getBlock().getType() == Material.BARRIER){l2.getBlock().setType(Material.AIR);} + Location l2 = new Location(world, x - 1, y + i, z); + if (l2.getBlock().getType() == Material.BARRIER) { + l2.getBlock().setType(Material.AIR); + } // - Location l3 = new Location(world, x, y+i, z+1); - if (l3.getBlock().getType() == Material.BARRIER){l3.getBlock().setType(Material.AIR);} + Location l3 = new Location(world, x, y + i, z + 1); + if (l3.getBlock().getType() == Material.BARRIER) { + l3.getBlock().setType(Material.AIR); + } // - Location l4 = new Location(world, x, y+i, z-1); - if (l4.getBlock().getType() == Material.BARRIER){l4.getBlock().setType(Material.AIR);} + Location l4 = new Location(world, x, y + i, z - 1); + if (l4.getBlock().getType() == Material.BARRIER) { + l4.getBlock().setType(Material.AIR); + } // - Location l5 = new Location(world, x+1, y+i, z+1); - if (l5.getBlock().getType() == Material.BARRIER){l5.getBlock().setType(Material.AIR);} + Location l5 = new Location(world, x + 1, y + i, z + 1); + if (l5.getBlock().getType() == Material.BARRIER) { + l5.getBlock().setType(Material.AIR); + } // - Location l6 = new Location(world, x+1, y+i, z-1); - if (l6.getBlock().getType() == Material.BARRIER){l6.getBlock().setType(Material.AIR);} + Location l6 = new Location(world, x + 1, y + i, z - 1); + if (l6.getBlock().getType() == Material.BARRIER) { + l6.getBlock().setType(Material.AIR); + } // - Location l7 = new Location(world, x-1, y+i, z+1); - if (l7.getBlock().getType() == Material.BARRIER){l7.getBlock().setType(Material.AIR);} + Location l7 = new Location(world, x - 1, y + i, z + 1); + if (l7.getBlock().getType() == Material.BARRIER) { + l7.getBlock().setType(Material.AIR); + } // - Location l8 = new Location(world, x-1, y+i, z-1); - if (l8.getBlock().getType() == Material.BARRIER){l8.getBlock().setType(Material.AIR);} + Location l8 = new Location(world, x - 1, y + i, z - 1); + if (l8.getBlock().getType() == Material.BARRIER) { + l8.getBlock().setType(Material.AIR); + } } } } diff --git a/src/main/java/cz/qery/toolkit/commands/Aliases.java b/src/main/java/cz/qery/toolkit/commands/Aliases.java new file mode 100644 index 0000000..ce02ad2 --- /dev/null +++ b/src/main/java/cz/qery/toolkit/commands/Aliases.java @@ -0,0 +1,61 @@ +package cz.qery.toolkit.commands; + +import cz.qery.toolkit.Main; +import cz.qery.toolkit.Tools; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; + +import java.util.Objects; + +public class Aliases implements CommandExecutor { + + Plugin plugin = Main.getPlugin(Main.class); + String b = plugin.getConfig().getString("color.bracket"); + String n = plugin.getConfig().getString("color.name"); + String t = plugin.getConfig().getString("color.text"); + String h = plugin.getConfig().getString("color.highlight"); + + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) { + + if (!(sender instanceof Player)) { + Tools.log(b+"["+n+"SERVER"+b+"]"+t+" This command cannot be used by the console!"); + } else { + Player p = (Player) sender; + if (!p.hasPermission("toolkit."+cmd.getName().toLowerCase())) { + p.sendMessage(Tools.chat(b + "[" + n + "SERVER" + b + "]" + t + " You're not allowed to do this!")); + } else { + Player target; + if (args.length > 0) { + target = Bukkit.getServer().getPlayer(args[0]); + } else { + target = p; + } + switch (cmd.getName().toLowerCase()) { + case "gmc": + target.setGameMode(GameMode.CREATIVE); + p.sendMessage(Tools.chat(b + "[" + n + "SERVER" + b + "]" + t + " Switched to " + h + "CREATIVE")); + break; + case "gms": + target.setGameMode(GameMode.SURVIVAL); + p.sendMessage(Tools.chat(b + "[" + n + "SERVER" + b + "]" + t + " Switched to " + h + "SURVIVAL")); + break; + case "gma": + target.setGameMode(GameMode.ADVENTURE); + p.sendMessage(Tools.chat(b + "[" + n + "SERVER" + b + "]" + t + " Switched to " + h + "ADVENTURE")); + break; + case "gmsp": + target.setGameMode(GameMode.SPECTATOR); + p.sendMessage(Tools.chat(b + "[" + n + "SERVER" + b + "]" + t + " Switched to " + h + "SPECTATOR")); + break; + } + } + } + return false; + } +} diff --git a/src/main/java/cz/qery/toolkit/commands/ToolKit.java b/src/main/java/cz/qery/toolkit/commands/ToolKit.java index f09b92d..5b52e8b 100644 --- a/src/main/java/cz/qery/toolkit/commands/ToolKit.java +++ b/src/main/java/cz/qery/toolkit/commands/ToolKit.java @@ -35,7 +35,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String github.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://github.com/czQery/ToolKit")); p.sendMessage(Tools.chat(b+"-------["+n+"TOOLKIT"+b+"]-------")); - p.sendMessage(Tools.chat(b+"- "+t+"Very useful plugin :))")); + p.sendMessage(Tools.chat(b+"- "+t+"Set of useful tools")); p.sendMessage(Tools.chat(b+"- "+t+"Version "+h+version)); p.spigot().sendMessage(github); p.sendMessage(Tools.chat(b+"- "+t+"Made by "+h+"czQery")); diff --git a/src/main/java/cz/qery/toolkit/commands/Troll.java b/src/main/java/cz/qery/toolkit/commands/Troll.java index 7d228e8..d614c24 100644 --- a/src/main/java/cz/qery/toolkit/commands/Troll.java +++ b/src/main/java/cz/qery/toolkit/commands/Troll.java @@ -1,12 +1,15 @@ package cz.qery.toolkit.commands; import cz.qery.toolkit.Main; +import cz.qery.toolkit.Scripts; import cz.qery.toolkit.Tools; +import net.minecraft.network.protocol.game.PacketPlayOutGameStateChange; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.plugin.Plugin; @@ -25,7 +28,7 @@ public class Troll implements CommandExecutor { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) { if (!(sender instanceof Player)) { - Tools.log(b+"["+n+"SERVER"+b+"]"+t+" This command cannot be used by the console!"); + Tools.log(b + "[" + n + "SERVER" + b + "]" + t + " This command cannot be used by the console!"); } else { Player p = (Player) sender; if (!p.hasPermission("toolkit.troll")) { @@ -143,29 +146,28 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N target.teleport(targetLocation); p.sendMessage(Tools.chat(b + "[" + n + "TROLL" + b + "]" + t + " Player " + h + target.getName() + t + " has been set" + h + " flip" + t + "!")); break; - case "fakedemo": - //! ISSUE #1041 - // ? WAITING FOR FIX - /* - ProtocolManager pm = ProtocolLibrary.getProtocolManager(); - PacketContainer packet = pm.createPacket(PacketType.Play.Server.GAME_STATE_CHANGE); - packet.getModifier().writeDefaults(); - packet.getBytes().write(0, (byte) 5); - packet.getFloat().write(0,0F); - try { - pm.sendServerPacket(target, packet); - } catch (InvocationTargetException e) { - } - */ - - p.sendMessage(Tools.chat(b + "[" + n + "TROLL" + b + "]" + t + " Player " + h + target.getName() + t + " has been set" + h + " fakedemo" + t + "!")); + case "thor": + target.getWorld().strikeLightning(target.getLocation()); + p.sendMessage(Tools.chat(b + "[" + n + "TROLL" + b + "]" + t + " Player " + h + target.getName() + t + " has been struck by lightning!")); break; - case "test": - //? I am trying to crash players windows by using this bug \\.\globalroot\device\condrv\kernelconnect (just file that crash windows when its open) - //? But its not working... If you reading this message you have probably enough skill to try it :) - target.setResourcePack("https://qery.cz/kek"); + case "fakedemo-WIP": + /* + final CraftPlayer craftPlayer = (CraftPlayer) target; + final PacketPlayOutGameStateChange welcomePacket = new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.a, 0.0F); + final PacketPlayOutGameStateChange moveHelpPacket = new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.a, 101F); + final PacketPlayOutGameStateChange jumpHelpPacket = new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.a, 102F); + final PacketPlayOutGameStateChange inventoryControl = new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.a, 103F); + + craftPlayer.getHandle(). - p.sendMessage(Tools.chat(b + "[" + n + "TROLL" + b + "]" + t + " Player " + h + target.getName() + t + " has been set" + h + " test" + t + "!")); + craftPlayer.getHandle().playerConnection.sendPacket(inventoryControl); + craftPlayer.getHandle().playerConnection.sendPacket(jumpHelpPacket); + craftPlayer.getHandle().playerConnection.sendPacket(welcomePacket); + craftPlayer.getHandle().playerConnection.sendPacket(moveHelpPacket); + */ + + + p.sendMessage(Tools.chat(b + "[" + n + "TROLL" + b + "]" + t + " Player " + h + target.getName() + t + " has been set" + h + " fakedemo" + t + "!")); break; default: p.sendMessage(Tools.chat(b + "[" + n + "TROLL" + b + "]" + t + " Please use " + h + "/troll ")); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 7ad682a..6741b60 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,47 +1,65 @@ name: ToolKit version: ${project.version} main: cz.qery.toolkit.Main -api-version: 1.16 +api-version: 1.17 authors: [ czQery ] -description: Very useful plugin -website: qery.cz +description: Set of useful tools +website: github.com/czQery/ToolKit commands: crash: - description: idk + description: Lag/Crash players game skick: - description: idk + description: Hax3er kick xDD (Badlion users cannot exit kick screen) toolkit: - description: idk + description: Show info about plugin troll: - description: idk + description: Set of troll commands crawl: - description: idk + description: Allows the player to crawl sit: - description: idk + description: Allows the player to sit down pinfo: - description: idk + description: Show info about player (even their client) rp: - description: idk + description: Set player resource pack + # Aliases + gmc: + description: Switch to CREATIVE mode + gms: + description: Switch to SURVIVAL mode + gma: + description: Switch to ADVENTURE mode + gmsp: + description: Switch to SPECTATOR mode permissions: toolkit.crash: - description: idk + description: Crash command toolkit.crash.bypass: - description: idk + description: Bypass crash command toolkit.skick: - description: idk + description: Skick command toolkit.skick.bypass: - description: idk + description: Bypass skick command toolkit.troll: - description: idk + description: Troll command toolkit.troll.bypass: - description: idk + description: Bypass troll command toolkit.crawl: - description: idk + description: Crawl command toolkit.sit: - description: idk + description: Sit command toolkit.pinfo: - description: idk + description: Pinfo command toolkit.rp: - description: idk \ No newline at end of file + description: Rp command + # Aliases + toolkit.gmc: + description: Gmc command + toolkit.gms: + description: Gms command + toolkit.gma: + description: Gma command + toolkit.gmsp: + description: Gmsp command \ No newline at end of file