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