mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-23 00:05:52 +01:00
1.20.2 support
This commit is contained in:
parent
760f7f6b0b
commit
b8e02c945f
@ -1,7 +1,5 @@
|
||||
package net.Indyuce.mmocore.api.player.profess;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
@ -21,18 +19,18 @@ import net.Indyuce.mmocore.api.player.profess.event.EventTrigger;
|
||||
import net.Indyuce.mmocore.api.player.profess.resource.ManaDisplayOptions;
|
||||
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
||||
import net.Indyuce.mmocore.api.player.profess.resource.ResourceRegeneration;
|
||||
import net.Indyuce.mmocore.skill.binding.SkillSlot;
|
||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
||||
import net.Indyuce.mmocore.experience.EXPSource;
|
||||
import net.Indyuce.mmocore.experience.ExpCurve;
|
||||
import net.Indyuce.mmocore.experience.ExperienceObject;
|
||||
import net.Indyuce.mmocore.experience.droptable.ExperienceTable;
|
||||
import net.Indyuce.mmocore.loot.chest.particle.CastingParticle;
|
||||
import net.Indyuce.mmocore.player.stats.StatInfo;
|
||||
import net.Indyuce.mmocore.skill.ClassSkill;
|
||||
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
||||
import net.Indyuce.mmocore.skill.binding.SkillSlot;
|
||||
import net.Indyuce.mmocore.skill.cast.ComboMap;
|
||||
import net.Indyuce.mmocore.experience.ExperienceObject;
|
||||
import net.Indyuce.mmocore.skilltree.tree.SkillTree;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -45,7 +43,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@ -90,19 +87,11 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
|
||||
name = MythicLib.plugin.parseColors(config.getString("display.name", "INVALID DISPLAY NAME"));
|
||||
icon = MMOCoreUtils.readIcon(config.getString("display.item", "BARRIER"));
|
||||
|
||||
if (config.contains("display.texture") && icon.getType() == VersionMaterial.PLAYER_HEAD.toMaterial())
|
||||
try {
|
||||
ItemMeta meta = icon.getItemMeta();
|
||||
Field profileField = meta.getClass().getDeclaredField("profile");
|
||||
profileField.setAccessible(true);
|
||||
GameProfile gp = new GameProfile(UUID.randomUUID(), null);
|
||||
gp.getProperties().put("textures", new Property("textures", config.getString("display.texture")));
|
||||
profileField.set(meta, gp);
|
||||
icon.setItemMeta(meta);
|
||||
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException
|
||||
| SecurityException exception) {
|
||||
throw new IllegalArgumentException("Could not apply playerhead texture: " + exception.getMessage());
|
||||
}
|
||||
if (config.contains("display.texture") && icon.getType() == VersionMaterial.PLAYER_HEAD.toMaterial()) {
|
||||
ItemMeta meta = icon.getItemMeta();
|
||||
UtilityMethods.setTextureValue(meta, config.getString("display.texture"));
|
||||
icon.setItemMeta(meta);
|
||||
}
|
||||
|
||||
for (String string : config.getStringList("display.lore"))
|
||||
description.add(ChatColor.GRAY + MythicLib.plugin.parseColors(string));
|
||||
@ -375,9 +364,9 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
|
||||
|
||||
/**
|
||||
* @return A list of passive skills which correspond to class
|
||||
* scripts wrapped in a format recognized by MythicLib.
|
||||
* Class scripts are handled just like
|
||||
* passive skills
|
||||
* scripts wrapped in a format recognized by MythicLib.
|
||||
* Class scripts are handled just like
|
||||
* passive skills
|
||||
*/
|
||||
@NotNull
|
||||
public List<PassiveSkill> getScripts() {
|
||||
|
@ -1,14 +1,11 @@
|
||||
package net.Indyuce.mmocore.gui.api.item;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import net.Indyuce.mmocore.gui.api.GeneratedInventory;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -17,11 +14,8 @@ import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public abstract class InventoryItem<T extends GeneratedInventory> {
|
||||
private final String id, function;
|
||||
@ -153,7 +147,8 @@ public abstract class InventoryItem<T extends GeneratedInventory> {
|
||||
final ItemStack item = new ItemStack(material);
|
||||
final ItemMeta meta = item.getItemMeta();
|
||||
meta.setCustomModelData(modelData);
|
||||
if (texture != null && meta instanceof SkullMeta) applyTexture(texture, (SkullMeta) meta);
|
||||
if (texture != null && meta instanceof SkullMeta)
|
||||
UtilityMethods.setTextureValue(meta, texture);
|
||||
|
||||
if (hasName()) meta.setDisplayName(placeholders.apply(effectivePlayer, getName()));
|
||||
|
||||
@ -182,19 +177,6 @@ public abstract class InventoryItem<T extends GeneratedInventory> {
|
||||
return inv.getPlayer();
|
||||
}
|
||||
|
||||
private void applyTexture(String value, SkullMeta meta) {
|
||||
try {
|
||||
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
|
||||
profile.getProperties().put("textures", new Property("textures", value));
|
||||
|
||||
Field profileField = meta.getClass().getDeclaredField("profile");
|
||||
profileField.setAccessible(true);
|
||||
profileField.set(meta, profile);
|
||||
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException exception) {
|
||||
MMOCore.log(Level.WARNING, "Could not apply item texture value of " + getId());
|
||||
}
|
||||
}
|
||||
|
||||
public Placeholders getPlaceholders(T inv) {
|
||||
return getPlaceholders(inv, 0);
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
package net.Indyuce.mmocore.util.item;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||
@ -13,7 +12,6 @@ import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@ -45,12 +43,8 @@ public abstract class AbstractItemBuilder {
|
||||
|
||||
if (item.getType() == VersionMaterial.PLAYER_HEAD.toMaterial() && configItem.getTexture() != null)
|
||||
try {
|
||||
Field profileField = meta.getClass().getDeclaredField("profile");
|
||||
profileField.setAccessible(true);
|
||||
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
|
||||
profile.getProperties().put("textures", new Property("textures", configItem.getTexture()));
|
||||
profileField.set(meta, profile);
|
||||
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException exception) {
|
||||
UtilityMethods.setTextureValue(meta, configItem.getTexture());
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.log(Level.WARNING, "Could not load texture of config item called '" + configItem.getId() + "'");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user