Dieser Commit ist enthalten in:
Ursprung
e58ad971f6
Commit
897fdba6bb
@ -24,6 +24,7 @@ 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.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;
|
||||||
@ -134,11 +135,17 @@ public class SchematicCommand extends SWCommand {
|
|||||||
@Register("save")
|
@Register("save")
|
||||||
@Register("s")
|
@Register("s")
|
||||||
public void saveSchem(Player player, @Mapper("dirStringMapper") String name) {
|
public void saveSchem(Player player, @Mapper("dirStringMapper") String name) {
|
||||||
|
SteamwarUser user = getUser(player);
|
||||||
|
if((Punishment.isPunished(user, Punishment.PunishmentType.NoSchemReceiving, punishment -> player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst hier keine Schematics laden")) ||
|
||||||
|
Punishment.isPunished(SteamwarUser.get(BauSystemProvider.use(BauSystemProvider::getOwner, 0)), Punishment.PunishmentType.NoSchemSharing, punishment -> player.sendMessage(SchematicSystem.PREFIX + "§cAuf diesem Bau kannst du keine Schematics speichern"))) &&
|
||||||
|
Boolean.TRUE.equals(BauSystemProvider.use(bauSystemProvider -> bauSystemProvider.getOwner() != user.getId(), false))) {
|
||||||
|
player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst hier keine Schematics speichern");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (name.endsWith("/")) {
|
if (name.endsWith("/")) {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDu must auch einen Namen für die Schematic nach dem Ordner angeben");
|
player.sendMessage(SchematicSystem.PREFIX + "§cDu must auch einen Namen für die Schematic nach dem Ordner angeben");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SteamwarUser user = getUser(player);
|
|
||||||
if (name.startsWith("/")) name = name.substring(1);
|
if (name.startsWith("/")) name = name.substring(1);
|
||||||
String[] layers = name.split("/");
|
String[] layers = name.split("/");
|
||||||
if (invalidSchemName(player, layers)) return;
|
if (invalidSchemName(player, layers)) return;
|
||||||
|
@ -25,6 +25,7 @@ import de.steamwar.inventory.SWItem;
|
|||||||
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;
|
||||||
@ -45,7 +46,8 @@ public class SchematicCommandUtils {
|
|||||||
private static final List<Player> PUBLIC_TOGGLED = new ArrayList<>();
|
private static final List<Player> PUBLIC_TOGGLED = new ArrayList<>();
|
||||||
private static final List<String> FORBIDDEN_NAMES = Collections.unmodifiableList(Arrays.asList("public"));
|
private static final List<String> FORBIDDEN_NAMES = Collections.unmodifiableList(Arrays.asList("public"));
|
||||||
|
|
||||||
private SchematicCommandUtils() {}
|
private SchematicCommandUtils() {
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean invalidSchemName(Player player, String[] layers) {
|
public static boolean invalidSchemName(Player player, String[] layers) {
|
||||||
for (String layer : layers) {
|
for (String layer : layers) {
|
||||||
@ -65,7 +67,7 @@ public class SchematicCommandUtils {
|
|||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen");
|
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(FORBIDDEN_NAMES.contains(layer.toLowerCase())) {
|
if (FORBIDDEN_NAMES.contains(layer.toLowerCase())) {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDer Pfad darf nicht \"§l" + layer + "§c\" enthalten");
|
player.sendMessage(SchematicSystem.PREFIX + "§cDer Pfad darf nicht \"§l" + layer + "§c\" enthalten");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -236,7 +238,7 @@ public class SchematicCommandUtils {
|
|||||||
base.addExtra(rename);
|
base.addExtra(rename);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextComponent delete = new TextComponent("[" + (node.getOwner()==user.getId()?"Löschen":"Entfernen") + "] ");
|
TextComponent delete = new TextComponent("[" + (node.getOwner() == user.getId() ? "Löschen" : "Entfernen") + "] ");
|
||||||
delete.setColor(ChatColor.DARK_RED);
|
delete.setColor(ChatColor.DARK_RED);
|
||||||
delete.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§e" + (node.isDir() ? "Ordner" : "Schematic") + " Löschen")));
|
delete.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§e" + (node.isDir() ? "Ordner" : "Schematic") + " Löschen")));
|
||||||
delete.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem delete " + node.generateBreadcrumbs(user)));
|
delete.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem delete " + node.generateBreadcrumbs(user)));
|
||||||
@ -292,6 +294,13 @@ public class SchematicCommandUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void loadSchem(Player player, SchematicNode node) {
|
public static void loadSchem(Player player, SchematicNode node) {
|
||||||
|
SteamwarUser user = getUser(player);
|
||||||
|
if ((Punishment.isPunished(user, Punishment.PunishmentType.NoSchemSharing, punishment -> player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst hier keine Schematics laden")) &&
|
||||||
|
Boolean.TRUE.equals(BauSystemProvider.use(bauSystemProvider -> bauSystemProvider.getOwner() != user.getId(), false))) ||
|
||||||
|
(Boolean.TRUE.equals(BauSystemProvider.use(bauSystemProvider -> bauSystemProvider.getOwner() != user.getId(), false)) &&
|
||||||
|
Punishment.isPunished(BauSystemProvider.use(bauSystemProvider -> SteamwarUser.get(bauSystemProvider.getOwner()), user), Punishment.PunishmentType.NoSchemSharing, punishment -> player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst auf diesem Bau keine Schematics laden")))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (node.isDir()) {
|
if (node.isDir()) {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst keine Ordner Laden");
|
player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst keine Ordner Laden");
|
||||||
return;
|
return;
|
||||||
@ -311,7 +320,7 @@ public class SchematicCommandUtils {
|
|||||||
|
|
||||||
public static void download(Player player, SchematicNode node) {
|
public static void download(Player player, SchematicNode node) {
|
||||||
SteamwarUser user = getUser(player);
|
SteamwarUser user = getUser(player);
|
||||||
if(Punishment.isPunished(user, Punishment.PunishmentType.NoSchemSharing, punishment -> {
|
if (Punishment.isPunished(user, Punishment.PunishmentType.NoSchemSharing, punishment -> {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cDu darf keine Schematics Downloaden: §f§l" + punishment.getReason());
|
player.sendMessage(SchematicSystem.PREFIX + "§cDu darf keine Schematics Downloaden: §f§l" + punishment.getReason());
|
||||||
})) {
|
})) {
|
||||||
return;
|
return;
|
||||||
@ -327,7 +336,7 @@ public class SchematicCommandUtils {
|
|||||||
|
|
||||||
public static void changeType(Player player, SchematicNode node, SchematicType type, SchematicCommand.Extend extend) {
|
public static void changeType(Player player, SchematicNode node, SchematicType type, SchematicCommand.Extend extend) {
|
||||||
SteamwarUser user = getUser(player);
|
SteamwarUser user = getUser(player);
|
||||||
if(Punishment.isPunished(user,
|
if (Punishment.isPunished(user,
|
||||||
Punishment.PunishmentType.NoSchemSubmitting,
|
Punishment.PunishmentType.NoSchemSubmitting,
|
||||||
punishment -> player.sendMessage(SchematicSystem.PREFIX + "§cDu darf keine Schematics einsenden: §f§l: " + punishment.getReason()))) {
|
punishment -> player.sendMessage(SchematicSystem.PREFIX + "§cDu darf keine Schematics einsenden: §f§l: " + punishment.getReason()))) {
|
||||||
return;
|
return;
|
||||||
@ -342,7 +351,7 @@ public class SchematicCommandUtils {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!type.isAssignable()) {
|
if (!type.isAssignable()) {
|
||||||
player.sendMessage(SchematicSystem.PREFIX + "§cZu diesem Typen können keine Schematics geändert werden.");
|
player.sendMessage(SchematicSystem.PREFIX + "§cZu diesem Typen können keine Schematics geändert werden.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@ name: SchematicSystem
|
|||||||
version: "2.0"
|
version: "2.0"
|
||||||
authors: [Yaruma3341, Lixfel, Chaoscaot]
|
authors: [Yaruma3341, Lixfel, Chaoscaot]
|
||||||
depend: [SpigotCore, WorldEdit]
|
depend: [SpigotCore, WorldEdit]
|
||||||
|
softdepend: [BauSystem]
|
||||||
main: de.steamwar.schematicsystem.SchematicSystem
|
main: de.steamwar.schematicsystem.SchematicSystem
|
||||||
website: steamwar.de
|
website: steamwar.de
|
||||||
api-version: "1.13"
|
api-version: "1.13"
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren