Merge remote-tracking branch 'origin/master'
Dieser Commit ist enthalten in:
Commit
2579d7b6e6
@ -27,6 +27,8 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
public class InventoryListener_15 {
|
public class InventoryListener_15 {
|
||||||
|
|
||||||
|
private static final int threshold = 2048;
|
||||||
|
|
||||||
public static boolean checkItemStack(ItemStack item) {
|
public static boolean checkItemStack(ItemStack item) {
|
||||||
net.minecraft.server.v1_15_R1.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
|
net.minecraft.server.v1_15_R1.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
|
||||||
NBTTagCompound tag = nmsItem.getTag();
|
NBTTagCompound tag = nmsItem.getTag();
|
||||||
@ -34,13 +36,13 @@ public class InventoryListener_15 {
|
|||||||
NBTTagCompound blockTag = tag.getCompound("BlockEntityTag");
|
NBTTagCompound blockTag = tag.getCompound("BlockEntityTag");
|
||||||
assert blockTag != null;
|
assert blockTag != null;
|
||||||
if (blockTag.hasKey("Items")) {
|
if (blockTag.hasKey("Items")) {
|
||||||
return drillDown(blockTag.getList("Items", 10), 0, 0) > 1024;
|
return drillDown(blockTag.getList("Items", 10), 0, 0) > threshold;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int drillDown(NBTTagList items, int layer, int start) {
|
private static int drillDown(NBTTagList items, int layer, int start) {
|
||||||
if (layer > 2) return start + 1024;
|
if (layer > 2) return start + threshold;
|
||||||
int invalid = start;
|
int invalid = start;
|
||||||
for (NBTBase nbtBase : items) {
|
for (NBTBase nbtBase : items) {
|
||||||
if (!(nbtBase instanceof NBTTagCompound))
|
if (!(nbtBase instanceof NBTTagCompound))
|
||||||
@ -56,7 +58,7 @@ public class InventoryListener_15 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (invalid > 1024)
|
if (invalid > threshold)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return invalid;
|
return invalid;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.bausystem.features.loader;
|
package de.steamwar.bausystem.features.loader;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.config.ColorConfig;
|
import de.steamwar.bausystem.config.ColorConfig;
|
||||||
import de.steamwar.bausystem.linkage.LinkageType;
|
import de.steamwar.bausystem.linkage.LinkageType;
|
||||||
import de.steamwar.bausystem.linkage.Linked;
|
import de.steamwar.bausystem.linkage.Linked;
|
||||||
@ -58,6 +59,7 @@ public class LoaderCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register("setup")
|
@Register("setup")
|
||||||
public void setupLoader(Player p) {
|
public void setupLoader(Player p) {
|
||||||
|
if (permissionCheck(p)) {
|
||||||
if (Loader.getLoader(p) != null) {
|
if (Loader.getLoader(p) != null) {
|
||||||
Loader.getLoader(p).setup();
|
Loader.getLoader(p).setup();
|
||||||
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Dein Loader ist nun wieder im Setup");
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Dein Loader ist nun wieder im Setup");
|
||||||
@ -67,9 +69,11 @@ public class LoaderCommand extends SWCommand {
|
|||||||
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Führe dann /" + ColorConfig.HIGHLIGHT + "loader start" + ColorConfig.BASE + " um den Loader zu starten");
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Führe dann /" + ColorConfig.HIGHLIGHT + "loader start" + ColorConfig.BASE + " um den Loader zu starten");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Register("start")
|
@Register("start")
|
||||||
public void startLoader(Player p) {
|
public void startLoader(Player p) {
|
||||||
|
if (permissionCheck(p)) {
|
||||||
Loader loader = Loader.getLoader(p);
|
Loader loader = Loader.getLoader(p);
|
||||||
if (loaderNullCheck(loader, p)) {
|
if (loaderNullCheck(loader, p)) {
|
||||||
return;
|
return;
|
||||||
@ -77,9 +81,11 @@ public class LoaderCommand extends SWCommand {
|
|||||||
loader.start();
|
loader.start();
|
||||||
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Der Loader ist nun aktiviert.");
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Der Loader ist nun aktiviert.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Register("stop")
|
@Register("stop")
|
||||||
public void stopLoader(Player p) {
|
public void stopLoader(Player p) {
|
||||||
|
if (permissionCheck(p)) {
|
||||||
Loader loader = Loader.getLoader(p);
|
Loader loader = Loader.getLoader(p);
|
||||||
if (loaderNullCheck(loader, p)) {
|
if (loaderNullCheck(loader, p)) {
|
||||||
return;
|
return;
|
||||||
@ -87,9 +93,11 @@ public class LoaderCommand extends SWCommand {
|
|||||||
loader.stop();
|
loader.stop();
|
||||||
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Der Loader ist nun gestoppt.");
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Der Loader ist nun gestoppt.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Register("pause")
|
@Register("pause")
|
||||||
public void pauseLoader(Player p) {
|
public void pauseLoader(Player p) {
|
||||||
|
if (permissionCheck(p)) {
|
||||||
Loader loader = Loader.getLoader(p);
|
Loader loader = Loader.getLoader(p);
|
||||||
if (loaderNullCheck(loader, p)) {
|
if (loaderNullCheck(loader, p)) {
|
||||||
return;
|
return;
|
||||||
@ -97,9 +105,11 @@ public class LoaderCommand extends SWCommand {
|
|||||||
loader.pause();
|
loader.pause();
|
||||||
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Der Loader ist nun pausiert.");
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Der Loader ist nun pausiert.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Register("resume")
|
@Register("resume")
|
||||||
public void resumeLoader(Player p) {
|
public void resumeLoader(Player p) {
|
||||||
|
if (permissionCheck(p)) {
|
||||||
Loader loader = Loader.getLoader(p);
|
Loader loader = Loader.getLoader(p);
|
||||||
if (loaderNullCheck(loader, p)) {
|
if (loaderNullCheck(loader, p)) {
|
||||||
return;
|
return;
|
||||||
@ -107,9 +117,11 @@ public class LoaderCommand extends SWCommand {
|
|||||||
loader.resume();
|
loader.resume();
|
||||||
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Der Loader läuft nun weiter.");
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Der Loader läuft nun weiter.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Register("wait")
|
@Register("wait")
|
||||||
public void shotDelayLoader(Player p, int delay) {
|
public void shotDelayLoader(Player p, int delay) {
|
||||||
|
if (permissionCheck(p)) {
|
||||||
if (delay < 1) {
|
if (delay < 1) {
|
||||||
p.sendMessage(BauSystem.PREFIX + ColorConfig.ERROR + "Die Wartezeit ist zu klein");
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.ERROR + "Die Wartezeit ist zu klein");
|
||||||
return;
|
return;
|
||||||
@ -121,9 +133,11 @@ public class LoaderCommand extends SWCommand {
|
|||||||
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Die Schusswartezeit ist nun: " + delay + ", zuvor " + loader.getTicksBetweenShots());
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Die Schusswartezeit ist nun: " + delay + ", zuvor " + loader.getTicksBetweenShots());
|
||||||
loader.setTicksBetweenShots(delay);
|
loader.setTicksBetweenShots(delay);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Register("speed")
|
@Register("speed")
|
||||||
public void speedLoader(Player p, int delay) {
|
public void speedLoader(Player p, int delay) {
|
||||||
|
if (permissionCheck(p)) {
|
||||||
if (delay < 1) {
|
if (delay < 1) {
|
||||||
p.sendMessage(BauSystem.PREFIX + ColorConfig.ERROR + "Die Wartezeit ist zu klein");
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.ERROR + "Die Wartezeit ist zu klein");
|
||||||
return;
|
return;
|
||||||
@ -135,9 +149,11 @@ public class LoaderCommand extends SWCommand {
|
|||||||
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "die Setzwartezeit ist nun: " + delay + ", zuvor " + loader.getTicksBetweenBlocks());
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "die Setzwartezeit ist nun: " + delay + ", zuvor " + loader.getTicksBetweenBlocks());
|
||||||
loader.setTicksBetweenShots(delay);
|
loader.setTicksBetweenShots(delay);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Register("undo")
|
@Register("undo")
|
||||||
public void undoLast(Player p) {
|
public void undoLast(Player p) {
|
||||||
|
if (permissionCheck(p)) {
|
||||||
Loader loader = Loader.getLoader(p);
|
Loader loader = Loader.getLoader(p);
|
||||||
if (loaderNullCheck(loader, p)) {
|
if (loaderNullCheck(loader, p)) {
|
||||||
return;
|
return;
|
||||||
@ -145,9 +161,11 @@ public class LoaderCommand extends SWCommand {
|
|||||||
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Undo erfolgreich.");
|
p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Undo erfolgreich.");
|
||||||
loader.undo();
|
loader.undo();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Register("clear")
|
@Register("clear")
|
||||||
public void clearLoader(Player p) {
|
public void clearLoader(Player p) {
|
||||||
|
if (permissionCheck(p)) {
|
||||||
Loader loader = Loader.getLoader(p);
|
Loader loader = Loader.getLoader(p);
|
||||||
if (loaderNullCheck(loader, p)) {
|
if (loaderNullCheck(loader, p)) {
|
||||||
return;
|
return;
|
||||||
@ -155,3 +173,12 @@ public class LoaderCommand extends SWCommand {
|
|||||||
loader.clear();
|
loader.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean permissionCheck(Player player) {
|
||||||
|
if (!Permission.hasPermission(player, Permission.WORLD)) {
|
||||||
|
player.sendMessage(BauSystem.PREFIX + ColorConfig.DISABLE + "Du darfst hier nicht den Detonator nutzen");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren