From 50ee2727a2d745aba7f9b47898407180e46f74da Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Mon, 16 Aug 2021 18:23:13 +0200 Subject: [PATCH] bitwise --- .../com/volmit/iris/core/decrees/DecIris.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/main/java/com/volmit/iris/core/decrees/DecIris.java b/src/main/java/com/volmit/iris/core/decrees/DecIris.java index 3428761f2..86991645c 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIris.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIris.java @@ -23,6 +23,7 @@ import com.volmit.iris.core.IrisSettings; import com.volmit.iris.util.decree.DecreeExecutor; import com.volmit.iris.util.decree.annotations.Decree; import com.volmit.iris.util.decree.annotations.Param; +import com.volmit.iris.util.format.C; @Decree(name = "irisd", aliases = {"ird"}, description = "Basic Command") public class DecIris implements DecreeExecutor @@ -49,4 +50,31 @@ public class DecIris implements DecreeExecutor IrisSettings.get().forceSave(); sender().sendMessage("Aura Spins updated to " + h + " " + s + " " + b); } + + @Decree(description = "Bitwise calculations") + public void bitwise( + @Param(name = "value1", description = "The first value to run calculations on") + int val1, + @Param(name = "operator", description = "The operator: | & ^ >> << %") + String operator, + @Param(name = "value2", description = "The second value to run calculations on") + int val2 + ){ + Integer v = null; + switch(operator) { + case "|" -> v = val1 | val2; + case "&" -> v = val1 & val2; + case "^" -> v = val1 ^ val2; + case "%" -> v = val1 % val2; + case ">>" -> v = val1 >> val2; + case "<<" -> v = val1 << val2; + }; + if (v == null){ + sender().sendMessage(C.RED + "The operator you entered: (" + operator + ") is invalid!"); + return; + } + sender().sendMessage(C.GREEN + "" + val1 + " " + operator + " " + val2 + " => " + v); + } + + }