From 5888e7d5b594b0ccc33586a08e4d7f7db23aa932 Mon Sep 17 00:00:00 2001 From: OhDaveDev Date: Sun, 6 Oct 2024 21:26:33 +0100 Subject: [PATCH 1/2] Update for DominionMC and working 1.20.4 build with Base64 head fix --- pom.xml | 16 ++++-- .../lewisdev/deluxehub/DeluxeHubPlugin.java | 9 +--- .../actions/BroadcastMessageAction.java | 2 +- .../action/actions/MessageAction.java | 2 +- .../deluxehub/command/CommandManager.java | 3 +- .../deluxehub/hook/hooks/head/BaseHead.java | 53 +++++++++++++------ .../modules/hologram/HologramManager.java | 1 - .../module/modules/hotbar/HotbarItem.java | 2 +- .../modules/hotbar/items/PlayerHider.java | 2 +- .../module/modules/player/DoubleJump.java | 5 +- .../modules/visual/tablist/TablistHelper.java | 1 - .../module/modules/world/WorldProtect.java | 2 +- .../deluxehub/utility/ItemStackBuilder.java | 1 + .../lewisdev/deluxehub/utility/TextUtil.java | 3 -- .../utility/reflection/ArmorStandName.java | 1 - src/main/resources/plugin.yml | 4 +- 16 files changed, 61 insertions(+), 46 deletions(-) diff --git a/pom.xml b/pom.xml index 8a52c6a6..1cb718ed 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ fun.lewisdev DeluxeHub - 3.5.4 + 3.6.0 jar DeluxeHub @@ -115,7 +115,7 @@ org.spigotmc spigot-api - 1.20.1-R0.1-SNAPSHOT + 1.20.4-R0.1-SNAPSHOT provided @@ -133,7 +133,7 @@ me.clip placeholderapi - 2.10.4 + 2.11.6 provided @@ -160,13 +160,19 @@ de.tr7zw - item-nbt-api - 2.11.3 + item-nbt-api-plugin + 2.13.1 com.github.shynixn.headdatabase hdb-api 1.0 + + org.projectlombok + lombok + 1.18.30 + provided + diff --git a/src/main/java/fun/lewisdev/deluxehub/DeluxeHubPlugin.java b/src/main/java/fun/lewisdev/deluxehub/DeluxeHubPlugin.java index b81ecc46..15cb7bf3 100644 --- a/src/main/java/fun/lewisdev/deluxehub/DeluxeHubPlugin.java +++ b/src/main/java/fun/lewisdev/deluxehub/DeluxeHubPlugin.java @@ -1,11 +1,7 @@ package fun.lewisdev.deluxehub; -import cl.bgmp.minecraft.util.commands.exceptions.CommandException; -import cl.bgmp.minecraft.util.commands.exceptions.CommandPermissionsException; -import cl.bgmp.minecraft.util.commands.exceptions.CommandUsageException; -import cl.bgmp.minecraft.util.commands.exceptions.MissingNestedCommandException; -import cl.bgmp.minecraft.util.commands.exceptions.WrappedCommandException; -import de.tr7zw.changeme.nbtapi.utils.MinecraftVersion; +import cl.bgmp.minecraft.util.commands.exceptions.*; +import de.tr7zw.nbtapi.utils.MinecraftVersion; import fun.lewisdev.deluxehub.action.ActionManager; import fun.lewisdev.deluxehub.command.CommandManager; import fun.lewisdev.deluxehub.config.ConfigManager; @@ -17,7 +13,6 @@ import fun.lewisdev.deluxehub.module.ModuleManager; import fun.lewisdev.deluxehub.module.ModuleType; import fun.lewisdev.deluxehub.module.modules.hologram.HologramManager; -import fun.lewisdev.deluxehub.utility.TextUtil; import fun.lewisdev.deluxehub.utility.UpdateChecker; import org.bstats.bukkit.MetricsLite; import org.bukkit.Bukkit; diff --git a/src/main/java/fun/lewisdev/deluxehub/action/actions/BroadcastMessageAction.java b/src/main/java/fun/lewisdev/deluxehub/action/actions/BroadcastMessageAction.java index fa96af48..4b7ff49f 100644 --- a/src/main/java/fun/lewisdev/deluxehub/action/actions/BroadcastMessageAction.java +++ b/src/main/java/fun/lewisdev/deluxehub/action/actions/BroadcastMessageAction.java @@ -1,8 +1,8 @@ package fun.lewisdev.deluxehub.action.actions; import fun.lewisdev.deluxehub.DeluxeHubPlugin; -import fun.lewisdev.deluxehub.utility.TextUtil; import fun.lewisdev.deluxehub.action.Action; +import fun.lewisdev.deluxehub.utility.TextUtil; import org.bukkit.Bukkit; import org.bukkit.entity.Player; diff --git a/src/main/java/fun/lewisdev/deluxehub/action/actions/MessageAction.java b/src/main/java/fun/lewisdev/deluxehub/action/actions/MessageAction.java index b4509800..a6e7a897 100644 --- a/src/main/java/fun/lewisdev/deluxehub/action/actions/MessageAction.java +++ b/src/main/java/fun/lewisdev/deluxehub/action/actions/MessageAction.java @@ -1,8 +1,8 @@ package fun.lewisdev.deluxehub.action.actions; import fun.lewisdev.deluxehub.DeluxeHubPlugin; -import fun.lewisdev.deluxehub.utility.TextUtil; import fun.lewisdev.deluxehub.action.Action; +import fun.lewisdev.deluxehub.utility.TextUtil; import org.bukkit.entity.Player; public class MessageAction implements Action { diff --git a/src/main/java/fun/lewisdev/deluxehub/command/CommandManager.java b/src/main/java/fun/lewisdev/deluxehub/command/CommandManager.java index 2446b7e1..b4506a2f 100644 --- a/src/main/java/fun/lewisdev/deluxehub/command/CommandManager.java +++ b/src/main/java/fun/lewisdev/deluxehub/command/CommandManager.java @@ -12,7 +12,8 @@ import org.bukkit.command.CommandSender; import org.bukkit.configuration.file.FileConfiguration; -import java.util.*; +import java.util.ArrayList; +import java.util.List; public class CommandManager { diff --git a/src/main/java/fun/lewisdev/deluxehub/hook/hooks/head/BaseHead.java b/src/main/java/fun/lewisdev/deluxehub/hook/hooks/head/BaseHead.java index ddcb4ca7..10a35bb0 100644 --- a/src/main/java/fun/lewisdev/deluxehub/hook/hooks/head/BaseHead.java +++ b/src/main/java/fun/lewisdev/deluxehub/hook/hooks/head/BaseHead.java @@ -1,14 +1,16 @@ package fun.lewisdev.deluxehub.hook.hooks.head; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.Property; import fun.lewisdev.deluxehub.DeluxeHubPlugin; import fun.lewisdev.deluxehub.hook.PluginHook; -import fun.lewisdev.deluxehub.utility.universal.XMaterial; +import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; - -import java.lang.reflect.Field; +import org.bukkit.profile.PlayerProfile; +import org.bukkit.profile.PlayerTextures; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Base64; import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -26,20 +28,39 @@ public void onEnable(DeluxeHubPlugin plugin) { public ItemStack getHead(String data) { if (cache.containsKey(data)) return cache.get(data); - ItemStack head = XMaterial.PLAYER_HEAD.parseItem(); + ItemStack head = new ItemStack(Material.PLAYER_HEAD); SkullMeta meta = (SkullMeta) head.getItemMeta(); - GameProfile profile = new GameProfile(UUID.randomUUID(), ""); - profile.getProperties().put("textures", new Property("textures", data)); - Field profileField; - try { - profileField = meta.getClass().getDeclaredField("profile"); - profileField.setAccessible(true); - profileField.set(meta, profile); - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) { - e.printStackTrace(); - } + setBase64ToSkullMeta(data, meta); head.setItemMeta(meta); cache.put(data, head); return head; } + + public static URL getUrlFromBase64(String base64) throws MalformedURLException { + try { + String decoded = new String(Base64.getDecoder().decode(base64)); + return new URL(decoded.substring("{\"textures\":{\"SKIN\":{\"url\":\"".length(), decoded.length() - "\"}}}".length())); + } catch (Throwable t) { + throw new MalformedURLException("Invalid base64 string: " + base64); + } + } + private static void setBase64ToSkullMeta(String base64, SkullMeta meta) { + PlayerProfile profile = getProfileBase64(base64); + meta.setOwnerProfile(profile); + } + private static PlayerProfile getProfileBase64(String base64) { + PlayerProfile profile = Bukkit.createPlayerProfile(RANDOM_UUID); // Get a new player profile + PlayerTextures textures = profile.getTextures(); + URL urlObject; + try { + urlObject = getUrlFromBase64(base64); + } catch (MalformedURLException exception) { + throw new RuntimeException("Invalid URL", exception); + } + textures.setSkin(urlObject); + profile.setTextures(textures); + return profile; + } + private static final UUID RANDOM_UUID = UUID.fromString("92864445-51c5-4c3b-9039-517c9927d1b4"); + } diff --git a/src/main/java/fun/lewisdev/deluxehub/module/modules/hologram/HologramManager.java b/src/main/java/fun/lewisdev/deluxehub/module/modules/hologram/HologramManager.java index d39fbf13..b7d528b2 100644 --- a/src/main/java/fun/lewisdev/deluxehub/module/modules/hologram/HologramManager.java +++ b/src/main/java/fun/lewisdev/deluxehub/module/modules/hologram/HologramManager.java @@ -10,7 +10,6 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; -import org.bukkit.event.Listener; import java.util.ArrayList; import java.util.HashSet; diff --git a/src/main/java/fun/lewisdev/deluxehub/module/modules/hotbar/HotbarItem.java b/src/main/java/fun/lewisdev/deluxehub/module/modules/hotbar/HotbarItem.java index 0ac34bae..44e44ac9 100644 --- a/src/main/java/fun/lewisdev/deluxehub/module/modules/hotbar/HotbarItem.java +++ b/src/main/java/fun/lewisdev/deluxehub/module/modules/hotbar/HotbarItem.java @@ -1,6 +1,6 @@ package fun.lewisdev.deluxehub.module.modules.hotbar; -import de.tr7zw.changeme.nbtapi.NBTItem; +import de.tr7zw.nbtapi.NBTItem; import fun.lewisdev.deluxehub.DeluxeHubPlugin; import fun.lewisdev.deluxehub.utility.ItemStackBuilder; import fun.lewisdev.deluxehub.utility.universal.XMaterial; diff --git a/src/main/java/fun/lewisdev/deluxehub/module/modules/hotbar/items/PlayerHider.java b/src/main/java/fun/lewisdev/deluxehub/module/modules/hotbar/items/PlayerHider.java index 10c40540..fb9b22ad 100644 --- a/src/main/java/fun/lewisdev/deluxehub/module/modules/hotbar/items/PlayerHider.java +++ b/src/main/java/fun/lewisdev/deluxehub/module/modules/hotbar/items/PlayerHider.java @@ -1,6 +1,6 @@ package fun.lewisdev.deluxehub.module.modules.hotbar.items; -import de.tr7zw.changeme.nbtapi.NBTItem; +import de.tr7zw.nbtapi.NBTItem; import fun.lewisdev.deluxehub.config.ConfigType; import fun.lewisdev.deluxehub.config.Messages; import fun.lewisdev.deluxehub.cooldown.CooldownType; diff --git a/src/main/java/fun/lewisdev/deluxehub/module/modules/player/DoubleJump.java b/src/main/java/fun/lewisdev/deluxehub/module/modules/player/DoubleJump.java index 59494ac7..63f45bd5 100644 --- a/src/main/java/fun/lewisdev/deluxehub/module/modules/player/DoubleJump.java +++ b/src/main/java/fun/lewisdev/deluxehub/module/modules/player/DoubleJump.java @@ -54,10 +54,7 @@ public void onPlayerToggleFlight(PlayerToggleFlightEvent event) { Player player = event.getPlayer(); // Perform checks - if (player.hasPermission(new Permission(Permissions.DOUBLE_JUMP_BYPASS.getPermission(), PermissionDefault.FALSE))) return; - else if (inDisabledWorld(player.getLocation())) return; - else if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) return; - else if (!event.isFlying()) return; + if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) return; else if (player.getWorld().getBlockAt(player.getLocation().subtract(0, 2, 0)).getType() == Material.AIR) { event.setCancelled(true); return; diff --git a/src/main/java/fun/lewisdev/deluxehub/module/modules/visual/tablist/TablistHelper.java b/src/main/java/fun/lewisdev/deluxehub/module/modules/visual/tablist/TablistHelper.java index edf0474a..784df4e5 100644 --- a/src/main/java/fun/lewisdev/deluxehub/module/modules/visual/tablist/TablistHelper.java +++ b/src/main/java/fun/lewisdev/deluxehub/module/modules/visual/tablist/TablistHelper.java @@ -1,7 +1,6 @@ package fun.lewisdev.deluxehub.module.modules.visual.tablist; import com.google.common.base.Strings; -import fun.lewisdev.deluxehub.DeluxeHubPlugin; import fun.lewisdev.deluxehub.utility.TextUtil; import fun.lewisdev.deluxehub.utility.reflection.ReflectionUtils; import fun.lewisdev.deluxehub.utility.universal.XMaterial; diff --git a/src/main/java/fun/lewisdev/deluxehub/module/modules/world/WorldProtect.java b/src/main/java/fun/lewisdev/deluxehub/module/modules/world/WorldProtect.java index a91ab4c2..af1ac189 100644 --- a/src/main/java/fun/lewisdev/deluxehub/module/modules/world/WorldProtect.java +++ b/src/main/java/fun/lewisdev/deluxehub/module/modules/world/WorldProtect.java @@ -1,6 +1,6 @@ package fun.lewisdev.deluxehub.module.modules.world; -import de.tr7zw.changeme.nbtapi.NBTItem; +import de.tr7zw.nbtapi.NBTItem; import fun.lewisdev.deluxehub.DeluxeHubPlugin; import fun.lewisdev.deluxehub.Permissions; import fun.lewisdev.deluxehub.config.ConfigType; diff --git a/src/main/java/fun/lewisdev/deluxehub/utility/ItemStackBuilder.java b/src/main/java/fun/lewisdev/deluxehub/utility/ItemStackBuilder.java index bc8bd2d0..20f89d1d 100644 --- a/src/main/java/fun/lewisdev/deluxehub/utility/ItemStackBuilder.java +++ b/src/main/java/fun/lewisdev/deluxehub/utility/ItemStackBuilder.java @@ -14,6 +14,7 @@ import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.plugin.java.JavaPlugin; + import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/fun/lewisdev/deluxehub/utility/TextUtil.java b/src/main/java/fun/lewisdev/deluxehub/utility/TextUtil.java index a5ffebd7..2daa4080 100644 --- a/src/main/java/fun/lewisdev/deluxehub/utility/TextUtil.java +++ b/src/main/java/fun/lewisdev/deluxehub/utility/TextUtil.java @@ -1,12 +1,9 @@ package fun.lewisdev.deluxehub.utility; import fun.lewisdev.deluxehub.utility.color.IridiumColorAPI; -import net.md_5.bungee.api.ChatColor; import org.bukkit.Color; import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; public class TextUtil { diff --git a/src/main/java/fun/lewisdev/deluxehub/utility/reflection/ArmorStandName.java b/src/main/java/fun/lewisdev/deluxehub/utility/reflection/ArmorStandName.java index 9a3a90a4..e9ef1f2d 100644 --- a/src/main/java/fun/lewisdev/deluxehub/utility/reflection/ArmorStandName.java +++ b/src/main/java/fun/lewisdev/deluxehub/utility/reflection/ArmorStandName.java @@ -1,6 +1,5 @@ package fun.lewisdev.deluxehub.utility.reflection; -import fun.lewisdev.deluxehub.DeluxeHubPlugin; import fun.lewisdev.deluxehub.utility.universal.XMaterial; import org.bukkit.entity.ArmorStand; diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 36235594..1c958b2d 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: ${project.name} -author: ItsLewizzz +author: ItsLewizzz, OhDave version: ${project.version} description: ${project.description} website: ${project.url} @@ -40,7 +40,7 @@ permissions: deluxehub.bypass.commands: true deluxehub.bypass.lockchat: true deluxehub.bypass.antiwdl: true - deluxehub.bypass.doublejump: false + deluxehub.bypass.doublejump: true deluxehub.alert.*: description: Gives access to all alert permissions children: From 6e68ccc43e3d8f13ff62162d5d602e9d7f2e4a5e Mon Sep 17 00:00:00 2001 From: OhDaveDev Date: Sun, 6 Oct 2024 21:42:01 +0100 Subject: [PATCH 2/2] update --- src/main/java/fun/lewisdev/deluxehub/DeluxeHubPlugin.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/fun/lewisdev/deluxehub/DeluxeHubPlugin.java b/src/main/java/fun/lewisdev/deluxehub/DeluxeHubPlugin.java index 15cb7bf3..0f3db4cc 100644 --- a/src/main/java/fun/lewisdev/deluxehub/DeluxeHubPlugin.java +++ b/src/main/java/fun/lewisdev/deluxehub/DeluxeHubPlugin.java @@ -44,6 +44,7 @@ public void onEnable() { getLogger().log(Level.INFO, ""); getLogger().log(Level.INFO, "Version: " + getDescription().getVersion()); getLogger().log(Level.INFO, "Author: ItsLewizzz"); + getLogger().log(Level.INFO, "Forked by: OhDaveDev"); getLogger().log(Level.INFO, ""); // Check if using Spigot