Implement new core changes

This commit is contained in:
ceze88 2024-07-25 14:45:14 +02:00
parent d9e5b4fd8a
commit 4e00c88e39
15 changed files with 63 additions and 64 deletions

View File

@ -31,17 +31,17 @@ public class Level {
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()
@ -52,8 +52,8 @@ public class Level {
getPlugin()
.getLocale()
.getMessage("general.word.enabled")
.getMessage())
.getMessage());
.toText())
.toText());
}
for (Module module : this.registeredModules) {

View File

@ -80,7 +80,7 @@ public class Methods {
String name = getPlugin().getLocale()
.getMessage("general.nametag.nameformat")
.processPlaceholder("level", level)
.getMessage();
.toText();
return TextUtils.formatText(name);

View File

@ -235,7 +235,7 @@ public class EpicHoppers extends SongodaPlugin {
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")));
}

View File

@ -72,7 +72,7 @@ public class GUIAutoSellFilter extends CustomizableGui {
// 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};
@ -92,7 +92,7 @@ public class GUIAutoSellFilter extends CustomizableGui {
// 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};
@ -113,12 +113,12 @@ public class GUIAutoSellFilter extends CustomizableGui {
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) {

View File

@ -64,7 +64,7 @@ public class GUIFilter extends CustomizableGui {
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(),
@ -93,7 +93,7 @@ public class GUIFilter extends CustomizableGui {
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};
@ -114,7 +114,7 @@ public class GUIFilter extends CustomizableGui {
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};
@ -134,9 +134,9 @@ public class GUIFilter extends CustomizableGui {
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));
}
@ -148,11 +148,11 @@ public class GUIFilter extends CustomizableGui {
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));
}

View File

@ -79,7 +79,7 @@ public class GUIOverview extends CustomizableGui {
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(
@ -88,7 +88,7 @@ public class GUIOverview extends CustomizableGui {
? this.plugin.getLocale().getMessage("general.word.disabled").getMessage()
: this.hopper.getTeleportTrigger().name()
)
.getMessage()
.toText()
.split("\\|");
for (String line : parts) {
lorePearl.add(TextUtils.formatText(line));
@ -98,9 +98,9 @@ public class GUIOverview extends CustomizableGui {
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));
}
@ -110,14 +110,14 @@ public class GUIOverview extends CustomizableGui {
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());
}
}
@ -127,7 +127,7 @@ public class GUIOverview extends CustomizableGui {
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));
@ -139,11 +139,11 @@ public class GUIOverview extends CustomizableGui {
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));
}

View File

