diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 76f0c9f..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,40 +0,0 @@ -# To contribute improvements to CI/CD templates, please follow the Development guide at: -# https://docs.gitlab.com/ee/development/cicd/templates.html -# This specific template is located at: -# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Gradle.gitlab-ci.yml - -# This is the Gradle build system for JVM applications -# https://gradle.org/ -# https://github.com/gradle/gradle - -image: gradle:alpine - -# Disable the Gradle daemon for Continuous Integration servers as correctness -# is usually a priority over speed in CI environments. Using a fresh -# runtime for each build is more reliable since the runtime is completely -# isolated from any previous builds. -variables: - GRADLE_OPTS: "-Dorg.gradle.daemon=false" - -before_script: - - export GRADLE_USER_HOME=`pwd`/.gradle - -build: - stage: build - script: gradle --build-cache assemble - cache: - key: "$CI_COMMIT_REF_NAME" - policy: push - paths: - - build - - .gradle - -test: - stage: test - script: gradle check - cache: - key: "$CI_COMMIT_REF_NAME" - policy: pull - paths: - - build - - .gradle diff --git a/src/main/java/gq/unurled/raxen/Raxen.java b/src/main/java/gq/unurled/raxen/Raxen.java index 9be3d14..9540756 100644 --- a/src/main/java/gq/unurled/raxen/Raxen.java +++ b/src/main/java/gq/unurled/raxen/Raxen.java @@ -10,6 +10,7 @@ import gq.unurled.raxen.utils.Reload; import gq.unurled.raxen.utils.Vault; import lombok.Getter; import net.kyori.adventure.text.Component; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; @@ -20,7 +21,7 @@ public final class Raxen extends JavaPlugin { private static final String prefix = ChatColor.AQUA + "Rx" + ChatColor.LIGHT_PURPLE + "> "; @Getter - private static String version = ""; + private static String version = "0.4.4"; private final PluginManager pm = getServer().getPluginManager(); private static Raxen plugin; @@ -83,6 +84,8 @@ public final class Raxen extends JavaPlugin { registerEvents(); getServer().getConsoleSender().sendMessage(Component.text(prefix +"§aServer Started Successfully!")); + + listenerManager.getServerPingEvent().setLoading(false); } private void registerCommands() { @@ -99,6 +102,7 @@ public final class Raxen extends JavaPlugin { @Override public void onDisable() { + listenerManager.getServerPingEvent().setLoading(true); Reload.kickAll(); playerConfig.close(); diff --git a/src/main/java/gq/unurled/raxen/commands/admin/NbtCommand.java b/src/main/java/gq/unurled/raxen/commands/admin/NbtCommand.java index 7a4e5fa..e1bcc9f 100644 --- a/src/main/java/gq/unurled/raxen/commands/admin/NbtCommand.java +++ b/src/main/java/gq/unurled/raxen/commands/admin/NbtCommand.java @@ -2,7 +2,7 @@ package gq.unurled.raxen.commands.admin; import de.tr7zw.nbtapi.NBTItem; import gq.unurled.raxen.Raxen; -import gq.unurled.raxen.components.player.Attributes.Attributes; +import gq.unurled.raxen.components.player.attributes.Attributes; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.command.Command; diff --git a/src/main/java/gq/unurled/raxen/commands/admin/SpawnEntity.java b/src/main/java/gq/unurled/raxen/commands/admin/SpawnEntity.java index 2771222..954ff9e 100644 --- a/src/main/java/gq/unurled/raxen/commands/admin/SpawnEntity.java +++ b/src/main/java/gq/unurled/raxen/commands/admin/SpawnEntity.java @@ -42,6 +42,8 @@ public class SpawnEntity implements TabExecutor { EntityType type = EntityType.valueOf(args[0]); Entity e = player.getWorld().spawnEntity(player.getLocation(), type, false); setNameSpacedKeys(e, "&cName", 100, 100,0,50,0,100,0,100,0); + e.setCustomName(color(args[1])); + e.setCustomNameVisible(true); return false; } diff --git a/src/main/java/gq/unurled/raxen/commands/player/ClassCommand.java b/src/main/java/gq/unurled/raxen/commands/player/ClassCommand.java new file mode 100644 index 0000000..66bb23d --- /dev/null +++ b/src/main/java/gq/unurled/raxen/commands/player/ClassCommand.java @@ -0,0 +1,37 @@ +package gq.unurled.raxen.commands.player; + +import gq.unurled.raxen.Raxen; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.command.TabExecutor; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +import static gq.unurled.raxen.utils.Utils.error; + +public class ClassCommand implements TabExecutor { + + private Raxen main; + + public ClassCommand(Raxen main) { + this.main = main; + } + + @Override + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { + if(!(sender instanceof Player)) { + error("The console can't execute this Command!"); + return true; + } + Player player = (Player) sender; + return false; + } + + @Override + public @Nullable List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) { + return null; + } +} diff --git a/src/main/java/gq/unurled/raxen/commands/player/SkillsCommand.java b/src/main/java/gq/unurled/raxen/commands/player/SkillsCommand.java index e3b5b19..0dd775e 100644 --- a/src/main/java/gq/unurled/raxen/commands/player/SkillsCommand.java +++ b/src/main/java/gq/unurled/raxen/commands/player/SkillsCommand.java @@ -1,7 +1,7 @@ package gq.unurled.raxen.commands.player; import gq.unurled.raxen.Raxen; -import gq.unurled.raxen.components.player.Attributes.Attributes; +import gq.unurled.raxen.components.player.attributes.Attributes; import net.kyori.adventure.text.Component; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; diff --git a/src/main/java/gq/unurled/raxen/components/entity/Attributes.java b/src/main/java/gq/unurled/raxen/components/entity/Attributes.java index a6ae893..a0c6f24 100644 --- a/src/main/java/gq/unurled/raxen/components/entity/Attributes.java +++ b/src/main/java/gq/unurled/raxen/components/entity/Attributes.java @@ -1,7 +1,7 @@ package gq.unurled.raxen.components.entity; import gq.unurled.raxen.Raxen; -import gq.unurled.raxen.components.player.Attributes.Attribute; +import gq.unurled.raxen.components.player.attributes.Attribute; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.persistence.PersistentDataContainer; diff --git a/src/main/java/gq/unurled/raxen/components/entity/EntityUtils.java b/src/main/java/gq/unurled/raxen/components/entity/EntityUtils.java index 1c89838..098d447 100644 --- a/src/main/java/gq/unurled/raxen/components/entity/EntityUtils.java +++ b/src/main/java/gq/unurled/raxen/components/entity/EntityUtils.java @@ -1,7 +1,6 @@ package gq.unurled.raxen.components.entity; import gq.unurled.raxen.Raxen; -import gq.unurled.raxen.components.player.Attributes.Attribute; import org.bukkit.entity.LivingEntity; import org.bukkit.persistence.PersistentDataContainer; import org.bukkit.persistence.PersistentDataType; diff --git a/src/main/java/gq/unurled/raxen/components/gui/ItemListGui.java b/src/main/java/gq/unurled/raxen/components/gui/ItemListGui.java index 871784b..e17f218 100644 --- a/src/main/java/gq/unurled/raxen/components/gui/ItemListGui.java +++ b/src/main/java/gq/unurled/raxen/components/gui/ItemListGui.java @@ -216,6 +216,7 @@ public class ItemListGui implements Listener { //add to stash //} player.getInventory().addItem(e.getCurrentItem()); + gq.unurled.raxen.utils.Skills.updateSkills(main, player); } } } diff --git a/src/main/java/gq/unurled/raxen/components/player/Inventories.java b/src/main/java/gq/unurled/raxen/components/player/Inventories.java index 2e35bf5..2b6712a 100644 --- a/src/main/java/gq/unurled/raxen/components/player/Inventories.java +++ b/src/main/java/gq/unurled/raxen/components/player/Inventories.java @@ -1,6 +1,6 @@ package gq.unurled.raxen.components.player; -import gq.unurled.raxen.components.player.Storages.Inventory; +import gq.unurled.raxen.components.player.storages.Inventory; public class Inventories { private Inventory inv; diff --git a/src/main/java/gq/unurled/raxen/components/player/RaxenPlayer.java b/src/main/java/gq/unurled/raxen/components/player/RaxenPlayer.java index 8cdd981..b79d1b4 100644 --- a/src/main/java/gq/unurled/raxen/components/player/RaxenPlayer.java +++ b/src/main/java/gq/unurled/raxen/components/player/RaxenPlayer.java @@ -2,10 +2,10 @@ package gq.unurled.raxen.components.player; import gq.unurled.raxen.Raxen; import gq.unurled.raxen.components.entity.EntityNamespacedKey; -import gq.unurled.raxen.components.player.Attributes.Attribute; -import gq.unurled.raxen.components.player.Attributes.Attributes; -import gq.unurled.raxen.components.player.Storages.EnderChest; -import gq.unurled.raxen.components.player.Storages.Inventory; +import gq.unurled.raxen.components.player.attributes.Attribute; +import gq.unurled.raxen.components.player.attributes.Attributes; +import gq.unurled.raxen.components.player.storages.EnderChest; +import gq.unurled.raxen.components.player.storages.Inventory; import gq.unurled.raxen.utils.Items; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; @@ -69,7 +69,7 @@ public class RaxenPlayer { String inv = data.get(namespacedKey.inventory, PersistentDataType.STRING); org.bukkit.inventory.Inventory invv = Bukkit.createInventory(player, InventoryType.PLAYER); invv = setItemsToInventory(Items.listItemStackDeserilize(inv), invv); - gq.unurled.raxen.components.player.Storages.Inventory invvv = new gq.unurled.raxen.components.player.Storages.Inventory(invv); + gq.unurled.raxen.components.player.storages.Inventory invvv = new gq.unurled.raxen.components.player.storages.Inventory(invv); Inventories invvvv = new Inventories(invvv); return invvvv; } diff --git a/src/main/java/gq/unurled/raxen/components/player/Storage.java b/src/main/java/gq/unurled/raxen/components/player/Storage.java index 726c324..103451a 100644 --- a/src/main/java/gq/unurled/raxen/components/player/Storage.java +++ b/src/main/java/gq/unurled/raxen/components/player/Storage.java @@ -1,6 +1,6 @@ package gq.unurled.raxen.components.player; -import gq.unurled.raxen.components.player.Storages.EnderChest; +import gq.unurled.raxen.components.player.storages.EnderChest; public class Storage { diff --git a/src/main/java/gq/unurled/raxen/components/player/Attributes/Attribute.java b/src/main/java/gq/unurled/raxen/components/player/attributes/Attribute.java similarity index 94% rename from src/main/java/gq/unurled/raxen/components/player/Attributes/Attribute.java rename to src/main/java/gq/unurled/raxen/components/player/attributes/Attribute.java index 286b481..e20bd75 100644 --- a/src/main/java/gq/unurled/raxen/components/player/Attributes/Attribute.java +++ b/src/main/java/gq/unurled/raxen/components/player/attributes/Attribute.java @@ -1,4 +1,4 @@ -package gq.unurled.raxen.components.player.Attributes; +package gq.unurled.raxen.components.player.attributes; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/gq/unurled/raxen/components/player/Attributes/Attributes.java b/src/main/java/gq/unurled/raxen/components/player/attributes/Attributes.java similarity index 99% rename from src/main/java/gq/unurled/raxen/components/player/Attributes/Attributes.java rename to src/main/java/gq/unurled/raxen/components/player/attributes/Attributes.java index d34bb24..0d53e85 100644 --- a/src/main/java/gq/unurled/raxen/components/player/Attributes/Attributes.java +++ b/src/main/java/gq/unurled/raxen/components/player/attributes/Attributes.java @@ -1,4 +1,4 @@ -package gq.unurled.raxen.components.player.Attributes; +package gq.unurled.raxen.components.player.attributes; import gq.unurled.raxen.Raxen; import gq.unurled.raxen.components.entity.EntityNamespacedKey; diff --git a/src/main/java/gq/unurled/raxen/components/player/classes/Class.java b/src/main/java/gq/unurled/raxen/components/player/classes/Class.java new file mode 100644 index 0000000..ec6ca6f --- /dev/null +++ b/src/main/java/gq/unurled/raxen/components/player/classes/Class.java @@ -0,0 +1,4 @@ +package gq.unurled.raxen.components.player.classes; + +public class Class { +} diff --git a/src/main/java/gq/unurled/raxen/components/player/Storages/EnderChest.java b/src/main/java/gq/unurled/raxen/components/player/storages/EnderChest.java similarity index 87% rename from src/main/java/gq/unurled/raxen/components/player/Storages/EnderChest.java rename to src/main/java/gq/unurled/raxen/components/player/storages/EnderChest.java index 0676d41..a5c5f9a 100644 --- a/src/main/java/gq/unurled/raxen/components/player/Storages/EnderChest.java +++ b/src/main/java/gq/unurled/raxen/components/player/storages/EnderChest.java @@ -1,4 +1,4 @@ -package gq.unurled.raxen.components.player.Storages; +package gq.unurled.raxen.components.player.storages; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/gq/unurled/raxen/components/player/Storages/Inventory.java b/src/main/java/gq/unurled/raxen/components/player/storages/Inventory.java similarity index 87% rename from src/main/java/gq/unurled/raxen/components/player/Storages/Inventory.java rename to src/main/java/gq/unurled/raxen/components/player/storages/Inventory.java index 18feed9..238814f 100644 --- a/src/main/java/gq/unurled/raxen/components/player/Storages/Inventory.java +++ b/src/main/java/gq/unurled/raxen/components/player/storages/Inventory.java @@ -1,4 +1,4 @@ -package gq.unurled.raxen.components.player.Storages; +package gq.unurled.raxen.components.player.storages; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/gq/unurled/raxen/config/PlayerConfig.java b/src/main/java/gq/unurled/raxen/config/PlayerConfig.java index a1abc56..9bdc273 100644 --- a/src/main/java/gq/unurled/raxen/config/PlayerConfig.java +++ b/src/main/java/gq/unurled/raxen/config/PlayerConfig.java @@ -3,10 +3,10 @@ package gq.unurled.raxen.config; import com.mongodb.client.MongoCollection; import com.mongodb.client.model.Filters; import gq.unurled.raxen.Raxen; -import gq.unurled.raxen.components.player.Attributes.Attributes; +import gq.unurled.raxen.components.player.attributes.Attributes; import gq.unurled.raxen.components.player.Inventories; import gq.unurled.raxen.components.player.Storage; -import gq.unurled.raxen.components.player.Storages.EnderChest; +import gq.unurled.raxen.components.player.storages.EnderChest; import gq.unurled.raxen.manager.PlayerManager; import gq.unurled.raxen.manager.StorageManager; import gq.unurled.raxen.utils.Items; @@ -165,7 +165,7 @@ public class PlayerConfig { inv = setItemsToInventory(listItemStackDeserilize(playerDoc.getString("inv")), inv); player.getInventory().setContents(inv.getContents()); player.updateInventory(); - gq.unurled.raxen.components.player.Storages.Inventory invv = new gq.unurled.raxen.components.player.Storages.Inventory(inv); + gq.unurled.raxen.components.player.storages.Inventory invv = new gq.unurled.raxen.components.player.storages.Inventory(inv); Inventories invvv = new Inventories(invv); playerManager.getRaxenPlayer(player).setInventory(inv); } @@ -189,7 +189,7 @@ public class PlayerConfig { inv = setItemsToInventory(listItemStackDeserilize((String) config.getString("inv")), inv); player.getInventory().setContents(inv.getContents()); player.updateInventory(); - gq.unurled.raxen.components.player.Storages.Inventory invv = new gq.unurled.raxen.components.player.Storages.Inventory(inv); + gq.unurled.raxen.components.player.storages.Inventory invv = new gq.unurled.raxen.components.player.storages.Inventory(inv); Inventories invvv = new Inventories(invv); playerManager.getRaxenPlayer(player).setInventory(inv); } diff --git a/src/main/java/gq/unurled/raxen/listener/entity/DamageEntity.java b/src/main/java/gq/unurled/raxen/listener/entity/DamageEntity.java index c6d59b3..7812265 100644 --- a/src/main/java/gq/unurled/raxen/listener/entity/DamageEntity.java +++ b/src/main/java/gq/unurled/raxen/listener/entity/DamageEntity.java @@ -41,7 +41,7 @@ public class DamageEntity implements Listener { debug(main, e.getEntity().getName(), e.getEntity().getType().toString(), e.getDamager().getType().toString(), e.getDamager().getName()); if (e.getDamager() instanceof Player) { Player playerDamager = (Player) e.getDamager(); - gq.unurled.raxen.components.player.Attributes.Attributes attributes = new gq.unurled.raxen.components.player.Attributes.Attributes(main); + gq.unurled.raxen.components.player.attributes.Attributes attributes = new gq.unurled.raxen.components.player.attributes.Attributes(main); strength = attributes.getStrength(playerDamager); itemDmg = attributes.getItemStrength(playerDamager); } else { @@ -55,7 +55,7 @@ public class DamageEntity implements Listener { } if (e.getEntity() instanceof Player) { Player playerVictim = (Player) e.getEntity(); - gq.unurled.raxen.components.player.Attributes.Attributes attributes = new gq.unurled.raxen.components.player.Attributes.Attributes(main); + gq.unurled.raxen.components.player.attributes.Attributes attributes = new gq.unurled.raxen.components.player.attributes.Attributes(main); defense = attributes.getDefense(playerVictim); health = attributes.getHealth(playerVictim); itemDefense = attributes.getItemDefense(playerVictim); @@ -97,7 +97,7 @@ public class DamageEntity implements Listener { } if (e.getEntity() instanceof Player) { Player playerVictim = (Player) e.getEntity(); - gq.unurled.raxen.components.player.Attributes.Attributes attributes = new gq.unurled.raxen.components.player.Attributes.Attributes(main); + gq.unurled.raxen.components.player.attributes.Attributes attributes = new gq.unurled.raxen.components.player.attributes.Attributes(main); attributes.setHealth(playerVictim, health); } else { Entity entityVictim = e.getEntity(); @@ -113,7 +113,7 @@ public class DamageEntity implements Listener { e.setDamage(0); if (e.getEntity() instanceof Player) { Player player = (Player) e.getEntity(); - gq.unurled.raxen.components.player.Attributes.Attributes attributes = new gq.unurled.raxen.components.player.Attributes.Attributes(main); + gq.unurled.raxen.components.player.attributes.Attributes attributes = new gq.unurled.raxen.components.player.attributes.Attributes(main); Integer health = attributes.getHealth(player); } diff --git a/src/main/java/gq/unurled/raxen/listener/player/ArmorEvent.java b/src/main/java/gq/unurled/raxen/listener/player/ArmorEvent.java index 2b0c202..e2cbbcf 100644 --- a/src/main/java/gq/unurled/raxen/listener/player/ArmorEvent.java +++ b/src/main/java/gq/unurled/raxen/listener/player/ArmorEvent.java @@ -3,7 +3,7 @@ package gq.unurled.raxen.listener.player; import com.destroystokyo.paper.event.player.PlayerArmorChangeEvent; import de.tr7zw.nbtapi.NBTItem; import gq.unurled.raxen.Raxen; -import gq.unurled.raxen.components.player.Attributes.Attributes; +import gq.unurled.raxen.components.player.attributes.Attributes; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/src/main/java/gq/unurled/raxen/listener/player/ClickBlockEvent.java b/src/main/java/gq/unurled/raxen/listener/player/ClickBlockEvent.java index 24dfa6b..d30c8ca 100644 --- a/src/main/java/gq/unurled/raxen/listener/player/ClickBlockEvent.java +++ b/src/main/java/gq/unurled/raxen/listener/player/ClickBlockEvent.java @@ -27,10 +27,12 @@ public class ClickBlockEvent implements Listener { Block block = e.getClickedBlock(); Action action = e.getAction(); if (action.isRightClick()) { - if (block.getType() == Material.CHEST) { - player.closeInventory(); - Inventory inv = gui.addItems(player); - player.openInventory(inv); + if (block != null) { + if (block.getType() == Material.CHEST) { + player.closeInventory(); + Inventory inv = gui.addItems(player); + player.openInventory(inv); + } } } } diff --git a/src/main/java/gq/unurled/raxen/listener/player/ItemHandEvent.java b/src/main/java/gq/unurled/raxen/listener/player/ItemHandEvent.java index b5eaba0..a786a9c 100644 --- a/src/main/java/gq/unurled/raxen/listener/player/ItemHandEvent.java +++ b/src/main/java/gq/unurled/raxen/listener/player/ItemHandEvent.java @@ -2,7 +2,7 @@ package gq.unurled.raxen.listener.player; import de.tr7zw.nbtapi.NBTItem; import gq.unurled.raxen.Raxen; -import gq.unurled.raxen.components.player.Attributes.Attributes; +import gq.unurled.raxen.components.player.attributes.Attributes; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/src/main/java/gq/unurled/raxen/listener/player/ServerPingEvent.java b/src/main/java/gq/unurled/raxen/listener/player/ServerPingEvent.java new file mode 100644 index 0000000..b0bf129 --- /dev/null +++ b/src/main/java/gq/unurled/raxen/listener/player/ServerPingEvent.java @@ -0,0 +1,37 @@ +package gq.unurled.raxen.listener.player; + +import gq.unurled.raxen.Raxen; +import lombok.Getter; +import lombok.Setter; +import net.kyori.adventure.text.Component; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.server.ServerListPingEvent; + +import static gq.unurled.raxen.utils.Utils.color; + +public class ServerPingEvent implements Listener { + + private Raxen main; + @Getter + @Setter + private boolean loading = false; + + public ServerPingEvent(Raxen main) { + this.main = main; + this.loading = true; + } + + @EventHandler + public void ServerListPingEvent(ServerListPingEvent e) { + FileConfiguration config = this.main.getConfig(); + String motd = config.getString("motd"); + String motdReload = config.getString("motd-reload"); + if (loading) { + e.motd(Component.text(color(motdReload))); + } else { + e.motd(Component.text(color(motd))); + } + } +} diff --git a/src/main/java/gq/unurled/raxen/manager/CommandManager.java b/src/main/java/gq/unurled/raxen/manager/CommandManager.java index 1f94fbe..f73a57e 100644 --- a/src/main/java/gq/unurled/raxen/manager/CommandManager.java +++ b/src/main/java/gq/unurled/raxen/manager/CommandManager.java @@ -3,6 +3,7 @@ package gq.unurled.raxen.manager; import gq.unurled.raxen.Raxen; import gq.unurled.raxen.commands.RaxenCommand; import gq.unurled.raxen.commands.admin.*; +import gq.unurled.raxen.commands.player.ClassCommand; import gq.unurled.raxen.commands.player.SkillsCommand; import gq.unurled.raxen.commands.player.StorageCommand; import lombok.Getter; @@ -20,12 +21,14 @@ public class CommandManager { private SkillsCommand skillsCommand = new SkillsCommand(main); private RaxenCommand raxenCommand = new RaxenCommand(main); private SpawnEntity entityspawn; + private ClassCommand classCommand; public CommandManager(Raxen main) { this.main = main; this.itemListCommand = new ItemListCommand(this.main); this.nbtCommand = new NbtCommand(this.main); this.entityspawn = new SpawnEntity(this.main); + this.classCommand = new ClassCommand(this.main); } public void register() { @@ -53,6 +56,9 @@ public class CommandManager { main.getCommand("entityspawn").setTabCompleter(entityspawn); main.getCommand("entityspawn").setExecutor(entityspawn); + + main.getCommand("class").setTabCompleter(classCommand); + main.getCommand("class").setExecutor(classCommand); } } diff --git a/src/main/java/gq/unurled/raxen/manager/ListenerManager.java b/src/main/java/gq/unurled/raxen/manager/ListenerManager.java index 01ca081..4c65601 100644 --- a/src/main/java/gq/unurled/raxen/manager/ListenerManager.java +++ b/src/main/java/gq/unurled/raxen/manager/ListenerManager.java @@ -5,16 +5,20 @@ import gq.unurled.raxen.listener.entity.DamageEntity; import gq.unurled.raxen.listener.entity.SpawnEvent; import gq.unurled.raxen.listener.player.*; import gq.unurled.raxen.utils.Reload; +import lombok.Getter; import org.bukkit.plugin.PluginManager; public class ListenerManager { private final Raxen main; private final PluginManager pm; + @Getter + private ServerPingEvent serverPingEvent; public ListenerManager(Raxen main) { this.main = main; this.pm = main.getPm(); + this.serverPingEvent = new ServerPingEvent(main); } public void register() { @@ -28,5 +32,7 @@ public class ListenerManager { this.pm.registerEvents(new DamageEntity(main), main); this.pm.registerEvents(new SpawnEvent(main), main); this.pm.registerEvents(new ClickBlockEvent(main), main); + this.pm.registerEvents(serverPingEvent, main); + } } diff --git a/src/main/java/gq/unurled/raxen/manager/PlayerManager.java b/src/main/java/gq/unurled/raxen/manager/PlayerManager.java index f17ee8d..c88ed78 100644 --- a/src/main/java/gq/unurled/raxen/manager/PlayerManager.java +++ b/src/main/java/gq/unurled/raxen/manager/PlayerManager.java @@ -1,8 +1,7 @@ package gq.unurled.raxen.manager; import gq.unurled.raxen.Raxen; -import gq.unurled.raxen.components.player.Attributes.Attribute; -import gq.unurled.raxen.components.player.Attributes.Attributes; +import gq.unurled.raxen.components.player.attributes.Attribute; import gq.unurled.raxen.components.player.RaxenPlayer; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; @@ -48,6 +47,6 @@ public class PlayerManager { } } - public void unEegisterRaxenPlayer(Player player) { + public void unRegisterRaxenPlayer(Player player) { } } diff --git a/src/main/java/gq/unurled/raxen/utils/Items.java b/src/main/java/gq/unurled/raxen/utils/Items.java index 74737b6..00ac2c4 100644 --- a/src/main/java/gq/unurled/raxen/utils/Items.java +++ b/src/main/java/gq/unurled/raxen/utils/Items.java @@ -12,11 +12,16 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; import org.bukkit.inventory.*; import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.util.io.BukkitObjectInputStream; +import org.bukkit.util.io.BukkitObjectOutputStream; +import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.util.*; -import static gq.unurled.raxen.utils.Utils.color; -import static gq.unurled.raxen.utils.Utils.error; +import static gq.unurled.raxen.utils.Utils.*; public class Items { @@ -67,12 +72,8 @@ public class Items { } public static String itemStackSerilize(ItemStack it, Integer slot) { - Gson gson = new Gson(); - String str = gson.toJson(it.serialize()); - net.minecraft.world.item.ItemStack itm = CraftItemStack.asNMSCopy(it); - //String str = gson.toJson(it.serialize(), new TypeToken(){}.getType()); - NBTItem nbti = new NBTItem(it); - str = str + "@#NBT#" + nbti.toString(); + String str = ""; + str = itemTo64(it); str = str + "@#SLOT#" + slot.toString(); return str; } @@ -95,41 +96,21 @@ public class Items { } } - public static itemStackDeserilizeResult itemStackDeserilize(String str) { - List mapp = Arrays.asList(str.split("@#NBT#")); + public static itemStackDeserilizeResult itemStackDeserilize(String str) { + List mapp = Arrays.asList(str.split("@#SLOT#")); Gson gson = new Gson(); ItemStack it = new ItemStack(Material.AIR); Integer slot = 0; + log("full item " + str); for (String s : mapp) { - if(s != null && s.length() > 2) { + if(s != null) { try { - Map map = gson.fromJson(s, new TypeToken>(){}.getType()); - it = ItemStack.deserialize(map); + it = itemFrom64(s); } catch (Exception e) { - List mappp = Arrays.asList(s.split("@#SLOT#")); - for (String ss : mappp) { - try { - if (ss != null && ss.length() > 2) { - NBTItem nbti = new NBTItem(it); - String strrr = ss; - if (strrr.length() > 2) { - for (String strr : strrr.split(",")) { - if (!strr.equals("{") && !strr.equals("}")) { - strr = strr.replace("{", ""); - strr = strr.replace("}", ""); - String[] nb = strr.split(":"); - nbti.setInteger(nb[0], Integer.valueOf(nb[1])); - it = nbti.getItem(); - } - } - - } - } - } catch (Exception ee) { - slot = Integer.valueOf(ss); - } + if (!s.equals("")) { + log("slot " + s); + slot = Integer.valueOf(s); } - } } @@ -178,11 +159,53 @@ public class Items { public static PlayerInventory setItemsToInventory(HashMap list, PlayerInventory inv) { for (Map.Entry entry : list.entrySet()) { - inv.setItem(entry.getKey(), entry.getValue()); + if (entry.getKey() == 40) { + inv.setHelmet(entry.getValue()); + } else if (entry.getKey() == 39) { + inv.setChestplate(entry.getValue()); + } else if (entry.getKey() == 38) { + inv.setLeggings(entry.getValue()); + } else if (entry.getKey() == 37) { + inv.setBoots(entry.getValue()); + } else if (entry.getKey() == 41) { + inv.setItemInOffHand(entry.getValue()); + } + else { + inv.setItem(entry.getKey(), entry.getValue()); + } } return inv; } + private static String itemTo64(ItemStack stack) throws IllegalStateException { + try { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream); + dataOutput.writeObject(stack); + + // Serialize that array + dataOutput.close(); + return Base64Coder.encodeLines(outputStream.toByteArray()); + } + catch (Exception e) { + throw new IllegalStateException("Unable to save item stack.", e); + } + } + + private static ItemStack itemFrom64(String data) throws IOException { + try { + ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data)); + BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream); + try { + return (ItemStack) dataInput.readObject(); + } finally { + dataInput.close(); + } + } + catch (ClassNotFoundException e) { + throw new IOException("Unable to decode class type.", e); + } + } public static String attributes(String str) { String stt = ""; diff --git a/src/main/java/gq/unurled/raxen/utils/Skills.java b/src/main/java/gq/unurled/raxen/utils/Skills.java index ae48bac..944bf61 100644 --- a/src/main/java/gq/unurled/raxen/utils/Skills.java +++ b/src/main/java/gq/unurled/raxen/utils/Skills.java @@ -1,7 +1,7 @@ package gq.unurled.raxen.utils; import gq.unurled.raxen.Raxen; -import gq.unurled.raxen.components.player.Attributes.Attributes; +import gq.unurled.raxen.components.player.attributes.Attributes; import org.bukkit.attribute.Attribute; import org.bukkit.entity.Player; diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 675f5ed..0a6ee89 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -29,6 +29,8 @@ commands: description: Open ItemList menu entityspawn: description: Spawn an custom entity + class: + description: player command that make them choose their class and then their stats permissions: raxen.reload.cmd: @@ -42,4 +44,6 @@ permissions: raxen.itemlist.cmd: description: itemlist command permission raxen.entityspawn.cmd: - description: entityspawn command permission \ No newline at end of file + description: entityspawn command permission + raxen.class.cmd: + description: class command premission \ No newline at end of file