From b734d2352b6eeee3645f5d60958568abecb897fb Mon Sep 17 00:00:00 2001 From: jakub Date: Wed, 16 Oct 2024 20:30:44 +0200 Subject: [PATCH] =?UTF-8?q?pRVN=C3=8D=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 113 ++++++++++++++++++ pom.xml | 72 +++++++++++ .../mineconomiaCoreV2/MineconomiaCoreV2.java | 30 +++++ .../mineconomiaCoreV2/core/MsgRetriever.java | 15 +++ .../soukup/mineconomiaCoreV2/core/PDC.java | 51 ++++++++ .../mineconomiaCoreV2/core/sharedValues.java | 12 ++ .../tractor/giveTractorCommand.java | 17 +++ src/main/resources/config.yml | 2 + src/main/resources/lang/czech.yml | 6 + src/main/resources/plugin.yml | 7 ++ 10 files changed, 325 insertions(+) create mode 100644 .gitignore create mode 100644 pom.xml create mode 100644 src/main/java/xyz/soukup/mineconomiaCoreV2/MineconomiaCoreV2.java create mode 100644 src/main/java/xyz/soukup/mineconomiaCoreV2/core/MsgRetriever.java create mode 100644 src/main/java/xyz/soukup/mineconomiaCoreV2/core/PDC.java create mode 100644 src/main/java/xyz/soukup/mineconomiaCoreV2/core/sharedValues.java create mode 100644 src/main/java/xyz/soukup/mineconomiaCoreV2/tractor/giveTractorCommand.java create mode 100644 src/main/resources/config.yml create mode 100644 src/main/resources/lang/czech.yml create mode 100644 src/main/resources/plugin.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4788b4b --- /dev/null +++ b/.gitignore @@ -0,0 +1,113 @@ +# User-specific stuff +.idea/ + +*.iml +*.ipr +*.iws + +# IntelliJ +out/ + +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +target/ + +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next + +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +.mvn/wrapper/maven-wrapper.jar +.flattened-pom.xml + +# Common working directory +run/ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..9cc5baf --- /dev/null +++ b/pom.xml @@ -0,0 +1,72 @@ + + + 4.0.0 + + xyz.soukup + mineconomiacorev2 + 1.0-SNAPSHOT + jar + + mineconomiacorev2 + + + 21 + UTF-8 + + + + clean package + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + ${java.version} + ${java.version} + + + + org.apache.maven.plugins + maven-shade-plugin + 3.5.3 + + + package + + shade + + + + + + + + src/main/resources + true + + + + + + + spigotmc-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + sonatype + https://oss.sonatype.org/content/groups/public/ + + + + + + org.spigotmc + spigot-api + 1.21.1-R0.1-SNAPSHOT + provided + + + diff --git a/src/main/java/xyz/soukup/mineconomiaCoreV2/MineconomiaCoreV2.java b/src/main/java/xyz/soukup/mineconomiaCoreV2/MineconomiaCoreV2.java new file mode 100644 index 0000000..bbc1af4 --- /dev/null +++ b/src/main/java/xyz/soukup/mineconomiaCoreV2/MineconomiaCoreV2.java @@ -0,0 +1,30 @@ +package xyz.soukup.mineconomiaCoreV2; + +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.plugin.java.JavaPlugin; +import xyz.soukup.mineconomiaCoreV2.tractor.giveTractorCommand; + +import java.util.Objects; + +public final class MineconomiaCoreV2 extends JavaPlugin { + MineconomiaCoreV2 plugin = getPlugin(this.getClass()); + @Override + public void onEnable() { + // Plugin startup logic + getLogger().info("STARTING MINECONOMIA CORE"); + plugin.saveConfig(); + + //tractor registration + Objects.requireNonNull(plugin.getCommand("tractor")).setExecutor(new giveTractorCommand()); + + + + + } + + @Override + public void onDisable() { + // Plugin shutdown logic + } + +} diff --git a/src/main/java/xyz/soukup/mineconomiaCoreV2/core/MsgRetriever.java b/src/main/java/xyz/soukup/mineconomiaCoreV2/core/MsgRetriever.java new file mode 100644 index 0000000..b0c20f4 --- /dev/null +++ b/src/main/java/xyz/soukup/mineconomiaCoreV2/core/MsgRetriever.java @@ -0,0 +1,15 @@ +package xyz.soukup.mineconomiaCoreV2.core; + +import org.bukkit.configuration.file.YamlConfiguration; + +import static xyz.soukup.mineconomiaCoreV2.core.sharedValues.config; +import static xyz.soukup.mineconomiaCoreV2.core.sharedValues.plugin; + +public class MsgRetriever { + public static YamlConfiguration lang = null; + public static void loadLang(){ + String langPath = "lang/" + config.getString("lang"); + plugin.saveResource(langPath, false); + //lang = YamlConfiguration.loadConfiguration(plugin.getResource(langPath)); + } +} diff --git a/src/main/java/xyz/soukup/mineconomiaCoreV2/core/PDC.java b/src/main/java/xyz/soukup/mineconomiaCoreV2/core/PDC.java new file mode 100644 index 0000000..bf5f637 --- /dev/null +++ b/src/main/java/xyz/soukup/mineconomiaCoreV2/core/PDC.java @@ -0,0 +1,51 @@ +package xyz.soukup.mineconomiaCoreV2.core; + +import org.bukkit.NamespacedKey; +import org.bukkit.block.TileState; +import org.bukkit.entity.Player; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.persistence.PersistentDataContainer; +import org.bukkit.persistence.PersistentDataType; + +public class PDC { + public static void WritePlayerPDC(Player player, String key, PersistentDataType type, Object value){ + NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); + PersistentDataContainer pdc = player.getPersistentDataContainer(); + pdc.set(nKey, type, value); + + } + public static Object GetPlayerPDC(Player player, String key, PersistentDataType type){ + NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); + PersistentDataContainer pdc = player.getPersistentDataContainer(); + return pdc.get(nKey, type); + } + public static void DeletePlayerPDC(Player player, String key){ + NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); + PersistentDataContainer pdc = player.getPersistentDataContainer(); + pdc.remove(nKey); + + } + public static void WriteItemMetaPDC(ItemMeta itemMeta, String key, PersistentDataType type, Object value){ + NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); + PersistentDataContainer pdc = itemMeta.getPersistentDataContainer(); + pdc.set(nKey, type, value); + + } + public static Object GetItemMetaPDC(ItemMeta itemMeta, String key, PersistentDataType type){ + NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); + PersistentDataContainer pdc = itemMeta.getPersistentDataContainer(); + return pdc.get(nKey, type); + } + public static void WriteTileStatePDC(TileState tileState, String key, PersistentDataType type, Object value){ + NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); + PersistentDataContainer pdc = tileState.getPersistentDataContainer(); + pdc.set(nKey, type, value); + + } + public static Object GetTileStatePDC(TileState tileState, String key, PersistentDataType type){ + NamespacedKey nKey = new NamespacedKey(sharedValues.plugin, key); + PersistentDataContainer pdc = tileState.getPersistentDataContainer(); + return pdc.get(nKey, type); + } + +} diff --git a/src/main/java/xyz/soukup/mineconomiaCoreV2/core/sharedValues.java b/src/main/java/xyz/soukup/mineconomiaCoreV2/core/sharedValues.java new file mode 100644 index 0000000..989729a --- /dev/null +++ b/src/main/java/xyz/soukup/mineconomiaCoreV2/core/sharedValues.java @@ -0,0 +1,12 @@ +package xyz.soukup.mineconomiaCoreV2.core; + +import org.bukkit.configuration.file.FileConfiguration; +import xyz.soukup.mineconomiaCoreV2.MineconomiaCoreV2; + +import java.util.logging.Logger; + +public class sharedValues { + public static MineconomiaCoreV2 plugin = MineconomiaCoreV2.getPlugin(MineconomiaCoreV2.class); + public static FileConfiguration config = plugin.getConfig(); + public static Logger logger = plugin.getLogger(); +} diff --git a/src/main/java/xyz/soukup/mineconomiaCoreV2/tractor/giveTractorCommand.java b/src/main/java/xyz/soukup/mineconomiaCoreV2/tractor/giveTractorCommand.java new file mode 100644 index 0000000..b804fa9 --- /dev/null +++ b/src/main/java/xyz/soukup/mineconomiaCoreV2/tractor/giveTractorCommand.java @@ -0,0 +1,17 @@ +package xyz.soukup.mineconomiaCoreV2.tractor; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class giveTractorCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) { + if (!(commandSender instanceof Player)){ + + return false; + } + return false; + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml new file mode 100644 index 0000000..46ccd95 --- /dev/null +++ b/src/main/resources/config.yml @@ -0,0 +1,2 @@ +version: 1.0 +language: "czech.yml" \ No newline at end of file diff --git a/src/main/resources/lang/czech.yml b/src/main/resources/lang/czech.yml new file mode 100644 index 0000000..d8d6abc --- /dev/null +++ b/src/main/resources/lang/czech.yml @@ -0,0 +1,6 @@ +error: + command: + not-player: "&cPříkaz může použít jen hráč!" + not-console: "&cPříkaz může použít jen konzole!" + wrong-argument-count: "&cNesprávný počet parametrů!" + no-permissions: "&cNemáš oprávnění!" diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..b1c2bf9 --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,7 @@ +name: MineconomiaCoreV2 +version: '1.0-SNAPSHOT' +main: xyz.soukup.mineconomiaCoreV2.MineconomiaCoreV2 +api-version: '1.21' +commands: + tractor: + description: "blieat"