Dieser Commit ist enthalten in:
Ursprung
897fdba6bb
Commit
d800b90ac2
@ -23,8 +23,8 @@ import de.steamwar.command.SWCommand;
|
|||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.inventory.SWAnvilInv;
|
import de.steamwar.inventory.SWAnvilInv;
|
||||||
import de.steamwar.inventory.SchematicSelector;
|
import de.steamwar.inventory.SchematicSelector;
|
||||||
|
import de.steamwar.providers.BauSystemProvider;
|
||||||
import de.steamwar.schematicsystem.SchematicSystem;
|
import de.steamwar.schematicsystem.SchematicSystem;
|
||||||
import de.steamwar.schematicsystem.providers.BauSystemProvider;
|
|
||||||
import de.steamwar.sql.*;
|
import de.steamwar.sql.*;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
@ -22,10 +22,10 @@ package de.steamwar.schematicsystem.commands;
|
|||||||
import de.steamwar.comms.packets.PrepareSchemPacket;
|
import de.steamwar.comms.packets.PrepareSchemPacket;
|
||||||
import de.steamwar.inventory.SWInventory;
|
import de.steamwar.inventory.SWInventory;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
|
import de.steamwar.providers.BauSystemProvider;
|
||||||
import de.steamwar.schematicsystem.AutoCheckResult;
|
import de.steamwar.schematicsystem.AutoCheckResult;
|
||||||
import de.steamwar.schematicsystem.CheckSchemType;
|
import de.steamwar.schematicsystem.CheckSchemType;
|
||||||
import de.steamwar.schematicsystem.SchematicSystem;
|
import de.steamwar.schematicsystem.SchematicSystem;
|
||||||
import de.steamwar.schematicsystem.providers.BauSystemProvider;
|
|
||||||
import de.steamwar.sql.*;
|
import de.steamwar.sql.*;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
@ -1,56 +0,0 @@
|
|||||||
package de.steamwar.schematicsystem.providers;
|
|
||||||
|
|
||||||
import de.steamwar.schematicsystem.providers.impl.*;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public interface BauSystemProvider {
|
|
||||||
|
|
||||||
static <T> T use(Function<BauSystemProvider, T> function, T def) {
|
|
||||||
return BauSystemProviderImplementor.use(function, def);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void use(Consumer<BauSystemProvider> consumer) {
|
|
||||||
BauSystemProviderImplementor.use(consumer);
|
|
||||||
}
|
|
||||||
|
|
||||||
int getOwner();
|
|
||||||
|
|
||||||
class BauSystemProviderImplementor {
|
|
||||||
private BauSystemProviderImplementor() {}
|
|
||||||
|
|
||||||
static boolean hasBausystem;
|
|
||||||
static BauSystemProvider bauSystemProvider;
|
|
||||||
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
Class.forName("de.steamwar.bausystem.BauSystem");
|
|
||||||
hasBausystem = true;
|
|
||||||
switch (Bukkit.getPluginManager().getPlugin("BauSystem").getDescription().getVersion()) {
|
|
||||||
case "2.0":
|
|
||||||
bauSystemProvider = new BauSystem2Provider();
|
|
||||||
break;
|
|
||||||
case "1.0":
|
|
||||||
bauSystemProvider = new BauSystem1Provider();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
hasBausystem = false;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
hasBausystem = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static <T> T use(Function<BauSystemProvider, T> function, T def) {
|
|
||||||
if(!hasBausystem) return def;
|
|
||||||
return function.apply(bauSystemProvider);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void use(Consumer<BauSystemProvider> consumer) {
|
|
||||||
if(!hasBausystem) return;
|
|
||||||
consumer.accept(bauSystemProvider);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
package de.steamwar.schematicsystem.providers.impl;
|
|
||||||
|
|
||||||
import de.steamwar.schematicsystem.providers.BauSystemProvider;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
public class BauSystem1Provider implements BauSystemProvider {
|
|
||||||
|
|
||||||
private static final Method BAUSYSTEM_GET_OWNER_ID;
|
|
||||||
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
Class<?> bausystem = Class.forName("de.steamwar.bausystem.BauSystem");
|
|
||||||
BAUSYSTEM_GET_OWNER_ID = bausystem.getDeclaredMethod("getOwnerID");
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new SecurityException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getOwner() {
|
|
||||||
try {
|
|
||||||
return (int) BAUSYSTEM_GET_OWNER_ID.invoke(null);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new SecurityException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
package de.steamwar.schematicsystem.providers.impl;
|
|
||||||
|
|
||||||
import de.steamwar.schematicsystem.providers.BauSystemProvider;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
public class BauSystem2Provider implements BauSystemProvider {
|
|
||||||
|
|
||||||
private static final Method BAU_SERVER_GET_OWNER_ID;
|
|
||||||
private static final Object BAU_SERVER_INSTANCE;
|
|
||||||
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
Class<?> bauServer = Class.forName("de.steamwar.bausystem.config.BauServer");
|
|
||||||
Method bauServerGet = bauServer.getDeclaredMethod("getInstance");
|
|
||||||
BAU_SERVER_GET_OWNER_ID = bauServer.getMethod("getOwnerID");
|
|
||||||
BAU_SERVER_INSTANCE = bauServerGet.invoke(null);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new SecurityException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getOwner() {
|
|
||||||
try {
|
|
||||||
return (int) BAU_SERVER_GET_OWNER_ID.invoke(BAU_SERVER_INSTANCE);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new SecurityException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
In neuem Issue referenzieren
Einen Benutzer sperren