From db8dfa79bc4cdbc648cb6f3f712e8b0649bca0fe Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 9 Jun 2019 23:32:49 +0200 Subject: [PATCH 01/18] Some prep for 1.14 --- BuildConfigUpdater/BuildConfigUpdater.iml | 1 + .../buttondevteam/lib/TBMCChatEventBase.java | 11 ++- .../lib/TBMCChatPreprocessEvent.java | 1 + .../java/buttondevteam/lib/TBMCCoreAPI.java | 61 +++++++------- .../buttondevteam/lib/TBMCExceptionEvent.java | 79 ++++++++++--------- 5 files changed, 86 insertions(+), 67 deletions(-) diff --git a/BuildConfigUpdater/BuildConfigUpdater.iml b/BuildConfigUpdater/BuildConfigUpdater.iml index 098cd57..d0f3587 100644 --- a/BuildConfigUpdater/BuildConfigUpdater.iml +++ b/BuildConfigUpdater/BuildConfigUpdater.iml @@ -19,6 +19,7 @@ + diff --git a/ButtonCore/src/main/java/buttondevteam/lib/TBMCChatEventBase.java b/ButtonCore/src/main/java/buttondevteam/lib/TBMCChatEventBase.java index d30e12e..1ac02b6 100755 --- a/ButtonCore/src/main/java/buttondevteam/lib/TBMCChatEventBase.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/TBMCChatEventBase.java @@ -3,7 +3,6 @@ package buttondevteam.lib; import buttondevteam.core.component.channel.Channel; import lombok.Getter; import lombok.NonNull; -import lombok.RequiredArgsConstructor; import lombok.Setter; import org.bukkit.command.CommandSender; import org.bukkit.event.Cancellable; @@ -12,7 +11,6 @@ import org.bukkit.event.Event; import javax.annotation.Nullable; @Getter -@RequiredArgsConstructor public abstract class TBMCChatEventBase extends Event implements Cancellable { private final Channel channel; private @NonNull String message; @@ -26,6 +24,15 @@ public abstract class TBMCChatEventBase extends Event implements Cancellable { */ private final String groupID; + @java.beans.ConstructorProperties({"channel", "message", "score", "groupID"}) + public TBMCChatEventBase(Channel channel, String message, int score, String groupID) { + super(true); + this.channel = channel; + this.message = message; + this.score = score; + this.groupID = groupID; + } + /** * Note: Errors are sent to the sender automatically */ diff --git a/ButtonCore/src/main/java/buttondevteam/lib/TBMCChatPreprocessEvent.java b/ButtonCore/src/main/java/buttondevteam/lib/TBMCChatPreprocessEvent.java index 6ff3bda..9a512ee 100755 --- a/ButtonCore/src/main/java/buttondevteam/lib/TBMCChatPreprocessEvent.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/TBMCChatPreprocessEvent.java @@ -27,6 +27,7 @@ public class TBMCChatPreprocessEvent extends Event implements Cancellable { private boolean cancelled; public TBMCChatPreprocessEvent(CommandSender sender, Channel channel, String message) { + super(true); this.sender = sender; this.channel = channel; this.message = message; // TODO: Message object with data? diff --git a/ButtonCore/src/main/java/buttondevteam/lib/TBMCCoreAPI.java b/ButtonCore/src/main/java/buttondevteam/lib/TBMCCoreAPI.java index a313fe0..6b193aa 100755 --- a/ButtonCore/src/main/java/buttondevteam/lib/TBMCCoreAPI.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/TBMCCoreAPI.java @@ -82,36 +82,41 @@ public class TBMCCoreAPI { } public static void SendException(String sourcemsg, Throwable e, boolean debugPotato) { - SendUnsentExceptions(); - TBMCExceptionEvent event = new TBMCExceptionEvent(sourcemsg, e); - Bukkit.getPluginManager().callEvent(event); - synchronized (exceptionsToSend) { - if (!event.isHandled()) - exceptionsToSend.put(sourcemsg, e); - } - Bukkit.getLogger().warning(sourcemsg); - e.printStackTrace(); - if (debugPotato) { - List devsOnline = new ArrayList<>(); - for (Player player : Bukkit.getOnlinePlayers()) { - if (coders.contains(player.getName())) { - devsOnline.add(player); - } - } - if (!devsOnline.isEmpty()) { - DebugPotato potato = new DebugPotato() - .setMessage(new String[]{ // - "§b§o" + e.getClass().getSimpleName(), // - "§c§o" + sourcemsg, // - "§a§oFind a dev to fix this issue"}) - .setType(e instanceof IOException ? "Throwable Potato" - : e instanceof ClassCastException ? "Squished Potato" - : e instanceof NullPointerException ? "Plain Potato" - : e instanceof StackOverflowError ? "Chips" : "Error Potato"); - for (Player dev : devsOnline) { - potato.Send(dev); + try { + SendUnsentExceptions(); + TBMCExceptionEvent event = new TBMCExceptionEvent(sourcemsg, e); + Bukkit.getPluginManager().callEvent(event); + synchronized (exceptionsToSend) { + if (!event.isHandled()) + exceptionsToSend.put(sourcemsg, e); + } + Bukkit.getLogger().warning(sourcemsg); + e.printStackTrace(); + if (debugPotato) { + List devsOnline = new ArrayList<>(); + for (Player player : Bukkit.getOnlinePlayers()) { + if (coders.contains(player.getName())) { + devsOnline.add(player); + } + } + if (!devsOnline.isEmpty()) { + DebugPotato potato = new DebugPotato() + .setMessage(new String[]{ // + "§b§o" + e.getClass().getSimpleName(), // + "§c§o" + sourcemsg, // + "§a§oFind a dev to fix this issue"}) + .setType(e instanceof IOException ? "Throwable Potato" + : e instanceof ClassCastException ? "Squished Potato" + : e instanceof NullPointerException ? "Plain Potato" + : e instanceof StackOverflowError ? "Chips" : "Error Potato"); + for (Player dev : devsOnline) { + potato.Send(dev); + } } } + } catch (Exception ee) { + System.err.println("Failed to send exception!"); + ee.printStackTrace(); } } diff --git a/ButtonCore/src/main/java/buttondevteam/lib/TBMCExceptionEvent.java b/ButtonCore/src/main/java/buttondevteam/lib/TBMCExceptionEvent.java index 90c4185..44a93b1 100755 --- a/ButtonCore/src/main/java/buttondevteam/lib/TBMCExceptionEvent.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/TBMCExceptionEvent.java @@ -1,37 +1,42 @@ -package buttondevteam.lib; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - -/** - *

- * This event gets called (ideally) each time an exception occurs in a TBMC plugin. To call it, use {@link TBMCCoreAPI#SendException(String, Throwable)}. - *

- * - * @author Norbi - * - */ -@Getter -@RequiredArgsConstructor -public class TBMCExceptionEvent extends Event { - private static final HandlerList handlers = new HandlerList(); - - private final String sourceMessage; - private final Throwable exception; - private boolean handled; - - public void setHandled() { - handled = true; - } - - @Override - public HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() { - return handlers; - } -} +package buttondevteam.lib; + +import lombok.Getter; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +/** + *

+ * This event gets called (ideally) each time an exception occurs in a TBMC plugin. To call it, use {@link TBMCCoreAPI#SendException(String, Throwable)}. + *

+ * + * @author Norbi + * + */ +@Getter +public class TBMCExceptionEvent extends Event { + private static final HandlerList handlers = new HandlerList(); + + private final String sourceMessage; + private final Throwable exception; + private boolean handled; + + @java.beans.ConstructorProperties({"sourceMessage", "exception"}) + public TBMCExceptionEvent(String sourceMessage, Throwable exception) { + super(true); + this.sourceMessage = sourceMessage; + this.exception = exception; + } + + public void setHandled() { + handled = true; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} From a39fd083be78326a2e2d55b9b752395fc0664507 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 8 Jul 2019 01:56:25 +0200 Subject: [PATCH 02/18] Added support for cmd tabcomplete --- BuildConfigUpdater/BuildConfigUpdater.iml | 2 + ButtonCore/pom.xml | 4 +- .../java/buttondevteam/core/MainPlugin.java | 1 + .../buttondevteam/lib/TBMCExceptionEvent.java | 3 +- .../java/buttondevteam/lib/chat/Command2.java | 6 +- .../buttondevteam/lib/chat/Command2MC.java | 126 +++++++++++++++++- .../lib/player/TBMCPlayerGetInfoEvent.java | 1 + 7 files changed, 135 insertions(+), 8 deletions(-) diff --git a/BuildConfigUpdater/BuildConfigUpdater.iml b/BuildConfigUpdater/BuildConfigUpdater.iml index d0f3587..15937e7 100644 --- a/BuildConfigUpdater/BuildConfigUpdater.iml +++ b/BuildConfigUpdater/BuildConfigUpdater.iml @@ -20,6 +20,8 @@ + + diff --git a/ButtonCore/pom.xml b/ButtonCore/pom.xml index ed35499..db16155 100755 --- a/ButtonCore/pom.xml +++ b/ButtonCore/pom.xml @@ -111,7 +111,7 @@ --> ess-repo - http://repo.ess3.net/content/repositories/essrel/ + https://ci.ender.zone/plugin/repository/everything/ Votifier @@ -209,4 +209,4 @@ scm:git:https://github.com/TBMCPlugins/mvn-repo.git scm:git:https://github.com/TBMCPlugins/mvn-repo.git - \ No newline at end of file + diff --git a/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java b/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java index 2f29b6e..5c4463f 100755 --- a/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java +++ b/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java @@ -97,6 +97,7 @@ public class MainPlugin extends ButtonPlugin { getCommand2MC().registerCommand(new ComponentCommand()); getCommand2MC().registerCommand(new ThorpeCommand()); TBMCCoreAPI.RegisterEventsForExceptions(new PlayerListener(), this); + TBMCCoreAPI.RegisterEventsForExceptions(getCommand2MC(), this); ChromaGamerBase.addConverter(commandSender -> Optional.ofNullable(commandSender instanceof ConsoleCommandSender || commandSender instanceof BlockCommandSender ? TBMCPlayer.getPlayer(new UUID(0, 0), TBMCPlayer.class) : null)); //Console & cmdblocks ChromaGamerBase.addConverter(sender -> Optional.ofNullable(sender instanceof Player diff --git a/ButtonCore/src/main/java/buttondevteam/lib/TBMCExceptionEvent.java b/ButtonCore/src/main/java/buttondevteam/lib/TBMCExceptionEvent.java index 44a93b1..974a52f 100755 --- a/ButtonCore/src/main/java/buttondevteam/lib/TBMCExceptionEvent.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/TBMCExceptionEvent.java @@ -1,6 +1,7 @@ package buttondevteam.lib; import lombok.Getter; +import org.bukkit.Bukkit; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -22,7 +23,7 @@ public class TBMCExceptionEvent extends Event { @java.beans.ConstructorProperties({"sourceMessage", "exception"}) public TBMCExceptionEvent(String sourceMessage, Throwable exception) { - super(true); + super(!Bukkit.isPrimaryThread()); this.sourceMessage = sourceMessage; this.exception = exception; } diff --git a/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2.java b/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2.java index 020bc84..d2851fe 100644 --- a/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2.java @@ -109,7 +109,7 @@ public abstract class Command2 public final String errormsg; } - private HashMap> subcommands = new HashMap<>(); + protected HashMap> subcommands = new HashMap<>(); private HashMap, ParamConverter> paramConverters = new HashMap<>(); private ArrayList commandHelp = new ArrayList<>(); //Mainly needed by Discord @@ -321,4 +321,8 @@ public abstract class Command2 if (scmd == null) return null; return scmd.helpText; } + + /*public Set getAllSubcommands() { + return Collections.unmodifiableSet(subcommands.keySet()); + }*/ } diff --git a/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2MC.java b/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2MC.java index 3a46491..aac9cc9 100644 --- a/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2MC.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2MC.java @@ -5,16 +5,22 @@ import lombok.experimental.var; import lombok.val; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.server.TabCompleteEvent; import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionDefault; import java.lang.annotation.Annotation; import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.HashMap; import java.util.UUID; import java.util.function.Function; -public class Command2MC extends Command2 { +public class Command2MC extends Command2 implements Listener { @Override public void registerCommand(ICommand2MC command) { super.registerCommand(command, '/'); @@ -36,7 +42,11 @@ public class Command2MC extends Command2 { @Override public boolean hasPermission(Command2MCSender sender, ICommand2MC command, Method method) { - if (sender.getSender() instanceof ConsoleCommandSender) return true; //Always allow the console + return hasPermission(sender.getSender(), command, method); + } + + public boolean hasPermission(CommandSender sender, ICommand2MC command, Method method) { + if (sender instanceof ConsoleCommandSender) return true; //Always allow the console String pg; boolean p = true; String[] perms = { @@ -47,8 +57,8 @@ public class Command2MC extends Command2 { for (String perm : perms) { if (perm != null) { if (p) { //Use OfflinePlayer to avoid fetching player data - if (sender.getSender() instanceof OfflinePlayer) - p = MainPlugin.permission.playerHas(null, (OfflinePlayer) sender.getSender(), perm); + if (sender instanceof OfflinePlayer) + p = MainPlugin.permission.playerHas(null, (OfflinePlayer) sender, perm); else p = MainPlugin.permission.playerHas(null, Bukkit.getOfflinePlayer(new UUID(0, 0)), perm); } else break; //If any of the permissions aren't granted then don't allow @@ -109,4 +119,112 @@ public class Command2MC extends Command2 { public void addParamConverter(Class cl, Function converter, String errormsg) { super.addParamConverter(cl, converter, "§c" + errormsg); } + + @EventHandler + private void handleTabComplete(TabCompleteEvent event) { + String commandline = event.getBuffer(); + CommandSender sender = event.getSender(); + //System.out.println("tab"); + for (int i = commandline.length(); i != -1; i = commandline.lastIndexOf(' ', i - 1)) { + String subcommand = commandline.substring(0, i).toLowerCase(); + if (subcommand.charAt(0) != '/') subcommand = '/' + subcommand; //Console + //System.out.println("Subcommand: " + subcommand); + SubcommandData sd = subcommands.get(subcommand); //O(1) + if (sd == null) continue; + //System.out.println("ht: " + Arrays.toString(sd.helpText)); + Arrays.stream(sd.helpText).skip(1).map(ht -> new HashMap.SimpleEntry<>(ht, subcommands.get(ht))).filter(e -> e.getValue() != null) + .filter(kv -> kv.getKey().startsWith(commandline)) + .filter(kv -> hasPermission(sender, kv.getValue().command, kv.getValue().method)) + .forEach(kv -> event.getCompletions().add((kv.getKey()).substring(kv.getKey().lastIndexOf(' ', commandline.length()) + 1))); + if (sd.method == null || sd.command == null) + return; + /*if (!hasPermission(sender, sd.command, sd.method)) { - TODO: Arguments + sender.sendMessage("§cYou don't have permission to use this command"); + return true; + } + val params = new ArrayList(sd.method.getParameterCount()); + int j = subcommand.length(), pj; + Class[] parameterTypes = sd.method.getParameterTypes(); + if (parameterTypes.length == 0) + throw new Exception("No sender parameter for method '" + sd.method + "'"); + val sendertype = parameterTypes[0]; + final ChromaGamerBase cg; + if (sendertype.isAssignableFrom(sender.getClass())) + params.add(sender); //The command either expects a CommandSender or it is a Player, or some other expected type + else if (sender instanceof Command2MCSender + && sendertype.isAssignableFrom(((Command2MCSender) sender).getSender().getClass())) + params.add(((Command2MCSender) sender).getSender()); + else if (ChromaGamerBase.class.isAssignableFrom(sendertype) + && sender instanceof Command2MCSender + && (cg = ChromaGamerBase.getFromSender(((Command2MCSender) sender).getSender())) != null + && cg.getClass() == sendertype) //The command expects a user of our system + params.add(cg); + else { + sender.sendMessage("§cYou need to be a " + sendertype.getSimpleName() + " to use this command."); + return true; + } + val paramArr = sd.method.getParameters(); + for (int i1 = 1; i1 < parameterTypes.length; i1++) { + Class cl = parameterTypes[i1]; + pj = j + 1; //Start index + if (pj == commandline.length() + 1) { //No param given + if (paramArr[i1].isAnnotationPresent(OptionalArg.class)) { + if (cl.isPrimitive()) + params.add(Defaults.defaultValue(cl)); + else if (Number.class.isAssignableFrom(cl) + || Number.class.isAssignableFrom(cl)) + params.add(Defaults.defaultValue(Primitives.unwrap(cl))); + else + params.add(null); + continue; //Fill the remaining params with nulls + } else { + sender.sendMessage(sd.helpText); //Required param missing + return true; + } + } + if (paramArr[i1].isVarArgs()) { + params.add(commandline.substring(j + 1).split(" +")); + continue; + } + j = commandline.indexOf(' ', j + 1); //End index + if (j == -1 || paramArr[i1].isAnnotationPresent(TextArg.class)) //Last parameter + j = commandline.length(); + String param = commandline.substring(pj, j); + if (cl == String.class) { + params.add(param); + continue; + } else if (Number.class.isAssignableFrom(cl) || cl.isPrimitive()) { + try { + //noinspection unchecked + Number n = ThorpeUtils.convertNumber(NumberFormat.getInstance().parse(param), (Class) cl); + params.add(n); + } catch (ParseException e) { + sender.sendMessage("§c'" + param + "' is not a number."); + return true; + } + continue; + } + val conv = paramConverters.get(cl); + if (conv == null) + throw new Exception("No suitable converter found for parameter type '" + cl.getCanonicalName() + "' for command '" + sd.method.toString() + "'"); + val cparam = conv.converter.apply(param); + if (cparam == null) { + sender.sendMessage(conv.errormsg); //Param conversion failed - ex. plugin not found + return true; + } + params.add(cparam); + } + try { + val ret = sd.method.invoke(sd.command, params.toArray()); //I FORGOT TO TURN IT INTO AN ARRAY (for a long time) + if (ret instanceof Boolean) { + if (!(boolean) ret) //Show usage + sender.sendMessage(sd.helpText); + } else if (ret != null) + throw new Exception("Wrong return type! Must return a boolean or void. Return value: " + ret); + return true; //We found a method + } catch (InvocationTargetException e) { + TBMCCoreAPI.SendException("An error occurred in a command handler!", e.getCause()); + }*/ + } + } } diff --git a/ButtonCore/src/main/java/buttondevteam/lib/player/TBMCPlayerGetInfoEvent.java b/ButtonCore/src/main/java/buttondevteam/lib/player/TBMCPlayerGetInfoEvent.java index 5e63713..471a5f6 100755 --- a/ButtonCore/src/main/java/buttondevteam/lib/player/TBMCPlayerGetInfoEvent.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/player/TBMCPlayerGetInfoEvent.java @@ -24,6 +24,7 @@ public class TBMCPlayerGetInfoEvent extends Event { private final InfoTarget target; TBMCPlayerGetInfoEvent(ChromaGamerBase player, InfoTarget target) { + super(true); this.player = player; infolines = new ArrayList<>(); this.target = target; From 773277cb276706233daa9a117ec0b641b3aecdcb Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 22 Jul 2019 22:23:35 +0200 Subject: [PATCH 03/18] A few fixes --- ...Maven__net_bytebuddy_byte_buddy_1_6_11.xml | 13 -- ..._net_bytebuddy_byte_buddy_agent_1_6_11.xml | 13 -- ...Maven__org_mockito_mockito_core_2_7_20.xml | 13 -- .../Maven__org_objenesis_objenesis_2_5.xml | 13 -- BuildConfigUpdater/BuildConfigUpdater.iml | 18 +-- ButtonCore/pom.xml | 2 +- .../buttondevteam/lib/chat/Command2MC.java | 5 +- .../buttondevteam/lib/chat/TBMCChatAPI.java | 122 +++++++++--------- 8 files changed, 65 insertions(+), 134 deletions(-) delete mode 100755 .idea/libraries/Maven__net_bytebuddy_byte_buddy_1_6_11.xml delete mode 100755 .idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_6_11.xml delete mode 100755 .idea/libraries/Maven__org_mockito_mockito_core_2_7_20.xml delete mode 100755 .idea/libraries/Maven__org_objenesis_objenesis_2_5.xml diff --git a/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_6_11.xml b/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_6_11.xml deleted file mode 100755 index b956618..0000000 --- a/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_6_11.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_6_11.xml b/.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_6_11.xml deleted file mode 100755 index dbbe456..0000000 --- a/.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_6_11.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_mockito_mockito_core_2_7_20.xml b/.idea/libraries/Maven__org_mockito_mockito_core_2_7_20.xml deleted file mode 100755 index db215ab..0000000 --- a/.idea/libraries/Maven__org_mockito_mockito_core_2_7_20.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_objenesis_objenesis_2_5.xml b/.idea/libraries/Maven__org_objenesis_objenesis_2_5.xml deleted file mode 100755 index 57448b4..0000000 --- a/.idea/libraries/Maven__org_objenesis_objenesis_2_5.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/BuildConfigUpdater/BuildConfigUpdater.iml b/BuildConfigUpdater/BuildConfigUpdater.iml index 15937e7..df2c815 100644 --- a/BuildConfigUpdater/BuildConfigUpdater.iml +++ b/BuildConfigUpdater/BuildConfigUpdater.iml @@ -12,23 +12,13 @@ - - - - - - - - - - - - - - + + + + diff --git a/ButtonCore/pom.xml b/ButtonCore/pom.xml index db16155..568f662 100755 --- a/ButtonCore/pom.xml +++ b/ButtonCore/pom.xml @@ -160,7 +160,7 @@ org.mockito mockito-core - 2.7.20 + 3.0.0 diff --git a/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2MC.java b/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2MC.java index aac9cc9..ff1b5f1 100644 --- a/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2MC.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2MC.java @@ -1,7 +1,6 @@ package buttondevteam.lib.chat; import buttondevteam.core.MainPlugin; -import lombok.experimental.var; import lombok.val; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; @@ -127,7 +126,7 @@ public class Command2MC extends Command2 implemen //System.out.println("tab"); for (int i = commandline.length(); i != -1; i = commandline.lastIndexOf(' ', i - 1)) { String subcommand = commandline.substring(0, i).toLowerCase(); - if (subcommand.charAt(0) != '/') subcommand = '/' + subcommand; //Console + if (subcommand.length() == 0 || subcommand.charAt(0) != '/') subcommand = '/' + subcommand; //Console //System.out.println("Subcommand: " + subcommand); SubcommandData sd = subcommands.get(subcommand); //O(1) if (sd == null) continue; @@ -183,7 +182,7 @@ public class Command2MC extends Command2 implemen } } if (paramArr[i1].isVarArgs()) { - params.add(commandline.substring(j + 1).split(" +")); + par0ams.add(commandline.substring(j + 1).split(" +")); continue; } j = commandline.indexOf(' ', j + 1); //End index diff --git a/ButtonCore/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java b/ButtonCore/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java index f164d91..2ba2190 100755 --- a/ButtonCore/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java @@ -26,10 +26,11 @@ import java.util.HashMap; import java.util.Map.Entry; import java.util.Set; import java.util.function.Consumer; +import java.util.function.Supplier; public class TBMCChatAPI { - private static final HashMap commands = new HashMap<>(); + private static final HashMap commands = new HashMap<>(); public static HashMap GetCommands() { return commands; @@ -38,10 +39,8 @@ public class TBMCChatAPI { /** * Returns messages formatted for Minecraft chat listing the subcommands of the command. * - * @param command - * The command which we want the subcommands of - * @param sender - * The sender for permissions + * @param command The command which we want the subcommands of + * @param sender The sender for permissions * @return The subcommands */ public static String[] GetSubCommands(TBMCCommandBase command, CommandSender sender) { @@ -52,10 +51,8 @@ public class TBMCChatAPI { * Returns messages formatted for Minecraft chat listing the subcommands of the command.
* Returns a header if subcommands were found, otherwise returns an empty array. * - * @param command - * The command which we want the subcommands of - * @param sender - * The sender for permissions + * @param command The command which we want the subcommands of + * @param sender The sender for permissions * @return The subcommands */ public static String[] GetSubCommands(String command, CommandSender sender) { @@ -69,7 +66,7 @@ public class TBMCChatAPI { if (cmd.getKey().startsWith(command + " ")) { if (cmd.getValue().isPlayerOnly() && !(sender instanceof Player)) continue; - if (cmd.getValue().isModOnly() && (MainPlugin.permission != null ? !MainPlugin.permission.has(sender, "tbmc.admin") : !sender.isOp())) + if (cmd.getValue().isModOnly() && (MainPlugin.permission != null ? !MainPlugin.permission.has(sender, "tbmc.admin") : !sender.isOp())) continue; int ind = cmd.getKey().indexOf(' ', command.length() + 2); if (ind >= 0) { @@ -80,7 +77,7 @@ public class TBMCChatAPI { addToCmds.accept("/" + cmd.getKey()); } } - return cmds.toArray(new String[0]); //Apparently it's faster to use an empty array in modern Java + return cmds.toArray(new String[0]); //Apparently it's faster to use an empty array in modern Java } /** @@ -96,22 +93,20 @@ public class TBMCChatAPI { *

* Using this method after the server is done loading will have no effect. *

- * - * @param plugin - * The caller plugin - * @param acmdclass - * A command's class to get the package name for commands. The provided class's package and subpackages are scanned for commands. + * + * @param plugin The caller plugin + * @param acmdclass A command's class to get the package name for commands. The provided class's package and subpackages are scanned for commands. */ public static synchronized void AddCommands(JavaPlugin plugin, Class acmdclass) { plugin.getLogger().info("Registering commands from " + acmdclass.getPackage().getName()); Reflections rf = new Reflections(new ConfigurationBuilder() - .setUrls(ClasspathHelper.forPackage(acmdclass.getPackage().getName(), - plugin.getClass().getClassLoader())) - .addUrls( - ClasspathHelper.forClass(OptionallyPlayerCommandBase.class, - OptionallyPlayerCommandBase.class.getClassLoader()), - ClasspathHelper.forClass(PlayerCommandBase.class, PlayerCommandBase.class.getClassLoader())) // http://stackoverflow.com/questions/12917417/using-reflections-for-finding-the-transitive-subtypes-of-a-class-when-not-all - .addClassLoader(plugin.getClass().getClassLoader()).addScanners(new SubTypesScanner())); + .setUrls(ClasspathHelper.forPackage(acmdclass.getPackage().getName(), + plugin.getClass().getClassLoader())) + .addUrls( + ClasspathHelper.forClass(OptionallyPlayerCommandBase.class, + OptionallyPlayerCommandBase.class.getClassLoader()), + ClasspathHelper.forClass(PlayerCommandBase.class, PlayerCommandBase.class.getClassLoader())) // http://stackoverflow.com/questions/12917417/using-reflections-for-finding-the-transitive-subtypes-of-a-class-when-not-all + .addClassLoader(plugin.getClass().getClassLoader()).addScanners(new SubTypesScanner())); Set> cmds = rf.getSubTypesOf(TBMCCommandBase.class); for (Class cmd : cmds) { try { @@ -139,19 +134,17 @@ public class TBMCChatAPI { *

* Using this method after the server is done loading will have no effect. *

- * - * @param plugin - * The caller plugin - * @param thecmdclass - * The command's class to create it (because why let you create the command class) + * + * @param plugin The caller plugin + * @param thecmdclass The command's class to create it (because why let you create the command class) */ public static void AddCommand(JavaPlugin plugin, Class thecmdclass, Object... params) { // plugin.getLogger().info("Registering command " + thecmdclass.getSimpleName() + " for " + plugin.getName()); try { TBMCCommandBase c; if (params.length > 0) - c = thecmdclass.getConstructor(Arrays.stream(params).map(Object::getClass).toArray(Class[]::new)) - .newInstance(params); + c = thecmdclass.getConstructor(Arrays.stream(params).map(Object::getClass).toArray(Class[]::new)) + .newInstance(params); else c = thecmdclass.newInstance(); c.plugin = plugin; @@ -173,10 +166,8 @@ public class TBMCChatAPI { * Using this method after the server is done loading will have no effect. *

* - * @param plugin - * The caller plugin - * @param cmd - * The command to add + * @param plugin The caller plugin + * @param cmd The command to add */ public static void AddCommand(JavaPlugin plugin, TBMCCommandBase cmd) { try { @@ -259,14 +250,14 @@ public class TBMCChatAPI { /** * Sends a chat message to Minecraft. Make sure that the channel is registered with {@link #RegisterChatChannel(Channel)}.
- * This will also send the error message to the sender, if they can't send the message. + * This will also send the error message to the sender, if they can't send the message. * - * @param cm The message to send + * @param cm The message to send * @return The event cancelled state */ - public static boolean SendChatMessage(ChatMessage cm) { - return SendChatMessage(cm, cm.getUser().channel().get()); - } + public static boolean SendChatMessage(ChatMessage cm) { + return SendChatMessage(cm, cm.getUser().channel().get()); + } /** * Sends a chat message to Minecraft. Make sure that the channel is registered with {@link #RegisterChatChannel(Channel)}.
@@ -278,36 +269,40 @@ public class TBMCChatAPI { */ public static boolean SendChatMessage(ChatMessage cm, Channel channel) { if (!Channel.getChannelList().contains(channel)) - throw new RuntimeException("Channel " + channel.DisplayName().get() + " not registered!"); + throw new RuntimeException("Channel " + channel.DisplayName().get() + " not registered!"); if (!channel.Enabled().get()) { cm.getSender().sendMessage("§cThe channel '" + channel.DisplayName().get() + "' is disabled!"); return true; //Cancel sending if channel is disabled } - val permcheck = cm.getPermCheck(); - RecipientTestResult rtr = getScoreOrSendError(channel, permcheck); - int score = rtr.score; - if (score == Channel.SCORE_SEND_NOPE || rtr.groupID == null) - return true; - TBMCChatPreprocessEvent eventPre = new TBMCChatPreprocessEvent(cm.getSender(), channel, cm.getMessage()); - Bukkit.getPluginManager().callEvent(eventPre); - if (eventPre.isCancelled()) - return true; - cm.setMessage(eventPre.getMessage()); - TBMCChatEvent event; - event = new TBMCChatEvent(channel, cm, rtr); - Bukkit.getPluginManager().callEvent(event); - return event.isCancelled(); + Supplier task = () -> { + val permcheck = cm.getPermCheck(); + RecipientTestResult rtr = getScoreOrSendError(channel, permcheck); + int score = rtr.score; + if (score == Channel.SCORE_SEND_NOPE || rtr.groupID == null) + return true; + TBMCChatPreprocessEvent eventPre = new TBMCChatPreprocessEvent(cm.getSender(), channel, cm.getMessage()); + Bukkit.getPluginManager().callEvent(eventPre); + if (eventPre.isCancelled()) + return true; + cm.setMessage(eventPre.getMessage()); + TBMCChatEvent event; + event = new TBMCChatEvent(channel, cm, rtr); + Bukkit.getPluginManager().callEvent(event); + return event.isCancelled(); + }; + if (Bukkit.isPrimaryThread()) + Bukkit.getScheduler().runTaskAsynchronously(MainPlugin.Instance, task::get); + else + return task.get(); + return false; //Not cancelled if async } /** * Sends a regular message to Minecraft. Make sure that the channel is registered with {@link #RegisterChatChannel(Channel)}. - * - * @param channel - * The channel to send to - * @param rtr - * The score&group to use to find the group - use {@link RecipientTestResult#ALL} if the channel doesn't have scores - * @param message - * The message to send + * + * @param channel The channel to send to + * @param rtr The score&group to use to find the group - use {@link RecipientTestResult#ALL} if the channel doesn't have scores + * @param message The message to send * @param exceptions Platforms where this message shouldn't be sent (same as {@link ChatMessage#getOrigin()} * @return The event cancelled state */ @@ -332,9 +327,8 @@ public class TBMCChatAPI { /** * Register a chat channel. See {@link Channel#Channel(String, Color, String, java.util.function.Function)} for details. - * - * @param channel - * A new {@link Channel} to register + * + * @param channel A new {@link Channel} to register */ public static void RegisterChatChannel(Channel channel) { Channel.RegisterChannel(channel); From fa6c453a8d2ab15e3fbb2cfe61b5317d3ca4717d Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Wed, 7 Aug 2019 18:26:45 +0200 Subject: [PATCH 04/18] Removed reference to IOUtils & no config warn I use IOUtils suprisingly often Made the config name warning test only --- .../Maven__commons_io_commons_io_1_3_2.xml | 13 --------- ButtonCore/pom.xml | 9 ++---- .../core/component/updater/PluginUpdater.java | 10 +++---- .../java/buttondevteam/lib/TBMCCoreAPI.java | 9 ++---- .../lib/architecture/IHaveConfig.java | 3 +- .../buttondevteam/lib/chat/Command2MC.java | 1 + .../buttondevteam/core/PlayerDataTest.java | 29 +++++++++++++++++-- 7 files changed, 39 insertions(+), 35 deletions(-) delete mode 100755 .idea/libraries/Maven__commons_io_commons_io_1_3_2.xml diff --git a/.idea/libraries/Maven__commons_io_commons_io_1_3_2.xml b/.idea/libraries/Maven__commons_io_commons_io_1_3_2.xml deleted file mode 100755 index 7b5b3b7..0000000 --- a/.idea/libraries/Maven__commons_io_commons_io_1_3_2.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/ButtonCore/pom.xml b/ButtonCore/pom.xml index 568f662..2ae7ccb 100755 --- a/ButtonCore/pom.xml +++ b/ButtonCore/pom.xml @@ -31,6 +31,7 @@ 1.8 1.8 + UTF-8 @@ -68,6 +69,7 @@ src/main/resources + UTF-8 @@ -131,13 +133,6 @@ 1.12.2-R0.1-SNAPSHOT provided
- - - commons-io - commons-io - 1.3.2 - provided - com.github.TBMCPlugins.ButtonCore diff --git a/ButtonCore/src/main/java/buttondevteam/core/component/updater/PluginUpdater.java b/ButtonCore/src/main/java/buttondevteam/core/component/updater/PluginUpdater.java index 64401fd..5454ea1 100755 --- a/ButtonCore/src/main/java/buttondevteam/core/component/updater/PluginUpdater.java +++ b/ButtonCore/src/main/java/buttondevteam/core/component/updater/PluginUpdater.java @@ -5,16 +5,13 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import org.apache.commons.io.FileUtils; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; -import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -66,7 +63,7 @@ public class PluginUpdater { private static boolean updatePluginJitPack(CommandSender sender, String correctname, String correctbranch) { - URL url; + /*URL url; File result = new File(updatedir, correctname + ".jar"); try { url = new URL("https://jitpack.io/com/github/TBMCPlugins/" @@ -93,8 +90,9 @@ public class PluginUpdater { error(sender, "IO error while updating " + correctname + "\n" + e.getMessage()); } catch (Exception e) { e.printStackTrace(); - error(sender, "Unknown error while updating " + correctname + ": " + e); - } + error(sender, "Unknown error while updating " + correctname + ": " + e); - TODO: Either add Commons or don't use FileUtils + }*/ + info(sender, "Plugin updating is currently not supported"); return false; } diff --git a/ButtonCore/src/main/java/buttondevteam/lib/TBMCCoreAPI.java b/ButtonCore/src/main/java/buttondevteam/lib/TBMCCoreAPI.java index 6b193aa..35a33b7 100755 --- a/ButtonCore/src/main/java/buttondevteam/lib/TBMCCoreAPI.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/TBMCCoreAPI.java @@ -4,7 +4,6 @@ import buttondevteam.core.MainPlugin; import buttondevteam.core.component.updater.PluginUpdater; import buttondevteam.lib.player.ChromaGamerBase; import buttondevteam.lib.potato.DebugPotato; -import org.apache.commons.io.IOUtils; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -15,10 +14,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.net.URLConnection; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; +import java.util.*; import java.util.Map.Entry; public class TBMCCoreAPI { @@ -63,7 +59,8 @@ public class TBMCCoreAPI { InputStream in = con.getInputStream(); String encoding = con.getContentEncoding(); encoding = encoding == null ? "UTF-8" : encoding; - String body = IOUtils.toString(in, encoding); + Scanner s = new Scanner(in).useDelimiter("\\A"); + String body = s.hasNext() ? s.next() : ""; in.close(); return body; } diff --git a/ButtonCore/src/main/java/buttondevteam/lib/architecture/IHaveConfig.java b/ButtonCore/src/main/java/buttondevteam/lib/architecture/IHaveConfig.java index b3d6fbd..2a73e16 100644 --- a/ButtonCore/src/main/java/buttondevteam/lib/architecture/IHaveConfig.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/architecture/IHaveConfig.java @@ -166,7 +166,8 @@ public final class IHaveConfig { } }).filter(Objects::nonNull).collect(Collectors.toList()); } else { - MainPlugin.Instance.getLogger().warning("Method " + m.getName() + " returns a config but its parameters are unknown: " + Arrays.toString(m.getParameterTypes())); + if (TBMCCoreAPI.IsTestServer()) + MainPlugin.Instance.getLogger().warning("Method " + m.getName() + " returns a config but its parameters are unknown: " + Arrays.toString(m.getParameterTypes())); continue; } for (val c : configList) { diff --git a/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2MC.java b/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2MC.java index ff1b5f1..e111d77 100644 --- a/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2MC.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2MC.java @@ -1,6 +1,7 @@ package buttondevteam.lib.chat; import buttondevteam.core.MainPlugin; +import lombok.experimental.var; import lombok.val; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; diff --git a/ButtonCore/src/test/java/buttondevteam/core/PlayerDataTest.java b/ButtonCore/src/test/java/buttondevteam/core/PlayerDataTest.java index 13433bf..ecfd4ac 100755 --- a/ButtonCore/src/test/java/buttondevteam/core/PlayerDataTest.java +++ b/ButtonCore/src/test/java/buttondevteam/core/PlayerDataTest.java @@ -6,9 +6,14 @@ import buttondevteam.lib.player.TBMCPlayerBase; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; -import org.apache.commons.io.FileUtils; import java.io.File; +import java.io.IOException; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; import java.util.UUID; public class PlayerDataTest extends TestCase { @@ -25,7 +30,27 @@ public class PlayerDataTest extends TestCase { public void testConfig() throws Exception { TestPrepare.PrepareServer(); - FileUtils.deleteDirectory(new File(ChromaGamerBase.TBMC_PLAYERS_DIR)); + //FileUtils.deleteDirectory(new File(ChromaGamerBase.TBMC_PLAYERS_DIR)); + Files.walkFileTree(new File(ChromaGamerBase.TBMC_PLAYERS_DIR).toPath(), new SimpleFileVisitor() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) + throws IOException { + Files.delete(file); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException e) + throws IOException { + if (e == null) { + Files.delete(dir); + return FileVisitResult.CONTINUE; + } else { + // directory iteration failed + throw e; + } + } + }); UUID uuid = new UUID(0L, 0L); try (TestPlayerClass p = TBMCPlayerBase.getPlayer(uuid, TestPlayerClass.class)) { p.PlayerName().set("Test"); From 14bcebabcdf752dccb47c91996a5d7d02a45d21d Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 11 Aug 2019 20:02:30 +0200 Subject: [PATCH 05/18] Fixed schrestart message async event stuff --- BuildConfigUpdater/BuildConfigUpdater.iml | 1 + .../java/buttondevteam/lib/ThorpeUtils.java | 35 +++++++++++++++++++ .../buttondevteam/lib/chat/TBMCChatAPI.java | 14 ++------ 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/BuildConfigUpdater/BuildConfigUpdater.iml b/BuildConfigUpdater/BuildConfigUpdater.iml index df2c815..31ba17d 100644 --- a/BuildConfigUpdater/BuildConfigUpdater.iml +++ b/BuildConfigUpdater/BuildConfigUpdater.iml @@ -12,6 +12,7 @@ + diff --git a/ButtonCore/src/main/java/buttondevteam/lib/ThorpeUtils.java b/ButtonCore/src/main/java/buttondevteam/lib/ThorpeUtils.java index d69983e..bf19323 100644 --- a/ButtonCore/src/main/java/buttondevteam/lib/ThorpeUtils.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/ThorpeUtils.java @@ -1,7 +1,13 @@ package buttondevteam.lib; +import buttondevteam.core.MainPlugin; +import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; + +import java.util.function.Supplier; public final class ThorpeUtils { private ThorpeUtils() {} @@ -51,4 +57,33 @@ public final class ThorpeUtils { return number.doubleValue(); return number; } + + /** + * Calls the event always asynchronously. The return value is always false if async. + * + * @param event The event to call + * @return The event cancelled state or false if async. + */ + public static boolean callEventAsync(T event) { + Supplier task = () -> { + Bukkit.getPluginManager().callEvent(event); + return event.isCancelled(); + }; + return doItAsync(task, false); + } + + /** + * Does something always asynchronously. It will execute in the same thread if it's not the server thread. + * + * @param what What to do + * @param def Default if async + * @return The event cancelled state or false if async. + */ + public static T doItAsync(Supplier what, T def) { + if (Bukkit.isPrimaryThread()) + Bukkit.getScheduler().runTaskAsynchronously(MainPlugin.Instance, what::get); + else + return what.get(); + return def; + } } diff --git a/ButtonCore/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java b/ButtonCore/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java index 2ba2190..92dece9 100755 --- a/ButtonCore/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java @@ -4,10 +4,7 @@ import buttondevteam.core.CommandCaller; import buttondevteam.core.MainPlugin; import buttondevteam.core.component.channel.Channel; import buttondevteam.core.component.channel.Channel.RecipientTestResult; -import buttondevteam.lib.TBMCChatEvent; -import buttondevteam.lib.TBMCChatPreprocessEvent; -import buttondevteam.lib.TBMCCoreAPI; -import buttondevteam.lib.TBMCSystemChatEvent; +import buttondevteam.lib.*; import buttondevteam.lib.architecture.Component; import lombok.val; import org.bukkit.Bukkit; @@ -290,11 +287,7 @@ public class TBMCChatAPI { Bukkit.getPluginManager().callEvent(event); return event.isCancelled(); }; - if (Bukkit.isPrimaryThread()) - Bukkit.getScheduler().runTaskAsynchronously(MainPlugin.Instance, task::get); - else - return task.get(); - return false; //Not cancelled if async + return ThorpeUtils.doItAsync(task, false); //Not cancelled if async } /** @@ -314,8 +307,7 @@ public class TBMCChatAPI { if (!Arrays.asList(exceptions).contains("Minecraft")) Bukkit.getConsoleSender().sendMessage("[" + channel.DisplayName().get() + "] " + message); TBMCSystemChatEvent event = new TBMCSystemChatEvent(channel, message, rtr.score, rtr.groupID, exceptions, target); - Bukkit.getPluginManager().callEvent(event); - return event.isCancelled(); + return ThorpeUtils.callEventAsync(event); } private static RecipientTestResult getScoreOrSendError(Channel channel, CommandSender sender) { From 2ad7a757c6e9c426ec663cd6aed9fd8d9d5e2cae Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 18 Aug 2019 03:49:36 +0200 Subject: [PATCH 06/18] Made SpawnComponent, working just fine Supports Multiverse and BungeeCord --- BuildConfigUpdater/BuildConfigUpdater.iml | 1 - ButtonCore/pom.xml | 10 ++ .../java/buttondevteam/core/MainPlugin.java | 2 + .../core/component/spawn/SpawnComponent.java | 120 ++++++++++++++++++ ButtonCore/src/main/resources/plugin.yml | 3 +- 5 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 ButtonCore/src/main/java/buttondevteam/core/component/spawn/SpawnComponent.java diff --git a/BuildConfigUpdater/BuildConfigUpdater.iml b/BuildConfigUpdater/BuildConfigUpdater.iml index 31ba17d..df2c815 100644 --- a/BuildConfigUpdater/BuildConfigUpdater.iml +++ b/BuildConfigUpdater/BuildConfigUpdater.iml @@ -12,7 +12,6 @@ - diff --git a/ButtonCore/pom.xml b/ButtonCore/pom.xml index 2ae7ccb..088389a 100755 --- a/ButtonCore/pom.xml +++ b/ButtonCore/pom.xml @@ -119,6 +119,10 @@ Votifier https://dl.bintray.com/nuvotifier/maven/ + + Multiverse-Core + http://repo.onarandombox.com/content/repositories/multiverse/ + @@ -182,6 +186,12 @@ 2.3.4 provided + + com.onarandombox.multiversecore + Multiverse-Core + 4.0.1 + provided + TBMCPlugins diff --git a/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java b/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java index 5c4463f..01132f9 100755 --- a/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java +++ b/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java @@ -6,6 +6,7 @@ import buttondevteam.core.component.channel.ChatRoom; import buttondevteam.core.component.members.MemberComponent; import buttondevteam.core.component.randomtp.RandomTPComponent; import buttondevteam.core.component.restart.RestartComponent; +import buttondevteam.core.component.spawn.SpawnComponent; import buttondevteam.core.component.towny.TownyComponent; import buttondevteam.core.component.updater.PluginUpdater; import buttondevteam.core.component.updater.PluginUpdaterComponent; @@ -89,6 +90,7 @@ public class MainPlugin extends ButtonPlugin { Component.registerComponent(this, new ChannelComponent()); Component.registerComponent(this, new RandomTPComponent()); Component.registerComponent(this, new MemberComponent()); + Component.registerComponent(this, new SpawnComponent()); if (Bukkit.getPluginManager().isPluginEnabled("Towny")) //It fails to load the component class otherwise Component.registerComponent(this, new TownyComponent()); if (Bukkit.getPluginManager().isPluginEnabled("Votifier") && economy != null) diff --git a/ButtonCore/src/main/java/buttondevteam/core/component/spawn/SpawnComponent.java b/ButtonCore/src/main/java/buttondevteam/core/component/spawn/SpawnComponent.java new file mode 100644 index 0000000..a9b9970 --- /dev/null +++ b/ButtonCore/src/main/java/buttondevteam/core/component/spawn/SpawnComponent.java @@ -0,0 +1,120 @@ +package buttondevteam.core.component.spawn; + +import buttondevteam.core.MainPlugin; +import buttondevteam.lib.architecture.Component; +import buttondevteam.lib.architecture.ConfigData; +import buttondevteam.lib.chat.Command2; +import buttondevteam.lib.chat.CommandClass; +import buttondevteam.lib.chat.ICommand2MC; +import com.google.common.io.ByteArrayDataInput; +import com.google.common.io.ByteArrayDataOutput; +import com.google.common.io.ByteStreams; +import com.onarandombox.MultiverseCore.MultiverseCore; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.plugin.messaging.PluginMessageListener; + +import java.io.*; + +public class SpawnComponent extends Component implements PluginMessageListener { + @Override + protected void enable() { + registerCommand(new SpawnCommand()); + if (targetServer().get().length() == 0) { + spawnloc = MultiverseCore.getPlugin(MultiverseCore.class).getMVWorldManager().getFirstSpawnWorld() + .getSpawnLocation(); + } + + Bukkit.getServer().getMessenger().registerOutgoingPluginChannel(getPlugin(), "BungeeCord"); + Bukkit.getServer().getMessenger().registerIncomingPluginChannel(getPlugin(), "BungeeCord", this); + } + + @Override + protected void disable() { + Bukkit.getServer().getMessenger().unregisterIncomingPluginChannel(getPlugin(), "BungeeCord"); + Bukkit.getServer().getMessenger().unregisterOutgoingPluginChannel(getPlugin(), "BungeeCord"); + } + + @Override + public void onPluginMessageReceived(String channel, Player player, byte[] message) { + if (!channel.equals("BungeeCord")) { + return; + } + if (targetServer().get().length() != 0) + return; + ByteArrayDataInput in = ByteStreams.newDataInput(message); + String subchannel = in.readUTF(); + if ("ChromaCore-Spawn".equals(subchannel)) { + // Use the code sample in the 'Response' sections below to read + // the data. + System.out.println("Heh nice"); + short len = in.readShort(); + byte[] msgbytes = new byte[len]; + in.readFully(msgbytes); + + try { + DataInputStream msgin = new DataInputStream(new ByteArrayInputStream(msgbytes)); + String somedata = msgin.readUTF(); // Read the data in the same way you wrote it + if (!"SendToSpawn".equals(somedata)) { + System.out.println("somedata: " + somedata); + return; + } + player.teleport(spawnloc); + } catch (IOException e) { + e.printStackTrace(); + } + } else + System.out.println("Subchannel: " + subchannel); + } + + /** + * Set to empty if this server is the target. + */ + private ConfigData targetServer() { + return getConfig().getData("targetServer", ""); + } + + private Location spawnloc; + + @CommandClass(helpText = { + "Spawn", + "Teleport to spawn." + }) + public class SpawnCommand extends ICommand2MC { + @SuppressWarnings("UnstableApiUsage") + @Command2.Subcommand + public void def(Player player) { + if (targetServer().get().length() == 0) { + player.sendMessage("§bTeleporting to spawn."); + player.teleport(spawnloc); + return; + } + ByteArrayDataOutput out = ByteStreams.newDataOutput(); + out.writeUTF("Connect"); + out.writeUTF(targetServer().get()); + + player.sendPluginMessage(getPlugin(), "BungeeCord", out.toByteArray()); + + Bukkit.getScheduler().runTask(getPlugin(), () -> { //Delay it a bit + ByteArrayDataOutput outt = ByteStreams.newDataOutput(); + outt.writeUTF("Forward"); // So BungeeCord knows to forward it + outt.writeUTF("ALL"); + outt.writeUTF("ChromaCore-Spawn"); // The channel name to check if this your data + + ByteArrayOutputStream msgbytes = new ByteArrayOutputStream(); + DataOutputStream msgout = new DataOutputStream(msgbytes); + try { + msgout.writeUTF("SendToSpawn"); // You can do anything you want with msgout + } catch (IOException exception) { + exception.printStackTrace(); + } + + outt.writeShort(msgbytes.toByteArray().length); + outt.write(msgbytes.toByteArray()); + + player.sendPluginMessage(getPlugin(), "BungeeCord", outt.toByteArray()); + }); + } + } +} diff --git a/ButtonCore/src/main/resources/plugin.yml b/ButtonCore/src/main/resources/plugin.yml index 29bfbb1..7b3d8bf 100755 --- a/ButtonCore/src/main/resources/plugin.yml +++ b/ButtonCore/src/main/resources/plugin.yml @@ -20,4 +20,5 @@ depend: - Vault softdepend: - Towny - - Votifier \ No newline at end of file + - Votifier + - Multiverse-Core \ No newline at end of file From feee6a0ebefd07ebc3528245fa009c919018b2aa Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 18 Aug 2019 18:20:50 +0200 Subject: [PATCH 07/18] MemberComponent fix, better error handling --- .../java/buttondevteam/core/ComponentManager.java | 2 +- .../core/component/members/MemberComponent.java | 11 ++++++++++- .../src/main/java/buttondevteam/lib/TBMCCoreAPI.java | 4 +++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ButtonCore/src/main/java/buttondevteam/core/ComponentManager.java b/ButtonCore/src/main/java/buttondevteam/core/ComponentManager.java index c8a28b8..bbc3a01 100644 --- a/ButtonCore/src/main/java/buttondevteam/core/ComponentManager.java +++ b/ButtonCore/src/main/java/buttondevteam/core/ComponentManager.java @@ -24,7 +24,7 @@ public final class ComponentManager { Component.getComponents().values().stream().filter(c -> c.shouldBeEnabled().get()).forEach(c -> { try { Component.setComponentEnabled(c, true); - } catch (Exception e) { + } catch (Exception | NoClassDefFoundError e) { TBMCCoreAPI.SendException("Failed to enable one of the components: " + c.getClass().getSimpleName(), e); } }); diff --git a/ButtonCore/src/main/java/buttondevteam/core/component/members/MemberComponent.java b/ButtonCore/src/main/java/buttondevteam/core/component/members/MemberComponent.java index 66ce1ed..5ea098a 100644 --- a/ButtonCore/src/main/java/buttondevteam/core/component/members/MemberComponent.java +++ b/ButtonCore/src/main/java/buttondevteam/core/component/members/MemberComponent.java @@ -10,6 +10,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import java.time.Instant; import java.time.temporal.ChronoUnit; +import java.util.AbstractMap; import java.util.Date; import static buttondevteam.core.MainPlugin.permission; @@ -39,10 +40,17 @@ public class MemberComponent extends Component implements Listener { return getConfig().getData("registeredForDays", 7); } + private AbstractMap.SimpleEntry playtime; + @Override protected void enable() { registerListener(this); registerCommand(new MemberCommand(this)); + try { + playtime = new AbstractMap.SimpleEntry<>(Statistic.valueOf("PLAY_ONE_MINUTE"), 60); //1.14 + } catch (IllegalArgumentException e) { + playtime = new AbstractMap.SimpleEntry<>(Statistic.valueOf("PLAY_ONE_TICK"), 20 * 3600); //1.12 + } } @Override @@ -53,7 +61,7 @@ public class MemberComponent extends Component implements Listener { public void onPlayerJoin(PlayerJoinEvent event) { if (permission != null && !permission.playerInGroup(event.getPlayer(), memberGroup().get()) && (new Date(event.getPlayer().getFirstPlayed()).toInstant().plus(registeredForDays().get(), ChronoUnit.DAYS).isBefore(Instant.now()) - || event.getPlayer().getStatistic(Statistic.PLAY_ONE_TICK) > 20 * 3600 * playedHours().get())) { + || event.getPlayer().getStatistic(playtime.getKey()) > playtime.getValue() * playedHours().get())) { if (permission.playerAddGroup(null, event.getPlayer(), memberGroup().get())) { event.getPlayer().sendMessage("§bYou are a member now. YEEHAW"); MainPlugin.Instance.getLogger().info("Added " + event.getPlayer().getName() + " as a member."); @@ -62,4 +70,5 @@ public class MemberComponent extends Component implements Listener { } } } + } diff --git a/ButtonCore/src/main/java/buttondevteam/lib/TBMCCoreAPI.java b/ButtonCore/src/main/java/buttondevteam/lib/TBMCCoreAPI.java index 35a33b7..7e8939b 100755 --- a/ButtonCore/src/main/java/buttondevteam/lib/TBMCCoreAPI.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/TBMCCoreAPI.java @@ -127,6 +127,7 @@ public class TBMCCoreAPI { } } + private static EventExceptionCoreHandler eventExceptionCoreHandler; /** * Registers Bukkit events, handling the exceptions occurring in those events * @@ -134,7 +135,8 @@ public class TBMCCoreAPI { * @param plugin The plugin which the listener belongs to */ public static void RegisterEventsForExceptions(Listener listener, Plugin plugin) { - EventExceptionHandler.registerEvents(listener, plugin, new EventExceptionCoreHandler()); + if (eventExceptionCoreHandler == null) eventExceptionCoreHandler = new EventExceptionCoreHandler(); + EventExceptionHandler.registerEvents(listener, plugin, eventExceptionCoreHandler); } public static void RegisterUserClass(Class userclass) { From a17923602f55ae32f09c57cc7decfaebb27b33a8 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 23 Aug 2019 00:50:36 +0200 Subject: [PATCH 08/18] Slow startup debug, async command handling The command argument processing and permission checking is done asynchronously, mainly because LuckPerms (rightfully) complains that loading player data (for unconnected DC users) should not be done on the main thread. The actual command execution is still done on the main thread. --- BuildConfigUpdater/BuildConfigUpdater.iml | 2 + .../core/component/randomtp/RandomTP.java | 6 +- .../component/restart/RestartComponent.java | 1 - .../lib/architecture/Component.java | 7 +- .../java/buttondevteam/lib/chat/Command2.java | 177 ++++++++++-------- 5 files changed, 109 insertions(+), 84 deletions(-) diff --git a/BuildConfigUpdater/BuildConfigUpdater.iml b/BuildConfigUpdater/BuildConfigUpdater.iml index df2c815..cea34c4 100644 --- a/BuildConfigUpdater/BuildConfigUpdater.iml +++ b/BuildConfigUpdater/BuildConfigUpdater.iml @@ -12,6 +12,8 @@ + + diff --git a/ButtonCore/src/main/java/buttondevteam/core/component/randomtp/RandomTP.java b/ButtonCore/src/main/java/buttondevteam/core/component/randomtp/RandomTP.java index a0612db..755a32a 100644 --- a/ButtonCore/src/main/java/buttondevteam/core/component/randomtp/RandomTP.java +++ b/ButtonCore/src/main/java/buttondevteam/core/component/randomtp/RandomTP.java @@ -53,11 +53,15 @@ public class RandomTP extends TBMCCommandBase public void onEnable(Component component) { + System.out.println("Adding command"); TBMCChatAPI.AddCommand(component, this); + System.out.println("Getting world"); world = Bukkit.getWorld("World"); + System.out.println("Getting border"); border = world.getWorldBorder(); - newLocation(); + System.out.println("Getting new location"); + System.out.println("Success: "+newLocation()); //TODO: It takes 10-30 seconds to find a location (newLocation() was there) } /*================================================================================================*/ diff --git a/ButtonCore/src/main/java/buttondevteam/core/component/restart/RestartComponent.java b/ButtonCore/src/main/java/buttondevteam/core/component/restart/RestartComponent.java index 6b431bb..d0104a0 100644 --- a/ButtonCore/src/main/java/buttondevteam/core/component/restart/RestartComponent.java +++ b/ButtonCore/src/main/java/buttondevteam/core/component/restart/RestartComponent.java @@ -19,7 +19,6 @@ import org.bukkit.event.player.PlayerQuitEvent; public class RestartComponent extends Component implements Listener { @Override public void enable() { - //TODO: Permissions for the commands registerCommand(new ScheduledRestartCommand(this)); TBMCChatAPI.AddCommand(this, new PrimeRestartCommand(this)); registerListener(this); diff --git a/ButtonCore/src/main/java/buttondevteam/lib/architecture/Component.java b/ButtonCore/src/main/java/buttondevteam/lib/architecture/Component.java index b98466b..a39db67 100644 --- a/ButtonCore/src/main/java/buttondevteam/lib/architecture/Component.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/architecture/Component.java @@ -131,10 +131,15 @@ public abstract class Component { throw new UnregisteredComponentException(component); if (component.enabled == enabled) return; //Don't do anything if (component.enabled = enabled) { + //System.out.println("Updating config for "+component.getClassName()); updateConfig(component.getPlugin(), component); + //System.out.println("Enabling "+component.getClassName()); component.enable(); - if (ButtonPlugin.configGenAllowed(component)) + if (ButtonPlugin.configGenAllowed(component)) { + //System.out.println("Pregenning config for "+component.getClassName()); IHaveConfig.pregenConfig(component, null); + } + //System.out.println("Done enabling "+component.getClassName()); } else { component.disable(); component.plugin.saveConfig(); diff --git a/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2.java b/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2.java index d2851fe..1e75596 100644 --- a/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2.java @@ -126,91 +126,106 @@ public abstract class Command2 paramConverters.put(cl, new ParamConverter<>(converter, errormsg)); } - public boolean handleCommand(TP sender, String commandline) throws Exception { + public boolean handleCommand(TP sender, String commandline) { for (int i = commandline.length(); i != -1; i = commandline.lastIndexOf(' ', i - 1)) { String subcommand = commandline.substring(0, i).toLowerCase(); SubcommandData sd = subcommands.get(subcommand); //O(1) if (sd == null) continue; - if (sd.method == null || sd.command == null) { //Main command not registered, but we have subcommands - sender.sendMessage(sd.helpText); - return true; - } - if (!hasPermission(sender, sd.command, sd.method)) { - sender.sendMessage("§cYou don't have permission to use this command"); - return true; - } - val params = new ArrayList(sd.method.getParameterCount()); - int j = subcommand.length(), pj; - Class[] parameterTypes = sd.method.getParameterTypes(); - if (parameterTypes.length == 0) - throw new Exception("No sender parameter for method '" + sd.method + "'"); - val sendertype = parameterTypes[0]; - final ChromaGamerBase cg; - if (sendertype.isAssignableFrom(sender.getClass())) - params.add(sender); //The command either expects a CommandSender or it is a Player, or some other expected type - else if (sender instanceof Command2MCSender - && sendertype.isAssignableFrom(((Command2MCSender) sender).getSender().getClass())) - params.add(((Command2MCSender) sender).getSender()); - else if (ChromaGamerBase.class.isAssignableFrom(sendertype) - && sender instanceof Command2MCSender - && (cg = ChromaGamerBase.getFromSender(((Command2MCSender) sender).getSender())) != null - && cg.getClass() == sendertype) //The command expects a user of our system - params.add(cg); - else { - sender.sendMessage("§cYou need to be a " + sendertype.getSimpleName() + " to use this command."); - return true; - } - val paramArr = sd.method.getParameters(); - for (int i1 = 1; i1 < parameterTypes.length; i1++) { - Class cl = parameterTypes[i1]; - pj = j + 1; //Start index - if (pj == commandline.length() + 1) { //No param given - if (paramArr[i1].isAnnotationPresent(OptionalArg.class)) { - if (cl.isPrimitive()) - params.add(Defaults.defaultValue(cl)); - else if (Number.class.isAssignableFrom(cl) - || Number.class.isAssignableFrom(cl)) - params.add(Defaults.defaultValue(Primitives.unwrap(cl))); - else - params.add(null); - continue; //Fill the remaining params with nulls - } else { - sender.sendMessage(sd.helpText); //Required param missing - return true; - } + Bukkit.getScheduler().runTaskAsynchronously(MainPlugin.Instance, () -> { + try { + handleCommandAsync(sender, commandline, sd, subcommand); + } catch (Exception e) { + TBMCCoreAPI.SendException("Command execution failed for sender " + sender + " and message " + commandline, e); } - if (paramArr[i1].isVarArgs()) { - params.add(commandline.substring(j + 1).split(" +")); - continue; + }); + return true; //We found a method + } + return false; + } + + //Needed because permission checking may load the (perhaps offline) sender's file which is disallowed on the main thread + public void handleCommandAsync(TP sender, String commandline, SubcommandData sd, String subcommand) throws Exception { + if (sd.method == null || sd.command == null) { //Main command not registered, but we have subcommands + sender.sendMessage(sd.helpText); + return; + } + if (!hasPermission(sender, sd.command, sd.method)) { + sender.sendMessage("§cYou don't have permission to use this command"); + return; + } + val params = new ArrayList(sd.method.getParameterCount()); + int j = subcommand.length(), pj; + Class[] parameterTypes = sd.method.getParameterTypes(); + if (parameterTypes.length == 0) + throw new Exception("No sender parameter for method '" + sd.method + "'"); + val sendertype = parameterTypes[0]; + final ChromaGamerBase cg; + if (sendertype.isAssignableFrom(sender.getClass())) + params.add(sender); //The command either expects a CommandSender or it is a Player, or some other expected type + else if (sender instanceof Command2MCSender + && sendertype.isAssignableFrom(((Command2MCSender) sender).getSender().getClass())) + params.add(((Command2MCSender) sender).getSender()); + else if (ChromaGamerBase.class.isAssignableFrom(sendertype) + && sender instanceof Command2MCSender + && (cg = ChromaGamerBase.getFromSender(((Command2MCSender) sender).getSender())) != null + && cg.getClass() == sendertype) //The command expects a user of our system + params.add(cg); + else { + sender.sendMessage("§cYou need to be a " + sendertype.getSimpleName() + " to use this command."); + return; + } + val paramArr = sd.method.getParameters(); + for (int i1 = 1; i1 < parameterTypes.length; i1++) { + Class cl = parameterTypes[i1]; + pj = j + 1; //Start index + if (pj == commandline.length() + 1) { //No param given + if (paramArr[i1].isAnnotationPresent(OptionalArg.class)) { + if (cl.isPrimitive()) + params.add(Defaults.defaultValue(cl)); + else if (Number.class.isAssignableFrom(cl) + || Number.class.isAssignableFrom(cl)) + params.add(Defaults.defaultValue(Primitives.unwrap(cl))); + else + params.add(null); + continue; //Fill the remaining params with nulls + } else { + sender.sendMessage(sd.helpText); //Required param missing + return; } - j = commandline.indexOf(' ', j + 1); //End index - if (j == -1 || paramArr[i1].isAnnotationPresent(TextArg.class)) //Last parameter - j = commandline.length(); - String param = commandline.substring(pj, j); - if (cl == String.class) { - params.add(param); - continue; - } else if (Number.class.isAssignableFrom(cl) || cl.isPrimitive()) { - try { - //noinspection unchecked - Number n = ThorpeUtils.convertNumber(NumberFormat.getInstance().parse(param), (Class) cl); - params.add(n); - } catch (ParseException e) { - sender.sendMessage("§c'" + param + "' is not a number."); - return true; - } - continue; - } - val conv = paramConverters.get(cl); - if (conv == null) - throw new Exception("No suitable converter found for parameter type '" + cl.getCanonicalName() + "' for command '" + sd.method.toString() + "'"); - val cparam = conv.converter.apply(param); - if (cparam == null) { - sender.sendMessage(conv.errormsg); //Param conversion failed - ex. plugin not found - return true; - } - params.add(cparam); } + if (paramArr[i1].isVarArgs()) { + params.add(commandline.substring(j + 1).split(" +")); + continue; + } + j = commandline.indexOf(' ', j + 1); //End index + if (j == -1 || paramArr[i1].isAnnotationPresent(TextArg.class)) //Last parameter + j = commandline.length(); + String param = commandline.substring(pj, j); + if (cl == String.class) { + params.add(param); + continue; + } else if (Number.class.isAssignableFrom(cl) || cl.isPrimitive()) { + try { + //noinspection unchecked + Number n = ThorpeUtils.convertNumber(NumberFormat.getInstance().parse(param), (Class) cl); + params.add(n); + } catch (ParseException e) { + sender.sendMessage("§c'" + param + "' is not a number."); + return; + } + continue; + } + val conv = paramConverters.get(cl); + if (conv == null) + throw new Exception("No suitable converter found for parameter type '" + cl.getCanonicalName() + "' for command '" + sd.method.toString() + "'"); + val cparam = conv.converter.apply(param); + if (cparam == null) { + sender.sendMessage(conv.errormsg); //Param conversion failed - ex. plugin not found + return; + } + params.add(cparam); + } + Bukkit.getScheduler().runTask(MainPlugin.Instance, () -> { try { val ret = sd.method.invoke(sd.command, params.toArray()); //I FORGOT TO TURN IT INTO AN ARRAY (for a long time) if (ret instanceof Boolean) { @@ -218,12 +233,12 @@ public abstract class Command2 sender.sendMessage(sd.helpText); } else if (ret != null) throw new Exception("Wrong return type! Must return a boolean or void. Return value: " + ret); - return true; //We found a method } catch (InvocationTargetException e) { TBMCCoreAPI.SendException("An error occurred in a command handler!", e.getCause()); + } catch (Exception e) { + TBMCCoreAPI.SendException("Command handling failed for sender " + sender + " and subcommand " + subcommand, e); } - } - return false; //Didn't handle + }); } //TODO: Add to the help public abstract void registerCommand(TC command); From 0967095f59340fb7cd082920b8ea61bea866f3eb Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 26 Aug 2019 00:58:09 +0200 Subject: [PATCH 09/18] A few Towny and debug event fixes --- BuildConfigUpdater/BuildConfigUpdater.iml | 1 - ...1) (com.github.TBMCPlugins.ButtonCore).iml | 38 +++++++++++++++++++ .../core/component/towny/TownyComponent.java | 4 +- .../lib/TBMCDebugMessageEvent.java | 2 + 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 ButtonCore/ButtonCore (1) (com.github.TBMCPlugins.ButtonCore).iml diff --git a/BuildConfigUpdater/BuildConfigUpdater.iml b/BuildConfigUpdater/BuildConfigUpdater.iml index cea34c4..31ba17d 100644 --- a/BuildConfigUpdater/BuildConfigUpdater.iml +++ b/BuildConfigUpdater/BuildConfigUpdater.iml @@ -13,7 +13,6 @@ - diff --git a/ButtonCore/ButtonCore (1) (com.github.TBMCPlugins.ButtonCore).iml b/ButtonCore/ButtonCore (1) (com.github.TBMCPlugins.ButtonCore).iml new file mode 100644 index 0000000..fbd4f39 --- /dev/null +++ b/ButtonCore/ButtonCore (1) (com.github.TBMCPlugins.ButtonCore).iml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ButtonCore/src/main/java/buttondevteam/core/component/towny/TownyComponent.java b/ButtonCore/src/main/java/buttondevteam/core/component/towny/TownyComponent.java index 42c857d..3d8966d 100644 --- a/ButtonCore/src/main/java/buttondevteam/core/component/towny/TownyComponent.java +++ b/ButtonCore/src/main/java/buttondevteam/core/component/towny/TownyComponent.java @@ -5,10 +5,10 @@ import buttondevteam.core.MainPlugin; import buttondevteam.lib.TBMCCoreAPI; import buttondevteam.lib.architecture.Component; import com.palmergames.bukkit.towny.Towny; +import com.palmergames.bukkit.towny.TownyUniverse; import com.palmergames.bukkit.towny.exceptions.AlreadyRegisteredException; import com.palmergames.bukkit.towny.exceptions.NotRegisteredException; import com.palmergames.bukkit.towny.object.Resident; -import com.palmergames.bukkit.towny.object.TownyUniverse; import org.bukkit.Bukkit; /** @@ -41,7 +41,7 @@ public class TownyComponent extends Component { TBMCCoreAPI.sendDebugMessage("Target resident name is already in use."); } else try { - TownyUniverse.getDataSource().renamePlayer(resident, newName); //Fixed in Towny 0.91.1.2 + tu.getDataSource().renamePlayer(resident, newName); //Fixed in Towny 0.91.1.2 } catch (AlreadyRegisteredException e) { TBMCCoreAPI.SendException("Failed to rename resident, there's already one with this name.", e); } catch (NotRegisteredException e) { diff --git a/ButtonCore/src/main/java/buttondevteam/lib/TBMCDebugMessageEvent.java b/ButtonCore/src/main/java/buttondevteam/lib/TBMCDebugMessageEvent.java index d2cbbdf..36154c2 100755 --- a/ButtonCore/src/main/java/buttondevteam/lib/TBMCDebugMessageEvent.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/TBMCDebugMessageEvent.java @@ -1,5 +1,6 @@ package buttondevteam.lib; +import org.bukkit.Bukkit; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -9,6 +10,7 @@ public class TBMCDebugMessageEvent extends Event { private boolean sent; public TBMCDebugMessageEvent(String message) { + super(!Bukkit.isPrimaryThread()); this.message = message; } From bb10f9fb0f65ae2ff188f65cae610762e0fbe6ee Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 26 Aug 2019 13:13:42 +0200 Subject: [PATCH 10/18] Only run cmds sync if they were sync Needed for DC command handler --- .../main/java/buttondevteam/lib/chat/Command2.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2.java b/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2.java index 1e75596..f6f3798 100644 --- a/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2.java @@ -131,9 +131,10 @@ public abstract class Command2 String subcommand = commandline.substring(0, i).toLowerCase(); SubcommandData sd = subcommands.get(subcommand); //O(1) if (sd == null) continue; + boolean sync = Bukkit.isPrimaryThread(); Bukkit.getScheduler().runTaskAsynchronously(MainPlugin.Instance, () -> { try { - handleCommandAsync(sender, commandline, sd, subcommand); + handleCommandAsync(sender, commandline, sd, subcommand, sync); } catch (Exception e) { TBMCCoreAPI.SendException("Command execution failed for sender " + sender + " and message " + commandline, e); } @@ -144,7 +145,7 @@ public abstract class Command2 } //Needed because permission checking may load the (perhaps offline) sender's file which is disallowed on the main thread - public void handleCommandAsync(TP sender, String commandline, SubcommandData sd, String subcommand) throws Exception { + public void handleCommandAsync(TP sender, String commandline, SubcommandData sd, String subcommand, boolean sync) throws Exception { if (sd.method == null || sd.command == null) { //Main command not registered, but we have subcommands sender.sendMessage(sd.helpText); return; @@ -225,7 +226,7 @@ public abstract class Command2 } params.add(cparam); } - Bukkit.getScheduler().runTask(MainPlugin.Instance, () -> { + Runnable lol = () -> { try { val ret = sd.method.invoke(sd.command, params.toArray()); //I FORGOT TO TURN IT INTO AN ARRAY (for a long time) if (ret instanceof Boolean) { @@ -238,7 +239,11 @@ public abstract class Command2 } catch (Exception e) { TBMCCoreAPI.SendException("Command handling failed for sender " + sender + " and subcommand " + subcommand, e); } - }); + }; + if (sync) + Bukkit.getScheduler().runTask(MainPlugin.Instance, lol); + else + lol.run(); } //TODO: Add to the help public abstract void registerCommand(TC command); From 17ac28b9b7449fe3969a5bb25f33051280a088b7 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 26 Aug 2019 22:19:53 +0200 Subject: [PATCH 11/18] Rename --- ButtonCore/src/main/resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ButtonCore/src/main/resources/plugin.yml b/ButtonCore/src/main/resources/plugin.yml index 7b3d8bf..81c2ccf 100755 --- a/ButtonCore/src/main/resources/plugin.yml +++ b/ButtonCore/src/main/resources/plugin.yml @@ -1,4 +1,4 @@ -name: ThorpeCore +name: ChromaCore main: buttondevteam.core.MainPlugin version: 1.0 author: TBMCPlugins From ed4a4da37fc49fe95275e543e832aab8b8e6f3bd Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 2 Sep 2019 11:38:51 +0200 Subject: [PATCH 12/18] Fix Travis build, update dependencies, fix test 9 --- .../Maven__net_ess3_Essentials_2_13_1.xml | 13 ------- .travis.yml | 1 + BuildConfigUpdater/BuildConfigUpdater.iml | 1 - ...1) (com.github.TBMCPlugins.ButtonCore).iml | 12 +++++- ButtonCore/pom.xml | 6 +-- .../buttondevteam/core/PlayerDataTest.java | 39 ++++++++++--------- ButtonProcessor/ButtonProcessor.iml | 2 + 7 files changed, 37 insertions(+), 37 deletions(-) delete mode 100644 .idea/libraries/Maven__net_ess3_Essentials_2_13_1.xml diff --git a/.idea/libraries/Maven__net_ess3_Essentials_2_13_1.xml b/.idea/libraries/Maven__net_ess3_Essentials_2_13_1.xml deleted file mode 100644 index bbc5141..0000000 --- a/.idea/libraries/Maven__net_ess3_Essentials_2_13_1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 808d9b0..1d962ae 100755 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ language: java jdk: - oraclejdk8 sudo: true +dist: trusty # Needed for Java 8, although we might not need Java 8 deploy: # deploy develop to the staging environment - provider: script diff --git a/BuildConfigUpdater/BuildConfigUpdater.iml b/BuildConfigUpdater/BuildConfigUpdater.iml index 31ba17d..df2c815 100644 --- a/BuildConfigUpdater/BuildConfigUpdater.iml +++ b/BuildConfigUpdater/BuildConfigUpdater.iml @@ -12,7 +12,6 @@ - diff --git a/ButtonCore/ButtonCore (1) (com.github.TBMCPlugins.ButtonCore).iml b/ButtonCore/ButtonCore (1) (com.github.TBMCPlugins.ButtonCore).iml index fbd4f39..25360d4 100644 --- a/ButtonCore/ButtonCore (1) (com.github.TBMCPlugins.ButtonCore).iml +++ b/ButtonCore/ButtonCore (1) (com.github.TBMCPlugins.ButtonCore).iml @@ -28,9 +28,17 @@ - + - + + + + + + + + + diff --git a/ButtonCore/pom.xml b/ButtonCore/pom.xml index 088389a..8cc0204 100755 --- a/ButtonCore/pom.xml +++ b/ButtonCore/pom.xml @@ -165,7 +165,7 @@ org.projectlombok lombok - 1.16.16 + 1.18.8 provided @@ -176,8 +176,8 @@ net.ess3 - Essentials - 2.13.1 + EssentialsX + 2.17.1 provided diff --git a/ButtonCore/src/test/java/buttondevteam/core/PlayerDataTest.java b/ButtonCore/src/test/java/buttondevteam/core/PlayerDataTest.java index ecfd4ac..1b9c808 100755 --- a/ButtonCore/src/test/java/buttondevteam/core/PlayerDataTest.java +++ b/ButtonCore/src/test/java/buttondevteam/core/PlayerDataTest.java @@ -31,26 +31,29 @@ public class PlayerDataTest extends TestCase { public void testConfig() throws Exception { TestPrepare.PrepareServer(); //FileUtils.deleteDirectory(new File(ChromaGamerBase.TBMC_PLAYERS_DIR)); - Files.walkFileTree(new File(ChromaGamerBase.TBMC_PLAYERS_DIR).toPath(), new SimpleFileVisitor() { - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) - throws IOException { - Files.delete(file); - return FileVisitResult.CONTINUE; - } - - @Override - public FileVisitResult postVisitDirectory(Path dir, IOException e) - throws IOException { - if (e == null) { - Files.delete(dir); + File file = new File(ChromaGamerBase.TBMC_PLAYERS_DIR); + if (file.exists()) { + Files.walkFileTree(file.toPath(), new SimpleFileVisitor() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) + throws IOException { + Files.delete(file); return FileVisitResult.CONTINUE; - } else { - // directory iteration failed - throw e; } - } - }); + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException e) + throws IOException { + if (e == null) { + Files.delete(dir); + return FileVisitResult.CONTINUE; + } else { + // directory iteration failed + throw e; + } + } + }); + } UUID uuid = new UUID(0L, 0L); try (TestPlayerClass p = TBMCPlayerBase.getPlayer(uuid, TestPlayerClass.class)) { p.PlayerName().set("Test"); diff --git a/ButtonProcessor/ButtonProcessor.iml b/ButtonProcessor/ButtonProcessor.iml index 35bfd14..b606543 100755 --- a/ButtonProcessor/ButtonProcessor.iml +++ b/ButtonProcessor/ButtonProcessor.iml @@ -13,6 +13,8 @@ + + From 1a6bd297416a59c665cc2f7a05bf44bfc60ebe10 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 16 Sep 2019 13:31:58 +0200 Subject: [PATCH 13/18] Use original Towny dependency Now that we have one --- .idea/misc.xml | 2 +- ButtonCore/pom.xml | 5 ++--- jitpack.yml | 18 +++++++++--------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 6db2058..1014481 100755 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -17,7 +17,7 @@ - + \ No newline at end of file diff --git a/ButtonCore/pom.xml b/ButtonCore/pom.xml index 8cc0204..af156e8 100755 --- a/ButtonCore/pom.xml +++ b/ButtonCore/pom.xml @@ -137,11 +137,10 @@ 1.12.2-R0.1-SNAPSHOT provided - - com.github.TBMCPlugins.ButtonCore + com.github.TownyAdvanced Towny - master-SNAPSHOT + 0.94.0.9 provided diff --git a/jitpack.yml b/jitpack.yml index 5d9bcff..bc6b9a0 100755 --- a/jitpack.yml +++ b/jitpack.yml @@ -1,10 +1,10 @@ -jdk: - - oraclejdk8 -#before_install: -# - ./prepareEnvironment.sh -install: - - echo "Downloading Towny JAR..." - - 'wget -O "Towny.jar" --header="Accept-Language: en-us,en;q=0.5" http://palmergames.com/file-repo/Towny%20Advanced/Development/0.91.1.5/Towny.jar' - - mvn install:install-file -Dfile=Towny.jar -DgroupId=com.github.TBMCPlugins.ButtonCore -DartifactId=Towny -Dversion=master-SNAPSHOT -Dpackaging=jar - - mvn clean install -DskipTests +jdk: + - oraclejdk8 +#before_install: +# - ./prepareEnvironment.sh +install: +# - echo "Downloading Towny JAR..." +# - 'wget -O "Towny.jar" --header="Accept-Language: en-us,en;q=0.5" http://palmergames.com/file-repo/Towny%20Advanced/Development/0.91.1.5/Towny.jar' +# - mvn install:install-file -Dfile=Towny.jar -DgroupId=com.github.TBMCPlugins.ButtonCore -DartifactId=Towny -Dversion=master-SNAPSHOT -Dpackaging=jar + - mvn clean install -DskipTests # - rm -r ~/.m2/repository/com/palmergames/Towny/ \ No newline at end of file From 383e9dc8d567bcf80b5ffd4f98ddcedd01031476 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 20 Oct 2019 15:10:09 +0200 Subject: [PATCH 14/18] Rename & fix #75 --- .idea/misc.xml | 2 +- BuildConfigUpdater/BuildConfigUpdater.iml | 1 + ...1) (com.github.TBMCPlugins.ButtonCore).iml | 46 ------------------- ...{ThorpeCommand.java => ChromaCommand.java} | 4 +- .../java/buttondevteam/core/MainPlugin.java | 2 +- .../buttondevteam/core/PlayerListener.java | 2 +- .../core/component/spawn/SpawnComponent.java | 4 +- .../{ThorpeUtils.java => ChromaUtils.java} | 4 +- .../lib/architecture/ConfigData.java | 4 +- .../java/buttondevteam/lib/chat/Command2.java | 6 +-- .../buttondevteam/lib/chat/Command2MC.java | 8 ++-- .../buttondevteam/lib/chat/CommandClass.java | 2 +- .../buttondevteam/lib/chat/TBMCChatAPI.java | 4 +- ButtonProcessor/ButtonProcessor.iml | 2 - 14 files changed, 22 insertions(+), 69 deletions(-) delete mode 100644 ButtonCore/ButtonCore (1) (com.github.TBMCPlugins.ButtonCore).iml rename ButtonCore/src/main/java/buttondevteam/core/{ThorpeCommand.java => ChromaCommand.java} (81%) rename ButtonCore/src/main/java/buttondevteam/lib/{ThorpeUtils.java => ChromaUtils.java} (97%) diff --git a/.idea/misc.xml b/.idea/misc.xml index 1014481..e405a1f 100755 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -17,7 +17,7 @@ - + \ No newline at end of file diff --git a/BuildConfigUpdater/BuildConfigUpdater.iml b/BuildConfigUpdater/BuildConfigUpdater.iml index df2c815..31ba17d 100644 --- a/BuildConfigUpdater/BuildConfigUpdater.iml +++ b/BuildConfigUpdater/BuildConfigUpdater.iml @@ -12,6 +12,7 @@ + diff --git a/ButtonCore/ButtonCore (1) (com.github.TBMCPlugins.ButtonCore).iml b/ButtonCore/ButtonCore (1) (com.github.TBMCPlugins.ButtonCore).iml deleted file mode 100644 index 25360d4..0000000 --- a/ButtonCore/ButtonCore (1) (com.github.TBMCPlugins.ButtonCore).iml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ButtonCore/src/main/java/buttondevteam/core/ThorpeCommand.java b/ButtonCore/src/main/java/buttondevteam/core/ChromaCommand.java similarity index 81% rename from ButtonCore/src/main/java/buttondevteam/core/ThorpeCommand.java rename to ButtonCore/src/main/java/buttondevteam/core/ChromaCommand.java index 91f2d5c..f17dbf8 100644 --- a/ButtonCore/src/main/java/buttondevteam/core/ThorpeCommand.java +++ b/ButtonCore/src/main/java/buttondevteam/core/ChromaCommand.java @@ -6,11 +6,11 @@ import buttondevteam.lib.chat.ICommand2MC; import org.bukkit.command.CommandSender; @CommandClass -public class ThorpeCommand extends ICommand2MC { +public class ChromaCommand extends ICommand2MC { @Command2.Subcommand //TODO: Main permissions (groups) like 'mod' public void reload(CommandSender sender) { if (MainPlugin.Instance.tryReloadConfig()) - sender.sendMessage("§bConfig reloaded."); + sender.sendMessage("§bCore config reloaded."); else sender.sendMessage("§cFailed to reload config. Check console."); } diff --git a/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java b/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java index 01132f9..d5b690b 100755 --- a/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java +++ b/ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java @@ -97,7 +97,7 @@ public class MainPlugin extends ButtonPlugin { Component.registerComponent(this, new VotifierComponent(economy)); ComponentManager.enableComponents(); getCommand2MC().registerCommand(new ComponentCommand()); - getCommand2MC().registerCommand(new ThorpeCommand()); + getCommand2MC().registerCommand(new ChromaCommand()); TBMCCoreAPI.RegisterEventsForExceptions(new PlayerListener(), this); TBMCCoreAPI.RegisterEventsForExceptions(getCommand2MC(), this); ChromaGamerBase.addConverter(commandSender -> Optional.ofNullable(commandSender instanceof ConsoleCommandSender || commandSender instanceof BlockCommandSender diff --git a/ButtonCore/src/main/java/buttondevteam/core/PlayerListener.java b/ButtonCore/src/main/java/buttondevteam/core/PlayerListener.java index 097b90a..d29a9e8 100755 --- a/ButtonCore/src/main/java/buttondevteam/core/PlayerListener.java +++ b/ButtonCore/src/main/java/buttondevteam/core/PlayerListener.java @@ -93,7 +93,7 @@ public class PlayerListener implements Listener { String msg = MainPlugin.Instance.chatFormat().get() .replace("{channel}", event.getChannel().DisplayName().get()) .replace("{origin}", event.getOrigin().substring(0, 1)) - .replace("{name}", ThorpeUtils.getDisplayName(event.getSender())) + .replace("{name}", ChromaUtils.getDisplayName(event.getSender())) .replace("{message}", event.getMessage()); for (Player player : Bukkit.getOnlinePlayers()) if (event.shouldSendTo(player)) diff --git a/ButtonCore/src/main/java/buttondevteam/core/component/spawn/SpawnComponent.java b/ButtonCore/src/main/java/buttondevteam/core/component/spawn/SpawnComponent.java index a9b9970..12cc43b 100644 --- a/ButtonCore/src/main/java/buttondevteam/core/component/spawn/SpawnComponent.java +++ b/ButtonCore/src/main/java/buttondevteam/core/component/spawn/SpawnComponent.java @@ -98,8 +98,8 @@ public class SpawnComponent extends Component implements PluginMessa Bukkit.getScheduler().runTask(getPlugin(), () -> { //Delay it a bit ByteArrayDataOutput outt = ByteStreams.newDataOutput(); - outt.writeUTF("Forward"); // So BungeeCord knows to forward it - outt.writeUTF("ALL"); + outt.writeUTF("ForwardToPlayer"); // So BungeeCord knows to forward it + outt.writeUTF(player.getName()); outt.writeUTF("ChromaCore-Spawn"); // The channel name to check if this your data ByteArrayOutputStream msgbytes = new ByteArrayOutputStream(); diff --git a/ButtonCore/src/main/java/buttondevteam/lib/ThorpeUtils.java b/ButtonCore/src/main/java/buttondevteam/lib/ChromaUtils.java similarity index 97% rename from ButtonCore/src/main/java/buttondevteam/lib/ThorpeUtils.java rename to ButtonCore/src/main/java/buttondevteam/lib/ChromaUtils.java index bf19323..7fa3105 100644 --- a/ButtonCore/src/main/java/buttondevteam/lib/ThorpeUtils.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/ChromaUtils.java @@ -9,8 +9,8 @@ import org.bukkit.event.Event; import java.util.function.Supplier; -public final class ThorpeUtils { - private ThorpeUtils() {} +public final class ChromaUtils { + private ChromaUtils() {} public static String getDisplayName(CommandSender sender) { if (sender instanceof IHaveFancyName) diff --git a/ButtonCore/src/main/java/buttondevteam/lib/architecture/ConfigData.java b/ButtonCore/src/main/java/buttondevteam/lib/architecture/ConfigData.java index b14f7c6..2d74f3e 100644 --- a/ButtonCore/src/main/java/buttondevteam/lib/architecture/ConfigData.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/architecture/ConfigData.java @@ -1,7 +1,7 @@ package buttondevteam.lib.architecture; import buttondevteam.core.MainPlugin; -import buttondevteam.lib.ThorpeUtils; +import buttondevteam.lib.ChromaUtils; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; @@ -101,7 +101,7 @@ public class ConfigData { return hmm; } if (val instanceof Number && def != null) - val = ThorpeUtils.convertNumber((Number) val, + val = ChromaUtils.convertNumber((Number) val, (Class) def.getClass()); if (val instanceof List && def != null && def.getClass().isArray()) val = ((List) val).toArray((T[]) Array.newInstance(def.getClass().getComponentType(), 0)); diff --git a/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2.java b/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2.java index f6f3798..eea8a2b 100644 --- a/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2.java @@ -1,8 +1,8 @@ package buttondevteam.lib.chat; import buttondevteam.core.MainPlugin; +import buttondevteam.lib.ChromaUtils; import buttondevteam.lib.TBMCCoreAPI; -import buttondevteam.lib.ThorpeUtils; import buttondevteam.lib.player.ChromaGamerBase; import com.google.common.base.Defaults; import com.google.common.primitives.Primitives; @@ -60,7 +60,7 @@ public abstract class Command2 String[] helpText() default {}; /** - * The main permission which allows using this command (individual access can be still granted with "thorpe.command.X"). + * The main permission which allows using this command (individual access can be still granted with "chroma.command.X"). * Used to be "tbmc.admin". The {@link #MOD_GROUP} is provided to use with this. */ String permGroup() default ""; //TODO @@ -208,7 +208,7 @@ public abstract class Command2 } else if (Number.class.isAssignableFrom(cl) || cl.isPrimitive()) { try { //noinspection unchecked - Number n = ThorpeUtils.convertNumber(NumberFormat.getInstance().parse(param), (Class) cl); + Number n = ChromaUtils.convertNumber(NumberFormat.getInstance().parse(param), (Class) cl); params.add(n); } catch (ParseException e) { sender.sendMessage("§c'" + param + "' is not a number."); diff --git a/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2MC.java b/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2MC.java index e111d77..809cc46 100644 --- a/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2MC.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2MC.java @@ -24,7 +24,7 @@ public class Command2MC extends Command2 implemen @Override public void registerCommand(ICommand2MC command) { super.registerCommand(command, '/'); - var perm = "thorpe.command." + command.getCommandPath().replace(' ', '.'); + var perm = "chroma.command." + command.getCommandPath().replace(' ', '.'); if (Bukkit.getPluginManager().getPermission(perm) == null) //Check needed for plugin reset Bukkit.getPluginManager().addPermission(new Permission(perm, modOnly(command) ? PermissionDefault.OP : PermissionDefault.TRUE)); //Allow commands by default, unless it's mod only - TODO: Test @@ -32,7 +32,7 @@ public class Command2MC extends Command2 implemen if (!method.isAnnotationPresent(Subcommand.class)) continue; String pg = permGroup(command, method); if (pg.length() == 0) continue; - perm = "thorpe." + pg; + perm = "chroma." + pg; if (Bukkit.getPluginManager().getPermission(perm) == null) //It may occur multiple times Bukkit.getPluginManager().addPermission(new Permission(perm, //pg.equals(Subcommand.MOD_GROUP) ? PermissionDefault.OP : PermissionDefault.TRUE)); //Allow commands by default, unless it's mod only @@ -50,8 +50,8 @@ public class Command2MC extends Command2 implemen String pg; boolean p = true; String[] perms = { - "thorpe.command." + command.getCommandPath().replace(' ', '.'), - (pg = permGroup(command, method)).length() > 0 ? "thorpe." + pg : null, + "chroma.command." + command.getCommandPath().replace(' ', '.'), + (pg = permGroup(command, method)).length() > 0 ? "chroma." + pg : null, modOnly(command) ? "tbmc.admin" : null }; for (String perm : perms) { diff --git a/ButtonCore/src/main/java/buttondevteam/lib/chat/CommandClass.java b/ButtonCore/src/main/java/buttondevteam/lib/chat/CommandClass.java index bc17204..327ebe7 100755 --- a/ButtonCore/src/main/java/buttondevteam/lib/chat/CommandClass.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/chat/CommandClass.java @@ -46,7 +46,7 @@ public @interface CommandClass { String[] helpText() default {}; /** - * The main permission which allows using this command (individual access can be still granted with "thorpe.command.X"). + * The main permission which allows using this command (individual access can be still granted with "chroma.command.X"). * Used to be "tbmc.admin" */ String permGroup() default ""; //TODO: A single annotation instead of these two diff --git a/ButtonCore/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java b/ButtonCore/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java index 92dece9..b6b160b 100755 --- a/ButtonCore/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java @@ -287,7 +287,7 @@ public class TBMCChatAPI { Bukkit.getPluginManager().callEvent(event); return event.isCancelled(); }; - return ThorpeUtils.doItAsync(task, false); //Not cancelled if async + return ChromaUtils.doItAsync(task, false); //Not cancelled if async } /** @@ -307,7 +307,7 @@ public class TBMCChatAPI { if (!Arrays.asList(exceptions).contains("Minecraft")) Bukkit.getConsoleSender().sendMessage("[" + channel.DisplayName().get() + "] " + message); TBMCSystemChatEvent event = new TBMCSystemChatEvent(channel, message, rtr.score, rtr.groupID, exceptions, target); - return ThorpeUtils.callEventAsync(event); + return ChromaUtils.callEventAsync(event); } private static RecipientTestResult getScoreOrSendError(Channel channel, CommandSender sender) { diff --git a/ButtonProcessor/ButtonProcessor.iml b/ButtonProcessor/ButtonProcessor.iml index b606543..35bfd14 100755 --- a/ButtonProcessor/ButtonProcessor.iml +++ b/ButtonProcessor/ButtonProcessor.iml @@ -13,8 +13,6 @@ - - From 7b29f001057e1e81a6f52b2e87383a2fa6ae336e Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 20 Oct 2019 20:48:24 +0200 Subject: [PATCH 15/18] Update to Java 10/11 --- .idea/compiler.xml | 6 +- .idea/misc.xml | 2 +- BuildConfigUpdater/BuildConfigUpdater.iml | 3 +- BuildConfigUpdater/pom.xml | 1 - ButtonCore/pom.xml | 8 -- .../lib/architecture/ButtonPlugin.java | 1 - .../lib/architecture/Component.java | 1 - .../java/buttondevteam/lib/chat/Command2.java | 1 - .../buttondevteam/lib/chat/Command2MC.java | 1 - ButtonProcessor/ButtonProcessor.iml | 2 +- ButtonProcessor/pom.xml | 2 - pom.xml | 96 +++++++++---------- 12 files changed, 54 insertions(+), 70 deletions(-) diff --git a/.idea/compiler.xml b/.idea/compiler.xml index ba952b2..2317a4e 100755 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -12,10 +12,10 @@ - + - - + + diff --git a/.idea/misc.xml b/.idea/misc.xml index e405a1f..1014481 100755 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -17,7 +17,7 @@ - + \ No newline at end of file diff --git a/BuildConfigUpdater/BuildConfigUpdater.iml b/BuildConfigUpdater/BuildConfigUpdater.iml index 31ba17d..567e232 100644 --- a/BuildConfigUpdater/BuildConfigUpdater.iml +++ b/BuildConfigUpdater/BuildConfigUpdater.iml @@ -1,6 +1,6 @@ - + @@ -12,7 +12,6 @@ - diff --git a/BuildConfigUpdater/pom.xml b/BuildConfigUpdater/pom.xml index 01781fb..2fe01de 100644 --- a/BuildConfigUpdater/pom.xml +++ b/BuildConfigUpdater/pom.xml @@ -39,5 +39,4 @@ 2.6 - \ No newline at end of file diff --git a/ButtonCore/pom.xml b/ButtonCore/pom.xml index af156e8..23d0e4b 100755 --- a/ButtonCore/pom.xml +++ b/ButtonCore/pom.xml @@ -26,14 +26,6 @@ ButtonCore - - maven-compiler-plugin - - 1.8 - 1.8 - UTF-8 - - org.apache.maven.plugins maven-shade-plugin diff --git a/ButtonCore/src/main/java/buttondevteam/lib/architecture/ButtonPlugin.java b/ButtonCore/src/main/java/buttondevteam/lib/architecture/ButtonPlugin.java index c4e7ce1..d22f192 100644 --- a/ButtonCore/src/main/java/buttondevteam/lib/architecture/ButtonPlugin.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/architecture/ButtonPlugin.java @@ -6,7 +6,6 @@ import buttondevteam.lib.chat.Command2MC; import buttondevteam.lib.chat.TBMCChatAPI; import lombok.AccessLevel; import lombok.Getter; -import lombok.experimental.var; import org.bukkit.plugin.java.JavaPlugin; import java.lang.annotation.ElementType; diff --git a/ButtonCore/src/main/java/buttondevteam/lib/architecture/Component.java b/ButtonCore/src/main/java/buttondevteam/lib/architecture/Component.java index a39db67..582102f 100644 --- a/ButtonCore/src/main/java/buttondevteam/lib/architecture/Component.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/architecture/Component.java @@ -8,7 +8,6 @@ import buttondevteam.lib.chat.TBMCChatAPI; import buttondevteam.lib.chat.TBMCCommandBase; import lombok.Getter; import lombok.NonNull; -import lombok.experimental.var; import lombok.val; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.event.Listener; diff --git a/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2.java b/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2.java index eea8a2b..562de54 100644 --- a/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2.java @@ -8,7 +8,6 @@ import com.google.common.base.Defaults; import com.google.common.primitives.Primitives; import lombok.AllArgsConstructor; import lombok.RequiredArgsConstructor; -import lombok.experimental.var; import lombok.val; import org.bukkit.Bukkit; import org.bukkit.configuration.file.YamlConfiguration; diff --git a/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2MC.java b/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2MC.java index 809cc46..561befc 100644 --- a/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2MC.java +++ b/ButtonCore/src/main/java/buttondevteam/lib/chat/Command2MC.java @@ -1,7 +1,6 @@ package buttondevteam.lib.chat; import buttondevteam.core.MainPlugin; -import lombok.experimental.var; import lombok.val; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; diff --git a/ButtonProcessor/ButtonProcessor.iml b/ButtonProcessor/ButtonProcessor.iml index 35bfd14..30c9f05 100755 --- a/ButtonProcessor/ButtonProcessor.iml +++ b/ButtonProcessor/ButtonProcessor.iml @@ -1,7 +1,7 @@ - + diff --git a/ButtonProcessor/pom.xml b/ButtonProcessor/pom.xml index 401e62c..35626d7 100755 --- a/ButtonProcessor/pom.xml +++ b/ButtonProcessor/pom.xml @@ -38,8 +38,6 @@ maven-compiler-plugin - 1.8 - 1.8 -proc:none diff --git a/pom.xml b/pom.xml index 9529df4..3ed6cd8 100755 --- a/pom.xml +++ b/pom.xml @@ -1,49 +1,49 @@ - - 4.0.0 - - com.github.TBMCPlugins - ButtonCore - pom - master-SNAPSHOT - ButtonCore Parent - - - ButtonCore - ButtonProcessor - BuildConfigUpdater - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.3 - - 1.8 - 1.8 - - - - maven-surefire-plugin - - false - - - - - - - - - junit - junit - 3.8.1 - test - - + + 4.0.0 + + com.github.TBMCPlugins + ButtonCore + pom + master-SNAPSHOT + ButtonCore Parent + + + ButtonCore + ButtonProcessor + BuildConfigUpdater + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 10 + 10 + + + + maven-surefire-plugin + + false + + + + + + + + + junit + junit + 3.8.1 + test + + \ No newline at end of file From dd64062fba7a55721cbbfa621d88029749c2851b Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Wed, 23 Oct 2019 01:22:24 +0200 Subject: [PATCH 16/18] Compile to Java 8 using Jabel Currently, the server runs on Java 8 and some plugins, notably Terrain Control depend on a version-specific hack. Now, we do want to drop TC anyway to upgrade to 1.14.4 but there's also the goal of sharing this plugin for others, who likely run Java 8. It took me a while to figure out how to make it work with Lombok - have to use the right order. --- .idea/compiler.xml | 29 +++++++-- ...google_code_findbugs_annotations_2_0_1.xml | 13 ---- ...Maven__com_google_code_gson_gson_2_8_0.xml | 13 ---- .../Maven__com_google_guava_guava_15_0.xml | 13 ---- .../Maven__com_google_guava_guava_21_0.xml | 13 ---- ...oglecode_json_simple_json_simple_1_1_1.xml | 13 ---- .../Maven__commons_io_commons_io_2_6.xml | 13 ---- .../Maven__commons_lang_commons_lang_2_6.xml | 13 ---- .idea/libraries/Maven__junit_junit_3_8_1.xml | 13 ---- ...net_md_5_bungeecord_chat_1_12_SNAPSHOT.xml | 13 ---- ...org_bukkit_bukkit_1_13_1_R0_1_SNAPSHOT.xml | 13 ---- ...ven__org_javassist_javassist_3_20_0_GA.xml | 13 ---- ...en__org_reflections_reflections_0_9_10.xml | 13 ---- ...igotmc_spigot_api_1_12_2_R0_1_SNAPSHOT.xml | 13 ---- .../Maven__org_yaml_snakeyaml_1_19.xml | 13 ---- BuildConfigUpdater/BuildConfigUpdater.iml | 9 ++- ButtonCore/pom.xml | 7 --- ButtonProcessor/ButtonProcessor.iml | 9 ++- pom.xml | 60 ++++++++++++++++++- 19 files changed, 98 insertions(+), 198 deletions(-) delete mode 100755 .idea/libraries/Maven__com_google_code_findbugs_annotations_2_0_1.xml delete mode 100644 .idea/libraries/Maven__com_google_code_gson_gson_2_8_0.xml delete mode 100755 .idea/libraries/Maven__com_google_guava_guava_15_0.xml delete mode 100644 .idea/libraries/Maven__com_google_guava_guava_21_0.xml delete mode 100755 .idea/libraries/Maven__com_googlecode_json_simple_json_simple_1_1_1.xml delete mode 100644 .idea/libraries/Maven__commons_io_commons_io_2_6.xml delete mode 100755 .idea/libraries/Maven__commons_lang_commons_lang_2_6.xml delete mode 100755 .idea/libraries/Maven__junit_junit_3_8_1.xml delete mode 100644 .idea/libraries/Maven__net_md_5_bungeecord_chat_1_12_SNAPSHOT.xml delete mode 100644 .idea/libraries/Maven__org_bukkit_bukkit_1_13_1_R0_1_SNAPSHOT.xml delete mode 100755 .idea/libraries/Maven__org_javassist_javassist_3_20_0_GA.xml delete mode 100755 .idea/libraries/Maven__org_reflections_reflections_0_9_10.xml delete mode 100644 .idea/libraries/Maven__org_spigotmc_spigot_api_1_12_2_R0_1_SNAPSHOT.xml delete mode 100644 .idea/libraries/Maven__org_yaml_snakeyaml_1_19.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 2317a4e..0de1f8c 100755 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -3,26 +3,45 @@ - + + + + + + + + + + + + + + + + + + - + - - + + \ No newline at end of file diff --git a/.idea/libraries/Maven__com_google_code_findbugs_annotations_2_0_1.xml b/.idea/libraries/Maven__com_google_code_findbugs_annotations_2_0_1.xml deleted file mode 100755 index a3d1316..0000000 --- a/.idea/libraries/Maven__com_google_code_findbugs_annotations_2_0_1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__com_google_code_gson_gson_2_8_0.xml b/.idea/libraries/Maven__com_google_code_gson_gson_2_8_0.xml deleted file mode 100644 index 6e5d5b7..0000000 --- a/.idea/libraries/Maven__com_google_code_gson_gson_2_8_0.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__com_google_guava_guava_15_0.xml b/.idea/libraries/Maven__com_google_guava_guava_15_0.xml deleted file mode 100755 index 8ae2de1..0000000 --- a/.idea/libraries/Maven__com_google_guava_guava_15_0.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__com_google_guava_guava_21_0.xml b/.idea/libraries/Maven__com_google_guava_guava_21_0.xml deleted file mode 100644 index a923456..0000000 --- a/.idea/libraries/Maven__com_google_guava_guava_21_0.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__com_googlecode_json_simple_json_simple_1_1_1.xml b/.idea/libraries/Maven__com_googlecode_json_simple_json_simple_1_1_1.xml deleted file mode 100755 index f3f3738..0000000 --- a/.idea/libraries/Maven__com_googlecode_json_simple_json_simple_1_1_1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__commons_io_commons_io_2_6.xml b/.idea/libraries/Maven__commons_io_commons_io_2_6.xml deleted file mode 100644 index d722698..0000000 --- a/.idea/libraries/Maven__commons_io_commons_io_2_6.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__commons_lang_commons_lang_2_6.xml b/.idea/libraries/Maven__commons_lang_commons_lang_2_6.xml deleted file mode 100755 index 2ec8376..0000000 --- a/.idea/libraries/Maven__commons_lang_commons_lang_2_6.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__junit_junit_3_8_1.xml b/.idea/libraries/Maven__junit_junit_3_8_1.xml deleted file mode 100755 index 71b2993..0000000 --- a/.idea/libraries/Maven__junit_junit_3_8_1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__net_md_5_bungeecord_chat_1_12_SNAPSHOT.xml b/.idea/libraries/Maven__net_md_5_bungeecord_chat_1_12_SNAPSHOT.xml deleted file mode 100644 index a472890..0000000 --- a/.idea/libraries/Maven__net_md_5_bungeecord_chat_1_12_SNAPSHOT.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_bukkit_bukkit_1_13_1_R0_1_SNAPSHOT.xml b/.idea/libraries/Maven__org_bukkit_bukkit_1_13_1_R0_1_SNAPSHOT.xml deleted file mode 100644 index 63108e8..0000000 --- a/.idea/libraries/Maven__org_bukkit_bukkit_1_13_1_R0_1_SNAPSHOT.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_javassist_javassist_3_20_0_GA.xml b/.idea/libraries/Maven__org_javassist_javassist_3_20_0_GA.xml deleted file mode 100755 index c21c9b0..0000000 --- a/.idea/libraries/Maven__org_javassist_javassist_3_20_0_GA.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_reflections_reflections_0_9_10.xml b/.idea/libraries/Maven__org_reflections_reflections_0_9_10.xml deleted file mode 100755 index d92ca0d..0000000 --- a/.idea/libraries/Maven__org_reflections_reflections_0_9_10.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_spigotmc_spigot_api_1_12_2_R0_1_SNAPSHOT.xml b/.idea/libraries/Maven__org_spigotmc_spigot_api_1_12_2_R0_1_SNAPSHOT.xml deleted file mode 100644 index b6f88ae..0000000 --- a/.idea/libraries/Maven__org_spigotmc_spigot_api_1_12_2_R0_1_SNAPSHOT.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_yaml_snakeyaml_1_19.xml b/.idea/libraries/Maven__org_yaml_snakeyaml_1_19.xml deleted file mode 100644 index 33ccf19..0000000 --- a/.idea/libraries/Maven__org_yaml_snakeyaml_1_19.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/BuildConfigUpdater/BuildConfigUpdater.iml b/BuildConfigUpdater/BuildConfigUpdater.iml index 567e232..8be4539 100644 --- a/BuildConfigUpdater/BuildConfigUpdater.iml +++ b/BuildConfigUpdater/BuildConfigUpdater.iml @@ -1,12 +1,18 @@ - + + + + + + + @@ -29,5 +35,6 @@ + \ No newline at end of file diff --git a/ButtonCore/pom.xml b/ButtonCore/pom.xml index 23d0e4b..752e64d 100755 --- a/ButtonCore/pom.xml +++ b/ButtonCore/pom.xml @@ -152,13 +152,6 @@ mockito-core 3.0.0 - - - org.projectlombok - lombok - 1.18.8 - provided - com.github.TBMCPlugins.ButtonCore ButtonProcessor diff --git a/ButtonProcessor/ButtonProcessor.iml b/ButtonProcessor/ButtonProcessor.iml index 30c9f05..d373248 100755 --- a/ButtonProcessor/ButtonProcessor.iml +++ b/ButtonProcessor/ButtonProcessor.iml @@ -1,13 +1,19 @@ - + + + + + + + @@ -20,5 +26,6 @@ + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 3ed6cd8..422fc03 100755 --- a/pom.xml +++ b/pom.xml @@ -8,6 +8,9 @@ ButtonCore pom master-SNAPSHOT + + 1.18.10 + ButtonCore Parent @@ -24,8 +27,29 @@ maven-compiler-plugin 3.8.1 - 10 - 10 + 8 + + + com.github.bsideup.jabel + jabel-javac-plugin + 0.2.0 + + + org.projectlombok + lombok + ${lombok.version} + + + com.github.TBMCPlugins.ButtonCore + ButtonProcessor + master-SNAPSHOT + + + + com.github.bsideup.jabel.JabelJavacProcessor + lombok.launch.AnnotationProcessorHider$AnnotationProcessor + buttondevteam.buttonproc.ButtonProcessor + @@ -45,5 +69,37 @@ 3.8.1 test + + + org.projectlombok + lombok + ${lombok.version} + provided + + + + + intellij-idea-only + + + idea.maven.embedder.version + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 13 + + --enable-preview + + + + + + + \ No newline at end of file From d100b86d72108d543c197fd5af1d45b4a2343823 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Wed, 23 Oct 2019 02:07:31 +0200 Subject: [PATCH 17/18] Create parent POM for all my plugins Also update Travis config to use Java 11 Also fix gitignore --- .gitignore | 4 +- .idea/compiler.xml | 28 ++++-- .idea/modules.xml | 1 + .travis.yml | 3 +- BuildConfigUpdater/BuildConfigUpdater.iml | 2 +- ButtonCore/pom.xml | 6 +- ButtonProcessor/ButtonProcessor.iml | 2 +- CorePOM/CorePOM.iml | 20 ++++ CorePOM/pom.xml | 108 ++++++++++++++++++++++ pom.xml | 48 +--------- 10 files changed, 160 insertions(+), 62 deletions(-) create mode 100644 CorePOM/CorePOM.iml create mode 100755 CorePOM/pom.xml diff --git a/.gitignore b/.gitignore index 8983379..7219eb8 100755 --- a/.gitignore +++ b/.gitignore @@ -220,8 +220,8 @@ pip-log.txt TheButtonAutoFlair/out/artifacts/Autoflair/Autoflair.jar #*.iml *.name -.idea/compiler.xml -*.xml +.idea +dependency-reduced-pom.xml TBMC/ /.apt_generated/ diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 0de1f8c..56dd862 100755 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -3,13 +3,29 @@ + + + + + + + + + + + + + + + + - + @@ -24,24 +40,24 @@ - - + - + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index 0b24af5..c3d052f 100755 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -5,6 +5,7 @@ + \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 1d962ae..7a60b95 100755 --- a/.travis.yml +++ b/.travis.yml @@ -9,9 +9,8 @@ before_install: | # Wget BuildTools and run if cached folder not found fi language: java jdk: - - oraclejdk8 + - oraclejdk11 sudo: true -dist: trusty # Needed for Java 8, although we might not need Java 8 deploy: # deploy develop to the staging environment - provider: script diff --git a/BuildConfigUpdater/BuildConfigUpdater.iml b/BuildConfigUpdater/BuildConfigUpdater.iml index 8be4539..67aa057 100644 --- a/BuildConfigUpdater/BuildConfigUpdater.iml +++ b/BuildConfigUpdater/BuildConfigUpdater.iml @@ -5,7 +5,7 @@ - + diff --git a/ButtonCore/pom.xml b/ButtonCore/pom.xml index 752e64d..93d96e3 100755 --- a/ButtonCore/pom.xml +++ b/ButtonCore/pom.xml @@ -2,11 +2,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.github.TBMCPlugins - ButtonCore + com.github.TBMCPlugins.ButtonCore + CorePOM master-SNAPSHOT + ../CorePOM - com.github.TBMCPlugins.ButtonCore ButtonCore ButtonCore ButtonCore diff --git a/ButtonProcessor/ButtonProcessor.iml b/ButtonProcessor/ButtonProcessor.iml index d373248..a6bf3b9 100755 --- a/ButtonProcessor/ButtonProcessor.iml +++ b/ButtonProcessor/ButtonProcessor.iml @@ -6,7 +6,7 @@ - + diff --git a/CorePOM/CorePOM.iml b/CorePOM/CorePOM.iml new file mode 100644 index 0000000..0e07dc2 --- /dev/null +++ b/CorePOM/CorePOM.iml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CorePOM/pom.xml b/CorePOM/pom.xml new file mode 100755 index 0000000..024d7eb --- /dev/null +++ b/CorePOM/pom.xml @@ -0,0 +1,108 @@ + + 4.0.0 + + com.github.TBMCPlugins.ButtonCore + CorePOM + pom + master-SNAPSHOT + + 1.18.10 + + Core POM for Chroma + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 8 + + + com.github.bsideup.jabel + jabel-javac-plugin + 0.2.0 + + + org.projectlombok + lombok + ${lombok.version} + + + com.github.TBMCPlugins.ButtonCore + ButtonProcessor + master-SNAPSHOT + + + + com.github.bsideup.jabel.JabelJavacProcessor + lombok.launch.AnnotationProcessorHider$AnnotationProcessor + + buttondevteam.buttonproc.ButtonProcessor + + + + + maven-surefire-plugin + + false + + + + + + + + + + jitpack.io + https://jitpack.io/ + + + + + + junit + junit + 3.8.1 + test + + + + org.projectlombok + lombok + ${lombok.version} + provided + + + + + + intellij-idea-only + + + idea.maven.embedder.version + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 13 + + --enable-preview + + + + + + + + diff --git a/pom.xml b/pom.xml index 422fc03..935e426 100755 --- a/pom.xml +++ b/pom.xml @@ -14,6 +14,7 @@ ButtonCore Parent + CorePOM ButtonCore ButtonProcessor BuildConfigUpdater @@ -28,28 +29,6 @@ 3.8.1 8 - - - com.github.bsideup.jabel - jabel-javac-plugin - 0.2.0 - - - org.projectlombok - lombok - ${lombok.version} - - - com.github.TBMCPlugins.ButtonCore - ButtonProcessor - master-SNAPSHOT - - - - com.github.bsideup.jabel.JabelJavacProcessor - lombok.launch.AnnotationProcessorHider$AnnotationProcessor - buttondevteam.buttonproc.ButtonProcessor - @@ -77,29 +56,4 @@ provided - - - - intellij-idea-only - - - idea.maven.embedder.version - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 13 - - --enable-preview - - - - - - - \ No newline at end of file From 2f62d2b962e300812a3869718256317c0bd3fa29 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Wed, 30 Oct 2019 19:08:24 +0100 Subject: [PATCH 18/18] Removing jitpack.yml so it builds with what's in the POM --- BuildConfigUpdater/BuildConfigUpdater.iml | 1 + jitpack.yml | 10 ---------- 2 files changed, 1 insertion(+), 10 deletions(-) delete mode 100755 jitpack.yml diff --git a/BuildConfigUpdater/BuildConfigUpdater.iml b/BuildConfigUpdater/BuildConfigUpdater.iml index 67aa057..04dfdc0 100644 --- a/BuildConfigUpdater/BuildConfigUpdater.iml +++ b/BuildConfigUpdater/BuildConfigUpdater.iml @@ -18,6 +18,7 @@ + diff --git a/jitpack.yml b/jitpack.yml deleted file mode 100755 index bc6b9a0..0000000 --- a/jitpack.yml +++ /dev/null @@ -1,10 +0,0 @@ -jdk: - - oraclejdk8 -#before_install: -# - ./prepareEnvironment.sh -install: -# - echo "Downloading Towny JAR..." -# - 'wget -O "Towny.jar" --header="Accept-Language: en-us,en;q=0.5" http://palmergames.com/file-repo/Towny%20Advanced/Development/0.91.1.5/Towny.jar' -# - mvn install:install-file -Dfile=Towny.jar -DgroupId=com.github.TBMCPlugins.ButtonCore -DartifactId=Towny -Dversion=master-SNAPSHOT -Dpackaging=jar - - mvn clean install -DskipTests -# - rm -r ~/.m2/repository/com/palmergames/Towny/ \ No newline at end of file