Skip to content

Commit

Permalink
Implement new core changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ceze88 committed Jul 25, 2024
1 parent d9e5b4f commit 4e00c88
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ public void buildDescription() {
this.description.clear();

this.description.add(getPlugin().getLocale().getMessage("interface.hopper.range")
.processPlaceholder("range", this.range).getMessage());
.processPlaceholder("range", this.range).toText());
this.description.add(getPlugin().getLocale().getMessage("interface.hopper.amount")
.processPlaceholder("amount", this.amount).getMessage());
.processPlaceholder("amount", this.amount).toText());
if (this.linkAmount != 1) {
this.description.add(getPlugin().getLocale().getMessage("interface.hopper.linkamount")
.processPlaceholder("amount", this.linkAmount).getMessage());
.processPlaceholder("amount", this.linkAmount).toText());
}
if (this.filter) {
this.description.add(getPlugin().getLocale().getMessage("interface.hopper.filter")
.processPlaceholder("enabled", getPlugin().getLocale()
.getMessage("general.word.enabled").getMessage()).getMessage());
.getMessage("general.word.enabled").getMessage()).toText());
}
if (this.teleport) {
this.description.add(getPlugin()
Expand All @@ -52,8 +52,8 @@ public void buildDescription() {
getPlugin()
.getLocale()
.getMessage("general.word.enabled")
.getMessage())
.getMessage());
.toText())
.toText());
}

