From 55c4e9635a3d09e012a76c05c816510d85ae74e5 Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Thu, 22 Jul 2021 20:07:18 -0400 Subject: [PATCH] Commands --- .../volmit/iris/core/command/CommandIris.java | 3 + .../iris/core/command/CommandIrisBitwise.java | 110 ++++++++++++++++++ .../core/command/world/CommandIrisVerify.java | 5 + .../volmit/iris/engine/data/mca/Chunk.java | 4 + 4 files changed, 122 insertions(+) create mode 100644 src/main/java/com/volmit/iris/core/command/CommandIrisBitwise.java diff --git a/src/main/java/com/volmit/iris/core/command/CommandIris.java b/src/main/java/com/volmit/iris/core/command/CommandIris.java index d69aa10e3..3c3229c31 100644 --- a/src/main/java/com/volmit/iris/core/command/CommandIris.java +++ b/src/main/java/com/volmit/iris/core/command/CommandIris.java @@ -60,6 +60,9 @@ public class CommandIris extends MortarCommand { @Command private CommandIrisUpdateWorld updateWorld; + @Command + private CommandIrisBitwise bitwise; + @Command private CommandIrisWhat what; diff --git a/src/main/java/com/volmit/iris/core/command/CommandIrisBitwise.java b/src/main/java/com/volmit/iris/core/command/CommandIrisBitwise.java new file mode 100644 index 000000000..23c7ff576 --- /dev/null +++ b/src/main/java/com/volmit/iris/core/command/CommandIrisBitwise.java @@ -0,0 +1,110 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.core.command; + +import com.volmit.iris.Iris; +import com.volmit.iris.util.collection.KList; +import com.volmit.iris.util.format.C; +import com.volmit.iris.util.plugin.MortarCommand; +import com.volmit.iris.util.plugin.VolmitSender; +import com.volmit.iris.util.scheduling.J; + +import java.util.Arrays; + +public class CommandIrisBitwise extends MortarCommand { + public CommandIrisBitwise() { + super("bitwise", "bits", "bw"); + requiresPermission(Iris.perm.studio); + setDescription("Run bitwise calculations"); + setCategory("Studio"); + } + + + @Override + public void addTabOptions(VolmitSender sender, String[] args, KList list) { + + } + + @Override + public boolean handle(VolmitSender sender, String[] args) { + if(args.length != 3) + { + sender.sendMessage("/iris bw " + getArgsUsage()); + } + + if(args[0].contains(",")) + { + KList r = new KList<>(); + + for(String i : args[0].split("\\Q,\\E")) + { + int a = Integer.valueOf(i); + String op = args[1]; + int b = Integer.valueOf(args[2]); + int v = 0; + + switch(op) + { + case "|": v = a | b; + case "&": v = a & b; + case "^": v = a ^ b; + case "%": v = a ^ b; + case ">>": v = a >> b; + case "<<": v = a << b; + default: { + sender.sendMessage("Error Invalid operation"); + }; + }; + + r.add(v); + sender.sendMessage("Result: " + r.toString(",")); + } + } + + else + { + int a = Integer.valueOf(args[0]); + String op = args[1]; + int b = Integer.valueOf(args[2]); + int v = 0; + + switch(op) + { + case "|": v = a | b; + case "&": v = a & b; + case "^": v = a ^ b; + case "%": v = a ^ b; + case ">>": v = a >> b; + case "<<": v = a << b; + default: { + sender.sendMessage("Error Invalid operation"); + }; + }; + + sender.sendMessage("Result: " + v); + } + + return true; + } + + @Override + protected String getArgsUsage() { + return " [|,&,^,>>,<<,%] "; + } +} diff --git a/src/main/java/com/volmit/iris/core/command/world/CommandIrisVerify.java b/src/main/java/com/volmit/iris/core/command/world/CommandIrisVerify.java index ab0f56e02..f6ecd886b 100644 --- a/src/main/java/com/volmit/iris/core/command/world/CommandIrisVerify.java +++ b/src/main/java/com/volmit/iris/core/command/world/CommandIrisVerify.java @@ -78,6 +78,11 @@ public class CommandIrisVerify extends MortarCommand { { sender.sendMessage("Found Missing Chunk " + i.getName() + ", chunk #" + j + "," + k + " (see " + (((rx << 5)<<4)+(j<<4)) + "," + (((rz << 5)<<4)+(k<<4))); } + + if(c.sectionCount() == 0) + { + sender.sendMessage("Found Missing Chunk (valid, but 0 sections) " + i.getName() + ", chunk #" + j + "," + k + " (see " + (((rx << 5)<<4)+(j<<4)) + "," + (((rz << 5)<<4)+(k<<4))); + } } } } catch (IOException ioException) { diff --git a/src/main/java/com/volmit/iris/engine/data/mca/Chunk.java b/src/main/java/com/volmit/iris/engine/data/mca/Chunk.java index 060a169a7..eea46ca36 100644 --- a/src/main/java/com/volmit/iris/engine/data/mca/Chunk.java +++ b/src/main/java/com/volmit/iris/engine/data/mca/Chunk.java @@ -681,4 +681,8 @@ public class Chunk { level.put("Sections", sections); return data; } + + public int sectionCount() { + return sections.length; + } }