Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

working 1.20.4 build with Base64 head fix #126

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>fun.lewisdev</groupId>
<artifactId>DeluxeHub</artifactId>
<version>3.5.4</version>
<version>3.6.0</version>
<packaging>jar</packaging>

<name>DeluxeHub</name>
Expand Down Expand Up @@ -115,7 +115,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.1-R0.1-SNAPSHOT</version>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -133,7 +133,7 @@
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.10.4</version>
<version>2.11.6</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -160,13 +160,19 @@
</dependency>
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId>
<version>2.11.3</version>
<artifactId>item-nbt-api-plugin</artifactId>
<version>2.13.1</version>
</dependency>
<dependency>
<groupId>com.github.shynixn.headdatabase</groupId>
<artifactId>hdb-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
10 changes: 3 additions & 7 deletions src/main/java/fun/lewisdev/deluxehub/DeluxeHubPlugin.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -49,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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
53 changes: 37 additions & 16 deletions src/main/java/fun/lewisdev/deluxehub/hook/hooks/head/BaseHead.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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");

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 0 additions & 3 deletions src/main/java/fun/lewisdev/deluxehub/utility/TextUtil.java
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: ${project.name}
author: ItsLewizzz
author: ItsLewizzz, OhDave
version: ${project.version}
description: ${project.description}
website: ${project.url}
Expand Down Expand Up @@ -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:
Expand Down