mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-27 20:45:27 +01:00
Merge branch 'development'
This commit is contained in:
commit
b4090303c1
@ -4,7 +4,7 @@ stages:
|
||||
variables:
|
||||
name: "SongodaCore"
|
||||
path: "/builds/$CI_PROJECT_PATH"
|
||||
version: "2.2.3"
|
||||
version: "2.2.4"
|
||||
|
||||
build:
|
||||
stage: build
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.core.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.gui.events.GuiClickEvent;
|
||||
import com.songoda.core.gui.events.GuiCloseEvent;
|
||||
import com.songoda.core.gui.events.GuiDropItemEvent;
|
||||
@ -789,7 +790,7 @@ public class Gui {
|
||||
protected static String trimTitle(String title) {
|
||||
if(title == null) {
|
||||
return "";
|
||||
} else if (title.length() > 32) {
|
||||
} else if (ServerVersion.isServerVersionAtOrBelow(ServerVersion.V1_8) && title.length() > 32) {
|
||||
return title.charAt(30) == '\u00A7' ? title.substring(0, 30) : title.substring(0, 31);
|
||||
}
|
||||
return title;
|
||||
|
@ -328,30 +328,24 @@ public class ItemUtils {
|
||||
}
|
||||
}
|
||||
|
||||
static Field cb_SkullMeta_profile;
|
||||
public static String getSkullTexture(ItemStack item) {
|
||||
if (!CompatibleMaterial.PLAYER_HEAD.matches(item) || ServerVersion.isServerVersionBelow(ServerVersion.V1_8)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
SkullMeta localSkullMeta = (SkullMeta) item.getItemMeta();
|
||||
Field cb_SkullMeta_profile = localSkullMeta.getClass().getDeclaredField("profile");
|
||||
if (cb_SkullMeta_profile == null) return null;
|
||||
cb_SkullMeta_profile.setAccessible(true);
|
||||
|
||||
static {
|
||||
try {
|
||||
cb_SkullMeta_profile = SkullMeta.class.getDeclaredField("profile");
|
||||
cb_SkullMeta_profile.setAccessible(true);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
GameProfile profile = (GameProfile) cb_SkullMeta_profile.get(localSkullMeta);
|
||||
Iterator<Property> iterator = profile.getProperties().get("textures").iterator();
|
||||
|
||||
public static String getSkullTexture(ItemStack item) {
|
||||
if (cb_SkullMeta_profile == null || !CompatibleMaterial.PLAYER_HEAD.matches(item) || ServerVersion.isServerVersionBelow(ServerVersion.V1_8)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
SkullMeta localSkullMeta = (SkullMeta) item.getItemMeta();
|
||||
GameProfile profile = (GameProfile) cb_SkullMeta_profile.get(localSkullMeta);
|
||||
Iterator<Property> iterator = profile.getProperties().get("textures").iterator();
|
||||
|
||||
return iterator.hasNext() ? iterator.next().getValue() : null;
|
||||
} catch (IllegalArgumentException | IllegalAccessException ex) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return iterator.hasNext() ? iterator.next().getValue() : null;
|
||||
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException ex) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getDecodedTexture(String encoded) {
|
||||
return encoded != null ? StringUtils.substringBetween(new String(Base64.getDecoder().decode(encoded)), "texture/", "\"") : null;
|
||||
|
@ -34,12 +34,21 @@ public class AnvilView extends ContainerAnvil implements CustomAnvil {
|
||||
|
||||
static {
|
||||
try {
|
||||
mc_ContainerAnvil_repairInventory = ContainerAnvil.class.getDeclaredField("h");
|
||||
mc_ContainerAnvil_repairInventory.setAccessible(true);
|
||||
mc_ContainerAnvil_resultInventory = ContainerAnvil.class.getDeclaredField("g");
|
||||
mc_ContainerAnvil_resultInventory.setAccessible(true);
|
||||
mc_ContainerAnvil_bukkitEntity = ContainerAnvil.class.getDeclaredField("bukkitEntity");
|
||||
mc_ContainerAnvil_bukkitEntity.setAccessible(true);
|
||||
mc_ContainerAnvil_repairInventory = ContainerAnvil.class.getDeclaredField("repairInventory");
|
||||
mc_ContainerAnvil_repairInventory.setAccessible(true);
|
||||
mc_ContainerAnvil_resultInventory = ContainerAnvil.class.getDeclaredField("resultInventory");
|
||||
mc_ContainerAnvil_resultInventory.setAccessible(true);
|
||||
} catch (NoSuchFieldException ignore) {
|
||||
try {
|
||||
mc_ContainerAnvil_repairInventory = ContainerAnvil.class.getDeclaredField("h");
|
||||
mc_ContainerAnvil_repairInventory.setAccessible(true);
|
||||
mc_ContainerAnvil_resultInventory = ContainerAnvil.class.getDeclaredField("g");
|
||||
mc_ContainerAnvil_resultInventory.setAccessible(true);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(AnvilView.class.getName()).log(Level.SEVERE, "Anvil Setup Error", ex);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(AnvilView.class.getName()).log(Level.SEVERE, "Anvil Setup Error", ex);
|
||||
}
|
||||
|
@ -34,9 +34,9 @@ public class AnvilView extends ContainerAnvil implements CustomAnvil {
|
||||
|
||||
static {
|
||||
try {
|
||||
mc_ContainerAnvil_repairInventory = ContainerAnvil.class.getDeclaredField("h");
|
||||
mc_ContainerAnvil_repairInventory = ContainerAnvil.class.getDeclaredField("repairInventory");
|
||||
mc_ContainerAnvil_repairInventory.setAccessible(true);
|
||||
mc_ContainerAnvil_resultInventory = ContainerAnvil.class.getDeclaredField("g");
|
||||
mc_ContainerAnvil_resultInventory = ContainerAnvil.class.getDeclaredField("resultInventory");
|
||||
mc_ContainerAnvil_resultInventory.setAccessible(true);
|
||||
mc_ContainerAnvil_bukkitEntity = ContainerAnvil.class.getDeclaredField("bukkitEntity");
|
||||
mc_ContainerAnvil_bukkitEntity.setAccessible(true);
|
||||
|
Loading…
Reference in New Issue
Block a user