mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-24 02:56:17 +01:00
Merge branch 'development' into 'master'
2.1.10 See merge request Songoda/songodaupdater!15
This commit is contained in:
commit
eba30befc5
@ -4,7 +4,7 @@ stages:
|
||||
variables:
|
||||
name: "SongodaCore"
|
||||
path: "/builds/$CI_PROJECT_PATH"
|
||||
version: "2.1.9"
|
||||
version: "2.1.10"
|
||||
|
||||
build:
|
||||
stage: build
|
||||
|
@ -602,8 +602,9 @@ public class Gui {
|
||||
@NotNull
|
||||
public Gui setNextPage(int cell, @NotNull ItemStack item) {
|
||||
nextPageIndex = cell;
|
||||
nextPage = item;
|
||||
if (page < pages) {
|
||||
setButton(nextPageIndex, nextPage = item, ClickType.LEFT, (event) -> this.nextPage());
|
||||
setButton(nextPageIndex, nextPage, ClickType.LEFT, (event) -> this.nextPage());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@ -611,8 +612,9 @@ public class Gui {
|
||||
@NotNull
|
||||
public Gui setNextPage(int row, int col, @NotNull ItemStack item) {
|
||||
nextPageIndex = col + row * 9;
|
||||
nextPage = item;
|
||||
if (page < pages) {
|
||||
setButton(nextPageIndex, nextPage = item, ClickType.LEFT, (event) -> this.nextPage());
|
||||
setButton(nextPageIndex, nextPage, ClickType.LEFT, (event) -> this.nextPage());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@ -620,8 +622,9 @@ public class Gui {
|
||||
@NotNull
|
||||
public Gui setPrevPage(int cell, @NotNull ItemStack item) {
|
||||
prevPageIndex = cell;
|
||||
prevPage = item;
|
||||
if (page > 1) {
|
||||
setButton(prevPageIndex, prevPage = item, ClickType.LEFT, (event) -> this.prevPage());
|
||||
setButton(prevPageIndex, prevPage, ClickType.LEFT, (event) -> this.prevPage());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@ -629,12 +632,20 @@ public class Gui {
|
||||
@NotNull
|
||||
public Gui setPrevPage(int row, int col, @NotNull ItemStack item) {
|
||||
prevPageIndex = col + row * 9;
|
||||
prevPage = item;
|
||||
if (page > 1) {
|
||||
setButton(prevPageIndex, prevPage = item, ClickType.LEFT, (event) -> this.prevPage());
|
||||
setButton(prevPageIndex, prevPage, ClickType.LEFT, (event) -> this.prevPage());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setPages(int pages) {
|
||||
this.pages = Math.max(1, pages);
|
||||
if (page > pages) {
|
||||
setPage(pages);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPage(int page) {
|
||||
int lastPage = this.page;
|
||||
this.page = Math.max(1, Math.min(pages, page));
|
||||
|
@ -64,7 +64,8 @@ public class WorldGuardFlagHandler {
|
||||
// if this class exists, we're on 6.0
|
||||
Class.forName("com.sk89q.worldguard.protection.flags.BuildFlag");
|
||||
legacy_v60 = true;
|
||||
} catch (ClassNotFoundException ex3) {try {
|
||||
} catch (ClassNotFoundException ex3) {
|
||||
try {
|
||||
// if this class exists, we're on 5.x
|
||||
Class.forName("com.sk89q.worldguard.protection.flags.DefaultFlag");
|
||||
legacy_v5 = true;
|
||||
@ -76,7 +77,9 @@ public class WorldGuardFlagHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!wgPlugin) return;
|
||||
if (!wgPlugin) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (legacy_v62 || legacy_v60 || legacy_v5) {
|
||||
addLegacyHook(flag, state);
|
||||
@ -95,7 +98,7 @@ public class WorldGuardFlagHandler {
|
||||
Bukkit.getServer().getLogger().log(Level.WARNING, "Could not hook WorldGuard");
|
||||
} else {
|
||||
flags.put(flag, wgFlag);
|
||||
Bukkit.getServer().getLogger().log(Level.WARNING, "Loaded existing {1} {0}", new Object[] {wgFlag.getName(), wgFlag.getClass().getSimpleName()});
|
||||
Bukkit.getServer().getLogger().log(Level.WARNING, "Loaded existing {1} {0}", new Object[]{wgFlag.getName(), wgFlag.getClass().getSimpleName()});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -109,12 +112,12 @@ public class WorldGuardFlagHandler {
|
||||
Field flagField = defaultFlagClazz.getField("flagsList");
|
||||
Flag<?>[] flagsOld = (Flag<?>[]) flagField.get(null);
|
||||
Flag wgFlag = Stream.of(flagsOld)
|
||||
.filter(f -> ((Flag<?>)f).getName().equalsIgnoreCase(flag))
|
||||
.filter(f -> ((Flag<?>) f).getName().equalsIgnoreCase(flag))
|
||||
.findFirst().orElse(null);
|
||||
if (wgFlag != null) {
|
||||
// we already have one
|
||||
flags.put(flag, wgFlag);
|
||||
Bukkit.getServer().getLogger().log(Level.WARNING, "Loaded existing {1} {0}", new Object[] {wgFlag.getName(), wgFlag.getClass().getSimpleName()});
|
||||
Bukkit.getServer().getLogger().log(Level.WARNING, "Loaded existing {1} {0}", new Object[]{wgFlag.getName(), wgFlag.getClass().getSimpleName()});
|
||||
return;
|
||||
}
|
||||
|
||||
@ -132,7 +135,7 @@ public class WorldGuardFlagHandler {
|
||||
// and put the new list into place
|
||||
setStaticField(flagField, flagsNew);
|
||||
|
||||
if(legacy_v62) { // SimpleFlagRegistry is NOT in 6.0
|
||||
if (legacy_v62) { // SimpleFlagRegistry is NOT in 6.0
|
||||
// register this flag in the registry
|
||||
Object flagRegistry = getPrivateField(worldGuardPlugin.getClass(), worldGuardPlugin, "flagRegistry");
|
||||
Class simpleFlagRegistryClazz = Class.forName("com.sk89q.worldguard.protection.flags.registry.SimpleFlagRegistry");
|
||||
@ -170,20 +173,25 @@ public class WorldGuardFlagHandler {
|
||||
|
||||
/**
|
||||
* Checks this location to see what this flag is set to
|
||||
*
|
||||
* @param l location to check
|
||||
* @param flag ALLOW/DENY flag to check
|
||||
* @return flag state, or null if undefined
|
||||
*/
|
||||
public static Boolean getBooleanFlag(Location l, String flag) {
|
||||
if (wgPlugin == null || !wgPlugin) return null;
|
||||
if (wgPlugin == null || !wgPlugin) {
|
||||
return null;
|
||||
}
|
||||
Object flagObj = flags.get(flag);
|
||||
// There's a different way to get this in the old version
|
||||
if (legacy_v62 || legacy_v60 || legacy_v5)
|
||||
if (legacy_v62 || legacy_v60 || legacy_v5) {
|
||||
return flagObj == null ? null : getBooleanFlagLegacy(l, flagObj);
|
||||
}
|
||||
|
||||
// for convinience, we can load a flag if we don't know it
|
||||
if (flagObj == null)
|
||||
if (flagObj == null) {
|
||||
flags.put(flag, flagObj = WorldGuard.getInstance().getFlagRegistry().get(flag));
|
||||
}
|
||||
|
||||
// so, what's up?
|
||||
if (flagObj instanceof StateFlag) {
|
||||
@ -197,33 +205,40 @@ public class WorldGuardFlagHandler {
|
||||
|
||||
/**
|
||||
* Query all regions that are in or intersect this chunk
|
||||
*
|
||||
* @param c chunk to check for regions in
|
||||
* @param flag ALLOW/DENY flag to check
|
||||
* @return flag state, or null if undefined
|
||||
*/
|
||||
public static Boolean getBooleanFlag(Chunk c, String flag) {
|
||||
if (wgPlugin == null || !wgPlugin) return null;
|
||||
if (wgPlugin == null || !wgPlugin) {
|
||||
return null;
|
||||
}
|
||||
Object flagObj = flags.get(flag);
|
||||
// There's a different way to get this in the old version
|
||||
if (legacy_v62 || legacy_v60 || legacy_v5)
|
||||
if (legacy_v62 || legacy_v60 || legacy_v5) {
|
||||
return flagObj == null ? null : getBooleanFlagLegacy(c, flagObj);
|
||||
}
|
||||
|
||||
// for convinience, we can load a flag if we don't know it
|
||||
if (flagObj == null)
|
||||
if (flagObj == null) {
|
||||
flags.put(flag, flagObj = WorldGuard.getInstance().getFlagRegistry().get(flag));
|
||||
}
|
||||
|
||||
// so, what's up?
|
||||
if (flagObj instanceof StateFlag) {
|
||||
RegionManager worldManager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(BukkitAdapter.adapt(c.getWorld()));
|
||||
if (worldManager == null)
|
||||
if (worldManager == null) {
|
||||
return null;
|
||||
}
|
||||
ProtectedCuboidRegion chunkRegion = new ProtectedCuboidRegion("__TEST__",
|
||||
BlockVector3.at(c.getX() << 4, c.getWorld().getMaxHeight(), c.getZ() << 4),
|
||||
BlockVector3.at((c.getX() << 4) + 15, 0, (c.getZ() << 4) + 15));
|
||||
ApplicableRegionSet set = worldManager.getApplicableRegions(chunkRegion);
|
||||
State result = set.queryState((RegionAssociable) null, (StateFlag) flagObj);
|
||||
if (result == null && set.size() == 0)
|
||||
if (result == null && set.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
return result == State.ALLOW;
|
||||
}
|
||||
return null;
|
||||
@ -261,8 +276,9 @@ public class WorldGuardFlagHandler {
|
||||
|
||||
// grab the applicable manager for this world
|
||||
Object worldManager = (RegionManager) legacy_getRegionManager.invoke(worldGuardPlugin, l.getWorld());
|
||||
if (worldManager == null)
|
||||
if (worldManager == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// create a vector object
|
||||
Object vec = legacy_newVectorClazz.newInstance(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
@ -271,19 +287,20 @@ public class WorldGuardFlagHandler {
|
||||
|
||||
// so what's the verdict?
|
||||
State result;
|
||||
if(legacy_v62 || legacy_v60) {
|
||||
if (legacy_v62 || legacy_v60) {
|
||||
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
|
||||
//getFlag(T flag)
|
||||
if(legacy5_applicableRegionSet_getFlag == null) {
|
||||
if (legacy5_applicableRegionSet_getFlag == null) {
|
||||
legacy5_applicableRegionSet_getFlag = Class.forName("com.sk89q.worldguard.protection.ApplicableRegionSet").getMethod("getFlag", Object.class);
|
||||
}
|
||||
result = (State) legacy5_applicableRegionSet_getFlag.invoke(set, flag);
|
||||
}
|
||||
if (result == null && set != null && ((Iterable) set).iterator().hasNext())
|
||||
if (result == null && set != null && ((Iterable) set).iterator().hasNext()) {
|
||||
return null;
|
||||
}
|
||||
return result == State.ALLOW;
|
||||
|
||||
} catch (Exception ex) {
|
||||
@ -315,8 +332,9 @@ public class WorldGuardFlagHandler {
|
||||
|
||||
// grab the applicable manager for this world
|
||||
Object worldManager = (RegionManager) legacy_getRegionManager.invoke(worldGuardPlugin, c.getWorld());
|
||||
if (worldManager == null)
|
||||
if (worldManager == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Create a legacy ProtectedCuboidRegion
|
||||
Object chunkRegion = legacy_newProtectedCuboidRegion.newInstance("__TEST__",
|
||||
@ -328,19 +346,20 @@ public class WorldGuardFlagHandler {
|
||||
|
||||
// so what's the verdict?
|
||||
State result;
|
||||
if(legacy_v62 || legacy_v60) {
|
||||
if (legacy_v62 || legacy_v60) {
|
||||
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
|
||||
//getFlag(T flag)
|
||||
if(legacy5_applicableRegionSet_getFlag == null) {
|
||||
if (legacy5_applicableRegionSet_getFlag == null) {
|
||||
legacy5_applicableRegionSet_getFlag = Class.forName("com.sk89q.worldguard.protection.ApplicableRegionSet").getMethod("getFlag", Flag.class);
|
||||
}
|
||||
result = (State) legacy5_applicableRegionSet_getFlag.invoke(set, flag);
|
||||
}
|
||||
if (result == null && set != null && ((Iterable) set).iterator().hasNext())
|
||||
if (result == null && set != null && ((Iterable) set).iterator().hasNext()) {
|
||||
return null;
|
||||
}
|
||||
return result == State.ALLOW;
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
Loading…
Reference in New Issue
Block a user