summaryrefslogtreecommitdiffstats
path: root/bukkit/src
diff options
context:
space:
mode:
Diffstat (limited to 'bukkit/src')
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/itemgetter/ItemGetterLatest.java40
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/itemgetter/ItemGetter_1_13.java41
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/itemgetter/ItemGetter_Late_1_8.java44
3 files changed, 125 insertions, 0 deletions
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/itemgetter/ItemGetterLatest.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/itemgetter/ItemGetterLatest.java
index 91c96968..d2515948 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/itemgetter/ItemGetterLatest.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/itemgetter/ItemGetterLatest.java
@@ -1,6 +1,9 @@
package com.leonardobishop.quests.bukkit.hook.itemgetter;
import com.leonardobishop.quests.bukkit.util.chat.Chat;
+import com.mojang.authlib.GameProfile;
+import com.mojang.authlib.properties.Property;
+import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
@@ -10,7 +13,9 @@ import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
+import org.bukkit.inventory.meta.SkullMeta;
+import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -18,6 +23,8 @@ import java.util.UUID;
public class ItemGetterLatest implements ItemGetter {
+ private Field profileField;
+
/*
supporting:
- name
@@ -56,6 +63,39 @@ public class ItemGetterLatest implements ItemGetter {
ItemStack is = getItemStack(cType);
ItemMeta ism = is.getItemMeta();
+ // skull
+ if (is.getType() == Material.PLAYER_HEAD) {
+ SkullMeta sm = (SkullMeta) ism;
+ String cOwnerBase64 = config.getString(path + "owner-base64");
+ String cOwnerUsername = config.getString(path + "owner-username");
+ String cOwnerUuid = config.getString(path + "owner-uuid");
+ if (cOwnerBase64 != null || cOwnerUsername != null || cOwnerUuid != null) {
+ if (cOwnerUsername != null) {
+ sm.setOwner(cOwnerUsername);
+ } else if (cOwnerUuid != null) {
+ try {
+ sm.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(cOwnerUuid)));
+ } catch (IllegalArgumentException ignored) { }
+ } else {
+ GameProfile profile = new GameProfile(UUID.randomUUID(), "");
+ profile.getProperties().put("textures", new Property("textures", cOwnerBase64));
+ if (profileField == null) {
+ try {
+ profileField = sm.getClass().getDeclaredField("profile");
+ profileField.setAccessible(true);
+ } catch (NoSuchFieldException e) {
+ e.printStackTrace();
+ }
+ }
+ try {
+ profileField.set(sm, profile);
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
// name
if (!filters.contains(Filter.DISPLAY_NAME)) {
name = Chat.color(cName);
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/itemgetter/ItemGetter_1_13.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/itemgetter/ItemGetter_1_13.java
index d63720c7..f9a488f2 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/itemgetter/ItemGetter_1_13.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/itemgetter/ItemGetter_1_13.java
@@ -1,6 +1,9 @@
package com.leonardobishop.quests.bukkit.hook.itemgetter;
import com.leonardobishop.quests.bukkit.util.chat.Chat;
+import com.mojang.authlib.GameProfile;
+import com.mojang.authlib.properties.Property;
+import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
@@ -10,13 +13,18 @@ import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
+import org.bukkit.inventory.meta.SkullMeta;
+import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class ItemGetter_1_13 implements ItemGetter {
+
+ private Field profileField;
+
/*
reads the following:
- name
@@ -52,6 +60,39 @@ public class ItemGetter_1_13 implements ItemGetter {
ItemStack is = getItemStack(cType);
ItemMeta ism = is.getItemMeta();
+ // skull
+ if (is.getType() == Material.PLAYER_HEAD) {
+ SkullMeta sm = (SkullMeta) ism;
+ String cOwnerBase64 = config.getString(path + "owner-base64");
+ String cOwnerUsername = config.getString(path + "owner-username");
+ String cOwnerUuid = config.getString(path + "owner-uuid");
+ if (cOwnerBase64 != null || cOwnerUsername != null || cOwnerUuid != null) {
+ if (cOwnerUsername != null) {
+ sm.setOwner(cOwnerUsername);
+ } else if (cOwnerUuid != null) {
+ try {
+ sm.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(cOwnerUuid)));
+ } catch (IllegalArgumentException ignored) { }
+ } else {
+ GameProfile profile = new GameProfile(UUID.randomUUID(), "");
+ profile.getProperties().put("textures", new Property("textures", cOwnerBase64));
+ if (profileField == null) {
+ try {
+ profileField = sm.getClass().getDeclaredField("profile");
+ profileField.setAccessible(true);
+ } catch (NoSuchFieldException e) {
+ e.printStackTrace();
+ }
+ }
+ try {
+ profileField.set(sm, profile);
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
// name
if (!filters.contains(Filter.DISPLAY_NAME)) {
name = Chat.color(cName);
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/itemgetter/ItemGetter_Late_1_8.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/itemgetter/ItemGetter_Late_1_8.java
index 5959108d..5e19f095 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/itemgetter/ItemGetter_Late_1_8.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/itemgetter/ItemGetter_Late_1_8.java
@@ -1,19 +1,28 @@
package com.leonardobishop.quests.bukkit.hook.itemgetter;
import com.leonardobishop.quests.bukkit.util.chat.Chat;
+import com.mojang.authlib.GameProfile;
+import com.mojang.authlib.properties.Property;
import org.apache.commons.lang.StringUtils;
+import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
+import org.bukkit.inventory.meta.SkullMeta;
+import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;
+import java.util.UUID;
import java.util.regex.Pattern;
public class ItemGetter_Late_1_8 implements ItemGetter {
+
+ private Field profileField;
+
/*
reads the following:
- name
@@ -45,6 +54,41 @@ public class ItemGetter_Late_1_8 implements ItemGetter {
ItemStack is = getItemStack(cType);
ItemMeta ism = is.getItemMeta();
+ // skull
+
+ // skull
+ if (is.getType().toString().equals("SKULL_ITEM")) {
+ SkullMeta sm = (SkullMeta) ism;
+ String cOwnerBase64 = config.getString(path + "owner-base64");
+ String cOwnerUsername = config.getString(path + "owner-username");
+ String cOwnerUuid = config.getString(path + "owner-uuid");
+ if (cOwnerBase64 != null || cOwnerUsername != null || cOwnerUuid != null) {
+ if (cOwnerUsername != null) {
+ sm.setOwner(cOwnerUsername);
+ } else if (cOwnerUuid != null) {
+ try {
+ sm.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(cOwnerUuid)));
+ } catch (IllegalArgumentException ignored) { }
+ } else {
+ GameProfile profile = new GameProfile(UUID.randomUUID(), "");
+ profile.getProperties().put("textures", new Property("textures", cOwnerBase64));
+ if (profileField == null) {
+ try {
+ profileField = sm.getClass().getDeclaredField("profile");
+ profileField.setAccessible(true);
+ } catch (NoSuchFieldException e) {
+ e.printStackTrace();
+ }
+ }
+ try {
+ profileField.set(sm, profile);
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
// lore
if (!filters.contains(Filter.LORE)) {
ism.setLore(Chat.color(cLore));