mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2024-11-28 12:55:34 +01:00
Added tooltips to lookups that display item names and enchantments (#67)
This commit is contained in:
parent
20710a00de
commit
5d6fd60d40
@ -1,5 +1,6 @@
|
|||||||
package net.coreprotect.command;
|
package net.coreprotect.command;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
@ -356,14 +357,9 @@ public class LookupCommand {
|
|||||||
ConfigHandler.lookupThrottle.put(player2.getName(), new Object[] { true, System.currentTimeMillis() });
|
ConfigHandler.lookupThrottle.put(player2.getName(), new Object[] { true, System.currentTimeMillis() });
|
||||||
if (connection != null) {
|
if (connection != null) {
|
||||||
Statement statement = connection.createStatement();
|
Statement statement = connection.createStatement();
|
||||||
String blockdata = ChestTransactionLookup.performLookup(command.getName(), statement, location, player2, p2, finalLimit, false);
|
List<String> blockData = ChestTransactionLookup.performLookup(command.getName(), statement, location, player2, p2, finalLimit, false);
|
||||||
if (blockdata.contains("\n")) {
|
for (String data : blockData) {
|
||||||
for (String b : blockdata.split("\n")) {
|
Chat.sendComponent(player2, data);
|
||||||
Chat.sendComponent(player2, b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Chat.sendComponent(player2, blockdata);
|
|
||||||
}
|
}
|
||||||
statement.close();
|
statement.close();
|
||||||
}
|
}
|
||||||
@ -906,7 +902,7 @@ public class LookupCommand {
|
|||||||
for (String[] data : lookupList) {
|
for (String[] data : lookupList) {
|
||||||
String time = data[0];
|
String time = data[0];
|
||||||
String dplayer = data[1];
|
String dplayer = data[1];
|
||||||
String dtype = data[5];
|
int dtype = Integer.parseInt(data[5]);
|
||||||
int ddata = Integer.parseInt(data[6]);
|
int ddata = Integer.parseInt(data[6]);
|
||||||
int daction = Integer.parseInt(data[7]);
|
int daction = Integer.parseInt(data[7]);
|
||||||
int amount = Integer.parseInt(data[10]);
|
int amount = Integer.parseInt(data[10]);
|
||||||
@ -916,8 +912,10 @@ public class LookupCommand {
|
|||||||
int z = Integer.parseInt(data[4]);
|
int z = Integer.parseInt(data[4]);
|
||||||
String rbd = ((Integer.parseInt(data[8]) == 2 || Integer.parseInt(data[8]) == 3) ? Color.STRIKETHROUGH : "");
|
String rbd = ((Integer.parseInt(data[8]) == 2 || Integer.parseInt(data[8]) == 3) ? Color.STRIKETHROUGH : "");
|
||||||
String timeago = Util.getTimeSince(Integer.parseInt(time), unixtimestamp, true);
|
String timeago = Util.getTimeSince(Integer.parseInt(time), unixtimestamp, true);
|
||||||
Material blockType = Util.itemFilter(Util.getType(Integer.parseInt(dtype)), (Integer.parseInt(data[13]) == 0));
|
Material blockType = Util.itemFilter(Util.getType(dtype), (Integer.parseInt(data[13]) == 0));
|
||||||
String dname = Util.nameFilter(blockType.name().toLowerCase(Locale.ROOT), ddata);
|
String dname = Util.nameFilter(blockType.name().toLowerCase(Locale.ROOT), ddata);
|
||||||
|
byte[] metadata = data[11] == null ? null : data[11].getBytes(StandardCharsets.ISO_8859_1);
|
||||||
|
String tooltip = Util.getEnchantments(metadata, dtype, amount);
|
||||||
|
|
||||||
String selector = Selector.FIRST;
|
String selector = Selector.FIRST;
|
||||||
String tag = Color.WHITE + "-";
|
String tag = Color.WHITE + "-";
|
||||||
@ -946,7 +944,7 @@ public class LookupCommand {
|
|||||||
tag = (daction == 0 ? Color.GREEN + "+" : Color.RED + "-");
|
tag = (daction == 0 ? Color.GREEN + "+" : Color.RED + "-");
|
||||||
}
|
}
|
||||||
|
|
||||||
Chat.sendComponent(player2, timeago + " " + tag + " " + Phrase.build(Phrase.LOOKUP_CONTAINER, Color.DARK_AQUA + rbd + dplayer + Color.WHITE + rbd, "x" + amount, Color.DARK_AQUA + rbd + dname + Color.WHITE, selector));
|
Chat.sendComponent(player2, timeago + " " + tag + " " + Phrase.build(Phrase.LOOKUP_CONTAINER, Color.DARK_AQUA + rbd + dplayer + Color.WHITE + rbd, "x" + amount, Util.createTooltip(Color.DARK_AQUA + rbd + dname, tooltip) + Color.WHITE, selector));
|
||||||
PluginChannelListener.getInstance().sendData(player2, Integer.parseInt(time), Phrase.LOOKUP_CONTAINER, selector, dplayer, dname, amount, x, y, z, wid, rbd, true, tag.contains("+"));
|
PluginChannelListener.getInstance().sendData(player2, Integer.parseInt(time), Phrase.LOOKUP_CONTAINER, selector, dplayer, dname, amount, x, y, z, wid, rbd, true, tag.contains("+"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -963,7 +961,7 @@ public class LookupCommand {
|
|||||||
int x = Integer.parseInt(data[2]);
|
int x = Integer.parseInt(data[2]);
|
||||||
int y = Integer.parseInt(data[3]);
|
int y = Integer.parseInt(data[3]);
|
||||||
int z = Integer.parseInt(data[4]);
|
int z = Integer.parseInt(data[4]);
|
||||||
String dtype = data[5];
|
int dtype = Integer.parseInt(data[5]);
|
||||||
int ddata = Integer.parseInt(data[6]);
|
int ddata = Integer.parseInt(data[6]);
|
||||||
int daction = Integer.parseInt(data[7]);
|
int daction = Integer.parseInt(data[7]);
|
||||||
int wid = Integer.parseInt(data[9]);
|
int wid = Integer.parseInt(data[9]);
|
||||||
@ -983,8 +981,7 @@ public class LookupCommand {
|
|||||||
String dname = "";
|
String dname = "";
|
||||||
boolean isPlayer = false;
|
boolean isPlayer = false;
|
||||||
if (daction == 3 && !finalArgAction.contains(11) && amount == -1) {
|
if (daction == 3 && !finalArgAction.contains(11) && amount == -1) {
|
||||||
int dTypeInt = Integer.parseInt(dtype);
|
if (dtype == 0) {
|
||||||
if (dTypeInt == 0) {
|
|
||||||
if (ConfigHandler.playerIdCacheReversed.get(ddata) == null) {
|
if (ConfigHandler.playerIdCacheReversed.get(ddata) == null) {
|
||||||
UserStatement.loadName(connection, ddata);
|
UserStatement.loadName(connection, ddata);
|
||||||
}
|
}
|
||||||
@ -992,11 +989,11 @@ public class LookupCommand {
|
|||||||
isPlayer = true;
|
isPlayer = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dname = Util.getEntityType(dTypeInt).name();
|
dname = Util.getEntityType(dtype).name();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dname = Util.getType(Integer.parseInt(dtype)).name().toLowerCase(Locale.ROOT);
|
dname = Util.getType(dtype).name().toLowerCase(Locale.ROOT);
|
||||||
dname = Util.nameFilter(dname, ddata);
|
dname = Util.nameFilter(dname, ddata);
|
||||||
}
|
}
|
||||||
if (dname.length() > 0 && !isPlayer) {
|
if (dname.length() > 0 && !isPlayer) {
|
||||||
@ -1015,6 +1012,9 @@ public class LookupCommand {
|
|||||||
String selector = Selector.FIRST;
|
String selector = Selector.FIRST;
|
||||||
String action = "a:block";
|
String action = "a:block";
|
||||||
if (finalArgAction.contains(4) || finalArgAction.contains(5) || finalArgAction.contains(11) || amount > -1) {
|
if (finalArgAction.contains(4) || finalArgAction.contains(5) || finalArgAction.contains(11) || amount > -1) {
|
||||||
|
byte[] metadata = data[11] == null ? null : data[11].getBytes(StandardCharsets.ISO_8859_1);
|
||||||
|
String tooltip = Util.getEnchantments(metadata, dtype, amount);
|
||||||
|
|
||||||
if (daction == 2 || daction == 3) {
|
if (daction == 2 || daction == 3) {
|
||||||
phrase = Phrase.LOOKUP_ITEM; // {picked up|dropped}
|
phrase = Phrase.LOOKUP_ITEM; // {picked up|dropped}
|
||||||
selector = (daction != 2 ? Selector.FIRST : Selector.SECOND);
|
selector = (daction != 2 ? Selector.FIRST : Selector.SECOND);
|
||||||
@ -1040,7 +1040,7 @@ public class LookupCommand {
|
|||||||
action = "a:container";
|
action = "a:container";
|
||||||
}
|
}
|
||||||
|
|
||||||
Chat.sendComponent(player2, timeago + " " + tag + " " + Phrase.build(phrase, Color.DARK_AQUA + rbd + dplayer + Color.WHITE + rbd, "x" + amount, Color.DARK_AQUA + rbd + dname + Color.WHITE, selector));
|
Chat.sendComponent(player2, timeago + " " + tag + " " + Phrase.build(phrase, Color.DARK_AQUA + rbd + dplayer + Color.WHITE + rbd, "x" + amount, Util.createTooltip(Color.DARK_AQUA + rbd + dname, tooltip) + Color.WHITE, selector));
|
||||||
PluginChannelListener.getInstance().sendData(player2, Integer.parseInt(time), phrase, selector, dplayer, dname, (tag.contains("+") ? 1 : -1), x, y, z, wid, rbd, action.contains("container"), tag.contains("+"));
|
PluginChannelListener.getInstance().sendData(player2, Integer.parseInt(time), phrase, selector, dplayer, dname, (tag.contains("+") ? 1 : -1), x, y, z, wid, rbd, action.contains("container"), tag.contains("+"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.coreprotect.database;
|
package net.coreprotect.database;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -65,6 +66,9 @@ public class Lookup extends Queue {
|
|||||||
else if (map[i] instanceof String) {
|
else if (map[i] instanceof String) {
|
||||||
results[newId] = (String) map[i];
|
results[newId] = (String) map[i];
|
||||||
}
|
}
|
||||||
|
else if (map[i] instanceof byte[]) {
|
||||||
|
results[newId] = new String((byte[]) map[i], StandardCharsets.ISO_8859_1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
@ -2,6 +2,8 @@ package net.coreprotect.database.lookup;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -18,8 +20,8 @@ import net.coreprotect.utility.Util;
|
|||||||
|
|
||||||
public class ChestTransactionLookup {
|
public class ChestTransactionLookup {
|
||||||
|
|
||||||
public static String performLookup(String command, Statement statement, Location l, CommandSender commandSender, int page, int limit, boolean exact) {
|
public static List<String> performLookup(String command, Statement statement, Location l, CommandSender commandSender, int page, int limit, boolean exact) {
|
||||||
String result = "";
|
List<String> result = new ArrayList<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (l == null) {
|
if (l == null) {
|
||||||
@ -67,13 +69,11 @@ public class ChestTransactionLookup {
|
|||||||
|
|
||||||
int totalPages = (int) Math.ceil(count / (limit + 0.0));
|
int totalPages = (int) Math.ceil(count / (limit + 0.0));
|
||||||
|
|
||||||
query = "SELECT time,user,action,type,data,amount,rolled_back FROM " + ConfigHandler.prefix + "container " + Util.getWidIndex("container") + "WHERE wid = '" + worldId + "' AND (x = '" + x + "' OR x = '" + x2 + "') AND (z = '" + z + "' OR z = '" + z2 + "') AND y = '" + y + "' ORDER BY rowid DESC LIMIT " + pageStart + ", " + limit + "";
|
query = "SELECT time,user,action,type,data,amount,metadata,rolled_back FROM " + ConfigHandler.prefix + "container " + Util.getWidIndex("container") + "WHERE wid = '" + worldId + "' AND (x = '" + x + "' OR x = '" + x2 + "') AND (z = '" + z + "' OR z = '" + z2 + "') AND y = '" + y + "' ORDER BY rowid DESC LIMIT " + pageStart + ", " + limit + "";
|
||||||
if (exact) {
|
if (exact) {
|
||||||
query = "SELECT time,user,action,type,data,amount,rolled_back FROM " + ConfigHandler.prefix + "container " + Util.getWidIndex("container") + "WHERE wid = '" + worldId + "' AND (x = '" + l.getBlockX() + "') AND (z = '" + l.getBlockZ() + "') AND y = '" + y + "' ORDER BY rowid DESC LIMIT " + pageStart + ", " + limit + "";
|
query = "SELECT time,user,action,type,data,amount,metadata,rolled_back FROM " + ConfigHandler.prefix + "container " + Util.getWidIndex("container") + "WHERE wid = '" + worldId + "' AND (x = '" + l.getBlockX() + "') AND (z = '" + l.getBlockZ() + "') AND y = '" + y + "' ORDER BY rowid DESC LIMIT " + pageStart + ", " + limit + "";
|
||||||
}
|
}
|
||||||
results = statement.executeQuery(query);
|
results = statement.executeQuery(query);
|
||||||
|
|
||||||
StringBuilder resultBuilder = new StringBuilder();
|
|
||||||
while (results.next()) {
|
while (results.next()) {
|
||||||
int resultUserId = results.getInt("user");
|
int resultUserId = results.getInt("user");
|
||||||
int resultAction = results.getInt("action");
|
int resultAction = results.getInt("action");
|
||||||
@ -82,6 +82,8 @@ public class ChestTransactionLookup {
|
|||||||
long resultTime = results.getLong("time");
|
long resultTime = results.getLong("time");
|
||||||
int resultAmount = results.getInt("amount");
|
int resultAmount = results.getInt("amount");
|
||||||
int resultRolledBack = results.getInt("rolled_back");
|
int resultRolledBack = results.getInt("rolled_back");
|
||||||
|
byte[] resultMetadata = results.getBytes("metadata");
|
||||||
|
String tooltip = Util.getEnchantments(resultMetadata, resultType, resultAmount);
|
||||||
|
|
||||||
if (ConfigHandler.playerIdCacheReversed.get(resultUserId) == null) {
|
if (ConfigHandler.playerIdCacheReversed.get(resultUserId) == null) {
|
||||||
UserStatement.loadName(statement.getConnection(), resultUserId);
|
UserStatement.loadName(statement.getConnection(), resultUserId);
|
||||||
@ -91,7 +93,7 @@ public class ChestTransactionLookup {
|
|||||||
String timeAgo = Util.getTimeSince(resultTime, time, true);
|
String timeAgo = Util.getTimeSince(resultTime, time, true);
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
resultBuilder = new StringBuilder(Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.CONTAINER_HEADER) + Color.WHITE + " ----- " + Util.getCoordinates(command, worldId, x, y, z, false, false) + "\n");
|
result.add(new StringBuilder(Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.CONTAINER_HEADER) + Color.WHITE + " ----- " + Util.getCoordinates(command, worldId, x, y, z, false, false)).toString());
|
||||||
}
|
}
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
@ -117,25 +119,23 @@ public class ChestTransactionLookup {
|
|||||||
target = target.split(":")[1];
|
target = target.split(":")[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
resultBuilder.append(timeAgo + " " + tag + " ").append(Phrase.build(Phrase.LOOKUP_CONTAINER, Color.DARK_AQUA + rbFormat + resultUser + Color.WHITE + rbFormat, "x" + resultAmount, Color.DARK_AQUA + rbFormat + target + Color.WHITE, selector)).append("\n");
|
result.add(new StringBuilder(timeAgo + " " + tag + " " + Phrase.build(Phrase.LOOKUP_CONTAINER, Color.DARK_AQUA + rbFormat + resultUser + Color.WHITE + rbFormat, "x" + resultAmount, Util.createTooltip(Color.DARK_AQUA + rbFormat + target, tooltip) + Color.WHITE, selector)).toString());
|
||||||
PluginChannelListener.getInstance().sendData(commandSender, resultTime, Phrase.LOOKUP_CONTAINER, selector, resultUser, target, resultAmount, x, y, z, worldId, rbFormat, true, tag.contains("+"));
|
PluginChannelListener.getInstance().sendData(commandSender, resultTime, Phrase.LOOKUP_CONTAINER, selector, resultUser, target, resultAmount, x, y, z, worldId, rbFormat, true, tag.contains("+"));
|
||||||
}
|
}
|
||||||
result = resultBuilder.toString();
|
|
||||||
results.close();
|
results.close();
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
if (count > limit) {
|
if (count > limit) {
|
||||||
String pageInfo = Color.WHITE + "-----\n";
|
result.add(Color.WHITE + "-----");
|
||||||
pageInfo = pageInfo + Util.getPageNavigation(command, page, totalPages) + "\n";
|
result.add(Util.getPageNavigation(command, page, totalPages));
|
||||||
result = result + pageInfo;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (rowMax > count && count > 0) {
|
if (rowMax > count && count > 0) {
|
||||||
result = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_RESULTS_PAGE, Selector.SECOND);
|
result.add(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_RESULTS_PAGE, Selector.SECOND));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_DATA_LOCATION, Selector.SECOND);
|
result.add(Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_DATA_LOCATION, Selector.SECOND));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,15 +60,9 @@ public final class ArmorStandManipulateListener extends Queue implements Listene
|
|||||||
try (Connection connection = Database.getConnection(true)) {
|
try (Connection connection = Database.getConnection(true)) {
|
||||||
if (connection != null) {
|
if (connection != null) {
|
||||||
Statement statement = connection.createStatement();
|
Statement statement = connection.createStatement();
|
||||||
String blockData = ChestTransactionLookup.performLookup(null, statement, location, finalPlayer, 1, 7, true);
|
List<String> blockData = ChestTransactionLookup.performLookup(null, statement, location, finalPlayer, 1, 7, true);
|
||||||
|
for (String data : blockData) {
|
||||||
if (blockData.contains("\n")) {
|
Chat.sendComponent(finalPlayer, data);
|
||||||
for (String b : blockData.split("\n")) {
|
|
||||||
Chat.sendComponent(finalPlayer, b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Chat.sendComponent(finalPlayer, blockData);
|
|
||||||
}
|
}
|
||||||
statement.close();
|
statement.close();
|
||||||
}
|
}
|
||||||
|
@ -304,15 +304,9 @@ public final class PlayerInteractListener extends Queue implements Listener {
|
|||||||
try (Connection connection = Database.getConnection(true)) {
|
try (Connection connection = Database.getConnection(true)) {
|
||||||
if (connection != null) {
|
if (connection != null) {
|
||||||
Statement statement = connection.createStatement();
|
Statement statement = connection.createStatement();
|
||||||
String blockData = ChestTransactionLookup.performLookup(null, statement, finalLocation, player, 1, 7, false);
|
List<String> blockData = ChestTransactionLookup.performLookup(null, statement, finalLocation, player, 1, 7, false);
|
||||||
|
for (String data : blockData) {
|
||||||
if (blockData.contains("\n")) {
|
Chat.sendComponent(player, data);
|
||||||
for (String splitData : blockData.split("\n")) {
|
|
||||||
Chat.sendComponent(player, splitData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Chat.sendComponent(player, blockData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
statement.close();
|
statement.close();
|
||||||
|
@ -266,6 +266,51 @@ public class Util extends Queue {
|
|||||||
return message.toString();
|
return message.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getEnchantments(byte[] metadata, int type, int amount) {
|
||||||
|
if (metadata == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack item = new ItemStack(Util.getType(type), amount);
|
||||||
|
item = (ItemStack) Rollback.populateItemStack(item, metadata)[2];
|
||||||
|
String displayName = item.hasItemMeta() && item.getItemMeta().hasDisplayName() ? item.getItemMeta().getDisplayName() : "";
|
||||||
|
StringBuilder message = new StringBuilder(Color.ITALIC + displayName + Color.GREY);
|
||||||
|
|
||||||
|
List<String> enchantments = ItemMetaHandler.getEnchantments(item, displayName);
|
||||||
|
for (String enchantment : enchantments) {
|
||||||
|
if (message.length() > 0) {
|
||||||
|
message.append("\n");
|
||||||
|
}
|
||||||
|
message.append(enchantment);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!displayName.isEmpty()) {
|
||||||
|
message.insert(0, enchantments.isEmpty() ? Color.WHITE : Color.AQUA);
|
||||||
|
}
|
||||||
|
else if (!enchantments.isEmpty()) {
|
||||||
|
String name = Util.capitalize(item.getType().name().replace("_", " "), true);
|
||||||
|
message.insert(0, Color.AQUA + Color.ITALIC + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return message.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String createTooltip(String phrase, String tooltip) {
|
||||||
|
if (tooltip.isEmpty()) {
|
||||||
|
return phrase;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder message = new StringBuilder(Chat.COMPONENT_TAG_OPEN + Chat.COMPONENT_POPUP);
|
||||||
|
|
||||||
|
// tooltip
|
||||||
|
message.append("|" + tooltip + "|");
|
||||||
|
|
||||||
|
// chat output
|
||||||
|
message.append(phrase);
|
||||||
|
|
||||||
|
return message.append(Chat.COMPONENT_TAG_CLOSE).toString();
|
||||||
|
}
|
||||||
|
|
||||||
public static String hoverCommandFilter(String string) {
|
public static String hoverCommandFilter(String string) {
|
||||||
StringBuilder command = new StringBuilder();
|
StringBuilder command = new StringBuilder();
|
||||||
|
|
||||||
|
@ -93,21 +93,18 @@ public class ItemMetaHandler {
|
|||||||
return itemMeta.getEnchants();
|
return itemMeta.getEnchants();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getEnchantments(ItemStack item) {
|
public static List<String> getEnchantments(ItemStack item, String displayName) {
|
||||||
StringBuilder result = new StringBuilder();
|
List<String> result = new ArrayList<>();
|
||||||
Map<Enchantment, Integer> enchantments = getEnchantments(item.getItemMeta());
|
Map<Enchantment, Integer> enchantments = getEnchantments(item.getItemMeta());
|
||||||
|
|
||||||
for (Entry<Enchantment, Integer> entry : enchantments.entrySet()) {
|
for (Entry<Enchantment, Integer> entry : enchantments.entrySet()) {
|
||||||
Enchantment enchantment = entry.getKey();
|
Enchantment enchantment = entry.getKey();
|
||||||
Integer level = entry.getValue();
|
Integer level = entry.getValue();
|
||||||
|
|
||||||
if (result.length() > 0) {
|
result.add(getEnchantmentName(enchantment, level));
|
||||||
result.append("\n");
|
|
||||||
}
|
|
||||||
result.append(getEnchantmentName(enchantment, level));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.toString();
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<List<Map<String, Object>>> seralize(ItemStack item, Material type, String faceData, int slot) {
|
public static List<List<Map<String, Object>>> seralize(ItemStack item, Material type, String faceData, int slot) {
|
||||||
|
Loading…
Reference in New Issue
Block a user