Merge branch 'development'

This commit is contained in:
Brianna 2019-09-23 11:54:58 -04:00
commit b39ded402f
5 changed files with 44 additions and 23 deletions

View File

@ -4,7 +4,7 @@ stages:
variables:
name: "SongodaCore"
path: "/builds/$CI_PROJECT_PATH"
version: "2.1.6"
version: "2.1.8"
build:
stage: build

View File

@ -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;
@ -88,10 +83,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()) {
@ -172,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()) {

View File

@ -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() {

View File

@ -43,12 +43,22 @@ public class DataManagerAbstract {
}
}
/**
* Queue a task to be run asynchronously. <br>
* TODO: This needs to be separated from BukkitScheduler
*
* @param runnable task to run
*/
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);
}
}

View File

@ -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;
@ -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