From c6f2d5530dff70880d90a32c719430462f6b888f Mon Sep 17 00:00:00 2001 From: jascotty2 Date: Thu, 19 Sep 2019 09:20:49 -0500 Subject: [PATCH 1/6] remove sync from datamanager --- .../songoda/core/database/DataManagerAbstract.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Core/src/main/java/com/songoda/core/database/DataManagerAbstract.java b/Core/src/main/java/com/songoda/core/database/DataManagerAbstract.java index 6625d718..57ae5388 100644 --- a/Core/src/main/java/com/songoda/core/database/DataManagerAbstract.java +++ b/Core/src/main/java/com/songoda/core/database/DataManagerAbstract.java @@ -43,12 +43,13 @@ public class DataManagerAbstract { } } + /** + * Queue a task to be run asynchronously.
+ * TODO: This needs to be separated from BukkitScheduler + * + * @param runnable task to run + */ public void async(Runnable runnable) { Bukkit.getScheduler().runTaskAsynchronously(this.plugin, runnable); } - - public void sync(Runnable runnable) { - Bukkit.getScheduler().runTask(this.plugin, runnable); - } - } From 6e49b7b6d156d6821eb03e908d43264d5e78e60a Mon Sep 17 00:00:00 2001 From: jascotty2 Date: Thu, 19 Sep 2019 15:15:27 -0500 Subject: [PATCH 2/6] re-add sync. --- Core/src/main/java/com/songoda/core/SongodaCore.java | 9 +++++++-- .../core/configuration/editor/ConfigEditorGui.java | 4 ++-- .../com/songoda/core/database/DataManagerAbstract.java | 9 +++++++++ .../core/hooks/worldguard/WorldGuardFlagHandler.java | 10 +++++----- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Core/src/main/java/com/songoda/core/SongodaCore.java b/Core/src/main/java/com/songoda/core/SongodaCore.java index a9ff8c62..911a5678 100644 --- a/Core/src/main/java/com/songoda/core/SongodaCore.java +++ b/Core/src/main/java/com/songoda/core/SongodaCore.java @@ -88,10 +88,15 @@ public class SongodaCore { if(clazz.getSimpleName().equals("SongodaCore")) { try { // test to see if we're up to date - int otherVersion = (int) clazz.getMethod("getCoreVersion").invoke(null); + int otherVersion; + try { + otherVersion = (int) clazz.getMethod("getCoreVersion").invoke(null); + } catch (Exception ignore) { + otherVersion = -1; + } if(otherVersion >= getCoreVersion()) { // use the active service - // assuming that the other is greater than R6 ;) + // assuming that the other is greater than R6 if we get here ;) clazz.getMethod("registerPlugin", JavaPlugin.class, int.class, String.class, String.class).invoke(null, plugin, pluginID, icon, coreVersion); if(hasShading()) { diff --git a/Core/src/main/java/com/songoda/core/configuration/editor/ConfigEditorGui.java b/Core/src/main/java/com/songoda/core/configuration/editor/ConfigEditorGui.java index 1d226ba3..7a96df75 100644 --- a/Core/src/main/java/com/songoda/core/configuration/editor/ConfigEditorGui.java +++ b/Core/src/main/java/com/songoda/core/configuration/editor/ConfigEditorGui.java @@ -40,10 +40,9 @@ public class ConfigEditorGui extends SimplePagedGui { public ConfigEditorGui(JavaPlugin plugin, Gui parent, String file, MemoryConfiguration config) { this(plugin, parent, file, config, config); - setOnClose((gui) -> save()); } - public ConfigEditorGui(JavaPlugin plugin, Gui parent, String file, MemoryConfiguration config, ConfigurationSection node) { + protected ConfigEditorGui(JavaPlugin plugin, Gui parent, String file, MemoryConfiguration config, ConfigurationSection node) { super(parent); this.plugin = plugin; this.file = file; @@ -150,6 +149,7 @@ public class ConfigEditorGui extends SimplePagedGui { ++index; } + setOnClose((gui) -> save()); } public ConfigurationSection getCurrentNode() { diff --git a/Core/src/main/java/com/songoda/core/database/DataManagerAbstract.java b/Core/src/main/java/com/songoda/core/database/DataManagerAbstract.java index 57ae5388..604f70d6 100644 --- a/Core/src/main/java/com/songoda/core/database/DataManagerAbstract.java +++ b/Core/src/main/java/com/songoda/core/database/DataManagerAbstract.java @@ -52,4 +52,13 @@ public class DataManagerAbstract { public void async(Runnable runnable) { Bukkit.getScheduler().runTaskAsynchronously(this.plugin, runnable); } + + /** + * Queue a task to be run synchronously. + * + * @param runnable task to run on the next server tick + */ + public void sync(Runnable runnable) { + Bukkit.getScheduler().runTask(this.plugin, runnable); + } } diff --git a/Core/src/main/java/com/songoda/core/hooks/worldguard/WorldGuardFlagHandler.java b/Core/src/main/java/com/songoda/core/hooks/worldguard/WorldGuardFlagHandler.java index 05103431..7fd7c151 100644 --- a/Core/src/main/java/com/songoda/core/hooks/worldguard/WorldGuardFlagHandler.java +++ b/Core/src/main/java/com/songoda/core/hooks/worldguard/WorldGuardFlagHandler.java @@ -1,8 +1,3 @@ -/** - * Hooks for adding a custom WorldGuard flag - * - * Note: Hooks must be added before WG loads! - */ package com.songoda.core.hooks.worldguard; import com.sk89q.worldedit.bukkit.BukkitAdapter; @@ -29,6 +24,11 @@ import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Location; +/** + * Hooks for adding a custom WorldGuard flag + * + * Note: Hooks must be added before WG loads! + */ public class WorldGuardFlagHandler { static Boolean wgPlugin = null; From 2983b55b6032f4021c9612654c2422c4031805f2 Mon Sep 17 00:00:00 2001 From: jascotty2 Date: Thu, 19 Sep 2019 16:15:42 -0500 Subject: [PATCH 3/6] fix legacy v6 flag check --- .../worldguard/WorldGuardFlagHandler.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Core/src/main/java/com/songoda/core/hooks/worldguard/WorldGuardFlagHandler.java b/Core/src/main/java/com/songoda/core/hooks/worldguard/WorldGuardFlagHandler.java index 7fd7c151..6807b1c3 100644 --- a/Core/src/main/java/com/songoda/core/hooks/worldguard/WorldGuardFlagHandler.java +++ b/Core/src/main/java/com/songoda/core/hooks/worldguard/WorldGuardFlagHandler.java @@ -229,6 +229,9 @@ public class WorldGuardFlagHandler { static Constructor legacy_newProtectedCuboidRegion; static Class legacy_blockVectorClazz; static Constructor legacy_newblockVector; + static Class legacy_VectorClazz; + static Constructor legacy_newVectorClazz; + static Method legacy_getApplicableRegions_Vector = null; private static Boolean getBooleanFlagLegacy(Location l, Object flag) { try { @@ -244,6 +247,9 @@ public class WorldGuardFlagHandler { legacy_newblockVector = legacy_blockVectorClazz.getConstructor(int.class, int.class, int.class); legacy_newProtectedCuboidRegion = Class.forName("com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion") .getConstructor(String.class, legacy_blockVectorClazz, legacy_blockVectorClazz); + legacy_VectorClazz = Class.forName("com.sk89q.worldedit.Vector"); + legacy_newVectorClazz = legacy_VectorClazz.getConstructor(int.class, int.class, int.class); + legacy_getApplicableRegions_Vector = RegionManager.class.getDeclaredMethod("getApplicableRegions", legacy_VectorClazz); } // grab the applicable manager for this world @@ -251,13 +257,15 @@ public class WorldGuardFlagHandler { if (worldManager == null) return null; + // create a vector object + Object vec = legacy_newVectorClazz.newInstance(l.getBlockX(), l.getBlockY(), l.getBlockZ()); // now look for any intersecting regions - Object set = legacy_getApplicableRegions_Region.invoke(worldManager, l); + Object set = legacy_getApplicableRegions_Vector.invoke(worldManager, legacy_VectorClazz.cast(vec)); // so what's the verdict? - State result = null; + State result; if(legacy_v6) { - set = ((ApplicableRegionSet) set).queryState((RegionAssociable) null, (StateFlag) flag); + result = (State) ((ApplicableRegionSet) set).queryState((RegionAssociable) null, (StateFlag) flag); } else { // v5 has a different class signature for ApplicableRegionSet // also doesn't have a "queryState" function @@ -293,6 +301,9 @@ public class WorldGuardFlagHandler { legacy_newblockVector = legacy_blockVectorClazz.getConstructor(int.class, int.class, int.class); legacy_newProtectedCuboidRegion = Class.forName("com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion") .getConstructor(String.class, legacy_blockVectorClazz, legacy_blockVectorClazz); + legacy_VectorClazz = Class.forName("com.sk89q.worldedit.Vector"); + legacy_newVectorClazz = legacy_VectorClazz.getConstructor(int.class, int.class, int.class); + legacy_getApplicableRegions_Vector = RegionManager.class.getDeclaredMethod("getApplicableRegions", legacy_VectorClazz); } // grab the applicable manager for this world @@ -309,9 +320,9 @@ public class WorldGuardFlagHandler { Object set = legacy_getApplicableRegions_Region.invoke(worldManager, chunkRegion); // so what's the verdict? - State result = null; + State result; if(legacy_v6) { - set = ((ApplicableRegionSet) set).queryState((RegionAssociable) null, (StateFlag) flag); + result = (State) ((ApplicableRegionSet) set).queryState((RegionAssociable) null, (StateFlag) flag); } else { // v5 has a different class signature for ApplicableRegionSet // also doesn't have a "queryState" function From 1f3ac22dc27842c1a4cc5ed69afa21354e3d9741 Mon Sep 17 00:00:00 2001 From: jascotty2 Date: Thu, 19 Sep 2019 16:20:04 -0500 Subject: [PATCH 4/6] 2.1.7 --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8e444d8c..cfa10497 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ stages: variables: name: "SongodaCore" path: "/builds/$CI_PROJECT_PATH" - version: "2.1.6" + version: "2.1.7" build: stage: build From b60531da2463452ad923e1451031b016009e9fce Mon Sep 17 00:00:00 2001 From: Brianna Date: Mon, 23 Sep 2019 11:36:06 -0400 Subject: [PATCH 5/6] Removed 1.11.2- incompatible method. --- Core/src/main/java/com/songoda/core/SongodaCore.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Core/src/main/java/com/songoda/core/SongodaCore.java b/Core/src/main/java/com/songoda/core/SongodaCore.java index 911a5678..a8fbcee2 100644 --- a/Core/src/main/java/com/songoda/core/SongodaCore.java +++ b/Core/src/main/java/com/songoda/core/SongodaCore.java @@ -15,12 +15,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.HttpURLConnection; import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.UUID; +import java.util.*; import java.util.logging.Level; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -177,7 +172,7 @@ public class SongodaCore { */ private void destroy() { Bukkit.getServicesManager().unregister(SongodaCore.class, INSTANCE); - tasks.stream().filter(task -> task != null && !task.isCancelled()) + tasks.stream().filter(Objects::nonNull) .forEach(task -> Bukkit.getScheduler().cancelTask(task.getTaskId())); HandlerList.unregisterAll(loginListener); if (!hasShading()) { From c4d8df77c806e8c65b36b318e40eb461807b2f38 Mon Sep 17 00:00:00 2001 From: Brianna Date: Mon, 23 Sep 2019 11:36:29 -0400 Subject: [PATCH 6/6] version 2.1.8 --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cfa10497..4562bac3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ stages: variables: name: "SongodaCore" path: "/builds/$CI_PROJECT_PATH" - version: "2.1.7" + version: "2.1.8" build: stage: build