diff --git a/build.gradle b/build.gradle index 7f62a12b7..5ce0f06c6 100644 --- a/build.gradle +++ b/build.gradle @@ -32,7 +32,7 @@ plugins { } group 'com.volmit.iris' -version '1.6.2' +version '1.6.3' def apiVersion = '1.17' def name = 'Iris' def main = 'com.volmit.iris.Iris' diff --git a/src/main/java/com/volmit/iris/Iris.java b/src/main/java/com/volmit/iris/Iris.java index 623e4caf5..bfca9c085 100644 --- a/src/main/java/com/volmit/iris/Iris.java +++ b/src/main/java/com/volmit/iris/Iris.java @@ -250,7 +250,7 @@ public class Iris extends VolmitPlugin implements Listener { @Override public String getTag(String subTag) { - return C.BOLD + "" + C.DARK_GRAY + "[" + C.BOLD + "" + C.GREEN + "Iris" + C.BOLD + C.DARK_GRAY + "]" + C.RESET + "" + C.GRAY + ": "; + return C.BOLD + "" + C.DARK_GRAY + "[" + C.BOLD + "" + C.IRIS + "Iris" + C.BOLD + C.DARK_GRAY + "]" + C.RESET + "" + C.GRAY + ": "; } private void checkConfigHotload() { @@ -423,7 +423,7 @@ public class Iris extends VolmitPlugin implements Listener { } public void imsg(CommandSender s, String msg) { - s.sendMessage(C.GREEN + "[" + C.DARK_GRAY + "Iris" + C.GREEN + "]" + C.GRAY + ": " + msg); + s.sendMessage(C.IRIS + "[" + C.DARK_GRAY + "Iris" + C.IRIS + "]" + C.GRAY + ": " + msg); } @@ -442,9 +442,16 @@ public class Iris extends VolmitPlugin implements Listener { public static void msg(String string) { try { sender.sendMessage(string); - } catch (Throwable e) { - System.out.println(string); - Iris.reportError(e); + } catch (Throwable ignored) { + try + { + System.out.println(string); + } + + catch(Throwable ignored1) + { + + } } } @@ -537,7 +544,7 @@ public class Iris extends VolmitPlugin implements Listener { } public static void success(String string) { - msg(C.GREEN + string); + msg(C.IRIS + string); } public static void info(String string) { @@ -557,9 +564,9 @@ public class Iris extends VolmitPlugin implements Listener { // @NoArgsConstructor String padd = Form.repeat(" ", 8); String padd2 = Form.repeat(" ", 4); - String[] info = {"", "", "", "", "", padd2 + C.GREEN + " Iris", padd2 + C.GRAY + " by " + C.randomColor() + "V" + C.randomColor() + "o" + C.randomColor() + "l" + C.randomColor() + "m" + C.randomColor() + "i" + C.randomColor() + "t" + C.randomColor() + "S" + C.randomColor() + "o" + C.randomColor() + "f" + C.randomColor() + "t" + C.randomColor() + "w" + C.randomColor() + "a" + C.randomColor() + "r" + C.randomColor() + "e", padd2 + C.GRAY + " v" + getDescription().getVersion(), + String[] info = {"", "", "", "", "", padd2 + C.IRIS + " Iris", padd2 + C.GRAY + " by " + "Volmit Software", padd2 + C.GRAY + " v" + C.IRIS + getDescription().getVersion(), }; - String[] splash = {padd + C.GRAY + " @@@@@@@@@@@@@@" + C.DARK_GRAY + "@@@", padd + C.GRAY + " @@&&&&&&&&&" + C.DARK_GRAY + "&&&&&&" + C.GREEN + " .(((()))). ", padd + C.GRAY + "@@@&&&&&&&&" + C.DARK_GRAY + "&&&&&" + C.GREEN + " .((((((())))))). ", padd + C.GRAY + "@@@&&&&&" + C.DARK_GRAY + "&&&&&&&" + C.GREEN + " ((((((((())))))))) " + C.GRAY + " @", padd + C.GRAY + "@@@&&&&" + C.DARK_GRAY + "@@@@@&" + C.GREEN + " ((((((((-))))))))) " + C.GRAY + " @@", padd + C.GRAY + "@@@&&" + C.GREEN + " ((((((({ })))))))) " + C.GRAY + " &&@@@", padd + C.GRAY + "@@" + C.GREEN + " ((((((((-))))))))) " + C.DARK_GRAY + "&@@@@@" + C.GRAY + "&&&&@@@", padd + C.GRAY + "@" + C.GREEN + " ((((((((())))))))) " + C.DARK_GRAY + "&&&&&" + C.GRAY + "&&&&&&&@@@", padd + C.GRAY + "" + C.GREEN + " '((((((()))))))' " + C.DARK_GRAY + "&&&&&" + C.GRAY + "&&&&&&&&@@@", padd + C.GRAY + "" + C.GREEN + " '(((())))' " + C.DARK_GRAY + "&&&&&&&&" + C.GRAY + "&&&&&&&@@", padd + C.GRAY + " " + C.DARK_GRAY + "@@@" + C.GRAY + "@@@@@@@@@@@@@@" + String[] splash = {padd + C.GRAY + " @@@@@@@@@@@@@@" + C.DARK_GRAY + "@@@", padd + C.GRAY + " @@&&&&&&&&&" + C.DARK_GRAY + "&&&&&&" + C.IRIS + " .(((()))). ", padd + C.GRAY + "@@@&&&&&&&&" + C.DARK_GRAY + "&&&&&" + C.IRIS + " .((((((())))))). ", padd + C.GRAY + "@@@&&&&&" + C.DARK_GRAY + "&&&&&&&" + C.IRIS + " ((((((((())))))))) " + C.GRAY + " @", padd + C.GRAY + "@@@&&&&" + C.DARK_GRAY + "@@@@@&" + C.IRIS + " ((((((((-))))))))) " + C.GRAY + " @@", padd + C.GRAY + "@@@&&" + C.IRIS + " ((((((({ })))))))) " + C.GRAY + " &&@@@", padd + C.GRAY + "@@" + C.IRIS + " ((((((((-))))))))) " + C.DARK_GRAY + "&@@@@@" + C.GRAY + "&&&&@@@", padd + C.GRAY + "@" + C.IRIS + " ((((((((())))))))) " + C.DARK_GRAY + "&&&&&" + C.GRAY + "&&&&&&&@@@", padd + C.GRAY + "" + C.IRIS + " '((((((()))))))' " + C.DARK_GRAY + "&&&&&" + C.GRAY + "&&&&&&&&@@@", padd + C.GRAY + "" + C.IRIS + " '(((())))' " + C.DARK_GRAY + "&&&&&&&&" + C.GRAY + "&&&&&&&@@", padd + C.GRAY + " " + C.DARK_GRAY + "@@@" + C.GRAY + "@@@@@@@@@@@@@@" }; //@done Iris.info("Server type & version: " + Bukkit.getVersion()); diff --git a/src/main/java/com/volmit/iris/core/IrisSettings.java b/src/main/java/com/volmit/iris/core/IrisSettings.java index 1c87528fa..ed02347d9 100644 --- a/src/main/java/com/volmit/iris/core/IrisSettings.java +++ b/src/main/java/com/volmit/iris/core/IrisSettings.java @@ -107,6 +107,9 @@ public class IrisSettings { public boolean pluginMetrics = true; public boolean splashLogoStartup = true; public String forceMainWorld = ""; + public int spinh = -20; + public int spins = 7; + public int spinb = 8; } @Data diff --git a/src/main/java/com/volmit/iris/core/WandManager.java b/src/main/java/com/volmit/iris/core/WandManager.java index ea683439a..86136dfed 100644 --- a/src/main/java/com/volmit/iris/core/WandManager.java +++ b/src/main/java/com/volmit/iris/core/WandManager.java @@ -64,7 +64,7 @@ public class WandManager implements Listener { for (Player i : Bukkit.getOnlinePlayers()) { tick(i); } - }, 0); + }, 5); } public void tick(Player p) { 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 dfdee227d..7e3d37420 100644 --- a/src/main/java/com/volmit/iris/core/command/CommandIris.java +++ b/src/main/java/com/volmit/iris/core/command/CommandIris.java @@ -75,6 +75,9 @@ public class CommandIris extends MortarCommand { @Command private CommandIrisReload reload; + @Command + private CommandIrisAura aura; + public CommandIris() { super("iris", "ir", "irs"); requiresPermission(Iris.perm); diff --git a/src/main/java/com/volmit/iris/core/command/CommandIrisAura.java b/src/main/java/com/volmit/iris/core/command/CommandIrisAura.java new file mode 100644 index 000000000..24b49240b --- /dev/null +++ b/src/main/java/com/volmit/iris/core/command/CommandIrisAura.java @@ -0,0 +1,66 @@ +/* + * 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.core.IrisSettings; +import com.volmit.iris.util.collection.KList; +import com.volmit.iris.util.plugin.MortarCommand; +import com.volmit.iris.util.plugin.VolmitSender; + +public class CommandIrisAura extends MortarCommand { + public CommandIrisAura() { + super("aura", "au"); + requiresPermission(Iris.perm.studio); + setDescription("Set aura spins"); + setCategory("Studio"); + } + + @Override + public void addTabOptions(VolmitSender sender, String[] args, KList list) { + + } + + @Override + public boolean handle(VolmitSender sender, String[] args) { + try + { + int h = Integer.parseInt(args[0]); + int s = Integer.parseInt(args[1]); + int b = Integer.parseInt(args[2]); + IrisSettings.get().getGeneral().setSpinh(h); + IrisSettings.get().getGeneral().setSpins(s); + IrisSettings.get().getGeneral().setSpinb(b); + IrisSettings.get().forceSave(); + sender.sendMessage("Aura Spins updated to " + h + " " + s + " " + b); + } + + catch(Throwable b) + { + sender.sendMessage(getArgsUsage()); + } + + return true; + } + + @Override + protected String getArgsUsage() { + return " "; + } +} diff --git a/src/main/java/com/volmit/iris/util/format/C.java b/src/main/java/com/volmit/iris/util/format/C.java index f69f47997..878291ca9 100644 --- a/src/main/java/com/volmit/iris/util/format/C.java +++ b/src/main/java/com/volmit/iris/util/format/C.java @@ -21,7 +21,11 @@ package com.volmit.iris.util.format; import com.volmit.iris.Iris; import com.volmit.iris.core.nms.INMS; import com.volmit.iris.engine.object.biome.IrisBiomeCustom; +import com.volmit.iris.util.math.M; import com.volmit.iris.util.plugin.VolmitSender; +import net.kyori.adventure.text.minimessage.transformation.inbuild.FontTransformation; +import net.md_5.bungee.api.chat.BaseComponent; +import net.md_5.bungee.api.chat.TextComponent; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.Color; @@ -139,6 +143,14 @@ public enum C { return net.md_5.bungee.api.ChatColor.GREEN; } }, + + IRIS("<#1bb19e>", 'a', 0xA) { + @Override + public net.md_5.bungee.api.ChatColor asBungee() { + return net.md_5.bungee.api.ChatColor.GREEN; + } + }, + /** * Represents aqua */ @@ -238,8 +250,10 @@ public enum C { public net.md_5.bungee.api.ChatColor asBungee() { return net.md_5.bungee.api.ChatColor.RESET; } - }; + }, + + ; /** * The special character which prefixes all chat colour codes. Use this if you * need to dynamically convert colour codes from your custom format. @@ -263,6 +277,7 @@ public enum C { static { chatHexMap.put(C.BLACK, "#000000"); chatHexMap.put(C.DARK_BLUE, "#0000AA"); + chatHexMap.put(C.IRIS, "#1bb19e"); chatHexMap.put(C.DARK_GREEN, "#00AA00"); chatHexMap.put(C.DARK_AQUA, "#00AAAA"); chatHexMap.put(C.DARK_RED, "#AA0000"); @@ -332,12 +347,12 @@ public enum C { public static float[] spin(float[] c, int shift) { - return new float[]{spin(c[0], shift),spin(c[1], shift),spin(c[2], shift)}; + return new float[]{spin(c[0], shift),spinc(c[1], shift),spinc(c[2], shift)}; } public static float[] spin(float[] c, int a,int b, int d) { - return new float[]{spin(c[0], a),spin(c[1], b),spin(c[2], d)}; + return new float[]{spin(c[0], a),spinc(c[1], b),spinc(c[2], d)}; } public static float spin(float c, int shift) @@ -346,7 +361,26 @@ public enum C { return g < 0 ? 1f - g : g; } - public static String aura(String msg, int hrad, int srad, int vrad) { + public static float spinc(float c, int shift) + { + float g = ((((int)Math.floor(c * 255)) + shift)) / 255F; + return Math.max(0f, Math.min(g, 1f)); + } + + public static java.awt.Color spin(java.awt.Color c, int h, int s, int b) + { + float[] hsb = java.awt.Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null); + hsb = spin(hsb, h, s, b); + return java.awt.Color.getHSBColor(hsb[0], hsb[1], hsb[2]); + } + + public static String spinToHex(C color, int h, int s, int b) + { + return "#" + Integer.toHexString(spin(color.awtColor(), h, s, b).getRGB()).substring(2); + } + + public static String aura(String s, int hrad, int srad, int vrad) { + String msg = compress(s); StringBuilder b = new StringBuilder(); boolean c = false; @@ -360,8 +394,11 @@ public enum C { if(hrad != 0 || srad != 0 || vrad != 0) { - //TODO: Spin to win - b.append(C.getByChar(i).token); + b.append(""); } else @@ -384,6 +421,11 @@ public enum C { return b.toString(); } + public static String compress(String c) + { + return BaseComponent.toLegacyText(TextComponent.fromLegacyText(c)); + } + public net.md_5.bungee.api.ChatColor asBungee() { return net.md_5.bungee.api.ChatColor.RESET; } @@ -399,7 +441,7 @@ public enum C { @Override public String toString() { - return toString; + return intCode == -1 ? token : toString; } /** @@ -413,6 +455,11 @@ public enum C { return chatToHex(this); } + public java.awt.Color awtColor() + { + return java.awt.Color.decode(hex()); + } + /** * Checks if this code is a format code as opposed to a color code. * @@ -638,6 +685,7 @@ public enum C { case RED -> (byte) 12; case WHITE -> (byte) 15; case YELLOW -> (byte) 14; + default -> (byte) 15; }; } @@ -657,6 +705,7 @@ public enum C { case GREEN -> (byte) 5; case LIGHT_PURPLE -> (byte) 2; case WHITE -> (byte) 0; + default -> (byte) 15; }; } diff --git a/src/main/java/com/volmit/iris/util/plugin/MortarCommand.java b/src/main/java/com/volmit/iris/util/plugin/MortarCommand.java index 04db9e6f9..ccb29caa7 100644 --- a/src/main/java/com/volmit/iris/util/plugin/MortarCommand.java +++ b/src/main/java/com/volmit/iris/util/plugin/MortarCommand.java @@ -91,7 +91,7 @@ public abstract class MortarCommand implements ICommand { b = true; - sender.sendMessage(C.GREEN + i.getNode() + " " + C.WHITE + i.getArgsUsage() + C.GRAY + " - " + i.getDescription()); + sender.sendMessage("" + C.GREEN + i.getNode() + " " + C.WHITE + "" + i.getArgsUsage() + C.GRAY + " - " + i.getDescription()); } if (!b) { diff --git a/src/main/java/com/volmit/iris/util/plugin/VolmitSender.java b/src/main/java/com/volmit/iris/util/plugin/VolmitSender.java index 8a8f8da12..735734f73 100644 --- a/src/main/java/com/volmit/iris/util/plugin/VolmitSender.java +++ b/src/main/java/com/volmit/iris/util/plugin/VolmitSender.java @@ -19,6 +19,7 @@ package com.volmit.iris.util.plugin; import com.volmit.iris.Iris; +import com.volmit.iris.core.IrisSettings; import com.volmit.iris.util.format.C; import lombok.Getter; import lombok.Setter; @@ -187,10 +188,18 @@ public class VolmitSender implements CommandSender { @Override public void sendMessage(String message) { - String t = C.translateAlternateColorCodes('&', getTag() + message); - String a = C.aura(t, 12, 0, 0); - Component c = MiniMessage.get().parse(a); - Iris.audiences.sender(s).sendMessage(c); + try + { + String t = C.translateAlternateColorCodes('&', getTag() + message); + String a = C.aura(t, IrisSettings.get().getGeneral().getSpinh(), IrisSettings.get().getGeneral().getSpins(), IrisSettings.get().getGeneral().getSpinb()); + Component c = MiniMessage.get().parse(a); + Iris.audiences.sender(s).sendMessage(c); + } + + catch(Throwable e) + { + s.sendMessage(C.translateAlternateColorCodes('&', getTag() + message)); + } } @Override