for (Module module : this.registeredModules) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static String formatName(int level) {
String name = getPlugin().getLocale()
.getMessage("general.nametag.nameformat")
.processPlaceholder("level", level)
.getMessage();
.toText();


return TextUtils.formatText(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public ItemStack newHopperItem(Level level) {
ItemStack item = XMaterial.HOPPER.parseItem();
ItemMeta itemmeta = item.getItemMeta();
itemmeta.setDisplayName(TextUtils.formatText(Methods.formatName(level.getLevel())));
String line = getLocale().getMessage("general.nametag.lore").getMessage();
String line = getLocale().getMessage("general.nametag.lore").toText();
if (!line.isEmpty()) {
itemmeta.setLore(Arrays.asList(line.split("\n")));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public GUIAutoSellFilter(SongodaPlugin plugin, Hopper hopper) {
// Whitelist
ItemStack indicatorItem = XMaterial.WHITE_STAINED_GLASS_PANE.parseItem();
ItemMeta indicatorMeta = indicatorItem.getItemMeta();
indicatorMeta.setDisplayName(plugin.getLocale().getMessage("interface.autosell-filter.whitelist").getMessage());
indicatorMeta.setDisplayName(plugin.getLocale().getMessage("interface.autosell-filter.whitelist").toText());
indicatorItem.setItemMeta(indicatorMeta);

int[] whiteSlots = {0, 1, 2, 45, 46, 47};
Expand All @@ -92,7 +92,7 @@ public GUIAutoSellFilter(SongodaPlugin plugin, Hopper hopper) {
// Blacklist
indicatorItem = XMaterial.BLACK_STAINED_GLASS_PANE.parseItem();
indicatorMeta = indicatorItem.getItemMeta();
indicatorMeta.setDisplayName(plugin.getLocale().getMessage("interface.autosell-filter.blacklist").getMessage());
indicatorMeta.setDisplayName(plugin.getLocale().getMessage("interface.autosell-filter.blacklist").toText());
indicatorItem.setItemMeta(indicatorMeta);

int[] blackSlots = {3, 4, 5, 48, 49, 50};
Expand All @@ -113,12 +113,12 @@ public GUIAutoSellFilter(SongodaPlugin plugin, Hopper hopper) {
indicatorItem = XMaterial.PAPER.parseItem();
indicatorMeta = indicatorItem.getItemMeta();

indicatorMeta.setDisplayName(plugin.getLocale().getMessage("interface.autosell-filter.infotitle").getMessage());
indicatorMeta.setDisplayName(plugin.getLocale().getMessage("interface.autosell-filter.infotitle").toText());
ArrayList<String> loreInfo = new ArrayList<>();
String[] parts = plugin
.getLocale()
.getMessage("interface.autosell-filter.infolore")
.getMessage()
.toText()
.split("\\|");

for (String line : parts) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public GUIFilter(SongodaPlugin plugin, Hopper hopper, Player player) {

ItemStack it = XMaterial.WHITE_STAINED_GLASS_PANE.parseItem();
ItemMeta itm = it.getItemMeta();
itm.setDisplayName(plugin.getLocale().getMessage("interface.filter.whitelist").getMessage());
itm.setDisplayName(plugin.getLocale().getMessage("interface.filter.whitelist").toText());
it.setItemMeta(itm);

setButton("back", 8, GuiUtils.createButtonItem(XMaterial.ARROW.parseItem(),
Expand Down Expand Up @@ -93,7 +93,7 @@ public GUIFilter(SongodaPlugin plugin, Hopper hopper, Player player) {

it = XMaterial.BLACK_STAINED_GLASS_PANE.parseItem();
itm = it.getItemMeta();
itm.setDisplayName(plugin.getLocale().getMessage("interface.filter.blacklist").getMessage());
itm.setDisplayName(plugin.getLocale().getMessage("interface.filter.blacklist").toText());
it.setItemMeta(itm);

int[] blackSlots = {2, 3, 47, 48};
Expand All @@ -114,7 +114,7 @@ public GUIFilter(SongodaPlugin plugin, Hopper hopper, Player player) {

it = XMaterial.BARRIER.parseItem();
itm = it.getItemMeta();
itm.setDisplayName(plugin.getLocale().getMessage("interface.filter.void").getMessage());
itm.setDisplayName(plugin.getLocale().getMessage("interface.filter.void").toText());
it.setItemMeta(itm);

int[] avoid = {4, 5, 49, 50};
Expand All @@ -134,9 +134,9 @@ public GUIFilter(SongodaPlugin plugin, Hopper hopper, Player player) {

ItemStack itemInfo = XMaterial.PAPER.parseItem();
ItemMeta itemMetaInfo = itemInfo.getItemMeta();
itemMetaInfo.setDisplayName(plugin.getLocale().getMessage("interface.filter.infotitle").getMessage());
itemMetaInfo.setDisplayName(plugin.getLocale().getMessage("interface.filter.infotitle").toText());
ArrayList<String> loreInfo = new ArrayList<>();
String[] parts = plugin.getLocale().getMessage("interface.filter.infolore").getMessage().split("\\|");
String[] parts = plugin.getLocale().getMessage("interface.filter.infolore").toText().split("\\|");
for (String line : parts) {
loreInfo.add(TextUtils.formatText(line));
}
Expand All @@ -148,11 +148,11 @@ public GUIFilter(SongodaPlugin plugin, Hopper hopper, Player player) {

ItemStack hook = XMaterial.TRIPWIRE_HOOK.parseItem();
ItemMeta hookMeta = hook.getItemMeta();
hookMeta.setDisplayName(plugin.getLocale().getMessage("interface.hopper.rejectsync").getMessage());
hookMeta.setDisplayName(plugin.getLocale().getMessage("interface.hopper.rejectsync").toText());
ArrayList<String> loreHook = new ArrayList<>();
parts = plugin.getLocale().getMessage("interface.hopper.synclore")
.processPlaceholder("amount", filter.getEndPoint() != null ? 1 : 0)
.getMessage().split("\\|");
.toText().split("\\|");
for (String line : parts) {
loreHook.add(TextUtils.formatText(line));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void constructGUI() {

ItemStack pearl = new ItemStack(Material.ENDER_PEARL, 1);
ItemMeta pearlMeta = pearl.getItemMeta();
pearlMeta.setDisplayName(this.plugin.getLocale().getMessage("interface.hopper.perltitle").getMessage());
pearlMeta.setDisplayName(this.plugin.getLocale().getMessage("interface.hopper.perltitle").toText());
ArrayList<String> lorePearl = new ArrayList<>();
String[] parts = this.plugin.getLocale().getMessage("interface.hopper.perllore2")
.processPlaceholder(
Expand All @@ -88,7 +88,7 @@ private void constructGUI() {
? this.plugin.getLocale().getMessage("general.word.disabled").getMessage()
: this.hopper.getTeleportTrigger().name()
)
.getMessage()
.toText()
.split("\\|");
for (String line : parts) {
lorePearl.add(TextUtils.formatText(line));
Expand All @@ -98,9 +98,9 @@ private void constructGUI() {

ItemStack filter = new ItemStack(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.COMPARATOR : Material.valueOf("REDSTONE_COMPARATOR"), 1);
ItemMeta filterMeta = filter.getItemMeta();
filterMeta.setDisplayName(this.plugin.getLocale().getMessage("interface.hopper.filtertitle").getMessage());
filterMeta.setDisplayName(this.plugin.getLocale().getMessage("interface.hopper.filtertitle").toText());
ArrayList<String> loreFilter = new ArrayList<>();
parts = this.plugin.getLocale().getMessage("interface.hopper.filterlore").getMessage().split("\\|");
parts = this.plugin.getLocale().getMessage("interface.hopper.filterlore").toText().split("\\|");
for (String line : parts) {
loreFilter.add(TextUtils.formatText(line));
}
Expand All @@ -110,14 +110,14 @@ private void constructGUI() {

ItemStack item = new ItemStack(Material.HOPPER, 1);
ItemMeta itemmeta = item.getItemMeta();
itemmeta.setDisplayName(this.plugin.getLocale().getMessage("interface.hopper.currentlevel").processPlaceholder("level", level.getLevel()).getMessage());
itemmeta.setDisplayName(this.plugin.getLocale().getMessage("interface.hopper.currentlevel").processPlaceholder("level", level.getLevel()).toText());
List<String> lore = level.getDescription();
if (this.plugin.getConfig().getBoolean("Main.Allow hopper Upgrading")) {
lore.add("");
if (nextLevel == null) {
lore.add(this.plugin.getLocale().getMessage("interface.hopper.alreadymaxed").getMessage());
lore.add(this.plugin.getLocale().getMessage("interface.hopper.alreadymaxed").toText());
} else {
lore.add(this.plugin.getLocale().getMessage("interface.hopper.nextlevel").processPlaceholder("level", nextLevel.getLevel()).getMessage());
lore.add(this.plugin.getLocale().getMessage("interface.hopper.nextlevel").processPlaceholder("level", nextLevel.getLevel()).toText());
lore.addAll(nextLevel.getDescription());
}
}
Expand All @@ -127,7 +127,7 @@ private void constructGUI() {
parts = this.plugin.getLocale().getMessage("interface.hopper.boostedstats")
.processPlaceholder("amount", Integer.toString(boostData.getMultiplier()))
.processPlaceholder("time", TimeUtils.makeReadable(boostData.getEndTime() - System.currentTimeMillis()))
.getMessage().split("\\|");
.toText().split("\\|");
lore.add("");
for (String line : parts) {
lore.add(TextUtils.formatText(line));
Expand All @@ -139,11 +139,11 @@ private void constructGUI() {

ItemStack hook = new ItemStack(Material.TRIPWIRE_HOOK, 1);
ItemMeta hookMeta = hook.getItemMeta();
hookMeta.setDisplayName(this.plugin.getLocale().getMessage("interface.hopper.synchopper").getMessage());
hookMeta.setDisplayName(this.plugin.getLocale().getMessage("interface.hopper.synchopper").toText());
ArrayList<String> loreHook = new ArrayList<>();
parts = this.plugin.getLocale().getMessage("interface.hopper.synclore")
.processPlaceholder("amount", this.hopper.getLinkedBlocks().stream().distinct().count())
.getMessage().split("\\|");
.toText().split("\\|");
for (String line : parts) {
loreHook.add(TextUtils.formatText(line));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public ItemStack getItemStack(XMaterial material, boolean enabled) {
meta.setLore(Arrays.asList(TextUtils.formatText(" &7-> &e" + CompatibleMaterial.getFurnaceResult(material).getType().name()),
TextUtils.formatText("&7Enabled: &6" + String.valueOf(enabled).toLowerCase() + "&7."),
"",
this.plugin.getLocale().getMessage("interface.hopper.toggle").getMessage()));
this.plugin.getLocale().getMessage("interface.hopper.toggle").toText()));
item.setItemMeta(meta);

return item;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ public ItemStack getGUIButton(Hopper hopper) {
ItemStack crafting = XMaterial.CRAFTING_TABLE.parseItem();
ItemMeta craftingMeta = crafting.getItemMeta();
craftingMeta.setDisplayName(this.plugin.getLocale().getMessage("interface.hopper.craftingtitle")
.getMessage());
.toText());
ArrayList<String> lorecrafting = new ArrayList<>();
String[] parts = this.plugin.getLocale().getMessage("interface.hopper.craftinglore")
.getMessage().split("\\|");
.toText().split("\\|");
for (String line : parts) {
lorecrafting.add(TextUtils.formatText(line));
}
Expand Down Expand Up @@ -223,8 +223,8 @@ public List<Material> getBlockedItems(Hopper hopper) {
public String getDescription() {
return this.plugin.getLocale()
.getMessage("interface.hopper.crafting")
.processPlaceholder("enabled", this.plugin.getLocale().getMessage("general.word.enabled").getMessage())
.getMessage();
.processPlaceholder("enabled", this.plugin.getLocale().getMessage("general.word.enabled").toText())
.toText();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ public ItemStack getGUIButton(Hopper hopper) {
ItemStack sellItem = XMaterial.SUNFLOWER.parseItem();
ItemMeta sellMeta = sellItem.getItemMeta();

sellMeta.setDisplayName(this.plugin.getLocale().getMessage("interface.hopper.selltitle").getMessage());
sellMeta.setDisplayName(this.plugin.getLocale().getMessage("interface.hopper.selltitle").toText());
ArrayList<String> loreSell = new ArrayList<>();

String[] parts = this.plugin.getLocale().getMessage("interface.hopper.selllore")
.processPlaceholder("timeleft", getTime(hopper) == -9999 ? "∞" : (int) Math.floor(getTime(hopper) / 20))
.processPlaceholder("state", isNotifying(hopper))
.getMessage()
.toText()
.split("\\|");

for (String line : parts) {
Expand Down Expand Up @@ -192,7 +192,7 @@ public String getDescription() {
return this.plugin.getLocale()
.getMessage("interface.hopper.autosell")
.processPlaceholder("seconds", (int) Math.floor(this.timeOut / 20))
.getMessage();
.toText();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ public void run(Hopper hopper, StorageContainerCache.Cache hopperCache) {
public ItemStack getGUIButton(Hopper hopper) {
ItemStack block = XMaterial.IRON_INGOT.parseItem();
ItemMeta blockMeta = block.getItemMeta();
blockMeta.setDisplayName(this.plugin.getLocale().getMessage("interface.hopper.smelttitle").getMessage());
blockMeta.setDisplayName(this.plugin.getLocale().getMessage("interface.hopper.smelttitle").toText());
ArrayList<String> loreBlock = new ArrayList<>();
String[] parts = this.plugin.getLocale().getMessage("interface.hopper.smeltlore")
.processPlaceholder("timeleft", getTime(hopper) == -9999 ? "∞" : (int) Math.floor(getTime(hopper) / 20.0))
.processPlaceholder("enabled", isEnabled(hopper) ?
this.plugin.getLocale().getMessage("general.word.enabled").getMessage() :
this.plugin.getLocale().getMessage("general.word.disabled").getMessage()
)
.getMessage()
.toText()
.split("\\|");
for (String line : parts) {
loreBlock.add(TextUtils.formatText(line));
Expand Down Expand Up @@ -138,7 +138,7 @@ public List<Material> getBlockedItems(Hopper hopper) {
@Override
public String getDescription() {
return this.plugin.getLocale().getMessage("interface.hopper.autosmelt")
.processPlaceholder("ticks", (int) Math.floor(this.timeOut / 20.0)).getMessage();
.processPlaceholder("ticks", (int) Math.floor(this.timeOut / 20.0)).toText();
}

private int getTime(Hopper hopper) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.craftaro.epichoppers.hopper.levels.modules;

import com.craftaro.core.SongodaPlugin;
import com.craftaro.core.chat.AdventureUtils;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.core.gui.GuiManager;
import com.craftaro.core.utils.TextUtils;
Expand Down Expand Up @@ -127,22 +128,20 @@ public void run(Hopper hopper, StorageContainerCache.Cache hopperCache) {
@Override
public ItemStack getGUIButton(Hopper hopper) {
ItemStack block = new ItemStack(Material.IRON_ORE, 1);
ItemMeta blockMeta = block.getItemMeta();
blockMeta.setDisplayName(this.plugin.getLocale().getMessage("interface.hopper.blocktitle").getMessage());
AdventureUtils.formatItemName(block, this.plugin.getLocale().getMessage("interface.hopper.blocktitle").getMessage());
ArrayList<String> loreBlock = new ArrayList<>();
String[] parts = this.plugin.getLocale()
.getMessage("interface.hopper.blocklore")
.processPlaceholder("enabled", isEnabled(hopper)
? this.plugin.getLocale().getMessage("general.word.enabled").getMessage()
: this.plugin.getLocale().getMessage("general.word.disabled").getMessage()
? this.plugin.getLocale().getMessage("general.word.enabled").toText()
: this.plugin.getLocale().getMessage("general.word.disabled").toText()
)
.getMessage()
.toText()
.split("\\|");
for (String line : parts) {
loreBlock.add(TextUtils.formatText(line));
}
blockMeta.setLore(loreBlock);
block.setItemMeta(blockMeta);
AdventureUtils.formatItemLore(block, loreBlock);
return block;
}

Expand All @@ -159,7 +158,7 @@ public List<Material> getBlockedItems(Hopper hopper) {
@Override
public String getDescription() {
return this.plugin.getLocale().getMessage("interface.hopper.blockbreak")
.processPlaceholder("ticks", this.ticksPerBreak).getMessage();
.processPlaceholder("ticks", this.ticksPerBreak).toText();
}

@Override
Expand Down
Loading

0 comments on commit 4e00c88

Please sign in to comment.