diff --git a/.gradle/8.8/checksums/checksums.lock b/.gradle/8.8/checksums/checksums.lock index c1fc5c1..4797fd9 100644 Binary files a/.gradle/8.8/checksums/checksums.lock and b/.gradle/8.8/checksums/checksums.lock differ diff --git a/.gradle/8.8/executionHistory/executionHistory.bin b/.gradle/8.8/executionHistory/executionHistory.bin index 6036544..039484b 100644 Binary files a/.gradle/8.8/executionHistory/executionHistory.bin and b/.gradle/8.8/executionHistory/executionHistory.bin differ diff --git a/.gradle/8.8/executionHistory/executionHistory.lock b/.gradle/8.8/executionHistory/executionHistory.lock index 2207ec9..0fefdff 100644 Binary files a/.gradle/8.8/executionHistory/executionHistory.lock and b/.gradle/8.8/executionHistory/executionHistory.lock differ diff --git a/.gradle/8.8/fileHashes/fileHashes.bin b/.gradle/8.8/fileHashes/fileHashes.bin index e47e479..b5c7a45 100644 Binary files a/.gradle/8.8/fileHashes/fileHashes.bin and b/.gradle/8.8/fileHashes/fileHashes.bin differ diff --git a/.gradle/8.8/fileHashes/fileHashes.lock b/.gradle/8.8/fileHashes/fileHashes.lock index affe9a5..4aa53a9 100644 Binary files a/.gradle/8.8/fileHashes/fileHashes.lock and b/.gradle/8.8/fileHashes/fileHashes.lock differ diff --git a/.gradle/8.8/fileHashes/resourceHashesCache.bin b/.gradle/8.8/fileHashes/resourceHashesCache.bin index dad9b3d..acaad40 100644 Binary files a/.gradle/8.8/fileHashes/resourceHashesCache.bin and b/.gradle/8.8/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index d2268d4..2bc18a4 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin index a008bd8..9e9435c 100644 Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..3fd2793 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index c76471f..b389fca 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,6 +3,7 @@ + \ No newline at end of file diff --git a/.idea/modules/ArmorSMP.main.iml b/.idea/modules/ArmorSMP.main.iml index bbeeb3e..746f1fd 100644 --- a/.idea/modules/ArmorSMP.main.iml +++ b/.idea/modules/ArmorSMP.main.iml @@ -11,4 +11,8 @@ + + + + \ No newline at end of file diff --git a/.idea/modules/me.trouper.ArmorSMP.main.iml b/.idea/modules/me.trouper.ArmorSMP.main.iml new file mode 100644 index 0000000..bbeeb3e --- /dev/null +++ b/.idea/modules/me.trouper.ArmorSMP.main.iml @@ -0,0 +1,14 @@ + + + + + + + PAPER + ADVENTURE + + 1 + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin index d2a74a9..e828df8 100644 Binary files a/build/tmp/compileJava/previous-compilation-data.bin and b/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/libs/PDK-1.4.0.jar b/libs/PDK-1.4.0.jar new file mode 100644 index 0000000..0e4230c Binary files /dev/null and b/libs/PDK-1.4.0.jar differ diff --git a/src/main/java/me/trouper/armorsmp/data/Config.java b/src/main/java/me/trouper/armorsmp/data/Config.java index 3b42c10..fd168b9 100644 --- a/src/main/java/me/trouper/armorsmp/data/Config.java +++ b/src/main/java/me/trouper/armorsmp/data/Config.java @@ -8,26 +8,58 @@ import java.util.Arrays; import java.util.List; public class Config implements JsonSerializable { - - public String mainColor = "�ff00"; - public String prefix = "&9ArmorSMP> &7"; - public String pluginName = "ArmorSMP"; - + @Override public File getFile() { return ArmorSMP.getInstance().getManager().io.CONFIG_FILE; } - - public boolean fancyAlerts = true; + public boolean maceCraftingeEnabled = true; + + public String mainColor = "�ff00"; + public String prefix = "&9ArmorSMP> &7"; + public String pluginName = "ArmorSMP"; + public boolean fancyAlerts = true; public Tips tips = new Tips(); public class Tips { public boolean tipsEnabled = true; public List tipList = Arrays.asList( - "Tips1", - "Tips2", - "Tips3" + "Kill players to obtain Armor Upgraders and progress through armor tiers!", + "Right-click an Armor Upgrader to upgrade your armor to the next tier!", + "When you die, you'll drop an Armor Upgrader and be downgraded one tier.", + "Enchants stay when upgrading armor, but are lost when downgrading after death.", + "Armor cannot be crafted, removed, dropped, or moved in your inventory!", + "Found armor in the world cannot be equipped - you must use the upgrade system.", + "Craft Armor Upgraders using diamond blocks, ominous keys, and enchanted golden apples!", + "Netherite armor and tools are special event rewards with powerful abilities!", + "The Dragon Egg grants a special Netherite Chestplate with the Bad Breath ability!", + "Bad Breath summons damaging dragon breath for 7 seconds with a 50-second cooldown.", + "Netherite Helmet grants 5 extra hearts and permanent Fire Resistance!", + "Use Back Up ability (Netherite Leggings) to create a protective shield for 10 seconds.", + "Dash forward 10 blocks with Netherite Boots' ability (30-second cooldown).", + "Netherite Sword's Go Wild gives 7 seconds of Strength 2 for massive damage!", + "Activate Rampage with Netherite Axe for 5 seconds of Haste 6 attacks!", + "Trust players to prevent your abilities from affecting them with /trust commands.", + "The Mace is a powerful weapon that can only be crafted once when enabled!", + "Netherite items cannot be stored in containers - they must be kept in your inventory.", + "Losing Netherite items makes you lose their abilities - be careful when dropping them!", + "Use /armorsmp commands to manage armor tiers and special items (OPs only).", + "Higher armor tiers provide better protection and more powerful abilities!", + "Strategize with teammates - trusted players won't be affected by your abilities!", + "The Dragon Egg holder becomes a high-value target - protect your Netherite Chestplate!", + "Combine abilities for powerful combos - Dash in then use Go Wild for surprise attacks!", + "Manage your cooldowns wisely - abilities are powerful but have long wait times.", + "Upgrade through all tiers: None → Leather → Chainmail → Gold → Iron → Diamond!", + "Players with no armor (naked) don't drop Armor Upgraders when killed.", + "Your armor progress is saved even when you log out or the server restarts!", + "Netherite tools have both combat utility and special abilities - use them wisely!", + "The Mace's Wind Burst can knock enemies away while you maintain Speed 1!", + "Ominous Keys are valuable - save them for crafting Armor Upgraders!", + "Higher tier armor makes you a bigger target - balance protection with strategy!", + "Use terrain to your advantage while abilities are on cooldown!", + "Team up to take down players with Netherite gear and share the upgrades!", + "The End and Nether can be disabled by admins to focus on overworld PvP!" ); } diff --git a/src/main/java/me/trouper/armorsmp/server/commands/GiveCommand.java b/src/main/java/me/trouper/armorsmp/server/commands/GiveCommand.java new file mode 100644 index 0000000..6e5a80e --- /dev/null +++ b/src/main/java/me/trouper/armorsmp/server/commands/GiveCommand.java @@ -0,0 +1,37 @@ +package me.trouper.armorsmp.server.commands; + +import io.github.itzispyder.pdk.commands.Args; +import io.github.itzispyder.pdk.commands.CommandRegistry; +import io.github.itzispyder.pdk.commands.CustomCommand; +import io.github.itzispyder.pdk.commands.Permission; +import io.github.itzispyder.pdk.commands.completions.CompletionBuilder; +import me.trouper.armorsmp.utils.Text; +import org.bukkit.Bukkit; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandRegistry(value = "armorsmp_give", permission = @Permission("armorsmp.give")) +public class GiveCommand implements CustomCommand { + + @Override + public void dispatchCommand(CommandSender commandSender, Command command, String label, Args args) { + String target = args.get(0).toString(); + Player t = Bukkit.getPlayer(target); + if (t == null) { + Text.sendError((Player) commandSender); + return; + } + switch (label) { + case "neth_axe" -> { + + } + + } + } + + @Override + public void dispatchCompletions(CommandSender commandSender, Command command, String label, CompletionBuilder completionBuilder) { + + } +} diff --git a/src/main/java/me/trouper/armorsmp/server/commands/MaceToggleCommand.java b/src/main/java/me/trouper/armorsmp/server/commands/MaceToggleCommand.java new file mode 100644 index 0000000..00c6b44 --- /dev/null +++ b/src/main/java/me/trouper/armorsmp/server/commands/MaceToggleCommand.java @@ -0,0 +1,19 @@ +package me.trouper.armorsmp.server.commands; + +import io.github.itzispyder.pdk.commands.Args; +import io.github.itzispyder.pdk.commands.CustomCommand; +import io.github.itzispyder.pdk.commands.completions.CompletionBuilder; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; + +public class MaceToggleCommand implements CustomCommand { + @Override + public void dispatchCommand(CommandSender commandSender, Command command, String s, Args args) { + + } + + @Override + public void dispatchCompletions(CommandSender commandSender, Command command, String s, CompletionBuilder completionBuilder) { + + } +} diff --git a/src/main/java/me/trouper/armorsmp/server/events/CraftEvent.java b/src/main/java/me/trouper/armorsmp/server/events/CraftEvent.java new file mode 100644 index 0000000..b247b8e --- /dev/null +++ b/src/main/java/me/trouper/armorsmp/server/events/CraftEvent.java @@ -0,0 +1,33 @@ +package me.trouper.armorsmp.server.events; + +import io.github.itzispyder.pdk.events.CustomListener; +import me.trouper.armorsmp.utils.Text; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.inventory.CraftItemEvent; +import org.bukkit.inventory.ItemStack; + +public class CraftEvent implements CustomListener { + + @EventHandler + public void onCraft(CraftItemEvent e) { + final ItemStack result = e.getRecipe().getResult(); + final String name = result.getType().name(); + final Player p = (Player) e.getWhoClicked(); + + if (!name.contains("HELMET") + && !name.contains("CHESTPLATE") + && !name.contains("LEGGINGS") + && !name.contains("BOOTS") + && !name.contains("NETHERITE_AXE") + && !name.contains("NETHERITE_SWORD") + && !name.contains("NETHERITE_SHOVEL") + && !name.contains("NETHERITE_HOE") + && !name.contains("NETHERITE_PICKAXE") + ) return; + + e.setCancelled(true); + p.closeInventory(); + Text.sendWarning(p,"You are not allowed to craft {0}.",name); + } +} diff --git a/src/main/java/me/trouper/armorsmp/utils/Text.java b/src/main/java/me/trouper/armorsmp/utils/Text.java index 7c032ce..3307516 100644 --- a/src/main/java/me/trouper/armorsmp/utils/Text.java +++ b/src/main/java/me/trouper/armorsmp/utils/Text.java @@ -2,16 +2,15 @@ package me.trouper.armorsmp.utils; import io.github.itzispyder.pdk.utils.misc.Randomizer; import me.trouper.armorsmp.ArmorSMP; +import net.kyori.adventure.audience.Audience; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextColor; import net.kyori.adventure.text.format.TextDecoration; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.bukkit.entity.Player; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -24,41 +23,27 @@ public class Text { public static Component color(String msg) { return LegacyComponentSerializer.legacyAmpersand().deserialize(msg); } - - public static String getActiveFormatting(String text) { - final Pattern pattern = Pattern.compile("&[0-9a-fk-or]"); - final Matcher matcher = pattern.matcher(text); - - String lastColor = ""; - Set activeFormats = new HashSet<>(); - - while (matcher.find()) { - String code = matcher.group(); - char identifier = code.charAt(1); - - if (identifier >= '0' && identifier <= '9' || identifier >= 'a' && identifier <= 'f') { - lastColor = code; - activeFormats.clear(); - } else if (identifier >= 'k' && identifier <= 'o') { - activeFormats.add(identifier); - } else if (identifier == 'r') { - lastColor = ""; - activeFormats.clear(); - } - } - - StringBuilder result = new StringBuilder(lastColor); - for (char format : activeFormats) { - result.append("&").append(format); - } - - return result.toString(); + + public static void sendWarning(Player player,String warning, Object... args) { + sendMessage(Pallet.WARNING,player,warning,false,args); + } + + public static void sendError(Player player, String error, Object... args) { + sendMessage(Pallet.ERROR,player,error,false,args); } + public static void sendMessage(Player player, String text, boolean allowTip, Object... args) { + sendMessage(Pallet.NEUTRAL,player,text,allowTip,args); + } + public static void sendMessage(Pallet pallet, Player player, String text, boolean allowTip, Object... args) { + text = formatArgs(pallet,text,args); + sendMessage(player,text,allowTip); + } public static void sendMessage(Player player, String text, boolean allowTip) { - Component message = getMessage(text,allowTip && ArmorSMP.getInstance().getManager().io.config.tips.tipsEnabled && !ArmorSMP.getInstance().getManager().io.storage.userData.tipsDisabled.contains(player.getUniqueId().toString())); + allowTip = allowTip && ArmorSMP.getInstance().getManager().io.config.tips.tipsEnabled && !ArmorSMP.getInstance().getManager().io.storage.userData.tipsDisabled.contains(player.getUniqueId().toString()); + Component message = getMessage(text,allowTip); player.sendMessage(message); } @@ -70,7 +55,38 @@ public class Text { } } + public static String formatArgs(Pallet pallet, String format, Object... args) { + Component message = Component.empty(); + Pattern pattern = Pattern.compile("\\{(\\d+)}"); + Matcher matcher = pattern.matcher(format); + int lastIndex = 0; + while (matcher.find()) { + String prefix = format.substring(lastIndex, matcher.start()); + if (!prefix.isEmpty()) { + message = message.append(Component.text(prefix).color(pallet.mainText)); + } + + int argIndex = Integer.parseInt(matcher.group(1)); + TextColor argColor = getArgColor(pallet, argIndex); + + if (argIndex >= 0 && argIndex < args.length) { + String argText = args[argIndex].toString(); + message = message.append(Component.text(argText).color(argColor)); + } else { + message = message.append(Component.text(matcher.group()).color(pallet.mainText)); + } + + lastIndex = matcher.end(); + } + + String suffix = format.substring(lastIndex); + if (!suffix.isEmpty()) { + message = message.append(Component.text(suffix).color(pallet.mainText)); + } + + return LegacyComponentSerializer.legacyAmpersand().serialize(message); + } public static Component formatFancyMessage(String text,boolean addTip) { Component message = Component.empty().appendNewline(); @@ -139,6 +155,87 @@ public class Text { return lines; } + public static String getActiveFormatting(String text) { + final Pattern pattern = Pattern.compile("&[0-9a-fk-or]"); + final Matcher matcher = pattern.matcher(text); + String lastColor = ""; + Set activeFormats = new HashSet<>(); + + while (matcher.find()) { + String code = matcher.group(); + char identifier = code.charAt(1); + + if (identifier >= '0' && identifier <= '9' || identifier >= 'a' && identifier <= 'f') { + lastColor = code; + activeFormats.clear(); + } else if (identifier >= 'k' && identifier <= 'o') { + activeFormats.add(identifier); + } else if (identifier == 'r') { + lastColor = ""; + activeFormats.clear(); + } + } + + StringBuilder result = new StringBuilder(lastColor); + for (char format : activeFormats) { + result.append("&").append(format); + } + + return result.toString(); + } + + private static TextColor getArgColor(Pallet pallet, int argIndex) { + return switch (argIndex) { + case 1 -> pallet.arg2; + case 2 -> pallet.arg3; + default -> pallet.argDefault; + }; + } + + public enum Pallet { + ERROR( + NamedTextColor.RED, + NamedTextColor.YELLOW, + NamedTextColor.GOLD, + NamedTextColor.DARK_RED + ), + WARNING( + NamedTextColor.YELLOW, + NamedTextColor.GOLD, + NamedTextColor.RED, + NamedTextColor.DARK_RED + ), + INFO( + NamedTextColor.GRAY, + NamedTextColor.WHITE, + NamedTextColor.AQUA, + NamedTextColor.DARK_AQUA + ), + SUCCESS( + NamedTextColor.GREEN, + NamedTextColor.DARK_GREEN, + NamedTextColor.YELLOW, + NamedTextColor.GOLD + ), + NEUTRAL( + NamedTextColor.GRAY, + NamedTextColor.WHITE, + NamedTextColor.DARK_AQUA, + NamedTextColor.BLUE + ); + + private final TextColor mainText; + private final TextColor argDefault; + private final TextColor arg2; + private final TextColor arg3; + + Pallet(TextColor mainText, TextColor argDefault, TextColor arg2, TextColor arg3) { + this.mainText = mainText; + this.argDefault = argDefault; + this.arg2 = arg2; + this.arg3 = arg3; + } + } }