mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-01 15:03:36 +01:00
Correct tabcomplete for give command
Getting rid of less efficient adventure String processing Huge boost for limited item recognition process which can be up to 100x faster than original one
This commit is contained in:
parent
84be2eba79
commit
c18916bd56
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -213,7 +214,8 @@ public class GuiManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void openJobsBrowseGUI(Player player, Job job, boolean fromCommand) {
|
public void openJobsBrowseGUI(Player player, Job job, boolean fromCommand) {
|
||||||
Inventory tempInv = plugin.getComplement().createInventory(player, 54, "");
|
|
||||||
|
Inventory tempInv = Bukkit.createInventory(player, 54, "");
|
||||||
|
|
||||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||||
Boost boost = Jobs.getPlayerManager().getFinalBonus(jPlayer, job);
|
Boost boost = Jobs.getPlayerManager().getFinalBonus(jPlayer, job);
|
||||||
@ -369,7 +371,7 @@ public class GuiManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void openJobsBrowseGUI(Player player, Job job, List<ActionType> jobsRemained) {
|
private void openJobsBrowseGUI(Player player, Job job, List<ActionType> jobsRemained) {
|
||||||
Inventory tempInv = plugin.getComplement().createInventory(player, 54, "");
|
Inventory tempInv = Bukkit.createInventory(player, 54, "");
|
||||||
|
|
||||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||||
Boost boost = Jobs.getPlayerManager().getFinalBonus(jPlayer, job);
|
Boost boost = Jobs.getPlayerManager().getFinalBonus(jPlayer, job);
|
||||||
|
@ -59,6 +59,7 @@ import net.Zrips.CMILib.Equations.ParseError;
|
|||||||
import net.Zrips.CMILib.Equations.Parser;
|
import net.Zrips.CMILib.Equations.Parser;
|
||||||
import net.Zrips.CMILib.FileHandler.ConfigReader;
|
import net.Zrips.CMILib.FileHandler.ConfigReader;
|
||||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||||
|
import net.Zrips.CMILib.Logs.CMIDebug;
|
||||||
import net.Zrips.CMILib.Version.Version;
|
import net.Zrips.CMILib.Version.Version;
|
||||||
|
|
||||||
public class ConfigManager {
|
public class ConfigManager {
|
||||||
|
@ -343,7 +343,7 @@ public class LanguageManager {
|
|||||||
|
|
||||||
c.get("command.give.help.info", "Gives item by jobs name and item category name. Player name is optional");
|
c.get("command.give.help.info", "Gives item by jobs name and item category name. Player name is optional");
|
||||||
c.get("command.give.help.args", "[playername] [jobname] [items/limiteditems] [jobitemname]");
|
c.get("command.give.help.args", "[playername] [jobname] [items/limiteditems] [jobitemname]");
|
||||||
Jobs.getGCManager().getCommandArgs().put("give", Arrays.asList("[playername]", "[jobname]%%[jobitemname]", "[jobitemname]"));
|
Jobs.getGCManager().getCommandArgs().put("give", Arrays.asList("[playername]", "[jobname]", "items%%limiteditems","[jobitemname]"));
|
||||||
c.get("command.give.output.notonline", "&4Player with that name is not online!");
|
c.get("command.give.output.notonline", "&4Player with that name is not online!");
|
||||||
c.get("command.give.output.noitem", "&4Can't find any item by given name!");
|
c.get("command.give.output.noitem", "&4Can't find any item by given name!");
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
|||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.world.StructureGrowEvent;
|
import org.bukkit.event.world.StructureGrowEvent;
|
||||||
import org.bukkit.event.world.WorldLoadEvent;
|
import org.bukkit.event.world.WorldLoadEvent;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
@ -85,6 +86,7 @@ import net.Zrips.CMILib.Colors.CMIChatColor;
|
|||||||
import net.Zrips.CMILib.Items.ArmorTypes;
|
import net.Zrips.CMILib.Items.ArmorTypes;
|
||||||
import net.Zrips.CMILib.Items.CMIItemStack;
|
import net.Zrips.CMILib.Items.CMIItemStack;
|
||||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||||
|
import net.Zrips.CMILib.NBT.CMINBT;
|
||||||
import net.Zrips.CMILib.Version.Version;
|
import net.Zrips.CMILib.Version.Version;
|
||||||
|
|
||||||
public class JobsListener implements Listener {
|
public class JobsListener implements Listener {
|
||||||
@ -383,14 +385,23 @@ public class JobsListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onLimitedItemInteract(PlayerInteractEvent event) {
|
public void onLimitedItemInteract(PlayerInteractEvent event) {
|
||||||
|
|
||||||
if(!Jobs.hasLimitedItems())
|
if (!Jobs.hasLimitedItems()) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
ItemStack iih = CMIItemStack.getItemInMainHand(player);
|
ItemStack iih = null;
|
||||||
if (iih.getType() == Material.AIR)
|
try {
|
||||||
|
if (Version.isCurrentHigher(Version.v1_8_R3) && event.getHand() != EquipmentSlot.HAND) {
|
||||||
|
iih = CMIItemStack.getItemInOffHand(player);
|
||||||
|
} else {
|
||||||
|
iih = CMIItemStack.getItemInMainHand(player);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
iih = CMIItemStack.getItemInMainHand(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iih == null || iih.getType() == Material.AIR)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (event.getClickedBlock() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getClickedBlock().getWorld()))
|
if (event.getClickedBlock() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getClickedBlock().getWorld()))
|
||||||
@ -401,29 +412,54 @@ public class JobsListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Map<Enchantment, Integer> enchants = new HashMap<>(iih.getEnchantments());
|
Map<Enchantment, Integer> enchants = new HashMap<>(iih.getEnchantments());
|
||||||
if (enchants.isEmpty())
|
if (enchants.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String name = null;
|
String name = null;
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
|
|
||||||
|
CMINBT nbt = new CMINBT(iih);
|
||||||
|
Integer i = nbt.getInt("JobsLimited");
|
||||||
|
if (i != null) {
|
||||||
|
Job job = Jobs.getJob(i);
|
||||||
|
if (job != null) {
|
||||||
|
JobProgression prog = jPlayer.getJobProgression(job);
|
||||||
|
if (prog != null) {
|
||||||
|
String node = nbt.getString("JobsLimitedNode");
|
||||||
|
if (node != null) {
|
||||||
|
for (JobLimitedItems oneItem : job.getLimitedItems().values()) {
|
||||||
|
if (prog.getLevel() >= oneItem.getLevel() || !oneItem.getNode().equalsIgnoreCase(node))
|
||||||
|
continue;
|
||||||
|
event.setCancelled(true);
|
||||||
|
CMIActionBar.send(player, Jobs.getLanguage().getMessage("limitedItem.error.levelup", "[jobname]", job.getDisplayName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (iih.hasItemMeta()) {
|
if (iih.hasItemMeta()) {
|
||||||
ItemMeta meta = iih.getItemMeta();
|
ItemMeta meta = iih.getItemMeta();
|
||||||
if (meta.hasDisplayName())
|
if (meta.hasDisplayName())
|
||||||
name = plugin.getComplement().getDisplayName(meta);
|
name = meta.getDisplayName();
|
||||||
if (meta.hasLore())
|
if (meta.hasLore())
|
||||||
lore = plugin.getComplement().getLore(meta);
|
lore = meta.getLore();
|
||||||
}
|
}
|
||||||
|
|
||||||
String meinOk = null;
|
String meinOk = null;
|
||||||
|
String itemNode = null;
|
||||||
CMIMaterial mat = CMIMaterial.get(iih);
|
CMIMaterial mat = CMIMaterial.get(iih);
|
||||||
|
|
||||||
|
Integer jobId = null;
|
||||||
mein: for (JobProgression one : jPlayer.getJobProgression()) {
|
mein: for (JobProgression one : jPlayer.getJobProgression()) {
|
||||||
for (JobLimitedItems oneItem : one.getJob().getLimitedItems().values()) {
|
for (JobLimitedItems oneItem : one.getJob().getLimitedItems().values()) {
|
||||||
if (one.getLevel() >= oneItem.getLevel() || !isThisItem(oneItem, mat, name, lore, enchants))
|
if (one.getLevel() >= oneItem.getLevel() || !isThisItem(oneItem, mat, name, lore, enchants))
|
||||||
continue;
|
continue;
|
||||||
|
jobId = one.getJob().getId();
|
||||||
meinOk = one.getJob().getName();
|
meinOk = one.getJob().getDisplayName();
|
||||||
|
itemNode = oneItem.getNode();
|
||||||
break mein;
|
break mein;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -431,6 +467,19 @@ public class JobsListener implements Listener {
|
|||||||
if (meinOk != null) {
|
if (meinOk != null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
CMIActionBar.send(player, Jobs.getLanguage().getMessage("limitedItem.error.levelup", "[jobname]", meinOk));
|
CMIActionBar.send(player, Jobs.getLanguage().getMessage("limitedItem.error.levelup", "[jobname]", meinOk));
|
||||||
|
|
||||||
|
nbt = new CMINBT(iih);
|
||||||
|
nbt.setInt("JobsLimited", jobId);
|
||||||
|
iih = (ItemStack) nbt.setString("JobsLimitedNode", itemNode);
|
||||||
|
try {
|
||||||
|
if (Version.isCurrentHigher(Version.v1_8_R3) && event.getHand() != EquipmentSlot.HAND) {
|
||||||
|
CMIItemStack.setItemInOffHand(player, iih);
|
||||||
|
} else {
|
||||||
|
CMIItemStack.setItemInMainHand(player, iih);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
CMIItemStack.setItemInMainHand(player, iih);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,6 @@ import net.Zrips.CMILib.Entities.CMIEntityType;
|
|||||||
import net.Zrips.CMILib.Items.CMIItemStack;
|
import net.Zrips.CMILib.Items.CMIItemStack;
|
||||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||||
import net.Zrips.CMILib.Locale.LC;
|
import net.Zrips.CMILib.Locale.LC;
|
||||||
import net.Zrips.CMILib.Logs.CMIDebug;
|
|
||||||
import net.Zrips.CMILib.Messages.CMIMessages;
|
import net.Zrips.CMILib.Messages.CMIMessages;
|
||||||
import net.Zrips.CMILib.Version.Version;
|
import net.Zrips.CMILib.Version.Version;
|
||||||
|
|
||||||
@ -214,8 +213,7 @@ public final class JobsPaymentListener implements Listener {
|
|||||||
ItemStack currentItem = event.getCurrentItem();
|
ItemStack currentItem = event.getCurrentItem();
|
||||||
|
|
||||||
if (resultStack.hasItemMeta() && resultStack.getItemMeta().hasDisplayName()) {
|
if (resultStack.hasItemMeta() && resultStack.getItemMeta().hasDisplayName()) {
|
||||||
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(plugin
|
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(resultStack.getItemMeta().getDisplayName()), ActionType.VTRADE));
|
||||||
.getComplement().getDisplayName(resultStack.getItemMeta())), ActionType.VTRADE));
|
|
||||||
} else if (currentItem != null) {
|
} else if (currentItem != null) {
|
||||||
Jobs.action(jPlayer, new ItemActionInfo(currentItem, ActionType.VTRADE));
|
Jobs.action(jPlayer, new ItemActionInfo(currentItem, ActionType.VTRADE));
|
||||||
}
|
}
|
||||||
@ -237,8 +235,7 @@ public final class JobsPaymentListener implements Listener {
|
|||||||
while (newItemsCount >= 1) {
|
while (newItemsCount >= 1) {
|
||||||
newItemsCount--;
|
newItemsCount--;
|
||||||
if (resultStack.hasItemMeta() && resultStack.getItemMeta().hasDisplayName())
|
if (resultStack.hasItemMeta() && resultStack.getItemMeta().hasDisplayName())
|
||||||
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(plugin
|
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(resultStack.getItemMeta().getDisplayName()), ActionType.VTRADE));
|
||||||
.getComplement().getDisplayName(resultStack.getItemMeta())), ActionType.VTRADE));
|
|
||||||
else
|
else
|
||||||
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.VTRADE));
|
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.VTRADE));
|
||||||
}
|
}
|
||||||
@ -749,8 +746,7 @@ public final class JobsPaymentListener implements Listener {
|
|||||||
PotionMeta potion = (PotionMeta) currentItem.getItemMeta();
|
PotionMeta potion = (PotionMeta) currentItem.getItemMeta();
|
||||||
Jobs.action(jPlayer, new PotionItemActionInfo(currentItem, ActionType.CRAFT, potion.getBasePotionData().getType()));
|
Jobs.action(jPlayer, new PotionItemActionInfo(currentItem, ActionType.CRAFT, potion.getBasePotionData().getType()));
|
||||||
} else if (resultStack.hasItemMeta() && resultStack.getItemMeta().hasDisplayName()) {
|
} else if (resultStack.hasItemMeta() && resultStack.getItemMeta().hasDisplayName()) {
|
||||||
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(plugin
|
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(resultStack.getItemMeta().getDisplayName()), ActionType.CRAFT));
|
||||||
.getComplement().getDisplayName(resultStack.getItemMeta())), ActionType.CRAFT));
|
|
||||||
} else if (currentItem != null) {
|
} else if (currentItem != null) {
|
||||||
Jobs.action(jPlayer, new ItemActionInfo(currentItem, ActionType.CRAFT));
|
Jobs.action(jPlayer, new ItemActionInfo(currentItem, ActionType.CRAFT));
|
||||||
}
|
}
|
||||||
@ -776,8 +772,7 @@ public final class JobsPaymentListener implements Listener {
|
|||||||
org.bukkit.inventory.meta.ItemMeta resultItemMeta = resultStack.getItemMeta();
|
org.bukkit.inventory.meta.ItemMeta resultItemMeta = resultStack.getItemMeta();
|
||||||
|
|
||||||
if (resultItemMeta != null && resultItemMeta.hasDisplayName())
|
if (resultItemMeta != null && resultItemMeta.hasDisplayName())
|
||||||
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(plugin
|
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(resultItemMeta.getDisplayName()), ActionType.CRAFT));
|
||||||
.getComplement().getDisplayName(resultItemMeta)), ActionType.CRAFT));
|
|
||||||
else
|
else
|
||||||
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT));
|
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT));
|
||||||
}
|
}
|
||||||
@ -967,10 +962,10 @@ public final class JobsPaymentListener implements Listener {
|
|||||||
String originalName = null;
|
String originalName = null;
|
||||||
String newName = null;
|
String newName = null;
|
||||||
if (firstSlot.hasItemMeta())
|
if (firstSlot.hasItemMeta())
|
||||||
originalName = plugin.getComplement().getDisplayName(firstSlot.getItemMeta());
|
originalName = firstSlot.getItemMeta().getDisplayName();
|
||||||
|
|
||||||
if (resultStack.hasItemMeta())
|
if (resultStack.hasItemMeta())
|
||||||
newName = plugin.getComplement().getDisplayName(resultStack.getItemMeta());
|
newName = resultStack.getItemMeta().getDisplayName();
|
||||||
|
|
||||||
if (originalName != null && !originalName.equals(newName) && inv.getItem(1) == null && !Jobs.getGCManager().PayForRenaming)
|
if (originalName != null && !originalName.equals(newName) && inv.getItem(1) == null && !Jobs.getGCManager().PayForRenaming)
|
||||||
return;
|
return;
|
||||||
|
@ -108,7 +108,7 @@ public final class TabComplete implements TabCompleter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args.length > 3 && args[3].equalsIgnoreCase("limiteditems")) {
|
if (args.length > 3 && args[3].equalsIgnoreCase("limiteditems")) {
|
||||||
Job oneJob = Jobs.getJob(args[i - 1]);
|
Job oneJob = Jobs.getJob(args[i - 2]);
|
||||||
|
|
||||||
if (oneJob != null)
|
if (oneJob != null)
|
||||||
for (JobLimitedItems limitedItem : oneJob.getLimitedItems().values()) {
|
for (JobLimitedItems limitedItem : oneJob.getLimitedItems().values()) {
|
||||||
|
@ -6,15 +6,11 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.block.SignChangeEvent;
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
|
|
||||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||||
|
|
||||||
public interface Complement {
|
public interface Complement {
|
||||||
|
|
||||||
String getDisplayName(ItemMeta meta);
|
|
||||||
|
|
||||||
String getDisplayName(Player player);
|
String getDisplayName(Player player);
|
||||||
|
|
||||||
String getLine(SignChangeEvent event, int line);
|
String getLine(SignChangeEvent event, int line);
|
||||||
@ -25,14 +21,6 @@ public interface Complement {
|
|||||||
|
|
||||||
void setLine(Sign sign, int line, String text);
|
void setLine(Sign sign, int line, String text);
|
||||||
|
|
||||||
org.bukkit.inventory.Inventory createInventory(InventoryHolder owner, int size, String title);
|
|
||||||
|
|
||||||
void setLore(ItemMeta meta, List<String> lore);
|
|
||||||
|
|
||||||
List<String> getLore(ItemMeta meta);
|
|
||||||
|
|
||||||
void setDisplayName(ItemMeta meta, String name);
|
|
||||||
|
|
||||||
default void broadcastMessage(String message) {
|
default void broadcastMessage(String message) {
|
||||||
message = CMIChatColor.translate(message);
|
message = CMIChatColor.translate(message);
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
@ -1,23 +1,12 @@
|
|||||||
package com.gamingmesh.jobs.stuff.complement;
|
package com.gamingmesh.jobs.stuff.complement;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.block.SignChangeEvent;
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public final class Complement1 implements Complement {
|
public final class Complement1 implements Complement {
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayName(ItemMeta meta) {
|
|
||||||
return meta.getDisplayName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLine(SignChangeEvent event, int line) {
|
public String getLine(SignChangeEvent event, int line) {
|
||||||
return event.getLine(line);
|
return event.getLine(line);
|
||||||
@ -33,21 +22,6 @@ public final class Complement1 implements Complement {
|
|||||||
return sign.getLine(line);
|
return sign.getLine(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Inventory createInventory(InventoryHolder owner, int size, String title) {
|
|
||||||
return Bukkit.createInventory(owner, size, title);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLore(ItemMeta meta, List<String> lore) {
|
|
||||||
meta.setLore(lore);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDisplayName(ItemMeta meta, String name) {
|
|
||||||
meta.setDisplayName(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDisplayName(Player player) {
|
public String getDisplayName(Player player) {
|
||||||
return player.getDisplayName();
|
return player.getDisplayName();
|
||||||
@ -57,9 +31,4 @@ public final class Complement1 implements Complement {
|
|||||||
public void setLine(Sign sign, int line, String text) {
|
public void setLine(Sign sign, int line, String text) {
|
||||||
sign.setLine(line, text);
|
sign.setLine(line, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getLore(ItemMeta meta) {
|
|
||||||
return meta.getLore();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,8 @@
|
|||||||
package com.gamingmesh.jobs.stuff.complement;
|
package com.gamingmesh.jobs.stuff.complement;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.block.SignChangeEvent;
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
@ -25,18 +18,6 @@ public class Complement2 implements Complement {
|
|||||||
return LegacyComponentSerializer.legacyAmpersand().deserialize(t);
|
return LegacyComponentSerializer.legacyAmpersand().deserialize(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayName(ItemMeta meta) {
|
|
||||||
Component dName = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
dName = meta.displayName();
|
|
||||||
} catch (NoSuchMethodError e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
return dName == null ? "" : serialize(dName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLine(SignChangeEvent event, int line) {
|
public String getLine(SignChangeEvent event, int line) {
|
||||||
Component l = event.line(line);
|
Component l = event.line(line);
|
||||||
@ -53,27 +34,6 @@ public class Complement2 implements Complement {
|
|||||||
return serialize(sign.line(line));
|
return serialize(sign.line(line));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Inventory createInventory(InventoryHolder owner, int size, String title) {
|
|
||||||
return Bukkit.createInventory(owner, size, deserialize(title));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLore(ItemMeta meta, List<String> lore) {
|
|
||||||
List<Component> l = new ArrayList<>();
|
|
||||||
|
|
||||||
for (String e : lore) {
|
|
||||||
l.add(deserialize(e));
|
|
||||||
}
|
|
||||||
|
|
||||||
meta.lore(l);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDisplayName(ItemMeta meta, String name) {
|
|
||||||
meta.displayName(deserialize(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDisplayName(Player player) {
|
public String getDisplayName(Player player) {
|
||||||
return serialize(player.displayName());
|
return serialize(player.displayName());
|
||||||
@ -84,16 +44,4 @@ public class Complement2 implements Complement {
|
|||||||
sign.line(line, deserialize(text));
|
sign.line(line, deserialize(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getLore(ItemMeta meta) {
|
|
||||||
List<String> lore = new ArrayList<>();
|
|
||||||
|
|
||||||
if (meta.hasLore()) {
|
|
||||||
for (Component comp : meta.lore()) {
|
|
||||||
lore.add(serialize(comp));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return lore;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user