mirror of
https://github.com/kaboomserver/extras.git
synced 2024-11-23 16:08:18 -05:00
Simplify command check
This commit is contained in:
parent
c246fb9b27
commit
d805770131
5 changed files with 130 additions and 134 deletions
|
@ -320,16 +320,25 @@ public class Main extends JavaPlugin {
|
|||
"ewarps",
|
||||
"ewhisper",
|
||||
|
||||
"extras:bcraw",
|
||||
"extras:broadcastraw",
|
||||
"extras:cc",
|
||||
"extras:clearchat",
|
||||
"extras:console",
|
||||
"extras:jumpscare",
|
||||
"extras:scare",
|
||||
"extras:tellraw",
|
||||
"bcraw",
|
||||
"broadcastraw",
|
||||
"cc",
|
||||
"clearchat",
|
||||
"console",
|
||||
"jumpscare",
|
||||
"scare",
|
||||
"tellraw",
|
||||
|
||||
"minecraft:clear",
|
||||
"minecraft:clone",
|
||||
"minecraft:datapack",
|
||||
"minecraft:effect",
|
||||
"minecraft:execute",
|
||||
|
@ -345,6 +354,7 @@ public class Main extends JavaPlugin {
|
|||
"minecraft:tp",
|
||||
"minecraft:worldborder",
|
||||
"clear",
|
||||
"clone",
|
||||
"datapack",
|
||||
"effect",
|
||||
"execute",
|
||||
|
|
|
@ -45,6 +45,7 @@ class SkinDownloader {
|
|||
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
try {
|
||||
if (player.isOnline()) {
|
||||
player.setPlayerProfile(profile);
|
||||
|
||||
|
@ -52,6 +53,9 @@ class SkinDownloader {
|
|||
player.sendMessage("Successfully set your username to \"" + name + "\"");
|
||||
}
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
// Do nothing
|
||||
}
|
||||
Main.skinInProgress.remove(player.getUniqueId());
|
||||
}
|
||||
}.runTask(JavaPlugin.getPlugin(Main.class));
|
||||
|
|
|
@ -73,12 +73,12 @@ class BlockPhysics implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
/*@EventHandler
|
||||
void onBlockPhysics(BlockPhysicsEvent event) {
|
||||
if (event.getSourceBlock().getState() instanceof CommandBlock) {
|
||||
event.getSourceBlock().getState().update();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@EventHandler
|
||||
void onBlockRedstone(BlockRedstoneEvent event) {
|
||||
|
|
|
@ -38,8 +38,6 @@ import org.bukkit.event.entity.EntitySpawnEvent;
|
|||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
||||
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
|
||||
import org.bukkit.event.vehicle.VehicleCreateEvent;
|
||||
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
@ -194,10 +192,6 @@ class EntitySpawn implements Listener {
|
|||
if (Z < minValue)
|
||||
Z = minValue;
|
||||
|
||||
System.out.println(X);
|
||||
System.out.println(Y);
|
||||
System.out.println(Z);
|
||||
|
||||
return new Location(location.getWorld(), X, Y, Z);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ class ServerCommand implements Listener {
|
|||
commandName = "/" + arr[0].toLowerCase();
|
||||
}
|
||||
|
||||
try {
|
||||
switch (commandName) {
|
||||
case "/minecraft:execute":
|
||||
case "/execute":
|
||||
|
@ -36,6 +37,7 @@ class ServerCommand implements Listener {
|
|||
if ("execute".equalsIgnoreCase(arr[i+1]) ||
|
||||
"particle".equalsIgnoreCase(arr[i+1]) ||
|
||||
"save-off".equalsIgnoreCase(arr[i+1]) ||
|
||||
"spreadplayers".equalsIgnoreCase(arr[i+1]) ||
|
||||
"stop".equalsIgnoreCase(arr[i+1])) {
|
||||
Command.broadcastCommandMessage(sender, "Forbidden execute command detected");
|
||||
return "cancel";
|
||||
|
@ -48,20 +50,10 @@ class ServerCommand implements Listener {
|
|||
Double.parseDouble(arr[i+3]) > 100) {
|
||||
return command.replaceFirst("(?i)" + "spawnRadius " + arr[i+3], "spawnRadius 100");
|
||||
}
|
||||
} else if (i+5 < arr.length &&
|
||||
"spreadplayers".equalsIgnoreCase(arr[i+1])) {
|
||||
if (Double.parseDouble(arr[i+5]) > 75) {
|
||||
final StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
for (int i2 = 0; i2 < i+5; i2++) {
|
||||
stringBuilder.append(arr[i2]).append(" ");
|
||||
}
|
||||
stringBuilder.append("75 ");
|
||||
for (int i2 = i+6; i2 < arr.length; i2++) {
|
||||
stringBuilder.append(arr[i2]).append(" ");
|
||||
}
|
||||
|
||||
return stringBuilder.toString();
|
||||
} else if ("give".equalsIgnoreCase(arr[i+1])) {
|
||||
if (Double.parseDouble(arr[arr.length-1]) > 1024) {
|
||||
arr[arr.length-1] = "1024";
|
||||
return String.join(" ", arr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,22 +84,19 @@ class ServerCommand implements Listener {
|
|||
}
|
||||
}
|
||||
break;
|
||||
case "/minecraft:give":
|
||||
case "/give":
|
||||
if (Double.parseDouble(arr[arr.length-1]) > 1024) {
|
||||
arr[arr.length-1] = "1024";
|
||||
return String.join(" ", arr);
|
||||
}
|
||||
break;
|
||||
case "/minecraft:particle":
|
||||
case "/particle":
|
||||
if (arr.length >= 10) {
|
||||
if (Double.parseDouble(arr[9]) > 10) {
|
||||
final StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
stringBuilder.append(arr[i]).append(" ");
|
||||
}
|
||||
stringBuilder.append("10 ");
|
||||
for (int i = 10; i < arr.length; i++) {
|
||||
stringBuilder.append(arr[i]).append(" ");
|
||||
}
|
||||
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
if (arr.length >= 10 &&
|
||||
Double.parseDouble(arr[9]) > 10) {
|
||||
arr[9] = "10";
|
||||
return String.join(" ", arr);
|
||||
}
|
||||
break;
|
||||
case "/bukkit:reload":
|
||||
|
@ -138,19 +127,15 @@ class ServerCommand implements Listener {
|
|||
break;
|
||||
case "/minecraft:spreadplayers":
|
||||
case "/spreadplayers":
|
||||
if (arr.length >= 5 &&
|
||||
Double.parseDouble(arr[4]) > 75) {
|
||||
final StringBuilder stringBuilder = new StringBuilder();
|
||||
if (arr.length >= 5) {
|
||||
if (Double.parseDouble(arr[3]) > 0)
|
||||
arr[3] = "0";
|
||||
if (Double.parseDouble(arr[4]) < 8)
|
||||
arr[4] = "8";
|
||||
if (Double.parseDouble(arr[4]) > 50)
|
||||
arr[4] = "50";
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
stringBuilder.append(arr[i]).append(" ");
|
||||
}
|
||||
stringBuilder.append("75 ");
|
||||
for (int i = 5; i < arr.length; i++) {
|
||||
stringBuilder.append(arr[i]).append(" ");
|
||||
}
|
||||
|
||||
return stringBuilder.toString();
|
||||
return String.join(" ", arr);
|
||||
}
|
||||
break;
|
||||
case "/minecraft:stop":
|
||||
|
@ -160,6 +145,9 @@ class ServerCommand implements Listener {
|
|||
return "cancel";
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException exception) {
|
||||
// Do nothing
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue