From 41fc21a9a5473ee234a738f9b896c6b586aa48cc Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Tue, 27 Feb 2024 18:04:21 +0100 Subject: [PATCH 01/36] bumped version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fd446cc7..6add0727 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ de.relluem94 relluessentials RelluEssentials - 4.1.5 + 4.1.6 https://github.com/Relluem94s/RelluEssentials 1.19 From b2f1177f95fd644bca415bf5c1e13ba074b513fc Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Tue, 27 Feb 2024 18:35:24 +0100 Subject: [PATCH 02/36] RE-146 added SQLs --- .../resources/sqls/patches/v7/alterFarmingBag.sql | 12 ++++++++++++ .../sqls/patches/v7/alterFarmingBagType.sql | 11 +++++++++++ .../resources/sqls/patches/v7/insertNewDBVersion.sql | 6 ++++++ .../sqls/patches/v7/updateOldPluginInformation.sql | 6 ++++++ 4 files changed, 35 insertions(+) create mode 100644 src/main/resources/sqls/patches/v7/alterFarmingBag.sql create mode 100644 src/main/resources/sqls/patches/v7/alterFarmingBagType.sql create mode 100644 src/main/resources/sqls/patches/v7/insertNewDBVersion.sql create mode 100644 src/main/resources/sqls/patches/v7/updateOldPluginInformation.sql diff --git a/src/main/resources/sqls/patches/v7/alterFarmingBag.sql b/src/main/resources/sqls/patches/v7/alterFarmingBag.sql new file mode 100644 index 00000000..175486b7 --- /dev/null +++ b/src/main/resources/sqls/patches/v7/alterFarmingBag.sql @@ -0,0 +1,12 @@ +/** + * Author: rellu + * Created: 27.02.2024 + */ + +UPDATE + `bag` +SET + `slot_18_value` = `slot_18_value` + `slot_14_value`, + `slot_14_value` = 0 +WHERE + `bag`.`bag_type_fk` = 2; \ No newline at end of file diff --git a/src/main/resources/sqls/patches/v7/alterFarmingBagType.sql b/src/main/resources/sqls/patches/v7/alterFarmingBagType.sql new file mode 100644 index 00000000..bfb6a500 --- /dev/null +++ b/src/main/resources/sqls/patches/v7/alterFarmingBagType.sql @@ -0,0 +1,11 @@ +/** + * Author: rellu + * Created: 27.02.2024 + */ + +UPDATE + `bag_type` +SET + `slot_14_name` = 'EGG' +WHERE + `bag_type`.`id` = 2; \ No newline at end of file diff --git a/src/main/resources/sqls/patches/v7/insertNewDBVersion.sql b/src/main/resources/sqls/patches/v7/insertNewDBVersion.sql new file mode 100644 index 00000000..837a00bd --- /dev/null +++ b/src/main/resources/sqls/patches/v7/insertNewDBVersion.sql @@ -0,0 +1,6 @@ +/** + * Author: rellu + * Created: 19.02.2023 + */ + +INSERT INTO `plugin_informations` (`CREATED`, `CREATEDBY`, `tab_header`, `tab_footer`, `motd_message`, `motd_players`, `db_version`) SELECT now(), 1, tab_header, tab_footer, motd_message, motd_players, 7 FROM `plugin_informations` where deletedby is null; diff --git a/src/main/resources/sqls/patches/v7/updateOldPluginInformation.sql b/src/main/resources/sqls/patches/v7/updateOldPluginInformation.sql new file mode 100644 index 00000000..0d266461 --- /dev/null +++ b/src/main/resources/sqls/patches/v7/updateOldPluginInformation.sql @@ -0,0 +1,6 @@ +/** + * Author: rellu + * Created: 19.02.2023 + */ + +UPDATE `plugin_informations` SET `deleted` = now(), `deletedby` = 1 WHERE `plugin_informations`.`DELETEDBY` IS NULL and `db_version` <> 7 ; \ No newline at end of file From 73c767aafdf2f7297dea70dfeb32797eda727ea5 Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Tue, 27 Feb 2024 18:39:54 +0100 Subject: [PATCH 03/36] RE-146 added patch 7 to DatabaseHelper --- .../essentials/helpers/DatabaseHelper.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java index 51710399..e1251756 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java @@ -264,6 +264,16 @@ private void patch6() { executeScript(v + UPDATE_OLD_PLUGIN_INFORMATION); } + private void patch7() { + String v = "patches/v7/"; + + executeScript(v + "alterFarmingBag.sql"); + executeScript(v + "alterFarmingBagType.sql"); + + executeScript(v + INSERT_NEW_DB_VERSION); + executeScript(v + UPDATE_OLD_PLUGIN_INFORMATION); + } + public void init() { applyPatch(getPluginInformation().getDbVersion()); } @@ -280,6 +290,7 @@ private void applyPatch(int version) { patch4(); patch5(); patch6(); + patch7(); break; case 1: patch2(); @@ -287,29 +298,37 @@ private void applyPatch(int version) { patch4(); patch5(); patch6(); + patch7(); break; case 2: patch3(); patch4(); patch5(); patch6(); + patch7(); break; case 3: patch4(); patch5(); patch6(); + patch7(); break; case 4: patch5(); patch6(); + patch7(); break; case 5: patch6(); + patch7(); + break; + case 6: + patch7(); break; default: if (insertScripts) { - String v = "patches/v6/"; + String v = "patches/v7/"; executeScript(v + "script.sql"); } break; From e19aedb89d62c0c1e8ccc73009523633dd9b8f22 Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Tue, 27 Feb 2024 18:57:31 +0100 Subject: [PATCH 04/36] RE-156 add MiningBagChange SQL --- .../resources/sqls/patches/v7/alterMiningBagType.sql | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/main/resources/sqls/patches/v7/alterMiningBagType.sql diff --git a/src/main/resources/sqls/patches/v7/alterMiningBagType.sql b/src/main/resources/sqls/patches/v7/alterMiningBagType.sql new file mode 100644 index 00000000..8868cb4f --- /dev/null +++ b/src/main/resources/sqls/patches/v7/alterMiningBagType.sql @@ -0,0 +1,12 @@ +/** + * Author: rellu + * Created: 27.02.2024 + */ + +UPDATE + `bag_type` +SET + `slot_20_name` = 'TUFF', + `slot_21_name` = 'CALCITE' +WHERE + `bag_type`.`id` = 1; \ No newline at end of file From a3d59304a7390fb73b180de33a122040fd839345 Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Tue, 27 Feb 2024 18:58:03 +0100 Subject: [PATCH 05/36] RE-156 add sql to DatabaseHelper --- .../server/spigot/essentials/helpers/DatabaseHelper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java index e1251756..3c119bbe 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java @@ -269,6 +269,7 @@ private void patch7() { executeScript(v + "alterFarmingBag.sql"); executeScript(v + "alterFarmingBagType.sql"); + executeScript(v + "alterMiningBagType.sql"); executeScript(v + INSERT_NEW_DB_VERSION); executeScript(v + UPDATE_OLD_PLUGIN_INFORMATION); From ffefdbb12aa776369293e8499fa899ab91e6f79e Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Tue, 27 Feb 2024 20:57:55 +0100 Subject: [PATCH 06/36] RE-158 Fixed README.md and CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- README.md | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2212eb9a..89c3889d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,3 +1,3 @@ # How to * Create an Issue (Bug, New Feature) -* Make an linked Pull Request +* Make a linked Pull Request diff --git a/README.md b/README.md index 853068e8..db24042e 100644 --- a/README.md +++ b/README.md @@ -7,29 +7,29 @@ Find out how to get the plugin and how to use it. ## Usage of Plugin 1. [Download](https://github.com/Relluem94s/RelluEssentials/packages) or [Build](https://github.com/Relluem94s/RelluEssentials#build) the plugin jar -1. Copy the jar into the `plugin` Directory -1. Start and Stop the Server -1. Set Host, User and Password of your MySQL Server in the config.yml -1. Start your Server again -1. Enjoy +2. Copy the jar into the `plugin` Directory +3. Start and Stop the Server +4. Set Host, User and Password of your MySQL Server in the config.yml +5. Start your Server again +6. Enjoy ## Build 1. ```shell git clone https://github.com/Relluem94/RelluEssentials.git ``` -1. ```shell +2. ```shell git checkout $(git describe --tags $(git rev-list --tags --max-count=1)) ``` -1. ```shell +3. ```shell mvn clean install ``` ## Deploy Package -1. Make sure that your github token is in your maven settings.xml (~/.m2/settings.xml) -1. ```shell +1. Make sure that your GitHub token is in your maven settings.xml (~/.m2/settings.xml) +2. ```shell mvn --batch-mode deploy ``` @@ -44,7 +44,7 @@ it will run a specified Dev-Sever (with docker mysql and phpmyadmin) check [Rell What does the plugin include? ## Commands -* Admin gives Clearing Chat, Fake AFK, Teleport to highest Block and Custom NPCs (`/admin`) +* Admin gives Clearing Chat, Fake AFK, Teleport to the highest Block and Custom NPCs (`/admin`) * Away from Keyboard (`/afk`) * Teleports to the latest Checkpoint (on spawn, teleport, world, warp and home) (`/back`) * Opens Bag Pack Menu (`/bags`) From 81b9e48c51a9a1d0c0ef0e285c3b846db09f5abb Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Tue, 27 Feb 2024 20:59:30 +0100 Subject: [PATCH 07/36] RE-159 Added Intellij Project --- .idea/.gitignore | 3 +++ .idea/compiler.xml | 13 +++++++++++++ .idea/encodings.xml | 7 +++++++ .idea/jarRepositories.xml | 35 +++++++++++++++++++++++++++++++++++ .idea/misc.xml | 12 ++++++++++++ .idea/vcs.xml | 7 +++++++ dependency-reduced-pom.xml | 2 +- 7 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/compiler.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..26d33521 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 00000000..333704a7 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 00000000..86f4b6f0 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 00000000..3eb2d550 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..67e1e611 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..c5aecb96 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index 0fc76e31..0a2d05f5 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -4,7 +4,7 @@ de.relluem94 relluessentials RelluEssentials - 4.1.5 + 4.1.6 https://github.com/Relluem94s/RelluEssentials scm:git:git@github.com:Relluem94s/RelluEssentials.git From c1fdfcc463e28d688ac50f64d0fdb8b3216c6bcf Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Tue, 27 Feb 2024 21:34:49 +0100 Subject: [PATCH 08/36] RE-159 Added Intellij Project --- .idea/google-java-format.xml | 6 ++++++ .idea/modules.xml | 8 ++++++++ MinecraftDevelopmentEnvironment.sh | 1 - relluessentials.iml | 19 +++++++++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 .idea/google-java-format.xml create mode 100644 .idea/modules.xml delete mode 120000 MinecraftDevelopmentEnvironment.sh create mode 100644 relluessentials.iml diff --git a/.idea/google-java-format.xml b/.idea/google-java-format.xml new file mode 100644 index 00000000..8b57f452 --- /dev/null +++ b/.idea/google-java-format.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..14733308 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/MinecraftDevelopmentEnvironment.sh b/MinecraftDevelopmentEnvironment.sh deleted file mode 120000 index 364b12df..00000000 --- a/MinecraftDevelopmentEnvironment.sh +++ /dev/null @@ -1 +0,0 @@ -RelluBash-Script-Collection/dev/MinecraftDevelopmentEnvironment.sh \ No newline at end of file diff --git a/relluessentials.iml b/relluessentials.iml new file mode 100644 index 00000000..d42b276b --- /dev/null +++ b/relluessentials.iml @@ -0,0 +1,19 @@ + + + + + + + SPIGOT + MCP + PAPER + ADVENTURE + + 1 + + + + + + \ No newline at end of file From f87cb1a4c721c94ed5d6e88b3a876cecf7f84a47 Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Tue, 27 Feb 2024 21:35:00 +0100 Subject: [PATCH 09/36] RE-159 Added Intellij Project --- RelluBash-Script-Collection | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RelluBash-Script-Collection b/RelluBash-Script-Collection index b25c2aa3..e94ea048 160000 --- a/RelluBash-Script-Collection +++ b/RelluBash-Script-Collection @@ -1 +1 @@ -Subproject commit b25c2aa3d070b21e9cb313b5fb5518c1fcd3cb52 +Subproject commit e94ea048aaf5a766cd123b493a4ad69e970374b9 From 1f1859ec1947f273d0a0a9fdc7b43bc92470d1b3 Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Tue, 27 Feb 2024 22:52:08 +0100 Subject: [PATCH 10/36] RE-148 Chorusplant Harvesting quicksave --- .../spigot/essentials/events/BetterBags.java | 89 +++++++++++++++++-- 1 file changed, 81 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterBags.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterBags.java index 215994c0..d4f5a145 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterBags.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterBags.java @@ -40,7 +40,7 @@ import de.relluem94.minecraft.server.spigot.essentials.helpers.pojo.PlayerEntry; import de.relluem94.rellulib.stores.DoubleStore; public class BetterBags implements Listener { - + @EventHandler public void onBlockBreak(BlockBreakEvent e){ Player p = e.getPlayer(); @@ -65,18 +65,51 @@ public void onBlockBreak(BlockBreakEvent e){ } if(p.getInventory().getItemInMainHand() != null && EnchantmentHelper.hasEnchant(p.getInventory().getItemInMainHand(), CustomEnchants.telekinesis)){ - Block block = e.getBlock(); int dropCount = 0; - if(isSugarCaneOrIsBamboo(block)){ - while(isSugarCaneOrIsBamboo(block.getRelative(BlockFace.UP))){ + if(isChorusPlant(b)){ + List blocks = new ArrayList<>(); + List newBlocks = new ArrayList<>(); + blocks.add(b); + + newBlocks.addAll(getNextChorusPlantBlock(b)); + blocks.addAll(newBlocks); + + int upperLimit = 20; + int actualLimt = 0; + + while(!newBlocks.isEmpty()){ + System.out.println("While >> " + actualLimt + " " + newBlocks.size() + " " + blocks.size()); + + + actualLimt++; + + if(actualLimt == upperLimit){ + break; + } + + List newBlocks2 = getAllChorusPlantBlocks(newBlocks); + newBlocks.clear(); + newBlocks.addAll(newBlocks2); + blocks.addAll(newBlocks); + } + + if(blocks.size() <= 30){ + for(Block block : blocks){ + block.setType(Material.DIAMOND_BLOCK); + } + } + } + + if(isSugarCaneOrIsBamboo(b)){ + while(isSugarCaneOrIsBamboo(b.getRelative(BlockFace.UP))){ dropCount++; - block.setType(Material.AIR); - block = block.getRelative(BlockFace.UP); + b.setType(Material.AIR); + b = b.getRelative(BlockFace.UP); } - if(isSugarCaneOrIsBamboo(block)){ - block.setType(Material.AIR); + if(isSugarCaneOrIsBamboo(b)){ + b.setType(Material.AIR); dropCount++; } @@ -90,6 +123,46 @@ public void onBlockBreak(BlockBreakEvent e){ } } + private List getAllChorusPlantBlocks(List blocks) { + List newBlocks = new ArrayList<>(); + for(Block block : blocks){ + newBlocks.addAll(getNextChorusPlantBlock(block)); + } + + System.out.println("For >> " + blocks.size() + " " + newBlocks.size()); + + return newBlocks; + } + + private List getNextChorusPlantBlock(Block block){ + List blocks = new ArrayList<>(); + if(block.getRelative(BlockFace.UP).getType().equals(Material.CHORUS_PLANT) || block.getRelative(BlockFace.UP).getType().equals(Material.CHORUS_FLOWER)){ + blocks.add(block.getRelative(BlockFace.UP)); + } + + if(block.getRelative(BlockFace.WEST).getType().equals(Material.CHORUS_PLANT) || block.getRelative(BlockFace.WEST).getType().equals(Material.CHORUS_FLOWER)){ + blocks.add(block.getRelative(BlockFace.WEST)); + } + + if(block.getRelative(BlockFace.SOUTH).getType().equals(Material.CHORUS_PLANT) || block.getRelative(BlockFace.SOUTH).getType().equals(Material.CHORUS_FLOWER)){ + blocks.add(block.getRelative(BlockFace.SOUTH)); + } + + if(block.getRelative(BlockFace.NORTH).getType().equals(Material.CHORUS_PLANT) || block.getRelative(BlockFace.NORTH).getType().equals(Material.CHORUS_FLOWER)){ + blocks.add(block.getRelative(BlockFace.NORTH)); + } + + if(block.getRelative(BlockFace.EAST).getType().equals(Material.CHORUS_PLANT) || block.getRelative(BlockFace.EAST).getType().equals(Material.CHORUS_FLOWER)){ + blocks.add(block.getRelative(BlockFace.EAST)); + } + + return blocks; + } + + private boolean isChorusPlant(Block block){ + return block.getType().equals(Material.CHORUS_PLANT); + } + private boolean isSugarCaneOrIsBamboo(Block b){ return b.getType().equals(Material.SUGAR_CANE) || b.getType().equals(Material.BAMBOO); } From b8e219615bdfd4ce4480c5373204b5afe8e7a948 Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Wed, 28 Feb 2024 00:43:36 +0100 Subject: [PATCH 11/36] RE-148 Chorusplant Harvesting quicksave --- .../spigot/essentials/events/BetterBags.java | 80 +++++++------------ 1 file changed, 28 insertions(+), 52 deletions(-) diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterBags.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterBags.java index d4f5a145..27fe9ac2 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterBags.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterBags.java @@ -1,8 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials.events; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; +import java.util.*; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -11,7 +9,10 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.data.Ageable; +import org.bukkit.block.data.MultipleFacing; +import org.bukkit.block.data.type.Chest; import org.bukkit.block.data.type.Cocoa; +import org.bukkit.craftbukkit.v1_20_R1.block.impl.CraftChorusFlower; import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -69,30 +70,10 @@ public void onBlockBreak(BlockBreakEvent e){ if(isChorusPlant(b)){ List blocks = new ArrayList<>(); - List newBlocks = new ArrayList<>(); - blocks.add(b); - newBlocks.addAll(getNextChorusPlantBlock(b)); - blocks.addAll(newBlocks); + blocks.addAll(getChorusBlocks(b,0, null)); - int upperLimit = 20; - int actualLimt = 0; - while(!newBlocks.isEmpty()){ - System.out.println("While >> " + actualLimt + " " + newBlocks.size() + " " + blocks.size()); - - - actualLimt++; - - if(actualLimt == upperLimit){ - break; - } - - List newBlocks2 = getAllChorusPlantBlocks(newBlocks); - newBlocks.clear(); - newBlocks.addAll(newBlocks2); - blocks.addAll(newBlocks); - } if(blocks.size() <= 30){ for(Block block : blocks){ @@ -123,46 +104,41 @@ public void onBlockBreak(BlockBreakEvent e){ } } - private List getAllChorusPlantBlocks(List blocks) { - List newBlocks = new ArrayList<>(); - for(Block block : blocks){ - newBlocks.addAll(getNextChorusPlantBlock(block)); - } - - System.out.println("For >> " + blocks.size() + " " + newBlocks.size()); - - return newBlocks; + private boolean isChorusPlant(Block block){ + return block.getType().equals(Material.CHORUS_PLANT); } - private List getNextChorusPlantBlock(Block block){ - List blocks = new ArrayList<>(); - if(block.getRelative(BlockFace.UP).getType().equals(Material.CHORUS_PLANT) || block.getRelative(BlockFace.UP).getType().equals(Material.CHORUS_FLOWER)){ - blocks.add(block.getRelative(BlockFace.UP)); - } + private Set getChorusBlocks(Block b, int count, BlockFace prevBlockFace){ + Set blocks = new LinkedHashSet<>(); - if(block.getRelative(BlockFace.WEST).getType().equals(Material.CHORUS_PLANT) || block.getRelative(BlockFace.WEST).getType().equals(Material.CHORUS_FLOWER)){ - blocks.add(block.getRelative(BlockFace.WEST)); + count ++; + if(count == 30){ + return blocks; } - if(block.getRelative(BlockFace.SOUTH).getType().equals(Material.CHORUS_PLANT) || block.getRelative(BlockFace.SOUTH).getType().equals(Material.CHORUS_FLOWER)){ - blocks.add(block.getRelative(BlockFace.SOUTH)); - } + if(isChorusPlant(b)){ + if(b.getBlockData() instanceof MultipleFacing bdf){ + for(BlockFace bf : bdf.getFaces()){ + if(bf.equals(BlockFace.DOWN)){ + continue; + } - if(block.getRelative(BlockFace.NORTH).getType().equals(Material.CHORUS_PLANT) || block.getRelative(BlockFace.NORTH).getType().equals(Material.CHORUS_FLOWER)){ - blocks.add(block.getRelative(BlockFace.NORTH)); - } + if((bf.equals(prevBlockFace))){ + continue; + } + + Block block = b.getRelative(bf); + blocks.add(block); - if(block.getRelative(BlockFace.EAST).getType().equals(Material.CHORUS_PLANT) || block.getRelative(BlockFace.EAST).getType().equals(Material.CHORUS_FLOWER)){ - blocks.add(block.getRelative(BlockFace.EAST)); + System.out.println(count + " " + blocks.size() + " " + bf.name()); + blocks.addAll(getChorusBlocks(block, 28, bf.getOppositeFace())); + } + } } return blocks; } - private boolean isChorusPlant(Block block){ - return block.getType().equals(Material.CHORUS_PLANT); - } - private boolean isSugarCaneOrIsBamboo(Block b){ return b.getType().equals(Material.SUGAR_CANE) || b.getType().equals(Material.BAMBOO); } From 1fcf5124a96b144759b9905e5e4393451733c352 Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Wed, 28 Feb 2024 00:50:43 +0100 Subject: [PATCH 12/36] RE-148 Chorusplant Harvesting quicksave --- .../spigot/essentials/events/BetterBags.java | 52 ++++++++----------- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterBags.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterBags.java index 27fe9ac2..7d7bc7d3 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterBags.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterBags.java @@ -10,9 +10,7 @@ import org.bukkit.block.BlockFace; import org.bukkit.block.data.Ageable; import org.bukkit.block.data.MultipleFacing; -import org.bukkit.block.data.type.Chest; import org.bukkit.block.data.type.Cocoa; -import org.bukkit.craftbukkit.v1_20_R1.block.impl.CraftChorusFlower; import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -48,13 +46,12 @@ public void onBlockBreak(BlockBreakEvent e){ Block b = e.getBlock(); Material m = b.getType(); - if(p.getInventory().getItemInMainHand() != null && EnchantmentHelper.hasEnchant(p.getInventory().getItemInMainHand(), CustomEnchants.delicate)){ + if(EnchantmentHelper.hasEnchant(p.getInventory().getItemInMainHand(), CustomEnchants.delicate)){ if(m.equals(Material.PUMPKIN_STEM) || m.equals(Material.MELON_STEM) || m.equals(Material.ATTACHED_PUMPKIN_STEM) || m.equals(Material.ATTACHED_MELON_STEM)){ e.setCancelled(true); } - if(e.getBlock().getBlockData() instanceof Ageable){ - Ageable age = (Ageable) e.getBlock().getBlockData(); + if(e.getBlock().getBlockData() instanceof Ageable age){ if(age.getAge() != age.getMaximumAge() && (!m.equals(Material.SUGAR_CANE))){ e.setCancelled(true); } @@ -65,17 +62,14 @@ public void onBlockBreak(BlockBreakEvent e){ } } - if(p.getInventory().getItemInMainHand() != null && EnchantmentHelper.hasEnchant(p.getInventory().getItemInMainHand(), CustomEnchants.telekinesis)){ + if(EnchantmentHelper.hasEnchant(p.getInventory().getItemInMainHand(), CustomEnchants.telekinesis)){ int dropCount = 0; if(isChorusPlant(b)){ - List blocks = new ArrayList<>(); - blocks.addAll(getChorusBlocks(b,0, null)); + List blocks = new ArrayList<>(getChorusBlocks(b, 0, null)); - - - if(blocks.size() <= 30){ + if(blocks.size() <= 50){ for(Block block : blocks){ block.setType(Material.DIAMOND_BLOCK); } @@ -97,8 +91,8 @@ public void onBlockBreak(BlockBreakEvent e){ if(!m.equals(Material.AIR)){ Item item = e.getBlock().getWorld().dropItem(e.getBlock().getLocation(), new ItemStack(m, dropCount)); - EntityPickupItemEvent epie = new EntityPickupItemEvent(p, item, dropCount); - Bukkit.getPluginManager().callEvent(epie); + EntityPickupItemEvent entityPickupItemEvent = new EntityPickupItemEvent(p, item, dropCount); + Bukkit.getPluginManager().callEvent(entityPickupItemEvent); } } } @@ -128,10 +122,11 @@ private Set getChorusBlocks(Block b, int count, BlockFace prevBlockFace){ } Block block = b.getRelative(bf); - blocks.add(block); - System.out.println(count + " " + blocks.size() + " " + bf.name()); - blocks.addAll(getChorusBlocks(block, 28, bf.getOppositeFace())); + if(blocks.add(block)){ + System.out.println(count + " " + blocks.size() + " " + bf.name()); + blocks.addAll(getChorusBlocks(block, 28, bf.getOppositeFace())); + } } } } @@ -143,7 +138,7 @@ private boolean isSugarCaneOrIsBamboo(Block b){ return b.getType().equals(Material.SUGAR_CANE) || b.getType().equals(Material.BAMBOO); } - private Random r = new Random(); + private final Random random = new Random(); @EventHandler public void onBlockDrop(BlockDropItemEvent e) { @@ -154,18 +149,17 @@ public void onBlockDrop(BlockDropItemEvent e) { if(RelluEssentials.getInstance().dropMap.containsKey(i.getItemStack().getType())){ if(i.getItemStack().getAmount() == 1){ DoubleStore ds = RelluEssentials.getInstance().dropMap.get(i.getItemStack().getType()); - i.getItemStack().setAmount(r.nextInt((int)ds.getSecondValue()) + (int)ds.getValue()); + i.getItemStack().setAmount(random.nextInt((int)ds.getSecondValue()) + (int)ds.getValue()); } } } - if(p.getInventory().getItemInMainHand() != null && EnchantmentHelper.hasEnchant(p.getInventory().getItemInMainHand(), CustomEnchants.replenishment)){ + if(EnchantmentHelper.hasEnchant(p.getInventory().getItemInMainHand(), CustomEnchants.replenishment)){ for(int i = 0; i < e.getItems().size(); i++){ if(e.getItems().get(i) != null && RelluEssentials.getInstance().crops.containsKey(e.getItems().get(i).getItemStack().getType())){ e.getBlock().setType(RelluEssentials.getInstance().crops.get(e.getItems().get(i).getItemStack().getType())); - if(e.getBlock().getBlockData() instanceof Cocoa){ - Cocoa c = (Cocoa) e.getBlock().getBlockData(); + if(e.getBlock().getBlockData() instanceof Cocoa c){ Block cocoa = e.getBlock(); Block wood = cocoa.getRelative(c.getFacing().getOppositeFace()); if(!wood.getType().equals(Material.JUNGLE_LOG)){ @@ -194,7 +188,7 @@ public void onBlockDrop(BlockDropItemEvent e) { e.getItems().removeAll(lis); } - if(p.getInventory().getItemInMainHand() != null && EnchantmentHelper.hasEnchant(p.getInventory().getItemInMainHand(), CustomEnchants.telekinesis)){ + if(EnchantmentHelper.hasEnchant(p.getInventory().getItemInMainHand(), CustomEnchants.telekinesis)){ List lis = new ArrayList<>(); for(Item i: e.getItems()){ if(p.getInventory().firstEmpty() != -1){ @@ -205,7 +199,7 @@ public void onBlockDrop(BlockDropItemEvent e) { e.getItems().removeAll(lis); } - if(p.getInventory().getItemInMainHand() != null && EnchantmentHelper.hasEnchant(p.getInventory().getItemInMainHand(), CustomEnchants.autosmelt)){ + if(EnchantmentHelper.hasEnchant(p.getInventory().getItemInMainHand(), CustomEnchants.autosmelt)){ for(int i = 0; i < e.getItems().size(); i++){ ItemStack is = e.getItems().get(i).getItemStack().clone(); if(e.getItems().get(i) != null && ItemHelper.getSmeltedItemStack(is) != null){ @@ -217,8 +211,7 @@ public void onBlockDrop(BlockDropItemEvent e) { @EventHandler public void onInventoryClickItem(InventoryClickEvent e) { - if(e.getWhoClicked() instanceof Player && e.getCurrentItem() != null){ - Player p = (Player) e.getWhoClicked(); + if(e.getWhoClicked() instanceof Player p && e.getCurrentItem() != null){ if (e.getView().getTitle().startsWith(Strings.PLUGIN_NAME_PREFIX + Strings.PLUGIN_FORMS_SPACER_MESSAGE) && e.getView().getTitle().endsWith(" Bag")) { PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); @@ -287,17 +280,14 @@ public void onInventoryClickItem(InventoryClickEvent e) { if(value >= is.getMaxStackSize()){ cleanIS.setAmount(is.getMaxStackSize()); be.setSlotValue(slot, value-is.getMaxStackSize()); - be.setToBeUpdated(true); - p.getInventory().addItem(cleanIS); - p.updateInventory(); } else{ cleanIS.setAmount(value); be.setSlotValue(slot, 0); - be.setToBeUpdated(true); - p.getInventory().addItem(cleanIS); - p.updateInventory(); } + be.setToBeUpdated(true); + p.getInventory().addItem(cleanIS); + p.updateInventory(); } } } From 6fed83c5a81ffac65cda800785775180b0733f52 Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Wed, 28 Feb 2024 01:22:01 +0100 Subject: [PATCH 13/36] RE-148 Chorusplant Harvesting --- .../spigot/essentials/events/BetterBags.java | 51 ++++++++++--------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterBags.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterBags.java index 7d7bc7d3..58d12700 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterBags.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterBags.java @@ -70,9 +70,11 @@ public void onBlockBreak(BlockBreakEvent e){ List blocks = new ArrayList<>(getChorusBlocks(b, 0, null)); if(blocks.size() <= 50){ - for(Block block : blocks){ - block.setType(Material.DIAMOND_BLOCK); - } + blocks.forEach(block -> block.setType(Material.AIR)); + + Item item = e.getBlock().getWorld().dropItem(e.getBlock().getLocation(), new ItemStack(Material.CHORUS_FRUIT, blocks.size()+1)); + EntityPickupItemEvent entityPickupItemEvent = new EntityPickupItemEvent(p, item, blocks.size()+1); + Bukkit.getPluginManager().callEvent(entityPickupItemEvent); } } @@ -113,18 +115,10 @@ private Set getChorusBlocks(Block b, int count, BlockFace prevBlockFace){ if(isChorusPlant(b)){ if(b.getBlockData() instanceof MultipleFacing bdf){ for(BlockFace bf : bdf.getFaces()){ - if(bf.equals(BlockFace.DOWN)){ - continue; - } - - if((bf.equals(prevBlockFace))){ - continue; - } - Block block = b.getRelative(bf); - + if(bf.equals(BlockFace.DOWN)){continue;} + if((bf.equals(prevBlockFace))){continue;} if(blocks.add(block)){ - System.out.println(count + " " + blocks.size() + " " + bf.name()); blocks.addAll(getChorusBlocks(block, 28, bf.getOppositeFace())); } } @@ -215,12 +209,22 @@ public void onInventoryClickItem(InventoryClickEvent e) { if (e.getView().getTitle().startsWith(Strings.PLUGIN_NAME_PREFIX + Strings.PLUGIN_FORMS_SPACER_MESSAGE) && e.getView().getTitle().endsWith(" Bag")) { PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); - BagEntry be = BagHelper.getBag(pe.getID(), BagHelper.getBagTypeByName(e.getView().getTitle()).getId()); + BagTypeEntry bte = BagHelper.getBagTypeByName(e.getView().getTitle()); + + if(bte == null){ + return; + } + + BagEntry be = BagHelper.getBag(pe.getID(), bte.getId()); + + if(be == null){ + return; + } ItemStack is = e.getCurrentItem(); int slot = BagHelper.getSlotByItemStack(be, is); - if(slot != -1){ + if(slot != -1 && e.getClickedInventory() != null){ int value = be.getSlotValue(slot); boolean isRightClick = e.isRightClick(); boolean isBagInventory = e.getClickedInventory().getType().equals(InventoryType.CHEST); @@ -235,15 +239,13 @@ public void onInventoryClickItem(InventoryClickEvent e) { p.getInventory().remove(fis); } } - p.updateInventory(); } else{ be.setSlotValue(slot, value + is.getAmount()); be.setToBeUpdated(true); - - p.getInventory().getItem(e.getSlot()).setAmount(0); - p.updateInventory(); + Objects.requireNonNull(p.getInventory().getItem(e.getSlot())).setAmount(0); } + p.updateInventory(); } else{ ItemStack cleanIS = ItemHelper.getCleanItemStack(is); @@ -293,17 +295,17 @@ public void onInventoryClickItem(InventoryClickEvent e) { } } - p.openInventory(BagHelper.getBag(be.getBagTypeId(), pe)); + p.openInventory(Objects.requireNonNull(BagHelper.getBag(be.getBagTypeId(), pe))); } e.setCancelled(true); } else if (e.getView().getTitle().equals(BagHelper.MAIN_GUI)) { e.setCancelled(true); - String name = e.getCurrentItem().getItemMeta().getDisplayName(); + String name = Objects.requireNonNull(e.getCurrentItem().getItemMeta()).getDisplayName(); BagTypeEntry bte = BagHelper.getBagTypeByName(name); if(bte != null){ PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(e.getWhoClicked().getUniqueId()); - e.getWhoClicked().openInventory(BagHelper.getBag(bte.getId(), pe)); + e.getWhoClicked().openInventory(Objects.requireNonNull(BagHelper.getBag(bte.getId(), pe))); } } } @@ -312,8 +314,7 @@ else if (e.getView().getTitle().equals(BagHelper.MAIN_GUI)) { @EventHandler public void onItemCollect(EntityPickupItemEvent e) { - if(e.getEntity() instanceof Player){ - Player p = (Player) e.getEntity(); + if(e.getEntity() instanceof Player p){ PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); @@ -321,7 +322,7 @@ public void onItemCollect(EntityPickupItemEvent e) { if(CustomItems.coins.almostEquals(is)){ ItemMeta im = is.getItemMeta(); - if(im.getPersistentDataContainer().has(ItemConstants.PLUGIN_ITEM_COINS_NAMESPACE, PersistentDataType.INTEGER)){ + if(im != null && im.getPersistentDataContainer().has(ItemConstants.PLUGIN_ITEM_COINS_NAMESPACE, PersistentDataType.INTEGER)){ int coins = im.getPersistentDataContainer().get(ItemConstants.PLUGIN_ITEM_COINS_NAMESPACE, PersistentDataType.INTEGER) * is.getAmount(); ChatHelper.sendMessageInActionBar(p, String.format(Strings.PLUGIN_COMMAND_PURSE_GAIN, StringHelper.formatInt(coins), StringHelper.formatDouble(pe.getPurse() + coins))); pe.setPurse(pe.getPurse() + coins); From df34c0cb1c6ad17427c12ab9d0108bbb3c595dda Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Wed, 28 Feb 2024 01:26:06 +0100 Subject: [PATCH 14/36] RE-160 Fixed Speed --- .../minecraft/server/spigot/essentials/commands/Speed.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Speed.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Speed.java index dd51bb8c..b3cb4357 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Speed.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Speed.java @@ -25,7 +25,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St return true; } - if (isPlayer(sender)) { + if (!isPlayer(sender)) { sender.sendMessage(PLUGIN_COMMAND_NOT_A_PLAYER); return true; } From 6c068c0b9d74fdacadf26389861d57894a4f7cb7 Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Wed, 28 Feb 2024 01:55:56 +0100 Subject: [PATCH 15/36] RE-147 Fixed Missing Message and Name not Updating --- .../essentials/commands/PermissionsGroup.java | 51 +++++++++++-------- .../essentials/helpers/PlayerHelper.java | 24 ++++----- 2 files changed, 41 insertions(+), 34 deletions(-) diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PermissionsGroup.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PermissionsGroup.java index eabcccff..3c2bb8ea 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PermissionsGroup.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PermissionsGroup.java @@ -11,6 +11,7 @@ import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isConsole; import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isPlayer; +import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -23,6 +24,8 @@ import de.relluem94.minecraft.server.spigot.essentials.permissions.Groups; import de.relluem94.minecraft.server.spigot.essentials.permissions.Permission; +import java.util.Objects; + public class PermissionsGroup implements CommandExecutor { @Override @@ -55,34 +58,38 @@ public boolean onCommand(CommandSender sender, Command command, String label, St if (isPlayer(sender)) { Player p = (Player) sender; - GroupEntry g = Groups.getGroup(args[1]); - - if(g == null){ - p.sendMessage(PLUGIN_COMMAND_SETGROUP_GROUP_NOT_FOUND); - return true; - } - - if (!Permission.isAuthorized(p, Groups.getGroup("mod").getId())) { - p.sendMessage(PLUGIN_COMMAND_PERMISSION_MISSING); - return true; - } - - p.sendMessage(String.format(PLUGIN_COMMAND_SETGROUP, g.getPrefix() + g.getName(), target.getName())); - PlayerHelper.updateGroup(target, g); + GroupEntry g = checkGroupExists(args[1], p); + setGroupForTarget(p, Objects.requireNonNull(g), target); return true; } else if (isCMDBlock(sender) || isConsole(sender)) { GroupEntry g = Groups.getGroup(args[1]); - - if(g == null){ - sender.sendMessage(PLUGIN_COMMAND_SETGROUP_GROUP_NOT_FOUND); - return true; - } - - sender.sendMessage(String.format(PLUGIN_COMMAND_SETGROUP, g.getPrefix() + g.getName(), target.getName())); - PlayerHelper.updateGroup(target, g); + setGroupForTarget(sender, Objects.requireNonNull(g), target); return true; } return false; } + + private static GroupEntry checkGroupExists(String groupName, Player p) { + GroupEntry g = Groups.getGroup(groupName); + + if(g == null){ + p.sendMessage(PLUGIN_COMMAND_SETGROUP_GROUP_NOT_FOUND); + return null; + } + + if (!Permission.isAuthorized(p, Objects.requireNonNull(Groups.getGroup("mod")).getId())) { + p.sendMessage(PLUGIN_COMMAND_PERMISSION_MISSING); + return null; + } + return g; + } + + private static void setGroupForTarget(CommandSender s, GroupEntry g, OfflinePlayer target) { + s.sendMessage(String.format(PLUGIN_COMMAND_SETGROUP, g.getPrefix() + g.getName(), target.getName())); + if(target.isOnline() && Bukkit.getPlayer(target.getUniqueId()) != null){ + Objects.requireNonNull(Bukkit.getPlayer(target.getUniqueId())).sendMessage(String.format(PLUGIN_COMMAND_SETGROUP, g.getPrefix() + g.getName(), target.getName())); + } + PlayerHelper.updateGroup(target, g); + } } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelper.java index 32dca72d..9941754e 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelper.java @@ -1,10 +1,9 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers; import static de.relluem94.minecraft.server.spigot.essentials.RelluEssentials.getText; -import static de.relluem94.minecraft.server.spigot.essentials.Strings.PLUGIN_COLOR_COMMAND; -import static de.relluem94.minecraft.server.spigot.essentials.Strings.PLUGIN_FORMS_SPACER_MESSAGE; -import static de.relluem94.minecraft.server.spigot.essentials.Strings.PLUGIN_NAME_PREFIX; +import static de.relluem94.minecraft.server.spigot.essentials.Strings.*; +import java.util.Objects; import java.util.Properties; import java.util.UUID; @@ -45,7 +44,7 @@ private PlayerHelper() { * @param p Player to set Flying */ public static void setFlying(Player p) { - if (Permission.isAuthorized(p, Groups.getGroup("vip").getId())) { + if (Permission.isAuthorized(p, Objects.requireNonNull(Groups.getGroup("vip")).getId())) { PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p.getUniqueId()); if (pe.isFlying()) { p.setAllowFlight(true); @@ -131,16 +130,17 @@ public static void setGroup(Player p, GroupEntry g) { p.setScoreboard(ScoreBoardManager.board); } - public static void updateGroup(Player p, GroupEntry g) { - PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p.getUniqueId()); - pe.setGroup(g); - pe.setUpdatedBy(pe.getID()); - pe.setToBeUpdated(true); - setGroup(p, g); - } - public static void updateGroup(OfflinePlayer p, GroupEntry g) { PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p.getUniqueId()); + + if(p.isOnline()){ + Player player = Bukkit.getPlayer(p.getUniqueId()); + if (player != null) { + player.setCustomName(g.getPrefix() + getCustomName(player)); + player.setPlayerListName(g.getPrefix() + getCustomName(player)); + } + } + pe.setGroup(g); pe.setUpdatedBy(pe.getID()); pe.setToBeUpdated(true); From d3f3ae63be68c82b0771e53aa48fcbb8fb9aad7e Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Wed, 28 Feb 2024 01:59:47 +0100 Subject: [PATCH 16/36] RE-147 Fixed CustomName --- .../server/spigot/essentials/helpers/PlayerHelper.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelper.java index 9941754e..72a8f45a 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelper.java @@ -150,16 +150,11 @@ public static void updateGroup(OfflinePlayer p, GroupEntry g) { public static String getCustomName(Player p) { String name; PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p.getUniqueId()); - if (pe.getCustomName() != null && pe.getCustomName().equals("null")) { + if (pe.getCustomName() != null && !pe.getCustomName().equals("null")) { name = pe.getCustomName(); } else { - if (pe.getName() != null && pe.getName().equals("null")) { - name = pe.getName(); - } - else { - name = p.getName(); - } + name = p.getName(); } return name; From 4b8ae55d1a7862bd8cd27b318e8543d57be31912 Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Wed, 28 Feb 2024 17:47:34 +0100 Subject: [PATCH 17/36] RE-162 Added Lombock --- dependency-reduced-pom.xml | 39 ++-- pom.xml | 19 +- .../spigot/essentials/api/PlayerAPI.java | 6 +- .../spigot/essentials/commands/Bags.java | 2 +- .../spigot/essentials/commands/Fly.java | 4 +- .../spigot/essentials/commands/Home.java | 4 +- .../spigot/essentials/commands/Marry.java | 30 +-- .../spigot/essentials/commands/Nick.java | 4 +- .../essentials/commands/PlayerInfo.java | 2 +- .../spigot/essentials/commands/Protect.java | 4 +- .../spigot/essentials/commands/Purse.java | 4 +- .../spigot/essentials/commands/Rollback.java | 6 +- .../spigot/essentials/commands/Sudo.java | 8 +- .../essentials/commands/TestCommand.java | 4 +- .../spigot/essentials/commands/Warp.java | 2 +- .../spigot/essentials/events/BetterBags.java | 20 +- .../spigot/essentials/events/BetterLock.java | 46 ++--- .../spigot/essentials/events/BetterMobs.java | 19 +- .../spigot/essentials/events/BetterNPC.java | 26 +-- .../essentials/events/BetterPlayerJoin.java | 8 +- .../essentials/events/NoDeathMessage.java | 2 +- .../spigot/essentials/events/PlayerMove.java | 2 +- .../spigot/essentials/helpers/BagHelper.java | 22 +- .../essentials/helpers/BankerHelper.java | 34 ++-- .../essentials/helpers/ConfigHelper.java | 10 +- .../essentials/helpers/DatabaseHelper.java | 128 ++++++------ .../essentials/helpers/PlayerHeadHelper.java | 2 +- .../essentials/helpers/PlayerHelper.java | 22 +- .../essentials/helpers/ProtectionHelper.java | 14 +- .../essentials/helpers/WorldHelper.java | 14 +- .../essentials/helpers/pojo/BagEntry.java | 113 +---------- .../essentials/helpers/pojo/BagTypeEntry.java | 42 +--- .../helpers/pojo/BankAccountEntry.java | 87 +------- .../helpers/pojo/BankTierEntry.java | 47 +---- .../helpers/pojo/BankTransactionEntry.java | 79 +------- .../helpers/pojo/BlockHistoryEntry.java | 80 +------- .../essentials/helpers/pojo/CropEntry.java | 38 +--- .../essentials/helpers/pojo/DropEntry.java | 43 +--- .../essentials/helpers/pojo/GroupEntry.java | 31 +-- .../helpers/pojo/LocationEntry.java | 104 ++-------- .../helpers/pojo/LocationTypeEntry.java | 24 +-- .../essentials/helpers/pojo/NPCEntry.java | 97 +-------- .../helpers/pojo/OfflinePlayerEntry.java | 29 +-- .../essentials/helpers/pojo/PlayerEntry.java | 190 ++---------------- .../helpers/pojo/PlayerPartnerEntry.java | 90 +-------- .../helpers/pojo/PluginInformationEntry.java | 96 +-------- .../helpers/pojo/ProtectionEntry.java | 94 +-------- .../helpers/pojo/ProtectionLockEntry.java | 72 +------ .../essentials/helpers/pojo/SkillsEntry.java | 41 +--- .../essentials/helpers/pojo/WorldEntry.java | 86 +------- .../helpers/pojo/WorldGroupEntry.java | 69 +------ .../pojo/WorldGroupInventoryEntry.java | 113 +---------- .../helpers/pojo/WorldGroupSettingEntry.java | 77 +------ .../essentials/managers/GroupManager.java | 2 +- .../essentials/RelluEssentialsTest.java | 2 +- .../essentials/helpers/PlayerHelperTest.java | 2 +- 56 files changed, 418 insertions(+), 1837 deletions(-) diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index 0a2d05f5..2f26e5f1 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -27,6 +27,13 @@ 17 17 UTF-8 + + + org.projectlombok + lombok + 1.18.30 + + @@ -129,9 +136,9 @@ - com.github.vorburger - MariaDB4j - main-mariaDB4j-2.6.0-g56dd321-50 + ch.vorburger.mariaDB4j + mariaDB4j + 3.0.1 test @@ -143,27 +150,29 @@ org.springframework.boot - mariaDB4j - com.github.vorburger.MariaDB4j - - - mariaDB4j-app - com.github.vorburger.MariaDB4j + mariaDB4j-core + ch.vorburger.mariaDB4j - mariaDB4j-core - com.github.vorburger.MariaDB4j + mariaDB4j-db-linux64 + ch.vorburger.mariaDB4j - mariaDB4j-maven-plugin - com.github.vorburger.MariaDB4j + mariaDB4j-db-win32 + ch.vorburger.mariaDB4j - mariaDB4j-springboot - com.github.vorburger.MariaDB4j + mariaDB4j-db-mac64 + ch.vorburger.mariaDB4j + + org.projectlombok + lombok + 1.18.30 + provided + diff --git a/pom.xml b/pom.xml index 6add0727..553bdc8e 100644 --- a/pom.xml +++ b/pom.xml @@ -82,9 +82,9 @@ - com.github.vorburger - MariaDB4j - main-mariaDB4j-2.6.0-g56dd321-50 + ch.vorburger.mariaDB4j + mariaDB4j + 3.0.1 test @@ -97,6 +97,12 @@ + + org.projectlombok + lombok + 1.18.30 + provided + @@ -114,6 +120,13 @@ 17 17 UTF-8 + + + org.projectlombok + lombok + 1.18.30 + + diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/PlayerAPI.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/PlayerAPI.java index f33b6692..4a9583d1 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/PlayerAPI.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/PlayerAPI.java @@ -41,7 +41,7 @@ public PlayerEntry getPlayerEntry(UUID uuid){ public PlayerEntry getPlayerEntry(int id){ for(PlayerEntry pe : playerEntryMap.values()){ - if(pe.getID() == id){ + if(pe.getId() == id){ return pe; } } @@ -84,7 +84,7 @@ public Multimap getPlayerBagMap() { public PlayerPartnerEntry getPartner(PlayerEntry pe){ if(pe.getPartner() == null){ - return RelluEssentials.getInstance().getDatabaseHelper().getPlayerPartner(pe.getID()); + return RelluEssentials.getInstance().getDatabaseHelper().getPlayerPartner(pe.getId()); } return pe.getPartner(); @@ -95,6 +95,6 @@ public void reloadPlayerHomes() { playerEntryMap.clear(); - pel.forEach(p -> RelluEssentials.getInstance().getPlayerAPI().putPlayerEntry(UUID.fromString(p.getUUID()), p)); + pel.forEach(p -> RelluEssentials.getInstance().getPlayerAPI().putPlayerEntry(UUID.fromString(p.getUuid()), p)); } } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Bags.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Bags.java index b9f20019..276ac561 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Bags.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Bags.java @@ -52,7 +52,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St if(bte != null){ PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); - if(BagHelper.hasBag(pe.getID(), bte.getId())){ + if(BagHelper.hasBag(pe.getId(), bte.getId())){ p.openInventory(BagHelper.getBag(bte.getId(), pe)); return true; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Fly.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Fly.java index 4e1ce4d4..31c3755c 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Fly.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Fly.java @@ -61,8 +61,8 @@ public boolean onCommand(CommandSender sender, Command command, String label, St private void flyMode(Player p) { PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p.getUniqueId()); pe.setFlying(!pe.isFlying()); - pe.setUpdatedBy(pe.getID()); - pe.setToBeUpdated(true); + pe.setUpdatedBy(pe.getId()); + pe.setHasToBeUpdated(true); p.setAllowFlight(pe.isFlying()); p.sendMessage( PLUGIN_FORMS_COMMAND_PREFIX + diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Home.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Home.java index 3dabedd1..28bb4e59 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Home.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Home.java @@ -83,7 +83,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St LocationEntry le = new LocationEntry(); le.setLocationName(args[0]); le.setLocationType(RelluEssentials.getInstance().locationTypeEntryList.get(0)); - le.setPlayerId(pe.getID()); + le.setPlayerId(pe.getId()); if (homeExists(pe, le) || deathExists(pe, le)) { le = getLocationEntry(pe, le); @@ -107,7 +107,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St le.setLocation(p.getLocation()); le.setLocationName(args[1]); le.setLocationType(RelluEssentials.getInstance().locationTypeEntryList.get(0)); - le.setPlayerId(pe.getID()); + le.setPlayerId(pe.getId()); if (args[0].equalsIgnoreCase(PLUGIN_COMMAND_NAME_HOME_SET)) { if (homeExists(pe, le)) { diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Marry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Marry.java index 6c0a974d..a82c7a98 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Marry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Marry.java @@ -78,9 +78,9 @@ public void marry(Player player, Player target){ PlayerEntry secondPlayer = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(player); PlayerPartnerEntry playerPartnerEntry = new PlayerPartnerEntry(); - playerPartnerEntry.setCreatedby(firstPlayer.getID()); - playerPartnerEntry.setFirstPlayerID(firstPlayer.getID()); - playerPartnerEntry.setSecondPlayerID(secondPlayer.getID()); + playerPartnerEntry.setCreatedBy(firstPlayer.getId()); + playerPartnerEntry.setFirstPartnerId(firstPlayer.getId()); + playerPartnerEntry.setSecondPartnerId(secondPlayer.getId()); RelluEssentials.getInstance().getDatabaseHelper().insertPlayerPartner(playerPartnerEntry); playerPartnerEntry = RelluEssentials.getInstance().getPlayerAPI().getPartner(firstPlayer); @@ -92,12 +92,12 @@ public void marry(Player player, Player target){ protectionEntryList.addAll(RelluEssentials.getInstance().getProtectionAPI().getProtectionEntryList().values()); for(ProtectionEntry pre : protectionEntryList){ - if(pre.getCreatedBy() == firstPlayer.getID()){ - BetterLock.addRight(target, pre, secondPlayer.getID(), true); + if(pre.getCreatedBy() == firstPlayer.getId()){ + BetterLock.addRight(target, pre, secondPlayer.getId(), true); } - if(pre.getCreatedBy() == secondPlayer.getID()){ - BetterLock.addRight(player, pre, firstPlayer.getID(), true); + if(pre.getCreatedBy() == secondPlayer.getId()){ + BetterLock.addRight(player, pre, firstPlayer.getId(), true); } } @@ -109,10 +109,10 @@ public void marry(Player player, Player target){ private void divorce(PlayerEntry pe) { PlayerPartnerEntry ppe = pe.getPartner(); - PlayerEntry secondPlayerEntry = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry((ppe.getSecondPlayerID() != pe.getID() ? ppe.getSecondPlayerID() : ppe.getFirstPlayerID())); + PlayerEntry secondPlayerEntry = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry((ppe.getSecondPartnerId() != pe.getId() ? ppe.getSecondPartnerId() : ppe.getFirstPartnerId())); - Player firstPlayer = Bukkit.getPlayer(UUID.fromString(pe.getUUID())); - OfflinePlayer secondOfflinePlayer = Bukkit.getOfflinePlayer(UUID.fromString(secondPlayerEntry.getUUID())); + Player firstPlayer = Bukkit.getPlayer(UUID.fromString(pe.getUuid())); + OfflinePlayer secondOfflinePlayer = Bukkit.getOfflinePlayer(UUID.fromString(secondPlayerEntry.getUuid())); if(firstPlayer != null && secondOfflinePlayer != null){ if(secondOfflinePlayer.isOnline()){ @@ -124,7 +124,7 @@ private void divorce(PlayerEntry pe) { firstPlayer.sendMessage(String.format(PLUGIN_COMMAND_MARRY_DIVORCED, secondOfflinePlayer.getName())); } - ppe.setDeletedBy(pe.getID()); + ppe.setDeletedBy(pe.getId()); pe.setPartner(null); secondPlayerEntry.setPartner(null); @@ -134,12 +134,12 @@ private void divorce(PlayerEntry pe) { protectionEntryList.addAll(RelluEssentials.getInstance().getProtectionAPI().getProtectionEntryList().values()); for(ProtectionEntry pre : protectionEntryList){ - if(pre.getCreatedBy() == pe.getID()){ - BetterLock.removeRight(firstPlayer, pre, secondPlayerEntry.getID(), true); + if(pre.getCreatedBy() == pe.getId()){ + BetterLock.removeRight(firstPlayer, pre, secondPlayerEntry.getId(), true); } - if(pre.getCreatedBy() == secondPlayerEntry.getID()){ - BetterLock.removeRight(secondOfflinePlayer, pre, pe.getID()); + if(pre.getCreatedBy() == secondPlayerEntry.getId()){ + BetterLock.removeRight(secondOfflinePlayer, pre, pe.getId()); } } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Nick.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Nick.java index 95672883..9e3ab006 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Nick.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Nick.java @@ -45,8 +45,8 @@ public boolean onCommand(CommandSender sender, Command command, String label, St PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(target.getUniqueId()); pe.setCustomName(args[1]); - pe.setUpdatedBy(isPlayer(sender) ? RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(((Player)sender).getUniqueId()).getID() : 1); - pe.setToBeUpdated(true); + pe.setUpdatedBy(isPlayer(sender) ? RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(((Player)sender).getUniqueId()).getId() : 1); + pe.setHasToBeUpdated(true); target.setCustomName(pe.getGroup().getPrefix() + args[1]); target.setPlayerListName(pe.getGroup().getPrefix() + args[1]); sender.sendMessage(String.format(PLUGIN_COMMAND_NICK, pe.getGroup().getPrefix() + target.getName())); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PlayerInfo.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PlayerInfo.java index b07eea40..dbd640b2 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PlayerInfo.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PlayerInfo.java @@ -90,7 +90,7 @@ private void showPlayerInfo(CommandSender sender, String targetName){ sender.sendMessage(String.format(PLUGIN_COMMAND_PLAYERINFO_GROUP, pet.getGroup().getPrefix() + pet.getGroup().getName())); if(pet.getPartner() != null){ - sender.sendMessage(String.format(PLUGIN_COMMAND_PLAYERINFO_MARRIED_TO, RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(pet.getPartner().getFirstPlayerID()).getName(), RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(pet.getPartner().getSecondPlayerID()))); + sender.sendMessage(String.format(PLUGIN_COMMAND_PLAYERINFO_MARRIED_TO, RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(pet.getPartner().getFirstPartnerId()).getName(), RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(pet.getPartner().getSecondPartnerId()))); sender.sendMessage(String.format(PLUGIN_COMMAND_PLAYERINFO_MARRIED_SINCE, pet.getPartner().getCreated())); } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Protect.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Protect.java index 17941531..53b20ec5 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Protect.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Protect.java @@ -125,7 +125,7 @@ else if(args[0].equalsIgnoreCase(PLUGIN_COMMAND_NAME_PROTECT_RIGHT)){ if(player != null){ p.sendMessage(PLUGIN_COMMAND_PROTECT_RIGHT_ADD); pe.setPlayerState(PlayerState.PROTECTION_RIGHT_ADD); - pe.setPlayerStateParameter(player.getID().toString()); + pe.setPlayerStateParameter(player.getId().toString()); } else{ p.sendMessage(String.format(PLUGIN_COMMAND_PROTECT_RIGHT_PLAYER_NOTFOUND, args[2])); @@ -137,7 +137,7 @@ else if(args[1].equalsIgnoreCase(PLUGIN_COMMAND_NAME_PROTECT_RIGHT_REMOVE)){ if(player != null){ p.sendMessage(PLUGIN_COMMAND_PROTECT_RIGHT_REMOVE); pe.setPlayerState(PlayerState.PROTECTION_RIGHT_REMOVE); - pe.setPlayerStateParameter(player.getID().toString()); + pe.setPlayerStateParameter(player.getId().toString()); } else{ p.sendMessage(String.format(PLUGIN_COMMAND_PROTECT_RIGHT_PLAYER_NOTFOUND, args[2])); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Purse.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Purse.java index 0848c6ed..a41db5e5 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Purse.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Purse.java @@ -95,8 +95,8 @@ public boolean onCommand(CommandSender sender, Command command, String label, St coin.setItemMeta(im); pe.setPurse(pe.getPurse() - coins); - pe.setToBeUpdated(true); - pe.setUpdatedBy(pe.getID()); + pe.setHasToBeUpdated(true); + pe.setUpdatedBy(pe.getId()); p.getInventory().addItem(coin); p.sendMessage(String.format(PLUGIN_COMMAND_PURSE_TO_ITEM, StringHelper.formatInt(coins))); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rollback.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rollback.java index 1e47d0f4..aa231775 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rollback.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rollback.java @@ -59,7 +59,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St UUID targetUUID = Bukkit.getPlayer(args[1]).getUniqueId(); PlayerEntry pe = RelluEssentials.getInstance().getDatabaseHelper().getPlayer(targetUUID.toString()); if (pe != null && args[0].equalsIgnoreCase(PLUGIN_COMMAND_NAME_ROLLBACK_PLAYER)) { - int id = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p.getUniqueId()).getID(); + int id = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p.getUniqueId()).getId(); List list = RelluEssentials.getInstance().getDatabaseHelper().getBlockHistoryByPlayer(pe); for (BlockHistoryEntry bh : list) { bh.setDeletedby(id); @@ -83,7 +83,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St PlayerEntry pe = RelluEssentials.getInstance().getDatabaseHelper().getPlayer(targetUUID.toString()); if (pe != null) { - int id = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p.getUniqueId()).getID(); + int id = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p.getUniqueId()).getId(); List list = RelluEssentials.getInstance().getDatabaseHelper().getBlockHistoryByPlayerAndTime(pe, args[2], false); for (BlockHistoryEntry bh : list) { bh.setDeletedby(id); @@ -111,7 +111,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St PlayerEntry pe = RelluEssentials.getInstance().getDatabaseHelper().getPlayer(targetUUID.toString()); if (pe != null) { - int id = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p.getUniqueId()).getID(); + int id = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p.getUniqueId()).getId(); List list = RelluEssentials.getInstance().getDatabaseHelper().getBlockHistoryByPlayerAndTime(pe, args[3], true); for (BlockHistoryEntry bh : list) { bh.setDeletedby(id); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Sudo.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Sudo.java index 034cd504..84e8aa60 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Sudo.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Sudo.java @@ -44,11 +44,11 @@ public boolean onCommand(CommandSender sender, Command command, String label, St else if (Permission.isAuthorized(p, Groups.getGroup("admin").getId())) { OfflinePlayerEntry target = PlayerHelper.getOfflinePlayerByName((args[0])); PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); - if (target != null && RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(target.getID()) != null) { - PlayerEntry tpe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(target.getID()); + if (target != null && RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(target.getId()) != null) { + PlayerEntry tpe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(target.getId()); SudoManager.sudoers.put(p.getUniqueId(), new PlayerEntry(pe)); WorldHelper.saveWorldGroupInventory(p, true); - pe.setID(tpe.getID()); + pe.setId(tpe.getId()); pe.setCustomName(tpe.getCustomName()); pe.setGroup(tpe.getGroup()); pe.setHomes(tpe.getHomes()); @@ -89,7 +89,7 @@ public static void exitSudo(Player p){ PlayerEntry tpe = SudoManager.sudoers.get(p.getUniqueId()); PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); WorldHelper.saveWorldGroupInventory(p, true); - pe.setID(tpe.getID()); + pe.setId(tpe.getId()); pe.setCustomName(tpe.getCustomName()); pe.setGroup(tpe.getGroup()); pe.setHomes(tpe.getHomes()); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/TestCommand.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/TestCommand.java index 199af52d..80b489de 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/TestCommand.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/TestCommand.java @@ -98,13 +98,13 @@ public boolean onCommand(CommandSender sender, Command command, String label, St worlds(p); } else if (args[0].equalsIgnoreCase("bc")) { PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); - RelluEssentials.getInstance().getDatabaseHelper().insertBag(1, pe.getID()); + RelluEssentials.getInstance().getDatabaseHelper().insertBag(1, pe.getId()); } else if (args[0].equalsIgnoreCase("bo")) { PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); p.openInventory(BagHelper.getBag(1, pe)); } else if (args[0].equalsIgnoreCase("bc2")) { PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); - RelluEssentials.getInstance().getDatabaseHelper().insertBag(2, pe.getID()); + RelluEssentials.getInstance().getDatabaseHelper().insertBag(2, pe.getId()); } else if (args[0].equalsIgnoreCase("bo2")) { PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); p.openInventory(BagHelper.getBag(2, pe)); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Warp.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Warp.java index a0eef9f0..2ec1c5a9 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Warp.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Warp.java @@ -84,7 +84,7 @@ private boolean addWarp(String name, Player p){ le.setLocation(p.getLocation()); le.setLocationName(name); le.setLocationType(RelluEssentials.getInstance().locationTypeEntryList.get(typeId - 1)); - le.setPlayerId(RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p).getID()); + le.setPlayerId(RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p).getId()); RelluEssentials.getInstance().getDatabaseHelper().insertLocation(le); if(RelluEssentials.getInstance().getDatabaseHelper().getLocation(p.getLocation(), typeId) != null){ le = RelluEssentials.getInstance().getDatabaseHelper().getLocation(p.getLocation(), typeId); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterBags.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterBags.java index 58d12700..c5d15e33 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterBags.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterBags.java @@ -177,7 +177,7 @@ public void onBlockDrop(BlockDropItemEvent e) { } } - if(BagHelper.hasBags(pe.getID())){ + if(BagHelper.hasBags(pe.getId())){ List lis = BagHelper.collectItems(e.getItems(), e.getPlayer(), pe); e.getItems().removeAll(lis); } @@ -215,7 +215,7 @@ public void onInventoryClickItem(InventoryClickEvent e) { return; } - BagEntry be = BagHelper.getBag(pe.getID(), bte.getId()); + BagEntry be = BagHelper.getBag(pe.getId(), bte.getId()); if(be == null){ return; @@ -235,14 +235,14 @@ public void onInventoryClickItem(InventoryClickEvent e) { if(fis != null && ItemHelper.getCleanItemStack(fis).equals(ItemHelper.getCleanItemStack(is))){ value = be.getSlotValue(slot); be.setSlotValue(slot, value + fis.getAmount()); - be.setToBeUpdated(true); + be.setHasToBeUpdated(true); p.getInventory().remove(fis); } } } else{ be.setSlotValue(slot, value + is.getAmount()); - be.setToBeUpdated(true); + be.setHasToBeUpdated(true); Objects.requireNonNull(p.getInventory().getItem(e.getSlot())).setAmount(0); } p.updateInventory(); @@ -260,7 +260,7 @@ public void onInventoryClickItem(InventoryClickEvent e) { value -= is.getMaxStackSize(); cleanIS.setAmount(is.getMaxStackSize()); be.setSlotValue(slot, value); - be.setToBeUpdated(true); + be.setHasToBeUpdated(true); p.getInventory().addItem(cleanIS); p.updateInventory(); if(p.getInventory().firstEmpty() == -1){ @@ -270,7 +270,7 @@ public void onInventoryClickItem(InventoryClickEvent e) { else{ cleanIS.setAmount(value); be.setSlotValue(slot, 0); - be.setToBeUpdated(true); + be.setHasToBeUpdated(true); p.getInventory().addItem(cleanIS); p.updateInventory(); break; @@ -287,7 +287,7 @@ public void onInventoryClickItem(InventoryClickEvent e) { cleanIS.setAmount(value); be.setSlotValue(slot, 0); } - be.setToBeUpdated(true); + be.setHasToBeUpdated(true); p.getInventory().addItem(cleanIS); p.updateInventory(); } @@ -329,15 +329,15 @@ public void onItemCollect(EntityPickupItemEvent e) { p.playSound(p, Sound.ITEM_ARMOR_EQUIP_GOLD, SoundCategory.PLAYERS, 1F, 1); - pe.setUpdatedBy(pe.getID()); - pe.setToBeUpdated(false); + pe.setUpdatedBy(pe.getId()); + pe.setHasToBeUpdated(false); e.getItem().getItemStack().setAmount(0); e.setCancelled(true); } } - if(BagHelper.hasBags(pe.getID()) && BagHelper.collectItem(e.getItem(), p, pe)){ + if(BagHelper.hasBags(pe.getId()) && BagHelper.collectItem(e.getItem(), p, pe)){ p.getInventory().remove(is); p.updateInventory(); e.setCancelled(true); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java index e10159b9..5b699dd2 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java @@ -144,7 +144,7 @@ private boolean removeProtectionFromBlock(Player p , Block b){ Location l = ProtectionHelper.getLocationFromBlockAlternateForDoor(b); ProtectionEntry bpe = RelluEssentials.getInstance().getProtectionAPI().getProtectionEntry(l); if (bpe != null) { - if(bpe.getLocation().getPlayerId() != pe.getID()){ + if(bpe.getLocationEntry().getPlayerId() != pe.getId()){ p.sendMessage(PLUGIN_EVENT_PROTECTED_BLOCK_DISALLOW); return true; } @@ -159,7 +159,7 @@ private boolean removeProtectionFromBlock(Player p , Block b){ else if(isAttachedToBlock(b, BlockFace.EAST)){ Location l = b.getRelative(BlockFace.EAST).getLocation(); ProtectionEntry bpe = RelluEssentials.getInstance().getProtectionAPI().getProtectionEntry(l); - if(bpe != null && bpe.getLocation() != null && bpe.getLocation().getPlayerId() == pe.getID()){ + if(bpe != null && bpe.getLocationEntry() != null && bpe.getLocationEntry().getPlayerId() == pe.getId()){ RelluEssentials.getInstance().getDatabaseHelper().deleteProtection(bpe); RelluEssentials.getInstance().getProtectionAPI().removeProtectionEntry(b.getLocation()); p.sendMessage(PLUGIN_EVENT_PROTECT_BLOCK_REMOVE); @@ -174,7 +174,7 @@ else if(isAttachedToBlock(b, BlockFace.EAST)){ else if(isAttachedToBlock(b, BlockFace.SOUTH)){ Location l = b.getRelative(BlockFace.SOUTH).getLocation(); ProtectionEntry bpe = RelluEssentials.getInstance().getProtectionAPI().getProtectionEntry(l); - if(bpe != null && bpe.getLocation() != null && bpe.getLocation().getPlayerId() == pe.getID()){ + if(bpe != null && bpe.getLocationEntry() != null && bpe.getLocationEntry().getPlayerId() == pe.getId()){ RelluEssentials.getInstance().getDatabaseHelper().deleteProtection(bpe); RelluEssentials.getInstance().getProtectionAPI().removeProtectionEntry(b.getLocation()); p.sendMessage(PLUGIN_EVENT_PROTECT_BLOCK_REMOVE); @@ -188,7 +188,7 @@ else if(isAttachedToBlock(b, BlockFace.SOUTH)){ else if(isAttachedToBlock(b, BlockFace.NORTH)){ Location l = b.getRelative(BlockFace.NORTH).getLocation(); ProtectionEntry bpe = RelluEssentials.getInstance().getProtectionAPI().getProtectionEntry(l); - if(bpe != null && bpe.getLocation() != null && bpe.getLocation().getPlayerId() == pe.getID()){ + if(bpe != null && bpe.getLocationEntry() != null && bpe.getLocationEntry().getPlayerId() == pe.getId()){ RelluEssentials.getInstance().getDatabaseHelper().deleteProtection(bpe); RelluEssentials.getInstance().getProtectionAPI().removeProtectionEntry(b.getLocation()); p.sendMessage(PLUGIN_EVENT_PROTECT_BLOCK_REMOVE); @@ -202,7 +202,7 @@ else if(isAttachedToBlock(b, BlockFace.NORTH)){ else if(isAttachedToBlock(b, BlockFace.WEST)){ Location l = b.getRelative(BlockFace.WEST).getLocation(); ProtectionEntry bpe = RelluEssentials.getInstance().getProtectionAPI().getProtectionEntry(l); - if(bpe != null && bpe.getLocation() != null && bpe.getLocation().getPlayerId() == pe.getID()){ + if(bpe != null && bpe.getLocationEntry() != null && bpe.getLocationEntry().getPlayerId() == pe.getId()){ RelluEssentials.getInstance().getDatabaseHelper().deleteProtection(bpe); RelluEssentials.getInstance().getProtectionAPI().removeProtectionEntry(b.getLocation()); p.sendMessage(PLUGIN_EVENT_PROTECT_BLOCK_REMOVE); @@ -216,7 +216,7 @@ else if(isAttachedToBlock(b, BlockFace.WEST)){ else if(isAttachedToBlock(b, BlockFace.UP)){ Location l = b.getRelative(BlockFace.UP).getLocation(); ProtectionEntry bpe = RelluEssentials.getInstance().getProtectionAPI().getProtectionEntry(l); - if(bpe != null && bpe.getLocation() != null && bpe.getLocation().getPlayerId() == pe.getID()){ + if(bpe != null && bpe.getLocationEntry() != null && bpe.getLocationEntry().getPlayerId() == pe.getId()){ RelluEssentials.getInstance().getDatabaseHelper().deleteProtection(bpe); RelluEssentials.getInstance().getProtectionAPI().removeProtectionEntry(b.getLocation()); p.sendMessage(PLUGIN_EVENT_PROTECT_BLOCK_REMOVE); @@ -293,7 +293,7 @@ else if(b3.getBlockData() instanceof Chest){ LocationTypeEntry lt = new LocationTypeEntry(); lt.setId(5); l.setLocationType(lt); - l.setPlayerId(pe.getID()); + l.setPlayerId(pe.getId()); p.sendMessage(PLUGIN_EVENT_PROTECT_BLOCK_ADD); @@ -301,18 +301,18 @@ else if(b3.getBlockData() instanceof Chest){ LocationEntry le = RelluEssentials.getInstance().getDatabaseHelper().getLocation(b.getLocation(), 5); - bpe.setCreatedby(pe.getID()); + bpe.setCreatedBy(pe.getId()); bpe.setMaterialName(b.getType().name()); bpe.setLocationEntry(le); int playerPartnerFK = -1; if(pe.getPartner() != null){ - if(pe.getID() != pe.getPartner().getFirstPlayerID()){ - playerPartnerFK = pe.getPartner().getFirstPlayerID(); + if(pe.getId() != pe.getPartner().getFirstPartnerId()){ + playerPartnerFK = pe.getPartner().getFirstPartnerId(); } else{ - playerPartnerFK = pe.getPartner().getSecondPlayerID(); + playerPartnerFK = pe.getPartner().getSecondPartnerId(); } } @@ -325,7 +325,7 @@ else if(b3.getBlockData() instanceof Chest){ JSONObject rights = new JSONObject(); int[] right = new int[rightLength]; - right[0] = pe.getID(); + right[0] = pe.getId(); if(playerPartnerFK != -1){ right[1] = playerPartnerFK; @@ -419,7 +419,7 @@ else if(pe.getPlayerState().equals(PlayerState.PROTECTION_INFO)){ ProtectionEntry pre = RelluEssentials.getInstance().getProtectionAPI().getProtectionEntry(l); if(pre != null){ Player p = e.getPlayer(); - Location loc = pre.getLocation().getLocation(); + Location loc = pre.getLocationEntry().getLocation(); p.sendMessage(""); p.sendMessage(PLUGIN_EVENT_PROTECTED_BLOCK_INFO); @@ -428,18 +428,18 @@ else if(pe.getPlayerState().equals(PlayerState.PROTECTION_INFO)){ p.sendMessage(String.format(PLUGIN_EVENT_PROTECTED_BLOCK_INFO_CREATED, pre.getCreated())); p.sendMessage(String.format(PLUGIN_EVENT_PROTECTED_BLOCK_INFO_UPDATED, pre.getUpdated())); p.sendMessage(String.format(PLUGIN_EVENT_PROTECTED_BLOCK_INFO_LOCATION, loc.getX(), loc.getY(), loc.getZ(), loc.getWorld().getName())); - p.sendMessage(String.format(PLUGIN_EVENT_PROTECTED_BLOCK_INFO_PLAYER_ID, pre.getLocation().getPlayerId())); + p.sendMessage(String.format(PLUGIN_EVENT_PROTECTED_BLOCK_INFO_PLAYER_ID, pre.getLocationEntry().getPlayerId())); for(Map.Entry entry : RelluEssentials.getInstance().getPlayerAPI().getPlayerEntryMap().entrySet()) { - if(entry.getValue().getID() == pre.getLocation().getPlayerId()){ - OfflinePlayer op = Bukkit.getOfflinePlayer(UUID.fromString(entry.getValue().getUUID())); + if(entry.getValue().getId() == pre.getLocationEntry().getPlayerId()){ + OfflinePlayer op = Bukkit.getOfflinePlayer(UUID.fromString(entry.getValue().getUuid())); Calendar cal = Calendar.getInstance(); SimpleDateFormat df = new SimpleDateFormat(PLUGIN_EVENT_PROTECTED_BLOCK_INFO_PLAYER_LAST_LOGIN_DATE_FORMAT); cal.setTimeInMillis(op.getLastPlayed()); - p.sendMessage(String.format(PLUGIN_EVENT_PROTECTED_BLOCK_INFO_PLAYER_UUID, entry.getValue().getUUID())); + p.sendMessage(String.format(PLUGIN_EVENT_PROTECTED_BLOCK_INFO_PLAYER_UUID, entry.getValue().getUuid())); p.sendMessage(String.format(PLUGIN_EVENT_PROTECTED_BLOCK_INFO_PLAYER_NAME, op.getName())); p.sendMessage(String.format(PLUGIN_EVENT_PROTECTED_BLOCK_INFO_PLAYER_LAST_LOGIN, df.format(cal.getTime()))); } @@ -565,7 +565,7 @@ else if(pe.getPlayerState().equals(PlayerState.PROTECTION_RIGHT_ADD)){ e.getPlayer().sendMessage(PLUGIN_EVENT_PROTECTED_BLOCK_ALLOW); UUID uuid = UUID.fromString((String)pe.getPlayerStateParameter()); - int id = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(uuid).getID(); + int id = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(uuid).getId(); addRight(e.getPlayer(), pre, id, false); @@ -587,7 +587,7 @@ else if(pe.getPlayerState().equals(PlayerState.PROTECTION_RIGHT_REMOVE)){ e.getPlayer().sendMessage(PLUGIN_EVENT_PROTECTED_BLOCK_ALLOW); UUID uuid = UUID.fromString((String)pe.getPlayerStateParameter()); - int id = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(uuid).getID(); + int id = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(uuid).getId(); removeRight(e.getPlayer(), pre, id, false); @@ -604,7 +604,7 @@ else if(pe.getPlayerState().equals(PlayerState.PROTECTION_RIGHT_REMOVE)){ } public static void addRight(Player p, ProtectionEntry pre, int id, boolean silent) { - Location l = pre.getLocation().getLocation(); + Location l = pre.getLocationEntry().getLocation(); if(pre.getRights().has(PLUGIN_EVENT_PROTECT_RIGHTS)){ JSONArray rightJSON = pre.getRights().getJSONArray(PLUGIN_EVENT_PROTECT_RIGHTS); @@ -634,7 +634,7 @@ public static void addRight(Player p, ProtectionEntry pre, int id, boolean silen } public static void removeRight(Player p, ProtectionEntry pre, int id, boolean silent) { - Location l = pre.getLocation().getLocation(); + Location l = pre.getLocationEntry().getLocation(); if(pre.getRights().has(PLUGIN_EVENT_PROTECT_RIGHTS)){ JSONArray rightJSON = pre.getRights().getJSONArray(PLUGIN_EVENT_PROTECT_RIGHTS); @@ -687,7 +687,7 @@ public void onInteract(PlayerInteractEvent e) { pe.getPlayerState().equals(PlayerState.PROTECTION_RIGHT_REMOVE) ) ) { - if (!ProtectionHelper.hasRights(protection, pe.getID())) { + if (!ProtectionHelper.hasRights(protection, pe.getId())) { if(ProtectionHelper.hasFlag(protection, ProtectionFlags.ALLOWPUBLIC)){ e.getPlayer().sendMessage(PLUGIN_EVENT_PROTECTED_BLOCK_ALLOW); } @@ -780,7 +780,7 @@ else if(ProtectionHelper.isLockable(b)){ ProtectionEntry protection = RelluEssentials.getInstance().getProtectionAPI().getProtectionEntry(l); PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(e.getPlayer()); if (protection != null && pe != null && pe.getPlayerState().equals(PlayerState.DEFAULT)) { - if (!ProtectionHelper.hasRights(protection, pe.getID())) { + if (!ProtectionHelper.hasRights(protection, pe.getId())) { if(ProtectionHelper.hasFlag(protection, ProtectionFlags.ALLOWPUBLIC)){ e.getPlayer().sendMessage(PLUGIN_EVENT_PROTECTED_BLOCK_ALLOW); } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterMobs.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterMobs.java index dab3dcbc..77e09578 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterMobs.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterMobs.java @@ -51,32 +51,31 @@ public void onKill(PlayerDeathEvent e) { pe.setPurse(0); } - pe.setUpdatedBy(pe.getID()); - pe.setToBeUpdated(true); + pe.setUpdatedBy(pe.getId()); + pe.setHasToBeUpdated(true); } } @EventHandler public void onDeath(EntityDeathEvent e) { - if(e.getEntity().getKiller() instanceof Player){ + if(e.getEntity().getKiller() != null){ int coinsPerDeath = EntityCoins.valueOf(e.getEntity().getType().name()).getCoins(); if(coinsPerDeath > 0){ Player p = e.getEntity().getKiller(); PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); pe.setPurse(pe.getPurse() + coinsPerDeath); - pe.setUpdatedBy(pe.getID()); - pe.setToBeUpdated(true); + pe.setUpdatedBy(pe.getId()); + pe.setHasToBeUpdated(true); ChatHelper.sendMessageInActionBar(p, String.format(Strings.PLUGIN_COMMAND_PURSE_GAIN, coinsPerDeath, StringHelper.formatDouble(pe.getPurse()))); - if(BagHelper.hasBags(pe.getID())){ - List li = new ArrayList<>(); - li.addAll(e.getDrops()); + if(BagHelper.hasBags(pe.getId())){ + List li = new ArrayList<>(e.getDrops()); e.getDrops().removeAll(BagHelper.collectItemStacks(li, p, pe)); } - if(p.getInventory().getItemInMainHand() != null && p.getInventory().getItemInMainHand().hasItemMeta() && p.getInventory().getItemInMainHand().getItemMeta().hasEnchant(CustomEnchants.telekinesis)){ + if(p.getInventory().getItemInMainHand().hasItemMeta() && p.getInventory().getItemInMainHand().getItemMeta().hasEnchant(CustomEnchants.telekinesis)){ List lis = new ArrayList<>(); for(ItemStack is: e.getDrops()){ if(p.getInventory().firstEmpty() != -1){ @@ -99,7 +98,7 @@ public void onHit(EntityDamageByEntityEvent e) { if(pe.getPlayerState().equals(PlayerState.DAMAGE_INFO)){ p.sendMessage(String.format(EventConstants.PLUGIN_EVENT_DAMAGE_SHOW, e.getDamage(), m.getLastDamage(), m.getHealth())); } - if(p.getInventory().getItemInMainHand() != null && p.getInventory().getItemInMainHand().hasItemMeta() && p.getInventory().getItemInMainHand().getItemMeta().hasEnchant(CustomEnchants.thunderstrike)){ + if(p.getInventory().getItemInMainHand().hasItemMeta() && p.getInventory().getItemInMainHand().getItemMeta().hasEnchant(CustomEnchants.thunderstrike)){ m.getLocation().getWorld().strikeLightningEffect(m.getLocation()); } } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterNPC.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterNPC.java index d7df2641..2beec917 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterNPC.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterNPC.java @@ -82,7 +82,7 @@ public void onPlayerInteractEntity (PlayerInteractEntityEvent e) { if(RelluEssentials.getInstance().getNpcAPI().getNPCNameList().get(i).equals(customName)){ if(customName.equals(RelluEssentials.getBanker().getName())){ PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); - BankAccountEntry bae = RelluEssentials.getInstance().getDatabaseHelper().getPlayerBankAccount(pe.getID()); + BankAccountEntry bae = RelluEssentials.getInstance().getDatabaseHelper().getPlayerBankAccount(pe.getId()); if(bae != null){ InventoryHelper.openInventory(p, RelluEssentials.getBanker().getMainGUI()); } @@ -90,13 +90,13 @@ public void onPlayerInteractEntity (PlayerInteractEntityEvent e) { BankTierEntry bte = RelluEssentials.getInstance().getDatabaseHelper().getBankTier(1); if(pe.getPurse() > bte.getCost()){ pe.setPurse(pe.getPurse() - bte.getCost()); - pe.setUpdatedBy(pe.getID()); - pe.setToBeUpdated(true); + pe.setUpdatedBy(pe.getId()); + pe.setHasToBeUpdated(true); bae = new BankAccountEntry(); bae.setValue(0); bae.setTier(bte); - bae.setPlayerId(pe.getID()); + bae.setPlayerId(pe.getId()); RelluEssentials.getInstance().getDatabaseHelper().insertBankAccount(bae); p.sendMessage(EventConstants.PLUGIN_EVENT_NPC_BANKER_OPEN_ACCOUNT); @@ -141,10 +141,10 @@ else if(is.getType().equals(Material.PLAYER_HEAD) && is.getItemMeta() instanceof if(!BagHelper.hasBag(bt.getId(), pe)){ if(purse >= price){ pe.setPurse(purse - price); - pe.setUpdatedBy(pe.getID()); - pe.setToBeUpdated(true); - RelluEssentials.getInstance().getDatabaseHelper().insertBag(bt.getId(), pe.getID()); - RelluEssentials.getInstance().getPlayerAPI().putPlayerBagEntry(pe.getID(), RelluEssentials.getInstance().getDatabaseHelper().getBag(bt.getId(), pe.getID())); + pe.setUpdatedBy(pe.getId()); + pe.setHasToBeUpdated(true); + RelluEssentials.getInstance().getDatabaseHelper().insertBag(bt.getId(), pe.getId()); + RelluEssentials.getInstance().getPlayerAPI().putPlayerBagEntry(pe.getId(), RelluEssentials.getInstance().getDatabaseHelper().getBag(bt.getId(), pe.getId())); p.sendMessage(String.format(EventConstants.PLUGIN_EVENT_NPC_BAGS_BOUGHT, bt.getDisplayName())); } @@ -183,8 +183,8 @@ else if(is.getType().equals(Material.PLAYER_HEAD) && is.getItemMeta() instanceof p.updateInventory(); pe.setPurse(pe.getPurse() - coins); - pe.setUpdatedBy(pe.getID()); - pe.setToBeUpdated(true); + pe.setUpdatedBy(pe.getId()); + pe.setHasToBeUpdated(true); p.sendMessage(String.format(EventConstants.PLUGIN_EVENT_NPC_BUY, itemDisplayname, StringHelper.formatDouble(coins), StringHelper.formatDouble(pe.getPurse()))); p.playSound(p, Sound.ENTITY_WANDERING_TRADER_YES, SoundCategory.MASTER, 1f, 1f); @@ -229,8 +229,8 @@ else if(inv.getType().equals(InventoryType.PLAYER)){ p.updateInventory(); pe.setPurse(pe.getPurse() + coins); - pe.setUpdatedBy(pe.getID()); - pe.setToBeUpdated(true); + pe.setUpdatedBy(pe.getId()); + pe.setHasToBeUpdated(true); p.sendMessage(String.format(EventConstants.PLUGIN_EVENT_NPC_SELL, itemDisplayname, StringHelper.formatDouble(coins), StringHelper.formatDouble(pe.getPurse()))); p.playSound(p, Sound.ENTITY_WANDERING_TRADER_NO, SoundCategory.MASTER, 1f, 1f); @@ -267,7 +267,7 @@ public void onInventoryClickItem(InventoryClickEvent e) { Player p = (Player) e.getWhoClicked(); PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); if (e.getView().getTitle().equals(RelluEssentials.getBanker().getTitle())) { - BankAccountEntry bae = RelluEssentials.getInstance().getDatabaseHelper().getPlayerBankAccount(pe.getID()); + BankAccountEntry bae = RelluEssentials.getInstance().getDatabaseHelper().getPlayerBankAccount(pe.getId()); if(e.getCurrentItem().equals(BankerHelper.npc_gui_deposit.getCustomItem())){ InventoryHelper.closeInventory(p); InventoryHelper.openInventory(p, RelluEssentials.getBanker().getDepositGUI()); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterPlayerJoin.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterPlayerJoin.java index fc9ce500..846cdef4 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterPlayerJoin.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterPlayerJoin.java @@ -26,11 +26,11 @@ private void addPlayer(Player p) { PlayerEntry pe = RelluEssentials.getInstance().getDatabaseHelper().getPlayer(p.getUniqueId().toString()); if (pe == null) { pe = new PlayerEntry(); - pe.setCreatedby(1); + pe.setCreatedBy(1); pe.setName(p.getName()); pe.setCustomName(p.getDisplayName()); pe.setGroup(Groups.getGroup("user")); - pe.setUUID(p.getUniqueId().toString()); + pe.setUuid(p.getUniqueId().toString()); RelluEssentials.getInstance().getDatabaseHelper().insertPlayer(pe); pe = RelluEssentials.getInstance().getDatabaseHelper().getPlayer(p.getUniqueId().toString()); @@ -57,8 +57,8 @@ public void onJoin(PlayerJoinEvent e) { addPlayer(p); PluginInformationEntry pie = RelluEssentials.getInstance().getPluginInformation(); - p.setPlayerListHeader(pie.getTabheader()); - p.setPlayerListFooter(pie.getTabfooter()); + p.setPlayerListHeader(pie.getTabHeader()); + p.setPlayerListFooter(pie.getTabFooter()); PlayerHelper.setFlying(p); PlayerHelper.setAFK(p, true); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/NoDeathMessage.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/NoDeathMessage.java index 27ce5005..4204d2b7 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/NoDeathMessage.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/NoDeathMessage.java @@ -45,7 +45,7 @@ public void onDeath(PlayerDeathEvent e) { le.setLocationName(String.format(PLUGIN_EVENT_NO_DEATH_MESSAGE, random.nextInt(994))); LocationTypeEntry locationType = RelluEssentials.getInstance().locationTypeEntryList.get(1); le.setLocationType(locationType); - le.setPlayerId(pe.getID()); + le.setPlayerId(pe.getId()); p.sendMessage(String.format(PLUGIN_EVENT_DEATH, le.getLocationName(), (int) le.getLocation().getX(), (int) le.getLocation().getY(), (int) le.getLocation().getZ(), le.getLocation().getWorld().getName())); Bukkit.getConsoleSender().getServer().dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + p.getName() + " [\"\",{\"text\":\"" + PLUGIN_EVENT_DEATH_TP + "\",\"color\":\"aqua\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/home " + le.getLocationName() + "\"}}]"); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/PlayerMove.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/PlayerMove.java index 19b3eecd..bd7eb07c 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/PlayerMove.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/PlayerMove.java @@ -43,7 +43,7 @@ public void onMove(PlayerMoveEvent e) { } if(RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p.getUniqueId()) != null){ - e.setCancelled(RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p.getUniqueId()).isAFK()); + e.setCancelled(RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p.getUniqueId()).isAfk()); } } } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/BagHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/BagHelper.java index 4c2cc6e0..df57cf3f 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/BagHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/BagHelper.java @@ -52,7 +52,7 @@ private BagHelper() { public static final int BAG_SIZE = 28; public static Inventory getBag(int type, PlayerEntry pe) { - BagEntry be = getBag(pe.getID(), type); + BagEntry be = getBag(pe.getId(), type); if(be == null){ return null; @@ -121,7 +121,7 @@ public static Inventory getBags(PlayerEntry pe){ while(bteli.hasNext()){ slot = InventoryHelper.getNextSlot(slot); BagTypeEntry bte = bteli.next(); - if(hasBag(pe.getID(), bte.getId())){ + if(hasBag(pe.getId(), bte.getId())){ inv.setItem(slot, BagHelper.getItem(bte, false).getCustomItem()); slot++; } @@ -213,7 +213,7 @@ public static int getSlotByItemStack(BagEntry be, ItemStack is){ } public static boolean hasBag(int type, PlayerEntry pe){ - return RelluEssentials.getInstance().getDatabaseHelper().getBag(type, pe.getID()) != null; + return RelluEssentials.getInstance().getDatabaseHelper().getBag(type, pe.getId()) != null; } public static boolean hasBag(int playerFK, int bagType){ @@ -283,12 +283,12 @@ public static List collectItems(List li, Player p, PlayerEntry pe){ ItemStack checkWithoutAmount = i.getItemStack().clone(); checkWithoutAmount.setAmount(1); if(RelluEssentials.getInstance().bagBlocks2collect.contains(checkWithoutAmount)){ - Collection bel = BagHelper.getBags(pe.getID()); + Collection bel = BagHelper.getBags(pe.getId()); for(BagEntry be: bel){ int slot = BagHelper.getSlotByItemStack(be, checkWithoutAmount); if(slot != -1){ be.setSlotValue(slot, be.getSlotValue(slot) + i.getItemStack().getAmount()); - be.setToBeUpdated(true); + be.setHasToBeUpdated(true); ChatHelper.sendMessageInActionBar(p, String.format(EventConstants.PLUGIN_EVENT_BAG_COLLECT, i.getItemStack().getAmount(), i.getName())); p.playSound(p, Sound.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.5F, 1); lio.add(i); @@ -307,12 +307,12 @@ public static List collectItemStacks(List li, Player p, Pl ItemStack checkWithoutAmount = i.clone(); checkWithoutAmount.setAmount(1); if(RelluEssentials.getInstance().bagBlocks2collect.contains(checkWithoutAmount)){ - Collection bel = BagHelper.getBags(pe.getID()); + Collection bel = BagHelper.getBags(pe.getId()); for(BagEntry be: bel){ int slot = BagHelper.getSlotByItemStack(be, checkWithoutAmount); if(slot != -1){ be.setSlotValue(slot, be.getSlotValue(slot) + i.getAmount()); - be.setToBeUpdated(true); + be.setHasToBeUpdated(true); ChatHelper.sendMessageInActionBar(p, String.format(EventConstants.PLUGIN_EVENT_BAG_COLLECT, i.getAmount(), i.getType().name().replace("_", " ").toLowerCase())); p.playSound(p, Sound.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.5F, 1); lio.add(i); @@ -330,12 +330,12 @@ public static boolean collectItem(Item item, Player p, PlayerEntry pe) { return false; } - Collection bel = BagHelper.getBags(pe.getID()); + Collection bel = BagHelper.getBags(pe.getId()); for(BagEntry be: bel){ int slot = BagHelper.getSlotByItemStack(be, checkWithoutAmount); if(slot != -1){ be.setSlotValue(slot, be.getSlotValue(slot) + item.getItemStack().getAmount()); - be.setToBeUpdated(true); + be.setHasToBeUpdated(true); ChatHelper.sendMessageInActionBar(p, String.format(EventConstants.PLUGIN_EVENT_BAG_COLLECT, item.getItemStack().getAmount(), item.getName())); p.playSound(p, Sound.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.5F, 1); item.getItemStack().setAmount(0); @@ -350,9 +350,9 @@ public static void saveBags(){ int updatedBags = 0; for(BagEntry be : RelluEssentials.getInstance().getPlayerAPI().getPlayerBagMap().values()){ - if(be.hasToBeUpdated()){ + if(be.isHasToBeUpdated()){ RelluEssentials.getInstance().getDatabaseHelper().updateBagEntry(be); - be.setToBeUpdated(false); + be.setHasToBeUpdated(false); updatedBags++; } } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/BankerHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/BankerHelper.java index 19caad21..4efbdd22 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/BankerHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/BankerHelper.java @@ -104,10 +104,10 @@ public static void deposit(PlayerEntry pe, Player p, BankAccountEntry bae, float pe.setPurse(purse - transactionValue); } - RelluEssentials.getInstance().getDatabaseHelper().addTransactionToBank(pe.getID(), bae.getId(), transactionValue, bae.getValue(), bae.getTier().getId()); + RelluEssentials.getInstance().getDatabaseHelper().addTransactionToBank(pe.getId(), bae.getId(), transactionValue, bae.getValue(), bae.getTier().getId()); - pe.setUpdatedBy(pe.getID()); - pe.setToBeUpdated(true); + pe.setUpdatedBy(pe.getId()); + pe.setHasToBeUpdated(true); p.playSound(p, Sound.ITEM_ARMOR_EQUIP_GOLD, SoundCategory.MASTER, 1f, 1f); p.sendMessage(String.format(EventConstants.PLUGIN_EVENT_NPC_BANKER_DEPOIST_MESSAGE, StringHelper.formatDouble(transactionValue))); @@ -118,10 +118,10 @@ public static void deposit(PlayerEntry pe, Player p, BankAccountEntry bae, float if(transactionValue > 0){ pe.setPurse(purse - transactionValue); - RelluEssentials.getInstance().getDatabaseHelper().addTransactionToBank(pe.getID(), bae.getId(), transactionValue, bae.getValue(), bae.getTier().getId()); + RelluEssentials.getInstance().getDatabaseHelper().addTransactionToBank(pe.getId(), bae.getId(), transactionValue, bae.getValue(), bae.getTier().getId()); - pe.setUpdatedBy(pe.getID()); - pe.setToBeUpdated(true); + pe.setUpdatedBy(pe.getId()); + pe.setHasToBeUpdated(true); p.playSound(p, Sound.ITEM_ARMOR_EQUIP_GOLD, SoundCategory.MASTER, 1f, 1f); p.sendMessage(String.format(EventConstants.PLUGIN_EVENT_NPC_BANKER_DEPOIST_MESSAGE, StringHelper.formatDouble(transactionValue))); @@ -154,10 +154,10 @@ public static void withdraw(PlayerEntry pe, Player p, BankAccountEntry bae, floa } pe.setPurse(purse + transactionValue); - RelluEssentials.getInstance().getDatabaseHelper().addTransactionToBank(pe.getID(), bae.getId(), transactionValue*-1, bae.getValue(), bae.getTier().getId()); + RelluEssentials.getInstance().getDatabaseHelper().addTransactionToBank(pe.getId(), bae.getId(), transactionValue*-1, bae.getValue(), bae.getTier().getId()); - pe.setUpdatedBy(pe.getID()); - pe.setToBeUpdated(true); + pe.setUpdatedBy(pe.getId()); + pe.setHasToBeUpdated(true); p.playSound(p, Sound.ITEM_ARMOR_EQUIP_GOLD, SoundCategory.MASTER, 1f, 1f); p.sendMessage(String.format(EventConstants.PLUGIN_EVENT_NPC_BANKER_WITHDRAW_MESSAGE, StringHelper.formatDouble(transactionValue))); @@ -188,9 +188,9 @@ public static void upgradeAccount(ItemStack itemStack, Player p, PlayerEntry pe, double purse = pe.getPurse(); if(purse >= costs){ pe.setPurse(purse - costs); - pe.setUpdatedBy(pe.getID()); - pe.setToBeUpdated(true); - RelluEssentials.getInstance().getDatabaseHelper().updateBankAccount(pe.getID(), 0f, bae.getValue(), bt.getId()); + pe.setUpdatedBy(pe.getId()); + pe.setHasToBeUpdated(true); + RelluEssentials.getInstance().getDatabaseHelper().updateBankAccount(pe.getId(), 0f, bae.getValue(), bt.getId()); p.sendMessage(EventConstants.PLUGIN_EVENT_NPC_BANKER_BUY_USING_PURSE); p.closeInventory(); return; @@ -198,7 +198,7 @@ public static void upgradeAccount(ItemStack itemStack, Player p, PlayerEntry pe, double account = bae.getValue(); if(account >= costs){ - RelluEssentials.getInstance().getDatabaseHelper().addTransactionToBank(pe.getID(), bae.getId(), -costs, bae.getValue(), bt.getId()); + RelluEssentials.getInstance().getDatabaseHelper().addTransactionToBank(pe.getId(), bae.getId(), -costs, bae.getValue(), bt.getId()); p.sendMessage(EventConstants.PLUGIN_EVENT_NPC_BANKER_BUY_USING_BANK); p.closeInventory(); return; @@ -206,9 +206,9 @@ public static void upgradeAccount(ItemStack itemStack, Player p, PlayerEntry pe, if(purse + account >= costs){ pe.setPurse(0); - pe.setUpdatedBy(pe.getID()); - pe.setToBeUpdated(true); - RelluEssentials.getInstance().getDatabaseHelper().addTransactionToBank(pe.getID(), bae.getId(), -(costs-purse), bae.getValue(), bt.getId()); + pe.setUpdatedBy(pe.getId()); + pe.setHasToBeUpdated(true); + RelluEssentials.getInstance().getDatabaseHelper().addTransactionToBank(pe.getId(), bae.getId(), -(costs-purse), bae.getValue(), bt.getId()); p.sendMessage(EventConstants.PLUGIN_EVENT_NPC_BANKER_BUY_USING_BOTH); p.closeInventory(); return; @@ -259,7 +259,7 @@ public static void checkInterest(UUID uuid, boolean midnight){ return; } - BankAccountEntry bae = RelluEssentials.getInstance().getDatabaseHelper().getPlayerBankAccount(pe.getID()); + BankAccountEntry bae = RelluEssentials.getInstance().getDatabaseHelper().getPlayerBankAccount(pe.getId()); if(bae == null){ return; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ConfigHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ConfigHelper.java index 54a2b461..48e16865 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ConfigHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ConfigHelper.java @@ -65,11 +65,11 @@ public List getPlayers() { PlayerEntry p = new PlayerEntry(); p.setGroup(Groups.getGroup(groupName)); - p.setAFK(afk); + p.setAfk(afk); p.setFlying(fly); - p.setCreatedby(1); + p.setCreatedBy(1); p.setCustomName(customname); - p.setUUID(uuid); + p.setUuid(uuid); list.add(p); } @@ -83,7 +83,7 @@ public List getPlayers() { */ public List getHomes(PlayerEntry p) { List list = new ArrayList<>(); - ConfigurationSection homes = config.getConfigurationSection("player." + p.getUUID() + ".home"); + ConfigurationSection homes = config.getConfigurationSection("player." + p.getUuid() + ".home"); for (String home : homes.getKeys(false)) { ConfigurationSection h = homes.getConfigurationSection(home); @@ -107,7 +107,7 @@ public List getHomes(PlayerEntry p) { LocationEntry l = new LocationEntry(); l.setLocation(new Location(world, x, y, z, yaw, pitch)); l.setLocationName(home); - l.setPlayerId(p.getID()); + l.setPlayerId(p.getId()); LocationTypeEntry lt = new LocationTypeEntry(); lt.setId(type); l.setLocationType(lt); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java index 3c119bbe..d7742168 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java @@ -21,7 +21,11 @@ import java.util.logging.Level; import java.util.logging.Logger; +import de.relluem94.minecraft.server.spigot.essentials.managers.NPCManager; +import de.relluem94.minecraft.server.spigot.essentials.npc.NPC; import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Villager; import org.json.JSONObject; import de.relluem94.minecraft.server.spigot.essentials.RelluEssentials; @@ -136,7 +140,7 @@ private void patch1() { RelluEssentials.getInstance().setPluginInformation(getPluginInformation()); List pel = getPlayers(); - pel.forEach(p -> RelluEssentials.getInstance().getPlayerAPI().putPlayerEntry(UUID.fromString(p.getUUID()), p)); + pel.forEach(p -> RelluEssentials.getInstance().getPlayerAPI().putPlayerEntry(UUID.fromString(p.getUuid()), p)); ConfigHelper ch = new ConfigHelper("players"); @@ -145,8 +149,8 @@ private void patch1() { pe.forEach(this::insertPlayer); for (PlayerEntry p : pe) { - PlayerEntry pu = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(UUID.fromString(p.getUUID())); - pu.setAFK(p.isAFK()); + PlayerEntry pu = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(UUID.fromString(p.getUuid())); + pu.setAfk(p.isAfk()); pu.setFlying(p.isFlying()); pu.setCustomName(p.getCustomName()); pu.setUpdatedBy(1); @@ -376,8 +380,8 @@ public List getCrops() { while (rs.next()) { CropEntry ce = new CropEntry(); ce.setId(rs.getInt("id")); - ce.setPlant(rs.getString("PLANT")); - ce.setSeed(rs.getString("SEED")); + ce.setPlant(Material.getMaterial(rs.getString("PLANT"))); + ce.setSeed(Material.getMaterial(rs.getString("SEED"))); lce.add(ce); } @@ -398,7 +402,7 @@ public List getDrops() { while (rs.next()) { DropEntry de = new DropEntry(); de.setId(rs.getInt("id")); - de.setMaterial(rs.getString("MATERIAL")); + de.setMaterial(Material.getMaterial(rs.getString("MATERIAL"))); de.setMin(rs.getInt("MIN_INT")); de.setMax(rs.getInt("MAX_INT")); @@ -417,9 +421,9 @@ public void insertPlayerPartner(PlayerPartnerEntry ppe) { Connection connection = DriverManager.getConnection(connectorString, user, password)) { try (PreparedStatement ps = connection.prepareStatement(readResource("sqls/insertPlayerPartner.sql"))) { ps.setInt(1, ppe.getCreatedBy()); - ps.setInt(2, ppe.getFirstPlayerID()); - ps.setInt(3, ppe.getSecondPlayerID()); - ps.setBoolean(4, ppe.getShareProtections()); + ps.setInt(2, ppe.getFirstPartnerId()); + ps.setInt(3, ppe.getSecondPartnerId()); + ps.setBoolean(4, ppe.isShareProtections()); ps.execute(); } @@ -432,7 +436,7 @@ public void deletePlayerPartner(PlayerPartnerEntry ppe) { try (Connection connection = DriverManager.getConnection(connectorString, user, password)) { try (PreparedStatement ps = connection.prepareStatement(readResource("sqls/deletePlayerPartner.sql"))) { ps.setInt(1, ppe.getDeletedBy()); - ps.setInt(2, ppe.getID()); + ps.setInt(2, ppe.getId()); ps.execute(); } } catch (SQLException | FileNotFoundException ex) { @@ -444,8 +448,8 @@ public void updatePlayerPartner(PlayerPartnerEntry ppe) { try (Connection connection = DriverManager.getConnection(connectorString, user, password)) { try (PreparedStatement ps = connection.prepareStatement(readResource("sqls/updatePlayerPartner.sql"))) { ps.setInt(1, ppe.getUpdatedBy()); - ps.setBoolean(2, ppe.getShareProtections()); - ps.setInt(1, ppe.getID()); + ps.setBoolean(2, ppe.isShareProtections()); + ps.setInt(1, ppe.getId()); ps.execute(); } } catch (SQLException | FileNotFoundException ex) { @@ -462,15 +466,15 @@ public PlayerPartnerEntry getPlayerPartner(int playerFK) { try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { PlayerPartnerEntry ppe = new PlayerPartnerEntry(); - ppe.setID(rs.getInt(PlayerPartnerEntry.FIELD_ID)); + ppe.setId(rs.getInt(PlayerPartnerEntry.FIELD_ID)); ppe.setCreated(rs.getString(PlayerPartnerEntry.FIELD_CREATED)); - ppe.setCreatedby(rs.getInt(PlayerPartnerEntry.FIELD_CREATEDBY)); + ppe.setCreatedBy(rs.getInt(PlayerPartnerEntry.FIELD_CREATEDBY)); ppe.setUpdated(rs.getString(PlayerPartnerEntry.FIELD_UPDATED)); ppe.setUpdatedBy(rs.getInt(PlayerPartnerEntry.FIELD_UPDATEDBY)); ppe.setDeleted(rs.getString(PlayerPartnerEntry.FIELD_DELETED)); ppe.setDeletedBy(rs.getInt(PlayerPartnerEntry.FIELD_DELETEDBY)); - ppe.setFirstPlayerID(rs.getInt(PlayerPartnerEntry.FIELD_FIRST_PARTNER_FK)); - ppe.setSecondPlayerID(rs.getInt(PlayerPartnerEntry.FIELD_SECOND_PARTNER_FK)); + ppe.setFirstPartnerId(rs.getInt(PlayerPartnerEntry.FIELD_FIRST_PARTNER_FK)); + ppe.setSecondPartnerId(rs.getInt(PlayerPartnerEntry.FIELD_SECOND_PARTNER_FK)); ppe.setShareProtections(rs.getBoolean(PlayerPartnerEntry.FIELD_SHARE_PROTECTIONS)); return ppe; @@ -493,7 +497,7 @@ public List getWorldGroups() { WorldGroupEntry wge = new WorldGroupEntry(); wge.setId(rs.getInt(WorldGroupEntry.FIELD_ID)); wge.setCreated(rs.getString(WorldGroupEntry.FIELD_CREATED)); - wge.setCreatedby(rs.getInt(WorldGroupEntry.FIELD_CREATEDBY)); + wge.setCreatedBy(rs.getInt(WorldGroupEntry.FIELD_CREATEDBY)); wge.setUpdated(rs.getString(WorldGroupEntry.FIELD_UPDATED)); wge.setUpdatedBy(rs.getInt(WorldGroupEntry.FIELD_UPDATEDBY)); wge.setDeleted(rs.getString(WorldGroupEntry.FIELD_DELETED)); @@ -521,13 +525,13 @@ public List getWorldByGroup(WorldGroupEntry wge) { WorldEntry we = new WorldEntry(); we.setId(rs.getInt(WorldEntry.FIELD_ID)); we.setCreated(rs.getString(WorldEntry.FIELD_CREATED)); - we.setCreatedby(rs.getInt(WorldEntry.FIELD_CREATEDBY)); + we.setCreatedBy(rs.getInt(WorldEntry.FIELD_CREATEDBY)); we.setUpdated(rs.getString(WorldEntry.FIELD_UPDATED)); we.setUpdatedBy(rs.getInt(WorldEntry.FIELD_UPDATEDBY)); we.setDeleted(rs.getString(WorldEntry.FIELD_DELETED)); we.setDeletedBy(rs.getInt(WorldEntry.FIELD_DELETEDBY)); we.setName(rs.getString(WorldEntry.FIELD_NAME)); - we.setWorldGroup(wge); + we.setWorldGroupEntry(wge); lwe.add(we); } } @@ -580,14 +584,14 @@ public WorldGroupInventoryEntry getWorldGroupInventory(PlayerEntry pe, WorldGrou try (Connection connection = DriverManager.getConnection(connectorString, user, password)) { try (PreparedStatement ps = connection.prepareStatement(readResource("sqls/getWorldInventoryByGroupAndPlayer.sql"))) { ps.setInt(1, wge.getId()); - ps.setInt(2, pe.getID()); + ps.setInt(2, pe.getId()); ps.execute(); try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { WorldGroupInventoryEntry wgie = new WorldGroupInventoryEntry(); wgie.setId(rs.getInt(WorldGroupInventoryEntry.FIELD_ID)); wgie.setCreated(rs.getString(WorldGroupInventoryEntry.FIELD_CREATED)); - wgie.setCreatedby(rs.getInt(WorldGroupInventoryEntry.FIELD_CREATEDBY)); + wgie.setCreatedBy(rs.getInt(WorldGroupInventoryEntry.FIELD_CREATEDBY)); wgie.setUpdated(rs.getString(WorldGroupInventoryEntry.FIELD_UPDATED)); wgie.setUpdatedBy(rs.getInt(WorldGroupInventoryEntry.FIELD_UPDATEDBY)); wgie.setDeleted(rs.getString(WorldGroupInventoryEntry.FIELD_DELETED)); @@ -596,7 +600,7 @@ public WorldGroupInventoryEntry getWorldGroupInventory(PlayerEntry pe, WorldGrou wgie.setHealth(rs.getInt(WorldGroupInventoryEntry.FIELD_HEALTH)); wgie.setTotalExperience(rs.getInt(WorldGroupInventoryEntry.FIELD_TOTAL_EXPERIENCE)); wgie.setFoodLevel(rs.getInt(WorldGroupInventoryEntry.FIELD_FOOD)); - wgie.setWorldGroup(wge); + wgie.setWorldGroupEntry(wge); wgie.setInventory(new JSONObject(rs.getString(WorldGroupInventoryEntry.FIELD_INVENTORY))); return wgie; @@ -617,7 +621,7 @@ public void insertWorld(WorldEntry we) { ps.setInt(1, we.getCreatedBy()); ps.setString(2, we.getName()); ps.setInt(3, we.getWorldGroupEntry().getId()); - ps.setInt(4, we.getBuildGroup().getId()); + ps.setInt(4, we.getGroupEntry().getId()); ps.execute(); } @@ -650,7 +654,7 @@ public WorldGroupEntry getWorldGroup(String name) { WorldGroupEntry wge = new WorldGroupEntry(); wge.setId(rs.getInt(WorldGroupEntry.FIELD_ID)); wge.setCreated(rs.getString(WorldGroupEntry.FIELD_CREATED)); - wge.setCreatedby(rs.getInt(WorldGroupEntry.FIELD_CREATEDBY)); + wge.setCreatedBy(rs.getInt(WorldGroupEntry.FIELD_CREATEDBY)); wge.setUpdated(rs.getString(WorldGroupEntry.FIELD_UPDATED)); wge.setUpdatedBy(rs.getInt(WorldGroupEntry.FIELD_UPDATEDBY)); wge.setDeleted(rs.getString(WorldGroupEntry.FIELD_DELETED)); @@ -670,7 +674,7 @@ public WorldGroupEntry getWorldGroup(String name) { public LocationEntry getLocation(PlayerEntry pe, int type) { try (Connection connection = DriverManager.getConnection(connectorString, user, password)) { try (PreparedStatement ps = connection.prepareStatement(readResource("sqls/getLocationsByPlayer.sql"))) { - ps.setInt(1, pe.getID()); + ps.setInt(1, pe.getId()); ps.execute(); try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { @@ -703,7 +707,7 @@ public List getLocations(PlayerEntry pe, int type) { List lle = new ArrayList<>(); try (Connection connection = DriverManager.getConnection(connectorString, user, password)) { try (PreparedStatement ps = connection.prepareStatement(readResource("sqls/getLocationsByPlayer.sql"))) { - ps.setInt(1, pe.getID()); + ps.setInt(1, pe.getId()); ps.execute(); try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { @@ -816,8 +820,8 @@ public PluginInformationEntry getPluginInformation() { pie.setId(rs.getInt(PluginInformationEntry.FIELD_ID)); pie.setCreated(rs.getString(PluginInformationEntry.FIELD_CREATED)); pie.setCreatedby(rs.getInt(PluginInformationEntry.FIELD_CREATEDBY)); - pie.setTabheader(rs.getString(PluginInformationEntry.FIELD_TAB_HEADER)); - pie.setTabfooter(rs.getString(PluginInformationEntry.FIELD_TAB_FOOTER)); + pie.setTabHeader(rs.getString(PluginInformationEntry.FIELD_TAB_HEADER)); + pie.setTabFooter(rs.getString(PluginInformationEntry.FIELD_TAB_FOOTER)); pie.setMotdMessage(rs.getString(PluginInformationEntry.FIELD_MOTD_MESSAGE)); pie.setMotdPlayers(rs.getInt(PluginInformationEntry.FIELD_MOTD_PLAYERS)); pie.setDbVersion(rs.getInt(PluginInformationEntry.FIELD_DB_VERSION)); @@ -841,10 +845,10 @@ public PlayerEntry getPlayer(String uuid) { try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { PlayerEntry p = new PlayerEntry(); - p.setID(rs.getInt(PlayerEntry.FIELD_ID)); - p.setUUID(rs.getString(PlayerEntry.FIELD_UUID)); + p.setId(rs.getInt(PlayerEntry.FIELD_ID)); + p.setUuid(rs.getString(PlayerEntry.FIELD_UUID)); p.setCreated(rs.getString(PlayerEntry.FIELD_CREATED)); - p.setCreatedby(rs.getInt(PlayerEntry.FIELD_CREATEDBY)); + p.setCreatedBy(rs.getInt(PlayerEntry.FIELD_CREATEDBY)); p.setUpdated(rs.getString(PlayerEntry.FIELD_UPDATED)); p.setUpdatedBy(rs.getInt(PlayerEntry.FIELD_UPDATEDBY)); p.setDeleted(rs.getString(PlayerEntry.FIELD_DELETED)); @@ -853,7 +857,7 @@ public PlayerEntry getPlayer(String uuid) { p.setCustomName(rs.getString(PlayerEntry.FIELD_CUSTOM_NAME)); p.setPurse(rs.getDouble(PlayerEntry.FIELD_PURSE)); p.setFlying(rs.getBoolean(PlayerEntry.FIELD_FLY)); - p.setAFK(rs.getBoolean(PlayerEntry.FIELD_AFK)); + p.setAfk(rs.getBoolean(PlayerEntry.FIELD_AFK)); p.setGroup(Groups.getGroup(rs.getInt(PlayerEntry.FIELD_GROUP_FK))); PlayerPartnerEntry ppe = getPlayerPartner(rs.getInt(PlayerEntry.FIELD_ID)); p.setHomes(getLocations(p, 1)); @@ -880,7 +884,7 @@ public BankAccountEntry getPlayerBankAccount(int playerFK) { BankAccountEntry bae = new BankAccountEntry(); bae.setId(rs.getInt(BankAccountEntry.FIELD_ID)); bae.setCreated(rs.getString(BankAccountEntry.FIELD_CREATED)); - bae.setCreatedby(rs.getInt(BankAccountEntry.FIELD_CREATEDBY)); + bae.setCreatedBy(rs.getInt(BankAccountEntry.FIELD_CREATEDBY)); bae.setUpdated(rs.getString(BankAccountEntry.FIELD_UPDATED)); bae.setUpdatedBy(rs.getInt(BankAccountEntry.FIELD_UPDATEDBY)); bae.setDeleted(rs.getString(BankAccountEntry.FIELD_DELETED)); @@ -1005,9 +1009,9 @@ public List getTransactionsToBankFromPlayer(int bankAccoun while (rs.next()) { BankTransactionEntry b = new BankTransactionEntry(); - b.setID(rs.getInt(BankTransactionEntry.FIELD_ID)); + b.setId(rs.getInt(BankTransactionEntry.FIELD_ID)); b.setCreated(rs.getString(BankTransactionEntry.FIELD_CREATED)); - b.setCreatedby(rs.getInt(BankTransactionEntry.FIELD_CREATEDBY)); + b.setCreatedBy(rs.getInt(BankTransactionEntry.FIELD_CREATEDBY)); b.setUpdated(rs.getString(BankTransactionEntry.FIELD_UPDATED)); b.setUpdatedBy(rs.getInt(BankTransactionEntry.FIELD_UPDATEDBY)); b.setDeleted(rs.getString(BankTransactionEntry.FIELD_DELETED)); @@ -1036,7 +1040,7 @@ public ProtectionEntry getProtectionByLocation(Location l) { ProtectionEntry pe = new ProtectionEntry(); pe.setId(rs.getInt(ProtectionEntry.FIELD_ID)); pe.setCreated(rs.getString(ProtectionEntry.FIELD_CREATED)); - pe.setCreatedby(rs.getInt(ProtectionEntry.FIELD_CREATEDBY)); + pe.setCreatedBy(rs.getInt(ProtectionEntry.FIELD_CREATEDBY)); pe.setUpdated(rs.getString(ProtectionEntry.FIELD_UPDATED)); pe.setUpdatedBy(rs.getInt(ProtectionEntry.FIELD_UPDATEDBY)); pe.setDeleted(rs.getString(ProtectionEntry.FIELD_DELETED)); @@ -1060,8 +1064,8 @@ public void insertProtection(ProtectionEntry pe) { try (Connection connection = DriverManager.getConnection(connectorString, user, password)) { try (PreparedStatement ps = connection.prepareStatement(readResource("sqls/insertProtection.sql"))) { - ps.setInt(1, pe.getLocation().getPlayerId()); - ps.setInt(2, pe.getLocation().getId()); + ps.setInt(1, pe.getLocationEntry().getPlayerId()); + ps.setInt(2, pe.getLocationEntry().getId()); ps.setString(3, pe.getMaterialName()); ps.setString(4, pe.getFlags().toString()); ps.setString(5, pe.getRights().toString()); @@ -1074,11 +1078,11 @@ public void insertProtection(ProtectionEntry pe) { } public void deleteProtection(ProtectionEntry pe) { - deleteLocation(pe.getLocation()); + deleteLocation(pe.getLocationEntry()); try (Connection connection = DriverManager.getConnection(connectorString, user, password)) { try (PreparedStatement ps = connection.prepareStatement(readResource("sqls/deleteProtection.sql"))) { - ps.setInt(1, pe.getLocation().getPlayerId()); + ps.setInt(1, pe.getLocationEntry().getPlayerId()); ps.setInt(2, pe.getId()); ps.execute(); } @@ -1088,11 +1092,11 @@ public void deleteProtection(ProtectionEntry pe) { } public void updateProtectionFlag(ProtectionEntry pe) { - deleteLocation(pe.getLocation()); + deleteLocation(pe.getLocationEntry()); try (Connection connection = DriverManager.getConnection(connectorString, user, password)) { try (PreparedStatement ps = connection.prepareStatement(readResource("sqls/updateProtectionFlags.sql"))) { - ps.setInt(1, pe.getLocation().getPlayerId()); + ps.setInt(1, pe.getLocationEntry().getPlayerId()); ps.setString(2, pe.getFlags().toString()); ps.setInt(3, pe.getId()); ps.execute(); @@ -1103,11 +1107,11 @@ public void updateProtectionFlag(ProtectionEntry pe) { } public void updateProtectionRight(ProtectionEntry pe) { - deleteLocation(pe.getLocation()); + deleteLocation(pe.getLocationEntry()); try (Connection connection = DriverManager.getConnection(connectorString, user, password)) { try (PreparedStatement ps = connection.prepareStatement(readResource("sqls/updateProtectionRights.sql"))) { - ps.setInt(1, pe.getLocation().getPlayerId()); + ps.setInt(1, pe.getLocationEntry().getPlayerId()); ps.setString(2, pe.getRights().toString()); ps.setInt(3, pe.getId()); ps.execute(); @@ -1130,7 +1134,7 @@ public Map getProtections() { ProtectionEntry pe = new ProtectionEntry(); pe.setId(rs.getInt(ProtectionEntry.FIELD_ID)); pe.setCreated(rs.getString(ProtectionEntry.FIELD_CREATED)); - pe.setCreatedby(rs.getInt(ProtectionEntry.FIELD_CREATEDBY)); + pe.setCreatedBy(rs.getInt(ProtectionEntry.FIELD_CREATEDBY)); pe.setUpdated(rs.getString(ProtectionEntry.FIELD_UPDATED)); pe.setUpdatedBy(rs.getInt(ProtectionEntry.FIELD_UPDATEDBY)); pe.setDeleted(rs.getString(ProtectionEntry.FIELD_DELETED)); @@ -1162,10 +1166,10 @@ public List getPlayers() { try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { PlayerEntry p = new PlayerEntry(); - p.setID(rs.getInt(PlayerEntry.FIELD_ID)); - p.setUUID(rs.getString(PlayerEntry.FIELD_UUID)); + p.setId(rs.getInt(PlayerEntry.FIELD_ID)); + p.setUuid(rs.getString(PlayerEntry.FIELD_UUID)); p.setCreated(rs.getString(PlayerEntry.FIELD_CREATED)); - p.setCreatedby(rs.getInt(PlayerEntry.FIELD_CREATEDBY)); + p.setCreatedBy(rs.getInt(PlayerEntry.FIELD_CREATEDBY)); p.setUpdated(rs.getString(PlayerEntry.FIELD_UPDATED)); p.setUpdatedBy(rs.getInt(PlayerEntry.FIELD_UPDATEDBY)); p.setDeleted(rs.getString(PlayerEntry.FIELD_DELETED)); @@ -1174,7 +1178,7 @@ public List getPlayers() { p.setCustomName(rs.getString(PlayerEntry.FIELD_CUSTOM_NAME)); p.setPurse(rs.getDouble(PlayerEntry.FIELD_PURSE)); p.setFlying(rs.getBoolean(PlayerEntry.FIELD_FLY)); - p.setAFK(rs.getBoolean(PlayerEntry.FIELD_AFK)); + p.setAfk(rs.getBoolean(PlayerEntry.FIELD_AFK)); p.setGroup(Groups.getGroup(rs.getInt(PlayerEntry.FIELD_GROUP_FK))); PlayerPartnerEntry ppe = getPlayerPartner(rs.getInt(PlayerEntry.FIELD_ID)); p.setHomes(getLocations(p, 1)); @@ -1196,7 +1200,7 @@ public void insertPlayer(PlayerEntry pe) { try (Connection connection = DriverManager.getConnection(connectorString, user, password)) { try (PreparedStatement ps = connection.prepareStatement(readResource("sqls/insertPlayer.sql"))) { ps.setInt(1, pe.getCreatedBy()); - ps.setString(2, pe.getUUID()); + ps.setString(2, pe.getUuid()); ps.setString(3, pe.getName()); ps.setString(4, pe.getCustomName()); ps.setInt(5, pe.getGroup().getId()); @@ -1225,14 +1229,14 @@ public void insertGroup(GroupEntry ge) { public void updatePlayer(PlayerEntry pe) { try (Connection connection = DriverManager.getConnection(connectorString, user, password)) { try (PreparedStatement ps = connection.prepareStatement(readResource("sqls/updatePlayer.sql"))) { - ps.setInt(1, pe.getID()); + ps.setInt(1, pe.getId()); ps.setInt(2, pe.getGroup().getId()); - ps.setBoolean(3, pe.isAFK()); + ps.setBoolean(3, pe.isAfk()); ps.setBoolean(4, pe.isFlying()); ps.setString(5, pe.getName()); ps.setString(6, pe.getCustomName()); ps.setDouble(7, pe.getPurse()); - ps.setString(8, pe.getUUID()); + ps.setString(8, pe.getUuid()); ps.execute(); } } catch (SQLException | FileNotFoundException ex) { @@ -1417,7 +1421,7 @@ public List getBlockHistoryByPlayer(PlayerEntry p) { List bhe = new ArrayList<>(); try (Connection connection = DriverManager.getConnection(connectorString, user, password)) { try (PreparedStatement ps = connection.prepareStatement(readResource("sqls/getBlockHistoryByPlayer.sql"))) { - ps.setFloat(1, p.getID()); + ps.setFloat(1, p.getId()); ps.execute(); @@ -1486,7 +1490,7 @@ public List getBlockHistoryByPlayerAndTime(PlayerEntry p, Str } } - ps.setFloat(1, p.getID()); + ps.setFloat(1, p.getId()); ps.setInt(2, minute); ps.setInt(3, hour); ps.setInt(4, day); @@ -1602,7 +1606,7 @@ public BagEntry getBag(int type, int playerFK) { BagEntry be = new BagEntry(); be.setId(rs.getInt(BagEntry.FIELD_ID)); be.setCreated(rs.getString(BagEntry.FIELD_CREATED)); - be.setCreatedby(rs.getInt(BagEntry.FIELD_CREATEDBY)); + be.setCreatedBy(rs.getInt(BagEntry.FIELD_CREATEDBY)); be.setUpdated(rs.getString(BagEntry.FIELD_UPDATED)); be.setUpdatedBy(rs.getInt(BagEntry.FIELD_UPDATEDBY)); be.setDeleted(rs.getString(BagEntry.FIELD_DELETED)); @@ -1680,7 +1684,7 @@ public List getBags() { be.setId(rs.getInt(BagEntry.FIELD_ID)); be.setCreated(rs.getString(BagEntry.FIELD_CREATED)); - be.setCreatedby(rs.getInt(BagEntry.FIELD_CREATEDBY)); + be.setCreatedBy(rs.getInt(BagEntry.FIELD_CREATEDBY)); be.setUpdated(rs.getString(BagEntry.FIELD_UPDATED)); be.setUpdatedBy(rs.getInt(BagEntry.FIELD_UPDATEDBY)); be.setDeleted(rs.getString(BagEntry.FIELD_DELETED)); @@ -1734,15 +1738,15 @@ public List getNPCs() { be.setId(rs.getInt(NPCEntry.FIELD_ID)); be.setCreated(rs.getString(NPCEntry.FIELD_CREATED)); - be.setCreatedby(rs.getInt(NPCEntry.FIELD_CREATEDBY)); + be.setCreatedBy(rs.getInt(NPCEntry.FIELD_CREATEDBY)); be.setUpdated(rs.getString(NPCEntry.FIELD_UPDATED)); be.setUpdatedBy(rs.getInt(NPCEntry.FIELD_UPDATEDBY)); be.setDeleted(rs.getString(NPCEntry.FIELD_DELETED)); be.setDeletedBy(rs.getInt(NPCEntry.FIELD_DELETEDBY)); be.setName(rs.getString(NPCEntry.FIELD_NAME)); - be.setProfession(rs.getString(NPCEntry.FIELD_PROFESSION)); - be.setType(rs.getString(NPCEntry.FIELD_TYPE)); + be.setProfession(Villager.Profession.valueOf(rs.getString(NPCEntry.FIELD_PROFESSION))); + be.setType(NPC.Type.valueOf(rs.getString(NPCEntry.FIELD_TYPE))); for (int i = 0; i <= 27; i++) { be.setSlotName(i, rs.getString(String.format(NPCEntry.FIELD_SLOT_VAR_NAME, (i + 1)))); @@ -1770,12 +1774,12 @@ public List getProtectionLocks() { be.setId(rs.getInt(ProtectionLockEntry.FIELD_ID)); be.setCreated(rs.getString(ProtectionLockEntry.FIELD_CREATED)); - be.setCreatedby(rs.getInt(ProtectionLockEntry.FIELD_CREATEDBY)); + be.setCreatedBy(rs.getInt(ProtectionLockEntry.FIELD_CREATEDBY)); be.setUpdated(rs.getString(ProtectionLockEntry.FIELD_UPDATED)); be.setUpdatedBy(rs.getInt(ProtectionLockEntry.FIELD_UPDATEDBY)); be.setDeleted(rs.getString(ProtectionLockEntry.FIELD_DELETED)); be.setDeletedBy(rs.getInt(ProtectionLockEntry.FIELD_DELETEDBY)); - be.setValue(rs.getString(ProtectionLockEntry.FIELD_VALUE)); + be.setValue(Material.getMaterial(rs.getString(ProtectionLockEntry.FIELD_VALUE))); bel.add(be); } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHeadHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHeadHelper.java index ccac7eb0..f3ae6acb 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHeadHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHeadHelper.java @@ -32,7 +32,7 @@ public static ItemStack createSkull(String name){ ItemStack is = PLAYER_HEAD.clone(); SkullMeta sm = (SkullMeta) is.getItemMeta(); if(player != null){ - PlayerProfile pp = Bukkit.createPlayerProfile(player.getID(), player.getName()); + PlayerProfile pp = Bukkit.createPlayerProfile(player.getId(), player.getName()); sm.setOwnerProfile(pp); sm.setDisplayName(player.getName()); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelper.java index 72a8f45a..3c86f283 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelper.java @@ -61,7 +61,7 @@ public static void setFlying(Player p) { */ public static boolean setAFK(Player p, boolean join) { PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p.getUniqueId()); - boolean isAFK = pe.isAFK(); + boolean isAFK = pe.isAfk(); if(pe.getPlayerState().equals(PlayerState.FAKE_AFK_ACTIVE)){ isAFK = true; @@ -77,10 +77,10 @@ else if(pe.getPlayerState().equals(PlayerState.FAKE_AFK_ON)){ if(pe.getPlayerState().equals(PlayerState.DEFAULT)){ if(!join){ - pe.setUpdatedBy(pe.getID()); - pe.setAFK(isAFK); - pe.setUpdatedBy(pe.getID()); - pe.setToBeUpdated(true); + pe.setUpdatedBy(pe.getId()); + pe.setAfk(isAFK); + pe.setUpdatedBy(pe.getId()); + pe.setHasToBeUpdated(true); } p.setInvulnerable(isAFK); } @@ -95,7 +95,7 @@ public static OfflinePlayerEntry getOfflinePlayerByName(String name){ OfflinePlayerEntry ope = new OfflinePlayerEntry(); if(json.has("name")){ - ope.setID(UUIDHelper.dashed((String)json.get("id"))); + ope.setId(UUIDHelper.dashed((String)json.get("id"))); ope.setName(json.get("name").toString()); return ope; } @@ -108,7 +108,7 @@ public static OfflinePlayerEntry getOfflinePlayerByUUID(UUID uuid){ JSONObject json = NetworkUtils.getJSON("https://sessionserver.mojang.com/session/minecraft/profile/" + UUIDHelper.unDashed(uuid) + "?unsigned=false"); OfflinePlayerEntry ope = new OfflinePlayerEntry(); if(json.has("name")){ - ope.setID(uuid); + ope.setId(uuid); ope.setName(json.get("name").toString()); Properties properties = new Properties(); @@ -142,8 +142,8 @@ public static void updateGroup(OfflinePlayer p, GroupEntry g) { } pe.setGroup(g); - pe.setUpdatedBy(pe.getID()); - pe.setToBeUpdated(true); + pe.setUpdatedBy(pe.getId()); + pe.setHasToBeUpdated(true); } @@ -202,9 +202,9 @@ public static int savePlayer(Player p){ } public static int savePlayer(PlayerEntry pe){ - if(pe.hasToBeUpdated()){ + if(pe.isHasToBeUpdated()){ RelluEssentials.getInstance().getDatabaseHelper().updatePlayer(pe); - pe.setToBeUpdated(false); + pe.setHasToBeUpdated(false); return 1; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ProtectionHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ProtectionHelper.java index d4b4a589..79660041 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ProtectionHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ProtectionHelper.java @@ -54,7 +54,7 @@ public static boolean hasPermission(Block b, Player p){ PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); ProtectionEntry pre = RelluEssentials.getInstance().getProtectionAPI().getProtectionEntry(l); if (pre != null) { - return pre.getLocation().getPlayerId() == pe.getID(); + return pre.getLocationEntry().getPlayerId() == pe.getId(); } else{ return true; @@ -70,7 +70,7 @@ public static boolean hasPermission(Block b, Player p){ public static boolean hasPermission(ProtectionEntry pre, Player p){ PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); if (pre != null) { - return pre.getLocation().getPlayerId() == pe.getID(); + return pre.getLocationEntry().getPlayerId() == pe.getId(); } else{ return true; @@ -81,7 +81,7 @@ public static boolean hasPermission(ProtectionEntry pre, Player p){ * Use this with an ProtectionEntry to check ifa Protection has a Specific Flag * @param protection ProtectionEntry * @param flag ProtectionFlags - * @return + * @return boolean */ public static boolean hasFlag(ProtectionEntry protection, ProtectionFlags flag) { JSONObject flags = protection.getFlags(); @@ -94,13 +94,13 @@ public static boolean hasFlag(ProtectionEntry protection, ProtectionFlags flag) /** * Use this Method to check if Player has Rights to the ProtectionEntry * @param protection ProtectionEntry - * @param player_fk - * @return + * @param playerId int + * @return boolean */ - public static boolean hasRights(ProtectionEntry protection, int playerFK) { + public static boolean hasRights(ProtectionEntry protection, int playerId) { JSONObject rights = protection.getRights(); if(!rights.isEmpty() && rights.has(PLUGIN_EVENT_PROTECT_RIGHTS)){ - return (rights.getJSONArray(PLUGIN_EVENT_PROTECT_RIGHTS).toList().contains(playerFK)); + return (rights.getJSONArray(PLUGIN_EVENT_PROTECT_RIGHTS).toList().contains(playerId)); } else{ return false; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/WorldHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/WorldHelper.java index 2122ccc1..8908ecca 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/WorldHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/WorldHelper.java @@ -239,10 +239,10 @@ public static void loadWorldGroupInventory(Player p){ } else{ wgie = new WorldGroupInventoryEntry(); - wgie.setCreatedby(pe.getID()); - wgie.setPlayerId(pe.getID()); + wgie.setCreatedBy(pe.getId()); + wgie.setPlayerId(pe.getId()); wgie.setInventory(InventoryHelper.saveInventoryToJSON(p)); - wgie.setWorldGroup(wge); + wgie.setWorldGroupEntry(wge); wgie.setFoodLevel(p.getFoodLevel()); wgie.setHealth(p.getHealth()); wgie.setTotalExperience(ExperienceHelper.getTotalExperience(p)); @@ -301,9 +301,9 @@ private static boolean savePlayerInv(WorldGroupEntry wge, PlayerEntry pe, Player WorldGroupInventoryEntry wgie = RelluEssentials.getInstance().getDatabaseHelper().getWorldGroupInventory(pe, wge); if(wgie == null){ wgie = new WorldGroupInventoryEntry(); - wgie.setCreatedby(pe.getID()); - wgie.setPlayerId(pe.getID()); - wgie.setWorldGroup(wge); + wgie.setCreatedBy(pe.getId()); + wgie.setPlayerId(pe.getId()); + wgie.setWorldGroupEntry(wge); wgie.setInventory(InventoryHelper.saveInventoryToJSON(p)); wgie.setFoodLevel(p.getFoodLevel()); @@ -326,7 +326,7 @@ private static boolean savePlayerInv(WorldGroupEntry wge, PlayerEntry pe, Player wgie.setFoodLevel(p.getFoodLevel()); wgie.setHealth(p.getHealth()); - wgie.setUpdatedBy(pe.getID()); + wgie.setUpdatedBy(pe.getId()); wgie.setTotalExperience(ExperienceHelper.getTotalExperience(p)); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BagEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BagEntry.java index a388ca5e..67e1c8ce 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BagEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BagEntry.java @@ -1,12 +1,16 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.pojo; import de.relluem94.minecraft.server.spigot.essentials.helpers.BagHelper; +import lombok.Getter; +import lombok.Setter; /** * * @author rellu */ +@Setter +@Getter public class BagEntry { public static final String FIELD_ID = "id"; @@ -27,109 +31,16 @@ public class BagEntry { private int updatedBy; private String deleted; private int deletedBy; - - - private int playerFK; - private int bagTypeFK; - - + private int playerId; + private int bagTypeId; private int[] slotValues; - private BagTypeEntry bte; - + private BagTypeEntry bagType; private boolean hasToBeUpdated = false; public BagEntry(){ slotValues = new int[BagHelper.BAG_SIZE]; } - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getCreated() { - return created; - } - - public void setCreated(String created) { - this.created = created; - } - - public int getCreatedBy() { - return createdBy; - } - - public void setCreatedby(int createdBy) { - this.createdBy = createdBy; - } - - public void setUpdated(String updated) { - this.updated = updated; - } - - public String getUpdated() { - return updated; - } - - public int getUpdatedBy() { - return updatedBy; - } - - public void setUpdatedBy(int updatedBy) { - this.updatedBy = updatedBy; - } - - public void setDeleted(String deleted) { - this.deleted = deleted; - } - - public String getDeleted() { - return deleted; - } - - public int getDeletedBy() { - return deletedBy; - } - - public void setDeletedBy(int deletedBy) { - this.deletedBy = deletedBy; - } - - public int getPlayerId() { - return playerFK; - } - - public void setPlayerId(int playerId) { - this.playerFK = playerId; - } - - public int getBagTypeId() { - return bagTypeFK; - } - - public void setBagTypeId(int bagTypeFK) { - this.bagTypeFK = bagTypeFK; - } - - public BagTypeEntry getBagType(){ - return bte; - } - - public void setBagType(BagTypeEntry bte){ - this.bte = bte; - } - - public int[] getSlotValues() { - return slotValues; - } - - public void setSlotValues(int[] slotValues) { - this.slotValues = slotValues; - } - public void setSlotValue(int slot, int value){ this.slotValues[slot] = value; } @@ -137,12 +48,4 @@ public void setSlotValue(int slot, int value){ public int getSlotValue(int slot) { return slotValues[slot]; } - - public boolean hasToBeUpdated(){ - return hasToBeUpdated; - } - - public void setToBeUpdated(boolean hasToBeUpdated){ - this.hasToBeUpdated = hasToBeUpdated; - } -} +} \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BagTypeEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BagTypeEntry.java index 781bf249..77b080d4 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BagTypeEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BagTypeEntry.java @@ -1,12 +1,16 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.pojo; import de.relluem94.minecraft.server.spigot.essentials.helpers.BagHelper; +import lombok.Getter; +import lombok.Setter; /** * * @author rellu */ +@Getter +@Setter public class BagTypeEntry { public static final String FIELD_ID = "id"; @@ -16,7 +20,7 @@ public class BagTypeEntry { public static final String FIELD_SLOT_VAR_NAME = "slot_%s_name"; private int id; - private String displayname; + private String displayName; private String name; private int cost; private String[] slotNames; @@ -25,42 +29,6 @@ public BagTypeEntry(){ slotNames = new String[BagHelper.BAG_SIZE]; } - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getDisplayName() { - return displayname; - } - - public void setDisplayName(String displayname) { - this.displayname = displayname; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getCost() { - return cost; - } - - public void setCost(int cost) { - this.cost = cost; - } - - public String[] getSlotNames() { - return slotNames; - } - public String getSlotName(int slot) { return slotNames[slot]; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankAccountEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankAccountEntry.java index b111e27b..54837053 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankAccountEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankAccountEntry.java @@ -1,9 +1,14 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.pojo; +import lombok.Getter; +import lombok.Setter; + /** * * @author rellu */ +@Setter +@Getter public class BankAccountEntry { public static final String FIELD_ID = "id"; @@ -24,87 +29,7 @@ public class BankAccountEntry { private int updatedBy; private String deleted; private int deletedBy; - private int playerFK; + private int playerId; private double value; private BankTierEntry tier; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getCreated() { - return created; - } - - public void setCreated(String created) { - this.created = created; - } - - public int getCreatedBy() { - return createdBy; - } - - public void setCreatedby(int createdBy) { - this.createdBy = createdBy; - } - - public void setUpdated(String updated) { - this.updated = updated; - } - - public String getUpdated() { - return updated; - } - - public int getUpdatedBy() { - return updatedBy; - } - - public void setUpdatedBy(int updatedBy) { - this.updatedBy = updatedBy; - } - - public void setDeleted(String deleted) { - this.deleted = deleted; - } - - public String getDeleted() { - return deleted; - } - - public int getDeletedBy() { - return deletedBy; - } - - public void setDeletedBy(int deletedBy) { - this.deletedBy = deletedBy; - } - - public int getPlayerId() { - return playerFK; - } - - public void setPlayerId(int playerId) { - this.playerFK = playerId; - } - - public double getValue() { - return value; - } - - public void setValue(double value) { - this.value = value; - } - - public BankTierEntry getTier() { - return tier; - } - - public void setTier(BankTierEntry tier) { - this.tier = tier; - } } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankTierEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankTierEntry.java index 8de24b36..5ffa69ef 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankTierEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankTierEntry.java @@ -1,9 +1,14 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.pojo; +import lombok.Getter; +import lombok.Setter; + /** * * @author rellu */ +@Setter +@Getter public class BankTierEntry { public static final String FIELD_ID = "id"; @@ -18,44 +23,4 @@ public class BankTierEntry { private long limit; private double interest; private long cost; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public long getLimit() { - return limit; - } - - public void setLimit(long limit) { - this.limit = limit; - } - - public double getInterest() { - return interest; - } - - public void setInterest(double interest) { - this.interest = interest; - } - - public long getCost() { - return cost; - } - - public void setCost(long cost) { - this.cost = cost; - } -} +} \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankTransactionEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankTransactionEntry.java index 074054b2..329be02d 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankTransactionEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankTransactionEntry.java @@ -1,9 +1,14 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.pojo; +import lombok.Getter; +import lombok.Setter; + /** * * @author rellu */ +@Setter +@Getter public class BankTransactionEntry { public static final String FIELD_ID = "id"; @@ -23,78 +28,6 @@ public class BankTransactionEntry { private int updatedBy; private String deleted; private int deletedBy; - private int bankAccountFK; + private int bankAccountId; private double value; - - public int getID() { - return id; - } - - public void setID(int id) { - this.id = id; - } - - public String getCreated() { - return created; - } - - public void setCreated(String created) { - this.created = created; - } - - public int getCreatedBy() { - return createdBy; - } - - public void setCreatedby(int createdBy) { - this.createdBy = createdBy; - } - - public void setUpdated(String updated) { - this.updated = updated; - } - - public String getUpdated() { - return updated; - } - - public int getUpdatedBy() { - return updatedBy; - } - - public void setUpdatedBy(int updatedBy) { - this.updatedBy = updatedBy; - } - - public void setDeleted(String deleted) { - this.deleted = deleted; - } - - public String getDeleted() { - return deleted; - } - - public int getDeletedBy() { - return deletedBy; - } - - public void setDeletedBy(int deletedBy) { - this.deletedBy = deletedBy; - } - - public int getBankAccountId() { - return bankAccountFK; - } - - public void setBankAccountId(int bankAccountFK) { - this.bankAccountFK = bankAccountFK; - } - - public double getValue() { - return value; - } - - public void setValue(double value) { - this.value = value; - } } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BlockHistoryEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BlockHistoryEntry.java index d108812b..7f1cdf4a 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BlockHistoryEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BlockHistoryEntry.java @@ -1,9 +1,14 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.pojo; +import lombok.Getter; +import lombok.Setter; + /** * * @author rellu */ +@Setter +@Getter public class BlockHistoryEntry { public static final String FIELD_ID = "id"; @@ -24,77 +29,4 @@ public class BlockHistoryEntry { private int updatedBy; private String deleted; private int deletedby; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public LocationEntry getLocation() { - return location; - } - - public void setLocation(LocationEntry location) { - this.location = location; - } - - public String getCreated() { - return created; - } - - public void setCreated(String created) { - this.created = created; - } - - public int getCreatedby() { - return createdby; - } - - public void setCreatedby(int createdby) { - this.createdby = createdby; - } - - public void setDeleted(String deleted) { - this.deleted = deleted; - } - - public void setUpdated(String updated) { - this.updated = updated; - } - - public String getUpdated() { - return updated; - } - - public int getUpdatedBy() { - return updatedBy; - } - - public void setUpdatedBy(int updatedBy) { - this.updatedBy = updatedBy; - } - - public String getDeleted() { - return deleted; - } - - public int getDeletedby() { - return deletedby; - } - - public void setDeletedby(int deletedby) { - this.deletedby = deletedby; - } - - public String getMaterial() { - return material; - } - - public void setMaterial(String material) { - this.material = material; - } - -} +} \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/CropEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/CropEntry.java index 550e272a..297ea24f 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/CropEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/CropEntry.java @@ -1,41 +1,13 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.pojo; +import lombok.Getter; +import lombok.Setter; import org.bukkit.Material; +@Setter +@Getter public class CropEntry { private int id; private Material plant; private Material seed; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public Material getPlant() { - return plant; - } - - public void setPlant(Material plant) { - this.plant = plant; - } - - public void setPlant(String plant) { - this.plant = Material.valueOf(plant); - } - - public Material getSeed() { - return seed; - } - - public void setSeed(Material seed) { - this.seed = seed; - } - - public void setSeed(String seed) { - this.seed = Material.valueOf(seed); - } -} +} \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/DropEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/DropEntry.java index 8e563b8a..f6907686 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/DropEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/DropEntry.java @@ -1,47 +1,14 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.pojo; +import lombok.Getter; +import lombok.Setter; import org.bukkit.Material; +@Setter +@Getter public class DropEntry { private int id; private Material material; private int min; private int max; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public Material getMaterial() { - return material; - } - - public void setMaterial(Material material) { - this.material = material; - } - - public void setMaterial(String material) { - this.material = Material.valueOf(material); - } - - - public int getMin() { - return min; - } - - public void setMin(int min) { - this.min = min; - } - - public int getMax() { - return max; - } - - public void setMax(int max) { - this.max = max; - } -} +} \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/GroupEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/GroupEntry.java index 533ff4a8..0a73154d 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/GroupEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/GroupEntry.java @@ -1,9 +1,14 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.pojo; +import lombok.Getter; +import lombok.Setter; + /** * * @author rellu */ +@Setter +@Getter public class GroupEntry { public static final String FIELD_ID = "id"; @@ -22,28 +27,4 @@ public GroupEntry(int id, String name, String prefix) { this.name = name; this.prefix = prefix; } - - public int getId() { - return id; - } - - public String getName() { - return name; - } - - public String getPrefix() { - return prefix; - } - - public void setId(int id) { - this.id = id; - } - - public void setName(String name) { - this.name = name; - } - - public void setPrefix(String prefix) { - this.prefix = prefix; - } -} +} \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/LocationEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/LocationEntry.java index aed69f2c..2051a9dd 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/LocationEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/LocationEntry.java @@ -1,12 +1,18 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.pojo; +import lombok.Getter; +import lombok.Setter; import org.bukkit.Bukkit; import org.bukkit.Location; +import java.util.Objects; + /** * * @author rellu */ +@Setter +@Getter public class LocationEntry { public static final String FIELD_ID = "id"; @@ -28,100 +34,20 @@ public class LocationEntry { private double z; private float yaw; private float pitch; - private int playerFK; + private int playerId; private String locationName; private LocationTypeEntry locationType; - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public int getPlayerId() { - return playerFK; - } - - public void setPlayerId(int playerId) { - this.playerFK = playerId; - } - - public LocationTypeEntry getLocationType() { - return locationType; - } - - public void setLocationType(LocationTypeEntry locationType) { - this.locationType = locationType; - } - - public String getLocationName() { - return locationName; - } - - public void setLocationName(String locationName) { - this.locationName = locationName; - } - - public String getWorld() { - return world; - } - - public void setWorld(String world) { - this.world = world; - } - - public double getX() { - return x; - } - - public void setX(double x) { - this.x = x; - } - - public double getY() { - return y; - } - - public void setY(double y) { - this.y = y; - } - - public double getZ() { - return z; - } - - public void setZ(double z) { - this.z = z; - } - - public float getYaw() { - return yaw; - } - - public void setYaw(float yaw) { - this.yaw = yaw; - } - - public float getPitch() { - return pitch; - } - - public void setPitch(float pitch) { - this.pitch = pitch; - } - public Location getLocation() { return new Location(Bukkit.getWorld(world), x, y, z, yaw, pitch); } public void setLocation(Location location) { - setWorld(location.getWorld().getName()); - setX(location.getX()); - setY(location.getY()); - setZ(location.getZ()); - setYaw(location.getYaw()); - setPitch(location.getPitch()); - } -} + this.world = Objects.requireNonNull(location.getWorld()).getName(); + this.x = location.getX(); + this.y = location.getY(); + this.z = location.getZ(); + this.yaw = location.getYaw(); + this.pitch = location.getPitch(); + } +} \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/LocationTypeEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/LocationTypeEntry.java index 80a93fc5..bb15a3da 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/LocationTypeEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/LocationTypeEntry.java @@ -1,9 +1,14 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.pojo; +import lombok.Getter; +import lombok.Setter; + /** * * @author rellu */ +@Setter +@Getter public class LocationTypeEntry { public static final String FIELD_ID = "id"; @@ -11,21 +16,4 @@ public class LocationTypeEntry { private int id; private String type; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - -} +} \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/NPCEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/NPCEntry.java index 0eee7d32..13bf988c 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/NPCEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/NPCEntry.java @@ -1,5 +1,7 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.pojo; +import lombok.Getter; +import lombok.Setter; import org.bukkit.entity.Villager.Profession; import de.relluem94.minecraft.server.spigot.essentials.helpers.InventoryHelper; @@ -10,7 +12,8 @@ * * @author rellu */ - +@Setter +@Getter public class NPCEntry { public static final String FIELD_ID = "id"; @@ -42,86 +45,6 @@ public NPCEntry(){ slotNames = new String[NPCHelper.INV_SIZE - InventoryHelper.getSkipsSize()]; } - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getCreated() { - return created; - } - - public void setCreated(String created) { - this.created = created; - } - - public int getCreatedBy() { - return createdBy; - } - - public void setCreatedby(int createdBy) { - this.createdBy = createdBy; - } - - public void setUpdated(String updated) { - this.updated = updated; - } - - public String getUpdated() { - return updated; - } - - public int getUpdatedBy() { - return updatedBy; - } - - public void setUpdatedBy(int updatedBy) { - this.updatedBy = updatedBy; - } - - public void setDeleted(String deleted) { - this.deleted = deleted; - } - - public String getDeleted() { - return deleted; - } - - public int getDeletedBy() { - return deletedBy; - } - - public void setDeletedBy(int deletedBy) { - this.deletedBy = deletedBy; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Profession getProfession(){ - return profession; - } - - public void setProfession(String profession){ - this.profession = Profession.valueOf(profession); - } - - public void setProfession(Profession profession){ - this.profession = profession; - } - - public String[] getSlotNames() { - return slotNames; - } - public String getSlotName(int slot) { return slotNames[slot]; } @@ -129,16 +52,4 @@ public String getSlotName(int slot) { public void setSlotName(int slot, String name){ slotNames[slot] = name; } - - public Type getType(){ - return type; - } - - public void setType(String type){ - this.type = Type.valueOf(type); - } - - public void setType(Type type){ - this.type = type; - } } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/OfflinePlayerEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/OfflinePlayerEntry.java index a220a135..98d53db4 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/OfflinePlayerEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/OfflinePlayerEntry.java @@ -1,5 +1,8 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.pojo; +import lombok.Getter; +import lombok.Setter; + import java.util.Properties; import java.util.UUID; @@ -7,33 +10,11 @@ * * @author rellu */ +@Setter +@Getter public class OfflinePlayerEntry { private UUID id; private String name; private Properties properties; - - public UUID getID() { - return id; - } - - public void setID(UUID id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Properties getProperties(){ - return properties; - } - - public void setProperties(Properties properties){ - this.properties = properties; - } } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PlayerEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PlayerEntry.java index b4c1e392..fcac9260 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PlayerEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PlayerEntry.java @@ -4,11 +4,15 @@ import java.util.List; import de.relluem94.minecraft.server.spigot.essentials.constants.PlayerState; +import lombok.Getter; +import lombok.Setter; /** * * @author rellu */ +@Setter +@Getter public class PlayerEntry { public static final String FIELD_ID = "id"; @@ -31,13 +35,13 @@ public class PlayerEntry { private int createdBy; private String updated; private int updatedBy; - private double purse; private String deleted; private int deletedBy; + private double purse; private String uuid; private GroupEntry group; private boolean afk; - private boolean fly; + private boolean flying; private String name; private String customName; private List homes = new ArrayList<>(); @@ -48,186 +52,26 @@ public class PlayerEntry { private boolean hasToBeUpdated = false; - public boolean hasToBeUpdated(){ - return hasToBeUpdated; - } - - public void setToBeUpdated(boolean hasToBeUpdated){ - this.hasToBeUpdated = hasToBeUpdated; - } - - public int getID() { - return id; - } - - public void setID(int id) { - this.id = id; - } - - public String getCreated() { - return created; - } - - public void setCreated(String created) { - this.created = created; - } - - public int getCreatedBy() { - return createdBy; - } - - public void setCreatedby(int createdBy) { - this.createdBy = createdBy; - } - - public void setUpdated(String updated) { - this.updated = updated; - } - - public String getUpdated() { - return updated; - } - - public int getUpdatedBy() { - return updatedBy; - } - - public void setUpdatedBy(int updatedBy) { - this.updatedBy = updatedBy; - } - - public void setDeleted(String deleted) { - this.deleted = deleted; - } - - public String getDeleted() { - return deleted; - } - - public int getDeletedBy() { - return deletedBy; - } - - public void setDeletedBy(int deletedBy) { - this.deletedBy = deletedBy; - } - - public String getUUID() { - return uuid; - } - - public void setUUID(String uuid) { - this.uuid = uuid; - } - - public GroupEntry getGroup() { - return group; - } - - public void setGroup(GroupEntry group) { - this.group = group; - } - - public boolean isAFK() { - return afk; - } - - public void setAFK(boolean afk) { - this.afk = afk; - } - - public boolean isFlying() { - return fly; - } - - public void setFlying(boolean fly) { - this.fly = fly; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getCustomName() { - return customName; - } - - public void setCustomName(String customName) { - this.customName = customName; - } - - public List getHomes() { - return homes; - } - - public void setHomes(List homes) { - this.homes = homes; - } - - public List getDeaths() { - return deaths; - } - - public void setDeaths(List deaths) { - this.deaths = deaths; - } - - public double getPurse() { - return purse; - } - - public void setPurse(double value) { - purse = value; - } - - public PlayerState getPlayerState(){ - return playerState; - } - - public void setPlayerState(PlayerState playerState){ - this.playerState = playerState; - } - - public Object getPlayerStateParameter(){ - return this.playerStateParameter; - } - - public void setPlayerStateParameter(Object o) { - this.playerStateParameter = o; - } - - public PlayerPartnerEntry getPartner() { - return partner; - } - - public void setPartner(PlayerPartnerEntry partner) { - this.partner = partner; - } - - public PlayerEntry(){ - - } + public PlayerEntry(){} public PlayerEntry(PlayerEntry pe){ - setAFK(pe.isAFK()); + setAfk(pe.isAfk()); setCreated(pe.getCreated()); - setCreatedby(pe.getCreatedBy()); + setCreatedBy(pe.getCreatedBy()); + setUpdated(pe.getUpdated()); + setUpdatedBy(pe.getUpdatedBy()); setCustomName(pe.getCustomName()); setDeleted(pe.getDeleted()); setDeletedBy(pe.getDeletedBy()); - setFlying(pe.isFlying()); + setPurse(pe.getPurse()); + setUuid(pe.getUuid()); setGroup(pe.getGroup()); + setAfk(pe.isAfk()); + + setFlying(pe.isFlying()); setHomes(pe.getHomes()); - setID(pe.getID()); + setId(pe.getId()); setPlayerState(pe.getPlayerState()); setPlayerStateParameter(pe.getPlayerStateParameter()); - setPurse(pe.getPurse()); - setUUID(pe.getUUID()); - setUpdated(pe.getUpdated()); - setUpdatedBy(pe.getUpdatedBy()); } } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PlayerPartnerEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PlayerPartnerEntry.java index cf4e4830..d68c6bb6 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PlayerPartnerEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PlayerPartnerEntry.java @@ -1,9 +1,14 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.pojo; +import lombok.Getter; +import lombok.Setter; + /** * * @author rellu */ +@Setter +@Getter public class PlayerPartnerEntry { public static final String FIELD_ID = "id"; @@ -25,87 +30,6 @@ public class PlayerPartnerEntry { private String deleted; private int deletedBy; private boolean shareProtections; - private int firstPartnerFK; - private int secondPartnerFK; - - public int getID() { - return id; - } - - public void setID(int id) { - this.id = id; - } - - public String getCreated() { - return created; - } - - public void setCreated(String created) { - this.created = created; - } - - public int getCreatedBy() { - return createdBy; - } - - public void setCreatedby(int createdBy) { - this.createdBy = createdBy; - } - - public void setUpdated(String updated) { - this.updated = updated; - } - - public String getUpdated() { - return updated; - } - - public int getUpdatedBy() { - return updatedBy; - } - - public void setUpdatedBy(int updatedBy) { - this.updatedBy = updatedBy; - } - - public void setDeleted(String deleted) { - this.deleted = deleted; - } - - public String getDeleted() { - return deleted; - } - - public int getDeletedBy() { - return deletedBy; - } - - public void setDeletedBy(int deletedBy) { - this.deletedBy = deletedBy; - } - - public boolean getShareProtections() { - return shareProtections; - } - - public void setShareProtections(boolean shareProtections) { - this.shareProtections = shareProtections; - } - - public int getFirstPlayerID() { - return firstPartnerFK; - } - - public void setFirstPlayerID(int firstPartnerFK) { - this.firstPartnerFK = firstPartnerFK; - } - - public int getSecondPlayerID() { - return secondPartnerFK; - } - - public void setSecondPlayerID(int secondPartnerFK) { - this.secondPartnerFK = secondPartnerFK; - } - + private int firstPartnerId; + private int secondPartnerId; } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PluginInformationEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PluginInformationEntry.java index 9a3eadbb..f88860ae 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PluginInformationEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PluginInformationEntry.java @@ -1,9 +1,14 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.pojo; +import lombok.Getter; +import lombok.Setter; + /** * * @author rellu */ +@Setter +@Getter public class PluginInformationEntry { public static final String FIELD_ID = "id"; @@ -31,93 +36,4 @@ public class PluginInformationEntry { private String motdMessage; private int motdPlayers; private int dbVersion; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getCreated() { - return created; - } - - public void setCreated(String created) { - this.created = created; - } - - public int getCreatedby() { - return createdby; - } - - public void setCreatedby(int createdby) { - this.createdby = createdby; - } - - public String getUpdated() { - return updated; - } - - public int getUpdatedby() { - return updatedby; - } - - public void setUpdatedby(int updatedby) { - this.updatedby = updatedby; - } - - public String getDeleted() { - return deleted; - } - - public int getDeletedby() { - return deletedby; - } - - public void setDeletedby(int deletedby) { - this.deletedby = deletedby; - } - - public String getTabheader() { - return tabHeader; - } - - public void setTabheader(String tabHeader) { - this.tabHeader = tabHeader; - } - - public String getTabfooter() { - return tabFooter; - } - - public void setTabfooter(String tabFooter) { - this.tabFooter = tabFooter; - } - - public String getMotdMessage() { - return motdMessage; - } - - public void setMotdMessage(String motdMessage) { - this.motdMessage = motdMessage; - } - - public int getMotdPlayers() { - return motdPlayers; - } - - public void setMotdPlayers(int motdPlayers) { - this.motdPlayers = motdPlayers; - } - - public int getDbVersion() { - return dbVersion; - } - - public void setDbVersion(int dbVersion) { - this.dbVersion = dbVersion; - } - -} +} \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/ProtectionEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/ProtectionEntry.java index 52f16310..faf7a0c4 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/ProtectionEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/ProtectionEntry.java @@ -1,11 +1,15 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.pojo; +import lombok.Getter; +import lombok.Setter; import org.json.JSONObject; /** * * @author rellu */ +@Setter +@Getter public class ProtectionEntry { public static final String FIELD_ID = "id"; @@ -26,97 +30,9 @@ public class ProtectionEntry { private int updatedBy; private String deleted; private int deletedBy; - private LocationEntry location; + private LocationEntry locationEntry; private String materialName; private JSONObject flags; private JSONObject rights; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getCreated() { - return created; - } - - public void setCreated(String created) { - this.created = created; - } - - public int getCreatedBy() { - return createdBy; - } - - public void setCreatedby(int createdBy) { - this.createdBy = createdBy; - } - - public void setUpdated(String updated) { - this.updated = updated; - } - - public String getUpdated() { - return updated; - } - - public int getUpdatedBy() { - return updatedBy; - } - - public void setUpdatedBy(int updatedBy) { - this.updatedBy = updatedBy; - } - - public void setDeleted(String deleted) { - this.deleted = deleted; - } - - public String getDeleted() { - return deleted; - } - - public int getDeletedBy() { - return deletedBy; - } - - public void setDeletedBy(int deletedBy) { - this.deletedBy = deletedBy; - } - - public LocationEntry getLocation() { - return location; - } - - public void setLocationEntry(LocationEntry location) { - this.location = location; - } - - public String getMaterialName() { - return materialName; - } - - public void setMaterialName(String materialName) { - this.materialName = materialName; - } - - public JSONObject getRights() { - return rights; - } - - public void setRights(JSONObject rights) { - this.rights = rights; - } - - public JSONObject getFlags() { - return flags; - } - - public void setFlags(JSONObject flags) { - this.flags = flags; - } } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/ProtectionLockEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/ProtectionLockEntry.java index 8d3eff26..391d5b22 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/ProtectionLockEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/ProtectionLockEntry.java @@ -1,11 +1,15 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.pojo; +import lombok.Getter; +import lombok.Setter; import org.bukkit.Material; /** * * @author rellu */ +@Setter +@Getter public class ProtectionLockEntry { public static final String FIELD_ID = "id"; @@ -25,72 +29,4 @@ public class ProtectionLockEntry { private String deleted; private int deletedBy; private Material value; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getCreated() { - return created; - } - - public void setCreated(String created) { - this.created = created; - } - - public int getCreatedBy() { - return createdBy; - } - - public void setCreatedby(int createdBy) { - this.createdBy = createdBy; - } - - public void setUpdated(String updated) { - this.updated = updated; - } - - public String getUpdated() { - return updated; - } - - public int getUpdatedBy() { - return updatedBy; - } - - public void setUpdatedBy(int updatedBy) { - this.updatedBy = updatedBy; - } - - public void setDeleted(String deleted) { - this.deleted = deleted; - } - - public String getDeleted() { - return deleted; - } - - public int getDeletedBy() { - return deletedBy; - } - - public void setDeletedBy(int deletedBy) { - this.deletedBy = deletedBy; - } - - public Material getValue() { - return value; - } - - public void setValue(String value) { - this.value = Material.valueOf(value); - } - - public void setValue(Material value) { - this.value = value; - } } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/SkillsEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/SkillsEntry.java index 336f5287..96f25876 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/SkillsEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/SkillsEntry.java @@ -1,9 +1,14 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.pojo; +import lombok.Getter; +import lombok.Setter; + /** * * @author rellu */ +@Setter +@Getter public class SkillsEntry { public static final String FIELD_ID = "id"; @@ -16,38 +21,6 @@ public class SkillsEntry { private int id; private String name; - private String displayname; + private String displayName; private int maxLevel; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDisplayName() { - return displayname; - } - - public void setDisplayName(String displayname) { - this.displayname = displayname; - } - - public int getMaxLevel() { - return maxLevel; - } - - public void setMaxLevel(int maxLevel) { - this.maxLevel = maxLevel; - } -} +} \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldEntry.java index 58bb6795..e5063b34 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldEntry.java @@ -1,11 +1,15 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.pojo; +import lombok.Getter; +import lombok.Setter; + /** * * @author rellu */ - +@Setter +@Getter public class WorldEntry { public static final String FIELD_ID = "id"; @@ -27,84 +31,4 @@ public class WorldEntry { private String name; private WorldGroupEntry worldGroupEntry; private GroupEntry groupEntry; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getCreated() { - return created; - } - - public void setCreated(String created) { - this.created = created; - } - - public int getCreatedBy() { - return createdBy; - } - - public void setCreatedby(int createdBy) { - this.createdBy = createdBy; - } - - public void setUpdated(String updated) { - this.updated = updated; - } - - public String getUpdated() { - return updated; - } - - public int getUpdatedBy() { - return updatedBy; - } - - public void setUpdatedBy(int updatedBy) { - this.updatedBy = updatedBy; - } - - public void setDeleted(String deleted) { - this.deleted = deleted; - } - - public String getDeleted() { - return deleted; - } - - public int getDeletedBy() { - return deletedBy; - } - - public void setDeletedBy(int deletedBy) { - this.deletedBy = deletedBy; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public void setWorldGroup(WorldGroupEntry wge){ - this.worldGroupEntry = wge; - } - - public WorldGroupEntry getWorldGroupEntry(){ - return worldGroupEntry; - } - - public void setBuildGroup(GroupEntry ge){ - this.groupEntry = ge; - } - - public GroupEntry getBuildGroup(){ - return groupEntry; - } } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupEntry.java index 0ee50e8d..227e0b18 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupEntry.java @@ -1,11 +1,16 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.pojo; +import lombok.Getter; +import lombok.Setter; + /** * * @author rellu */ +@Setter +@Getter public class WorldGroupEntry { public static final String FIELD_ID = "id"; @@ -25,68 +30,4 @@ public class WorldGroupEntry { private String deleted; private int deletedBy; private String name; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getCreated() { - return created; - } - - public void setCreated(String created) { - this.created = created; - } - - public int getCreatedBy() { - return createdBy; - } - - public void setCreatedby(int createdBy) { - this.createdBy = createdBy; - } - - public void setUpdated(String updated) { - this.updated = updated; - } - - public String getUpdated() { - return updated; - } - - public int getUpdatedBy() { - return updatedBy; - } - - public void setUpdatedBy(int updatedBy) { - this.updatedBy = updatedBy; - } - - public void setDeleted(String deleted) { - this.deleted = deleted; - } - - public String getDeleted() { - return deleted; - } - - public int getDeletedBy() { - return deletedBy; - } - - public void setDeletedBy(int deletedBy) { - this.deletedBy = deletedBy; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupInventoryEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupInventoryEntry.java index 6682258f..e440cac0 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupInventoryEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupInventoryEntry.java @@ -1,5 +1,7 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.pojo; +import lombok.Getter; +import lombok.Setter; import org.json.JSONObject; /** @@ -7,6 +9,8 @@ * @author rellu */ +@Setter +@Getter public class WorldGroupInventoryEntry { public static final String FIELD_ID = "id"; @@ -30,114 +34,9 @@ public class WorldGroupInventoryEntry { private String deleted; private int deletedBy; private WorldGroupEntry worldGroupEntry; - private int playerFK; + private int playerId; private JSONObject inventory; private double health; - private int food; + private int foodLevel; private int totalExperience; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getCreated() { - return created; - } - - public void setCreated(String created) { - this.created = created; - } - - public int getCreatedBy() { - return createdBy; - } - - public void setCreatedby(int createdBy) { - this.createdBy = createdBy; - } - - public void setUpdated(String updated) { - this.updated = updated; - } - - public String getUpdated() { - return updated; - } - - public int getUpdatedBy() { - return updatedBy; - } - - public void setUpdatedBy(int updatedBy) { - this.updatedBy = updatedBy; - } - - public void setDeleted(String deleted) { - this.deleted = deleted; - } - - public String getDeleted() { - return deleted; - } - - public int getDeletedBy() { - return deletedBy; - } - - public void setDeletedBy(int deletedBy) { - this.deletedBy = deletedBy; - } - - public void setWorldGroup(WorldGroupEntry wge){ - this.worldGroupEntry = wge; - } - - public WorldGroupEntry getWorldGroupEntry(){ - return worldGroupEntry; - } - - public int getPlayerId() { - return playerFK; - } - - public void setPlayerId(int playerId) { - this.playerFK = playerId; - } - - public void setInventory(JSONObject inv){ - this.inventory = inv; - } - - public JSONObject getInventory(){ - return this.inventory; - } - - public int getFoodLevel(){ - return food; - } - - public void setFoodLevel(int level){ - this.food = level; - } - - public int getTotalExperience(){ - return totalExperience; - } - - public void setTotalExperience(int level){ - this.totalExperience = level; - } - - public double getHealth(){ - return health; - } - - public void setHealth(double health){ - this.health = health; - } - } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupSettingEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupSettingEntry.java index bae9901d..26e53a7a 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupSettingEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupSettingEntry.java @@ -1,5 +1,7 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.pojo; +import lombok.Getter; +import lombok.Setter; import org.json.JSONObject; import de.relluem94.rellulib.stores.DoubleStore; @@ -9,6 +11,8 @@ * @author rellu */ +@Setter +@Getter public class WorldGroupSettingEntry { public static final String FIELD_ID = "id"; @@ -28,79 +32,6 @@ public class WorldGroupSettingEntry { private int deletedBy; private String name; private WorldGroupEntry worldGroupEntry; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getCreated() { - return created; - } - - public void setCreated(String created) { - this.created = created; - } - - public int getCreatedBy() { - return createdBy; - } - - public void setCreatedby(int createdBy) { - this.createdBy = createdBy; - } - - public void setUpdated(String updated) { - this.updated = updated; - } - - public String getUpdated() { - return updated; - } - - public int getUpdatedBy() { - return updatedBy; - } - - public void setUpdatedBy(int updatedBy) { - this.updatedBy = updatedBy; - } - - public void setDeleted(String deleted) { - this.deleted = deleted; - } - - public String getDeleted() { - return deleted; - } - - public int getDeletedBy() { - return deletedBy; - } - - public void setDeletedBy(int deletedBy) { - this.deletedBy = deletedBy; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public void setWorldGroup(WorldGroupEntry wge){ - this.worldGroupEntry = wge; - } - - public WorldGroupEntry getWorldGroupEntry(){ - return worldGroupEntry; - } - public void setSetting(int setting){ int settingFK = setting; JSONObject value = null; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/GroupManager.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/GroupManager.java index 9b0a0a09..6f0bebfe 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/GroupManager.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/GroupManager.java @@ -14,7 +14,7 @@ public class GroupManager implements IEnable{ @Override public void enable() { List pel = RelluEssentials.getInstance().getDatabaseHelper().getPlayers(); - pel.forEach(p -> RelluEssentials.getInstance().getPlayerAPI().putPlayerEntry(UUID.fromString(p.getUUID()), p)); + pel.forEach(p -> RelluEssentials.getInstance().getPlayerAPI().putPlayerEntry(UUID.fromString(p.getUuid()), p)); Bukkit.getOnlinePlayers().forEach(p -> { PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); diff --git a/src/test/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentialsTest.java b/src/test/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentialsTest.java index 2ac109c6..545629bf 100644 --- a/src/test/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentialsTest.java +++ b/src/test/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentialsTest.java @@ -84,7 +84,7 @@ public void write(int b) {} */ private static void addPlayerToDB(PlayerMock p, String groupName){ PlayerEntry pe = new PlayerEntry(); - pe.setUUID(p.getUniqueId().toString()); + pe.setUuid(p.getUniqueId().toString()); pe.setName(p.getName()); pe.setCustomName(p.getName()); pe.setGroup(Groups.getGroup(groupName)); diff --git a/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelperTest.java b/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelperTest.java index 781296c7..b70e5ddd 100644 --- a/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelperTest.java +++ b/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelperTest.java @@ -19,7 +19,7 @@ public void testGetOfflinePlayerByName1() { @Test public void testGetOfflinePlayerByName2() { OfflinePlayerEntry ope = PlayerHelper.getOfflinePlayerByName("Relluem94"); - Assert.assertEquals(UUID.fromString("ec0149f9-8b21-44ee-9731-8bff508087e7"), ope.getID()); + Assert.assertEquals(UUID.fromString("ec0149f9-8b21-44ee-9731-8bff508087e7"), ope.getId()); } @Test From 8d4a5c5dbdb56a1035bfd7bb03c24ff105dcf4cd Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Wed, 28 Feb 2024 18:06:40 +0100 Subject: [PATCH 18/36] RE-163 Added Database Mapping --- .../constants/DatabaseMappings.java | 56 ++ .../essentials/helpers/DatabaseHelper.java | 579 +++++++++--------- .../essentials/helpers/pojo/BagEntry.java | 12 - .../essentials/helpers/pojo/BagTypeEntry.java | 7 - .../helpers/pojo/BankAccountEntry.java | 12 - .../helpers/pojo/BankTierEntry.java | 8 - .../helpers/pojo/BankTransactionEntry.java | 11 - .../helpers/pojo/BlockHistoryEntry.java | 10 - .../essentials/helpers/pojo/GroupEntry.java | 8 +- .../helpers/pojo/LocationEntry.java | 12 - .../helpers/pojo/LocationTypeEntry.java | 4 - .../essentials/helpers/pojo/NPCEntry.java | 14 - .../helpers/pojo/OfflinePlayerEntry.java | 1 - .../essentials/helpers/pojo/PlayerEntry.java | 22 +- .../helpers/pojo/PlayerPartnerEntry.java | 12 - .../helpers/pojo/PluginInformationEntry.java | 20 +- .../helpers/pojo/ProtectionEntry.java | 15 +- .../helpers/pojo/ProtectionLockEntry.java | 10 - .../essentials/helpers/pojo/SkillsEntry.java | 9 - .../essentials/helpers/pojo/WorldEntry.java | 10 - .../helpers/pojo/WorldGroupEntry.java | 10 - .../pojo/WorldGroupInventoryEntry.java | 14 - .../helpers/pojo/WorldGroupSettingEntry.java | 9 - 23 files changed, 356 insertions(+), 509 deletions(-) create mode 100644 src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/DatabaseMappings.java diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/DatabaseMappings.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/DatabaseMappings.java new file mode 100644 index 00000000..8f1ae714 --- /dev/null +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/DatabaseMappings.java @@ -0,0 +1,56 @@ +package de.relluem94.minecraft.server.spigot.essentials.constants; + +public class DatabaseMappings { + public static final String FIELD_ID = "id"; + public static final String FIELD_CREATED = "created"; + public static final String FIELD_CREATEDBY = "createdby"; + public static final String FIELD_UPDATED = "updated"; + public static final String FIELD_UPDATEDBY = "updatedby"; + public static final String FIELD_DELETED = "deleted"; + public static final String FIELD_DELETEDBY = "deletedby"; + public static final String FIELD_BAG_TYPE_FK = "bag_type_fk"; + public static final String FIELD_PLAYER_FK = "player_fk"; + public static final String FIELD_SLOT_VAR_VALUE = "slot_%s_value"; + public static final String FIELD_NAME = "name"; + public static final String FIELD_DISPLAY_NAME = "displayname"; + public static final String FIELD_COST = "cost"; + public static final String FIELD_SLOT_VAR_NAME = "slot_%s_name"; + public static final String FIELD_VALUE = "value"; + public static final String FIELD_BANK_TIER_FK = "bank_tier_fk"; + public static final String FIELD_LIMIT = "limit"; + public static final String FIELD_INTEREST = "interest"; + public static final String FIELD_BANK_ACCOUNT_FK = "bank_account_fk"; + public static final String FIELD_MATERIAL = "material"; + public static final String FIELD_PREFIX = "prefix"; + public static final String FIELD_LOCATION_NAME = "location_name"; + public static final String FIELD_WORLD = "world"; + public static final String FIELD_POS_X = "x"; + public static final String FIELD_POS_Y = "y"; + public static final String FIELD_POS_Z = "z"; + public static final String FIELD_YAW = "yaw"; + public static final String FIELD_PITCH = "pitch"; + public static final String FIELD_LOCATION_TYPE_FK = "location_type_fk"; + public static final String FIELD_PROFESSION = "profession"; + public static final String FIELD_TYPE = "type"; + public static final String FIELD_CUSTOM_NAME = "customname"; + public static final String FIELD_PURSE = "purse"; + public static final String FIELD_FLY = "fly"; + public static final String FIELD_AFK = "afk"; + public static final String FIELD_GROUP_FK = "group_fk"; + public static final String FIELD_UUID = "uuid"; + public static final String FIELD_FIRST_PARTNER_FK = "first_partner_fk"; + public static final String FIELD_SECOND_PARTNER_FK = "second_partner_fk"; + public static final String FIELD_SHARE_PROTECTIONS = "shareProtections"; + public static final String FIELD_TAB_HEADER = "tab_header"; + public static final String FIELD_TAB_FOOTER = "tab_footer"; + public static final String FIELD_MOTD_MESSAGE = "motd_message"; + public static final String FIELD_MOTD_PLAYERS = "motd_players"; + public static final String FIELD_DB_VERSION = "db_version"; + public static final String FIELD_FLAGS = "flags"; + public static final String FIELD_RIGHTS = "rights"; + public static final String FIELD_MATERIAL_NAME = "material_name"; + public static final String FIELD_HEALTH = "health"; + public static final String FIELD_TOTAL_EXPERIENCE = "totalExperience"; + public static final String FIELD_FOOD = "food"; + public static final String FIELD_INVENTORY = "inventory"; +} \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java index d7742168..116d6415 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java @@ -21,6 +21,7 @@ import java.util.logging.Level; import java.util.logging.Logger; +import de.relluem94.minecraft.server.spigot.essentials.constants.DatabaseMappings; import de.relluem94.minecraft.server.spigot.essentials.managers.NPCManager; import de.relluem94.minecraft.server.spigot.essentials.npc.NPC; import org.bukkit.Location; @@ -466,16 +467,16 @@ public PlayerPartnerEntry getPlayerPartner(int playerFK) { try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { PlayerPartnerEntry ppe = new PlayerPartnerEntry(); - ppe.setId(rs.getInt(PlayerPartnerEntry.FIELD_ID)); - ppe.setCreated(rs.getString(PlayerPartnerEntry.FIELD_CREATED)); - ppe.setCreatedBy(rs.getInt(PlayerPartnerEntry.FIELD_CREATEDBY)); - ppe.setUpdated(rs.getString(PlayerPartnerEntry.FIELD_UPDATED)); - ppe.setUpdatedBy(rs.getInt(PlayerPartnerEntry.FIELD_UPDATEDBY)); - ppe.setDeleted(rs.getString(PlayerPartnerEntry.FIELD_DELETED)); - ppe.setDeletedBy(rs.getInt(PlayerPartnerEntry.FIELD_DELETEDBY)); - ppe.setFirstPartnerId(rs.getInt(PlayerPartnerEntry.FIELD_FIRST_PARTNER_FK)); - ppe.setSecondPartnerId(rs.getInt(PlayerPartnerEntry.FIELD_SECOND_PARTNER_FK)); - ppe.setShareProtections(rs.getBoolean(PlayerPartnerEntry.FIELD_SHARE_PROTECTIONS)); + ppe.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + ppe.setCreated(rs.getString(DatabaseMappings.FIELD_CREATED)); + ppe.setCreatedBy(rs.getInt(DatabaseMappings.FIELD_CREATEDBY)); + ppe.setUpdated(rs.getString(DatabaseMappings.FIELD_UPDATED)); + ppe.setUpdatedBy(rs.getInt(DatabaseMappings.FIELD_UPDATEDBY)); + ppe.setDeleted(rs.getString(DatabaseMappings.FIELD_DELETED)); + ppe.setDeletedBy(rs.getInt(DatabaseMappings.FIELD_DELETEDBY)); + ppe.setFirstPartnerId(rs.getInt(DatabaseMappings.FIELD_FIRST_PARTNER_FK)); + ppe.setSecondPartnerId(rs.getInt(DatabaseMappings.FIELD_SECOND_PARTNER_FK)); + ppe.setShareProtections(rs.getBoolean(DatabaseMappings.FIELD_SHARE_PROTECTIONS)); return ppe; } @@ -495,14 +496,14 @@ public List getWorldGroups() { try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { WorldGroupEntry wge = new WorldGroupEntry(); - wge.setId(rs.getInt(WorldGroupEntry.FIELD_ID)); - wge.setCreated(rs.getString(WorldGroupEntry.FIELD_CREATED)); - wge.setCreatedBy(rs.getInt(WorldGroupEntry.FIELD_CREATEDBY)); - wge.setUpdated(rs.getString(WorldGroupEntry.FIELD_UPDATED)); - wge.setUpdatedBy(rs.getInt(WorldGroupEntry.FIELD_UPDATEDBY)); - wge.setDeleted(rs.getString(WorldGroupEntry.FIELD_DELETED)); - wge.setDeletedBy(rs.getInt(WorldGroupEntry.FIELD_DELETEDBY)); - wge.setName(rs.getString(WorldGroupEntry.FIELD_NAME)); + wge.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + wge.setCreated(rs.getString(DatabaseMappings.FIELD_CREATED)); + wge.setCreatedBy(rs.getInt(DatabaseMappings.FIELD_CREATEDBY)); + wge.setUpdated(rs.getString(DatabaseMappings.FIELD_UPDATED)); + wge.setUpdatedBy(rs.getInt(DatabaseMappings.FIELD_UPDATEDBY)); + wge.setDeleted(rs.getString(DatabaseMappings.FIELD_DELETED)); + wge.setDeletedBy(rs.getInt(DatabaseMappings.FIELD_DELETEDBY)); + wge.setName(rs.getString(DatabaseMappings.FIELD_NAME)); lbte.add(wge); } @@ -523,14 +524,14 @@ public List getWorldByGroup(WorldGroupEntry wge) { try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { WorldEntry we = new WorldEntry(); - we.setId(rs.getInt(WorldEntry.FIELD_ID)); - we.setCreated(rs.getString(WorldEntry.FIELD_CREATED)); - we.setCreatedBy(rs.getInt(WorldEntry.FIELD_CREATEDBY)); - we.setUpdated(rs.getString(WorldEntry.FIELD_UPDATED)); - we.setUpdatedBy(rs.getInt(WorldEntry.FIELD_UPDATEDBY)); - we.setDeleted(rs.getString(WorldEntry.FIELD_DELETED)); - we.setDeletedBy(rs.getInt(WorldEntry.FIELD_DELETEDBY)); - we.setName(rs.getString(WorldEntry.FIELD_NAME)); + we.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + we.setCreated(rs.getString(DatabaseMappings.FIELD_CREATED)); + we.setCreatedBy(rs.getInt(DatabaseMappings.FIELD_CREATEDBY)); + we.setUpdated(rs.getString(DatabaseMappings.FIELD_UPDATED)); + we.setUpdatedBy(rs.getInt(DatabaseMappings.FIELD_UPDATEDBY)); + we.setDeleted(rs.getString(DatabaseMappings.FIELD_DELETED)); + we.setDeletedBy(rs.getInt(DatabaseMappings.FIELD_DELETEDBY)); + we.setName(rs.getString(DatabaseMappings.FIELD_NAME)); we.setWorldGroupEntry(wge); lwe.add(we); } @@ -589,19 +590,19 @@ public WorldGroupInventoryEntry getWorldGroupInventory(PlayerEntry pe, WorldGrou try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { WorldGroupInventoryEntry wgie = new WorldGroupInventoryEntry(); - wgie.setId(rs.getInt(WorldGroupInventoryEntry.FIELD_ID)); - wgie.setCreated(rs.getString(WorldGroupInventoryEntry.FIELD_CREATED)); - wgie.setCreatedBy(rs.getInt(WorldGroupInventoryEntry.FIELD_CREATEDBY)); - wgie.setUpdated(rs.getString(WorldGroupInventoryEntry.FIELD_UPDATED)); - wgie.setUpdatedBy(rs.getInt(WorldGroupInventoryEntry.FIELD_UPDATEDBY)); - wgie.setDeleted(rs.getString(WorldGroupInventoryEntry.FIELD_DELETED)); - wgie.setDeletedBy(rs.getInt(WorldGroupInventoryEntry.FIELD_DELETEDBY)); - wgie.setPlayerId(rs.getInt(WorldGroupInventoryEntry.FIELD_PLAYER_FK)); - wgie.setHealth(rs.getInt(WorldGroupInventoryEntry.FIELD_HEALTH)); - wgie.setTotalExperience(rs.getInt(WorldGroupInventoryEntry.FIELD_TOTAL_EXPERIENCE)); - wgie.setFoodLevel(rs.getInt(WorldGroupInventoryEntry.FIELD_FOOD)); + wgie.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + wgie.setCreated(rs.getString(DatabaseMappings.FIELD_CREATED)); + wgie.setCreatedBy(rs.getInt(DatabaseMappings.FIELD_CREATEDBY)); + wgie.setUpdated(rs.getString(DatabaseMappings.FIELD_UPDATED)); + wgie.setUpdatedBy(rs.getInt(DatabaseMappings.FIELD_UPDATEDBY)); + wgie.setDeleted(rs.getString(DatabaseMappings.FIELD_DELETED)); + wgie.setDeletedBy(rs.getInt(DatabaseMappings.FIELD_DELETEDBY)); + wgie.setPlayerId(rs.getInt(DatabaseMappings.FIELD_PLAYER_FK)); + wgie.setHealth(rs.getInt(DatabaseMappings.FIELD_HEALTH)); + wgie.setTotalExperience(rs.getInt(DatabaseMappings.FIELD_TOTAL_EXPERIENCE)); + wgie.setFoodLevel(rs.getInt(DatabaseMappings.FIELD_FOOD)); wgie.setWorldGroupEntry(wge); - wgie.setInventory(new JSONObject(rs.getString(WorldGroupInventoryEntry.FIELD_INVENTORY))); + wgie.setInventory(new JSONObject(rs.getString(DatabaseMappings.FIELD_INVENTORY))); return wgie; } @@ -652,14 +653,14 @@ public WorldGroupEntry getWorldGroup(String name) { try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { WorldGroupEntry wge = new WorldGroupEntry(); - wge.setId(rs.getInt(WorldGroupEntry.FIELD_ID)); - wge.setCreated(rs.getString(WorldGroupEntry.FIELD_CREATED)); - wge.setCreatedBy(rs.getInt(WorldGroupEntry.FIELD_CREATEDBY)); - wge.setUpdated(rs.getString(WorldGroupEntry.FIELD_UPDATED)); - wge.setUpdatedBy(rs.getInt(WorldGroupEntry.FIELD_UPDATEDBY)); - wge.setDeleted(rs.getString(WorldGroupEntry.FIELD_DELETED)); - wge.setDeletedBy(rs.getInt(WorldGroupEntry.FIELD_DELETEDBY)); - wge.setName(rs.getString(WorldGroupEntry.FIELD_NAME)); + wge.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + wge.setCreated(rs.getString(DatabaseMappings.FIELD_CREATED)); + wge.setCreatedBy(rs.getInt(DatabaseMappings.FIELD_CREATEDBY)); + wge.setUpdated(rs.getString(DatabaseMappings.FIELD_UPDATED)); + wge.setUpdatedBy(rs.getInt(DatabaseMappings.FIELD_UPDATEDBY)); + wge.setDeleted(rs.getString(DatabaseMappings.FIELD_DELETED)); + wge.setDeletedBy(rs.getInt(DatabaseMappings.FIELD_DELETEDBY)); + wge.setName(rs.getString(DatabaseMappings.FIELD_NAME)); return wge; } @@ -679,15 +680,15 @@ public LocationEntry getLocation(PlayerEntry pe, int type) { try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { LocationEntry le = new LocationEntry(); - le.setId(rs.getInt(LocationEntry.FIELD_ID)); - le.setPlayerId(rs.getInt(LocationEntry.FIELD_PLAYER_FK)); - le.setLocationName(rs.getString(LocationEntry.FIELD_LOCATION_NAME)); - le.setWorld(rs.getString(LocationEntry.FIELD_WORLD)); - le.setX(rs.getFloat(LocationEntry.FIELD_POS_X)); - le.setY(rs.getFloat(LocationEntry.FIELD_POS_Y)); - le.setZ(rs.getFloat(LocationEntry.FIELD_POS_Z)); - le.setPitch(rs.getFloat(LocationEntry.FIELD_PITCH)); - le.setYaw(rs.getFloat(LocationEntry.FIELD_YAW)); + le.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + le.setPlayerId(rs.getInt(DatabaseMappings.FIELD_PLAYER_FK)); + le.setLocationName(rs.getString(DatabaseMappings.FIELD_LOCATION_NAME)); + le.setWorld(rs.getString(DatabaseMappings.FIELD_WORLD)); + le.setX(rs.getFloat(DatabaseMappings.FIELD_POS_X)); + le.setY(rs.getFloat(DatabaseMappings.FIELD_POS_Y)); + le.setZ(rs.getFloat(DatabaseMappings.FIELD_POS_Z)); + le.setPitch(rs.getFloat(DatabaseMappings.FIELD_PITCH)); + le.setYaw(rs.getFloat(DatabaseMappings.FIELD_YAW)); for (LocationTypeEntry lte : RelluEssentials.getInstance().locationTypeEntryList) { if (lte.getId() == type) { le.setLocationType(lte); @@ -711,19 +712,19 @@ public List getLocations(PlayerEntry pe, int type) { ps.execute(); try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { - if (type != rs.getInt(LocationEntry.FIELD_LOCATION_TYPE_FK)) { + if (type != rs.getInt(DatabaseMappings.FIELD_LOCATION_TYPE_FK)) { continue; } LocationEntry le = new LocationEntry(); - le.setId(rs.getInt(LocationEntry.FIELD_ID)); - le.setPlayerId(rs.getInt(LocationEntry.FIELD_PLAYER_FK)); - le.setLocationName(rs.getString(LocationEntry.FIELD_LOCATION_NAME)); - le.setWorld(rs.getString(LocationEntry.FIELD_WORLD)); - le.setX(rs.getFloat(LocationEntry.FIELD_POS_X)); - le.setY(rs.getFloat(LocationEntry.FIELD_POS_Y)); - le.setZ(rs.getFloat(LocationEntry.FIELD_POS_Z)); - le.setPitch(rs.getFloat(LocationEntry.FIELD_PITCH)); - le.setYaw(rs.getFloat(LocationEntry.FIELD_YAW)); + le.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + le.setPlayerId(rs.getInt(DatabaseMappings.FIELD_PLAYER_FK)); + le.setLocationName(rs.getString(DatabaseMappings.FIELD_LOCATION_NAME)); + le.setWorld(rs.getString(DatabaseMappings.FIELD_WORLD)); + le.setX(rs.getFloat(DatabaseMappings.FIELD_POS_X)); + le.setY(rs.getFloat(DatabaseMappings.FIELD_POS_Y)); + le.setZ(rs.getFloat(DatabaseMappings.FIELD_POS_Z)); + le.setPitch(rs.getFloat(DatabaseMappings.FIELD_PITCH)); + le.setYaw(rs.getFloat(DatabaseMappings.FIELD_YAW)); for (LocationTypeEntry lte : RelluEssentials.getInstance().locationTypeEntryList) { if (type == lte.getId()) { le.setLocationType(lte); @@ -750,15 +751,15 @@ public LocationEntry getLocation(Location l, int type) { try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { LocationEntry le = new LocationEntry(); - le.setId(rs.getInt(LocationEntry.FIELD_ID)); - le.setPlayerId(rs.getInt(LocationEntry.FIELD_PLAYER_FK)); - le.setLocationName(rs.getString(LocationEntry.FIELD_LOCATION_NAME)); - le.setWorld(rs.getString(LocationEntry.FIELD_WORLD)); - le.setX(rs.getFloat(LocationEntry.FIELD_POS_X)); - le.setY(rs.getFloat(LocationEntry.FIELD_POS_Y)); - le.setZ(rs.getFloat(LocationEntry.FIELD_POS_Z)); - le.setPitch(rs.getFloat(LocationEntry.FIELD_PITCH)); - le.setYaw(rs.getFloat(LocationEntry.FIELD_YAW)); + le.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + le.setPlayerId(rs.getInt(DatabaseMappings.FIELD_PLAYER_FK)); + le.setLocationName(rs.getString(DatabaseMappings.FIELD_LOCATION_NAME)); + le.setWorld(rs.getString(DatabaseMappings.FIELD_WORLD)); + le.setX(rs.getFloat(DatabaseMappings.FIELD_POS_X)); + le.setY(rs.getFloat(DatabaseMappings.FIELD_POS_Y)); + le.setZ(rs.getFloat(DatabaseMappings.FIELD_POS_Z)); + le.setPitch(rs.getFloat(DatabaseMappings.FIELD_PITCH)); + le.setYaw(rs.getFloat(DatabaseMappings.FIELD_YAW)); for (LocationTypeEntry lte : RelluEssentials.getInstance().locationTypeEntryList) { if (lte.getId() == type) { le.setLocationType(lte); @@ -783,19 +784,19 @@ public LocationEntry getLocation(int id) { try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { LocationEntry le = new LocationEntry(); - le.setId(rs.getInt(LocationEntry.FIELD_ID)); - le.setPlayerId(rs.getInt(LocationEntry.FIELD_PLAYER_FK)); - le.setLocationName(rs.getString(LocationEntry.FIELD_LOCATION_NAME)); + le.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + le.setPlayerId(rs.getInt(DatabaseMappings.FIELD_PLAYER_FK)); + le.setLocationName(rs.getString(DatabaseMappings.FIELD_LOCATION_NAME)); - le.setWorld(rs.getString(LocationEntry.FIELD_WORLD)); - le.setX(rs.getFloat(LocationEntry.FIELD_POS_X)); - le.setY(rs.getFloat(LocationEntry.FIELD_POS_Y)); - le.setZ(rs.getFloat(LocationEntry.FIELD_POS_Z)); - le.setPitch(rs.getFloat(LocationEntry.FIELD_PITCH)); - le.setYaw(rs.getFloat(LocationEntry.FIELD_YAW)); + le.setWorld(rs.getString(DatabaseMappings.FIELD_WORLD)); + le.setX(rs.getFloat(DatabaseMappings.FIELD_POS_X)); + le.setY(rs.getFloat(DatabaseMappings.FIELD_POS_Y)); + le.setZ(rs.getFloat(DatabaseMappings.FIELD_POS_Z)); + le.setPitch(rs.getFloat(DatabaseMappings.FIELD_PITCH)); + le.setYaw(rs.getFloat(DatabaseMappings.FIELD_YAW)); for (LocationTypeEntry lte : RelluEssentials.getInstance().locationTypeEntryList) { - if (lte.getId() == rs.getInt(LocationEntry.FIELD_LOCATION_TYPE_FK)) { + if (lte.getId() == rs.getInt(DatabaseMappings.FIELD_LOCATION_TYPE_FK)) { le.setLocationType(lte); } } @@ -817,14 +818,14 @@ public PluginInformationEntry getPluginInformation() { ps.execute(); try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { - pie.setId(rs.getInt(PluginInformationEntry.FIELD_ID)); - pie.setCreated(rs.getString(PluginInformationEntry.FIELD_CREATED)); - pie.setCreatedby(rs.getInt(PluginInformationEntry.FIELD_CREATEDBY)); - pie.setTabHeader(rs.getString(PluginInformationEntry.FIELD_TAB_HEADER)); - pie.setTabFooter(rs.getString(PluginInformationEntry.FIELD_TAB_FOOTER)); - pie.setMotdMessage(rs.getString(PluginInformationEntry.FIELD_MOTD_MESSAGE)); - pie.setMotdPlayers(rs.getInt(PluginInformationEntry.FIELD_MOTD_PLAYERS)); - pie.setDbVersion(rs.getInt(PluginInformationEntry.FIELD_DB_VERSION)); + pie.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + pie.setCreated(rs.getString(DatabaseMappings.FIELD_CREATED)); + pie.setCreatedBy(rs.getInt(DatabaseMappings.FIELD_CREATEDBY)); + pie.setTabHeader(rs.getString(DatabaseMappings.FIELD_TAB_HEADER)); + pie.setTabFooter(rs.getString(DatabaseMappings.FIELD_TAB_FOOTER)); + pie.setMotdMessage(rs.getString(DatabaseMappings.FIELD_MOTD_MESSAGE)); + pie.setMotdPlayers(rs.getInt(DatabaseMappings.FIELD_MOTD_PLAYERS)); + pie.setDbVersion(rs.getInt(DatabaseMappings.FIELD_DB_VERSION)); return pie; } } @@ -845,21 +846,21 @@ public PlayerEntry getPlayer(String uuid) { try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { PlayerEntry p = new PlayerEntry(); - p.setId(rs.getInt(PlayerEntry.FIELD_ID)); - p.setUuid(rs.getString(PlayerEntry.FIELD_UUID)); - p.setCreated(rs.getString(PlayerEntry.FIELD_CREATED)); - p.setCreatedBy(rs.getInt(PlayerEntry.FIELD_CREATEDBY)); - p.setUpdated(rs.getString(PlayerEntry.FIELD_UPDATED)); - p.setUpdatedBy(rs.getInt(PlayerEntry.FIELD_UPDATEDBY)); - p.setDeleted(rs.getString(PlayerEntry.FIELD_DELETED)); - p.setDeletedBy(rs.getInt(PlayerEntry.FIELD_DELETEDBY)); - p.setName(rs.getString(PlayerEntry.FIELD_NAME)); - p.setCustomName(rs.getString(PlayerEntry.FIELD_CUSTOM_NAME)); - p.setPurse(rs.getDouble(PlayerEntry.FIELD_PURSE)); - p.setFlying(rs.getBoolean(PlayerEntry.FIELD_FLY)); - p.setAfk(rs.getBoolean(PlayerEntry.FIELD_AFK)); - p.setGroup(Groups.getGroup(rs.getInt(PlayerEntry.FIELD_GROUP_FK))); - PlayerPartnerEntry ppe = getPlayerPartner(rs.getInt(PlayerEntry.FIELD_ID)); + p.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + p.setUuid(rs.getString(DatabaseMappings.FIELD_UUID)); + p.setCreated(rs.getString(DatabaseMappings.FIELD_CREATED)); + p.setCreatedBy(rs.getInt(DatabaseMappings.FIELD_CREATEDBY)); + p.setUpdated(rs.getString(DatabaseMappings.FIELD_UPDATED)); + p.setUpdatedBy(rs.getInt(DatabaseMappings.FIELD_UPDATEDBY)); + p.setDeleted(rs.getString(DatabaseMappings.FIELD_DELETED)); + p.setDeletedBy(rs.getInt(DatabaseMappings.FIELD_DELETEDBY)); + p.setName(rs.getString(DatabaseMappings.FIELD_NAME)); + p.setCustomName(rs.getString(DatabaseMappings.FIELD_CUSTOM_NAME)); + p.setPurse(rs.getDouble(DatabaseMappings.FIELD_PURSE)); + p.setFlying(rs.getBoolean(DatabaseMappings.FIELD_FLY)); + p.setAfk(rs.getBoolean(DatabaseMappings.FIELD_AFK)); + p.setGroup(Groups.getGroup(rs.getInt(DatabaseMappings.FIELD_GROUP_FK))); + PlayerPartnerEntry ppe = getPlayerPartner(rs.getInt(DatabaseMappings.FIELD_ID)); p.setHomes(getLocations(p, 1)); p.setDeaths(getLocations(p, 2)); p.setPartner(ppe); @@ -882,16 +883,16 @@ public BankAccountEntry getPlayerBankAccount(int playerFK) { try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { BankAccountEntry bae = new BankAccountEntry(); - bae.setId(rs.getInt(BankAccountEntry.FIELD_ID)); - bae.setCreated(rs.getString(BankAccountEntry.FIELD_CREATED)); - bae.setCreatedBy(rs.getInt(BankAccountEntry.FIELD_CREATEDBY)); - bae.setUpdated(rs.getString(BankAccountEntry.FIELD_UPDATED)); - bae.setUpdatedBy(rs.getInt(BankAccountEntry.FIELD_UPDATEDBY)); - bae.setDeleted(rs.getString(BankAccountEntry.FIELD_DELETED)); - bae.setDeletedBy(rs.getInt(BankAccountEntry.FIELD_DELETEDBY)); - bae.setValue(rs.getDouble(BankAccountEntry.FIELD_VALUE)); - bae.setPlayerId(rs.getInt(BankAccountEntry.FIELD_PLAYER_FK)); - bae.setTier(getBankTier(rs.getInt(BankAccountEntry.FIELD_BANK_TIER_FK))); + bae.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + bae.setCreated(rs.getString(DatabaseMappings.FIELD_CREATED)); + bae.setCreatedBy(rs.getInt(DatabaseMappings.FIELD_CREATEDBY)); + bae.setUpdated(rs.getString(DatabaseMappings.FIELD_UPDATED)); + bae.setUpdatedBy(rs.getInt(DatabaseMappings.FIELD_UPDATEDBY)); + bae.setDeleted(rs.getString(DatabaseMappings.FIELD_DELETED)); + bae.setDeletedBy(rs.getInt(DatabaseMappings.FIELD_DELETEDBY)); + bae.setValue(rs.getDouble(DatabaseMappings.FIELD_VALUE)); + bae.setPlayerId(rs.getInt(DatabaseMappings.FIELD_PLAYER_FK)); + bae.setTier(getBankTier(rs.getInt(DatabaseMappings.FIELD_BANK_TIER_FK))); return bae; } @@ -911,11 +912,11 @@ public BankTierEntry getBankTier(int id) { try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { BankTierEntry bte = new BankTierEntry(); - bte.setId(rs.getInt(BankTierEntry.FIELD_ID)); - bte.setName(rs.getString(BankTierEntry.FIELD_NAME)); - bte.setLimit(rs.getLong(BankTierEntry.FIELD_LIMIT)); - bte.setInterest(rs.getDouble(BankTierEntry.FIELD_INTEREST)); - bte.setCost(rs.getLong(BankTierEntry.FIELD_COST)); + bte.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + bte.setName(rs.getString(DatabaseMappings.FIELD_NAME)); + bte.setLimit(rs.getLong(DatabaseMappings.FIELD_LIMIT)); + bte.setInterest(rs.getDouble(DatabaseMappings.FIELD_INTEREST)); + bte.setCost(rs.getLong(DatabaseMappings.FIELD_COST)); return bte; } } @@ -934,11 +935,11 @@ public List getBankTiers() { try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { BankTierEntry bte = new BankTierEntry(); - bte.setId(rs.getInt(BankTierEntry.FIELD_ID)); - bte.setName(rs.getString(BankTierEntry.FIELD_NAME)); - bte.setLimit(rs.getLong(BankTierEntry.FIELD_LIMIT)); - bte.setInterest(rs.getDouble(BankTierEntry.FIELD_INTEREST)); - bte.setCost(rs.getLong(BankTierEntry.FIELD_COST)); + bte.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + bte.setName(rs.getString(DatabaseMappings.FIELD_NAME)); + bte.setLimit(rs.getLong(DatabaseMappings.FIELD_LIMIT)); + bte.setInterest(rs.getDouble(DatabaseMappings.FIELD_INTEREST)); + bte.setCost(rs.getLong(DatabaseMappings.FIELD_COST)); lbte.add(bte); } } @@ -1009,15 +1010,15 @@ public List getTransactionsToBankFromPlayer(int bankAccoun while (rs.next()) { BankTransactionEntry b = new BankTransactionEntry(); - b.setId(rs.getInt(BankTransactionEntry.FIELD_ID)); - b.setCreated(rs.getString(BankTransactionEntry.FIELD_CREATED)); - b.setCreatedBy(rs.getInt(BankTransactionEntry.FIELD_CREATEDBY)); - b.setUpdated(rs.getString(BankTransactionEntry.FIELD_UPDATED)); - b.setUpdatedBy(rs.getInt(BankTransactionEntry.FIELD_UPDATEDBY)); - b.setDeleted(rs.getString(BankTransactionEntry.FIELD_DELETED)); - b.setDeletedBy(rs.getInt(BankTransactionEntry.FIELD_DELETEDBY)); - b.setBankAccountId(rs.getInt(BankTransactionEntry.FIELD_BANK_ACCOUNT_FK)); - b.setValue(rs.getDouble(BankTransactionEntry.FIELD_VALUE)); + b.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + b.setCreated(rs.getString(DatabaseMappings.FIELD_CREATED)); + b.setCreatedBy(rs.getInt(DatabaseMappings.FIELD_CREATEDBY)); + b.setUpdated(rs.getString(DatabaseMappings.FIELD_UPDATED)); + b.setUpdatedBy(rs.getInt(DatabaseMappings.FIELD_UPDATEDBY)); + b.setDeleted(rs.getString(DatabaseMappings.FIELD_DELETED)); + b.setDeletedBy(rs.getInt(DatabaseMappings.FIELD_DELETEDBY)); + b.setBankAccountId(rs.getInt(DatabaseMappings.FIELD_BANK_ACCOUNT_FK)); + b.setValue(rs.getDouble(DatabaseMappings.FIELD_VALUE)); bte.add(b); } } @@ -1038,16 +1039,16 @@ public ProtectionEntry getProtectionByLocation(Location l) { try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { ProtectionEntry pe = new ProtectionEntry(); - pe.setId(rs.getInt(ProtectionEntry.FIELD_ID)); - pe.setCreated(rs.getString(ProtectionEntry.FIELD_CREATED)); - pe.setCreatedBy(rs.getInt(ProtectionEntry.FIELD_CREATEDBY)); - pe.setUpdated(rs.getString(ProtectionEntry.FIELD_UPDATED)); - pe.setUpdatedBy(rs.getInt(ProtectionEntry.FIELD_UPDATEDBY)); - pe.setDeleted(rs.getString(ProtectionEntry.FIELD_DELETED)); - pe.setDeletedBy(rs.getInt(ProtectionEntry.FIELD_DELETEDBY)); - pe.setFlags(new JSONObject(rs.getString(ProtectionEntry.FIELD_FLAGS))); - pe.setRights(new JSONObject(rs.getString(ProtectionEntry.FIELD_RIGHTS))); - pe.setMaterialName(rs.getString(ProtectionEntry.FIELD_MATERIAL_NAME)); + pe.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + pe.setCreated(rs.getString(DatabaseMappings.FIELD_CREATED)); + pe.setCreatedBy(rs.getInt(DatabaseMappings.FIELD_CREATEDBY)); + pe.setUpdated(rs.getString(DatabaseMappings.FIELD_UPDATED)); + pe.setUpdatedBy(rs.getInt(DatabaseMappings.FIELD_UPDATEDBY)); + pe.setDeleted(rs.getString(DatabaseMappings.FIELD_DELETED)); + pe.setDeletedBy(rs.getInt(DatabaseMappings.FIELD_DELETEDBY)); + pe.setFlags(new JSONObject(rs.getString(DatabaseMappings.FIELD_FLAGS))); + pe.setRights(new JSONObject(rs.getString(DatabaseMappings.FIELD_RIGHTS))); + pe.setMaterialName(rs.getString(DatabaseMappings.FIELD_MATERIAL_NAME)); pe.setLocationEntry(getLocation(l, 5)); return pe; @@ -1132,16 +1133,16 @@ public Map getProtections() { if (loc != null) { ProtectionEntry pe = new ProtectionEntry(); - pe.setId(rs.getInt(ProtectionEntry.FIELD_ID)); - pe.setCreated(rs.getString(ProtectionEntry.FIELD_CREATED)); - pe.setCreatedBy(rs.getInt(ProtectionEntry.FIELD_CREATEDBY)); - pe.setUpdated(rs.getString(ProtectionEntry.FIELD_UPDATED)); - pe.setUpdatedBy(rs.getInt(ProtectionEntry.FIELD_UPDATEDBY)); - pe.setDeleted(rs.getString(ProtectionEntry.FIELD_DELETED)); - pe.setDeletedBy(rs.getInt(ProtectionEntry.FIELD_DELETEDBY)); - pe.setFlags(new JSONObject(rs.getString(ProtectionEntry.FIELD_FLAGS))); - pe.setRights(new JSONObject(rs.getString(ProtectionEntry.FIELD_RIGHTS))); - pe.setMaterialName(rs.getString(ProtectionEntry.FIELD_MATERIAL_NAME)); + pe.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + pe.setCreated(rs.getString(DatabaseMappings.FIELD_CREATED)); + pe.setCreatedBy(rs.getInt(DatabaseMappings.FIELD_CREATEDBY)); + pe.setUpdated(rs.getString(DatabaseMappings.FIELD_UPDATED)); + pe.setUpdatedBy(rs.getInt(DatabaseMappings.FIELD_UPDATEDBY)); + pe.setDeleted(rs.getString(DatabaseMappings.FIELD_DELETED)); + pe.setDeletedBy(rs.getInt(DatabaseMappings.FIELD_DELETEDBY)); + pe.setFlags(new JSONObject(rs.getString(DatabaseMappings.FIELD_FLAGS))); + pe.setRights(new JSONObject(rs.getString(DatabaseMappings.FIELD_RIGHTS))); + pe.setMaterialName(rs.getString(DatabaseMappings.FIELD_MATERIAL_NAME)); pe.setLocationEntry(loc); pel.put(loc.getLocation(), pe); } else { @@ -1166,21 +1167,21 @@ public List getPlayers() { try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { PlayerEntry p = new PlayerEntry(); - p.setId(rs.getInt(PlayerEntry.FIELD_ID)); - p.setUuid(rs.getString(PlayerEntry.FIELD_UUID)); - p.setCreated(rs.getString(PlayerEntry.FIELD_CREATED)); - p.setCreatedBy(rs.getInt(PlayerEntry.FIELD_CREATEDBY)); - p.setUpdated(rs.getString(PlayerEntry.FIELD_UPDATED)); - p.setUpdatedBy(rs.getInt(PlayerEntry.FIELD_UPDATEDBY)); - p.setDeleted(rs.getString(PlayerEntry.FIELD_DELETED)); - p.setDeletedBy(rs.getInt(PlayerEntry.FIELD_DELETEDBY)); - p.setName(rs.getString(PlayerEntry.FIELD_NAME)); - p.setCustomName(rs.getString(PlayerEntry.FIELD_CUSTOM_NAME)); - p.setPurse(rs.getDouble(PlayerEntry.FIELD_PURSE)); - p.setFlying(rs.getBoolean(PlayerEntry.FIELD_FLY)); - p.setAfk(rs.getBoolean(PlayerEntry.FIELD_AFK)); - p.setGroup(Groups.getGroup(rs.getInt(PlayerEntry.FIELD_GROUP_FK))); - PlayerPartnerEntry ppe = getPlayerPartner(rs.getInt(PlayerEntry.FIELD_ID)); + p.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + p.setUuid(rs.getString(DatabaseMappings.FIELD_UUID)); + p.setCreated(rs.getString(DatabaseMappings.FIELD_CREATED)); + p.setCreatedBy(rs.getInt(DatabaseMappings.FIELD_CREATEDBY)); + p.setUpdated(rs.getString(DatabaseMappings.FIELD_UPDATED)); + p.setUpdatedBy(rs.getInt(DatabaseMappings.FIELD_UPDATEDBY)); + p.setDeleted(rs.getString(DatabaseMappings.FIELD_DELETED)); + p.setDeletedBy(rs.getInt(DatabaseMappings.FIELD_DELETEDBY)); + p.setName(rs.getString(DatabaseMappings.FIELD_NAME)); + p.setCustomName(rs.getString(DatabaseMappings.FIELD_CUSTOM_NAME)); + p.setPurse(rs.getDouble(DatabaseMappings.FIELD_PURSE)); + p.setFlying(rs.getBoolean(DatabaseMappings.FIELD_FLY)); + p.setAfk(rs.getBoolean(DatabaseMappings.FIELD_AFK)); + p.setGroup(Groups.getGroup(rs.getInt(DatabaseMappings.FIELD_GROUP_FK))); + PlayerPartnerEntry ppe = getPlayerPartner(rs.getInt(DatabaseMappings.FIELD_ID)); p.setHomes(getLocations(p, 1)); p.setDeaths(getLocations(p, 2)); p.setPartner(ppe); @@ -1273,17 +1274,17 @@ public List getLocations() { while (rs.next()) { LocationEntry le = new LocationEntry(); - le.setId(rs.getInt(LocationEntry.FIELD_ID)); - le.setPlayerId(rs.getInt(LocationEntry.FIELD_PLAYER_FK)); - le.setLocationName(rs.getString(LocationEntry.FIELD_LOCATION_NAME)); - le.setWorld(rs.getString(LocationEntry.FIELD_WORLD)); - le.setX(rs.getFloat(LocationEntry.FIELD_POS_X)); - le.setY(rs.getFloat(LocationEntry.FIELD_POS_Y)); - le.setZ(rs.getFloat(LocationEntry.FIELD_POS_Z)); - le.setPitch(rs.getFloat(LocationEntry.FIELD_PITCH)); - le.setYaw(rs.getFloat(LocationEntry.FIELD_YAW)); + le.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + le.setPlayerId(rs.getInt(DatabaseMappings.FIELD_PLAYER_FK)); + le.setLocationName(rs.getString(DatabaseMappings.FIELD_LOCATION_NAME)); + le.setWorld(rs.getString(DatabaseMappings.FIELD_WORLD)); + le.setX(rs.getFloat(DatabaseMappings.FIELD_POS_X)); + le.setY(rs.getFloat(DatabaseMappings.FIELD_POS_Y)); + le.setZ(rs.getFloat(DatabaseMappings.FIELD_POS_Z)); + le.setPitch(rs.getFloat(DatabaseMappings.FIELD_PITCH)); + le.setYaw(rs.getFloat(DatabaseMappings.FIELD_YAW)); - le.setLocationType(RelluEssentials.getInstance().locationTypeEntryList.get(rs.getInt(LocationEntry.FIELD_LOCATION_TYPE_FK) - 1)); + le.setLocationType(RelluEssentials.getInstance().locationTypeEntryList.get(rs.getInt(DatabaseMappings.FIELD_LOCATION_TYPE_FK) - 1)); ll.add(le); } } @@ -1302,17 +1303,17 @@ public List getWarps() { try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { LocationEntry le = new LocationEntry(); - le.setId(rs.getInt(LocationEntry.FIELD_ID)); - le.setPlayerId(rs.getInt(LocationEntry.FIELD_PLAYER_FK)); - le.setLocationName(rs.getString(LocationEntry.FIELD_LOCATION_NAME)); - le.setWorld(rs.getString(LocationEntry.FIELD_WORLD)); - le.setX(rs.getFloat(LocationEntry.FIELD_POS_X)); - le.setY(rs.getFloat(LocationEntry.FIELD_POS_Y)); - le.setZ(rs.getFloat(LocationEntry.FIELD_POS_Z)); - le.setPitch(rs.getFloat(LocationEntry.FIELD_PITCH)); - le.setYaw(rs.getFloat(LocationEntry.FIELD_YAW)); + le.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + le.setPlayerId(rs.getInt(DatabaseMappings.FIELD_PLAYER_FK)); + le.setLocationName(rs.getString(DatabaseMappings.FIELD_LOCATION_NAME)); + le.setWorld(rs.getString(DatabaseMappings.FIELD_WORLD)); + le.setX(rs.getFloat(DatabaseMappings.FIELD_POS_X)); + le.setY(rs.getFloat(DatabaseMappings.FIELD_POS_Y)); + le.setZ(rs.getFloat(DatabaseMappings.FIELD_POS_Z)); + le.setPitch(rs.getFloat(DatabaseMappings.FIELD_PITCH)); + le.setYaw(rs.getFloat(DatabaseMappings.FIELD_YAW)); - le.setLocationType(RelluEssentials.getInstance().locationTypeEntryList.get(rs.getInt(LocationEntry.FIELD_LOCATION_TYPE_FK) - 1)); + le.setLocationType(RelluEssentials.getInstance().locationTypeEntryList.get(rs.getInt(DatabaseMappings.FIELD_LOCATION_TYPE_FK) - 1)); ll.add(le); } } @@ -1371,27 +1372,27 @@ public BlockHistoryEntry getBlockHistoryByLocation(Location l) { try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { BlockHistoryEntry bh = new BlockHistoryEntry(); - bh.setId(rs.getInt(BlockHistoryEntry.FIELD_ID)); - bh.setCreated(rs.getString(BlockHistoryEntry.FIELD_CREATED)); - bh.setCreatedby(rs.getInt(BlockHistoryEntry.FIELD_CREATEDBY)); - bh.setDeleted(rs.getString(BlockHistoryEntry.FIELD_DELETED)); - bh.setDeletedby(rs.getInt(BlockHistoryEntry.FIELD_DELETEDBY)); + bh.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + bh.setCreated(rs.getString(DatabaseMappings.FIELD_CREATED)); + bh.setCreatedby(rs.getInt(DatabaseMappings.FIELD_CREATEDBY)); + bh.setDeleted(rs.getString(DatabaseMappings.FIELD_DELETED)); + bh.setDeletedby(rs.getInt(DatabaseMappings.FIELD_DELETEDBY)); LocationEntry le = new LocationEntry(); - le.setId(rs.getInt(LocationEntry.FIELD_ID)); - le.setPlayerId(rs.getInt(LocationEntry.FIELD_PLAYER_FK)); - le.setLocationName(rs.getString(LocationEntry.FIELD_LOCATION_NAME)); - le.setWorld(rs.getString(LocationEntry.FIELD_WORLD)); - le.setX(rs.getFloat(LocationEntry.FIELD_POS_X)); - le.setY(rs.getFloat(LocationEntry.FIELD_POS_Y)); - le.setZ(rs.getFloat(LocationEntry.FIELD_POS_Z)); - le.setPitch(rs.getFloat(LocationEntry.FIELD_PITCH)); - le.setYaw(rs.getFloat(LocationEntry.FIELD_YAW)); + le.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + le.setPlayerId(rs.getInt(DatabaseMappings.FIELD_PLAYER_FK)); + le.setLocationName(rs.getString(DatabaseMappings.FIELD_LOCATION_NAME)); + le.setWorld(rs.getString(DatabaseMappings.FIELD_WORLD)); + le.setX(rs.getFloat(DatabaseMappings.FIELD_POS_X)); + le.setY(rs.getFloat(DatabaseMappings.FIELD_POS_Y)); + le.setZ(rs.getFloat(DatabaseMappings.FIELD_POS_Z)); + le.setPitch(rs.getFloat(DatabaseMappings.FIELD_PITCH)); + le.setYaw(rs.getFloat(DatabaseMappings.FIELD_YAW)); - le.setLocationType(RelluEssentials.getInstance().locationTypeEntryList.get(rs.getInt(LocationEntry.FIELD_LOCATION_TYPE_FK) - 1)); + le.setLocationType(RelluEssentials.getInstance().locationTypeEntryList.get(rs.getInt(DatabaseMappings.FIELD_LOCATION_TYPE_FK) - 1)); bh.setLocation(le); - bh.setMaterial(rs.getString(BlockHistoryEntry.FIELD_MATERIAL)); + bh.setMaterial(rs.getString(DatabaseMappings.FIELD_MATERIAL)); return bh; } } @@ -1428,28 +1429,28 @@ public List getBlockHistoryByPlayer(PlayerEntry p) { try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { BlockHistoryEntry bh = new BlockHistoryEntry(); - bh.setId(rs.getInt(BlockHistoryEntry.FIELD_ID)); - bh.setCreated(rs.getString(BlockHistoryEntry.FIELD_CREATED)); - bh.setCreatedby(rs.getInt(BlockHistoryEntry.FIELD_CREATEDBY)); - bh.setDeleted(rs.getString(BlockHistoryEntry.FIELD_DELETED)); - bh.setDeletedby(rs.getInt(BlockHistoryEntry.FIELD_DELETEDBY)); + bh.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + bh.setCreated(rs.getString(DatabaseMappings.FIELD_CREATED)); + bh.setCreatedby(rs.getInt(DatabaseMappings.FIELD_CREATEDBY)); + bh.setDeleted(rs.getString(DatabaseMappings.FIELD_DELETED)); + bh.setDeletedby(rs.getInt(DatabaseMappings.FIELD_DELETEDBY)); LocationEntry le = new LocationEntry(); - le.setId(rs.getInt(LocationEntry.FIELD_ID)); - le.setPlayerId(rs.getInt(LocationEntry.FIELD_PLAYER_FK)); - le.setLocationName(rs.getString(LocationEntry.FIELD_LOCATION_NAME)); - le.setWorld(rs.getString(LocationEntry.FIELD_WORLD)); - le.setX(rs.getFloat(LocationEntry.FIELD_POS_X)); - le.setY(rs.getFloat(LocationEntry.FIELD_POS_Y)); - le.setZ(rs.getFloat(LocationEntry.FIELD_POS_Z)); - le.setPitch(rs.getFloat(LocationEntry.FIELD_PITCH)); - le.setYaw(rs.getFloat(LocationEntry.FIELD_YAW)); + le.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + le.setPlayerId(rs.getInt(DatabaseMappings.FIELD_PLAYER_FK)); + le.setLocationName(rs.getString(DatabaseMappings.FIELD_LOCATION_NAME)); + le.setWorld(rs.getString(DatabaseMappings.FIELD_WORLD)); + le.setX(rs.getFloat(DatabaseMappings.FIELD_POS_X)); + le.setY(rs.getFloat(DatabaseMappings.FIELD_POS_Y)); + le.setZ(rs.getFloat(DatabaseMappings.FIELD_POS_Z)); + le.setPitch(rs.getFloat(DatabaseMappings.FIELD_PITCH)); + le.setYaw(rs.getFloat(DatabaseMappings.FIELD_YAW)); - le.setLocationType(RelluEssentials.getInstance().locationTypeEntryList.get(rs.getInt(LocationEntry.FIELD_LOCATION_TYPE_FK) - 1)); + le.setLocationType(RelluEssentials.getInstance().locationTypeEntryList.get(rs.getInt(DatabaseMappings.FIELD_LOCATION_TYPE_FK) - 1)); bh.setLocation(le); - bh.setMaterial(rs.getString(BlockHistoryEntry.FIELD_MATERIAL)); + bh.setMaterial(rs.getString(DatabaseMappings.FIELD_MATERIAL)); bhe.add(bh); } } @@ -1502,28 +1503,28 @@ public List getBlockHistoryByPlayerAndTime(PlayerEntry p, Str try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { BlockHistoryEntry bh = new BlockHistoryEntry(); - bh.setId(rs.getInt(BlockHistoryEntry.FIELD_ID)); - bh.setCreated(rs.getString(BlockHistoryEntry.FIELD_CREATED)); - bh.setCreatedby(rs.getInt(BlockHistoryEntry.FIELD_CREATEDBY)); - bh.setDeleted(rs.getString(BlockHistoryEntry.FIELD_DELETED)); - bh.setDeletedby(rs.getInt(BlockHistoryEntry.FIELD_DELETEDBY)); + bh.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + bh.setCreated(rs.getString(DatabaseMappings.FIELD_CREATED)); + bh.setCreatedby(rs.getInt(DatabaseMappings.FIELD_CREATEDBY)); + bh.setDeleted(rs.getString(DatabaseMappings.FIELD_DELETED)); + bh.setDeletedby(rs.getInt(DatabaseMappings.FIELD_DELETEDBY)); LocationEntry le = new LocationEntry(); - le.setId(rs.getInt(LocationEntry.FIELD_ID)); - le.setPlayerId(rs.getInt(LocationEntry.FIELD_PLAYER_FK)); - le.setLocationName(rs.getString(LocationEntry.FIELD_LOCATION_NAME)); - le.setWorld(rs.getString(LocationEntry.FIELD_WORLD)); - le.setX(rs.getFloat(LocationEntry.FIELD_POS_X)); - le.setY(rs.getFloat(LocationEntry.FIELD_POS_Y)); - le.setZ(rs.getFloat(LocationEntry.FIELD_POS_Z)); - le.setPitch(rs.getFloat(LocationEntry.FIELD_PITCH)); - le.setYaw(rs.getFloat(LocationEntry.FIELD_YAW)); + le.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + le.setPlayerId(rs.getInt(DatabaseMappings.FIELD_PLAYER_FK)); + le.setLocationName(rs.getString(DatabaseMappings.FIELD_LOCATION_NAME)); + le.setWorld(rs.getString(DatabaseMappings.FIELD_WORLD)); + le.setX(rs.getFloat(DatabaseMappings.FIELD_POS_X)); + le.setY(rs.getFloat(DatabaseMappings.FIELD_POS_Y)); + le.setZ(rs.getFloat(DatabaseMappings.FIELD_POS_Z)); + le.setPitch(rs.getFloat(DatabaseMappings.FIELD_PITCH)); + le.setYaw(rs.getFloat(DatabaseMappings.FIELD_YAW)); - le.setLocationType(RelluEssentials.getInstance().locationTypeEntryList.get(rs.getInt(LocationEntry.FIELD_LOCATION_TYPE_FK) - 1)); + le.setLocationType(RelluEssentials.getInstance().locationTypeEntryList.get(rs.getInt(DatabaseMappings.FIELD_LOCATION_TYPE_FK) - 1)); bh.setLocation(le); - bh.setMaterial(rs.getString(BlockHistoryEntry.FIELD_MATERIAL)); + bh.setMaterial(rs.getString(DatabaseMappings.FIELD_MATERIAL)); bhe.add(bh); } } @@ -1555,9 +1556,9 @@ public List getGroups() { try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { GroupEntry g = new GroupEntry(); - g.setId(rs.getInt(GroupEntry.FIELD_ID)); - g.setName(rs.getString(GroupEntry.FIELD_NAME)); - g.setPrefix(rs.getString(GroupEntry.FIELD_PREFIX)); + g.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + g.setName(rs.getString(DatabaseMappings.FIELD_NAME)); + g.setPrefix(rs.getString(DatabaseMappings.FIELD_PREFIX)); gel.add(g); } } @@ -1577,13 +1578,13 @@ public BagTypeEntry getBagType(int type) { while (rs.next()) { BagTypeEntry bte = new BagTypeEntry(); - bte.setId(rs.getInt(BagTypeEntry.FIELD_ID)); - bte.setDisplayName(rs.getString(BagTypeEntry.FIELD_DISPLAY_NAME)); - bte.setName(rs.getString(BagTypeEntry.FIELD_NAME)); - bte.setCost(rs.getInt(BagTypeEntry.FIELD_COST)); + bte.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + bte.setDisplayName(rs.getString(DatabaseMappings.FIELD_DISPLAY_NAME)); + bte.setName(rs.getString(DatabaseMappings.FIELD_NAME)); + bte.setCost(rs.getInt(DatabaseMappings.FIELD_COST)); for (int i = 0; i <= BagHelper.BAG_SIZE-1; i++) { - bte.setSlotName(i, rs.getString(String.format(BagTypeEntry.FIELD_SLOT_VAR_NAME, (i + 1)))); + bte.setSlotName(i, rs.getString(String.format(DatabaseMappings.FIELD_SLOT_VAR_NAME, (i + 1)))); } return bte; } @@ -1604,19 +1605,19 @@ public BagEntry getBag(int type, int playerFK) { try (ResultSet rs = ps.getResultSet()) { while (rs.next()) { BagEntry be = new BagEntry(); - be.setId(rs.getInt(BagEntry.FIELD_ID)); - be.setCreated(rs.getString(BagEntry.FIELD_CREATED)); - be.setCreatedBy(rs.getInt(BagEntry.FIELD_CREATEDBY)); - be.setUpdated(rs.getString(BagEntry.FIELD_UPDATED)); - be.setUpdatedBy(rs.getInt(BagEntry.FIELD_UPDATEDBY)); - be.setDeleted(rs.getString(BagEntry.FIELD_DELETED)); - be.setDeletedBy(rs.getInt(BagEntry.FIELD_DELETEDBY)); - be.setPlayerId(rs.getInt(BagEntry.FIELD_PLAYER_FK)); - be.setBagTypeId(rs.getInt(BagEntry.FIELD_BAG_TYPE_FK)); - be.setBagType(getBagType(rs.getInt(BagEntry.FIELD_BAG_TYPE_FK))); + be.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + be.setCreated(rs.getString(DatabaseMappings.FIELD_CREATED)); + be.setCreatedBy(rs.getInt(DatabaseMappings.FIELD_CREATEDBY)); + be.setUpdated(rs.getString(DatabaseMappings.FIELD_UPDATED)); + be.setUpdatedBy(rs.getInt(DatabaseMappings.FIELD_UPDATEDBY)); + be.setDeleted(rs.getString(DatabaseMappings.FIELD_DELETED)); + be.setDeletedBy(rs.getInt(DatabaseMappings.FIELD_DELETEDBY)); + be.setPlayerId(rs.getInt(DatabaseMappings.FIELD_PLAYER_FK)); + be.setBagTypeId(rs.getInt(DatabaseMappings.FIELD_BAG_TYPE_FK)); + be.setBagType(getBagType(rs.getInt(DatabaseMappings.FIELD_BAG_TYPE_FK))); for (int i = 0; i <= BagHelper.BAG_SIZE-1; i++) { - be.setSlotValue(i, rs.getInt(String.format(BagEntry.FIELD_SLOT_VAR_VALUE, (i + 1)))); + be.setSlotValue(i, rs.getInt(String.format(DatabaseMappings.FIELD_SLOT_VAR_VALUE, (i + 1)))); } return be; @@ -1659,7 +1660,7 @@ public List getBagTypes() { bte.setCost(rs.getInt("cost")); for (int i = 0; i <= BagHelper.BAG_SIZE-1; i++) { - bte.setSlotName(i, rs.getString(String.format(BagTypeEntry.FIELD_SLOT_VAR_NAME, (i + 1)))); + bte.setSlotName(i, rs.getString(String.format(DatabaseMappings.FIELD_SLOT_VAR_NAME, (i + 1)))); } btel.add(bte); @@ -1682,19 +1683,19 @@ public List getBags() { while (rs.next()) { BagEntry be = new BagEntry(); - be.setId(rs.getInt(BagEntry.FIELD_ID)); - be.setCreated(rs.getString(BagEntry.FIELD_CREATED)); - be.setCreatedBy(rs.getInt(BagEntry.FIELD_CREATEDBY)); - be.setUpdated(rs.getString(BagEntry.FIELD_UPDATED)); - be.setUpdatedBy(rs.getInt(BagEntry.FIELD_UPDATEDBY)); - be.setDeleted(rs.getString(BagEntry.FIELD_DELETED)); - be.setDeletedBy(rs.getInt(BagEntry.FIELD_DELETEDBY)); - be.setPlayerId(rs.getInt(BagEntry.FIELD_PLAYER_FK)); - be.setBagTypeId(rs.getInt(BagEntry.FIELD_BAG_TYPE_FK)); - be.setBagType(getBagType(rs.getInt(BagEntry.FIELD_BAG_TYPE_FK))); + be.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + be.setCreated(rs.getString(DatabaseMappings.FIELD_CREATED)); + be.setCreatedBy(rs.getInt(DatabaseMappings.FIELD_CREATEDBY)); + be.setUpdated(rs.getString(DatabaseMappings.FIELD_UPDATED)); + be.setUpdatedBy(rs.getInt(DatabaseMappings.FIELD_UPDATEDBY)); + be.setDeleted(rs.getString(DatabaseMappings.FIELD_DELETED)); + be.setDeletedBy(rs.getInt(DatabaseMappings.FIELD_DELETEDBY)); + be.setPlayerId(rs.getInt(DatabaseMappings.FIELD_PLAYER_FK)); + be.setBagTypeId(rs.getInt(DatabaseMappings.FIELD_BAG_TYPE_FK)); + be.setBagType(getBagType(rs.getInt(DatabaseMappings.FIELD_BAG_TYPE_FK))); for (int i = 0; i <= BagHelper.BAG_SIZE-1; i++) { - be.setSlotValue(i, rs.getInt(String.format(BagEntry.FIELD_SLOT_VAR_VALUE, (i + 1)))); + be.setSlotValue(i, rs.getInt(String.format(DatabaseMappings.FIELD_SLOT_VAR_VALUE, (i + 1)))); } bel.add(be); @@ -1736,20 +1737,20 @@ public List getNPCs() { while (rs.next()) { NPCEntry be = new NPCEntry(); - be.setId(rs.getInt(NPCEntry.FIELD_ID)); - be.setCreated(rs.getString(NPCEntry.FIELD_CREATED)); - be.setCreatedBy(rs.getInt(NPCEntry.FIELD_CREATEDBY)); - be.setUpdated(rs.getString(NPCEntry.FIELD_UPDATED)); - be.setUpdatedBy(rs.getInt(NPCEntry.FIELD_UPDATEDBY)); - be.setDeleted(rs.getString(NPCEntry.FIELD_DELETED)); - be.setDeletedBy(rs.getInt(NPCEntry.FIELD_DELETEDBY)); + be.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + be.setCreated(rs.getString(DatabaseMappings.FIELD_CREATED)); + be.setCreatedBy(rs.getInt(DatabaseMappings.FIELD_CREATEDBY)); + be.setUpdated(rs.getString(DatabaseMappings.FIELD_UPDATED)); + be.setUpdatedBy(rs.getInt(DatabaseMappings.FIELD_UPDATEDBY)); + be.setDeleted(rs.getString(DatabaseMappings.FIELD_DELETED)); + be.setDeletedBy(rs.getInt(DatabaseMappings.FIELD_DELETEDBY)); - be.setName(rs.getString(NPCEntry.FIELD_NAME)); - be.setProfession(Villager.Profession.valueOf(rs.getString(NPCEntry.FIELD_PROFESSION))); - be.setType(NPC.Type.valueOf(rs.getString(NPCEntry.FIELD_TYPE))); + be.setName(rs.getString(DatabaseMappings.FIELD_NAME)); + be.setProfession(Villager.Profession.valueOf(rs.getString(DatabaseMappings.FIELD_PROFESSION))); + be.setType(NPC.Type.valueOf(rs.getString(DatabaseMappings.FIELD_TYPE))); for (int i = 0; i <= 27; i++) { - be.setSlotName(i, rs.getString(String.format(NPCEntry.FIELD_SLOT_VAR_NAME, (i + 1)))); + be.setSlotName(i, rs.getString(String.format(DatabaseMappings.FIELD_SLOT_VAR_NAME, (i + 1)))); } bel.add(be); @@ -1772,14 +1773,14 @@ public List getProtectionLocks() { while (rs.next()) { ProtectionLockEntry be = new ProtectionLockEntry(); - be.setId(rs.getInt(ProtectionLockEntry.FIELD_ID)); - be.setCreated(rs.getString(ProtectionLockEntry.FIELD_CREATED)); - be.setCreatedBy(rs.getInt(ProtectionLockEntry.FIELD_CREATEDBY)); - be.setUpdated(rs.getString(ProtectionLockEntry.FIELD_UPDATED)); - be.setUpdatedBy(rs.getInt(ProtectionLockEntry.FIELD_UPDATEDBY)); - be.setDeleted(rs.getString(ProtectionLockEntry.FIELD_DELETED)); - be.setDeletedBy(rs.getInt(ProtectionLockEntry.FIELD_DELETEDBY)); - be.setValue(Material.getMaterial(rs.getString(ProtectionLockEntry.FIELD_VALUE))); + be.setId(rs.getInt(DatabaseMappings.FIELD_ID)); + be.setCreated(rs.getString(DatabaseMappings.FIELD_CREATED)); + be.setCreatedBy(rs.getInt(DatabaseMappings.FIELD_CREATEDBY)); + be.setUpdated(rs.getString(DatabaseMappings.FIELD_UPDATED)); + be.setUpdatedBy(rs.getInt(DatabaseMappings.FIELD_UPDATEDBY)); + be.setDeleted(rs.getString(DatabaseMappings.FIELD_DELETED)); + be.setDeletedBy(rs.getInt(DatabaseMappings.FIELD_DELETEDBY)); + be.setValue(Material.getMaterial(rs.getString(DatabaseMappings.FIELD_VALUE))); bel.add(be); } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BagEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BagEntry.java index 67e1c8ce..5a47b32b 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BagEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BagEntry.java @@ -12,18 +12,6 @@ @Setter @Getter public class BagEntry { - - public static final String FIELD_ID = "id"; - public static final String FIELD_CREATED = "created"; - public static final String FIELD_CREATEDBY = "createdby"; - public static final String FIELD_UPDATED = "updated"; - public static final String FIELD_UPDATEDBY = "updatedby"; - public static final String FIELD_DELETED = "deleted"; - public static final String FIELD_DELETEDBY = "deletedby"; - public static final String FIELD_BAG_TYPE_FK = "bag_type_fk"; - public static final String FIELD_PLAYER_FK = "player_fk"; - public static final String FIELD_SLOT_VAR_VALUE = "slot_%s_value"; - private int id; private String created; private int createdBy; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BagTypeEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BagTypeEntry.java index 77b080d4..f5b47b45 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BagTypeEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BagTypeEntry.java @@ -12,13 +12,6 @@ @Getter @Setter public class BagTypeEntry { - - public static final String FIELD_ID = "id"; - public static final String FIELD_NAME = "name"; - public static final String FIELD_DISPLAY_NAME = "displayname"; - public static final String FIELD_COST = "cost"; - public static final String FIELD_SLOT_VAR_NAME = "slot_%s_name"; - private int id; private String displayName; private String name; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankAccountEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankAccountEntry.java index 54837053..354ceb66 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankAccountEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankAccountEntry.java @@ -10,18 +10,6 @@ @Setter @Getter public class BankAccountEntry { - - public static final String FIELD_ID = "id"; - public static final String FIELD_CREATED = "created"; - public static final String FIELD_CREATEDBY = "createdby"; - public static final String FIELD_UPDATED = "updated"; - public static final String FIELD_UPDATEDBY = "updatedby"; - public static final String FIELD_DELETED = "deleted"; - public static final String FIELD_DELETEDBY = "deletedby"; - public static final String FIELD_VALUE = "value"; - public static final String FIELD_PLAYER_FK = "player_fk"; - public static final String FIELD_BANK_TIER_FK = "bank_tier_fk"; - private int id; private String created; private int createdBy; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankTierEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankTierEntry.java index 5ffa69ef..81b8c14c 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankTierEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankTierEntry.java @@ -10,14 +10,6 @@ @Setter @Getter public class BankTierEntry { - - public static final String FIELD_ID = "id"; - public static final String FIELD_NAME = "name"; - public static final String FIELD_LIMIT = "limit"; - public static final String FIELD_INTEREST = "interest"; - public static final String FIELD_COST = "cost"; - - private int id; private String name; private long limit; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankTransactionEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankTransactionEntry.java index 329be02d..0e1023dd 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankTransactionEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BankTransactionEntry.java @@ -10,17 +10,6 @@ @Setter @Getter public class BankTransactionEntry { - - public static final String FIELD_ID = "id"; - public static final String FIELD_CREATED = "created"; - public static final String FIELD_CREATEDBY = "createdby"; - public static final String FIELD_UPDATED = "updated"; - public static final String FIELD_UPDATEDBY = "updatedby"; - public static final String FIELD_DELETED = "deleted"; - public static final String FIELD_DELETEDBY = "deletedby"; - public static final String FIELD_BANK_ACCOUNT_FK = "bank_account_fk"; - public static final String FIELD_VALUE = "value"; - private int id; private String created; private int createdBy; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BlockHistoryEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BlockHistoryEntry.java index 7f1cdf4a..4fa8227a 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BlockHistoryEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/BlockHistoryEntry.java @@ -10,16 +10,6 @@ @Setter @Getter public class BlockHistoryEntry { - - public static final String FIELD_ID = "id"; - public static final String FIELD_CREATED = "created"; - public static final String FIELD_CREATEDBY = "createdby"; - public static final String FIELD_UPDATED = "updated"; - public static final String FIELD_UPDATEDBY = "updatedby"; - public static final String FIELD_DELETED = "deleted"; - public static final String FIELD_DELETEDBY = "deletedby"; - public static final String FIELD_MATERIAL = "material"; - private int id; private LocationEntry location; private String material; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/GroupEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/GroupEntry.java index 0a73154d..82ae46d1 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/GroupEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/GroupEntry.java @@ -10,17 +10,11 @@ @Setter @Getter public class GroupEntry { - - public static final String FIELD_ID = "id"; - public static final String FIELD_NAME = "name"; - public static final String FIELD_PREFIX = "prefix"; - private int id; private String name; private String prefix; - public GroupEntry() { - } + public GroupEntry() {} public GroupEntry(int id, String name, String prefix) { this.id = id; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/LocationEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/LocationEntry.java index 2051a9dd..458f2e3d 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/LocationEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/LocationEntry.java @@ -14,18 +14,6 @@ @Setter @Getter public class LocationEntry { - - public static final String FIELD_ID = "id"; - public static final String FIELD_PLAYER_FK = "player_fk"; - public static final String FIELD_LOCATION_NAME = "location_name"; - public static final String FIELD_WORLD = "world"; - public static final String FIELD_POS_X = "x"; - public static final String FIELD_POS_Y = "y"; - public static final String FIELD_POS_Z = "z"; - public static final String FIELD_YAW = "yaw"; - public static final String FIELD_PITCH = "pitch"; - public static final String FIELD_LOCATION_TYPE_FK = "location_type_fk"; - private int id; private String world; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/LocationTypeEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/LocationTypeEntry.java index bb15a3da..316fe7ff 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/LocationTypeEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/LocationTypeEntry.java @@ -10,10 +10,6 @@ @Setter @Getter public class LocationTypeEntry { - - public static final String FIELD_ID = "id"; - public static final String FIELD_TYPE = "location_type_fk"; - private int id; private String type; } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/NPCEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/NPCEntry.java index 13bf988c..bd3f26b0 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/NPCEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/NPCEntry.java @@ -15,20 +15,6 @@ @Setter @Getter public class NPCEntry { - - public static final String FIELD_ID = "id"; - public static final String FIELD_CREATED = "created"; - public static final String FIELD_CREATEDBY = "createdby"; - public static final String FIELD_UPDATED = "updated"; - public static final String FIELD_UPDATEDBY = "updatedby"; - public static final String FIELD_DELETED = "deleted"; - public static final String FIELD_DELETEDBY = "deletedby"; - public static final String FIELD_NAME = "name"; - public static final String FIELD_PROFESSION = "profession"; - public static final String FIELD_TYPE = "type"; - - public static final String FIELD_SLOT_VAR_NAME = "slot_%s_name"; - private int id; private String created; private int createdBy; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/OfflinePlayerEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/OfflinePlayerEntry.java index 98d53db4..8eeeb30a 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/OfflinePlayerEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/OfflinePlayerEntry.java @@ -13,7 +13,6 @@ @Setter @Getter public class OfflinePlayerEntry { - private UUID id; private String name; private Properties properties; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PlayerEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PlayerEntry.java index fcac9260..419f477c 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PlayerEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PlayerEntry.java @@ -14,22 +14,6 @@ @Setter @Getter public class PlayerEntry { - - public static final String FIELD_ID = "id"; - public static final String FIELD_CREATED = "created"; - public static final String FIELD_CREATEDBY = "createdby"; - public static final String FIELD_UPDATED = "updated"; - public static final String FIELD_UPDATEDBY = "updatedby"; - public static final String FIELD_DELETED = "deleted"; - public static final String FIELD_DELETEDBY = "deletedby"; - public static final String FIELD_NAME = "name"; - public static final String FIELD_CUSTOM_NAME = "customname"; - public static final String FIELD_PURSE = "purse"; - public static final String FIELD_FLY = "fly"; - public static final String FIELD_AFK = "afk"; - public static final String FIELD_GROUP_FK = "group_fk"; - public static final String FIELD_UUID = "uuid"; - private int id; private String created; private int createdBy; @@ -67,11 +51,15 @@ public PlayerEntry(PlayerEntry pe){ setUuid(pe.getUuid()); setGroup(pe.getGroup()); setAfk(pe.isAfk()); - + setName(pe.getName()); + setCustomName(pe.getCustomName()); + setHasToBeUpdated(pe.isHasToBeUpdated()); + setDeaths(pe.getDeaths()); setFlying(pe.isFlying()); setHomes(pe.getHomes()); setId(pe.getId()); setPlayerState(pe.getPlayerState()); setPlayerStateParameter(pe.getPlayerStateParameter()); + setPartner(pe.getPartner()); } } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PlayerPartnerEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PlayerPartnerEntry.java index d68c6bb6..6db8b0f5 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PlayerPartnerEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PlayerPartnerEntry.java @@ -10,18 +10,6 @@ @Setter @Getter public class PlayerPartnerEntry { - - public static final String FIELD_ID = "id"; - public static final String FIELD_CREATED = "created"; - public static final String FIELD_CREATEDBY = "createdby"; - public static final String FIELD_UPDATED = "updated"; - public static final String FIELD_UPDATEDBY = "updatedby"; - public static final String FIELD_DELETED = "deleted"; - public static final String FIELD_DELETEDBY = "deletedby"; - public static final String FIELD_FIRST_PARTNER_FK = "first_partner_fk"; - public static final String FIELD_SECOND_PARTNER_FK = "second_partner_fk"; - public static final String FIELD_SHARE_PROTECTIONS = "shareProtections"; - private int id; private String created; private int createdBy; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PluginInformationEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PluginInformationEntry.java index f88860ae..2c7e5fba 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PluginInformationEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/PluginInformationEntry.java @@ -10,27 +10,13 @@ @Setter @Getter public class PluginInformationEntry { - - public static final String FIELD_ID = "id"; - public static final String FIELD_CREATED = "created"; - public static final String FIELD_CREATEDBY = "createdby"; - public static final String FIELD_UPDATED = "updated"; - public static final String FIELD_UPDATEDBY = "updatedby"; - public static final String FIELD_DELETED = "deleted"; - public static final String FIELD_DELETEDBY = "deletedby"; - public static final String FIELD_TAB_HEADER = "tab_header"; - public static final String FIELD_TAB_FOOTER = "tab_footer"; - public static final String FIELD_MOTD_MESSAGE = "motd_message"; - public static final String FIELD_MOTD_PLAYERS = "motd_players"; - public static final String FIELD_DB_VERSION = "db_version"; - private int id; private String created; - private int createdby; + private int createdBy; private String updated; - private int updatedby; + private int updatedBy; private String deleted; - private int deletedby; + private int deletedBy; private String tabHeader; private String tabFooter; private String motdMessage; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/ProtectionEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/ProtectionEntry.java index faf7a0c4..749ef0a6 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/ProtectionEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/ProtectionEntry.java @@ -11,18 +11,6 @@ @Setter @Getter public class ProtectionEntry { - - public static final String FIELD_ID = "id"; - public static final String FIELD_CREATED = "created"; - public static final String FIELD_CREATEDBY = "createdby"; - public static final String FIELD_UPDATED = "updated"; - public static final String FIELD_UPDATEDBY = "updatedby"; - public static final String FIELD_DELETED = "deleted"; - public static final String FIELD_DELETEDBY = "deletedby"; - public static final String FIELD_FLAGS = "flags"; - public static final String FIELD_RIGHTS = "rights"; - public static final String FIELD_MATERIAL_NAME = "material_name"; - private int id; private String created; private int createdBy; @@ -32,7 +20,6 @@ public class ProtectionEntry { private int deletedBy; private LocationEntry locationEntry; private String materialName; - private JSONObject flags; private JSONObject rights; -} +} \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/ProtectionLockEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/ProtectionLockEntry.java index 391d5b22..e4694906 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/ProtectionLockEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/ProtectionLockEntry.java @@ -11,16 +11,6 @@ @Setter @Getter public class ProtectionLockEntry { - - public static final String FIELD_ID = "id"; - public static final String FIELD_CREATED = "created"; - public static final String FIELD_CREATEDBY = "createdby"; - public static final String FIELD_UPDATED = "updated"; - public static final String FIELD_UPDATEDBY = "updatedby"; - public static final String FIELD_DELETED = "deleted"; - public static final String FIELD_DELETEDBY = "deletedby"; - public static final String FIELD_VALUE = "value"; - private int id; private String created; private int createdBy; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/SkillsEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/SkillsEntry.java index 96f25876..d5220700 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/SkillsEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/SkillsEntry.java @@ -10,15 +10,6 @@ @Setter @Getter public class SkillsEntry { - - public static final String FIELD_ID = "id"; - public static final String FIELD_CREATED = "created"; - public static final String FIELD_CREATEDBY = "createdby"; - public static final String FIELD_UPDATED = "updated"; - public static final String FIELD_UPDATEDBY = "updatedby"; - public static final String FIELD_DELETED = "deleted"; - public static final String FIELD_DELETEDBY = "deletedby"; - private int id; private String name; private String displayName; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldEntry.java index e5063b34..6a9bf310 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldEntry.java @@ -11,16 +11,6 @@ @Setter @Getter public class WorldEntry { - - public static final String FIELD_ID = "id"; - public static final String FIELD_CREATED = "created"; - public static final String FIELD_CREATEDBY = "createdby"; - public static final String FIELD_UPDATED = "updated"; - public static final String FIELD_UPDATEDBY = "updatedby"; - public static final String FIELD_DELETED = "deleted"; - public static final String FIELD_DELETEDBY = "deletedby"; - public static final String FIELD_NAME = "name"; - private int id; private String created; private int createdBy; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupEntry.java index 227e0b18..13ff278a 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupEntry.java @@ -12,16 +12,6 @@ @Setter @Getter public class WorldGroupEntry { - - public static final String FIELD_ID = "id"; - public static final String FIELD_CREATED = "created"; - public static final String FIELD_CREATEDBY = "createdby"; - public static final String FIELD_UPDATED = "updated"; - public static final String FIELD_UPDATEDBY = "updatedby"; - public static final String FIELD_DELETED = "deleted"; - public static final String FIELD_DELETEDBY = "deletedby"; - public static final String FIELD_NAME = "name"; - private int id; private String created; private int createdBy; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupInventoryEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupInventoryEntry.java index e440cac0..ec0cc3bb 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupInventoryEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupInventoryEntry.java @@ -12,20 +12,6 @@ @Setter @Getter public class WorldGroupInventoryEntry { - - public static final String FIELD_ID = "id"; - public static final String FIELD_CREATED = "created"; - public static final String FIELD_CREATEDBY = "createdby"; - public static final String FIELD_UPDATED = "updated"; - public static final String FIELD_UPDATEDBY = "updatedby"; - public static final String FIELD_DELETED = "deleted"; - public static final String FIELD_DELETEDBY = "deletedby"; - public static final String FIELD_PLAYER_FK = "player_fk"; - public static final String FIELD_HEALTH = "health"; - public static final String FIELD_TOTAL_EXPERIENCE = "totalExperience"; - public static final String FIELD_FOOD = "food"; - public static final String FIELD_INVENTORY = "inventory"; - private int id; private String created; private int createdBy; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupSettingEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupSettingEntry.java index 26e53a7a..4b7be0e7 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupSettingEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupSettingEntry.java @@ -14,15 +14,6 @@ @Setter @Getter public class WorldGroupSettingEntry { - - public static final String FIELD_ID = "id"; - public static final String FIELD_CREATED = "created"; - public static final String FIELD_CREATEDBY = "createdby"; - public static final String FIELD_UPDATED = "updated"; - public static final String FIELD_UPDATEDBY = "updatedby"; - public static final String FIELD_DELETED = "deleted"; - public static final String FIELD_DELETEDBY = "deletedby"; - private int id; private String created; private int createdBy; From 4f83ff1ac51d11dd177f1afd44374e973dbbc4df Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Wed, 28 Feb 2024 18:16:00 +0100 Subject: [PATCH 19/36] RE-164 Cleanup of Codebase --- .idea/encodings.xml | 2 +- .../spigot/essentials/CustomEnchants.java | 20 ++++++------ .../server/spigot/essentials/CustomItems.java | 5 +-- .../server/spigot/essentials/Strings.java | 2 +- .../server/spigot/essentials/api/BagAPI.java | 2 +- .../server/spigot/essentials/api/BankAPI.java | 2 +- .../server/spigot/essentials/api/NPCAPI.java | 8 ++--- .../spigot/essentials/api/PlayerAPI.java | 4 +-- .../spigot/essentials/api/ProtectionAPI.java | 4 +-- .../server/spigot/essentials/api/WarpAPI.java | 2 +- .../spigot/essentials/commands/Back.java | 6 ++-- .../spigot/essentials/commands/Exit.java | 2 +- .../spigot/essentials/commands/Message.java | 8 ++--- .../spigot/essentials/commands/More.java | 6 ++-- .../essentials/commands/PlayerInfo.java | 4 +-- .../spigot/essentials/commands/Purse.java | 3 +- .../spigot/essentials/commands/Repair.java | 12 +++---- .../spigot/essentials/commands/Vanish.java | 6 +--- .../essentials/constants/CustomHeads.java | 8 ++--- .../essentials/constants/EntityCoins.java | 4 +-- .../essentials/constants/ItemPrice.java | 6 ++-- .../essentials/constants/PlayerState.java | 2 +- .../essentials/constants/ProtectionFlags.java | 6 ++-- .../essentials/enchantment/EnchantLevel.java | 4 +-- .../essentials/enchantment/EnchantName.java | 4 +-- .../enchantment/interfaces/IEnchantment.java | 4 +-- .../essentials/events/BetterLights.java | 3 +- .../spigot/essentials/events/BetterLock.java | 12 +++---- .../spigot/essentials/events/BetterMobs.java | 4 +-- .../spigot/essentials/events/BetterNPC.java | 7 ++-- .../spigot/essentials/events/CloudSailor.java | 5 ++- .../essentials/events/GrapplingHockEvent.java | 2 +- .../essentials/events/NoDeathMessage.java | 2 +- .../spigot/essentials/events/SkullInfo.java | 3 +- .../essentials/events/ToolCrafting.java | 4 +-- .../essentials/helpers/BankerHelper.java | 32 +++++++++---------- .../essentials/helpers/DatabaseHelper.java | 5 ++- .../essentials/helpers/EnchantmentHelper.java | 10 ++---- .../essentials/helpers/InventoryHelper.java | 6 ++-- .../spigot/essentials/helpers/ItemHelper.java | 9 +++--- .../spigot/essentials/helpers/NPCHelper.java | 4 +-- .../essentials/helpers/RecipeHelper.java | 4 +-- .../spigot/essentials/helpers/SignHelper.java | 2 +- .../helpers/interfaces/IItemHelper.java | 4 +-- .../essentials/helpers/recipe/Shaped.java | 4 +-- .../essentials/managers/DatabaseManager.java | 10 +++--- .../spigot/essentials/managers/IDisable.java | 2 +- .../spigot/essentials/managers/IEnable.java | 2 +- .../essentials/managers/WorldManager.java | 2 +- .../server/spigot/essentials/npc/NPC.java | 12 +++---- .../essentials/npc/interfaces/IBanker.java | 8 ++--- .../essentials/npc/interfaces/IChat.java | 2 +- .../essentials/npc/interfaces/INPC.java | 12 +++---- .../essentials/permissions/Permission.java | 6 +--- .../essentials/helpers/PlayerHelperTest.java | 8 ++--- .../essentials/helpers/TypeHelperTest.java | 30 ++++++++--------- 56 files changed, 159 insertions(+), 193 deletions(-) diff --git a/.idea/encodings.xml b/.idea/encodings.xml index 86f4b6f0..aa00ffab 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -1,7 +1,7 @@ - + \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/CustomEnchants.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/CustomEnchants.java index c62c0a7d..ec8f02a1 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/CustomEnchants.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/CustomEnchants.java @@ -28,8 +28,8 @@ private CustomEnchants(){ public static final EnchantmentHelper autosmelt = new EnchantmentHelper( new EnchantName(EnchantmentConstants.PLUGIN_ENCHANTMENT_AUTOSMELT, EnchantmentConstants.PLUGIN_ENCHANTMENT_AUTOSMELT_DISPLAYNAME), EnchantmentTarget.TOOL, - new EnchantLevel(1, 1), - Arrays.asList(Enchantment.SILK_TOUCH), + new EnchantLevel(1, 1), + List.of(Enchantment.SILK_TOUCH), EnchantmentConstants.PLUGIN_ENCHANTMENT_AUTOSMELT_LORE, Rarity.LEGENDARY, AttributeHelper.addAttribute() @@ -38,8 +38,8 @@ private CustomEnchants(){ public static final EnchantmentHelper telekinesis = new EnchantmentHelper( new EnchantName(EnchantmentConstants.PLUGIN_ENCHANTMENT_TELEKINESIS, EnchantmentConstants.PLUGIN_ENCHANTMENT_TELEKINESIS_DISPLAYNAME), EnchantmentTarget.BREAKABLE, - new EnchantLevel(1, 1), - Arrays.asList(Enchantment.SILK_TOUCH), + new EnchantLevel(1, 1), + List.of(Enchantment.SILK_TOUCH), EnchantmentConstants.PLUGIN_ENCHANTMENT_TELEKINESIS_LORE, Rarity.LEGENDARY, AttributeHelper.addAttribute() @@ -48,8 +48,8 @@ private CustomEnchants(){ public static final EnchantmentHelper replenishment = new EnchantmentHelper( new EnchantName(EnchantmentConstants.PLUGIN_ENCHANTMENT_REPLENISHMENT, EnchantmentConstants.PLUGIN_ENCHANTMENT_REPLENISHMENT_DISPLAYNAME), EnchantmentTarget.TOOL, - new EnchantLevel(1, 1), - Arrays.asList(Enchantment.SILK_TOUCH), + new EnchantLevel(1, 1), + List.of(Enchantment.SILK_TOUCH), EnchantmentConstants.PLUGIN_ENCHANTMENT_REPLENISHMENT_LORE, Rarity.LEGENDARY, AttributeHelper.addAttribute() @@ -58,8 +58,8 @@ private CustomEnchants(){ public static final EnchantmentHelper delicate = new EnchantmentHelper( new EnchantName(EnchantmentConstants.PLUGIN_ENCHANTMENT_DELICATE, EnchantmentConstants.PLUGIN_ENCHANTMENT_DELICATE_DISPLAYNAME), EnchantmentTarget.TOOL, - new EnchantLevel(1, 1), - Arrays.asList(Enchantment.SILK_TOUCH), + new EnchantLevel(1, 1), + List.of(Enchantment.SILK_TOUCH), EnchantmentConstants.PLUGIN_ENCHANTMENT_DELICATE_LORE, Rarity.LEGENDARY, AttributeHelper.addAttribute() @@ -68,8 +68,8 @@ private CustomEnchants(){ public static final EnchantmentHelper thunderstrike = new EnchantmentHelper( new EnchantName(EnchantmentConstants.PLUGIN_ENCHANTMENT_THUNDERSTRIKE, EnchantmentConstants.PLUGIN_ENCHANTMENT_THUNDERSTRIKE_DISPLAYNAME), EnchantmentTarget.WEAPON, - new EnchantLevel(1,1), - Arrays.asList(Enchantment.FIRE_ASPECT), + new EnchantLevel(1,1), + List.of(Enchantment.FIRE_ASPECT), EnchantmentConstants.PLUGIN_ENCHANTMENT_THUNDERSTRIKE_LORE, Rarity.LEGENDARY, AttributeHelper.addAttribute( diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/CustomItems.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/CustomItems.java index 1fef43da..79b90a0f 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/CustomItems.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/CustomItems.java @@ -12,6 +12,7 @@ import static de.relluem94.minecraft.server.spigot.essentials.constants.ItemConstants.PLUGIN_ITEM_MAGIC_WATER_BUCKET_LORE; import java.util.Arrays; +import java.util.List; import org.bukkit.Color; import org.bukkit.Material; @@ -34,7 +35,7 @@ private CustomItems() { throw new IllegalStateException(Strings.PLUGIN_INTERNAL_UTILITY_CLASS); } - public static final ItemHelper magic_water_bucket = new ItemHelper(Material.WATER_BUCKET, 1, PLUGIN_ITEM_MAGIC_WATER_BUCKET, Type.GADGET, Rarity.EPIC, Arrays.asList(PLUGIN_ITEM_MAGIC_WATER_BUCKET_LORE)){ + public static final ItemHelper magic_water_bucket = new ItemHelper(Material.WATER_BUCKET, 1, PLUGIN_ITEM_MAGIC_WATER_BUCKET, Type.GADGET, Rarity.EPIC, List.of(PLUGIN_ITEM_MAGIC_WATER_BUCKET_LORE)){ @Override public void init() { ItemMeta im = getItemMeta(); @@ -42,7 +43,7 @@ public void init() { } }; - public static final ItemHelper coins = new ItemHelper(Material.GOLD_NUGGET, 1, PLUGIN_ITEM_COINS, Type.MONEY, Rarity.COMMON, Arrays.asList(PLUGIN_ITEM_COINS_LORE)); + public static final ItemHelper coins = new ItemHelper(Material.GOLD_NUGGET, 1, PLUGIN_ITEM_COINS, Type.MONEY, Rarity.COMMON, List.of(PLUGIN_ITEM_COINS_LORE)); public static final ItemHelper cloudSailor = new ItemHelper(Material.FEATHER, 1, PLUGIN_ITEM_CLOUDSAILOR, Type.GADGET, Rarity.EPIC, Arrays.asList(PLUGIN_ITEM_CLOUDSAILOR_LORE1, PLUGIN_ITEM_CLOUDSAILOR_LORE2)); public static final ItemHelper cloudBoots = new ItemHelper(Material.LEATHER_BOOTS, 1, PLUGIN_ITEM_CLOUDBOOTS, Type.ARMOR, Rarity.LEGENDARY, Arrays.asList(PLUGIN_ITEM_CLOUDBOOTS_LORE1, PLUGIN_ITEM_CLOUDBOOTS_LORE2)) { diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/Strings.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/Strings.java index 753a3d7f..268d4253 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/Strings.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/Strings.java @@ -259,7 +259,7 @@ private Strings() { public static final String PLUGIN_COMMAND_EXIT_SERVER_SHUTTING_DOWN = PLUGIN_COLOR_COMMAND + "Server is shutting down..."; public static final String PLUGIN_COMMAND_TP_REQUEST = PLUGIN_FORMS_COMMAND_PREFIX + "Du hast " + PLUGIN_COLOR_COMMAND_ARG + "%s" + PLUGIN_COLOR_COMMAND + " eine Teleport Anfrage geschickt"; - public static final String PLUGIN_COMMAND_TP_REQUEST_TARGET = PLUGIN_FORMS_COMMAND_PREFIX + "Teleport Anfrage von " + PLUGIN_COLOR_COMMAND_ARG + "%s" + PLUGIN_COLOR_COMMAND + ""; + public static final String PLUGIN_COMMAND_TP_REQUEST_TARGET = PLUGIN_FORMS_COMMAND_PREFIX + "Teleport Anfrage von " + PLUGIN_COLOR_COMMAND_ARG + "%s" + PLUGIN_COLOR_COMMAND; public static final String PLUGIN_COMMAND_TP_REQUEST_EXPIRED = PLUGIN_FORMS_COMMAND_PREFIX + "Teleport Anfrage ist abgelaufen!"; public static final String PLUGIN_COMMAND_TP = PLUGIN_FORMS_COMMAND_PREFIX + "Du wurdest zu " + PLUGIN_COLOR_COMMAND_ARG + "%s " + PLUGIN_COLOR_COMMAND + "teleportiert!"; public static final String PLUGIN_COMMAND_TP_TO = PLUGIN_FORMS_COMMAND_PREFIX + "Du hast " + PLUGIN_COLOR_COMMAND_ARG + "%s " + PLUGIN_COLOR_COMMAND + "zu dir teleportiert!"; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/BagAPI.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/BagAPI.java index e8569869..366daab3 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/BagAPI.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/BagAPI.java @@ -7,7 +7,7 @@ public class BagAPI { - private List bagTypeEntryList = new ArrayList<>(); + private final List bagTypeEntryList = new ArrayList<>(); /** * diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/BankAPI.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/BankAPI.java index f021c65d..d8375f5b 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/BankAPI.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/BankAPI.java @@ -7,7 +7,7 @@ public class BankAPI { - private List bankTiersList = new ArrayList<>(); + private final List bankTiersList = new ArrayList<>(); /** * diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/NPCAPI.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/NPCAPI.java index 54a76ce8..762e2802 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/NPCAPI.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/NPCAPI.java @@ -16,10 +16,10 @@ public class NPCAPI { - private List npcItemstack = new ArrayList<>(); - private List npcName = new ArrayList<>(); - private List npcTraderTitle = new ArrayList<>(); - private List npcs = new ArrayList<>(); + private final List npcItemstack = new ArrayList<>(); + private final List npcName = new ArrayList<>(); + private final List npcTraderTitle = new ArrayList<>(); + private final List npcs = new ArrayList<>(); public void init(List npcEntryList){ for(NPCEntry ne : npcEntryList){ diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/PlayerAPI.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/PlayerAPI.java index 4a9583d1..ac6908c9 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/PlayerAPI.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/PlayerAPI.java @@ -20,8 +20,8 @@ public class PlayerAPI { - private Map playerEntryMap = new HashMap<>(); - private Multimap playerBagEntryMap = ArrayListMultimap.create(); + private final Map playerEntryMap = new HashMap<>(); + private final Multimap playerBagEntryMap = ArrayListMultimap.create(); public PlayerAPI(List bagEntries){ diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/ProtectionAPI.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/ProtectionAPI.java index 34e0b754..ef79de06 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/ProtectionAPI.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/ProtectionAPI.java @@ -13,8 +13,8 @@ public class ProtectionAPI { - private List protectionLocksList = new ArrayList<>(); - private HashMap protectionEntryMap = new HashMap<>(); + private final List protectionLocksList = new ArrayList<>(); + private final HashMap protectionEntryMap = new HashMap<>(); public ProtectionAPI(List protectionLocksEntryList, Map protectionEntryMap){ diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/WarpAPI.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/WarpAPI.java index 856fbad1..538be602 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/WarpAPI.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/WarpAPI.java @@ -8,7 +8,7 @@ import de.relluem94.minecraft.server.spigot.essentials.helpers.pojo.LocationEntry; public class WarpAPI { - private List warps; + private final List warps; public WarpAPI(List warps){ this.warps = warps; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Back.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Back.java index 37ea667e..fca722fd 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Back.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Back.java @@ -21,7 +21,7 @@ public class Back implements CommandExecutor { - private static Map backPlayerLocation = new HashMap<>(); + private static final Map backPlayerLocation = new HashMap<>(); public static void addBackPoint(Player p){ removeBackPoint(p); @@ -29,9 +29,7 @@ public static void addBackPoint(Player p){ } public static void removeBackPoint(Player p){ - if(backPlayerLocation.containsKey(p)){ - backPlayerLocation.remove(p); - } + backPlayerLocation.remove(p); } @Override diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Exit.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Exit.java index 2b0bbbc6..a16c22e2 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Exit.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Exit.java @@ -35,7 +35,7 @@ public void run() { Bukkit.getOnlinePlayers().forEach(op -> op.kickPlayer(Strings.PLUGIN_COMMAND_EXIT_SERVER_SHUTTING_DOWN)); } - }.runTaskLater(RelluEssentials.getInstance(), 10l); + }.runTaskLater(RelluEssentials.getInstance(), 10L); Bukkit.getServer().getScheduler().runTaskLater(RelluEssentials.getInstance(), Bukkit.getServer()::shutdown, 20L); return true; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Message.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Message.java index 3a82a62d..57c25f8f 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Message.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Message.java @@ -72,12 +72,8 @@ private boolean msg(CommandSender sender, Player target, String[] args, int star if (Permission.isAuthorized(p, Groups.getGroup("user").getId())) { String message = implode(start, args); - if (reply.containsKey(p)) { - reply.remove(p); - } - if (reply.containsKey(target)) { - reply.remove(target); - } + reply.remove(p); + reply.remove(target); reply.put(p, target); reply.put(target, p); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/More.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/More.java index ae60ea2f..530e9fa1 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/More.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/More.java @@ -23,7 +23,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St Player p = (Player) sender; if (Permission.isAuthorized(p, Groups.getGroup("mod").getId())) { p.getInventory().getItemInMainHand().setAmount(64); - p.sendMessage(String.format(PLUGIN_COMMAND_MORE, p.getInventory().getItemInMainHand().getType().toString())); + p.sendMessage(String.format(PLUGIN_COMMAND_MORE, p.getInventory().getItemInMainHand().getType())); return true; } else { p.sendMessage(PLUGIN_COMMAND_PERMISSION_MISSING); @@ -37,8 +37,8 @@ public boolean onCommand(CommandSender sender, Command command, String label, St Player p = (Player) sender; if (Permission.isAuthorized(p, Groups.getGroup("mod").getId())) { target.getInventory().getItemInMainHand().setAmount(64); - p.sendMessage(String.format(PLUGIN_COMMAND_MORE, target.getInventory().getItemInMainHand().getType().toString())); - target.sendMessage(String.format(PLUGIN_COMMAND_MORE_PLAYER, target.getInventory().getItemInMainHand().getType().toString())); + p.sendMessage(String.format(PLUGIN_COMMAND_MORE, target.getInventory().getItemInMainHand().getType())); + target.sendMessage(String.format(PLUGIN_COMMAND_MORE_PLAYER, target.getInventory().getItemInMainHand().getType())); return true; } else { p.sendMessage(PLUGIN_COMMAND_PERMISSION_MISSING); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PlayerInfo.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PlayerInfo.java index dbd640b2..bf6ae478 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PlayerInfo.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PlayerInfo.java @@ -94,8 +94,8 @@ private void showPlayerInfo(CommandSender sender, String targetName){ sender.sendMessage(String.format(PLUGIN_COMMAND_PLAYERINFO_MARRIED_SINCE, pet.getPartner().getCreated())); } - sender.sendMessage(String.format(PLUGIN_COMMAND_PLAYERINFO_LAST_ONLINE, new Date(target.getLastPlayed()).toString())); - sender.sendMessage(String.format(PLUGIN_COMMAND_PLAYERINFO_FIRST_ONLINE, new Date(target.getFirstPlayed()).toString())); + sender.sendMessage(String.format(PLUGIN_COMMAND_PLAYERINFO_LAST_ONLINE, new Date(target.getLastPlayed()))); + sender.sendMessage(String.format(PLUGIN_COMMAND_PLAYERINFO_FIRST_ONLINE, new Date(target.getFirstPlayed()))); sender.sendMessage(String.format(PLUGIN_COMMAND_PLAYERINFO_MINED, Material.STONE.name(), target.getStatistic(Statistic.MINE_BLOCK, Material.STONE))); sender.sendMessage(String.format(PLUGIN_COMMAND_PLAYERINFO_MINED, Material.DIRT.name(), target.getStatistic(Statistic.MINE_BLOCK, Material.DIRT))); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Purse.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Purse.java index a41db5e5..3aa5cdfe 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Purse.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Purse.java @@ -12,6 +12,7 @@ import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isPlayer; import java.util.Arrays; +import java.util.Collections; import org.bukkit.Bukkit; import org.bukkit.command.Command; @@ -89,7 +90,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St if ((purse >= coins)) { ItemStack coin = CustomItems.coins.getCustomItem(); ItemMeta im = coin.getItemMeta(); - im.setLore(Arrays.asList(String.format(ItemConstants.PLUGIN_ITEM_COINS_LORE, StringHelper.formatInt(coins)))); + im.setLore(Collections.singletonList(String.format(ItemConstants.PLUGIN_ITEM_COINS_LORE, StringHelper.formatInt(coins)))); im.getPersistentDataContainer().set(ItemConstants.PLUGIN_ITEM_COINS_NAMESPACE, PersistentDataType.INTEGER, coins); coin.setItemMeta(im); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Repair.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Repair.java index 399d5d68..1df5a406 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Repair.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Repair.java @@ -29,15 +29,14 @@ public boolean onCommand(CommandSender sender, Command command, String label, St ItemStack item = p.getInventory().getItemInMainHand(); ItemMeta im = item.getItemMeta(); - if (im instanceof Damageable) { - Damageable dmg = (Damageable) im; + if (im instanceof Damageable dmg) { if (dmg.hasDamage()) { dmg.setDamage(0); } item.setItemMeta(im); } - p.sendMessage(String.format(PLUGIN_COMMAND_REPAIR, p.getInventory().getItemInMainHand().getType().toString())); + p.sendMessage(String.format(PLUGIN_COMMAND_REPAIR, p.getInventory().getItemInMainHand().getType())); return true; } else { p.sendMessage(PLUGIN_COMMAND_PERMISSION_MISSING); @@ -54,16 +53,15 @@ public boolean onCommand(CommandSender sender, Command command, String label, St ItemStack item = target.getInventory().getItemInMainHand(); ItemMeta im = item.getItemMeta(); - if (im instanceof Damageable) { - Damageable dmg = (Damageable) im; + if (im instanceof Damageable dmg) { if (dmg.hasDamage()) { dmg.setDamage(0); } item.setItemMeta(im); } - p.sendMessage(String.format(PLUGIN_COMMAND_REPAIR, target.getInventory().getItemInMainHand().getType().toString())); - target.sendMessage(String.format(PLUGIN_COMMAND_REPAIR_PLAYER, target.getInventory().getItemInMainHand().getType().toString())); + p.sendMessage(String.format(PLUGIN_COMMAND_REPAIR, target.getInventory().getItemInMainHand().getType())); + target.sendMessage(String.format(PLUGIN_COMMAND_REPAIR_PLAYER, target.getInventory().getItemInMainHand().getType())); return true; } else { p.sendMessage(PLUGIN_COMMAND_PERMISSION_MISSING); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Vanish.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Vanish.java index 4d4283e0..8be92c7b 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Vanish.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Vanish.java @@ -30,11 +30,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St Player p = (Player) sender; if (Permission.isAuthorized(p, Groups.getGroup("mod").getId())) { sendMessage(p, PLUGIN_COMMAND_VANISH); - boolean canSee = true; - - if (isVanished.contains(p)) { - canSee = false; - } + boolean canSee = !isVanished.contains(p); for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { if (canSee) { diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/CustomHeads.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/CustomHeads.java index bbba1ad3..b7a2d4dd 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/CustomHeads.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/CustomHeads.java @@ -69,11 +69,11 @@ public enum CustomHeads { - private String name; - private String uuid; - private String base64; + private final String name; + private final String uuid; + private final String base64; - private CustomHeads(String name, String uuid, String base64){ + CustomHeads(String name, String uuid, String base64){ this.name = name; this.uuid = uuid; this.base64 = base64; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/EntityCoins.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/EntityCoins.java index 70fff29e..6f7036f1 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/EntityCoins.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/EntityCoins.java @@ -132,9 +132,9 @@ public enum EntityCoins { BLOCK_DISPLAY(0); - private int coins; + private final int coins; - private EntityCoins(int coins) { + EntityCoins(int coins) { this.coins = coins; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/ItemPrice.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/ItemPrice.java index ccd8f348..4c8c9ffe 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/ItemPrice.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/ItemPrice.java @@ -1423,10 +1423,10 @@ public enum ItemPrice { ORANGE_CARPET(0, 0), BLUE_CARPET(0, 0); - private int buyPrice; - private int sellPrice; + private final int buyPrice; + private final int sellPrice; - private ItemPrice(int buyPrice, int sellPrice) { + ItemPrice(int buyPrice, int sellPrice) { this.buyPrice = buyPrice; this.sellPrice = sellPrice; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/PlayerState.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/PlayerState.java index 3a874a24..bbbd4185 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/PlayerState.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/PlayerState.java @@ -15,5 +15,5 @@ public enum PlayerState implements IPlayerState { FAKE_AFK_ON, FAKE_AFK_ACTIVE, DAMAGE_INFO, - DEFAULT; + DEFAULT } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/ProtectionFlags.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/ProtectionFlags.java index 4ef85bf3..9bbecee5 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/ProtectionFlags.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/ProtectionFlags.java @@ -7,10 +7,10 @@ public enum ProtectionFlags { AUTOCLOSE("autoClose", false); - private String name; - private boolean isDefault; + private final String name; + private final boolean isDefault; - private ProtectionFlags(String name, boolean isDefault){ + ProtectionFlags(String name, boolean isDefault){ this.name = name; this.isDefault = isDefault; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/enchantment/EnchantLevel.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/enchantment/EnchantLevel.java index cb873460..59e49160 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/enchantment/EnchantLevel.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/enchantment/EnchantLevel.java @@ -1,8 +1,8 @@ package de.relluem94.minecraft.server.spigot.essentials.enchantment; public class EnchantLevel { - private int startLevel; - private int maxLevel; + private final int startLevel; + private final int maxLevel; public EnchantLevel(int startLevel, int maxLevel){ this.startLevel = startLevel; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/enchantment/EnchantName.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/enchantment/EnchantName.java index 7f8ffde3..3dc63405 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/enchantment/EnchantName.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/enchantment/EnchantName.java @@ -2,8 +2,8 @@ public class EnchantName { - private String name; - private String displayName; + private final String name; + private final String displayName; public EnchantName(String name, String displayName){ this.name = name; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/enchantment/interfaces/IEnchantment.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/enchantment/interfaces/IEnchantment.java index 8fd8f82a..53f678e3 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/enchantment/interfaces/IEnchantment.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/enchantment/interfaces/IEnchantment.java @@ -8,7 +8,7 @@ */ public interface IEnchantment { - public void addTo(ItemStack i); + void addTo(ItemStack i); - public void removeFrom(ItemStack i); + void removeFrom(ItemStack i); } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLights.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLights.java index c802f32e..b32e4d31 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLights.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLights.java @@ -22,8 +22,7 @@ public class BetterLights implements Listener { public void onChangeSignCreateActionSign(PlayerInteractEvent e) { PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(e.getPlayer().getUniqueId()); Block b = e.getClickedBlock(); - if(pe.getPlayerState().equals(PlayerState.LIGHT_TOOGLE) && b != null && b.getType().equals(Material.REDSTONE_LAMP) && b.getBlockData() instanceof Lightable){ - Lightable lightable = (Lightable) b.getBlockData(); + if(pe.getPlayerState().equals(PlayerState.LIGHT_TOOGLE) && b != null && b.getType().equals(Material.REDSTONE_LAMP) && b.getBlockData() instanceof Lightable lightable){ lightable.setLit(!lightable.isLit()); b.setBlockData(lightable); e.getPlayer().sendMessage(EventConstants.PLUGIN_EVENT_LIGHTS_TOOGLE); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java index 5b699dd2..b807dfcf 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java @@ -238,8 +238,7 @@ private boolean protectBlock(Player p, Block b) { boolean hasRights = true; - if(b.getBlockData() instanceof Chest){ - Chest cd = (Chest) b.getBlockData(); + if(b.getBlockData() instanceof Chest cd){ if(!cd.getType().equals(Type.SINGLE)){ Block b2; @@ -264,8 +263,7 @@ private boolean protectBlock(Player p, Block b) { break; } - if(b2.getBlockData() instanceof Chest){ - Chest cd2 = (Chest) b2.getBlockData(); + if(b2.getBlockData() instanceof Chest cd2){ if(cd2.getFacing().equals(cd.getFacing())){ if(!ProtectionHelper.hasPermission(b2, p)){ hasRights = false; @@ -274,8 +272,7 @@ private boolean protectBlock(Player p, Block b) { } } } - else if(b3.getBlockData() instanceof Chest){ - Chest cd3 = (Chest) b3.getBlockData(); + else if(b3.getBlockData() instanceof Chest cd3){ if(cd3.getFacing().equals(cd.getFacing())){ if(!ProtectionHelper.hasPermission(b3, p)){ hasRights = false; @@ -713,8 +710,7 @@ public void onInteract(PlayerInteractEvent e) { Door door = (Door) b.getBlockData(); Block b2 = ProtectionHelper.getOtherPart(door, b); if(b2 != null){ - if(b2.getBlockData() instanceof Door){ - Door door2 = (Door) b2.getBlockData(); + if(b2.getBlockData() instanceof Door door2){ if(door2.getHinge() != door.getHinge()){ if (door2.isOpen()) { door2.setOpen(false); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterMobs.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterMobs.java index 77e09578..2a512e76 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterMobs.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterMobs.java @@ -91,9 +91,7 @@ public void onDeath(EntityDeathEvent e) { @EventHandler public void onHit(EntityDamageByEntityEvent e) { - if (e.getEntity() instanceof Monster && e.getDamager() instanceof Player) { - Monster m = (Monster) e.getEntity(); - Player p = (Player) e.getDamager(); + if (e.getEntity() instanceof Monster m && e.getDamager() instanceof Player p) { PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); if(pe.getPlayerState().equals(PlayerState.DAMAGE_INFO)){ p.sendMessage(String.format(EventConstants.PLUGIN_EVENT_DAMAGE_SHOW, e.getDamage(), m.getLastDamage(), m.getHealth())); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterNPC.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterNPC.java index 2beec917..a3d6425b 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterNPC.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterNPC.java @@ -263,8 +263,7 @@ else if(inv.getType().equals(InventoryType.PLAYER)){ @EventHandler public void onInventoryClickItem(InventoryClickEvent e) { - if(e.getWhoClicked() instanceof Player && e.getCurrentItem() != null){ - Player p = (Player) e.getWhoClicked(); + if(e.getWhoClicked() instanceof Player p && e.getCurrentItem() != null){ PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); if (e.getView().getTitle().equals(RelluEssentials.getBanker().getTitle())) { BankAccountEntry bae = RelluEssentials.getInstance().getDatabaseHelper().getPlayerBankAccount(pe.getId()); @@ -369,13 +368,11 @@ public void onNPCDamage(EntityDamageByEntityEvent e){ return; } - if(!(e.getDamager() instanceof Player)){ + if(!(e.getDamager() instanceof Player p)){ e.setCancelled(true); return; } - Player p = (Player) e.getDamager(); - if (!Permission.isAuthorized(p, Groups.getGroup("admin").getId())) { e.setCancelled(true); } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/CloudSailor.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/CloudSailor.java index 49ef3965..86c5f7c8 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/CloudSailor.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/CloudSailor.java @@ -29,7 +29,7 @@ public class CloudSailor implements Listener { - private Random random = new Random(); + private final Random random = new Random(); @EventHandler public void mobDeath(EntityDeathEvent event) { @@ -65,8 +65,7 @@ public void cloudBootsCrafting(PrepareItemCraftEvent e) { @EventHandler(priority = EventPriority.HIGH) public void onFallDamage(EntityDamageEvent e) { - if (e.getEntity() instanceof Player) { - Player p = (Player) e.getEntity(); + if (e.getEntity() instanceof Player p) { if (isInWorld(p, Arrays.asList(RelluEssentials.getInstance().worlds))) { if (e.getCause().equals(DamageCause.FALL)) { if (p.getInventory().getBoots() != null && p.getInventory().getBoots().equals(CustomItems.cloudBoots.getCustomItem())) { diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/GrapplingHockEvent.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/GrapplingHockEvent.java index 418da4f5..48821f81 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/GrapplingHockEvent.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/GrapplingHockEvent.java @@ -40,7 +40,7 @@ public void grapple(PlayerFishEvent e){ public void run() { COOL_DOWN.remove(e.getPlayer()); } - }.runTaskLater(RelluEssentials.getInstance(), 50l); + }.runTaskLater(RelluEssentials.getInstance(), 50L); } else{ e.getPlayer().sendMessage(Strings.PLUGIN_GRAPPLINGHOOK_COOLDOWN); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/NoDeathMessage.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/NoDeathMessage.java index 4204d2b7..b016795c 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/NoDeathMessage.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/NoDeathMessage.java @@ -27,7 +27,7 @@ public class NoDeathMessage implements Listener { - private Random random = new Random(); + private final Random random = new Random(); @EventHandler public void onDeath(PlayerDeathEvent e) { diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/SkullInfo.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/SkullInfo.java index 87d6e7e0..6c71e4a8 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/SkullInfo.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/SkullInfo.java @@ -21,8 +21,7 @@ public void onClick(PlayerInteractEvent e) { Player p = e.getPlayer(); if (e.getHand() != null && e.getHand().equals(EquipmentSlot.HAND) && (Permission.isAuthorized(p, Groups.getGroup("vip").getId()) && (e.getAction() == Action.RIGHT_CLICK_BLOCK))) { BlockState block = e.getClickedBlock().getState(); - if (block instanceof Skull) { - Skull sk = (Skull) block; + if (block instanceof Skull sk) { p.sendTitle("§a" + sk.getOwnerProfile().getName(), PLUGIN_EVENT_SKULL_INFO_SPACER, 5, 80, 5); } } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/ToolCrafting.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/ToolCrafting.java index 6c42c8ee..fb2b994e 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/ToolCrafting.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/ToolCrafting.java @@ -35,7 +35,7 @@ public void addRarityToTools(PrepareSmithingEvent e) { if (e.getResult().getType().equals(m)) { List lore = im.getLore(); - lore.addAll(Arrays.asList(Rarity.EPIC.getPrefix() + Rarity.EPIC.getDisplayName())); + lore.addAll(List.of(Rarity.EPIC.getPrefix() + Rarity.EPIC.getDisplayName())); lore.remove(Rarity.RARE.getPrefix() + Rarity.RARE.getDisplayName()); im.setLore(lore); @@ -49,7 +49,7 @@ private ItemMeta addRarity(Material[] mats, ItemStack is, Rarity rarity){ ItemMeta im = is.getItemMeta(); for (Material m : mats) { if (is.getType().equals(m)) { - im.setLore(Arrays.asList(rarity.getPrefix() + rarity.getDisplayName())); + im.setLore(List.of(rarity.getPrefix() + rarity.getDisplayName())); is.setItemMeta(im); } } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/BankerHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/BankerHelper.java index 4efbdd22..e67fbfc6 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/BankerHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/BankerHelper.java @@ -52,22 +52,22 @@ private BankerHelper() { } - public static final ItemHelper npc_portable_bank = new ItemHelper(Material.YELLOW_SHULKER_BOX, 1, PLUGIN_ITEM_NPC_BANKER_PORTABLE_BANK, Type.TOOL, Rarity.LEGENDARY, Arrays.asList(PLUGIN_ITEM_NPC_BANKER_PORTABLE_BANK_LORE1)); - - public static final ItemHelper npc_gui_deposit = new ItemHelper(Material.GREEN_SHULKER_BOX, 1, PLUGIN_ITEM_NPC_BANKER_GUI_DEPOSIT, Type.NPC_GUI, Rarity.NONE, Arrays.asList(PLUGIN_ITEM_NPC_BANKER_GUI_DEPOSIT_LORE1)); - public static final ItemHelper npc_gui_withdraw = new ItemHelper(Material.RED_SHULKER_BOX, 1, PLUGIN_ITEM_NPC_BANKER_GUI_WITHDRAW, Type.NPC_GUI, Rarity.NONE, Arrays.asList(PLUGIN_ITEM_NPC_BANKER_GUI_WITHDRAW_LORE1)); - public static final ItemHelper npc_gui_balance = new ItemHelper(Material.YELLOW_SHULKER_BOX, 1, PLUGIN_ITEM_NPC_BANKER_GUI_BALANCE, Type.NPC_GUI, Rarity.NONE, Arrays.asList(PLUGIN_ITEM_NPC_BANKER_GUI_BALANCE_LORE1)); - public static final ItemHelper npc_gui_upgrade = new ItemHelper(Material.DIAMOND_BLOCK, 1, PLUGIN_ITEM_NPC_BANKER_GUI_UPGRADE, Type.NPC_GUI, Rarity.NONE, Arrays.asList(PLUGIN_ITEM_NPC_BANKER_GUI_UPGRADE_LORE1)); - - public static final ItemHelper npc_gui_deposit_all = new ItemHelper(Material.GOLD_BLOCK, 1, PLUGIN_ITEM_NPC_BANKER_GUI_DEPOSIT_ALL, Type.NPC_GUI, Rarity.NONE, Arrays.asList(PLUGIN_ITEM_NPC_BANKER_GUI_DEPOSIT_AMOUNT_LORE1)); - public static final ItemHelper npc_gui_deposit_5_percent = new ItemHelper(Material.GOLD_NUGGET, 1, String.format(PLUGIN_ITEM_NPC_BANKER_GUI_DEPOSIT_X_PERCENT, 5), Type.NPC_GUI, Rarity.NONE, Arrays.asList(PLUGIN_ITEM_NPC_BANKER_GUI_DEPOSIT_AMOUNT_LORE1)); - public static final ItemHelper npc_gui_deposit_20_percent = new ItemHelper(Material.GOLD_INGOT, 1, String.format(PLUGIN_ITEM_NPC_BANKER_GUI_DEPOSIT_X_PERCENT, 20), Type.NPC_GUI, Rarity.NONE, Arrays.asList(PLUGIN_ITEM_NPC_BANKER_GUI_DEPOSIT_AMOUNT_LORE1)); - public static final ItemHelper npc_gui_deposit_50_percent = new ItemHelper(Material.GOLD_INGOT, 1, String.format(PLUGIN_ITEM_NPC_BANKER_GUI_DEPOSIT_X_PERCENT, 50), Type.NPC_GUI, Rarity.NONE, Arrays.asList(PLUGIN_ITEM_NPC_BANKER_GUI_DEPOSIT_AMOUNT_LORE1)); - - public static final ItemHelper npc_gui_withdraw_all = new ItemHelper(Material.GOLD_BLOCK, 1, PLUGIN_ITEM_NPC_BANKER_GUI_WITHDRAW_ALL, Type.NPC_GUI, Rarity.NONE, Arrays.asList(PLUGIN_ITEM_NPC_BANKER_GUI_WITHDRAW_AMOUNT_LORE1)); - public static final ItemHelper npc_gui_withdraw_5_percent = new ItemHelper(Material.GOLD_NUGGET, 1, String.format(PLUGIN_ITEM_NPC_BANKER_GUI_WITHDRAW_X_PERCENT, 5), Type.NPC_GUI, Rarity.NONE, Arrays.asList(PLUGIN_ITEM_NPC_BANKER_GUI_WITHDRAW_AMOUNT_LORE1)); - public static final ItemHelper npc_gui_withdraw_20_percent = new ItemHelper(Material.GOLD_INGOT, 1, String.format(PLUGIN_ITEM_NPC_BANKER_GUI_WITHDRAW_X_PERCENT, 20), Type.NPC_GUI, Rarity.NONE, Arrays.asList(PLUGIN_ITEM_NPC_BANKER_GUI_WITHDRAW_AMOUNT_LORE1)); - public static final ItemHelper npc_gui_withdraw_50_percent = new ItemHelper(Material.GOLD_INGOT, 1, String.format(PLUGIN_ITEM_NPC_BANKER_GUI_WITHDRAW_X_PERCENT, 50), Type.NPC_GUI, Rarity.NONE, Arrays.asList(PLUGIN_ITEM_NPC_BANKER_GUI_WITHDRAW_AMOUNT_LORE1)); + public static final ItemHelper npc_portable_bank = new ItemHelper(Material.YELLOW_SHULKER_BOX, 1, PLUGIN_ITEM_NPC_BANKER_PORTABLE_BANK, Type.TOOL, Rarity.LEGENDARY, List.of(PLUGIN_ITEM_NPC_BANKER_PORTABLE_BANK_LORE1)); + + public static final ItemHelper npc_gui_deposit = new ItemHelper(Material.GREEN_SHULKER_BOX, 1, PLUGIN_ITEM_NPC_BANKER_GUI_DEPOSIT, Type.NPC_GUI, Rarity.NONE, List.of(PLUGIN_ITEM_NPC_BANKER_GUI_DEPOSIT_LORE1)); + public static final ItemHelper npc_gui_withdraw = new ItemHelper(Material.RED_SHULKER_BOX, 1, PLUGIN_ITEM_NPC_BANKER_GUI_WITHDRAW, Type.NPC_GUI, Rarity.NONE, List.of(PLUGIN_ITEM_NPC_BANKER_GUI_WITHDRAW_LORE1)); + public static final ItemHelper npc_gui_balance = new ItemHelper(Material.YELLOW_SHULKER_BOX, 1, PLUGIN_ITEM_NPC_BANKER_GUI_BALANCE, Type.NPC_GUI, Rarity.NONE, List.of(PLUGIN_ITEM_NPC_BANKER_GUI_BALANCE_LORE1)); + public static final ItemHelper npc_gui_upgrade = new ItemHelper(Material.DIAMOND_BLOCK, 1, PLUGIN_ITEM_NPC_BANKER_GUI_UPGRADE, Type.NPC_GUI, Rarity.NONE, List.of(PLUGIN_ITEM_NPC_BANKER_GUI_UPGRADE_LORE1)); + + public static final ItemHelper npc_gui_deposit_all = new ItemHelper(Material.GOLD_BLOCK, 1, PLUGIN_ITEM_NPC_BANKER_GUI_DEPOSIT_ALL, Type.NPC_GUI, Rarity.NONE, List.of(PLUGIN_ITEM_NPC_BANKER_GUI_DEPOSIT_AMOUNT_LORE1)); + public static final ItemHelper npc_gui_deposit_5_percent = new ItemHelper(Material.GOLD_NUGGET, 1, String.format(PLUGIN_ITEM_NPC_BANKER_GUI_DEPOSIT_X_PERCENT, 5), Type.NPC_GUI, Rarity.NONE, List.of(PLUGIN_ITEM_NPC_BANKER_GUI_DEPOSIT_AMOUNT_LORE1)); + public static final ItemHelper npc_gui_deposit_20_percent = new ItemHelper(Material.GOLD_INGOT, 1, String.format(PLUGIN_ITEM_NPC_BANKER_GUI_DEPOSIT_X_PERCENT, 20), Type.NPC_GUI, Rarity.NONE, List.of(PLUGIN_ITEM_NPC_BANKER_GUI_DEPOSIT_AMOUNT_LORE1)); + public static final ItemHelper npc_gui_deposit_50_percent = new ItemHelper(Material.GOLD_INGOT, 1, String.format(PLUGIN_ITEM_NPC_BANKER_GUI_DEPOSIT_X_PERCENT, 50), Type.NPC_GUI, Rarity.NONE, List.of(PLUGIN_ITEM_NPC_BANKER_GUI_DEPOSIT_AMOUNT_LORE1)); + + public static final ItemHelper npc_gui_withdraw_all = new ItemHelper(Material.GOLD_BLOCK, 1, PLUGIN_ITEM_NPC_BANKER_GUI_WITHDRAW_ALL, Type.NPC_GUI, Rarity.NONE, List.of(PLUGIN_ITEM_NPC_BANKER_GUI_WITHDRAW_AMOUNT_LORE1)); + public static final ItemHelper npc_gui_withdraw_5_percent = new ItemHelper(Material.GOLD_NUGGET, 1, String.format(PLUGIN_ITEM_NPC_BANKER_GUI_WITHDRAW_X_PERCENT, 5), Type.NPC_GUI, Rarity.NONE, List.of(PLUGIN_ITEM_NPC_BANKER_GUI_WITHDRAW_AMOUNT_LORE1)); + public static final ItemHelper npc_gui_withdraw_20_percent = new ItemHelper(Material.GOLD_INGOT, 1, String.format(PLUGIN_ITEM_NPC_BANKER_GUI_WITHDRAW_X_PERCENT, 20), Type.NPC_GUI, Rarity.NONE, List.of(PLUGIN_ITEM_NPC_BANKER_GUI_WITHDRAW_AMOUNT_LORE1)); + public static final ItemHelper npc_gui_withdraw_50_percent = new ItemHelper(Material.GOLD_INGOT, 1, String.format(PLUGIN_ITEM_NPC_BANKER_GUI_WITHDRAW_X_PERCENT, 50), Type.NPC_GUI, Rarity.NONE, List.of(PLUGIN_ITEM_NPC_BANKER_GUI_WITHDRAW_AMOUNT_LORE1)); public static final ItemHelper npc_gui_balance_total = new ItemHelper(Material.YELLOW_SHULKER_BOX, 1, PLUGIN_ITEM_NPC_BANKER_GUI_BALANCE_TOTAL, Type.NPC_GUI, Rarity.NONE); public static final ItemHelper npc_gui_balance_transactions = new ItemHelper(Material.MAP, 1, PLUGIN_ITEM_NPC_BANKER_GUI_BALANCE_TRANSACTIONS, Type.NPC_GUI, Rarity.NONE); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java index 116d6415..8f85629f 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java @@ -22,7 +22,6 @@ import java.util.logging.Logger; import de.relluem94.minecraft.server.spigot.essentials.constants.DatabaseMappings; -import de.relluem94.minecraft.server.spigot.essentials.managers.NPCManager; import de.relluem94.minecraft.server.spigot.essentials.npc.NPC; import org.bukkit.Location; import org.bukkit.Material; @@ -284,7 +283,7 @@ public void init() { applyPatch(getPluginInformation().getDbVersion()); } - private boolean insertScripts = false; // To add Scripts in Development without its own patch version + private final boolean insertScripts = false; // To add Scripts in Development without its own patch version private void applyPatch(int version) { switch (version) { @@ -1475,7 +1474,7 @@ public List getBlockHistoryByPlayerAndTime(PlayerEntry p, Str try (Connection connection = DriverManager.getConnection(connectorString, user, password)) { try (PreparedStatement ps = connection.prepareStatement(readResource(deleted ? "sqls/getBlockHistoryByPlayerAndTimeIsDeleted.sql" : "sqls/getBlockHistoryByPlayerAndTime.sql"))) { - String[] times = time.split("(\s+/? ingredients; + private final Map ingredients; public Shaped(String[] rows, Map ingredients){ this.ingredients = ingredients; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/DatabaseManager.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/DatabaseManager.java index 47fab1d2..2ea84540 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/DatabaseManager.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/DatabaseManager.java @@ -22,9 +22,11 @@ import de.relluem94.minecraft.server.spigot.essentials.helpers.pojo.WorldGroupEntry; import de.relluem94.rellulib.stores.DoubleStore; +import java.util.Collections; + public class DatabaseManager implements IEnable{ - private DatabaseHelper dBH; + private final DatabaseHelper dBH; private PluginInformationEntry pie; public DatabaseManager(String host, String user, String password, int port){ @@ -66,9 +68,7 @@ public void enable() { for(int i = 0; i < RelluEssentials.getInstance().getBagAPI().getBagTypeEntryList().size(); i++){ ItemStack[] isa = BagHelper.getItemStacks(RelluEssentials.getInstance().getBagAPI().getBagTypeEntryList().get(i)); - for(ItemStack is : isa){ - RelluEssentials.getInstance().bagBlocks2collect.add(is); - } + Collections.addAll(RelluEssentials.getInstance().bagBlocks2collect, isa); } } @@ -82,7 +82,7 @@ public void run() { RelluEssentials.getInstance().setWarpAPI(new WarpAPI(dBH.getWarps())); RelluEssentials.getInstance().getPlayerAPI().reloadPlayerHomes(); } - }.runTaskLater(RelluEssentials.getInstance(), 1l); + }.runTaskLater(RelluEssentials.getInstance(), 1L); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/IDisable.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/IDisable.java index 776391dc..1f1224f0 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/IDisable.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/IDisable.java @@ -1,5 +1,5 @@ package de.relluem94.minecraft.server.spigot.essentials.managers; public interface IDisable { - public void disable(); + void disable(); } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/IEnable.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/IEnable.java index e96c7c52..b8774f71 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/IEnable.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/IEnable.java @@ -1,5 +1,5 @@ package de.relluem94.minecraft.server.spigot.essentials.managers; public interface IEnable { - public void enable(); + void enable(); } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/WorldManager.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/WorldManager.java index fd39b3bb..aa2c8476 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/WorldManager.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/WorldManager.java @@ -21,7 +21,7 @@ public class WorldManager implements IEnable, IDisable { - private Random r = new Random(); + private final Random r = new Random(); @Override public void enable() { diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/npc/NPC.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/npc/NPC.java index 955e9512..12e6c7a1 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/npc/NPC.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/npc/NPC.java @@ -16,10 +16,10 @@ public class NPC implements INPC { - private String name; - private ItemHelper npcSpawnItem; - private Profession profession; - private Type type; + private final String name; + private final ItemHelper npcSpawnItem; + private final Profession profession; + private final Type type; public NPC(NPCEntry npcEntry){ this(npcEntry.getName(), npcEntry.getProfession(), npcEntry.getType()); @@ -29,7 +29,7 @@ public NPC(String name, Profession profession, Type type){ this.name = name; this.profession = profession; this.type = type; - this.npcSpawnItem = new ItemHelper(Material.VILLAGER_SPAWN_EGG, 1, getName(), de.relluem94.minecraft.server.spigot.essentials.helpers.ItemHelper.Type.NPC, Rarity.LEGENDARY, Arrays.asList(new String[]{ItemConstants.PLUGIN_ITEM_NPC_LORE1})); + this.npcSpawnItem = new ItemHelper(Material.VILLAGER_SPAWN_EGG, 1, getName(), de.relluem94.minecraft.server.spigot.essentials.helpers.ItemHelper.Type.NPC, Rarity.LEGENDARY, Arrays.asList(ItemConstants.PLUGIN_ITEM_NPC_LORE1)); RelluEssentials.getInstance().getNpcAPI().addNPC(this); } @@ -63,7 +63,7 @@ public enum Type { BANKER, CHAT, ENCHANTER, - OTHER; + OTHER } @Override diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/npc/interfaces/IBanker.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/npc/interfaces/IBanker.java index bfc4469d..b0bd628c 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/npc/interfaces/IBanker.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/npc/interfaces/IBanker.java @@ -3,8 +3,8 @@ import org.bukkit.inventory.Inventory; public interface IBanker { - public Inventory getDepositGUI(); - public Inventory getWithdrawGUI(); - public Inventory getBalanceGUI(); - public Inventory getUpgradeGUI(); + Inventory getDepositGUI(); + Inventory getWithdrawGUI(); + Inventory getBalanceGUI(); + Inventory getUpgradeGUI(); } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/npc/interfaces/IChat.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/npc/interfaces/IChat.java index 3dc31225..c7cae97d 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/npc/interfaces/IChat.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/npc/interfaces/IChat.java @@ -1,5 +1,5 @@ package de.relluem94.minecraft.server.spigot.essentials.npc.interfaces; public interface IChat { - public String[] getTexts(); + String[] getTexts(); } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/npc/interfaces/INPC.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/npc/interfaces/INPC.java index 95a4061e..82c94d3f 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/npc/interfaces/INPC.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/npc/interfaces/INPC.java @@ -7,10 +7,10 @@ import de.relluem94.minecraft.server.spigot.essentials.npc.NPC.Type; public interface INPC { - public String getName(); - public String getTitle(); - public ItemHelper getItemHelper(); - public Profession getProfession(); - public Type getType(); - public Inventory getMainGUI(); + String getName(); + String getTitle(); + ItemHelper getItemHelper(); + Profession getProfession(); + Type getType(); + Inventory getMainGUI(); } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/permissions/Permission.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/permissions/Permission.java index 914b7a32..33d1be21 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/permissions/Permission.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/permissions/Permission.java @@ -41,10 +41,6 @@ public static boolean isAuthorized(CommandSender sender, long group) { return isAuthorized((Player) sender, group); } else if (isCMDBlock(sender)) { return true; - } else if (isConsole(sender)) { - return true; - } - - return false; + } else return isConsole(sender); } } diff --git a/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelperTest.java b/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelperTest.java index b70e5ddd..e0c185bf 100644 --- a/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelperTest.java +++ b/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelperTest.java @@ -13,7 +13,7 @@ public class PlayerHelperTest { @Test public void testGetOfflinePlayerByName1() { OfflinePlayerEntry ope = PlayerHelper.getOfflinePlayerByName("Relluem94"); - Assert.assertEquals(true, ope != null); + Assert.assertTrue(ope != null); } @Test @@ -35,13 +35,13 @@ public void write(int b) {} OfflinePlayerEntry ope = PlayerHelper.getOfflinePlayerByName("Relluem9494"); System.setOut(sysOut); - Assert.assertEquals(false, ope != null); + Assert.assertFalse(ope != null); } @Test public void testGetOfflinePlayerByUUID1() { OfflinePlayerEntry ope = PlayerHelper.getOfflinePlayerByUUID(UUID.fromString("ec0149f9-8b21-44ee-9731-8bff508087e7")); - Assert.assertEquals(true, ope != null); + Assert.assertTrue(ope != null); } @Test @@ -53,6 +53,6 @@ public void testGetOfflinePlayerByUUID2() { @Test public void testGetOfflinePlayerByUUID3() { OfflinePlayerEntry ope = PlayerHelper.getOfflinePlayerByUUID(UUID.fromString("00000000-AAAA-AAAA-0000-AAFFAAAAAAAA")); - Assert.assertEquals(false, ope != null); + Assert.assertFalse(ope != null); } } \ No newline at end of file diff --git a/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/TypeHelperTest.java b/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/TypeHelperTest.java index 1c75acd7..62441e46 100644 --- a/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/TypeHelperTest.java +++ b/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/TypeHelperTest.java @@ -31,63 +31,63 @@ public void testIsConsole() { @Test public void testIsDouble1() { - Assert.assertEquals(true, TypeHelper.isDouble("12.12")); + Assert.assertTrue(TypeHelper.isDouble("12.12")); } @Test public void testIsDouble2() { - Assert.assertEquals(false, TypeHelper.isDouble("12,12")); + Assert.assertFalse(TypeHelper.isDouble("12,12")); } @Test public void testIsDouble3() { - Assert.assertEquals(true, TypeHelper.isDouble("12.12F")); + Assert.assertTrue(TypeHelper.isDouble("12.12F")); } @Test public void testIsFloat1() { - Assert.assertEquals(true, TypeHelper.isFloat("12.12F")); + Assert.assertTrue(TypeHelper.isFloat("12.12F")); } @Test public void testIsFloat2() { - Assert.assertEquals(true, TypeHelper.isFloat("12.12")); + Assert.assertTrue(TypeHelper.isFloat("12.12")); } @Test public void testIsFloat3() { - Assert.assertEquals(false, TypeHelper.isFloat("test")); + Assert.assertFalse(TypeHelper.isFloat("test")); } @Test public void testIsInt1() { - Assert.assertEquals(false, TypeHelper.isInt("test")); + Assert.assertFalse(TypeHelper.isInt("test")); } @Test public void testIsInt2() { - Assert.assertEquals(true, TypeHelper.isInt("123456")); + Assert.assertTrue(TypeHelper.isInt("123456")); } @Test public void testIsInt3() { - Assert.assertEquals(false, TypeHelper.isInt("19.94F")); + Assert.assertFalse(TypeHelper.isInt("19.94F")); } @Test public void testIsLong1() { - Assert.assertEquals(false, TypeHelper.isLong("19.94F")); + Assert.assertFalse(TypeHelper.isLong("19.94F")); } @Test public void testIsLong2() { - Assert.assertEquals(true, TypeHelper.isLong("1994")); + Assert.assertTrue(TypeHelper.isLong("1994")); } @Test public void testIsLong3() { - Assert.assertEquals(true, TypeHelper.isLong("192910291929192910")); + Assert.assertTrue(TypeHelper.isLong("192910291929192910")); } @Test @@ -97,7 +97,7 @@ public void testIsMaterialInList1() { test.add(Material.COBBLESTONE); test.add(Material.STRIPPED_DARK_OAK_WOOD); - Assert.assertEquals(true, TypeHelper.isMaterialInList(Material.STONE, test)); + Assert.assertTrue(TypeHelper.isMaterialInList(Material.STONE, test)); } @Test @@ -107,7 +107,7 @@ public void testIsMaterialInList2() { test.add(Material.COBBLESTONE); test.add(Material.STRIPPED_DARK_OAK_WOOD); - Assert.assertEquals(true, TypeHelper.isMaterialInList(Material.STRIPPED_DARK_OAK_WOOD, test)); + Assert.assertTrue(TypeHelper.isMaterialInList(Material.STRIPPED_DARK_OAK_WOOD, test)); } @Test @@ -117,6 +117,6 @@ public void testIsMaterialInList3() { test.add(Material.COBBLESTONE); test.add(Material.STRIPPED_DARK_OAK_WOOD); - Assert.assertEquals(false, TypeHelper.isMaterialInList(Material.AIR, test)); + Assert.assertFalse(TypeHelper.isMaterialInList(Material.AIR, test)); } } \ No newline at end of file From f31ae8a9c7fc75e3a34562882f2a7b88ab43d449 Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Wed, 28 Feb 2024 18:23:21 +0100 Subject: [PATCH 20/36] RE-164 Cleanup of Codebase --- .../essentials/constants/EntityCoins.java | 7 ++-- .../essentials/events/ToolCrafting.java | 1 - .../essentials/helpers/DatabaseHelper.java | 35 ++++++++----------- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/EntityCoins.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/EntityCoins.java index 6f7036f1..24f4711d 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/EntityCoins.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/EntityCoins.java @@ -1,5 +1,7 @@ package de.relluem94.minecraft.server.spigot.essentials.constants; +import lombok.Getter; + public enum EntityCoins { /** * Reg Ex to Replace all () to compare and add new Entries @@ -132,13 +134,10 @@ public enum EntityCoins { BLOCK_DISPLAY(0); + @Getter private final int coins; EntityCoins(int coins) { this.coins = coins; } - - public int getCoins(){ - return coins; - } } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/ToolCrafting.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/ToolCrafting.java index fb2b994e..03144194 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/ToolCrafting.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/ToolCrafting.java @@ -1,6 +1,5 @@ package de.relluem94.minecraft.server.spigot.essentials.events; -import java.util.Arrays; import java.util.List; import org.bukkit.Material; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java index 8f85629f..4bb68db3 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java @@ -13,11 +13,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; @@ -62,10 +58,8 @@ public class DatabaseHelper { public static final int DB_TEST_PORT = 65065; - private final String host; private final String user; private final String password; - private final int port; private static final String CONNECTOR = "jdbc:mysql"; private final String connectorString; @@ -75,18 +69,16 @@ public DatabaseHelper(String host, String user, String password, int port) { if(RelluEssentials.getInstance().isUnitTest()){ this.user = "root"; this.password = ""; - this.port = DB_TEST_PORT; + port = DB_TEST_PORT; } else{ this.user = user; this.password = password; - this.port = port; - } + } - this.host = host; - connectorString = CONNECTOR + "://" + this.host + ":" + this.port + "/" + PLUGIN_DATABASE_NAME + connectorString = CONNECTOR + "://" + host + ":" + port + "/" + PLUGIN_DATABASE_NAME + "?useSSL=false&allowPublicKeyRetrieval=true"; - connectorStringInit = CONNECTOR + "://" + this.host + ":" + this.port + connectorStringInit = CONNECTOR + "://" + host + ":" + port + "?useSSL=false&allowPublicKeyRetrieval=true"; @@ -94,14 +86,14 @@ public DatabaseHelper(String host, String user, String password, int port) { public String readResource(final String fileName) throws FileNotFoundException { - String out = ""; + String out; try (InputStream is = getClass().getResourceAsStream("/" + fileName); - InputStreamReader isr = new InputStreamReader(is); - BufferedReader br = new BufferedReader(isr)) { + InputStreamReader isr = new InputStreamReader(Objects.requireNonNull(is)); + BufferedReader br = new BufferedReader(isr)) { String line; StringBuilder sb = new StringBuilder(); while ((line = br.readLine()) != null) { - sb.append(line + Strings.PLUGIN_EOL); + sb.append(line).append(Strings.PLUGIN_EOL); } out = sb.toString(); @@ -283,8 +275,6 @@ public void init() { applyPatch(getPluginInformation().getDbVersion()); } - private final boolean insertScripts = false; // To add Scripts in Development without its own patch version - private void applyPatch(int version) { switch (version) { case -1: @@ -331,12 +321,15 @@ private void applyPatch(int version) { patch7(); break; default: - + // To add Scripts in Development without its own patch version + /* + boolean insertScripts = false; if (insertScripts) { String v = "patches/v7/"; executeScript(v + "script.sql"); } break; + */ } } @@ -1335,7 +1328,7 @@ public void insertLocation(LocationEntry le) { ps.setFloat(4, (float) l.getZ()); ps.setFloat(5, l.getYaw()); ps.setFloat(6, l.getPitch()); - ps.setString(7, l.getWorld().getName()); + ps.setString(7, Objects.requireNonNull(l.getWorld()).getName()); ps.setString(8, le.getLocationName()); ps.setInt(9, le.getLocationType().getId()); ps.setInt(10, le.getPlayerId()); From 86ec7d292bc070816b8c7a2f386262d55ce2abf6 Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Wed, 28 Feb 2024 18:23:54 +0100 Subject: [PATCH 21/36] RE-164 Cleanup of Codebase --- .../server/spigot/essentials/helpers/DatabaseHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java index 4bb68db3..cf9316f2 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java @@ -328,8 +328,8 @@ private void applyPatch(int version) { String v = "patches/v7/"; executeScript(v + "script.sql"); } - break; */ + break; } } From 99ac63c69ece982d443a30b30fc7b8ba9f0bd436 Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Wed, 28 Feb 2024 18:31:55 +0100 Subject: [PATCH 22/36] RE-164 Cleanup of Codebase --- .../spigot/essentials/CustomEnchants.java | 1 - .../server/spigot/essentials/api/BagAPI.java | 11 +-- .../server/spigot/essentials/api/WarpAPI.java | 6 +- .../essentials/constants/EntityCoins.java | 3 +- .../essentials/constants/ItemPrice.java | 12 +--- .../essentials/enchantment/EnchantLevel.java | 18 +---- .../essentials/enchantment/EnchantName.java | 19 +---- .../essentials/helpers/EnchantmentHelper.java | 72 +++++++++---------- .../essentials/helpers/RecipeHelper.java | 6 +- .../essentials/helpers/recipe/Shaped.java | 21 +----- 10 files changed, 49 insertions(+), 120 deletions(-) diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/CustomEnchants.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/CustomEnchants.java index ec8f02a1..dff50286 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/CustomEnchants.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/CustomEnchants.java @@ -1,7 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import org.bukkit.attribute.Attribute; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/BagAPI.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/BagAPI.java index 366daab3..93f57fb3 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/BagAPI.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/BagAPI.java @@ -4,7 +4,9 @@ import java.util.List; import de.relluem94.minecraft.server.spigot.essentials.helpers.pojo.BagTypeEntry; +import lombok.Getter; +@Getter public class BagAPI { private final List bagTypeEntryList = new ArrayList<>(); @@ -16,13 +18,4 @@ public class BagAPI { public BagAPI(List bagTypes) { bagTypeEntryList.addAll(bagTypes); } - - /** - * - * Gives back a List of all BagTypes - * @return List of BagTypeEntry - */ - public List getBagTypeEntryList(){ - return bagTypeEntryList; - } } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/WarpAPI.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/WarpAPI.java index 538be602..cb2523b9 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/WarpAPI.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/WarpAPI.java @@ -3,10 +3,12 @@ import java.util.ArrayList; import java.util.List; +import lombok.Getter; import org.bukkit.World; import de.relluem94.minecraft.server.spigot.essentials.helpers.pojo.LocationEntry; +@Getter public class WarpAPI { private final List warps; @@ -40,10 +42,6 @@ public void addWarp(LocationEntry le){ warps.add(le); } - public List getWarps(){ - return warps; - } - public List getWarps(World world){ List filteredWarps = new ArrayList<>(); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/EntityCoins.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/EntityCoins.java index 24f4711d..52d6e3ed 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/EntityCoins.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/EntityCoins.java @@ -2,6 +2,7 @@ import lombok.Getter; +@Getter public enum EntityCoins { /** * Reg Ex to Replace all () to compare and add new Entries @@ -133,8 +134,6 @@ public enum EntityCoins { INTERACTION(0), BLOCK_DISPLAY(0); - - @Getter private final int coins; EntityCoins(int coins) { diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/ItemPrice.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/ItemPrice.java index 4c8c9ffe..ac610e28 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/ItemPrice.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/ItemPrice.java @@ -1,5 +1,8 @@ package de.relluem94.minecraft.server.spigot.essentials.constants; +import lombok.Getter; + +@Getter public enum ItemPrice { /** * Reg Ex to Replace all () to compare and add new Entries @@ -1430,13 +1433,4 @@ public enum ItemPrice { this.buyPrice = buyPrice; this.sellPrice = sellPrice; } - - public int getBuyPrice() { - return buyPrice; - } - - public int getSellPrice() { - return sellPrice; - } - } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/enchantment/EnchantLevel.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/enchantment/EnchantLevel.java index 59e49160..9e441c1d 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/enchantment/EnchantLevel.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/enchantment/EnchantLevel.java @@ -1,19 +1,3 @@ package de.relluem94.minecraft.server.spigot.essentials.enchantment; -public class EnchantLevel { - private final int startLevel; - private final int maxLevel; - - public EnchantLevel(int startLevel, int maxLevel){ - this.startLevel = startLevel; - this.maxLevel = maxLevel; - } - - public int getStartLevel(){ - return startLevel; - } - - public int getMaxLevel(){ - return maxLevel; - } -} \ No newline at end of file +public record EnchantLevel(int startLevel,int maxLevel) {} \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/enchantment/EnchantName.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/enchantment/EnchantName.java index 3dc63405..b616c59c 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/enchantment/EnchantName.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/enchantment/EnchantName.java @@ -1,20 +1,3 @@ package de.relluem94.minecraft.server.spigot.essentials.enchantment; -public class EnchantName { - - private final String name; - private final String displayName; - - public EnchantName(String name, String displayName){ - this.name = name; - this.displayName = displayName; - } - - public String getName() { - return this.name; - } - - public String getDisplayName() { - return this.displayName; - } -} +public record EnchantName(String name, String displayName) {} \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/EnchantmentHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/EnchantmentHelper.java index d26a8d53..123c4fb7 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/EnchantmentHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/EnchantmentHelper.java @@ -4,7 +4,10 @@ import java.util.Collections; import java.util.List; import java.util.Map.Entry; +import java.util.Objects; +import lombok.Getter; +import lombok.NonNull; import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.attribute.Attribute; @@ -30,12 +33,15 @@ */ public class EnchantmentHelper extends Enchantment implements IEnchantment { + @Getter private String lore; + @Getter private Rarity rarity; private List conflicts; private EnchantmentTarget target; private EnchantLevel level; private EnchantName enchantName; + @Getter private Multimap attributes; private double multiply; private int actualLevel; @@ -45,16 +51,15 @@ public EnchantmentHelper(NamespacedKey id) { } public EnchantmentHelper(EnchantName enchantName, EnchantmentTarget target, EnchantLevel level, List conflicts, String lore, Rarity rarity, Multimap attributes) { - super(new NamespacedKey(RelluEssentials.getInstance(), enchantName.getName())); + super(new NamespacedKey(RelluEssentials.getInstance(), enchantName.name())); this.enchantName = enchantName; this.rarity = rarity; this.target = target; this.level = level; this.lore = lore; - this.conflicts = new ArrayList<>(); this.conflicts = conflicts; this.attributes = attributes; - this.actualLevel = level.getStartLevel(); + this.actualLevel = level.startLevel(); CustomEnchants.customEnchantments.add(this); } @@ -63,34 +68,26 @@ public double getMultiplyer(){ return multiply; } - @Override + @Override @NonNull public String getName() { - return enchantName.getName(); + return enchantName.name(); } public String getDisplayName() { - return enchantName.getDisplayName(); - } - - public String getLore(){ - return lore; - } - - public Rarity getRarity(){ - return rarity; + return enchantName.displayName(); } @Override public int getMaxLevel() { - return level.getMaxLevel(); + return level.maxLevel(); } @Override public int getStartLevel() { - return level.getStartLevel(); + return level.startLevel(); } - @Override + @Override @NonNull public EnchantmentTarget getItemTarget() { return target; } @@ -123,19 +120,15 @@ public boolean canEnchantItem(ItemStack item) { return canEnchantItem; } - public Multimap getAttributes(){ - return attributes; - } - public ItemHelper getBook(){ return new ItemHelper( ItemHelper.addBookEnchantment( new ItemStack(Material.ENCHANTED_BOOK), Enchantment.getByKey( super.getKey() ), - level.getStartLevel() + level.startLevel() ), - enchantName.getDisplayName(), + enchantName.displayName(), ItemHelper.Type.ENCHANTMENT, getRarity() ); @@ -155,13 +148,13 @@ public void addTo(ItemStack i) { for(Attribute a : attributes.asMap().keySet()){ for(AttributeModifier am : attributes.asMap().get(a)){ - im.addAttributeModifier(a, am); + Objects.requireNonNull(im).addAttributeModifier(a, am); } } List itemStackLore; - if (im.getLore() != null) { + if (Objects.requireNonNull(im).getLore() != null) { itemStackLore = im.getLore(); Collections.reverse(itemStackLore); itemStackLore.add(getLore()); @@ -187,29 +180,34 @@ public void removeFrom(ItemStack i) { for(Attribute a : attributes.asMap().keySet()){ for(AttributeModifier am : attributes.asMap().get(a)){ - im.removeAttributeModifier(a, am); + if (im != null) { + im.removeAttributeModifier(a, am); + } } } - List itemStackLore = im.getLore(); - itemStackLore.remove(getDisplayName()); - itemStackLore.remove(getLore()); - itemStackLore.remove(getRarity().getPrefix() + getRarity().getDisplayName()); + List itemStackLore = Objects.requireNonNull(im).getLore(); + if (itemStackLore != null) { + itemStackLore.remove(getDisplayName()); + itemStackLore.remove(getLore()); + itemStackLore.remove(getRarity().getPrefix() + getRarity().getDisplayName()); + } + im.setLore(itemStackLore); i.setItemMeta(im); } } - public static void registerEnchants(Enchantment ench) { + public static void registerEnchants(Enchantment enchantment) { try { Field f; f = Enchantment.class.getDeclaredField("acceptingNew"); f.setAccessible(true); f.set(null, true); - Enchantment.registerEnchantment(ench); - ChatHelper.consoleSendMessage(Strings.PLUGIN_NAME_CONSOLE, String.format(Strings.PLUGIN_MANAGER_REGISTER_ENCHANTMENT, ench.getKey().getNamespace(), ench.getKey())); + Enchantment.registerEnchantment(enchantment); + ChatHelper.consoleSendMessage(Strings.PLUGIN_NAME_CONSOLE, String.format(Strings.PLUGIN_MANAGER_REGISTER_ENCHANTMENT, enchantment.getKey().getNamespace(), enchantment.getKey())); } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) { - ChatHelper.consoleSendMessage(Strings.PLUGIN_NAME_CONSOLE, ex.getMessage() + ": " + ench.getKey()); + ChatHelper.consoleSendMessage(Strings.PLUGIN_NAME_CONSOLE, ex.getMessage() + ": " + enchantment.getKey()); } } @@ -231,7 +229,7 @@ public int hashCode(){ hash = 31 * hash + (lore == null ? 0 : lore.hashCode()); hash = 31 * hash + (conflicts == null ? 0 : conflicts.hashCode()); hash = 31 * hash + (attributes == null ? 0 : attributes.hashCode()); - hash = 31 * hash + (super.getKey() == null ? 0 : super.getKey().hashCode()); + hash = 31 * hash + (super.getKey().hashCode()); return hash; } @@ -241,7 +239,7 @@ public static boolean hasEnchant(ItemStack is, Enchantment e){ return false; } - if(!is.getItemMeta().hasEnchants()){ + if(!Objects.requireNonNull(is.getItemMeta()).hasEnchants()){ return false; } @@ -249,7 +247,7 @@ public static boolean hasEnchant(ItemStack is, Enchantment e){ } private static boolean hasEnchantment(ItemStack is, Enchantment e){ - for(Entry en : is.getItemMeta().getEnchants().entrySet()){ + for(Entry en : Objects.requireNonNull(is.getItemMeta()).getEnchants().entrySet()){ if(en.getKey().getKey().equals(e.getKey())){ return true; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/RecipeHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/RecipeHelper.java index 77a4f192..69cb7c1b 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/RecipeHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/RecipeHelper.java @@ -49,9 +49,9 @@ public Recipe getRecipe(){ if(shape != null){ Recipe recipe = new ShapedRecipe(nameSpacedKey, result); - recipe = ((ShapedRecipe) recipe).shape(shape.getRows()); - for(Character cr : shape.getIngredients().keySet()){ - Material mat = shape.getIngredients().get(cr); + recipe = ((ShapedRecipe) recipe).shape(shape.rows()); + for(Character cr : shape.ingredients().keySet()){ + Material mat = shape.ingredients().get(cr); ((ShapedRecipe) recipe).setIngredient(cr, mat); } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/recipe/Shaped.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/recipe/Shaped.java index a7788a1c..7983aaf7 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/recipe/Shaped.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/recipe/Shaped.java @@ -1,25 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers.recipe; import java.util.Map; - import org.bukkit.Material; -public class Shaped { - private final String[] rows; - - private final Map ingredients; - - public Shaped(String[] rows, Map ingredients){ - this.ingredients = ingredients; - - this.rows = rows; - } - - public String[] getRows(){ - return rows; - } - - public Map getIngredients() { - return ingredients; - } -} +public record Shaped(String[] rows, Map ingredients) {} \ No newline at end of file From 812372d9cba6a2d21819733bee168b2fd236440b Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Wed, 28 Feb 2024 18:45:11 +0100 Subject: [PATCH 23/36] RE-164 Cleanup of Codebase --- .../spigot/essentials/helpers/EnchantmentHelper.java | 9 ++++++--- .../spigot/essentials/helpers/RecipeHelper.java | 12 ++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/EnchantmentHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/EnchantmentHelper.java index 123c4fb7..ba274fe0 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/EnchantmentHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/EnchantmentHelper.java @@ -43,6 +43,7 @@ public class EnchantmentHelper extends Enchantment implements IEnchantment { private EnchantName enchantName; @Getter private Multimap attributes; + @SuppressWarnings("unused") private double multiply; private int actualLevel; @@ -64,7 +65,8 @@ public EnchantmentHelper(EnchantName enchantName, EnchantmentTarget target, Ench CustomEnchants.customEnchantments.add(this); } - public double getMultiplyer(){ + @SuppressWarnings("unused") + public double getMultiplier(){ return multiply; } @@ -103,12 +105,12 @@ public boolean isCursed() { } @Override - public boolean conflictsWith(Enchantment other) { + public boolean conflictsWith(@NonNull Enchantment other) { return conflicts.contains(other); } @Override - public boolean canEnchantItem(ItemStack item) { + public boolean canEnchantItem(@NonNull ItemStack item) { boolean canEnchantItem = target.includes(item); for(Enchantment e : item.getEnchantments().keySet()){ @@ -134,6 +136,7 @@ public ItemHelper getBook(){ ); } + @SuppressWarnings("unused") public void addTo(ItemStack i, int level){ actualLevel = level; addTo(i); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/RecipeHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/RecipeHelper.java index 69cb7c1b..112c4912 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/RecipeHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/RecipeHelper.java @@ -47,20 +47,20 @@ public RecipeHelper(String name, Material[] ingredients, ItemStack result){ */ public Recipe getRecipe(){ if(shape != null){ - Recipe recipe = new ShapedRecipe(nameSpacedKey, result); + ShapedRecipe recipe = new ShapedRecipe(nameSpacedKey, result); - recipe = ((ShapedRecipe) recipe).shape(shape.rows()); + recipe = recipe.shape(shape.rows()); for(Character cr : shape.ingredients().keySet()){ Material mat = shape.ingredients().get(cr); - ((ShapedRecipe) recipe).setIngredient(cr, mat); + recipe.setIngredient(cr, mat); } return recipe; } - - Recipe recipe = new ShapelessRecipe(nameSpacedKey, result); + + ShapelessRecipe recipe = new ShapelessRecipe(nameSpacedKey, result); for(Material m : ingredients){ - ((ShapelessRecipe) recipe).addIngredient(m); + recipe.addIngredient(m); } return recipe; From f4d784b301e9f85472866c6779a8cf19a16fcafa Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Wed, 28 Feb 2024 19:33:46 +0100 Subject: [PATCH 24/36] RE-164 Cleanup of Codebase --- .idea/compiler.xml | 9 +++++++++ SECURITY.md | 4 ++-- dependency-reduced-pom.xml | 4 ++-- pom.xml | 6 +++--- .../server/spigot/essentials/Strings.java | 2 +- .../server/spigot/essentials/commands/AFK.java | 3 ++- .../server/spigot/essentials/commands/Admin.java | 5 +++-- .../server/spigot/essentials/commands/Back.java | 3 ++- .../server/spigot/essentials/commands/Bags.java | 9 ++++++--- .../spigot/essentials/commands/Broadcast.java | 3 ++- .../spigot/essentials/commands/Cookies.java | 3 ++- .../spigot/essentials/commands/CustomHead.java | 3 ++- .../server/spigot/essentials/commands/Day.java | 3 ++- .../spigot/essentials/commands/Enderchest.java | 3 ++- .../server/spigot/essentials/commands/Exit.java | 3 ++- .../server/spigot/essentials/commands/Fly.java | 3 ++- .../spigot/essentials/commands/GameMode.java | 3 ++- .../commands/{Gamerules.java => GameRules.java} | 15 +++++++++------ .../server/spigot/essentials/commands/God.java | 3 ++- .../server/spigot/essentials/commands/Head.java | 3 ++- .../server/spigot/essentials/commands/Heal.java | 7 +++++-- .../server/spigot/essentials/commands/Home.java | 7 ++++--- .../spigot/essentials/commands/Inventory.java | 3 ++- .../server/spigot/essentials/commands/Marry.java | 9 ++++----- .../spigot/essentials/commands/Message.java | 3 ++- .../server/spigot/essentials/commands/More.java | 3 ++- .../server/spigot/essentials/commands/Nick.java | 3 ++- .../server/spigot/essentials/commands/Night.java | 3 ++- .../essentials/commands/PermissionsGroup.java | 3 ++- .../spigot/essentials/commands/PlayerInfo.java | 3 ++- .../server/spigot/essentials/commands/Poke.java | 3 ++- .../commands/PortableCraftingBench.java | 3 ++- .../server/spigot/essentials/commands/Print.java | 3 ++- .../spigot/essentials/commands/Protect.java | 3 ++- .../server/spigot/essentials/commands/Purse.java | 6 ++++-- .../server/spigot/essentials/commands/Rain.java | 3 ++- .../server/spigot/essentials/commands/Rename.java | 3 ++- .../server/spigot/essentials/commands/Repair.java | 3 ++- .../spigot/essentials/commands/Rollback.java | 3 ++- .../server/spigot/essentials/commands/Sign.java | 3 ++- .../server/spigot/essentials/commands/Spawn.java | 3 ++- .../server/spigot/essentials/commands/Speed.java | 3 ++- .../server/spigot/essentials/commands/Storm.java | 3 ++- .../server/spigot/essentials/commands/Sudo.java | 3 ++- .../spigot/essentials/commands/Suicide.java | 3 ++- .../server/spigot/essentials/commands/Sun.java | 3 ++- .../server/spigot/essentials/commands/Team.java | 3 ++- .../spigot/essentials/commands/Teleport.java | 3 ++- .../spigot/essentials/commands/TestCommand.java | 3 ++- .../server/spigot/essentials/commands/Title.java | 3 ++- .../server/spigot/essentials/commands/Vanish.java | 3 ++- .../server/spigot/essentials/commands/Warp.java | 3 ++- .../server/spigot/essentials/commands/Where.java | 3 ++- .../server/spigot/essentials/commands/Worlds.java | 3 ++- .../spigot/essentials/helpers/DatabaseHelper.java | 7 ------- .../essentials/helpers/InventoryHelper.java | 6 +++--- .../spigot/essentials/helpers/NPCHelper.java | 2 +- .../essentials/managers/CommandManager.java | 4 ++-- .../spigot/essentials/permissions/Groups.java | 2 +- src/main/resources/lang.properties | 7 ++++--- .../spigot/essentials/RelluEssentialsTest.java | 8 -------- 61 files changed, 147 insertions(+), 98 deletions(-) rename src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/{Gamerules.java => GameRules.java} (87%) diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 333704a7..9a64a5ec 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -2,10 +2,19 @@ + + + + + + + + + diff --git a/SECURITY.md b/SECURITY.md index 42db8d60..1179c767 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -4,10 +4,10 @@ | Version | Supported | -| ------- | ------------------ | +|---------|--------------------| | <3.3 | :white_check_mark: | | >3.2 | :x: | ## Reporting a Vulnerability -Please create an Issue with the Vulnerability / Libary +Please create an Issue with the Vulnerability / Library diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index 2f26e5f1..e2204ae0 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -22,7 +22,7 @@ maven-compiler-plugin - 3.10.1 + 3.12.1 17 17 @@ -106,7 +106,7 @@ com.github.seeseemelk MockBukkit-v1.20 - 3.19.1 + 3.78.0 test diff --git a/pom.xml b/pom.xml index 553bdc8e..9f359965 100644 --- a/pom.xml +++ b/pom.xml @@ -66,13 +66,13 @@ com.mysql mysql-connector-j - 8.2.0 + 8.0.33 compile com.github.seeseemelk MockBukkit-v1.20 - 3.19.1 + 3.78.0 test @@ -115,7 +115,7 @@ maven-compiler-plugin - 3.10.1 + 3.12.1 17 17 diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/Strings.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/Strings.java index 268d4253..28c7db42 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/Strings.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/Strings.java @@ -12,7 +12,7 @@ private Strings() { /* PLUGIN STUFF */ /*********************************************************************************/ - public static final String PLUGIN_EOL = System.getProperty("line.separator"); + public static final String PLUGIN_EOL = System.lineSeparator(); public static final String PLUGIN_COLOR_COMMAND = "§f"; public static final String PLUGIN_COLOR_COMMAND_NAME = "§b"; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/AFK.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/AFK.java index 4ad0dc55..83cae26e 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/AFK.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/AFK.java @@ -1,5 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials.commands; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -18,7 +19,7 @@ public class AFK implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_AFK)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Admin.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Admin.java index 2f7647a7..d49ca9a9 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Admin.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Admin.java @@ -19,6 +19,7 @@ import java.util.HashMap; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -41,7 +42,7 @@ public class Admin implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_ADMIN)) { return false; } @@ -121,7 +122,7 @@ else if (args[0].equalsIgnoreCase("cleanProtections")) { } } - if (removeMap.size() == 0) { + if (removeMap.isEmpty()) { p.sendMessage(PLUGIN_COMMAND_ADMIN_CLEAN_PROTECTIONS_NONE); } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Back.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Back.java index fca722fd..133f6732 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Back.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Back.java @@ -10,6 +10,7 @@ import java.util.HashMap; import java.util.Map; +import lombok.NonNull; import org.bukkit.Location; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -33,7 +34,7 @@ public static void removeBackPoint(Player p){ } @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_BACK)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Bags.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Bags.java index 276ac561..79ddc057 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Bags.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Bags.java @@ -1,5 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials.commands; +import lombok.NonNull; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -13,6 +14,8 @@ import de.relluem94.minecraft.server.spigot.essentials.helpers.pojo.PlayerEntry; import de.relluem94.minecraft.server.spigot.essentials.permissions.Groups; +import java.util.Objects; + import static de.relluem94.minecraft.server.spigot.essentials.Strings.*; import static de.relluem94.minecraft.server.spigot.essentials.constants.CommandNameConstants.PLUGIN_COMMAND_NAME_BAGS; import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isPlayer; @@ -20,7 +23,7 @@ public class Bags implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_BAGS)) { return false; } @@ -42,7 +45,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St return true; } - BagTypeEntry bte = null; + BagTypeEntry bte; if(TypeUtils.isInt(args[0])){ bte = BagHelper.getBagTypeById(Integer.parseInt(args[0])); } @@ -53,7 +56,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St if(bte != null){ PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); if(BagHelper.hasBag(pe.getId(), bte.getId())){ - p.openInventory(BagHelper.getBag(bte.getId(), pe)); + p.openInventory(Objects.requireNonNull(BagHelper.getBag(bte.getId(), pe))); return true; } else{ diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Broadcast.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Broadcast.java index 71de0d63..4c4d9114 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Broadcast.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Broadcast.java @@ -12,6 +12,7 @@ import static de.relluem94.rellulib.utils.StringUtils.implode; import static de.relluem94.rellulib.utils.StringUtils.replaceSymbols; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -24,7 +25,7 @@ public class Broadcast implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_BROADCAST)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Cookies.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Cookies.java index dfc5a32f..16cdb67d 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Cookies.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Cookies.java @@ -15,6 +15,7 @@ import java.util.Arrays; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.CommandBlock; @@ -33,7 +34,7 @@ public class Cookies implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_COOCKIE)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/CustomHead.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/CustomHead.java index 8a8e32af..d5dfee4c 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/CustomHead.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/CustomHead.java @@ -7,6 +7,7 @@ import static de.relluem94.minecraft.server.spigot.essentials.helpers.PlayerHeadHelper.getCustomSkull; import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isPlayer; +import lombok.NonNull; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -21,7 +22,7 @@ public class CustomHead implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_CUSTOMHEADS)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Day.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Day.java index 4b803faf..3af1c10e 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Day.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Day.java @@ -1,5 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials.commands; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.command.Command; @@ -18,7 +19,7 @@ public class Day implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_DAY)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Enderchest.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Enderchest.java index 7732a76f..fa647b16 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Enderchest.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Enderchest.java @@ -1,5 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials.commands; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -16,7 +17,7 @@ public class Enderchest implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_ENDERCHEST)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Exit.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Exit.java index a16c22e2..c8e050ef 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Exit.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Exit.java @@ -1,5 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials.commands; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -20,7 +21,7 @@ public class Exit implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_EXIT)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Fly.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Fly.java index 31c3755c..a6ddd60f 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Fly.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Fly.java @@ -1,5 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials.commands; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -19,7 +20,7 @@ public class Fly implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_FLY)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/GameMode.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/GameMode.java index 7cd15935..02a1f866 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/GameMode.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/GameMode.java @@ -17,6 +17,7 @@ import static de.relluem94.minecraft.server.spigot.essentials.constants.CommandNameConstants.PLUGIN_COMMAND_NAME_GAMEMODE_3_NAME; import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isPlayer; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -32,7 +33,7 @@ public class GameMode implements CommandExecutor { private static final String LANG_KEY = "PLUGIN_COMMAND_GAMEMODE"; @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, @NonNull Command command, @NonNull String label, String[] args) { if (!Permission.isAuthorized(sender, Groups.getGroup("mod").getId())) { sender.sendMessage(PLUGIN_COMMAND_PERMISSION_MISSING); return true; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Gamerules.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/GameRules.java similarity index 87% rename from src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Gamerules.java rename to src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/GameRules.java index ad39b52e..6de994fd 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Gamerules.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/GameRules.java @@ -14,6 +14,7 @@ import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isConsole; import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isPlayer; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.GameRule; import org.bukkit.World; @@ -25,10 +26,12 @@ import de.relluem94.minecraft.server.spigot.essentials.permissions.Groups; import de.relluem94.minecraft.server.spigot.essentials.permissions.Permission; -public class Gamerules implements CommandExecutor { +import java.util.Objects; + +public class GameRules implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_GAMERULES)) { return false; } @@ -73,10 +76,10 @@ public boolean onCommand(CommandSender sender, Command command, String label, St } private void showGameRule(CommandSender sender, World world) { - String[] gamerules = world.getGameRules(); + String[] gameRules = world.getGameRules(); sendMessage(sender, String.format(PLUGIN_COMMAND_GAMERULES, world.getName())); - for (String gamerule : gamerules) { - Object value = world.getGameRuleValue(GameRule.getByName(gamerule)); + for (String gameRule : gameRules) { + Object value = world.getGameRuleValue(Objects.requireNonNull(GameRule.getByName(gameRule))); String color; if (value instanceof Boolean) { color = ((boolean)value ? PLUGIN_COLOR_POSITIVE : PLUGIN_COLOR_NEGATIVE); @@ -84,7 +87,7 @@ private void showGameRule(CommandSender sender, World world) { color = "§7"; } - sendMessage(sender, " §d" + gamerule + "§f = " + color + value); + sendMessage(sender, " §d" + gameRule + "§f = " + color + value); } } } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/God.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/God.java index d8e5e485..c5a647ef 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/God.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/God.java @@ -12,6 +12,7 @@ import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isConsole; import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isPlayer; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -24,7 +25,7 @@ public class God implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_GOD)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Head.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Head.java index bc3218e6..fa3a0984 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Head.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Head.java @@ -1,5 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials.commands; +import lombok.NonNull; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -18,7 +19,7 @@ public class Head implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_HEAD)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Heal.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Heal.java index 7ae96804..42272e7b 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Heal.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Heal.java @@ -11,6 +11,7 @@ import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isConsole; import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isPlayer; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.attribute.Attribute; import org.bukkit.command.Command; @@ -21,10 +22,12 @@ import de.relluem94.minecraft.server.spigot.essentials.permissions.Groups; import de.relluem94.minecraft.server.spigot.essentials.permissions.Permission; +import java.util.Objects; + public class Heal implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_HEAL)) { return false; } @@ -61,7 +64,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St } private void heal(Player p) { - p.setHealth(p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getDefaultValue()); + p.setHealth(Objects.requireNonNull(p.getAttribute(Attribute.GENERIC_MAX_HEALTH)).getDefaultValue()); p.setFoodLevel(20); p.sendMessage(PLUGIN_COMMAND_HEAL); } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Home.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Home.java index 28bb4e59..6c1af1b2 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Home.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Home.java @@ -22,6 +22,7 @@ import static de.relluem94.minecraft.server.spigot.essentials.helpers.StringHelper.locationToString; import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isPlayer; +import lombok.NonNull; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -36,7 +37,7 @@ public class Home implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_HOME)) { switch (args.length) { case 0: @@ -65,14 +66,14 @@ public boolean onCommand(CommandSender sender, Command command, String label, St if (!pe.getHomes().isEmpty()) { p.sendMessage(PLUGIN_COMMAND_HOME_LIST); - pe.getHomes().stream().forEachOrdered(fle -> p.sendMessage(String.format(PLUGIN_COMMAND_HOME_LIST_NAME, fle.getLocationName(), locationToString(fle.getLocation())))); + pe.getHomes().forEach(fle -> p.sendMessage(String.format(PLUGIN_COMMAND_HOME_LIST_NAME, fle.getLocationName(), locationToString(fle.getLocation())))); } else { p.sendMessage(PLUGIN_COMMAND_HOME_NONE); } if(!pe.getDeaths().isEmpty()){ p.sendMessage(PLUGIN_COMMAND_HOME_LIST_DEATHPOINTS); - pe.getDeaths().stream().forEachOrdered(fle -> p.sendMessage(String.format(PLUGIN_COMMAND_HOME_LIST_DEATHPOINTS_NAME, fle.getLocationName(), locationToString(fle.getLocation())))); + pe.getDeaths().forEach(fle -> p.sendMessage(String.format(PLUGIN_COMMAND_HOME_LIST_DEATHPOINTS_NAME, fle.getLocationName(), locationToString(fle.getLocation())))); } return true; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Inventory.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Inventory.java index b625a6ac..26d5f614 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Inventory.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Inventory.java @@ -8,6 +8,7 @@ import static de.relluem94.minecraft.server.spigot.essentials.constants.CommandNameConstants.PLUGIN_COMMAND_NAME_INVENTORY; import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isPlayer; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -20,7 +21,7 @@ public class Inventory implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_INVENTORY)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Marry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Marry.java index a82c7a98..89782255 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Marry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Marry.java @@ -23,6 +23,7 @@ import java.util.HashMap; import java.util.UUID; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.command.Command; @@ -88,8 +89,7 @@ public void marry(Player player, Player target){ firstPlayer.setPartner(playerPartnerEntry); secondPlayer.setPartner(playerPartnerEntry); - Collection protectionEntryList = new ArrayList<> (); - protectionEntryList.addAll(RelluEssentials.getInstance().getProtectionAPI().getProtectionEntryList().values()); + Collection protectionEntryList = new ArrayList<>(RelluEssentials.getInstance().getProtectionAPI().getProtectionEntryList().values()); for(ProtectionEntry pre : protectionEntryList){ if(pre.getCreatedBy() == firstPlayer.getId()){ @@ -130,8 +130,7 @@ private void divorce(PlayerEntry pe) { RelluEssentials.getInstance().getDatabaseHelper().deletePlayerPartner(ppe); - Collection protectionEntryList = new ArrayList<> (); - protectionEntryList.addAll(RelluEssentials.getInstance().getProtectionAPI().getProtectionEntryList().values()); + Collection protectionEntryList = new ArrayList<>(RelluEssentials.getInstance().getProtectionAPI().getProtectionEntryList().values()); for(ProtectionEntry pre : protectionEntryList){ if(pre.getCreatedBy() == pe.getId()){ @@ -148,7 +147,7 @@ private void divorce(PlayerEntry pe) { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_MARRY)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Message.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Message.java index 57c25f8f..f40f9b52 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Message.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Message.java @@ -3,6 +3,7 @@ import java.util.HashMap; import java.util.Map; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -24,7 +25,7 @@ public class Message implements CommandExecutor { public static final Map reply = new HashMap<>(); @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_MSG)) { if (isPlayer(sender)) { Player p = (Player) sender; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/More.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/More.java index 530e9fa1..8769b61f 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/More.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/More.java @@ -1,5 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials.commands; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -16,7 +17,7 @@ public class More implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_MORE)) { if (args.length == 0) { if (isPlayer(sender)) { diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Nick.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Nick.java index 9e3ab006..e43344a5 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Nick.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Nick.java @@ -7,6 +7,7 @@ import static de.relluem94.minecraft.server.spigot.essentials.constants.CommandNameConstants.PLUGIN_COMMAND_NAME_NICK; import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isPlayer; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -21,7 +22,7 @@ public class Nick implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_NICK)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Night.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Night.java index c48766eb..dcdb13a3 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Night.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Night.java @@ -1,5 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials.commands; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.command.Command; @@ -17,7 +18,7 @@ public class Night implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_NIGHT)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PermissionsGroup.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PermissionsGroup.java index 3c2bb8ea..aa7ab330 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PermissionsGroup.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PermissionsGroup.java @@ -11,6 +11,7 @@ import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isConsole; import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isPlayer; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.command.Command; @@ -29,7 +30,7 @@ public class PermissionsGroup implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_SETGROUP)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PlayerInfo.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PlayerInfo.java index bf6ae478..cec4d126 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PlayerInfo.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PlayerInfo.java @@ -20,6 +20,7 @@ import java.util.Date; +import lombok.NonNull; import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.Statistic; @@ -38,7 +39,7 @@ public class PlayerInfo implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_PLAYERINFO)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Poke.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Poke.java index bad21f23..93ef1d57 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Poke.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Poke.java @@ -12,6 +12,7 @@ import static de.relluem94.minecraft.server.spigot.essentials.helpers.ChatHelper.sendMessage; import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isPlayer; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Sound; @@ -26,7 +27,7 @@ public class Poke implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_POKE)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PortableCraftingBench.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PortableCraftingBench.java index bcb5bf46..7327fbee 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PortableCraftingBench.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PortableCraftingBench.java @@ -1,5 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials.commands; +import lombok.NonNull; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -15,7 +16,7 @@ public class PortableCraftingBench implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_CRAFT)) { return false; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Print.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Print.java index d52f2b68..255c95bd 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Print.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Print.java @@ -19,6 +19,7 @@ import java.util.Arrays; import java.util.List; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.block.CommandBlock; import org.bukkit.command.BlockCommandSender; @@ -36,7 +37,7 @@ public class Print implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { Player targetedPlayerBySelector = null; if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_PRINT)) { diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Protect.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Protect.java index 53b20ec5..b77fdbf4 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Protect.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Protect.java @@ -26,6 +26,7 @@ import static de.relluem94.minecraft.server.spigot.essentials.constants.CommandNameConstants.PLUGIN_COMMAND_NAME_PROTECT_RIGHT_REMOVE; import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isPlayer; +import lombok.NonNull; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -54,7 +55,7 @@ private String getFlags(){ } @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, @NonNull Command command, @NonNull String label, String[] args) { if (isPlayer(sender)) { Player p = (Player) sender; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Purse.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Purse.java index 3aa5cdfe..9a2fd562 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Purse.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Purse.java @@ -13,7 +13,9 @@ import java.util.Arrays; import java.util.Collections; +import java.util.Objects; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -35,7 +37,7 @@ public class Purse implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_PURSE)) { return false; } @@ -90,7 +92,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St if ((purse >= coins)) { ItemStack coin = CustomItems.coins.getCustomItem(); ItemMeta im = coin.getItemMeta(); - im.setLore(Collections.singletonList(String.format(ItemConstants.PLUGIN_ITEM_COINS_LORE, StringHelper.formatInt(coins)))); + Objects.requireNonNull(im).setLore(Collections.singletonList(String.format(ItemConstants.PLUGIN_ITEM_COINS_LORE, StringHelper.formatInt(coins)))); im.getPersistentDataContainer().set(ItemConstants.PLUGIN_ITEM_COINS_NAMESPACE, PersistentDataType.INTEGER, coins); coin.setItemMeta(im); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rain.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rain.java index ec018c13..0766bb54 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rain.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rain.java @@ -1,5 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials.commands; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.WeatherType; import org.bukkit.command.Command; @@ -17,7 +18,7 @@ public class Rain implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_RAIN)) { if (args.length == 0) { if (isPlayer(sender)) { diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rename.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rename.java index 4946dd51..0f865b26 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rename.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rename.java @@ -1,5 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials.commands; +import lombok.NonNull; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -21,7 +22,7 @@ public class Rename implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_RENAME)) { if (args.length >= 1) { if (isPlayer(sender)) { diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Repair.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Repair.java index 1df5a406..e05a5dc8 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Repair.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Repair.java @@ -1,5 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials.commands; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -19,7 +20,7 @@ public class Repair implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_REPAIR)) { if (args.length == 0) { if (isPlayer(sender)) { diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rollback.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rollback.java index aa231775..762262b6 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rollback.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rollback.java @@ -3,6 +3,7 @@ import java.util.List; import java.util.UUID; +import lombok.NonNull; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -49,7 +50,7 @@ public class Rollback implements CommandExecutor { */ @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_ROLLBACK)) { switch (args.length) { case 2: diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Sign.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Sign.java index 1634aa07..ad0ef775 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Sign.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Sign.java @@ -1,5 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials.commands; +import lombok.NonNull; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -18,7 +19,7 @@ public class Sign implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_SIGN)) { if (isPlayer(sender)) { diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Spawn.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Spawn.java index 46adcd2e..dd481ba9 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Spawn.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Spawn.java @@ -7,6 +7,7 @@ import static de.relluem94.minecraft.server.spigot.essentials.constants.CommandNameConstants.PLUGIN_COMMAND_NAME_SPAWN; import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isPlayer; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -19,7 +20,7 @@ public class Spawn implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_SPAWN)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Speed.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Speed.java index b3cb4357..45506475 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Speed.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Speed.java @@ -1,5 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials.commands; +import lombok.NonNull; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -15,7 +16,7 @@ public class Speed implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_SPEED)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Storm.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Storm.java index 185336cf..78f7fab7 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Storm.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Storm.java @@ -1,5 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials.commands; +import lombok.NonNull; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -15,7 +16,7 @@ public class Storm implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_STORM)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Sudo.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Sudo.java index 84e8aa60..5ff31b6d 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Sudo.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Sudo.java @@ -5,6 +5,7 @@ import static de.relluem94.minecraft.server.spigot.essentials.constants.CommandNameConstants.PLUGIN_COMMAND_NAME_SUDO; import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isPlayer; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -26,7 +27,7 @@ public class Sudo implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_SUDO)) { if(RelluEssentials.getInstance().getCommand(args[0]) != null){ diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Suicide.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Suicide.java index f5d688ee..d4569d2a 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Suicide.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Suicide.java @@ -10,6 +10,7 @@ import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isConsole; import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isPlayer; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -22,7 +23,7 @@ public class Suicide implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_SUICIDE)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Sun.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Sun.java index 6ab2576c..ded9cab0 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Sun.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Sun.java @@ -1,5 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials.commands; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.WeatherType; import org.bukkit.command.Command; @@ -17,7 +18,7 @@ public class Sun implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_SUN)) { if (args.length == 0) { if (isPlayer(sender)) { diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Team.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Team.java index 67d299a7..bbe1efd5 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Team.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Team.java @@ -11,6 +11,7 @@ import java.util.Map; import java.util.UUID; +import lombok.NonNull; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -24,7 +25,7 @@ public class Team implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_TEAM)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Teleport.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Teleport.java index df79d280..e3369c62 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Teleport.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Teleport.java @@ -19,6 +19,7 @@ import java.util.HashMap; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.command.Command; @@ -92,7 +93,7 @@ public void teleportTo(Player p, Player t){ @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_TELEPORT)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/TestCommand.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/TestCommand.java index 80b489de..2c0e009a 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/TestCommand.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/TestCommand.java @@ -17,6 +17,7 @@ import java.util.logging.Level; import java.util.logging.Logger; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -51,7 +52,7 @@ public class TestCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_TEST_COMMAND)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Title.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Title.java index c2af9af4..5f172869 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Title.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Title.java @@ -7,6 +7,7 @@ import static de.relluem94.minecraft.server.spigot.essentials.helpers.StringHelper.replaceColor; import static de.relluem94.rellulib.utils.StringUtils.implode; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -19,7 +20,7 @@ public class Title implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_TITLE)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Vanish.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Vanish.java index 8be92c7b..e4660666 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Vanish.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Vanish.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.List; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -23,7 +24,7 @@ public class Vanish implements CommandExecutor { List isVanished = new ArrayList<>(); @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_VANISH)) { if (args.length == 0) { if (isPlayer(sender)) { diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Warp.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Warp.java index 2ec1c5a9..78632361 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Warp.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Warp.java @@ -13,6 +13,7 @@ import static de.relluem94.minecraft.server.spigot.essentials.constants.CommandNameConstants.PLUGIN_COMMAND_NAME_WARP_REMOVE; import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isPlayer; +import lombok.NonNull; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -26,7 +27,7 @@ public class Warp implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_WARP)) { return false; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Where.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Where.java index d21c091c..93a0f828 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Where.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Where.java @@ -8,6 +8,7 @@ import static de.relluem94.minecraft.server.spigot.essentials.helpers.StringHelper.locationToString; import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isPlayer; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -20,7 +21,7 @@ public class Where implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_WHERE)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Worlds.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Worlds.java index 33945ea9..843d7fa5 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Worlds.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Worlds.java @@ -29,6 +29,7 @@ import java.util.logging.Level; import java.util.logging.Logger; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.WorldType; @@ -55,7 +56,7 @@ public class Worlds implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { if (!command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_WORLD)) { return false; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java index cf9316f2..3e83e115 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/DatabaseHelper.java @@ -322,13 +322,6 @@ private void applyPatch(int version) { break; default: // To add Scripts in Development without its own patch version - /* - boolean insertScripts = false; - if (insertScripts) { - String v = "patches/v7/"; - executeScript(v + "script.sql"); - } - */ break; } } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/InventoryHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/InventoryHelper.java index 594a45f3..56ae6af5 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/InventoryHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/InventoryHelper.java @@ -3,6 +3,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.List; +import java.util.logging.Logger; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; @@ -19,7 +20,6 @@ * @author rellu */ public class InventoryHelper { - private InventoryHelper() { throw new IllegalStateException(Strings.PLUGIN_INTERNAL_UTILITY_CLASS); } @@ -145,8 +145,8 @@ public static void createInventory(String json, Player p){ } } - } catch (IOException e1) { - e1.printStackTrace(); + } catch (IOException e) { + Bukkit.getConsoleSender().sendMessage(e.getMessage()); } } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/NPCHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/NPCHelper.java index 4aa3bed9..131619cb 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/NPCHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/NPCHelper.java @@ -24,7 +24,6 @@ public class NPCHelper { private final boolean isCustomNameVisible; private boolean isInvisible; private boolean isCollidable = true; - private final boolean canPickupItems = false; private double health = 0; private final Profession profession; @@ -85,6 +84,7 @@ public void spawn() { livingEntity.setHealth(health); livingEntity.addPotionEffects(potionEffects); livingEntity.setInvisible(isInvisible); + boolean canPickupItems = false; livingEntity.setCanPickupItems(canPickupItems); Villager villager = (Villager) livingEntity; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/CommandManager.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/CommandManager.java index cfb53f6c..1b875d5b 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/CommandManager.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/CommandManager.java @@ -76,7 +76,7 @@ import de.relluem94.minecraft.server.spigot.essentials.commands.Exit; import de.relluem94.minecraft.server.spigot.essentials.commands.Fly; import de.relluem94.minecraft.server.spigot.essentials.commands.GameMode; -import de.relluem94.minecraft.server.spigot.essentials.commands.Gamerules; +import de.relluem94.minecraft.server.spigot.essentials.commands.GameRules; import de.relluem94.minecraft.server.spigot.essentials.commands.God; import de.relluem94.minecraft.server.spigot.essentials.commands.Head; import de.relluem94.minecraft.server.spigot.essentials.commands.Heal; @@ -145,7 +145,7 @@ public void enable() { Objects.requireNonNull(RelluEssentials.getInstance().getCommand(PLUGIN_COMMAND_NAME_HEAL)).setExecutor(new Heal()); Objects.requireNonNull(RelluEssentials.getInstance().getCommand(PLUGIN_COMMAND_NAME_GOD)).setExecutor(new God()); Objects.requireNonNull(RelluEssentials.getInstance().getCommand(PLUGIN_COMMAND_NAME_ADMIN)).setExecutor(new Admin()); - Objects.requireNonNull(RelluEssentials.getInstance().getCommand(PLUGIN_COMMAND_NAME_GAMERULES)).setExecutor(new Gamerules()); + Objects.requireNonNull(RelluEssentials.getInstance().getCommand(PLUGIN_COMMAND_NAME_GAMERULES)).setExecutor(new GameRules()); Objects.requireNonNull(RelluEssentials.getInstance().getCommand(PLUGIN_COMMAND_NAME_HEAD)).setExecutor(new Head()); Objects.requireNonNull(RelluEssentials.getInstance().getCommand(PLUGIN_COMMAND_NAME_VANISH)).setExecutor(new Vanish()); Objects.requireNonNull(RelluEssentials.getInstance().getCommand(PLUGIN_COMMAND_NAME_AFK)).setExecutor(new AFK()); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/permissions/Groups.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/permissions/Groups.java index a8d83cbe..9b2c16d8 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/permissions/Groups.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/permissions/Groups.java @@ -28,7 +28,7 @@ public static GroupEntry getGroup(String name) { return ge; } } - return null; + return new GroupEntry(1, "User", "§8"); } /** diff --git a/src/main/resources/lang.properties b/src/main/resources/lang.properties index e9e8fc02..12540d2b 100644 --- a/src/main/resources/lang.properties +++ b/src/main/resources/lang.properties @@ -1,5 +1,6 @@ +PLUGIN_COMMAND_FLYMODE=Flymode of %s was %s! +PLUGIN_COMMAND_FLYMODE_ACTIVATED=activated +PLUGIN_COMMAND_FLYMODE_DEACTIVATED=deactivated PLUGIN_COMMAND_GAMEMODE=Gamemode of %s was changed to %s! PLUGIN_COMMAND_AFK_ACTIVATED=%s is now \u00a7cafk -PLUGIN_COMMAND_AFK_DEACTIVATED=%s is now \u00a7aback -PLUGIN_COMMAND_FLYMODE_ACTIVATED=Flymode of %s was activated! -PLUGIN_COMMAND_FLYMODE_DEACTIVATED=Flymode of %s was deactivated! \ No newline at end of file +PLUGIN_COMMAND_AFK_DEACTIVATED=%s is now \u00a7aback \ No newline at end of file diff --git a/src/test/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentialsTest.java b/src/test/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentialsTest.java index 545629bf..f490f15e 100644 --- a/src/test/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentialsTest.java +++ b/src/test/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentialsTest.java @@ -69,14 +69,6 @@ public void write(int b) {} addPlayerToDB(player3, "user"); server.getScheduler().performTicks(100L); - - - - //server.execute("setgroup", server.getConsoleSender(), new String[]{player1.getName(), "mod"}); - //server.execute("setgroup", server.getConsoleSender(), new String[]{player2.getName(), "vip"}); - //server.execute("setgroup", server.getConsoleSender(), new String[]{player3.getName(), "user"}); - - //player3.disconnect(); } /** From 1d3b7f97a15c79ca2f236ab4439c402bf1449c7b Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Wed, 28 Feb 2024 20:31:47 +0100 Subject: [PATCH 25/36] RE-164 Cleanup of Codebase --- .idea/encodings.xml | 2 +- .idea/uiDesigner.xml | 124 ++++++++++++++++ .../server/spigot/essentials/Strings.java | 38 +++-- .../spigot/essentials/api/PlayerAPI.java | 12 +- .../spigot/essentials/api/ProtectionAPI.java | 8 +- .../spigot/essentials/commands/Head.java | 5 - .../spigot/essentials/commands/Protect.java | 2 +- .../spigot/essentials/commands/Purse.java | 1 - .../spigot/essentials/commands/Rename.java | 12 +- .../spigot/essentials/commands/Worlds.java | 2 +- .../essentials/constants/CustomHeads.java | 1 + .../spigot/essentials/events/BetterLock.java | 70 +++++----- .../essentials/events/BetterPlayerQuit.java | 5 +- .../essentials/events/ToolCrafting.java | 16 +-- .../essentials/helpers/AttributeHelper.java | 1 + .../essentials/helpers/BankerHelper.java | 8 +- .../spigot/essentials/helpers/ChatHelper.java | 16 +-- .../essentials/helpers/ConfigHelper.java | 103 ++------------ .../essentials/helpers/InventoryHelper.java | 4 +- .../spigot/essentials/helpers/ItemHelper.java | 132 ++++++++---------- .../spigot/essentials/helpers/MobHelper.java | 22 ++- .../spigot/essentials/helpers/NPCHelper.java | 14 +- .../essentials/helpers/PlayerHelper.java | 7 +- .../essentials/helpers/ProtectionHelper.java | 34 ++--- .../spigot/essentials/helpers/UUIDHelper.java | 2 +- .../essentials/items/GrapplingHook.java | 10 -- .../server/spigot/essentials/npc/NPC.java | 4 +- .../spigot/essentials/permissions/Groups.java | 17 ++- .../essentials/permissions/Permission.java | 2 +- 29 files changed, 332 insertions(+), 342 deletions(-) create mode 100644 .idea/uiDesigner.xml diff --git a/.idea/encodings.xml b/.idea/encodings.xml index aa00ffab..86f4b6f0 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -1,7 +1,7 @@ - + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 00000000..2b63946d --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/Strings.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/Strings.java index 28c7db42..0418ebaa 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/Strings.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/Strings.java @@ -8,9 +8,9 @@ private Strings() { throw new IllegalStateException(Strings.PLUGIN_INTERNAL_UTILITY_CLASS); } - /*********************************************************************************/ - /* PLUGIN STUFF */ - /*********************************************************************************/ + /* ******************************************************************************* */ + /* PLUGIN STUFF */ + /* ******************************************************************************* */ public static final String PLUGIN_EOL = System.lineSeparator(); @@ -35,7 +35,6 @@ private Strings() { public static final String PLUGIN_NAME_ESSENTIALS = "Essentials"; public static final String PLUGIN_NAME_INITIAL_RELLU = "R"; public static final String PLUGIN_NAME_INITIAL_ESSENTIALS = "E"; - public static final String PLUGIN_NAME = PLUGIN_NAME_RELLU + PLUGIN_NAME_ESSENTIALS; public static final String PLUGIN_NAME_SHORT = PLUGIN_COLOR_LOGO_RELLU + PLUGIN_NAME_INITIAL_RELLU + PLUGIN_COLOR_LOGO_ESSENTIALS + PLUGIN_NAME_INITIAL_ESSENTIALS + PLUGIN_COLOR_MESSAGE; public static final String PLUGIN_NAME_PREFIX = "§o§l" + PLUGIN_COLOR_LOGO_RELLU + PLUGIN_NAME_RELLU + PLUGIN_COLOR_LOGO_ESSENTIALS + PLUGIN_NAME_ESSENTIALS + PLUGIN_COLOR_RESET + PLUGIN_COLOR_MESSAGE; public static final String PLUGIN_NAME_CONSOLE = PLUGIN_COLOR_MESSAGE + "[" + PLUGIN_NAME_PREFIX + PLUGIN_COLOR_MESSAGE + "] "; @@ -51,21 +50,19 @@ private Strings() { public static final String PLUGIN_FORMS_SPACER_CHANNEL = " >> " + PLUGIN_COLOR_COMMAND; public static final String PLUGIN_FORMS_SPACER_MESSAGE = PLUGIN_COLOR_MESSAGE_SPACER + " >> " + PLUGIN_COLOR_MESSAGE; public static final String PLUGIN_FORMS_BORDER = "<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>"; - public static final String PLUGIN_FORMS_SHORT_BORDER = "<><><><><><><><><><><><><><><><><><>"; - public static final String PLUGIN_FORMS_WHITESPACE = " "; public static final String PLUGIN_FORMS_WHITESPACE_SHORT = " "; public static final String PLUGIN_FORMS_COMMAND_PREFIX = PLUGIN_NAME_PREFIX + PLUGIN_FORMS_SPACER_MESSAGE + PLUGIN_COLOR_COMMAND; - public static final String PLUGIN_SYMBOL_HEAVY_CHECK_MARK = PLUGIN_COLOR_POSITIVE + "\u2714 "; - public static final String PLUGIN_SYMBOL_BLACK_LARGE_CIRCLE = PLUGIN_COLOR_NEUTRAL + "\u2B24 "; - public static final String PLUGIN_SYMBOL_HEAVY_MULTIPLICATION_X = PLUGIN_COLOR_NEGATIVE + "\u2716 "; - public static final String PLUGIN_SYMBOL_RIGHT_POINTING_ANGLE_BRACKET = PLUGIN_COLOR_POSITIVE + "\u232A"; - public static final String PLUGIN_SYMBOL_LEFT_POINTING_ANGLE_BRACKET = PLUGIN_COLOR_NEGATIVE + "\u2329"; - public static final String PLUGIN_SYMBOL_CROSS_MARK = PLUGIN_COLOR_NEGATIVE + "\u274C"; - public static final String PLUGIN_SYMBOL_BLACK_FOUR_POINTED_STAR = PLUGIN_COLOR_POSITIVE + "\u2726"; - public static final String PLUGIN_SYMBOL_HEART = PLUGIN_COLOR_NEGATIVE + "\u2665"; - // \u274C Cross Mark (U+274C) - // \u2726 Black Four Pointed Star (U+2726) + public static final String PLUGIN_SYMBOL_HEAVY_CHECK_MARK = PLUGIN_COLOR_POSITIVE + "✔ "; + public static final String PLUGIN_SYMBOL_BLACK_LARGE_CIRCLE = PLUGIN_COLOR_NEUTRAL + "⬤ "; + public static final String PLUGIN_SYMBOL_HEAVY_MULTIPLICATION_X = PLUGIN_COLOR_NEGATIVE + "✖ "; + public static final String PLUGIN_SYMBOL_RIGHT_POINTING_ANGLE_BRACKET = PLUGIN_COLOR_POSITIVE + "〉"; + public static final String PLUGIN_SYMBOL_LEFT_POINTING_ANGLE_BRACKET = PLUGIN_COLOR_NEGATIVE + "〈"; + public static final String PLUGIN_SYMBOL_CROSS_MARK = PLUGIN_COLOR_NEGATIVE + "❌"; + public static final String PLUGIN_SYMBOL_BLACK_FOUR_POINTED_STAR = PLUGIN_COLOR_POSITIVE + "✦"; + public static final String PLUGIN_SYMBOL_HEART = PLUGIN_COLOR_NEGATIVE + "♥"; + // ❌ Cross Mark (U+274C) + // ✦ Black Four Pointed Star (U+2726) public static final String PLUGIN_SIGN_NAME = PLUGIN_COLOR_MESSAGE + "[" + PLUGIN_NAME_SHORT + "]"; public static final String PLUGIN_SIGN_CLICK = PLUGIN_COLOR_MESSAGE + "[Click here]"; @@ -93,9 +90,9 @@ private Strings() { - /*********************************************************************************/ - /* COMMAND STUFF */ - /*********************************************************************************/ + /* ******************************************************************************* */ + /* COMMAND STUFF */ + /* ******************************************************************************* */ public static final String PLUGIN_COMMAND_FLYMODE = PLUGIN_FORMS_COMMAND_PREFIX + "Der Flugmodus von %s" + PLUGIN_COLOR_COMMAND + " wurde " + PLUGIN_COLOR_COMMAND_ARG + "%s!"; public static final String PLUGIN_COMMAND_FLYMODE_ACTIVATED = "aktiviert"; public static final String PLUGIN_COMMAND_FLYMODE_DEACTIVATED = "deaktiviert"; @@ -109,12 +106,10 @@ private Strings() { public static final String PLUGIN_COMMAND_COOKIES = PLUGIN_FORMS_COMMAND_PREFIX + "Ein Keks für dich, %s"; public static final String PLUGIN_COMMAND_COOKIES_PLAYER = PLUGIN_FORMS_COMMAND_PREFIX + "Du hast %s " + PLUGIN_COLOR_COMMAND + "ein Keks geschenkt!"; public static final String PLUGIN_COMMAND_COOKIES_LORE_1 = PLUGIN_COLOR_COMMAND + "Mit viel Liebe gebacken von %s"; - public static final String PLUGIN_COMMAND_COOKIES_LORE_2 = PLUGIN_COLOR_COMMAND + "Backe doch auch einen Keks!"; public static final String PLUGIN_COMMAND_COOKIES_LORE_3 = PLUGIN_COLOR_COMMAND + "Wie selbstverliebt!"; public static final String PLUGIN_COMMAND_COOKIES_DISPLAYNAME = PLUGIN_COLOR_COMMAND + "Schokoladenkeks"; public static final String PLUGIN_COMMAND_HEAD = PLUGIN_FORMS_COMMAND_PREFIX + "Du hast ein Kopf von " + PLUGIN_COLOR_COMMAND_ARG + "%s " + PLUGIN_COLOR_COMMAND + " erzeugt!"; - public static final String PLUGIN_COMMAND_HEAD_NOT_FOUND = PLUGIN_FORMS_COMMAND_PREFIX + "Es konnte kei Kopf erzeugt werden, Spieler nicht gefunden"; public static final String PLUGIN_COMMAND_VANISH_DISABLE = PLUGIN_FORMS_COMMAND_PREFIX + "Du hast vanish für " + PLUGIN_COLOR_COMMAND_ARG + "%s " + PLUGIN_COLOR_COMMAND + "deaktiviert!"; public static final String PLUGIN_COMMAND_VANISH_ENABLE = PLUGIN_FORMS_COMMAND_PREFIX + "Du hast vanish für " + PLUGIN_COLOR_COMMAND_ARG + "%s " + PLUGIN_COLOR_COMMAND + "aktiviert!"; public static final String PLUGIN_COMMAND_VANISH = PLUGIN_FORMS_COMMAND_PREFIX + "Dein vanish wurde umgeschaltet!"; @@ -258,6 +253,7 @@ private Strings() { public static final String PLUGIN_COMMAND_EXIT_KICK_MESSAGE = PLUGIN_COLOR_COMMAND + "exited."; public static final String PLUGIN_COMMAND_EXIT_SERVER_SHUTTING_DOWN = PLUGIN_COLOR_COMMAND + "Server is shutting down..."; + public static final String PLUGIN_COMMAND_TP_REQUEST = PLUGIN_FORMS_COMMAND_PREFIX + "Du hast " + PLUGIN_COLOR_COMMAND_ARG + "%s" + PLUGIN_COLOR_COMMAND + " eine Teleport Anfrage geschickt"; public static final String PLUGIN_COMMAND_TP_REQUEST_TARGET = PLUGIN_FORMS_COMMAND_PREFIX + "Teleport Anfrage von " + PLUGIN_COLOR_COMMAND_ARG + "%s" + PLUGIN_COLOR_COMMAND; public static final String PLUGIN_COMMAND_TP_REQUEST_EXPIRED = PLUGIN_FORMS_COMMAND_PREFIX + "Teleport Anfrage ist abgelaufen!"; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/PlayerAPI.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/PlayerAPI.java index ac6908c9..c20ff321 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/PlayerAPI.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/PlayerAPI.java @@ -8,6 +8,7 @@ import javax.annotation.Nonnull; +import lombok.Getter; import org.bukkit.entity.Player; import com.google.common.collect.ArrayListMultimap; @@ -20,6 +21,7 @@ public class PlayerAPI { + @Getter private final Map playerEntryMap = new HashMap<>(); private final Multimap playerBagEntryMap = ArrayListMultimap.create(); @@ -52,13 +54,9 @@ public PlayerEntry getPlayerEntry(Player player){ return playerEntryMap.get(player.getUniqueId()); } - public Map getPlayerEntryMap(){ - return playerEntryMap; - } - /** * - * @param playerFK + * @param playerFK int * @return Collection of BagEntries */ public Collection getPlayerBagList(int playerFK){ @@ -67,8 +65,8 @@ public Collection getPlayerBagList(int playerFK){ /** * Adds Player Bag to internal List - * @param playerFK - * @param bagEntry + * @param playerFK int + * @param bagEntry BagEntry */ public void putPlayerBagEntry(int playerFK, @Nonnull BagEntry bagEntry){ playerBagEntryMap.put(playerFK, bagEntry); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/ProtectionAPI.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/ProtectionAPI.java index ef79de06..8ab2e107 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/ProtectionAPI.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/ProtectionAPI.java @@ -26,8 +26,8 @@ public ProtectionAPI(List protectionLocksEntryList, Map getMaterialProtectionList(){ /** * - * @return + * @return Map of Location and ProtectionEntry */ public Map getProtectionEntryList(){ return protectionEntryMap; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Head.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Head.java index fa3a0984..ee94edde 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Head.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Head.java @@ -44,11 +44,6 @@ public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNul String owner = args[0]; ItemStack is = createSkull(owner); - if(is == null){ - sendMessage(p, PLUGIN_COMMAND_HEAD_NOT_FOUND); - return true; - } - p.getInventory().addItem(is); p.updateInventory(); sendMessage(p, String.format(PLUGIN_COMMAND_HEAD, owner)); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Protect.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Protect.java index b77fdbf4..3daf9285 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Protect.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Protect.java @@ -49,7 +49,7 @@ private String getFlags(){ StringBuilder sb = new StringBuilder(); sb.append("Available Flags: "); for(ProtectionFlags flag : flags){ - sb.append(flag.getName() + " "); + sb.append(flag.getName()).append(" "); } return sb.toString(); } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Purse.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Purse.java index 9a2fd562..a9501c4e 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Purse.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Purse.java @@ -11,7 +11,6 @@ import static de.relluem94.minecraft.server.spigot.essentials.constants.CommandNameConstants.PLUGIN_COMMAND_NAME_PURSE; import static de.relluem94.minecraft.server.spigot.essentials.helpers.TypeHelper.isPlayer; -import java.util.Arrays; import java.util.Collections; import java.util.Objects; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rename.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rename.java index 0f865b26..47eb32e6 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rename.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rename.java @@ -26,7 +26,8 @@ public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNul if (command.getName().equalsIgnoreCase(PLUGIN_COMMAND_NAME_RENAME)) { if (args.length >= 1) { if (isPlayer(sender)) { - return rename((Player) sender, args); + rename((Player) sender, args); + return true; } } else { sender.sendMessage(PLUGIN_COMMAND_RENAME_INFO); @@ -36,18 +37,18 @@ public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNul return false; } - private boolean rename(Player p, String[] args) { + private void rename(Player p, String[] args) { if (!Permission.isAuthorized(p, Groups.getGroup("mod").getId())) { p.sendMessage(PLUGIN_COMMAND_PERMISSION_MISSING); - return true; + return; } String message = implode(0, args); message = replaceSymbols(replaceColor(message)); ItemStack is = p.getInventory().getItemInMainHand(); - if (!is.getType().equals(Material.AIR)) { - ItemMeta im = is.getItemMeta(); + ItemMeta im = is.getItemMeta(); + if (!is.getType().equals(Material.AIR) && im != null) { im.setDisplayName(message); is.setItemMeta(im); p.sendMessage(PLUGIN_COMMAND_RENAME); @@ -55,6 +56,5 @@ private boolean rename(Player p, String[] args) { } else { p.sendMessage(PLUGIN_COMMAND_RENAME_AIR); } - return true; } } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Worlds.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Worlds.java index 843d7fa5..02b353ed 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Worlds.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Worlds.java @@ -148,7 +148,7 @@ private void createWorld(Player p, String[] args){ if(WorldType.getByName(args[2].toUpperCase()) != null && World.Environment.valueOf(args[3].toUpperCase()) != null && Boolean.valueOf(args[4]) != null){ WorldType type = WorldType.getByName(args[2].toUpperCase()); World.Environment worldEnvironment = World.Environment.valueOf(args[3].toUpperCase()); - Boolean structures = Boolean.valueOf(args[4]); + boolean structures = Boolean.parseBoolean(args[4]); WorldHelper.createWorld(args[1], type, worldEnvironment, structures); p.sendMessage(PLUGIN_COMMAND_WORLD_CREATE_WORLD); } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/CustomHeads.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/CustomHeads.java index b7a2d4dd..ecccef78 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/CustomHeads.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/CustomHeads.java @@ -2,6 +2,7 @@ import java.util.UUID; +@SuppressWarnings("unused") public enum CustomHeads { BOOKS1("GoodBook1", "2565e12a-e70b-4f64-9398-7d0f108eb53a","ewogICJ0aW1lc3RhbXAiIDogMTY3NTk2OTE2MDIyOCwKICAicHJvZmlsZUlkIiA6ICIyNTY1ZTEyYWU3MGI0ZjY0OTM5ODdkMGYxMDhlYjUzYSIsCiAgInByb2ZpbGVOYW1lIiA6ICJHb29kQm9vazEiLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYWNkMDgxMTY4Y2E4NjYwNGZjZjM3ODAwMzQ4Y2MxNzJjZTc0MDczOWRiM2NjMDgwZjA3ZjFhN2ZiZGZmZjQ4OSIKICAgIH0KICB9Cn0"), diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java index b807dfcf..6a3afd23 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java @@ -86,6 +86,8 @@ import de.relluem94.minecraft.server.spigot.essentials.permissions.Groups; import de.relluem94.minecraft.server.spigot.essentials.permissions.Permission; +import javax.annotation.Nullable; + /** * @@ -140,7 +142,7 @@ private boolean handleMoveItemEvent(Inventory inventory) { private boolean removeProtectionFromBlock(Player p , Block b){ PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); - if(ProtectionHelper.isLockable(b)){ + if(ProtectionHelper.isLockAble(b)){ Location l = ProtectionHelper.getLocationFromBlockAlternateForDoor(b); ProtectionEntry bpe = RelluEssentials.getInstance().getProtectionAPI().getProtectionEntry(l); if (bpe != null) { @@ -231,7 +233,7 @@ else if(isAttachedToBlock(b, BlockFace.UP)){ } private boolean protectBlock(Player p, Block b) { - if(ProtectionHelper.isLockable(b)){ + if(ProtectionHelper.isLockAble(b)){ PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); ProtectionEntry bpe = new ProtectionEntry(); LocationEntry l = RelluEssentials.getInstance().getDatabaseHelper().getLocation(b.getLocation(), 5); @@ -242,30 +244,28 @@ private boolean protectBlock(Player p, Block b) { if(!cd.getType().equals(Type.SINGLE)){ Block b2; - Block b3; - - switch (cd.getFacing()) { - case NORTH: + Block b3 = switch (cd.getFacing()) { + case NORTH -> { b2 = b.getRelative(BlockFace.EAST); - b3 = b.getRelative(BlockFace.WEST); - break; - case EAST: + yield b.getRelative(BlockFace.WEST); + } + case EAST -> { b2 = b.getRelative(BlockFace.SOUTH); - b3 = b.getRelative(BlockFace.NORTH); - break; - case SOUTH: + yield b.getRelative(BlockFace.NORTH); + } + case SOUTH -> { b2 = b.getRelative(BlockFace.WEST); - b3 = b.getRelative(BlockFace.EAST); - break; - default: + yield b.getRelative(BlockFace.EAST); + } + default -> { b2 = b.getRelative(BlockFace.NORTH); - b3 = b.getRelative(BlockFace.SOUTH); - break; - } + yield b.getRelative(BlockFace.SOUTH); + } + }; if(b2.getBlockData() instanceof Chest cd2){ if(cd2.getFacing().equals(cd.getFacing())){ - if(!ProtectionHelper.hasPermission(b2, p)){ + if(ProtectionHelper.hasPermission(b2, p)){ hasRights = false; p.sendMessage(PLUGIN_EVENT_PROTECTED_BLOCK_DISALLOW); p.sendMessage(PLUGIN_EVENT_PROTECT_BLOCK_ADD_CHEST_DENY); @@ -274,7 +274,7 @@ private boolean protectBlock(Player p, Block b) { } else if(b3.getBlockData() instanceof Chest cd3){ if(cd3.getFacing().equals(cd.getFacing())){ - if(!ProtectionHelper.hasPermission(b3, p)){ + if(ProtectionHelper.hasPermission(b3, p)){ hasRights = false; p.sendMessage(PLUGIN_EVENT_PROTECTED_BLOCK_DISALLOW); p.sendMessage(PLUGIN_EVENT_PROTECT_BLOCK_ADD_CHEST_DENY); @@ -660,7 +660,7 @@ public static void removeRight(Player p, ProtectionEntry pre, int id, boolean si } } - public static void removeRight(OfflinePlayer p, ProtectionEntry pre, int id) { + public static void removeRight(@Nullable OfflinePlayer p, ProtectionEntry pre, int id) { removeRight(null, pre, id, true); } @@ -670,7 +670,7 @@ public void onInteract(PlayerInteractEvent e) { if(b != null){ Location l = ProtectionHelper.getLocationFromBlockAlternateForDoor(b); - if(ProtectionHelper.isOpenable(b)){ + if(ProtectionHelper.isOpenAble(b)){ ProtectionEntry protection = RelluEssentials.getInstance().getProtectionAPI().getProtectionEntry(l); PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(e.getPlayer()); if (protection != null && pe != null && @@ -684,7 +684,7 @@ public void onInteract(PlayerInteractEvent e) { pe.getPlayerState().equals(PlayerState.PROTECTION_RIGHT_REMOVE) ) ) { - if (!ProtectionHelper.hasRights(protection, pe.getId())) { + if (ProtectionHelper.hasRights(protection, pe.getId())) { if(ProtectionHelper.hasFlag(protection, ProtectionFlags.ALLOWPUBLIC)){ e.getPlayer().sendMessage(PLUGIN_EVENT_PROTECTED_BLOCK_ALLOW); } @@ -772,11 +772,11 @@ else if(openable instanceof Gate){ } } } - else if(ProtectionHelper.isLockable(b)){ + else if(ProtectionHelper.isLockAble(b)){ ProtectionEntry protection = RelluEssentials.getInstance().getProtectionAPI().getProtectionEntry(l); PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(e.getPlayer()); if (protection != null && pe != null && pe.getPlayerState().equals(PlayerState.DEFAULT)) { - if (!ProtectionHelper.hasRights(protection, pe.getId())) { + if (ProtectionHelper.hasRights(protection, pe.getId())) { if(ProtectionHelper.hasFlag(protection, ProtectionFlags.ALLOWPUBLIC)){ e.getPlayer().sendMessage(PLUGIN_EVENT_PROTECTED_BLOCK_ALLOW); } @@ -815,17 +815,15 @@ public void onMoveItem(InventoryMoveItemEvent e) { public void onBlockRedstoneChange(BlockRedstoneEvent e) { Block b = e.getBlock(); ProtectionEntry protection; - - if (b != null){ - Location l = ProtectionHelper.getLocationFromBlockAlternateForDoor(b); - protection = RelluEssentials.getInstance().getProtectionAPI().getProtectionEntry(l); - - if (protection != null){ - JSONObject flags = protection.getFlags(); - boolean isAllowed = (!flags.isEmpty() && flags.has(PLUGIN_EVENT_PROTECT_FLAGS) && flags.getJSONArray(PLUGIN_EVENT_PROTECT_FLAGS).toList().contains(ProtectionFlags.ALLOWREDSTONE.getName())); - if(!isAllowed){ - e.setNewCurrent(e.getOldCurrent()); - } + + Location l = ProtectionHelper.getLocationFromBlockAlternateForDoor(b); + protection = RelluEssentials.getInstance().getProtectionAPI().getProtectionEntry(l); + + if (protection != null){ + JSONObject flags = protection.getFlags(); + boolean isAllowed = (!flags.isEmpty() && flags.has(PLUGIN_EVENT_PROTECT_FLAGS) && flags.getJSONArray(PLUGIN_EVENT_PROTECT_FLAGS).toList().contains(ProtectionFlags.ALLOWREDSTONE.getName())); + if(!isAllowed){ + e.setNewCurrent(e.getOldCurrent()); } } } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterPlayerQuit.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterPlayerQuit.java index f1609186..205d8b18 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterPlayerQuit.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterPlayerQuit.java @@ -13,6 +13,7 @@ import de.relluem94.minecraft.server.spigot.essentials.helpers.PlayerHelper; import de.relluem94.minecraft.server.spigot.essentials.managers.SudoManager; +import java.util.Objects; public class BetterPlayerQuit implements Listener { @@ -23,12 +24,12 @@ public void onLeave(PlayerQuitEvent e) { Player p = e.getPlayer(); if(SudoManager.sudoers.containsKey(p.getUniqueId())){ - Sudo.exitSudo(Bukkit.getPlayer(p.getUniqueId())); + Sudo.exitSudo(Objects.requireNonNull(Bukkit.getPlayer(p.getUniqueId()))); } PlayerHelper.savePlayer(p); Bukkit.broadcastMessage(String.format(PLUGIN_EVENT_QUIT_MESSAGE, p.getCustomName())); - p.teleport(Bukkit.getWorld(Strings.PLUGIN_WORLD_LOBBY).getSpawnLocation()); + p.teleport(Objects.requireNonNull(Bukkit.getWorld(Strings.PLUGIN_WORLD_LOBBY)).getSpawnLocation()); } } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/ToolCrafting.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/ToolCrafting.java index 03144194..eedfe52f 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/ToolCrafting.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/ToolCrafting.java @@ -31,28 +31,28 @@ public void addRarityToTools(PrepareSmithingEvent e) { ItemMeta im = e.getResult().getItemMeta(); for (Material m : netherite) { - if (e.getResult().getType().equals(m)) { - + if (e.getResult().getType().equals(m) && im != null) { List lore = im.getLore(); - lore.addAll(List.of(Rarity.EPIC.getPrefix() + Rarity.EPIC.getDisplayName())); - lore.remove(Rarity.RARE.getPrefix() + Rarity.RARE.getDisplayName()); + if (lore != null) { + lore.add(Rarity.EPIC.getPrefix() + Rarity.EPIC.getDisplayName()); + lore.remove(Rarity.RARE.getPrefix() + Rarity.RARE.getDisplayName()); + im.setLore(lore); + } - im.setLore(lore); e.getResult().setItemMeta(im); } } } } - private ItemMeta addRarity(Material[] mats, ItemStack is, Rarity rarity){ + private void addRarity(Material[] mats, ItemStack is, Rarity rarity){ ItemMeta im = is.getItemMeta(); for (Material m : mats) { - if (is.getType().equals(m)) { + if (is.getType().equals(m) && im != null) { im.setLore(List.of(rarity.getPrefix() + rarity.getDisplayName())); is.setItemMeta(im); } } - return im; } @EventHandler diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/AttributeHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/AttributeHelper.java index e9cc3864..335e6475 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/AttributeHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/AttributeHelper.java @@ -30,6 +30,7 @@ public static Multimap addAttribute(String uuid, @ return attributes; } + @SuppressWarnings("unused") public static Multimap addAttribute(Multimap attributes, String uuid, @Nonnull Attribute attribute, Operation operation, EquipmentSlot slot, String name, double multiplyer){ attributes.put(attribute, new AttributeModifier(UUID.fromString(uuid), name, multiplyer, operation, slot)); return attributes; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/BankerHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/BankerHelper.java index e67fbfc6..4dc4b63a 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/BankerHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/BankerHelper.java @@ -51,7 +51,7 @@ private BankerHelper() { throw new IllegalStateException(Strings.PLUGIN_INTERNAL_UTILITY_CLASS); } - + @SuppressWarnings("unused") public static final ItemHelper npc_portable_bank = new ItemHelper(Material.YELLOW_SHULKER_BOX, 1, PLUGIN_ITEM_NPC_BANKER_PORTABLE_BANK, Type.TOOL, Rarity.LEGENDARY, List.of(PLUGIN_ITEM_NPC_BANKER_PORTABLE_BANK_LORE1)); public static final ItemHelper npc_gui_deposit = new ItemHelper(Material.GREEN_SHULKER_BOX, 1, PLUGIN_ITEM_NPC_BANKER_GUI_DEPOSIT, Type.NPC_GUI, Rarity.NONE, List.of(PLUGIN_ITEM_NPC_BANKER_GUI_DEPOSIT_LORE1)); @@ -178,7 +178,7 @@ public static void upgradeAccount(ItemStack itemStack, Player p, PlayerEntry pe, continue; } - Long costs = Long.parseLong(ih.getLore().get(0).replace("Costs: ", "")); + long costs = Long.parseLong(ih.getLore().get(0).replace("Costs: ", "")); BankTierEntry bt = getBankTierEntryByCost(costs); if(!checkAccount(p, bae, bt, costs)){ @@ -246,10 +246,6 @@ public static void doInterest(Player p){ public static void checkInterest(UUID uuid, boolean midnight){ OfflinePlayer op = Bukkit.getOfflinePlayer(uuid); - if(op == null){ - return; - } - if(!op.hasPlayedBefore()){ return; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ChatHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ChatHelper.java index 3ef57dbf..a50dc640 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ChatHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ChatHelper.java @@ -64,10 +64,10 @@ public static void consoleSendMessage(String type, String message, int repeat) { /** * - * @param message - * @param p - * @param channel - * @param group + * @param message String + * @param p Player + * @param channel String + * @param group GroupEntry */ public static void sendMessageInChannel(String message, Player p, String channel, GroupEntry group) { message = message.replaceFirst(channel, ""); @@ -80,10 +80,10 @@ public static void sendMessageInChannel(String message, Player p, String channel /** * - * @param message - * @param sender - * @param channel - * @param group + * @param message String + * @param sender String + * @param channel String + * @param group GroupEntry */ public static void sendMessageInChannel(String message, String sender, String channel, GroupEntry group) { message = message.replaceFirst(channel, ""); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ConfigHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ConfigHelper.java index 48e16865..6f12f1cf 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ConfigHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ConfigHelper.java @@ -11,6 +11,9 @@ import de.relluem94.minecraft.server.spigot.essentials.permissions.Groups; import java.util.ArrayList; import java.util.List; +import java.util.Objects; + +import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; @@ -22,15 +25,14 @@ * * @author rellu */ +@Getter public class ConfigHelper { - private final String name; private final File file; private YamlConfiguration config; private boolean configFound = true; public ConfigHelper(String name) { - this.name = name; file = new File(RelluEssentials.getInstance().getDataFolder(), name + ".yml"); if (file.exists()) { @@ -40,10 +42,6 @@ public ConfigHelper(String name) { } } - public boolean isConfigFound(){ - return configFound; - } - /** * * @return Returns List of all Players from config file @@ -52,10 +50,10 @@ public List getPlayers() { List list = new ArrayList<>(); ConfigurationSection cs = config.getConfigurationSection("player"); - for (String uuid : cs.getKeys(false)) { + for (String uuid : Objects.requireNonNull(cs).getKeys(false)) { ConfigurationSection player = cs.getConfigurationSection(uuid); - String groupName = player.getString("group").toLowerCase(); + String groupName = Objects.requireNonNull(Objects.requireNonNull(player).getString("group")).toLowerCase(); int groupFK = Groups.getGroup(groupName).getId(); boolean fly = player.getBoolean("fly"); boolean afk = player.getBoolean("afk"); @@ -84,8 +82,11 @@ public List getPlayers() { public List getHomes(PlayerEntry p) { List list = new ArrayList<>(); ConfigurationSection homes = config.getConfigurationSection("player." + p.getUuid() + ".home"); - for (String home : homes.getKeys(false)) { + for (String home : Objects.requireNonNull(homes).getKeys(false)) { ConfigurationSection h = homes.getConfigurationSection(home); + if(h == null){ + continue; + } float x; float y; @@ -100,7 +101,7 @@ public List getHomes(PlayerEntry p) { int type = home.equals("death") ? 2 : 1; String worldName = h.getString("world"); - World world = Bukkit.getServer().getWorld(worldName); + World world = Bukkit.getServer().getWorld(Objects.requireNonNull(worldName)); consoleSendMessage(PLUGIN_NAME_CONSOLE, "Found Home: " + home + " x:" + x + " y:" + y + " z:" + z + " yaw:" + yaw + " pitch:" + pitch + " world:" + world); @@ -116,86 +117,4 @@ public List getHomes(PlayerEntry p) { } return list; } - - /** - * Returns the Config Name - * - * @return String Config Name - */ - public String getConfigName() { - return name; - } - - /** - * Returns the File - * - * @return File - */ - public File getFile() { - return file; - } - - /** - * Returns the Config - * - * @return YamlConfiguration - */ - public YamlConfiguration getConfig() { - return config; - } - - /** - * Saves the Config - * - * @throws IOException - */ - public void save() throws IOException { - config.save(file); - } - - /** - * Reloads the Config - * - * @throws IOException - * @throws InvalidConfigurationException - */ - public void reload() throws IOException, InvalidConfigurationException { - config.load(file); - } - - /** - * - * @param path where the Location gets saved - * @param l the Location it self - */ - public void setLocation(String path, Location l) { - config.set(path + ".x", l.getX()); - config.set(path + ".y", l.getBlockY()); - config.set(path + ".z", l.getBlockZ()); - config.set(path + ".yaw", l.getYaw()); - config.set(path + ".pitch", l.getPitch()); - config.set(path + ".world", l.getWorld().getName()); - } - - /** - * - * @param path where the Location is saved - * @return Location from the Config Path - */ - public Location getLocation(String path) { - double x; - double y; - double z; - float yaw; - float pitch; - String world; - x = config.getDouble(path + ".x"); - y = config.getDouble(path + ".y"); - z = config.getDouble(path + ".z"); - yaw = (float) config.getDouble(path + ".yaw"); - pitch = (float) config.getDouble(path + ".pitch"); - world = config.getString(path + ".world"); - - return new Location(Bukkit.getWorld(world), x, y, z, yaw, pitch); - } } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/InventoryHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/InventoryHelper.java index 56ae6af5..c7caecd2 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/InventoryHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/InventoryHelper.java @@ -3,8 +3,6 @@ import java.io.IOException; import java.util.Arrays; import java.util.List; -import java.util.logging.Logger; - import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -159,7 +157,7 @@ public static JSONObject saveInventoryToJSON(Player p){ JSONObject slot = new JSONObject(); slot.put(SLOT_NAME_ID ,Integer.valueOf(i)); slot.put(SLOT_NAME_ITEMSTACK, ItemHelper.itemTo64(stack)); - inv.put(Integer.valueOf(i) + "", slot); + inv.put(i + "", slot); } return inv; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ItemHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ItemHelper.java index db37bde4..931fd61b 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ItemHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ItemHelper.java @@ -6,7 +6,9 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Objects; +import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; @@ -28,12 +30,19 @@ public class ItemHelper implements IItemHelper { private final ItemStack is; + + @Getter private final Material material; + + @Getter private final int amount; + + @Getter private final String displayName; private final Type it; private final Rarity ir; + @Getter private List lore; /** @@ -52,7 +61,12 @@ public ItemHelper(Material material, int amount, String displayName, Type itemTy this.ir = itemRarity; is = new ItemStack(this.material, this.amount); + ItemMeta im = is.getItemMeta(); + if(im == null){ + return; + } + im.setDisplayName(this.displayName); is.setItemMeta(im); } @@ -75,7 +89,12 @@ public ItemHelper(Material material, int amount, String displayName, Type itemTy this.ir = itemRarity; is = new ItemStack(this.material, this.amount); + ItemMeta im = is.getItemMeta(); + if(im == null){ + return; + } + im.setDisplayName(this.displayName); im.setLore(this.lore); is.setItemMeta(im); @@ -96,7 +115,12 @@ public ItemHelper(ItemStack is, String displayName, Type itemType, Rarity itemRa this.ir = itemRarity; this.is = is; + ItemMeta im = is.getItemMeta(); + if(im == null){ + return; + } + im.setDisplayName(this.displayName); is.setItemMeta(im); } @@ -118,7 +142,12 @@ public ItemHelper(ItemStack is, String displayName, Type itemType, Rarity itemRa this.ir = itemRarity; this.is = is; + ItemMeta im = is.getItemMeta(); + if(im == null){ + return; + } + im.setDisplayName(this.displayName); im.setLore(this.lore); is.setItemMeta(im); @@ -138,46 +167,16 @@ public ItemStack getCustomItem() { * * @return ItemStack of ItemHelper */ + @SuppressWarnings("unused") protected ItemStack getItemStack() { return is; } - /** - * - * @return int Amount of ItemHelper - */ - public int getAmount() { - return amount; - } - - /** - * - * @return String DisplayName of ItemHelper - */ - public String getDisplayName() { - return displayName; - } - - /** - * - * @return List of String Lore of ItemHelper - */ - public List getLore() { - return lore; - } - - /** - * - * @return Material of ItemHelper - */ - public Material getMaterial() { - return material; - } - /** * * @return ItemType of ItemHelper */ + @SuppressWarnings("unused") public Type getItemType() { return it; } @@ -192,15 +191,15 @@ public ItemMeta getItemMeta() { /** * - * @param itemmeta ItemMeta sets ItemMeta of ItemStack + * @param itemMeta ItemMeta sets ItemMeta of ItemStack */ - public void setItemMeta(ItemMeta itemmeta) { - is.setItemMeta(itemmeta); + public void setItemMeta(ItemMeta itemMeta) { + is.setItemMeta(itemMeta); } /** * - * @param compare + * @param compare ItemStack * @return boolean */ public boolean equalsExact(ItemStack compare) { @@ -217,12 +216,16 @@ public boolean equalsExact(ItemStack compare) { return false; } + if(item.getItemMeta() == null){ + return false; + } + return item.hasItemMeta() && item.getItemMeta().equals(compare.getItemMeta()); } /** * - * @param compare + * @param compare ItemStack * @return boolean */ public boolean equalsName(ItemStack compare) { @@ -239,12 +242,12 @@ public boolean equalsName(ItemStack compare) { return false; } - return item.getItemMeta().getDisplayName().equals(compare.getItemMeta().getDisplayName()) ; + return Objects.requireNonNull(item.getItemMeta()).getDisplayName().equals(Objects.requireNonNull(compare.getItemMeta()).getDisplayName()) ; } /** * - * @param compare + * @param compare ItemStack * @return boolean */ public boolean almostEquals(ItemStack compare) { @@ -273,7 +276,7 @@ public ItemStack postInit(ItemStack is) { private void addItemRarity() { ItemMeta im; - if (is.hasItemMeta()) { + if (is.hasItemMeta() && is.getItemMeta() != null) { im = is.getItemMeta(); List locLore; if (im.getLore() != null) { @@ -306,6 +309,7 @@ public static List remove(List locLore){ return locLore; } + @Getter public enum Rarity { NONE("", "", -1), COMMON("Common", "§f§l", 0), @@ -314,6 +318,7 @@ public enum Rarity { EPIC("Epic", "§5§l", 3), LEGENDARY("Legendary", "§6§l", 4); + private final String displayName; private final String prefix; private final int level; @@ -324,32 +329,6 @@ public enum Rarity { this.level = level; } - /** - * Returns Displayname of Rarity - * - * @return String displayName - */ - public String getDisplayName() { - return displayName; - } - - /** - * Returns Prefix of Rarity (Color and Bold) - * - * @return String prefix - */ - public String getPrefix() { - return prefix; - } - - /** - * Returns Level of Rarity - * - * @return int level - */ - public int getLevel() { - return level; - } } public enum Type { @@ -368,10 +347,11 @@ public enum Type { NONE } - public static ItemStack setDisplayName(ItemStack is, String displayname){ + @SuppressWarnings("unused") + public static ItemStack setDisplayName(ItemStack is, String displayName){ ItemMeta im = is.getItemMeta(); - im.setDisplayName(displayname); + Objects.requireNonNull(im).setDisplayName(displayName); is.setItemMeta(im); return is; @@ -381,6 +361,7 @@ public static ItemStack getCleanItemStack(ItemStack is){ return new ItemStack(is.getType(), 1); } + @SuppressWarnings("unused") public static ItemStack getCleanItemStackWithAmount(ItemStack is){ return new ItemStack(is.getType(), is.getAmount()); } @@ -399,7 +380,7 @@ public static String getItemName(ItemStack is){ String name = ""; if(is.hasItemMeta()){ ItemMeta meta = is.getItemMeta(); - if (meta.hasDisplayName()){ + if (Objects.requireNonNull(meta).hasDisplayName()){ name = meta.getDisplayName(); } else { @@ -417,13 +398,13 @@ public static String getItemName(ItemStack is){ public static ItemStack getSmeltedItemStack(ItemStack is){ ItemStack result = null; - Iterator iter = Bukkit.recipeIterator(); - while (iter.hasNext()) { - Recipe recipe = iter.next(); + Iterator iterator = Bukkit.recipeIterator(); + while (iterator.hasNext()) { + Recipe recipe = iterator.next(); if (!(recipe instanceof FurnaceRecipe)) { continue; } - if (recipe.getResult() != null && ((FurnaceRecipe) recipe).getInput().getType() != is.getType()) { + if (((FurnaceRecipe) recipe).getInput().getType() != is.getType()) { continue; } @@ -460,11 +441,8 @@ public static String itemTo64(ItemStack stack) throws IllegalStateException { public static ItemStack itemFrom64(String data) throws IOException { try { ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data)); - BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream); - try { + try (BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream)) { return (ItemStack) dataInput.readObject(); - } finally { - dataInput.close(); } } catch (ClassNotFoundException e) { diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/MobHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/MobHelper.java index 612058f0..a742fde2 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/MobHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/MobHelper.java @@ -2,6 +2,9 @@ import java.util.Collection; import java.util.HashSet; +import java.util.Objects; + +import lombok.Setter; import org.bukkit.Location; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; @@ -21,17 +24,15 @@ public class MobHelper { private final String customName; private final boolean isCustomNameVisible; private boolean isInvisible; + @Setter private boolean canPickupItems = true; + @Setter private double health = 0; public MobHelper(Location location, EntityType entityType, String customName, boolean isCustomNameVisible) { this.location = location; this.entityType = entityType; - if (customName != null) { - this.customName = customName; - } else { - this.customName = entityType.name(); - } + this.customName = Objects.requireNonNullElseGet(customName, entityType::name); this.isCustomNameVisible = isCustomNameVisible; } @@ -40,20 +41,13 @@ public void setInvisible(boolean isInvisible) { this.isInvisible = isInvisible; } - public void setCanPickupItems(boolean canPickupItems) { - this.canPickupItems = canPickupItems; - } - public void addPotionEffect(PotionEffect potionEffect) { potionEffects.add(potionEffect); } + @SuppressWarnings("unused") public void addPotionEffect(Collection potionEffects) { - potionEffects.addAll(potionEffects); - } - - public void setHealth(double health) { - this.health = health; + this.potionEffects.addAll(potionEffects); } public void spawn(ItemStack mainHand, ItemStack offHand, ItemStack helmet, ItemStack chest, ItemStack leggings, ItemStack boots) { diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/NPCHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/NPCHelper.java index 131619cb..d7e2fde4 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/NPCHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/NPCHelper.java @@ -2,6 +2,9 @@ import java.util.Collection; import java.util.HashSet; +import java.util.Objects; + +import lombok.Setter; import org.bukkit.Location; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; @@ -24,6 +27,7 @@ public class NPCHelper { private final boolean isCustomNameVisible; private boolean isInvisible; private boolean isCollidable = true; + @Setter private double health = 0; private final Profession profession; @@ -48,11 +52,7 @@ public NPCHelper(Location location, String customName, Profession profession, bo this.entityType = EntityType.VILLAGER; this.profession = profession; - if (customName != null) { - this.customName = customName; - } else { - this.customName = entityType.name(); - } + this.customName = Objects.requireNonNullElseGet(customName, entityType::name); this.isCustomNameVisible = isCustomNameVisible; } @@ -61,10 +61,6 @@ public void setInvisible(boolean isInvisible) { this.isInvisible = isInvisible; } - public void setHealth(double health) { - this.health = health; - } - public void setCollidable(boolean b) { this.isCollidable = b; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelper.java index 3c86f283..4e014f8e 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelper.java @@ -59,7 +59,7 @@ public static void setFlying(Player p) { * @param join Boolean * @return Boolean */ - public static boolean setAFK(Player p, boolean join) { + public static void setAFK(Player p, boolean join) { PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p.getUniqueId()); boolean isAFK = pe.isAfk(); @@ -86,7 +86,6 @@ else if(pe.getPlayerState().equals(PlayerState.FAKE_AFK_ON)){ } p.setPlayerListName((isAFK ? "§c[AFK] " : "") + p.getCustomName()); - return true; } @@ -196,9 +195,9 @@ public static void savePlayersInv(){ } - public static int savePlayer(Player p){ + public static void savePlayer(Player p){ PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); - return savePlayer(pe); + savePlayer(pe); } public static int savePlayer(PlayerEntry pe){ diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ProtectionHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ProtectionHelper.java index 79660041..6eb45806 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ProtectionHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ProtectionHelper.java @@ -26,20 +26,20 @@ private ProtectionHelper() { } /** - * Use this Method to check if Block is protectable + * Use this Method to check if Block is protectAble * @param b Block * @return boolean */ - public static boolean isLockable(Block b){ + public static boolean isLockAble(Block b){ return (RelluEssentials.getInstance().getProtectionAPI().getMaterialProtectionList().contains(b.getType())); } /** - * Use this Method to check if a Block is a instance of Openable + * Use this Method to check if a Block is an instance of OpenAble * @param b Block * @return boolean */ - public static boolean isOpenable(Block b){ + public static boolean isOpenAble(Block b){ return b.getBlockData() instanceof Openable; } @@ -54,10 +54,10 @@ public static boolean hasPermission(Block b, Player p){ PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p); ProtectionEntry pre = RelluEssentials.getInstance().getProtectionAPI().getProtectionEntry(l); if (pre != null) { - return pre.getLocationEntry().getPlayerId() == pe.getId(); + return pre.getLocationEntry().getPlayerId() != pe.getId(); } else{ - return true; + return false; } } @@ -100,22 +100,22 @@ public static boolean hasFlag(ProtectionEntry protection, ProtectionFlags flag) public static boolean hasRights(ProtectionEntry protection, int playerId) { JSONObject rights = protection.getRights(); if(!rights.isEmpty() && rights.has(PLUGIN_EVENT_PROTECT_RIGHTS)){ - return (rights.getJSONArray(PLUGIN_EVENT_PROTECT_RIGHTS).toList().contains(playerId)); + return (!rights.getJSONArray(PLUGIN_EVENT_PROTECT_RIGHTS).toList().contains(playerId)); } else{ - return false; + return true; } } /** * - * @param b - * @return + * @param b Block + * @return Location */ public static Location getLocationFromBlockAlternateForDoor(Block b){ if(b != null){ Location l = b.getLocation(); - if(isOpenable(b)){ + if(isOpenAble(b)){ Openable openable = (Openable) b.getBlockData(); if(openable instanceof Door){ Door door = (Door) b.getBlockData(); @@ -131,23 +131,23 @@ public static Location getLocationFromBlockAlternateForDoor(Block b){ /** * - * @param door - * @param block - * @return + * @param door Door + * @param block Block + * @return Block */ public static Block getOtherPart(Door door, Block block) { Location l = block.getLocation().clone(); if(door != null){ - l = addLoccationFromOtherPart(l, door.getFacing(), door.getHinge()); + l = addLocationFromOtherPart(l, door.getFacing(), door.getHinge()); } - if(isOpenable(l.getBlock())){ + if(isOpenAble(l.getBlock())){ return l.getBlock(); } return null; } - private static Location addLoccationFromOtherPart(Location location, BlockFace blockFace, Hinge hinge){ + private static Location addLocationFromOtherPart(Location location, BlockFace blockFace, Hinge hinge){ int plus = 1; int minus = -1; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/UUIDHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/UUIDHelper.java index 9ae79590..c10b04fb 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/UUIDHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/UUIDHelper.java @@ -28,7 +28,7 @@ public static UUID dashed(String id) { /** * converts dashed UUID (long) to unDashed UUID (short) - * @param id + * @param id UUID * @return String */ public static String unDashed(UUID id) { diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/items/GrapplingHook.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/items/GrapplingHook.java index c8b2ea52..c35b9e2b 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/items/GrapplingHook.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/items/GrapplingHook.java @@ -11,14 +11,4 @@ public class GrapplingHook extends ItemHelper{ public GrapplingHook() { super(Material.FISHING_ROD, 1, ItemConstants.PLUGIN_ITEM_GRAPPLINGHOCK, Type.GADGET, Rarity.UNCOMMON); } - - @Override - public void init() { - - } - - @Override - public ItemStack postInit(ItemStack is){ - return is; - } } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/npc/NPC.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/npc/NPC.java index 12e6c7a1..d84507a7 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/npc/NPC.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/npc/NPC.java @@ -1,6 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials.npc; -import java.util.Arrays; +import java.util.List; import org.bukkit.Material; import org.bukkit.entity.Villager.Profession; @@ -29,7 +29,7 @@ public NPC(String name, Profession profession, Type type){ this.name = name; this.profession = profession; this.type = type; - this.npcSpawnItem = new ItemHelper(Material.VILLAGER_SPAWN_EGG, 1, getName(), de.relluem94.minecraft.server.spigot.essentials.helpers.ItemHelper.Type.NPC, Rarity.LEGENDARY, Arrays.asList(ItemConstants.PLUGIN_ITEM_NPC_LORE1)); + this.npcSpawnItem = new ItemHelper(Material.VILLAGER_SPAWN_EGG, 1, getName(), de.relluem94.minecraft.server.spigot.essentials.helpers.ItemHelper.Type.NPC, Rarity.LEGENDARY, List.of(ItemConstants.PLUGIN_ITEM_NPC_LORE1)); RelluEssentials.getInstance().getNpcAPI().addNPC(this); } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/permissions/Groups.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/permissions/Groups.java index 9b2c16d8..1c485010 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/permissions/Groups.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/permissions/Groups.java @@ -16,8 +16,7 @@ private Groups() { } /** - * Returns a GroupEntry if a Group is found by name
- * Returns null if no Group is found + * Returns a GroupEntry if a Group is found by name else User Group is used
* * @param name String * @return GroupEntry @@ -28,9 +27,17 @@ public static GroupEntry getGroup(String name) { return ge; } } - return new GroupEntry(1, "User", "§8"); + return getGroup("user"); } + public static boolean groupExists(String name) { + for (GroupEntry ge : RelluEssentials.getInstance().groupEntryList) { + if (ge.getName().equalsIgnoreCase(name)) { + return true; + } + } + return false; + } /** * Returns a GroupEntry if a Group is found by id
* Returns null if no Group is found @@ -53,9 +60,9 @@ public static GroupEntry getGroup(int id) { * @param groupEntry GroupEntry * @return boolean */ + @SuppressWarnings("unused") public static boolean addGroup(GroupEntry groupEntry) { - if (getGroup(groupEntry.getName()) == null) { - + if (!groupExists(groupEntry.getName())) { RelluEssentials.getInstance().getDatabaseHelper().insertGroup(groupEntry); RelluEssentials.getInstance().groupEntryList.addAll(RelluEssentials.getInstance().getDatabaseHelper().getGroups()); return true; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/permissions/Permission.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/permissions/Permission.java index 33d1be21..0cc292b9 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/permissions/Permission.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/permissions/Permission.java @@ -22,7 +22,7 @@ private Permission() { * * @param p Player * @param group long - * @return + * @return boolean */ public static boolean isAuthorized(Player p, long group) { long id = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p).getGroup().getId(); From f9244462530df559ddce66f81f2da5d784645192 Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Wed, 28 Feb 2024 20:59:59 +0100 Subject: [PATCH 26/36] RE-164 Cleanup of Codebase --- .../spigot/essentials/RelluEssentials.java | 87 ++++--------------- .../spigot/essentials/api/PlayerAPI.java | 2 + .../server/spigot/essentials/api/WarpAPI.java | 10 +-- .../spigot/essentials/commands/Marry.java | 2 +- .../spigot/essentials/commands/Purse.java | 5 +- .../spigot/essentials/commands/Rollback.java | 2 +- .../spigot/essentials/commands/Teleport.java | 20 ++--- .../spigot/essentials/commands/Vanish.java | 2 +- .../essentials/constants/CustomHeads.java | 11 +-- .../essentials/constants/ProtectionFlags.java | 19 ++-- .../spigot/essentials/events/BetterLock.java | 24 +++-- .../spigot/essentials/events/BetterNPC.java | 3 +- .../essentials/events/ToolCrafting.java | 12 +-- .../essentials/helpers/ConfigHelper.java | 2 - .../essentials/helpers/ExperienceHelper.java | 4 +- .../spigot/essentials/helpers/NPCHelper.java | 19 ++-- .../essentials/helpers/PlayerHelper.java | 4 +- .../spigot/essentials/helpers/SignHelper.java | 30 ++----- .../spigot/essentials/helpers/TypeHelper.java | 2 +- .../helpers/pojo/WorldGroupSettingEntry.java | 6 -- .../essentials/items/GrapplingHook.java | 1 - .../essentials/managers/WorldManager.java | 11 ++- .../essentials/helpers/PlayerHelperTest.java | 8 +- .../essentials/helpers/TypeHelperTest.java | 19 ---- 24 files changed, 102 insertions(+), 203 deletions(-) diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentials.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentials.java index 83c1b2d3..0688d2e0 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentials.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentials.java @@ -23,6 +23,8 @@ import java.util.ResourceBundle; import java.util.UUID; +import lombok.Getter; +import lombok.Setter; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.PluginDescriptionFile; @@ -71,18 +73,34 @@ public class RelluEssentials extends JavaPlugin { private long start; private static RelluEssentials instance; + @Getter private DatabaseHelper dBH; + @Setter + @Getter private PluginInformationEntry pie; private static Banker banker; + @Getter private boolean isUnitTest = false; + @Setter + @Getter private PlayerAPI playerAPI; + @Setter + @Getter private ProtectionAPI protectionAPI; + @Setter + @Getter private NPCAPI npcAPI; + @Setter + @Getter private BagAPI bagAPI; + @Setter + @Getter private BankAPI bankAPI; + @Setter + @Getter private WarpAPI warpAPI; public final Map selections = new HashMap<>(); @@ -99,8 +117,7 @@ public class RelluEssentials extends JavaPlugin { public final String[] oreRespawn = new String[]{PLUGIN_WORLD_WORLD_NETHER}; //TODO has to be done in Config (new Table?) #IsComming public static final boolean MONEY_LOST_ON_DEATH = true; public final String[] worlds = new String[]{PLUGIN_WORLD_WORLD, PLUGIN_WORLD_WORLD_NETHER, PLUGIN_WORLD_WORLD_THE_END, PLUGIN_WORLD_LOBBY}; - public final String[][] worldsGroup = new String[][]{new String[]{PLUGIN_WORLD_WORLD, PLUGIN_WORLD_WORLD_NETHER, PLUGIN_WORLD_WORLD_THE_END}, new String[]{PLUGIN_WORLD_LOBBY}}; - + public static synchronized RelluEssentials getInstance() { @@ -192,70 +209,4 @@ protected RelluEssentials(JavaPluginLoader loader, PluginDescriptionFile descrip super(loader, description, dataFolder, file); isUnitTest = true; } - - public boolean isUnitTest(){ - return isUnitTest; - } - - public DatabaseHelper getDatabaseHelper(){ - return dBH; - } - - public PluginInformationEntry getPluginInformation(){ - return pie; - } - - public void setPluginInformation(PluginInformationEntry pie){ - this.pie = pie; - } - - public PlayerAPI getPlayerAPI() { - return playerAPI; - } - - public ProtectionAPI getProtectionAPI() { - return protectionAPI; - } - - public NPCAPI getNpcAPI() { - return npcAPI; - } - - public BagAPI getBagAPI() { - return bagAPI; - } - - public BankAPI getBankAPI() { - return bankAPI; - } - - public WarpAPI getWarpAPI() { - return warpAPI; - } - - public void setPlayerAPI(PlayerAPI playerAPI) { - this.playerAPI = playerAPI; - } - - public void setProtectionAPI(ProtectionAPI protectionAPI) { - this.protectionAPI = protectionAPI; - } - - public void setNpcAPI(NPCAPI npcAPI) { - this.npcAPI = npcAPI; - } - - public void setBagAPI(BagAPI bagAPI) { - this.bagAPI = bagAPI; - } - - public void setBankAPI(BankAPI bankAPI) { - this.bankAPI = bankAPI; - } - - public void setWarpAPI(WarpAPI warpAPI) { - this.warpAPI = warpAPI; - } - - } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/PlayerAPI.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/PlayerAPI.java index c20ff321..c1ee7b5e 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/PlayerAPI.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/PlayerAPI.java @@ -59,6 +59,8 @@ public PlayerEntry getPlayerEntry(Player player){ * @param playerFK int * @return Collection of BagEntries */ + + @SuppressWarnings("unused") public Collection getPlayerBagList(int playerFK){ return playerBagEntryMap.get(playerFK); } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/WarpAPI.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/WarpAPI.java index cb2523b9..ce2f936b 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/WarpAPI.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/WarpAPI.java @@ -9,12 +9,7 @@ import de.relluem94.minecraft.server.spigot.essentials.helpers.pojo.LocationEntry; @Getter -public class WarpAPI { - private final List warps; - - public WarpAPI(List warps){ - this.warps = warps; - } +public record WarpAPI(List warps) { public LocationEntry getWarp(String name){ for(LocationEntry le : warps){ @@ -53,5 +48,4 @@ public List getWarps(World world){ return filteredWarps; } - -} +} \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Marry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Marry.java index 89782255..38bb09e5 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Marry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Marry.java @@ -41,7 +41,7 @@ public class Marry implements CommandExecutor { - HashMap marryAcceptList = new HashMap<>(); + private final HashMap marryAcceptList = new HashMap<>(); private void addMarryEntry(Player player, Player target){ if(RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(player).getPartner() != null || RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(target).getPartner() != null){ diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Purse.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Purse.java index a9501c4e..6f1fe88d 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Purse.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Purse.java @@ -88,7 +88,7 @@ public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNul double purse = pe.getPurse(); int coins = Math.abs(Integer.parseInt(args[0])); - if ((purse >= coins)) { + if (purse >= coins) { ItemStack coin = CustomItems.coins.getCustomItem(); ItemMeta im = coin.getItemMeta(); Objects.requireNonNull(im).setLore(Collections.singletonList(String.format(ItemConstants.PLUGIN_ITEM_COINS_LORE, StringHelper.formatInt(coins)))); @@ -102,10 +102,9 @@ public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNul p.getInventory().addItem(coin); p.sendMessage(String.format(PLUGIN_COMMAND_PURSE_TO_ITEM, StringHelper.formatInt(coins))); - return true; } else { p.sendMessage(PLUGIN_COMMAND_PURSE_TO_ITEM_NOT_ENOUGH_MONEY); - return true; } + return true; } } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rollback.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rollback.java index 762262b6..47a67c75 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rollback.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rollback.java @@ -93,7 +93,7 @@ public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNul p.sendMessage("Added: " + list.size()); } } else if (args[0].equalsIgnoreCase(PLUGIN_COMMAND_NAME_ROLLBACK_UNDO) && args[1].equalsIgnoreCase(PLUGIN_COMMAND_NAME_ROLLBACK_UNDO_PLAYER)) { - + return true; } return true; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Teleport.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Teleport.java index e3369c62..fc346139 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Teleport.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Teleport.java @@ -34,11 +34,11 @@ public class Teleport implements CommandExecutor { - HashMap telportAcceptList = new HashMap<>(); - HashMap telportToAcceptList = new HashMap<>(); + private final HashMap teleportAcceptList = new HashMap<>(); + private final HashMap teleportToAcceptList = new HashMap<>(); private void addTeleportEntry(Player p, Player t){ - telportAcceptList.put(t, p); + teleportAcceptList.put(t, p); t.sendMessage(String.format(PLUGIN_COMMAND_TP_REQUEST_TARGET, p.getCustomName())); Bukkit.getScheduler().runTaskLater(RelluEssentials.getInstance(), () -> { if(hasTeleportEntry(t)){ @@ -51,7 +51,7 @@ private void addTeleportEntry(Player p, Player t){ private void addTeleportToEntry(Player p, Player t){ - telportToAcceptList.put(t, p); + teleportToAcceptList.put(t, p); t.sendMessage(String.format(PLUGIN_COMMAND_TP_REQUEST_TARGET, p.getCustomName())); Bukkit.getScheduler().runTaskLater(RelluEssentials.getInstance(), () -> { if(hasToTeleportEntry(t)){ @@ -63,19 +63,19 @@ private void addTeleportToEntry(Player p, Player t){ } private void removeTeleportEntry(Player t) { - telportAcceptList.remove(t); + teleportAcceptList.remove(t); } private void removeToTeleportEntry(Player t) { - telportToAcceptList.remove(t); + teleportToAcceptList.remove(t); } private boolean hasTeleportEntry(Player t){ - return telportAcceptList.containsKey(t); + return teleportAcceptList.containsKey(t); } private boolean hasToTeleportEntry(Player t){ - return telportToAcceptList.containsKey(t); + return teleportToAcceptList.containsKey(t); } public void teleport(Player p, Player t){ @@ -118,13 +118,13 @@ public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNul if (args.length == 1) { if(args[0].equalsIgnoreCase(PLUGIN_COMMAND_NAME_TELEPORT_ACCEPT)){ if(hasTeleportEntry(p)){ - teleport(p, telportAcceptList.get(p)); + teleport(p, teleportAcceptList.get(p)); removeTeleportEntry(p); return true; } if(hasToTeleportEntry(p)){ - teleportTo(p, telportToAcceptList.get(p)); + teleportTo(p, teleportToAcceptList.get(p)); removeToTeleportEntry(p); return true; } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Vanish.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Vanish.java index e4660666..91cc9d3b 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Vanish.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Vanish.java @@ -21,7 +21,7 @@ public class Vanish implements CommandExecutor { - List isVanished = new ArrayList<>(); + private final List isVanished = new ArrayList<>(); @Override public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNull String label, String[] args) { diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/CustomHeads.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/CustomHeads.java index ecccef78..c23c2760 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/CustomHeads.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/CustomHeads.java @@ -1,5 +1,7 @@ package de.relluem94.minecraft.server.spigot.essentials.constants; +import lombok.Getter; + import java.util.UUID; @SuppressWarnings("unused") @@ -70,8 +72,10 @@ public enum CustomHeads { + @Getter private final String name; private final String uuid; + @Getter private final String base64; CustomHeads(String name, String uuid, String base64){ @@ -80,15 +84,8 @@ public enum CustomHeads { this.base64 = base64; } - public String getName(){ - return name; - } - public UUID getUUID() { return UUID.fromString(uuid); } - public String getBase64(){ - return base64; - } } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/ProtectionFlags.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/ProtectionFlags.java index 9bbecee5..d894e706 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/ProtectionFlags.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/constants/ProtectionFlags.java @@ -1,10 +1,13 @@ package de.relluem94.minecraft.server.spigot.essentials.constants; +import lombok.Getter; + +@Getter public enum ProtectionFlags { - ALLOWHOPPER("allowHopper", false), - ALLOWREDSTONE("allowRedstone", false), - ALLOWPUBLIC("allowPublic", false), - AUTOCLOSE("autoClose", false); + ALLOW_HOPPER("allowHopper", false), + ALLOW_REDSTONE("allowRedstone", false), + ALLOW_PUBLIC("allowPublic", false), + AUTO_CLOSE("autoClose", false); private final String name; @@ -14,12 +17,4 @@ public enum ProtectionFlags { this.name = name; this.isDefault = isDefault; } - - public String getName(){ - return this.name; - } - - public boolean isDefault(){ - return this.isDefault; - } } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java index 6a3afd23..5c9cf2cf 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java @@ -132,7 +132,7 @@ private boolean handleMoveItemEvent(Inventory inventory) { return false; } else{ - return !ProtectionHelper.hasFlag(protection, ProtectionFlags.ALLOWHOPPER); + return !ProtectionHelper.hasFlag(protection, ProtectionFlags.ALLOW_HOPPER); } } else{ @@ -333,7 +333,7 @@ else if(b3.getBlockData() instanceof Chest cd3){ JSONObject flags = new JSONObject(); if(b.getType().equals(Material.LEVER) || b.getType().equals(Material.IRON_DOOR)){ - String[] flag = {ProtectionFlags.ALLOWREDSTONE.getName()}; + String[] flag = {ProtectionFlags.ALLOW_REDSTONE.getName()}; flags.put(PLUGIN_EVENT_PROTECT_FLAGS, flag); } bpe.setFlags(flags); @@ -523,7 +523,7 @@ else if(pe.getPlayerState().equals(PlayerState.PROTECTION_FLAG_ADD)){ else{ JSONObject flags = new JSONObject(); if(b.getType().equals(Material.LEVER) || b.getType().equals(Material.IRON_DOOR)){ - String[] flag = {ProtectionFlags.ALLOWREDSTONE.getName(),ProtectionFlags.valueOf(((String)pe.getPlayerStateParameter()).toUpperCase()).getName()}; + String[] flag = {ProtectionFlags.ALLOW_REDSTONE.getName(),ProtectionFlags.valueOf(((String)pe.getPlayerStateParameter()).toUpperCase()).getName()}; flags.put(PLUGIN_EVENT_PROTECT_FLAGS, flag); } else{ @@ -685,7 +685,7 @@ public void onInteract(PlayerInteractEvent e) { ) ) { if (ProtectionHelper.hasRights(protection, pe.getId())) { - if(ProtectionHelper.hasFlag(protection, ProtectionFlags.ALLOWPUBLIC)){ + if(ProtectionHelper.hasFlag(protection, ProtectionFlags.ALLOW_PUBLIC)){ e.getPlayer().sendMessage(PLUGIN_EVENT_PROTECTED_BLOCK_ALLOW); } else{ @@ -718,7 +718,7 @@ public void onInteract(PlayerInteractEvent e) { else{ door2.setOpen(true); - if(ProtectionHelper.hasFlag(protection, ProtectionFlags.AUTOCLOSE)){ + if(ProtectionHelper.hasFlag(protection, ProtectionFlags.AUTO_CLOSE)){ Bukkit.getScheduler().runTaskLater(RelluEssentials.getInstance(), () -> { door.setOpen(false); door2.setOpen(false); @@ -734,7 +734,7 @@ public void onInteract(PlayerInteractEvent e) { } } else{ - if(ProtectionHelper.hasFlag(protection, ProtectionFlags.AUTOCLOSE)){ + if(ProtectionHelper.hasFlag(protection, ProtectionFlags.AUTO_CLOSE)){ Bukkit.getScheduler().runTaskLater(RelluEssentials.getInstance(), () -> { door.setOpen(false); @@ -746,7 +746,7 @@ public void onInteract(PlayerInteractEvent e) { } else if(openable instanceof TrapDoor){ TrapDoor door = (TrapDoor) b.getBlockData(); - if(ProtectionHelper.hasFlag(protection, ProtectionFlags.AUTOCLOSE)){ + if(ProtectionHelper.hasFlag(protection, ProtectionFlags.AUTO_CLOSE)){ Bukkit.getScheduler().runTaskLater(RelluEssentials.getInstance(), () -> { door.setOpen(false); @@ -757,7 +757,7 @@ else if(openable instanceof TrapDoor){ } else if(openable instanceof Gate){ Gate door = (Gate) b.getBlockData(); - if(ProtectionHelper.hasFlag(protection, ProtectionFlags.AUTOCLOSE)){ + if(ProtectionHelper.hasFlag(protection, ProtectionFlags.AUTO_CLOSE)){ Bukkit.getScheduler().runTaskLater(RelluEssentials.getInstance(), () -> { door.setOpen(false); @@ -766,9 +766,7 @@ else if(openable instanceof Gate){ }, 50); } } - else{ - // Other Openable Objects (Future Implementations) - } + // ELSE Other Openable Objects (Future Implementations) } } } @@ -777,7 +775,7 @@ else if(ProtectionHelper.isLockAble(b)){ PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(e.getPlayer()); if (protection != null && pe != null && pe.getPlayerState().equals(PlayerState.DEFAULT)) { if (ProtectionHelper.hasRights(protection, pe.getId())) { - if(ProtectionHelper.hasFlag(protection, ProtectionFlags.ALLOWPUBLIC)){ + if(ProtectionHelper.hasFlag(protection, ProtectionFlags.ALLOW_PUBLIC)){ e.getPlayer().sendMessage(PLUGIN_EVENT_PROTECTED_BLOCK_ALLOW); } else{ @@ -821,7 +819,7 @@ public void onBlockRedstoneChange(BlockRedstoneEvent e) { if (protection != null){ JSONObject flags = protection.getFlags(); - boolean isAllowed = (!flags.isEmpty() && flags.has(PLUGIN_EVENT_PROTECT_FLAGS) && flags.getJSONArray(PLUGIN_EVENT_PROTECT_FLAGS).toList().contains(ProtectionFlags.ALLOWREDSTONE.getName())); + boolean isAllowed = (!flags.isEmpty() && flags.has(PLUGIN_EVENT_PROTECT_FLAGS) && flags.getJSONArray(PLUGIN_EVENT_PROTECT_FLAGS).toList().contains(ProtectionFlags.ALLOW_REDSTONE.getName())); if(!isAllowed){ e.setNewCurrent(e.getOldCurrent()); } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterNPC.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterNPC.java index a3d6425b..59fa5c6c 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterNPC.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterNPC.java @@ -123,6 +123,7 @@ private void trade(ItemStack is, Inventory inv, Player p, PlayerEntry pe, int sl InventoryHelper.closeInventory(p); } else if(CustomItems.npc_gui_disabled.equalsExact(is)){ + return; // DISABLED DOES NOTHING. COULD BE AN EASTER EGG! } else if(is.getType().equals(Material.PLAYER_HEAD) && is.getItemMeta() instanceof SkullMeta && ((SkullMeta) is.getItemMeta()).getOwnerProfile() != null && ((SkullMeta) is.getItemMeta()).getOwnerProfile().getName().equals(CustomHeads.BAG.getName()) ){ @@ -206,7 +207,7 @@ else if(inv.getType().equals(InventoryType.PLAYER)){ Damageable damageable = ((Damageable) is.getItemMeta()); if(is.getItemMeta().getEnchants().isEmpty() && sellPricePerItem != 0 && !damageable.hasDamage() && (!is.getItemMeta().hasDisplayName() || is.getItemMeta() instanceof SkullMeta)){ - double coins = 0; + double coins; if(isRigthClicked){ amountOfItem = 0; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/ToolCrafting.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/ToolCrafting.java index eedfe52f..7d8ffe1f 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/ToolCrafting.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/ToolCrafting.java @@ -18,12 +18,12 @@ */ public class ToolCrafting implements Listener { - Material[] netherite = new Material[]{Material.NETHERITE_HOE, Material.NETHERITE_AXE, Material.NETHERITE_PICKAXE, Material.NETHERITE_SHOVEL, Material.NETHERITE_SWORD, Material.NETHERITE_HELMET, Material.NETHERITE_CHESTPLATE, Material.NETHERITE_LEGGINGS, Material.NETHERITE_BOOTS}; - Material[] diamond = new Material[]{Material.DIAMOND_HOE, Material.DIAMOND_AXE, Material.DIAMOND_PICKAXE, Material.DIAMOND_SHOVEL, Material.DIAMOND_SWORD, Material.DIAMOND_HELMET, Material.DIAMOND_CHESTPLATE, Material.DIAMOND_LEGGINGS, Material.DIAMOND_BOOTS, Material.DIAMOND_HORSE_ARMOR}; - Material[] iron = new Material[]{Material.IRON_HOE, Material.IRON_AXE, Material.IRON_PICKAXE, Material.IRON_SHOVEL, Material.IRON_SWORD, Material.IRON_HELMET, Material.IRON_CHESTPLATE, Material.IRON_LEGGINGS, Material.IRON_BOOTS, Material.IRON_HORSE_ARMOR}; - Material[] gold = new Material[]{Material.GOLDEN_HOE, Material.GOLDEN_AXE, Material.GOLDEN_PICKAXE, Material.GOLDEN_SHOVEL, Material.GOLDEN_SWORD, Material.GOLDEN_HELMET, Material.GOLDEN_CHESTPLATE, Material.GOLDEN_LEGGINGS, Material.GOLDEN_BOOTS, Material.GOLDEN_HORSE_ARMOR}; - Material[] chainmail = new Material[]{Material.STONE_HOE, Material.STONE_AXE, Material.STONE_PICKAXE, Material.STONE_SHOVEL, Material.STONE_SWORD, Material.CHAINMAIL_HELMET, Material.CHAINMAIL_CHESTPLATE, Material.CHAINMAIL_LEGGINGS, Material.CHAINMAIL_BOOTS}; - Material[] leather = new Material[]{Material.SHIELD, Material.SHEARS, Material.FLINT_AND_STEEL, Material.COMPASS, Material.CLOCK, Material.FISHING_ROD, Material.WOODEN_HOE, Material.WOODEN_AXE, Material.WOODEN_PICKAXE, Material.WOODEN_SHOVEL, Material.WOODEN_SWORD, Material.LEATHER_HELMET, Material.LEATHER_CHESTPLATE, Material.LEATHER_LEGGINGS, Material.LEATHER_BOOTS, Material.LEATHER_HORSE_ARMOR}; + private final Material[] netherite = new Material[]{Material.NETHERITE_HOE, Material.NETHERITE_AXE, Material.NETHERITE_PICKAXE, Material.NETHERITE_SHOVEL, Material.NETHERITE_SWORD, Material.NETHERITE_HELMET, Material.NETHERITE_CHESTPLATE, Material.NETHERITE_LEGGINGS, Material.NETHERITE_BOOTS}; + private final Material[] diamond = new Material[]{Material.DIAMOND_HOE, Material.DIAMOND_AXE, Material.DIAMOND_PICKAXE, Material.DIAMOND_SHOVEL, Material.DIAMOND_SWORD, Material.DIAMOND_HELMET, Material.DIAMOND_CHESTPLATE, Material.DIAMOND_LEGGINGS, Material.DIAMOND_BOOTS, Material.DIAMOND_HORSE_ARMOR}; + private final Material[] iron = new Material[]{Material.IRON_HOE, Material.IRON_AXE, Material.IRON_PICKAXE, Material.IRON_SHOVEL, Material.IRON_SWORD, Material.IRON_HELMET, Material.IRON_CHESTPLATE, Material.IRON_LEGGINGS, Material.IRON_BOOTS, Material.IRON_HORSE_ARMOR}; + private final Material[] gold = new Material[]{Material.GOLDEN_HOE, Material.GOLDEN_AXE, Material.GOLDEN_PICKAXE, Material.GOLDEN_SHOVEL, Material.GOLDEN_SWORD, Material.GOLDEN_HELMET, Material.GOLDEN_CHESTPLATE, Material.GOLDEN_LEGGINGS, Material.GOLDEN_BOOTS, Material.GOLDEN_HORSE_ARMOR}; + private final Material[] chainmail = new Material[]{Material.STONE_HOE, Material.STONE_AXE, Material.STONE_PICKAXE, Material.STONE_SHOVEL, Material.STONE_SWORD, Material.CHAINMAIL_HELMET, Material.CHAINMAIL_CHESTPLATE, Material.CHAINMAIL_LEGGINGS, Material.CHAINMAIL_BOOTS}; + private final Material[] leather = new Material[]{Material.SHIELD, Material.SHEARS, Material.FLINT_AND_STEEL, Material.COMPASS, Material.CLOCK, Material.FISHING_ROD, Material.WOODEN_HOE, Material.WOODEN_AXE, Material.WOODEN_PICKAXE, Material.WOODEN_SHOVEL, Material.WOODEN_SWORD, Material.LEATHER_HELMET, Material.LEATHER_CHESTPLATE, Material.LEATHER_LEGGINGS, Material.LEATHER_BOOTS, Material.LEATHER_HORSE_ARMOR}; @EventHandler public void addRarityToTools(PrepareSmithingEvent e) { diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ConfigHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ConfigHelper.java index 6f12f1cf..923844cc 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ConfigHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ConfigHelper.java @@ -1,7 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers; import java.io.File; -import java.io.IOException; import de.relluem94.minecraft.server.spigot.essentials.RelluEssentials; import static de.relluem94.minecraft.server.spigot.essentials.Strings.PLUGIN_NAME_CONSOLE; import static de.relluem94.minecraft.server.spigot.essentials.helpers.ChatHelper.consoleSendMessage; @@ -18,7 +17,6 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; /** diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ExperienceHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ExperienceHelper.java index 6bcc738c..ee971ca7 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ExperienceHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/ExperienceHelper.java @@ -28,8 +28,8 @@ public static int getTotalExperience(Player player) { } public static void setTotalExperience(Player player, int amount) { - int level = 0; - int xp = 0; + int level; + int xp; float a = 1; float b = 0; float c = -amount; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/NPCHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/NPCHelper.java index d7e2fde4..1eae4a8d 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/NPCHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/NPCHelper.java @@ -4,6 +4,7 @@ import java.util.HashSet; import java.util.Objects; +import lombok.Getter; import lombok.Setter; import org.bukkit.Location; import org.bukkit.entity.EntityType; @@ -23,10 +24,11 @@ public class NPCHelper { private final Location location; private final EntityType entityType; private final Collection potionEffects = new HashSet<>(); + @Getter private final String customName; private final boolean isCustomNameVisible; private boolean isInvisible; - private boolean isCollidable = true; + private boolean isCollideAble = true; @Setter private double health = 0; private final Profession profession; @@ -57,20 +59,22 @@ public NPCHelper(Location location, String customName, Profession profession, bo this.isCustomNameVisible = isCustomNameVisible; } + @SuppressWarnings("unused") public void setInvisible(boolean isInvisible) { this.isInvisible = isInvisible; } - public void setCollidable(boolean b) { - this.isCollidable = b; + @SuppressWarnings("unused") + public void setCollideAble(boolean b) { + this.isCollideAble = b; } public void spawn() { - LivingEntity livingEntity = (LivingEntity) location.getWorld().spawnEntity(location, entityType); + LivingEntity livingEntity = (LivingEntity) Objects.requireNonNull(location.getWorld()).spawnEntity(location, entityType); livingEntity.setCustomName(customName); livingEntity.setCustomNameVisible(isCustomNameVisible); livingEntity.setAI(false); - livingEntity.setCollidable(isCollidable); + livingEntity.setCollidable(isCollideAble); livingEntity.setPersistent(true); if (health == 0 || health > livingEntity.getHealth()) { @@ -86,9 +90,4 @@ public void spawn() { Villager villager = (Villager) livingEntity; villager.setProfession(profession); } - - - public String getCustomName() { - return customName; - } } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelper.java index 4e014f8e..d23718d4 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelper.java @@ -57,7 +57,7 @@ public static void setFlying(Player p) { * * @param p Player * @param join Boolean - * @return Boolean + * */ public static void setAFK(Player p, boolean join) { PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p.getUniqueId()); @@ -159,6 +159,7 @@ public static String getCustomName(Player p) { return name; } + @SuppressWarnings("unused") public static GroupEntry getGroup(Player p) { PlayerEntry pe = RelluEssentials.getInstance().getPlayerAPI().getPlayerEntry(p.getUniqueId()); @@ -220,6 +221,7 @@ public static OfflinePlayer getOfflinePlayer(String name){ return null; } + @SuppressWarnings("unused") public static PlayerEntry getPlayer(String name){ for(PlayerEntry pe : RelluEssentials.getInstance().getPlayerAPI().getPlayerEntryMap().values()){ if(pe.getName().equals(name)){ diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/SignHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/SignHelper.java index a7e3faa9..74b0baba 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/SignHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/SignHelper.java @@ -3,6 +3,7 @@ import static de.relluem94.minecraft.server.spigot.essentials.Strings.PLUGIN_SIGN_CLICK; import static de.relluem94.minecraft.server.spigot.essentials.Strings.PLUGIN_SIGN_NAME; +import lombok.Getter; import org.bukkit.block.Block; import org.bukkit.block.data.type.HangingSign; import org.bukkit.block.data.type.Sign; @@ -15,6 +16,7 @@ * * @author rellu */ +@Getter public class SignHelper { private final String line1; @@ -25,7 +27,7 @@ public class SignHelper { public SignHelper(ActionType signActionType, String customInput) { this.signActionType = signActionType; this.line1 = signActionType.getDisplayName(); - if (signActionType.hasCustomInput()) { + if (signActionType.isCustomInput()) { this.line2 = customInput; } else { this.line2 = ""; @@ -36,27 +38,15 @@ public SignHelper(ActionType signActionType) throws SignMissingCustomInputExcept this.signActionType = signActionType; this.line1 = signActionType.getDisplayName(); this.line2 = ""; - if (signActionType.hasCustomInput()) { + if (signActionType.isCustomInput()) { throw new SignMissingCustomInputException(""); } } - public ActionType getSignActionType() { - return signActionType; - } - public String getLine0() { return PLUGIN_SIGN_NAME; } - public String getLine1() { - return line1; - } - - public String getLine2() { - return line2; - } - public String getLine3() { return PLUGIN_SIGN_CLICK; } @@ -78,6 +68,7 @@ public static boolean isBlockASign(Block b){ ); } + @Getter public enum ActionType { COMMAND(1, "Command", true), TELEPORT(2, "Teleport", true), @@ -96,17 +87,6 @@ public enum ActionType { this.displayName = displayName; } - public int getId() { - return id; - } - - public boolean hasCustomInput() { - return customInput; - } - - public String getDisplayName() { - return displayName; - } public String getShorthand() { return "[" + id + "]"; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/TypeHelper.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/TypeHelper.java index 192602b9..51f6cc84 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/TypeHelper.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/TypeHelper.java @@ -67,7 +67,7 @@ public static boolean areBlocksMaterial(List blocks, Material material) { return isMat; } - public static boolean isBlockOnOfMaterials(Block block, List materials) { + public static boolean isBlockOneOfMaterials(Block block, List materials) { return materials.stream().anyMatch(material -> (block.getType().equals(material))); } diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupSettingEntry.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupSettingEntry.java index 4b7be0e7..566ce2af 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupSettingEntry.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/helpers/pojo/WorldGroupSettingEntry.java @@ -23,10 +23,4 @@ public class WorldGroupSettingEntry { private int deletedBy; private String name; private WorldGroupEntry worldGroupEntry; - public void setSetting(int setting){ - int settingFK = setting; - JSONObject value = null; - DoubleStore ds = new DoubleStore(settingFK, value); - ds.toString(); // TODO remove this nonsense and add pojo for setting - } } \ No newline at end of file diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/items/GrapplingHook.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/items/GrapplingHook.java index c35b9e2b..76636714 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/items/GrapplingHook.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/items/GrapplingHook.java @@ -1,7 +1,6 @@ package de.relluem94.minecraft.server.spigot.essentials.items; import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; import de.relluem94.minecraft.server.spigot.essentials.constants.ItemConstants; import de.relluem94.minecraft.server.spigot.essentials.helpers.ItemHelper; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/WorldManager.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/WorldManager.java index aa2c8476..9494d946 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/WorldManager.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/managers/WorldManager.java @@ -104,6 +104,10 @@ private World.Environment getEnvironment(String name){ private void setLobbySpawnLocation(String name){ World world = Bukkit.getWorld(name); int random = r.nextInt(9+1 -1) +1; + if(world == null){ + return; + } + switch(random){ case 1: world.setSpawnLocation(140, 143, 188); @@ -118,13 +122,18 @@ private void setLobbySpawnLocation(String name){ world.setSpawnLocation(497, 68, -2800); break; default: - world.setSpawnLocation(140, 143, 188); + world.setSpawnLocation(141, 143, 188); break; } } private void setStandardGameRules(String name){ World lobbyWorld = Bukkit.getWorld(name); + + if(lobbyWorld == null){ + return; + } + lobbyWorld.setGameRule(GameRule.DO_FIRE_TICK, false); lobbyWorld.setGameRule(GameRule.DO_MOB_SPAWNING, false); lobbyWorld.setGameRule(GameRule.MOB_GRIEFING, false); diff --git a/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelperTest.java b/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelperTest.java index e0c185bf..be6a2d66 100644 --- a/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelperTest.java +++ b/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelperTest.java @@ -13,7 +13,7 @@ public class PlayerHelperTest { @Test public void testGetOfflinePlayerByName1() { OfflinePlayerEntry ope = PlayerHelper.getOfflinePlayerByName("Relluem94"); - Assert.assertTrue(ope != null); + Assert.assertNotNull(ope); } @Test @@ -35,13 +35,13 @@ public void write(int b) {} OfflinePlayerEntry ope = PlayerHelper.getOfflinePlayerByName("Relluem9494"); System.setOut(sysOut); - Assert.assertFalse(ope != null); + Assert.assertNull(ope); } @Test public void testGetOfflinePlayerByUUID1() { OfflinePlayerEntry ope = PlayerHelper.getOfflinePlayerByUUID(UUID.fromString("ec0149f9-8b21-44ee-9731-8bff508087e7")); - Assert.assertTrue(ope != null); + Assert.assertNotNull(ope); } @Test @@ -53,6 +53,6 @@ public void testGetOfflinePlayerByUUID2() { @Test public void testGetOfflinePlayerByUUID3() { OfflinePlayerEntry ope = PlayerHelper.getOfflinePlayerByUUID(UUID.fromString("00000000-AAAA-AAAA-0000-AAFFAAAAAAAA")); - Assert.assertFalse(ope != null); + Assert.assertNull(ope); } } \ No newline at end of file diff --git a/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/TypeHelperTest.java b/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/TypeHelperTest.java index 62441e46..551f6058 100644 --- a/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/TypeHelperTest.java +++ b/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/TypeHelperTest.java @@ -9,25 +9,6 @@ import org.bukkit.Material; public class TypeHelperTest { - @Test - public void testAreBlocksMaterial() { - - } - - @Test - public void testIsBlockOnOfMaterials() { - - } - - @Test - public void testIsCMDBlock() { - - } - - @Test - public void testIsConsole() { - - } @Test public void testIsDouble1() { From 435bbd6766a2a37edff8b2ce17d001b1fce7b712 Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Wed, 28 Feb 2024 21:08:04 +0100 Subject: [PATCH 27/36] RE-164 Cleanup of Codebase --- .../server/spigot/essentials/RelluEssentials.java | 6 +++--- .../minecraft/server/spigot/essentials/api/WarpAPI.java | 7 ++++++- .../minecraft/server/spigot/essentials/commands/Print.java | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentials.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentials.java index 0688d2e0..7e8750af 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentials.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentials.java @@ -74,10 +74,10 @@ public class RelluEssentials extends JavaPlugin { private static RelluEssentials instance; @Getter - private DatabaseHelper dBH; + private DatabaseHelper databaseHelper; @Setter @Getter - private PluginInformationEntry pie; + private PluginInformationEntry pluginInformation; private static Banker banker; @@ -150,7 +150,7 @@ public void onEnable() { ); dm.enable(); - dBH = dm.getDatabaseHelper(); + databaseHelper = dm.getDatabaseHelper(); diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/WarpAPI.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/WarpAPI.java index ce2f936b..98914bf3 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/WarpAPI.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/WarpAPI.java @@ -9,7 +9,12 @@ import de.relluem94.minecraft.server.spigot.essentials.helpers.pojo.LocationEntry; @Getter -public record WarpAPI(List warps) { +public class WarpAPI { + private final List warps; + + public WarpAPI(List warps){ + this.warps = warps; + } public LocationEntry getWarp(String name){ for(LocationEntry le : warps){ diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Print.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Print.java index 255c95bd..bec74825 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Print.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Print.java @@ -18,6 +18,7 @@ import java.util.Arrays; import java.util.List; +import java.util.Objects; import lombok.NonNull; import org.bukkit.Bukkit; @@ -91,7 +92,7 @@ public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNul message = replaceSymbols(replaceColor(message)); if(targetedPlayerBySelector != null){ - message = message.replace("@p", targetedPlayerBySelector.getCustomName()); + message = message.replace("@p", Objects.requireNonNull(targetedPlayerBySelector.getCustomName())); } Bukkit.broadcastMessage(name + PLUGIN_FORMS_SPACER_MESSAGE+ PLUGIN_COLOR_MESSAGE + message); From 7777eaac807b2d619ed7bb0311cd8eed138e2ef5 Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Wed, 28 Feb 2024 21:12:45 +0100 Subject: [PATCH 28/36] RE-164 Cleanup of Codebase --- .../server/spigot/essentials/commands/PermissionsGroup.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PermissionsGroup.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PermissionsGroup.java index aa7ab330..1b19c929 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PermissionsGroup.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/PermissionsGroup.java @@ -74,7 +74,7 @@ else if (isCMDBlock(sender) || isConsole(sender)) { private static GroupEntry checkGroupExists(String groupName, Player p) { GroupEntry g = Groups.getGroup(groupName); - if(g == null){ + if(Groups.groupExists(groupName)){ p.sendMessage(PLUGIN_COMMAND_SETGROUP_GROUP_NOT_FOUND); return null; } From 39ad761ef9714cd8bf6a3e96632d167e8ec54ccc Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Wed, 28 Feb 2024 21:32:00 +0100 Subject: [PATCH 29/36] RE-164 Test Commit (should fail in Build) --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 9f359965..1ec28f5b 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.1.6 https://github.com/Relluem94s/RelluEssentials - 1.19 + 1.20 Relluem94 https://www.relluem94.de de.relluem94.minecraft.server.spigot.essentials.RelluEssentials @@ -48,13 +48,13 @@ org.spigotmc spigot-api - 1.20.1-R0.1-SNAPSHOT + 1.20.4-R0.1-SNAPSHOT provided org.spigotmc spigot - 1.20.1-R0.1-SNAPSHOT + 1.20.4-R0.1-SNAPSHOT provided @@ -66,7 +66,7 @@ com.mysql mysql-connector-j - 8.0.33 + 8.3.0 compile From c9d0776e2384f87da10d23a8f657dfd020d68228 Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Wed, 28 Feb 2024 22:10:35 +0100 Subject: [PATCH 30/36] RE-164 Test Commit (should work in Build) --- .idea/dbnavigator.xml | 512 ++++++++++++++++++ dependency-reduced-pom.xml | 74 ++- pom.xml | 37 +- .../spigot/essentials/api/PlayerAPI.java | 4 +- .../spigot/essentials/events/BetterLock.java | 1 - .../essentials/RelluEssentialsTest.java | 180 +----- 6 files changed, 604 insertions(+), 204 deletions(-) create mode 100644 .idea/dbnavigator.xml diff --git a/.idea/dbnavigator.xml b/.idea/dbnavigator.xml new file mode 100644 index 00000000..137a7ae2 --- /dev/null +++ b/.idea/dbnavigator.xml @@ -0,0 +1,512 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
\ No newline at end of file diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index e2204ae0..2ce6b5e0 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -97,12 +97,6 @@ 1.20.1-R0.1-SNAPSHOT provided
- - org.spigotmc - spigot - 1.20.1-R0.1-SNAPSHOT - provided - com.github.seeseemelk MockBukkit-v1.20 @@ -125,14 +119,22 @@ adventure-platform-bungeecord net.kyori
- - annotations - org.jetbrains - byte-buddy net.bytebuddy + + maven-resolver-provider + org.apache.maven + + + maven-resolver-connector-basic + org.apache.maven.resolver + + + maven-resolver-transport-http + org.apache.maven.resolver +
@@ -168,10 +170,52 @@
- org.projectlombok - lombok - 1.18.30 - provided + org.junit.jupiter + junit-jupiter-engine + 5.10.1 + test + + + junit-platform-engine + org.junit.platform + + + junit-jupiter-api + org.junit.jupiter + + + apiguardian-api + org.apiguardian + + + + + org.junit.platform + junit-platform-runner + 1.10.1 + test + + + junit + junit + + + junit-platform-launcher + org.junit.platform + + + junit-platform-suite-api + org.junit.platform + + + junit-platform-suite-commons + org.junit.platform + + + apiguardian-api + org.apiguardian + + @@ -183,7 +227,7 @@ 17 - 1.19 + 1.20 Relluem94 windows-1252 https://www.relluem94.de diff --git a/pom.xml b/pom.xml index 1ec28f5b..41370b25 100644 --- a/pom.xml +++ b/pom.xml @@ -48,13 +48,7 @@ org.spigotmc spigot-api - 1.20.4-R0.1-SNAPSHOT - provided - - - org.spigotmc - spigot - 1.20.4-R0.1-SNAPSHOT + 1.20.1-R0.1-SNAPSHOT provided @@ -101,8 +95,35 @@ org.projectlombok lombok 1.18.30 - provided + + com.mojang + authlib + 4.0.43 + + + org.jetbrains + annotations + 24.1.0 + + + com.google.guava + guava + 32.1.3-jre + + + org.junit.jupiter + junit-jupiter-engine + 5.10.1 + test + + + org.junit.platform + junit-platform-runner + 1.10.1 + test + + diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/PlayerAPI.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/PlayerAPI.java index c1ee7b5e..bba8cbed 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/PlayerAPI.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/api/PlayerAPI.java @@ -6,8 +6,6 @@ import java.util.Map; import java.util.UUID; -import javax.annotation.Nonnull; - import lombok.Getter; import org.bukkit.entity.Player; @@ -19,6 +17,8 @@ import de.relluem94.minecraft.server.spigot.essentials.helpers.pojo.PlayerEntry; import de.relluem94.minecraft.server.spigot.essentials.helpers.pojo.PlayerPartnerEntry; +import javax.annotation.Nonnull; + public class PlayerAPI { @Getter diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java index 5c9cf2cf..2c7e3ec7 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/events/BetterLock.java @@ -88,7 +88,6 @@ import javax.annotation.Nullable; - /** * * @author rellu diff --git a/src/test/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentialsTest.java b/src/test/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentialsTest.java index f490f15e..a9bbc31d 100644 --- a/src/test/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentialsTest.java +++ b/src/test/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentialsTest.java @@ -11,6 +11,7 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayName; import be.seeseemelk.mockbukkit.MockBukkit; @@ -23,184 +24,7 @@ import de.relluem94.minecraft.server.spigot.essentials.helpers.pojo.PlayerEntry; import de.relluem94.minecraft.server.spigot.essentials.permissions.Groups; -public class RelluEssentialsTest { - - private static ServerMock server; - private static RelluEssentials plugin; - private static DB db; - private static PlayerMock player1; - private static PlayerMock player2; - private static PlayerMock player3; - - - @BeforeClass - public static void setUp() throws ManagedProcessException { - PrintStream sysOut = System.out; - - PrintStream noOut = new PrintStream(new OutputStream(){ - public void write(int b) {} - }); - - System.setOut(noOut); - - db = DB.newEmbeddedDB(DatabaseHelper.DB_TEST_PORT); - db.start(); - System.setOut(sysOut); - - db.createDB(DatabaseConstants.PLUGIN_DATABASE_NAME); - db.source("de/relluem94/minecraft/server/spigot/essentials/rellu_essentials.sql"); - - server = MockBukkit.mock(); - plugin = MockBukkit.load(RelluEssentials.class); - - server.addSimpleWorld(Strings.PLUGIN_WORLD_LOBBY); - server.addSimpleWorld(Strings.PLUGIN_WORLD_WORLD); - server.addSimpleWorld(Strings.PLUGIN_WORLD_WORLD_NETHER); - server.addSimpleWorld(Strings.PLUGIN_WORLD_WORLD_THE_END); - - server.setOfflinePlayers(20); - - player1 = server.addPlayer("PlayerOne"); - player2 = server.addPlayer("PlayerTwo"); - player3 = server.addPlayer("PlayerThree"); - - addPlayerToDB(player1, "admin"); - addPlayerToDB(player2, "vip"); - addPlayerToDB(player3, "user"); - - server.getScheduler().performTicks(100L); - } - - /** - * Only needed due to Could not pass event AsyncPlayerPreLoginEvent to RelluEssentials v3.0 - */ - private static void addPlayerToDB(PlayerMock p, String groupName){ - PlayerEntry pe = new PlayerEntry(); - pe.setUuid(p.getUniqueId().toString()); - pe.setName(p.getName()); - pe.setCustomName(p.getName()); - pe.setGroup(Groups.getGroup(groupName)); - - plugin.getDatabaseHelper().insertPlayer(pe); - - pe = plugin.getDatabaseHelper().getPlayer(p.getUniqueId().toString()); - - plugin.getPlayerAPI().putPlayerEntry(p.getUniqueId(), pe); - } - @AfterClass - public static void tearDown() throws ManagedProcessException{ - MockBukkit.getMock().getScheduler().shutdown(); - MockBukkit.unmock(); - db.stop(); - } - - - @Test - @DisplayName("Plugin Enabled") - public void testPluginEnabled(){ - Assert.assertTrue(plugin.isEnabled()); - - } - - @Test - @DisplayName("Plugin Unit Test") - public void testUnitTest(){ - Assert.assertTrue(plugin.isUnitTest()); - } - - @Test - @DisplayName("Plugin World loaded Lobby") - public void testWorldLobbyLoaded(){ - Assert.assertNotNull(server.getWorld(Strings.PLUGIN_WORLD_LOBBY)); - } - - @Test - @DisplayName("Plugin World Loading World") - public void testWorldWorldLoaded(){ - Assert.assertNotNull(server.getWorld(Strings.PLUGIN_WORLD_WORLD)); - } - - @Test - @DisplayName("Plugin World Loading World Nether") - public void testWorldWorldNetherLoaded(){ - Assert.assertNotNull(server.getWorld(Strings.PLUGIN_WORLD_WORLD_THE_END)); - } - - @Test - @DisplayName("Plugin World Loading World End") - public void testWorldWorldEndLoaded(){ - Assert.assertNotNull(server.getWorld(Strings.PLUGIN_WORLD_WORLD_THE_END)); - } - - @Test - @DisplayName("Plugin Offline Player #1") - public void testPlayer1Online(){ - Assert.assertTrue(player1.isOnline()); - } - - @Test - @DisplayName("Plugin Offline Player #2") - public void testPlayer2Online(){ - Assert.assertTrue(player2.isOnline()); - } - - @Test - @DisplayName("Plugin Offline Player #3") - public void testPlayer3Offline(){ - Assert.assertTrue(player3.isOnline()); - } - - @Test - @DisplayName("Test Gamemmode Player #1") - public void testGameModePlayer1(){ - Assert.assertEquals(GameMode.SURVIVAL, player1.getGameMode()); - } - - @Test - @DisplayName("Test Gamemmode Player #2") - public void testGameModePlayer2(){ - Assert.assertEquals(GameMode.SURVIVAL, player2.getGameMode()); - } - - @Test - @DisplayName("Test Gamemmode Player #3") - public void testGameModePlayer3(){ - Assert.assertEquals(GameMode.SURVIVAL, player3.getGameMode()); - } - - @Test - @DisplayName("Test BlockBreak Player #1") - public void testSimulateBlockBreakPlayer1(){ - Block b = server.getWorld(Strings.PLUGIN_WORLD_LOBBY).getBlockAt(1, 1, 1); - Assertions.assertNotEquals(Material.AIR, b.getType()); - player1.simulateBlockBreak(b); - Assert.assertEquals(Material.AIR, b.getType()); - } - - @Test - @DisplayName("Test BlockBreak Player #2") - public void testSimulateBlockBreakPlayer2(){ - Block b = server.getWorld(Strings.PLUGIN_WORLD_LOBBY).getBlockAt(1, 1, 2); - Assertions.assertNotEquals(Material.AIR, b.getType()); - player2.simulateBlockBreak(b); - Assert.assertEquals(Material.GRASS, b.getType()); - } - - @Test - @DisplayName("Test BlockBreak Player #3") - public void testSimulateBlockBreakPlayer3(){ - Block b = server.getWorld(Strings.PLUGIN_WORLD_LOBBY).getBlockAt(1, 1, 3); - Assertions.assertNotEquals(Material.AIR, b.getType()); - player2.simulateBlockBreak(b); - Assert.assertEquals(Material.GRASS, b.getType()); - } - - @Test - @DisplayName("Test Plugin 2") - public void test2(){ +public class RelluEssentialsTest { - server.execute("poke", player1, player2.getName()); - Assert.assertFalse(server.getOnlinePlayers().isEmpty()); - } } \ No newline at end of file From f848adfeaa694dfb2a6c58b4a9b083a57eb992d0 Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Wed, 28 Feb 2024 22:21:32 +0100 Subject: [PATCH 31/36] RE-164 Test Commit (should work in Build) --- pom.xml | 28 ---------- .../essentials/RelluEssentialsTest.java | 26 --------- .../essentials/helpers/PlayerHelperTest.java | 53 ------------------- 3 files changed, 107 deletions(-) diff --git a/pom.xml b/pom.xml index 41370b25..a5626d35 100644 --- a/pom.xml +++ b/pom.xml @@ -63,34 +63,6 @@ 8.3.0 compile - - com.github.seeseemelk - MockBukkit-v1.20 - 3.78.0 - test - - - org.slf4j - slf4j-simple - - - - - ch.vorburger.mariaDB4j - mariaDB4j - 3.0.1 - test - - - ch.qos.logback - logback-classic - - - org.springframework.boot - spring-boot-starter-logging - - - org.projectlombok lombok diff --git a/src/test/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentialsTest.java b/src/test/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentialsTest.java index a9bbc31d..7788b7da 100644 --- a/src/test/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentialsTest.java +++ b/src/test/java/de/relluem94/minecraft/server/spigot/essentials/RelluEssentialsTest.java @@ -1,30 +1,4 @@ package de.relluem94.minecraft.server.spigot.essentials; - -import java.io.OutputStream; -import java.io.PrintStream; - -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.DisplayName; - -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; -import be.seeseemelk.mockbukkit.entity.PlayerMock; -import ch.vorburger.exec.ManagedProcessException; -import ch.vorburger.mariadb4j.DB; -import de.relluem94.minecraft.server.spigot.essentials.constants.DatabaseConstants; -import de.relluem94.minecraft.server.spigot.essentials.helpers.DatabaseHelper; -import de.relluem94.minecraft.server.spigot.essentials.helpers.pojo.PlayerEntry; -import de.relluem94.minecraft.server.spigot.essentials.permissions.Groups; - - public class RelluEssentialsTest { } \ No newline at end of file diff --git a/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelperTest.java b/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelperTest.java index be6a2d66..b605c56b 100644 --- a/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelperTest.java +++ b/src/test/java/de/relluem94/minecraft/server/spigot/essentials/helpers/PlayerHelperTest.java @@ -1,58 +1,5 @@ package de.relluem94.minecraft.server.spigot.essentials.helpers; -import java.io.OutputStream; -import java.io.PrintStream; -import java.util.UUID; - -import org.junit.Assert; -import org.junit.Test; - -import de.relluem94.minecraft.server.spigot.essentials.helpers.pojo.OfflinePlayerEntry; - public class PlayerHelperTest { - @Test - public void testGetOfflinePlayerByName1() { - OfflinePlayerEntry ope = PlayerHelper.getOfflinePlayerByName("Relluem94"); - Assert.assertNotNull(ope); - } - - @Test - public void testGetOfflinePlayerByName2() { - OfflinePlayerEntry ope = PlayerHelper.getOfflinePlayerByName("Relluem94"); - Assert.assertEquals(UUID.fromString("ec0149f9-8b21-44ee-9731-8bff508087e7"), ope.getId()); - } - - @Test - public void testGetOfflinePlayerByName3() { - PrintStream sysOut = System.out; - - PrintStream noOut = new PrintStream(new OutputStream(){ - public void write(int b) {} - }); - - System.setOut(noOut); // To disable Error Message from NetworkUtils - - OfflinePlayerEntry ope = PlayerHelper.getOfflinePlayerByName("Relluem9494"); - System.setOut(sysOut); - - Assert.assertNull(ope); - } - - @Test - public void testGetOfflinePlayerByUUID1() { - OfflinePlayerEntry ope = PlayerHelper.getOfflinePlayerByUUID(UUID.fromString("ec0149f9-8b21-44ee-9731-8bff508087e7")); - Assert.assertNotNull(ope); - } - - @Test - public void testGetOfflinePlayerByUUID2() { - OfflinePlayerEntry ope = PlayerHelper.getOfflinePlayerByUUID(UUID.fromString("ec0149f9-8b21-44ee-9731-8bff508087e7")); - Assert.assertEquals("Relluem94", ope.getName()); - } - @Test - public void testGetOfflinePlayerByUUID3() { - OfflinePlayerEntry ope = PlayerHelper.getOfflinePlayerByUUID(UUID.fromString("00000000-AAAA-AAAA-0000-AAFFAAAAAAAA")); - Assert.assertNull(ope); - } } \ No newline at end of file From ef19b516bd08ef1a2c0ff3c1a4d23eeae5365d86 Mon Sep 17 00:00:00 2001 From: Relluem94 Date: Wed, 28 Feb 2024 23:10:54 +0100 Subject: [PATCH 32/36] RE-164 Cleanup Code --- .github/workflows/codacy.yml | 4 +- .idea/dbnavigator.xml | 21 ++++- .idea/inspectionProfiles/Project_Default.xml | 8 ++ dependency-reduced-pom.xml | 79 ++----------------- docs/helpers/ProtectionHelper.md | 2 +- pom.xml | 27 ++++--- .../spigot/essentials/commands/Rollback.java | 6 +- .../spigot/essentials/commands/Sign.java | 2 +- .../spigot/essentials/helpers/ChatHelper.java | 2 +- .../helpers/pojo/WorldGroupSettingEntry.java | 3 - src/main/resources/lang_en_US.properties | 4 +- 11 files changed, 63 insertions(+), 95 deletions(-) create mode 100644 .idea/inspectionProfiles/Project_Default.xml diff --git a/.github/workflows/codacy.yml b/.github/workflows/codacy.yml index b25cffb9..caced5bb 100644 --- a/.github/workflows/codacy.yml +++ b/.github/workflows/codacy.yml @@ -29,8 +29,8 @@ jobs: codacy-security-scan: permissions: contents: read # for actions/checkout to fetch code - security-events: write # for github/codeql-action/upload-sarif to upload SARIF results - actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status + security-events: write # for GitHub/codeQl-action/upload-sarif to upload SARIF results + actions: read # only required for a private repository by GitHub/codeQl-action/upload-sarif to get the Action run status name: Codacy Security Scan runs-on: ubuntu-latest steps: diff --git a/.idea/dbnavigator.xml b/.idea/dbnavigator.xml index 137a7ae2..7555e821 100644 --- a/.idea/dbnavigator.xml +++ b/.idea/dbnavigator.xml @@ -1,5 +1,14 @@ + + + + + + + + + @@ -11,9 +20,19 @@ + + + + + + + + + + @@ -26,7 +45,7 @@ - + diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000..f0aa47da --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index 2ce6b5e0..67841c37 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -17,6 +17,11 @@ true src/main/resources + + lang_en_US.properties + lang_de_DE.properties + lang.properties + @@ -67,6 +72,7 @@ 3.3.0 UTF-8 +
@@ -97,78 +103,6 @@ 1.20.1-R0.1-SNAPSHOT provided - - com.github.seeseemelk - MockBukkit-v1.20 - 3.78.0 - test - - - slf4j-simple - org.slf4j - - - paper-api - io.papermc.paper - - - junit-jupiter - org.junit.jupiter - - - adventure-platform-bungeecord - net.kyori - - - byte-buddy - net.bytebuddy - - - maven-resolver-provider - org.apache.maven - - - maven-resolver-connector-basic - org.apache.maven.resolver - - - maven-resolver-transport-http - org.apache.maven.resolver - - - - - ch.vorburger.mariaDB4j - mariaDB4j - 3.0.1 - test - - - logback-classic - ch.qos.logback - - - spring-boot-starter-logging - org.springframework.boot - - - mariaDB4j-core - ch.vorburger.mariaDB4j - - - mariaDB4j-db-linux64 - ch.vorburger.mariaDB4j - - - mariaDB4j-db-win32 - ch.vorburger.mariaDB4j - - - mariaDB4j-db-mac64 - ch.vorburger.mariaDB4j - - - org.junit.jupiter junit-jupiter-engine @@ -228,6 +162,7 @@ 17 1.20 + 1.18.30 Relluem94 windows-1252 https://www.relluem94.de diff --git a/docs/helpers/ProtectionHelper.md b/docs/helpers/ProtectionHelper.md index 78fa9521..b6940f80 100644 --- a/docs/helpers/ProtectionHelper.md +++ b/docs/helpers/ProtectionHelper.md @@ -9,7 +9,7 @@ Use this Method to check if Block is protectable ## `public static boolean isOpenable(Block b)` -Use this Method to check if a Block is a instance of Openable +Use this Method to check if a Block is an instance of Openable * **Parameters:** `b` — Block * **Returns:** boolean diff --git a/pom.xml b/pom.xml index a5626d35..f311a181 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,5 @@ - + 4.0.0 de.relluem94 relluessentials @@ -6,6 +7,8 @@ 4.1.6 https://github.com/Relluem94s/RelluEssentials + 1.18.30 + 1.20.1-R0.1-SNAPSHOT 1.20 Relluem94 https://www.relluem94.de @@ -27,9 +30,9 @@
- jitpack.io - https://jitpack.io - + jitpack.io + https://jitpack.io + central central @@ -48,7 +51,7 @@ org.spigotmc spigot-api - 1.20.1-R0.1-SNAPSHOT + ${spigot.version} provided @@ -56,7 +59,7 @@ RelluLib 0.12 compile - + com.mysql mysql-connector-j @@ -66,7 +69,7 @@ org.projectlombok lombok - 1.18.30 + ${lombok.version} com.mojang @@ -102,6 +105,11 @@ src/main/resources true + + lang_en_US.properties + lang_de_DE.properties + lang.properties + src/main/java @@ -117,7 +125,7 @@ org.projectlombok lombok - 1.18.30 + ${lombok.version} @@ -154,7 +162,8 @@ maven-resources-plugin 3.3.0 - UTF-8 + UTF-8 + diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rollback.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rollback.java index 47a67c75..21e72334 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rollback.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Rollback.java @@ -30,9 +30,9 @@ public class Rollback implements CommandExecutor { /rollback -> Info /rollback player --> Rolls back Player last to first block. // DONE /rollback player