forked from Upstream/CommandPanels
3.21.2.2
This commit is contained in:
parent
ad25df283f
commit
d1645d6bbb
@ -1,4 +1,4 @@
|
|||||||
version: 3.21.2.1
|
version: 3.21.2.2
|
||||||
main: me.rockyhawk.commandpanels.CommandPanels
|
main: me.rockyhawk.commandpanels.CommandPanels
|
||||||
name: CommandPanels
|
name: CommandPanels
|
||||||
author: RockyHawk
|
author: RockyHawk
|
||||||
|
@ -3,6 +3,7 @@ package me.rockyhawk.commandpanels.classresources;
|
|||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
import com.mojang.authlib.properties.PropertyMap;
|
import com.mojang.authlib.properties.PropertyMap;
|
||||||
|
import me.arcaniax.hdb.api.HeadDatabaseAPI;
|
||||||
import me.rockyhawk.commandpanels.CommandPanels;
|
import me.rockyhawk.commandpanels.CommandPanels;
|
||||||
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
|
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -17,10 +18,7 @@ import java.lang.reflect.Method;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Scanner;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class GetCustomHeads {
|
public class GetCustomHeads {
|
||||||
CommandPanels plugin;
|
CommandPanels plugin;
|
||||||
@ -33,39 +31,39 @@ public class GetCustomHeads {
|
|||||||
|
|
||||||
public String getHeadBase64(ItemStack head) {
|
public String getHeadBase64(ItemStack head) {
|
||||||
if (plugin.getHeads.ifSkullOrHead(head.getType().toString()) && head.hasItemMeta()) {
|
if (plugin.getHeads.ifSkullOrHead(head.getType().toString()) && head.hasItemMeta()) {
|
||||||
|
//check if the head is a HeadDatabase head first
|
||||||
|
if(plugin.getServer().getPluginManager().isPluginEnabled("HeadDatabase")) {
|
||||||
|
HeadDatabaseAPI api = new HeadDatabaseAPI();
|
||||||
try {
|
try {
|
||||||
|
String base64 = api.getBase64(head);
|
||||||
|
if(base64 != null){
|
||||||
|
return base64;
|
||||||
|
}
|
||||||
|
} catch (Exception ignore) {}
|
||||||
|
}
|
||||||
|
//try getting Base64 of a custom head
|
||||||
|
if (!(head.getItemMeta() instanceof SkullMeta)) return null;
|
||||||
SkullMeta meta = (SkullMeta) head.getItemMeta();
|
SkullMeta meta = (SkullMeta) head.getItemMeta();
|
||||||
assert meta != null;
|
if (meta == null) return null;
|
||||||
if (!meta.hasOwner()) {
|
|
||||||
Field fld = meta.getClass().getDeclaredField("profile");
|
try {
|
||||||
fld.setAccessible(true);
|
Field profileField = meta.getClass().getDeclaredField("profile");
|
||||||
GameProfile prof = (GameProfile) fld.get(meta);
|
profileField.setAccessible(true);
|
||||||
Iterator itr = prof.getProperties().get("textures").iterator();
|
GameProfile profile = (GameProfile) profileField.get(meta);
|
||||||
if (itr.hasNext()) {
|
|
||||||
Property var5 = (Property) itr.next();
|
Collection<Property> textures = profile.getProperties().get("textures");
|
||||||
return var5.getValue();
|
if (!textures.isEmpty()) {
|
||||||
|
// Directly accessing fields within the Property object via reflection.
|
||||||
|
Property textureProperty = textures.iterator().next();
|
||||||
|
Field valueField = textureProperty.getClass().getDeclaredField("value");
|
||||||
|
valueField.setAccessible(true);
|
||||||
|
return (String) valueField.get(textureProperty);
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
Field fld = meta.getClass().getDeclaredField("profile");
|
} catch (Exception error) {
|
||||||
fld.setAccessible(true);
|
plugin.debug(error, null);
|
||||||
GameProfile prof = (GameProfile) fld.get(meta);
|
|
||||||
Iterator itr = prof.getProperties().get("textures").iterator();
|
|
||||||
if (itr.hasNext()) {
|
|
||||||
Property var5 = (Property) itr.next();
|
|
||||||
String var5string = var5.toString();
|
|
||||||
var5string = var5string.replace("Property[","");
|
|
||||||
var5string = var5string.replace("]","");
|
|
||||||
String[] var5strings = var5string.split(",");
|
|
||||||
for(String var : var5strings){
|
|
||||||
if(var.contains("value= ")){
|
|
||||||
var = var.replace("value= ", "");
|
|
||||||
return var;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}catch(Exception exc){/*skip return null*/}
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,12 +424,12 @@ public class ItemCreation {
|
|||||||
if(plugin.getHeads.ifSkullOrHead(cont.getType().toString())){
|
if(plugin.getHeads.ifSkullOrHead(cont.getType().toString())){
|
||||||
if(!Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("%") && !Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("=")) {
|
if(!Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("%") && !Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("=")) {
|
||||||
SkullMeta meta = (SkullMeta) cont.getItemMeta();
|
SkullMeta meta = (SkullMeta) cont.getItemMeta();
|
||||||
if (plugin.customHeads.getHeadBase64(cont) != null && !plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)) {
|
if (plugin.customHeads.getHeadBase64(cont) != null) {
|
||||||
//inject base64 here, disable for legacy as is not working
|
//inject base64 here, disable for legacy as is not working
|
||||||
file.set("panels." + panelName + ".item." + i + ".material", "cps= " + plugin.customHeads.getHeadBase64(cont));
|
file.set("panels." + panelName + ".item." + i + ".material", "cps= " + plugin.customHeads.getHeadBase64(cont));
|
||||||
} else if (meta.hasOwner()) {
|
} else{
|
||||||
//check for skull owner
|
//return blank head
|
||||||
file.set("panels." + panelName + ".item." + i + ".material", "cps= " + meta.getOwner());
|
file.set("panels." + panelName + ".item." + i + ".material", plugin.getHeads.playerHeadString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -448,7 +448,9 @@ public class ItemCreation {
|
|||||||
//potion legacy PotionData or current PotionType
|
//potion legacy PotionData or current PotionType
|
||||||
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_19) ||
|
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_19) ||
|
||||||
(plugin.legacy.MAJOR_VERSION == MinecraftVersions.v1_20 && plugin.legacy.MINOR_VERSION <= 4)){
|
(plugin.legacy.MAJOR_VERSION == MinecraftVersions.v1_20 && plugin.legacy.MINOR_VERSION <= 4)){
|
||||||
|
if(plugin.legacyPotion.retrievePotionData(cont) != null) {
|
||||||
file.set("panels." + panelName + ".item." + i + ".potion", plugin.legacyPotion.retrievePotionData(cont));
|
file.set("panels." + panelName + ".item." + i + ".potion", plugin.legacyPotion.retrievePotionData(cont));
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
PotionMeta potionMeta = (PotionMeta) cont.getItemMeta();
|
PotionMeta potionMeta = (PotionMeta) cont.getItemMeta();
|
||||||
assert potionMeta != null;
|
assert potionMeta != null;
|
||||||
|
@ -2,7 +2,6 @@ package me.rockyhawk.commandpanels.ioclasses.potions;
|
|||||||
|
|
||||||
import me.rockyhawk.commandpanels.CommandPanels;
|
import me.rockyhawk.commandpanels.CommandPanels;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
@ -73,7 +72,7 @@ public class LegacyPotionData {
|
|||||||
return potionType.name() + " " + extended + " " + level;
|
return potionType.name() + " " + extended + " " + level;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
plugin.debug(e, null);
|
plugin.debug(e, null);
|
||||||
return "Failed to retrieve potion data";
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user