@ -117,7 +117,7 @@ public class GUISmeltable extends CustomizableGui {
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;

View File

@ -192,10 +192,10 @@ public class ModuleAutoCrafting extends Module {
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));
}
@ -223,8 +223,8 @@ public class ModuleAutoCrafting extends Module {
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

View File

@ -147,13 +147,13 @@ public class ModuleAutoSell extends Module {
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) {
@ -192,7 +192,7 @@ public class ModuleAutoSell extends Module {
return this.plugin.getLocale()
.getMessage("interface.hopper.autosell")
.processPlaceholder("seconds", (int) Math.floor(this.timeOut / 20))
.getMessage();
.toText();
}
@Override

View File

@ -92,7 +92,7 @@ public class ModuleAutoSmelter extends Module {
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))
@ -100,7 +100,7 @@ public class ModuleAutoSmelter extends Module {
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));
@ -138,7 +138,7 @@ public class ModuleAutoSmelter extends Module {
@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) {

View File

@ -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;
@ -127,22 +128,20 @@ public class ModuleBlockBreak extends Module {
@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;
}
@ -159,7 +158,7 @@ public class ModuleBlockBreak extends Module {
@Override
public String getDescription() {
return this.plugin.getLocale().getMessage("interface.hopper.blockbreak")
.processPlaceholder("ticks", this.ticksPerBreak).getMessage();
.processPlaceholder("ticks", this.ticksPerBreak).toText();
}
@Override

View File

@ -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.gui.GuiManager;
import com.craftaro.core.utils.TextUtils;
import com.craftaro.epichoppers.hopper.Hopper;
@ -67,17 +68,15 @@ public class ModuleMobHopper extends Module {
@Override
public ItemStack getGUIButton(Hopper hopper) {
ItemStack block = new ItemStack(Material.ROTTEN_FLESH, 1);
ItemMeta blockMeta = block.getItemMeta();
blockMeta.setDisplayName(this.plugin.getLocale().getMessage("interface.hopper.mobtitle").getMessage());
AdventureUtils.formatItemName(block, this.plugin.getLocale().getMessage("interface.hopper.mobtitle").getMessage());
ArrayList<String> loreBlock = new ArrayList<>();
String[] parts = this.plugin.getLocale().getMessage("interface.hopper.moblore").processPlaceholder("enabled",
isEnabled(hopper) ? this.plugin.getLocale().getMessage("general.word.enabled").getMessage()
: this.plugin.getLocale().getMessage("general.word.disabled").getMessage()).getMessage().split("\\|");
isEnabled(hopper) ? this.plugin.getLocale().getMessage("general.word.enabled").toText()
: this.plugin.getLocale().getMessage("general.word.disabled").getMessage()).toText().split("\\|");
for (String line : parts) {
loreBlock.add(TextUtils.formatText(line));
}
blockMeta.setLore(loreBlock);
block.setItemMeta(blockMeta);
AdventureUtils.formatItemLore(block, loreBlock);
return block;
}
@ -96,7 +95,7 @@ public class ModuleMobHopper extends Module {
return this.plugin.getLocale()
.getMessage("interface.hopper.mobhopper")
.processPlaceholder("ticks", this.amount)
.getMessage();
.toText();
}
public boolean isEnabled(Hopper hopper) {

View File

@ -191,11 +191,11 @@ public class ModuleSuction extends Module {
Locale locale = this.plugin.getLocale();
ItemStack item = XMaterial.CAULDRON.parseItem();
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(locale.getMessage("interface.hopper.suctiontitle").getMessage());
meta.setDisplayName(locale.getMessage("interface.hopper.suctiontitle").toText());
List<String> lore = new ArrayList<>();
String[] parts = locale.getMessage("interface.hopper.suctionlore")
.processPlaceholder("status", isEnabled(hopper) ? locale.getMessage("general.word.enabled").getMessage() : locale.getMessage("general.word.disabled").getMessage())
.processPlaceholder("radius", getRadius(hopper)).getMessage().split("\\|");
.processPlaceholder("status", isEnabled(hopper) ? locale.getMessage("general.word.enabled").toText() : locale.getMessage("general.word.disabled").toText())
.processPlaceholder("radius", getRadius(hopper)).toText().split("\\|");
for (String line : parts) {
lore.add(TextUtils.formatText(line));
}
@ -247,6 +247,6 @@ public class ModuleSuction extends Module {
return this.plugin.getLocale()
.getMessage("interface.hopper.suction")
.processPlaceholder("suction", this.maxSearchRadius)
.getMessage();
.toText();
}
}

View File

@ -52,7 +52,7 @@ public class BlockListeners implements Listener {
int max = maxHoppers(player);
if (max != -1 && amt > max) {
player.sendMessage(this.plugin.getLocale().getMessage("event.hopper.toomany").processPlaceholder("amount", max).getMessage());
player.sendMessage(this.plugin.getLocale().getMessage("event.hopper.toomany").processPlaceholder("amount", max).toText());
e.setCancelled(true);
return;
}
@ -64,7 +64,7 @@ public class BlockListeners implements Listener {
}
if (!this.plugin.getHopperManager().isReady()) {
player.sendMessage(this.plugin.getLocale().getMessage("event.hopper.notready").getMessage());
player.sendMessage(this.plugin.getLocale().getMessage("event.hopper.notready").toText());
e.setCancelled(true);
return;
}
@ -121,7 +121,7 @@ public class BlockListeners implements Listener {
}
if (!this.plugin.getHopperManager().isReady()) {
player.sendMessage(this.plugin.getLocale().getMessage("event.hopper.notready").getMessage());
player.sendMessage(this.plugin.getLocale().getMessage("event.hopper.notready").toText());
event.setCancelled(true);
return;
}

View File

@ -1,5 +1,6 @@
package com.craftaro.epichoppers.listeners;
import com.craftaro.core.chat.AdventureUtils;
import com.craftaro.core.hooks.ProtectionManager;
import com.craftaro.core.hooks.WorldGuardHook;
import com.craftaro.epichoppers.hopper.Hopper;
@ -63,7 +64,7 @@ public class InteractListeners implements Listener {
}
if (Settings.USE_PROTECTION_PLUGINS.getBoolean() && ProtectionManager.canInteract(player, event.getClickedBlock().getLocation()) && WorldGuardHook.isInteractAllowed(event.getClickedBlock().getLocation())) {
player.sendMessage(this.plugin.getLocale().getMessage("event.general.protected").getPrefixedMessage());
AdventureUtils.sendMessage(this.plugin, this.plugin.getLocale().getMessage("event.general.protected").getPrefixedMessage());
return;
}
@ -81,7 +82,7 @@ public class InteractListeners implements Listener {
if (playerData.getSyncType() == null) {
if (event.getClickedBlock().getType() == Material.HOPPER) {
if (!this.plugin.getHopperManager().isReady()) {
player.sendMessage(this.plugin.getLocale().getMessage("event.hopper.notready").getMessage());
AdventureUtils.sendMessage(this.plugin, this.plugin.getLocale().getMessage("event.hopper.notready").getPrefixedMessage());
event.setCancelled(true);
return;
}