diff --git a/BauSystem_ItemUtilities/build.gradle b/BauSystem_ItemUtilities/build.gradle new file mode 100644 index 00000000..dd0a66df --- /dev/null +++ b/BauSystem_ItemUtilities/build.gradle @@ -0,0 +1,63 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2021 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +plugins { + id 'base' + id 'java' +} + +group 'steamwar' +version '1.0' + +compileJava.options.encoding = 'UTF-8' + +sourceCompatibility = 17 +targetCompatibility = 17 + +sourceSets { + main { + java { + srcDirs = ['src/', 'build/generated/sources/annotationProcessor/java/main/'] + } + resources { + srcDirs = ['src/'] + exclude '**/*.java', '**/*.kt' + } + } +} + +dependencies { + implementation project(":BauSystem_PluginBase") + + compileOnly 'org.projectlombok:lombok:1.18.22' + annotationProcessor 'org.projectlombok:lombok:1.18.22' + + compileOnly 'org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT' + // compileOnly 'com.mojang:authlib:1.5.25' + // compileOnly 'io.netty:netty-all:4.1.68.Final' + + compileOnly swdep('Spigot-1.20') + compileOnly swdep('SpigotCore') + annotationProcessor swdep('SpigotCore') + + compileOnly swdep('FastAsyncWorldEdit-1.18') + // compileOnly swdep('AxiomPaper') + + // implementation 'org.luaj:luaj-jse:3.0.1' +} \ No newline at end of file diff --git a/BauSystem_ItemUtilities/src/BauSystem.properties b/BauSystem_ItemUtilities/src/BauSystem.properties new file mode 100644 index 00000000..50a1e654 --- /dev/null +++ b/BauSystem_ItemUtilities/src/BauSystem.properties @@ -0,0 +1,34 @@ +# +# This file is a part of the SteamWar software. +# +# Copyright (C) 2021 SteamWar.de-Serverteam +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +# General (always needed!) +PREFIX = §eBau§8System§8» +TIME = HH:mm:ss +COMMAND_HELP_HEAD = §7---=== (§e{0}§7) ===--- + +# Permissions (always needed!) +NO_PERMISSION = You are not allowed to use that here + +# BIND +BIND_COMMAND_HELP = §8/§ebind §8[§7Command§8] §8-§e Bind a command to item interaction +BIND_COMMAND_ERROR = §cInvalid or unknown command +BIND_MESSAGE_UNBINDABLE = §cCould not bind command to item +BIND_MESSAGE_BIND = §7Bound command §e{0} §7to item +BIND_MESSAGE_UNBIND = §7Unbound command +BIND_ITEM_LORE = §eCommand§8:§7 {0} diff --git a/BauSystem_ItemUtilities/src/BauSystem_de.properties b/BauSystem_ItemUtilities/src/BauSystem_de.properties new file mode 100644 index 00000000..ebd93ceb --- /dev/null +++ b/BauSystem_ItemUtilities/src/BauSystem_de.properties @@ -0,0 +1,33 @@ +# +# This file is a part of the SteamWar software. +# +# Copyright (C) 2021 SteamWar.de-Serverteam +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +# General (always needed!) +PREFIX = §eBau§8System§8» +TIME = HH:mm:ss +COMMAND_HELP_HEAD = §7---=== (§e{0}§7) ===--- + +# Permissions (always needed!) +NO_PERMISSION = Du darfst dies hier nicht nutzen + +# BIND +BIND_COMMAND_HELP = §8/§ebind §8[§7Command§8] §8-§e Binde ein Befehl auf die Item Interaktion +BIND_COMMAND_ERROR = §cFalscher oder unbekannter Befehl +BIND_MESSAGE_UNBINDABLE = §cBefehl konnte nicht ans Item gebunden werden +BIND_MESSAGE_BIND = §7Befehl §e{0} §7ans Item gebunden +BIND_MESSAGE_UNBIND = §7Befehl vom Item entfernt diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/BindCommand.java b/BauSystem_ItemUtilities/src/de/steamwar/bausystem/itemutilities/BindCommand.java similarity index 81% rename from BauSystem_Main/src/de/steamwar/bausystem/features/util/BindCommand.java rename to BauSystem_ItemUtilities/src/de/steamwar/bausystem/itemutilities/BindCommand.java index 9a93977e..86c2c47e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/BindCommand.java +++ b/BauSystem_ItemUtilities/src/de/steamwar/bausystem/itemutilities/BindCommand.java @@ -1,14 +1,32 @@ -package de.steamwar.bausystem.features.util; +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.itemutilities; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.event.platform.CommandEvent; import com.sk89q.worldedit.extension.platform.Actor; -import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.BauSystemPlugin; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.features.script.ScriptCommand; import de.steamwar.bausystem.features.script.ScriptRunner; import de.steamwar.bausystem.features.world.WorldEditListener; import de.steamwar.bausystem.utils.WorldEditUtils; @@ -28,10 +46,12 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.persistence.PersistentDataType; -import org.luaj.vm2.LuaValue; import java.lang.reflect.Field; -import java.util.*; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Objects; import java.util.logging.Level; import java.util.stream.Collectors; @@ -73,8 +93,8 @@ public class BindCommand extends SWCommand implements Listener { super("bind"); } - @Register(description = "OTHER_BIND_HELP") - public void bind(@Validator Player player, @Mapper("command") @ErrorMessage("OTHER_BIND_ERROR") String... command) { + @Register(description = "BIND_COMMAND_HELP") + public void bind(@Validator Player player, @Mapper("command") @ErrorMessage("BIND_COMMAND_ERROR") String... command) { bindInternal(player, command); } @@ -82,19 +102,19 @@ public class BindCommand extends SWCommand implements Listener { ItemStack item = player.getInventory().getItemInMainHand(); ItemMeta meta = item.getItemMeta(); if (meta == null) { - BauSystem.MESSAGE.send("OTHER_BIND_UNBINDABLE", player); + BauSystemPlugin.MESSAGE.send("BIND_MESSAGE_UNBINDABLE", player); return; } if (command.length != 0) { String commandText = String.join(" ", command); meta.getPersistentDataContainer().set(KEY, PersistentDataType.STRING, commandText); - meta.setDisplayName(BauSystem.MESSAGE.parse("OTHER_BIND_LORE", player, commandText)); - BauSystem.MESSAGE.send("OTHER_BIND_MESSAGE_BIND", player, commandText); + meta.setDisplayName(BauSystemPlugin.MESSAGE.parse("BIND_ITEM_LORE", player, commandText)); + BauSystemPlugin.MESSAGE.send("BIND_MESSAGE_BIND", player, commandText); } else { meta.getPersistentDataContainer().remove(KEY); meta.setDisplayName(null); - BauSystem.MESSAGE.send("OTHER_BIND_MESSAGE_UNBIND", player); + BauSystemPlugin.MESSAGE.send("BIND_MESSAGE_UNBIND", player); } item.setItemMeta(meta); player.getInventory().setItemInMainHand(item); @@ -116,7 +136,7 @@ public class BindCommand extends SWCommand implements Listener { } event.setCancelled(true); - Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { + Bukkit.getScheduler().runTaskLater(BauSystemPlugin.getInstance(), () -> { PlayerCommandPreprocessEvent preprocessEvent = new PlayerCommandPreprocessEvent(event.getPlayer(), "/" + command); Bukkit.getPluginManager().callEvent(preprocessEvent); if (preprocessEvent.isCancelled()) return; diff --git a/BauSystem_ItemUtilities/src/plugin.yml b/BauSystem_ItemUtilities/src/plugin.yml new file mode 100644 index 00000000..f4727758 --- /dev/null +++ b/BauSystem_ItemUtilities/src/plugin.yml @@ -0,0 +1,12 @@ +name: BauSystem_ItemUtilities +authors: [ Lixfel, YoyoNow, Chaoscaot, Zeanon, D4rkr34lm ] +version: "2.0" +depend: [ WorldEdit, SpigotCore ] +softdepend: [ ] +load: POSTWORLD +main: de.steamwar.bausystem.BauSystemPlugin +api-version: "1.13" +website: "https://steamwar.de" +description: "So unseriös wie wir sind: BauSystem nur besser." + +commands: diff --git a/BauSystem_PluginBase/build.gradle b/BauSystem_PluginBase/build.gradle new file mode 100644 index 00000000..4ff398a4 --- /dev/null +++ b/BauSystem_PluginBase/build.gradle @@ -0,0 +1,60 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2021 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +plugins { + id 'base' + id 'java' +} + +group 'steamwar' +version '1.0' + +compileJava.options.encoding = 'UTF-8' + +sourceCompatibility = 17 +targetCompatibility = 17 + +sourceSets { + main { + java { + srcDirs = ['src/', 'build/generated/sources/annotationProcessor/java/main/'] + } + resources { + srcDirs = ['src/'] + exclude '**/*.java', '**/*.kt' + } + } +} + +dependencies { + compileOnly 'org.projectlombok:lombok:1.18.22' + annotationProcessor 'org.projectlombok:lombok:1.18.22' + + compileOnly 'org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT' + // compileOnly 'com.mojang:authlib:1.5.25' + // compileOnly 'io.netty:netty-all:4.1.68.Final' + + // compileOnly swdep('Spigot-1.20') + compileOnly swdep('SpigotCore') + + // compileOnly swdep('FastAsyncWorldEdit-1.18') + // compileOnly swdep('AxiomPaper') + + // implementation 'org.luaj:luaj-jse:3.0.1' +} \ No newline at end of file diff --git a/BauSystem_PluginBase/src/de/steamwar/bausystem/BauSystemPlugin.java b/BauSystem_PluginBase/src/de/steamwar/bausystem/BauSystemPlugin.java new file mode 100644 index 00000000..1b77a2c3 --- /dev/null +++ b/BauSystem_PluginBase/src/de/steamwar/bausystem/BauSystemPlugin.java @@ -0,0 +1,63 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem; + +import de.steamwar.message.Message; +import lombok.Getter; +import org.bukkit.Bukkit; +import org.bukkit.plugin.java.JavaPlugin; + +import java.lang.reflect.Method; +import java.util.logging.Level; + +public class BauSystemPlugin extends JavaPlugin { + + public static Message MESSAGE; + + @Getter + public static BauSystemPlugin instance; + + @Override + public void onEnable() { + MESSAGE = new Message("BauSystem", getClassLoader()); + instance = this; + + try { + Class clazz = Class.forName("de.steamwar.bausystem.LinkageUtils"); + Method method = clazz.getMethod("link"); + method.invoke(null); + } catch (Exception e) { + Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e); + Bukkit.shutdown(); + System.exit(1); + } + } + + @Override + public void onDisable() { + try { + Class clazz = Class.forName("de.steamwar.bausystem.LinkageUtils"); + Method method = clazz.getMethod("unlink"); + method.invoke(null); + } catch (Exception e) { + Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e); + } + } +}