mirror of
https://github.com/songoda/SongodaCore.git
synced 2025-03-11 06:00:19 +01:00
Merge branch 'development' into 'master'
2.1.9 See merge request Songoda/songodaupdater!14
This commit is contained in:
commit
3d9d40c6dc
@ -4,7 +4,7 @@ stages:
|
||||
variables:
|
||||
name: "SongodaCore"
|
||||
path: "/builds/$CI_PROJECT_PATH"
|
||||
version: "2.1.8"
|
||||
version: "2.1.9"
|
||||
|
||||
build:
|
||||
stage: build
|
||||
|
@ -45,6 +45,7 @@ public abstract class SongodaPlugin extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public ConfigFileConfigurationAdapter getConfig() {
|
||||
// todo? change prototype to FileConfiguration? This seems to cause development issues due to shading.
|
||||
return config.getFileConfig();
|
||||
}
|
||||
|
||||
|
@ -9,9 +9,9 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class DataMigrationManager {
|
||||
|
||||
private List<DataMigration> migrations;
|
||||
private DatabaseConnector databaseConnector;
|
||||
private DataManagerAbstract dataManagerAbstract;
|
||||
private final List<DataMigration> migrations;
|
||||
private final DatabaseConnector databaseConnector;
|
||||
private final DataManagerAbstract dataManagerAbstract;
|
||||
|
||||
public DataMigrationManager(DatabaseConnector databaseConnector, DataManagerAbstract dataManagerAbstract, DataMigration... migrations) {
|
||||
this.databaseConnector = databaseConnector;
|
||||
|
@ -30,14 +30,17 @@ public class MySQLConnector implements DatabaseConnector {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitialized() {
|
||||
return this.initializedSuccessfully;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeConnection() {
|
||||
this.hikari.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(ConnectionCallback callback) {
|
||||
try (Connection connection = this.hikari.getConnection()) {
|
||||
callback.accept(connection);
|
||||
|
@ -18,16 +18,18 @@ public class SQLiteConnector implements DatabaseConnector {
|
||||
this.connectionString = "jdbc:sqlite:" + plugin.getDataFolder() + File.separator + plugin.getDescription().getName().toLowerCase() + ".db";
|
||||
|
||||
try {
|
||||
Class.forName("org.sqlite.JDBC"); // This is required to put here for Spigot 1.10 and below for some reason
|
||||
Class.forName("org.sqlite.JDBC"); // This is required to put here for Spigot 1.10 and below to force class load
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitialized() {
|
||||
return true; // Always available
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeConnection() {
|
||||
try {
|
||||
if (this.connection != null) {
|
||||
@ -38,6 +40,7 @@ public class SQLiteConnector implements DatabaseConnector {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(ConnectionCallback callback) {
|
||||
if (this.connection == null) {
|
||||
try {
|
||||
|
@ -180,6 +180,104 @@ public class GuiUtils {
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack createButtonItem(CompatibleMaterial mat, String[] lore) {
|
||||
ItemStack item = mat.getItem();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null) {
|
||||
if (lore != null && lore.length != 0) {
|
||||
List<String> safe = getSafeLore(lore);
|
||||
meta.setDisplayName(safe.get(0));
|
||||
meta.setLore(safe.subList(1, safe.size()));
|
||||
} else {
|
||||
meta.setLore(Collections.EMPTY_LIST);
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack createButtonItem(CompatibleMaterial mat, int amount, String[] lore) {
|
||||
ItemStack item = mat.getItem();
|
||||
item.setAmount(amount);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null) {
|
||||
if (lore != null && lore.length != 0) {
|
||||
List<String> safe = getSafeLore(lore);
|
||||
meta.setDisplayName(safe.get(0));
|
||||
meta.setLore(safe.subList(1, safe.size()));
|
||||
} else {
|
||||
meta.setLore(Collections.EMPTY_LIST);
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack createButtonItem(ItemStack from, String[] lore) {
|
||||
ItemStack item = from.clone();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null) {
|
||||
if (lore != null && lore.length != 0) {
|
||||
List<String> safe = getSafeLore(lore);
|
||||
meta.setDisplayName(safe.get(0));
|
||||
meta.setLore(safe.subList(1, safe.size()));
|
||||
} else {
|
||||
meta.setLore(Collections.EMPTY_LIST);
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack createButtonItem(CompatibleMaterial mat, List<String> lore) {
|
||||
ItemStack item = mat.getItem();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null) {
|
||||
if (lore != null && !lore.isEmpty()) {
|
||||
List<String> safe = getSafeLore(lore);
|
||||
meta.setDisplayName(safe.get(0));
|
||||
meta.setLore(safe.subList(1, safe.size()));
|
||||
} else {
|
||||
meta.setLore(Collections.EMPTY_LIST);
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack createButtonItem(CompatibleMaterial mat, int amount, List<String> lore) {
|
||||
ItemStack item = mat.getItem();
|
||||
item.setAmount(amount);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null) {
|
||||
if (lore != null && !lore.isEmpty()) {
|
||||
List<String> safe = getSafeLore(lore);
|
||||
meta.setDisplayName(safe.get(0));
|
||||
meta.setLore(safe.subList(1, safe.size()));
|
||||
} else {
|
||||
meta.setLore(Collections.EMPTY_LIST);
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack createButtonItem(ItemStack from, List<String> lore) {
|
||||
ItemStack item = from.clone();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null) {
|
||||
if (lore != null && !lore.isEmpty()) {
|
||||
List<String> safe = getSafeLore(lore);
|
||||
meta.setDisplayName(safe.get(0));
|
||||
meta.setLore(safe.subList(1, safe.size()));
|
||||
} else {
|
||||
meta.setLore(Collections.EMPTY_LIST);
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack updateItem(ItemStack item, String title, String... lore) {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null) {
|
||||
|
@ -34,7 +34,8 @@ public class WorldGuardFlagHandler {
|
||||
static Boolean wgPlugin = null;
|
||||
static Object worldGuardPlugin;
|
||||
static boolean wg_v7 = false;
|
||||
static boolean legacy_v6 = false;
|
||||
static boolean legacy_v60 = false;
|
||||
static boolean legacy_v62 = false;
|
||||
static boolean legacy_v5 = false;
|
||||
static boolean hooksInstalled = false;
|
||||
static Map<String, Object> flags = new HashMap();
|
||||
@ -55,23 +56,29 @@ public class WorldGuardFlagHandler {
|
||||
wg_v7 = true;
|
||||
} catch (ClassNotFoundException ex) {
|
||||
try {
|
||||
// if this class exists, we're on 6.0
|
||||
Class.forName("com.sk89q.worldguard.protection.flags.FlagContextCreateEvent");
|
||||
legacy_v6 = true;
|
||||
// if this class exists, we're on 6.2
|
||||
Class.forName("com.sk89q.worldguard.protection.flags.registry.SimpleFlagRegistry");
|
||||
legacy_v62 = true;
|
||||
} catch (ClassNotFoundException ex2) {
|
||||
try {
|
||||
// if this class exists, we're on 5.x
|
||||
Class.forName("com.sk89q.worldguard.protection.flags.DefaultFlag");
|
||||
legacy_v5 = true;
|
||||
} catch (ClassNotFoundException ex3) {
|
||||
// ¯\_(ツ)_/¯
|
||||
// if this class exists, we're on 6.0
|
||||
Class.forName("com.sk89q.worldguard.protection.flags.BuildFlag");
|
||||
legacy_v60 = true;
|
||||
} catch (ClassNotFoundException ex3) {try {
|
||||
// if this class exists, we're on 5.x
|
||||
Class.forName("com.sk89q.worldguard.protection.flags.DefaultFlag");
|
||||
legacy_v5 = true;
|
||||
} catch (ClassNotFoundException ex4) {
|
||||
// ¯\_(ツ)_/¯
|
||||
wgPlugin = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!wgPlugin) return;
|
||||
|
||||
if (legacy_v6 || legacy_v5) {
|
||||
if (legacy_v62 || legacy_v60 || legacy_v5) {
|
||||
addLegacyHook(flag, state);
|
||||
return;
|
||||
}
|
||||
@ -125,7 +132,7 @@ public class WorldGuardFlagHandler {
|
||||
// and put the new list into place
|
||||
setStaticField(flagField, flagsNew);
|
||||
|
||||
if(legacy_v6) {
|
||||
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");
|
||||
@ -137,7 +144,7 @@ public class WorldGuardFlagHandler {
|
||||
flags.put(flag, wgFlag);
|
||||
} catch (Exception ex) {
|
||||
//Bukkit.getServer().getLogger().log(Level.WARNING, "Failed to set legacy WorldGuard Flags", ex);
|
||||
Bukkit.getServer().getLogger().log(Level.WARNING, "Could not add flag {0} to WorldGuard " + (legacy_v6 ? "6" : "5"), flag);
|
||||
Bukkit.getServer().getLogger().log(Level.WARNING, "Could not add flag {0} to WorldGuard " + (legacy_v62 ? "6.2" : (legacy_v60 ? "6.0" : "5")), flag);
|
||||
Bukkit.getServer().getLogger().log(Level.WARNING, "Could not hook WorldGuard");
|
||||
wgPlugin = false;
|
||||
}
|
||||
@ -171,11 +178,11 @@ public class WorldGuardFlagHandler {
|
||||
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_v6 || 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 && !legacy_v6)
|
||||
if (flagObj == null)
|
||||
flags.put(flag, flagObj = WorldGuard.getInstance().getFlagRegistry().get(flag));
|
||||
|
||||
// so, what's up?
|
||||
@ -198,7 +205,7 @@ public class WorldGuardFlagHandler {
|
||||
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_v6 || 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
|
||||
@ -264,7 +271,7 @@ public class WorldGuardFlagHandler {
|
||||
|
||||
// so what's the verdict?
|
||||
State result;
|
||||
if(legacy_v6) {
|
||||
if(legacy_v62 || legacy_v60) {
|
||||
result = (State) ((ApplicableRegionSet) set).queryState((RegionAssociable) null, (StateFlag) flag);
|
||||
} else {
|
||||
// v5 has a different class signature for ApplicableRegionSet
|
||||
@ -321,7 +328,7 @@ public class WorldGuardFlagHandler {
|
||||
|
||||
// so what's the verdict?
|
||||
State result;
|
||||
if(legacy_v6) {
|
||||
if(legacy_v62 || legacy_v60) {
|
||||
result = (State) ((ApplicableRegionSet) set).queryState((RegionAssociable) null, (StateFlag) flag);
|
||||
} else {
|
||||
// v5 has a different class signature for ApplicableRegionSet
|
||||
|
Loading…
Reference in New Issue
Block a user