1.14 support.

This commit is contained in:
Brianna 2019-04-23 21:20:30 -04:00
parent 9f2b886b42
commit b0fe063b8b
11 changed files with 29 additions and 35 deletions

View File

@ -50,7 +50,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.13.2</version>
<version>1.14-pre5</version>
</dependency>
<dependency>
<groupId>com.songoda</groupId>

View File

@ -61,7 +61,7 @@ public class GUIDecorOptions extends AbstractGUI {
lore.add(Methods.formatText("&7Currently &cDisabled&7."));
}
createButton(10, Material.SIGN, "&9&lToggle Holograms", lore);
createButton(10, Material.NAME_TAG, "&9&lToggle Holograms", lore);
lore = new ArrayList<>();
if (kitBlockData.hasParticles()) {

View File

@ -213,7 +213,7 @@ public class GUIDisplayKit extends AbstractGUI {
protected void registerClickables() {
registerClickable(0, (player, inventory, cursor, slot, type) -> {
if (back == null) return;
back.init(back.getInventory().getTitle(), back.getInventory().getSize());
back.init(back.getSetTitle(), back.getInventory().getSize());
});
registerClickable(8, (player, inventory, cursor, slot, type) -> player.closeInventory());

View File

@ -110,7 +110,7 @@ public class GUIGUIOptions extends AbstractGUI {
@Override
protected void registerClickables() {
registerClickable(0, (player, inventory, cursor, slot, type) -> back.init(back.getInventory().getTitle(), back.getInventory().getSize()));
registerClickable(0, (player, inventory, cursor, slot, type) -> back.init(back.getSetTitle(), back.getInventory().getSize()));
registerClickable(8, (player, inventory, cursor, slot, type) -> player.closeInventory());
@ -124,7 +124,7 @@ public class GUIGUIOptions extends AbstractGUI {
plugin.getHologram().update(kit);
});
gui.setOnClose((player2, inventory3) -> init(inventory.getTitle(), inventory.getSize()));
gui.setOnClose((player2, inventory3) -> init(setTitle, inventory.getSize()));
ItemStack item = new ItemStack(Material.NAME_TAG);
ItemMeta meta = item.getItemMeta();

View File

@ -77,7 +77,7 @@ public class GUIGeneralOptions extends AbstractGUI {
@Override
protected void registerClickables() {
registerClickable(0, (player, inventory, cursor, slot, type) -> back.init(back.getInventory().getTitle(), back.getInventory().getSize()));
registerClickable(0, (player, inventory, cursor, slot, type) -> back.init(back.getSetTitle(), back.getInventory().getSize()));
registerClickable(8, (player, inventory, cursor, slot, type) -> player.closeInventory());
@ -97,7 +97,7 @@ public class GUIGeneralOptions extends AbstractGUI {
gui.setOnClose((player2, inventory3) -> {
if (plugin.getKitManager().getKit(name) != null) {
init(inventory.getTitle(), inventory.getSize());
init(setTitle, inventory.getSize());
}
});
@ -123,7 +123,7 @@ public class GUIGeneralOptions extends AbstractGUI {
}
});
gui.setOnClose((player2, inventory3) -> init(inventory.getTitle(), inventory.getSize()));
gui.setOnClose((player2, inventory3) -> init(setTitle, inventory.getSize()));
ItemStack item = new ItemStack(Material.PAPER);
ItemMeta meta = item.getItemMeta();

View File

@ -498,7 +498,7 @@ public class GUIKitEditor extends AbstractGUI {
registerClickable(0, ((player, inventory, cursor, slot, type) -> {
if (back == null) return;
back.init(back.getInventory().getTitle(), back.getInventory().getSize());
back.init(back.getSetTitle(), back.getInventory().getSize());
}));
registerClickable(48, ((player1, inventory, cursor, slot1, type) -> {

View File

@ -106,7 +106,7 @@ public class GUISellingOptions extends AbstractGUI {
@Override
protected void registerClickables() {
registerClickable(0, (player, inventory, cursor, slot, type) -> back.init(back.getInventory().getTitle(), back.getInventory().getSize()));
registerClickable(0, (player, inventory, cursor, slot, type) -> back.init(back.getSetTitle(), back.getInventory().getSize()));
registerClickable(8, (player, inventory, cursor, slot, type) -> player.closeInventory());
@ -130,7 +130,7 @@ public class GUISellingOptions extends AbstractGUI {
}
});
gui.setOnClose((player2, inventory3) -> init(inventory.getTitle(), inventory.getSize()));
gui.setOnClose((player2, inventory3) -> init(setTitle, inventory.getSize()));
ItemStack item = new ItemStack(Material.SUNFLOWER);
ItemMeta meta = item.getItemMeta();
@ -153,7 +153,7 @@ public class GUISellingOptions extends AbstractGUI {
plugin.getHologram().update(kit);
});
gui.setOnClose((player2, inventory3) -> init(inventory.getTitle(), inventory.getSize()));
gui.setOnClose((player2, inventory3) -> init(setTitle, inventory.getSize()));
ItemStack item = new ItemStack(Material.PAPER);
ItemMeta meta = item.getItemMeta();

View File

@ -127,7 +127,7 @@ public abstract class Hologram {
if (b.getType() == Material.TRAPPED_CHEST
|| b.getType() == Material.CHEST
|| b.getType() == Material.SIGN
|| b.getType().name().contains("SIGN")
|| b.getType() == Material.ENDER_CHEST) multi -= .15;
location.add(0, multi, 0);

View File

@ -1,34 +1,22 @@
package com.songoda.ultimatekits.utils;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.text.DecimalFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import org.apache.commons.codec.binary.Base64;
import com.songoda.ultimatekits.UltimateKits;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.songoda.ultimatekits.UltimateKits;
import net.milkbowl.vault.economy.Economy;
import java.lang.reflect.Field;
import java.text.DecimalFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* Created by songoda on 2/24/2017.
@ -268,7 +256,7 @@ public class Methods {
SkullMeta meta = (SkullMeta) item.getItemMeta();
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
byte[] encodedData = Base64.encodeBase64(String.format("{textures:{SKIN:{url:\"%s\"}}}", new Object[]{headURL}).getBytes());
byte[] encodedData = Base64.getEncoder().encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", new Object[]{headURL}).getBytes());
profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
Field profileField;

View File

@ -46,7 +46,7 @@ public class SettingsManager implements Listener {
|| e.getWhoClicked().getOpenInventory().getTopInventory() != e.getInventory()) {
return;
}
if (e.getInventory().getTitle().equals(pluginName + " Settings Manager")) {
if (e.getView().getTitle().equals(pluginName + " Settings Manager")) {
if (e.getCurrentItem().getType().name().contains("STAINED_GLASS")) {
e.setCancelled(true);
@ -57,7 +57,7 @@ public class SettingsManager implements Listener {
cat.put((Player) e.getWhoClicked(), type);
openEditor((Player) e.getWhoClicked());
e.setCancelled(true);
} else if (e.getInventory().getTitle().equals(pluginName + " Settings KitEditor")) {
} else if (e.getView().getTitle().equals(pluginName + " Settings KitEditor")) {
if (e.getCurrentItem().getType().name().contains("STAINED_GLASS")) {
e.setCancelled(true);

View File

@ -28,6 +28,7 @@ public abstract class AbstractGUI implements Listener {
private static boolean listenersInitialized = false;
protected Player player;
protected Inventory inventory = null;
protected String setTitle = null;
protected boolean cancelBottom = false;
private Map<Range, Clickable> clickables = new HashMap<>();
private List<OnClose> onCloses = new ArrayList<>();
@ -115,8 +116,9 @@ public abstract class AbstractGUI implements Listener {
public void init(String title, int slots) {
if (inventory == null
|| inventory.getSize() != slots
|| ChatColor.translateAlternateColorCodes('&', title) != inventory.getTitle()) {
|| !ChatColor.translateAlternateColorCodes('&', title).equals(player.getOpenInventory().getTitle())) {
this.inventory = Bukkit.getServer().createInventory(new GUIHolder(), slots, Methods.formatTitle(title));
this.setTitle = Methods.formatText(title);
if (this.clickables.size() == 0)
registerClickables();
if (this.onCloses.size() == 0)
@ -217,4 +219,8 @@ public abstract class AbstractGUI implements Listener {
return AbstractGUI.this;
}
}
public String getSetTitle() {
return setTitle;
}
}