mirror of
https://github.com/songoda/UltimateModeration.git
synced 2024-11-13 22:05:17 +01:00
Title formatting.
This commit is contained in:
parent
92a987d2df
commit
7d8b0dcaf4
@ -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 "";
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user