Title formatting.

This commit is contained in:
Brianna 2019-05-03 19:40:34 -04:00
parent 92a987d2df
commit 7d8b0dcaf4
2 changed files with 21 additions and 3 deletions

View File

@ -59,6 +59,17 @@ public class Methods {
return ChatColor.translateAlternateColorCodes('&', text);
}
public static String formatTitle(String text) {
if (text == null || text.equals(""))
return "";
if (!UltimateModeration.getInstance().isServerVersionAtLeast(ServerVersion.V1_9)) {
if (text.length() > 31)
text = text.substring(0, 29) + "...";
}
text = formatText(text);
return text;
}
public static String makeReadable(Long time) {
if (time == null)
return "";

View File

@ -100,6 +100,7 @@ public abstract class AbstractGUI implements Listener {
for (OnClose onClose : gui.onCloses) {
onClose.OnClose((Player) event.getPlayer(), inventory);
}
gui.destory();
}
private AbstractGUI getGUIFromInventory(Inventory inventory) {
@ -116,9 +117,9 @@ public abstract class AbstractGUI implements Listener {
public void init(String title, int slots) {
if (inventory == null
|| inventory.getSize() != slots
|| ChatColor.translateAlternateColorCodes('&', title) != player.getOpenInventory().getTitle()) {
this.inventory = Bukkit.getServer().createInventory(new GUIHolder(), slots, Methods.formatText(title));
this.setTitle = Methods.formatText(title);
|| Methods.formatTitle(title) != player.getOpenInventory().getTitle()) {
this.inventory = Bukkit.getServer().createInventory(new GUIHolder(), slots, Methods.formatTitle(title));
this.setTitle = Methods.formatTitle(title);
if (this.clickables.size() == 0)
registerClickables();
if (this.onCloses.size() == 0)
@ -129,6 +130,12 @@ public abstract class AbstractGUI implements Listener {
player.openInventory(inventory);
}
private void destory() {
onCloses.clear();
clickables.clear();
draggableRanges.clear();
}
protected abstract void constructGUI();
protected void addDraggable(Range range, boolean option) {