mirror of
https://github.com/songoda/EpicHoppers.git
synced 2024-11-22 10:15:43 +01:00
General code cleanup.
This commit is contained in:
parent
01dc7c13d2
commit
c9cd0d9eee
@ -13,6 +13,7 @@ import com.songoda.core.hooks.EconomyManager;
|
||||
import com.songoda.core.locale.Locale;
|
||||
import com.songoda.core.nms.NmsManager;
|
||||
import com.songoda.core.nms.nbt.NBTItem;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epichoppers.boost.BoostManager;
|
||||
import com.songoda.epichoppers.commands.CommandBoost;
|
||||
import com.songoda.epichoppers.commands.CommandGive;
|
||||
@ -239,7 +240,7 @@ public class EpicHoppers extends SongodaPlugin {
|
||||
public ItemStack newHopperItem(Level level) {
|
||||
ItemStack item = new ItemStack(Material.HOPPER, 1);
|
||||
ItemMeta itemmeta = item.getItemMeta();
|
||||
itemmeta.setDisplayName(Methods.formatText(Methods.formatName(level.getLevel())));
|
||||
itemmeta.setDisplayName(TextUtils.formatText(Methods.formatName(level.getLevel())));
|
||||
String line = getLocale().getMessage("general.nametag.lore").getMessage();
|
||||
if (!line.equals("")) {
|
||||
itemmeta.setLore(Arrays.asList(line.split("\n")));
|
||||
|
@ -3,6 +3,7 @@ package com.songoda.epichoppers.gui;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.hopper.Filter;
|
||||
import com.songoda.epichoppers.hopper.Hopper;
|
||||
@ -30,7 +31,7 @@ public class GUIAutoSellFilter extends Gui {
|
||||
this.hopper = hopper;
|
||||
|
||||
setRows(6);
|
||||
setTitle(Methods.formatText(Methods.formatName(hopper.getLevel().getLevel()) + " &8-&f AutoSell Filter"));
|
||||
setTitle(TextUtils.formatText(Methods.formatName(hopper.getLevel().getLevel()) + " &8-&f AutoSell Filter"));
|
||||
setDefaultItem(null);
|
||||
setAcceptsItems(true);
|
||||
|
||||
@ -104,7 +105,7 @@ public class GUIAutoSellFilter extends Gui {
|
||||
String[] parts = plugin.getLocale().getMessage("interface.autosell-filter.infolore").getMessage().split("\\|");
|
||||
|
||||
for (String line : parts) {
|
||||
loreInfo.add(Methods.formatText(line));
|
||||
loreInfo.add(TextUtils.formatText(line));
|
||||
}
|
||||
|
||||
indicatorMeta.setLore(loreInfo);
|
||||
|
@ -3,6 +3,7 @@ package com.songoda.epichoppers.gui;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.hopper.Hopper;
|
||||
import com.songoda.epichoppers.hopper.levels.modules.ModuleAutoCrafting;
|
||||
@ -15,7 +16,7 @@ public class GUICrafting extends Gui {
|
||||
|
||||
public GUICrafting(ModuleAutoCrafting module, Hopper hopper, Player player) {
|
||||
setRows(3);
|
||||
setTitle(Methods.formatName(hopper.getLevel().getLevel()) + Methods.formatText(" &8-&f Crafting"));
|
||||
setTitle(Methods.formatName(hopper.getLevel().getLevel()) + TextUtils.formatText(" &8-&f Crafting"));
|
||||
setOnClose((event) -> setItem(module, hopper, player));
|
||||
setAcceptsItems(true);
|
||||
|
||||
|
@ -3,6 +3,7 @@ package com.songoda.epichoppers.gui;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.hopper.Filter;
|
||||
import com.songoda.epichoppers.hopper.Hopper;
|
||||
@ -31,7 +32,7 @@ public class GUIFilter extends Gui {
|
||||
this.hopper = hopper;
|
||||
|
||||
setRows(6);
|
||||
setTitle(Methods.formatText(Methods.formatName(hopper.getLevel().getLevel()) + " &8-&f Filter"));
|
||||
setTitle(TextUtils.formatText(Methods.formatName(hopper.getLevel().getLevel()) + " &8-&f Filter"));
|
||||
setDefaultItem(null);
|
||||
setAcceptsItems(true);
|
||||
|
||||
@ -118,7 +119,7 @@ public class GUIFilter extends Gui {
|
||||
ArrayList<String> loreInfo = new ArrayList<>();
|
||||
String[] parts = plugin.getLocale().getMessage("interface.filter.infolore").getMessage().split("\\|");
|
||||
for (String line : parts) {
|
||||
loreInfo.add(Methods.formatText(line));
|
||||
loreInfo.add(TextUtils.formatText(line));
|
||||
}
|
||||
itemmetaInfo.setLore(loreInfo);
|
||||
itemInfo.setItemMeta(itemmetaInfo);
|
||||
@ -134,7 +135,7 @@ public class GUIFilter extends Gui {
|
||||
.processPlaceholder("amount", filter.getEndPoint() != null ? 1 : 0)
|
||||
.getMessage().split("\\|");
|
||||
for (String line : parts) {
|
||||
lorehook.add(Methods.formatText(line));
|
||||
lorehook.add(TextUtils.formatText(line));
|
||||
}
|
||||
hookmeta.setLore(lorehook);
|
||||
hook.setItemMeta(hookmeta);
|
||||
|
@ -4,6 +4,7 @@ import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.boost.BoostData;
|
||||
import com.songoda.epichoppers.hopper.Hopper;
|
||||
@ -75,7 +76,7 @@ public class GUIOverview extends Gui {
|
||||
? plugin.getLocale().getMessage("general.word.disabled").getMessage()
|
||||
: hopper.getTeleportTrigger().name()).getMessage().split("\\|");
|
||||
for (String line : parts) {
|
||||
loreperl.add(Methods.formatText(line));
|
||||
loreperl.add(TextUtils.formatText(line));
|
||||
}
|
||||
perlmeta.setLore(loreperl);
|
||||
perl.setItemMeta(perlmeta);
|
||||
@ -86,7 +87,7 @@ public class GUIOverview extends Gui {
|
||||
ArrayList<String> lorefilter = new ArrayList<>();
|
||||
parts = plugin.getLocale().getMessage("interface.hopper.filterlore").getMessage().split("\\|");
|
||||
for (String line : parts) {
|
||||
lorefilter.add(Methods.formatText(line));
|
||||
lorefilter.add(TextUtils.formatText(line));
|
||||
}
|
||||
filtermeta.setLore(lorefilter);
|
||||
filter.setItemMeta(filtermeta);
|
||||
@ -114,7 +115,7 @@ public class GUIOverview extends Gui {
|
||||
.getMessage().split("\\|");
|
||||
lore.add("");
|
||||
for (String line : parts)
|
||||
lore.add(Methods.formatText(line));
|
||||
lore.add(TextUtils.formatText(line));
|
||||
}
|
||||
|
||||
itemmeta.setLore(lore);
|
||||
@ -128,7 +129,7 @@ public class GUIOverview extends Gui {
|
||||
.processPlaceholder("amount", hopper.getLinkedBlocks().stream().distinct().count())
|
||||
.getMessage().split("\\|");
|
||||
for (String line : parts) {
|
||||
lorehook.add(Methods.formatText(line));
|
||||
lorehook.add(TextUtils.formatText(line));
|
||||
}
|
||||
hookmeta.setLore(lorehook);
|
||||
hook.setItemMeta(hookmeta);
|
||||
|
@ -24,11 +24,11 @@ public class TeleportHandler {
|
||||
|
||||
private final Map<UUID, Long> lastTeleports = new HashMap<>();
|
||||
|
||||
private EpicHoppers instance;
|
||||
private EpicHoppers plugin;
|
||||
|
||||
public TeleportHandler(EpicHoppers instance) {
|
||||
this.instance = instance;
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(instance, this::teleportRunner, 0, instance.getConfig().getLong("Main.Amount of Ticks Between Teleport"));
|
||||
public TeleportHandler(EpicHoppers plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, this::teleportRunner, 0, plugin.getConfig().getLong("Main.Amount of Ticks Between Teleport"));
|
||||
}
|
||||
|
||||
private void teleportRunner() {
|
||||
@ -37,16 +37,16 @@ public class TeleportHandler {
|
||||
if (!(entity instanceof LivingEntity) || entity.getType() == EntityType.ARMOR_STAND)
|
||||
continue;
|
||||
|
||||
if (!this.instance.getConfig().getBoolean("Main.Allow Players To Teleport Through Hoppers")
|
||||
if (!this.plugin.getConfig().getBoolean("Main.Allow Players To Teleport Through Hoppers")
|
||||
|| (entity instanceof Player && !entity.hasPermission("EpicHoppers.Teleport")))
|
||||
continue;
|
||||
|
||||
Location location = entity.getLocation().getBlock().getRelative(BlockFace.DOWN).getLocation();
|
||||
|
||||
if (!this.instance.getHopperManager().isHopper(location))
|
||||
if (!this.plugin.getHopperManager().isHopper(location))
|
||||
continue;
|
||||
|
||||
Hopper hopper = this.instance.getHopperManager().getHopper(location);
|
||||
Hopper hopper = this.plugin.getHopperManager().getHopper(location);
|
||||
|
||||
if (hopper.getTeleportTrigger() != TeleportTrigger.WALK_ON)
|
||||
continue;
|
||||
@ -64,11 +64,11 @@ public class TeleportHandler {
|
||||
}
|
||||
|
||||
public void tpEntity(Entity entity, Hopper hopper) {
|
||||
if (hopper == null || !this.instance.getHopperManager().isHopper(hopper.getLocation()))
|
||||
if (hopper == null || !this.plugin.getHopperManager().isHopper(hopper.getLocation()))
|
||||
return;
|
||||
|
||||
Hopper lastHopper = this.getChain(hopper, 1);
|
||||
if (hopper != lastHopper)
|
||||
if (!hopper.equals(lastHopper))
|
||||
this.doTeleport(entity, lastHopper.getLocation());
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ public class TeleportHandler {
|
||||
|
||||
for (Location nextHopperLocation : lastHopper.getLinkedBlocks()) {
|
||||
if (nextHopperLocation.getBlock().getState() instanceof org.bukkit.block.Hopper) {
|
||||
Hopper hopper = this.instance.getHopperManager().getHopper(nextHopperLocation);
|
||||
Hopper hopper = this.plugin.getHopperManager().getHopper(nextHopperLocation);
|
||||
if (hopper != null)
|
||||
return this.getChain(hopper, currentChainLength + 1);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.epichoppers.hopper.levels.modules;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.gui.GUICrafting;
|
||||
import com.songoda.epichoppers.hopper.Hopper;
|
||||
@ -33,8 +34,8 @@ public class ModuleAutoCrafting extends Module {
|
||||
|
||||
private static final Map<ItemStack, Recipes> cachedRecipes = new ConcurrentHashMap<>();
|
||||
private static final Map<Hopper, ItemStack> cachedCrafting = new ConcurrentHashMap<>();
|
||||
static final ItemStack noCraft = new ItemStack(Material.AIR);
|
||||
boolean crafterEjection;
|
||||
private static final ItemStack noCraft = new ItemStack(Material.AIR);
|
||||
private boolean crafterEjection;
|
||||
|
||||
public ModuleAutoCrafting(EpicHoppers plugin) {
|
||||
super(plugin);
|
||||
@ -185,7 +186,7 @@ public class ModuleAutoCrafting extends Module {
|
||||
String[] parts = EpicHoppers.getInstance().getLocale().getMessage("interface.hopper.craftinglore")
|
||||
.getMessage().split("\\|");
|
||||
for (String line : parts) {
|
||||
lorecrafting.add(Methods.formatText(line));
|
||||
lorecrafting.add(TextUtils.formatText(line));
|
||||
}
|
||||
craftingmeta.setLore(lorecrafting);
|
||||
crafting.setItemMeta(craftingmeta);
|
||||
@ -283,7 +284,7 @@ public class ModuleAutoCrafting extends Module {
|
||||
1, Short.parseShort(autoCraftingParts.length == 2 ? autoCraftingParts[1] : "0"));
|
||||
}
|
||||
|
||||
final static class Recipes {
|
||||
private final static class Recipes {
|
||||
private final List<SimpleRecipe> recipes = new ArrayList<>();
|
||||
// Used for the blacklist to ensure that items are not going to get transferred
|
||||
private final List<Material> possibleIngredientTypes = new ArrayList<>();
|
||||
@ -344,11 +345,11 @@ public class ModuleAutoCrafting extends Module {
|
||||
}
|
||||
}
|
||||
|
||||
final static class SimpleRecipe {
|
||||
final SimpleIngredient[] ingredients;
|
||||
final ItemStack result;
|
||||
private final static class SimpleRecipe {
|
||||
private final SimpleIngredient[] ingredients;
|
||||
private final ItemStack result;
|
||||
|
||||
SimpleRecipe(ShapelessRecipe recipe) {
|
||||
public SimpleRecipe(ShapelessRecipe recipe) {
|
||||
this.result = recipe.getResult();
|
||||
|
||||
List<SimpleIngredient> ingredients = new ArrayList<>();
|
||||
@ -368,7 +369,7 @@ public class ModuleAutoCrafting extends Module {
|
||||
this.ingredients = ingredients.toArray(new SimpleIngredient[0]);
|
||||
}
|
||||
|
||||
SimpleRecipe(ShapedRecipe recipe) {
|
||||
public SimpleRecipe(ShapedRecipe recipe) {
|
||||
this.result = recipe.getResult();
|
||||
|
||||
List<SimpleIngredient> ingredients = new ArrayList<>();
|
||||
@ -418,9 +419,9 @@ public class ModuleAutoCrafting extends Module {
|
||||
}
|
||||
}
|
||||
|
||||
static class SimpleIngredient {
|
||||
final ItemStack item;
|
||||
final ItemStack[] alternativeTypes;
|
||||
private static class SimpleIngredient {
|
||||
private final ItemStack item;
|
||||
private final ItemStack[] alternativeTypes;
|
||||
|
||||
/**
|
||||
* <b>Ignored by {@link #isSimilar(Object)}!</b><br>
|
||||
|
@ -2,6 +2,7 @@ package com.songoda.epichoppers.hopper.levels.modules;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.gui.GUIAutoSellFilter;
|
||||
import com.songoda.epichoppers.hopper.Filter;
|
||||
@ -125,7 +126,7 @@ public class ModuleAutoSell extends Module {
|
||||
.processPlaceholder("state", isNotifying(hopper)).getMessage().split("\\|");
|
||||
|
||||
for (String line : parts) {
|
||||
loreSell.add(Methods.formatText(line));
|
||||
loreSell.add(TextUtils.formatText(line));
|
||||
}
|
||||
|
||||
sellMeta.setLore(loreSell);
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.songoda.epichoppers.hopper.levels.modules;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.hopper.Hopper;
|
||||
import com.songoda.epichoppers.settings.Settings;
|
||||
import com.songoda.epichoppers.utils.Methods;
|
||||
import com.songoda.epichoppers.utils.StorageContainerCache;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -127,7 +127,7 @@ public class ModuleBlockBreak extends Module {
|
||||
: plugin.getLocale().getMessage("general.word.disabled").getMessage())
|
||||
.getMessage().split("\\|");
|
||||
for (String line : parts) {
|
||||
loreblock.add(Methods.formatText(line));
|
||||
loreblock.add(TextUtils.formatText(line));
|
||||
}
|
||||
blockmeta.setLore(loreblock);
|
||||
block.setItemMeta(blockmeta);
|
||||
|
@ -4,6 +4,7 @@ import com.bgsoftware.wildstacker.api.WildStackerAPI;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.CompatibleParticleHandler;
|
||||
import com.songoda.core.locale.Locale;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.hopper.Hopper;
|
||||
import com.songoda.epichoppers.settings.Settings;
|
||||
@ -206,7 +207,7 @@ public class ModuleSuction extends Module {
|
||||
.processPlaceholder("status", isEnabled(hopper) ? locale.getMessage("general.word.enabled").getMessage() : locale.getMessage("general.word.disabled").getMessage())
|
||||
.processPlaceholder("radius", getRadius(hopper)).getMessage().split("\\|");
|
||||
for (String line : parts) {
|
||||
lore.add(Methods.formatText(line));
|
||||
lore.add(TextUtils.formatText(line));
|
||||
}
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
|
@ -17,20 +17,16 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/14/2017.
|
||||
*/
|
||||
public class BlockListeners implements Listener {
|
||||
|
||||
private final EpicHoppers instance;
|
||||
private final Random random;
|
||||
private final EpicHoppers plugin;
|
||||
|
||||
public BlockListeners(EpicHoppers instance) {
|
||||
this.instance = instance;
|
||||
this.random = new Random();
|
||||
public BlockListeners(EpicHoppers plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@ -40,7 +36,7 @@ public class BlockListeners implements Listener {
|
||||
if (e.getBlock().getType() != Material.HOPPER)
|
||||
return;
|
||||
|
||||
if (instance.isLiquidtanks() && net.arcaniax.liquidtanks.object.LiquidTankAPI.isLiquidTank(e.getBlock().getLocation()))
|
||||
if (plugin.isLiquidtanks() && net.arcaniax.liquidtanks.object.LiquidTankAPI.isLiquidTank(e.getBlock().getLocation()))
|
||||
return;
|
||||
|
||||
int amt = count(e.getBlock().getChunk());
|
||||
@ -48,19 +44,19 @@ public class BlockListeners implements Listener {
|
||||
int max = maxHoppers(player);
|
||||
|
||||
if (max != -1 && amt > max) {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.toomany").processPlaceholder("amount", max).getMessage());
|
||||
player.sendMessage(plugin.getLocale().getMessage("event.hopper.toomany").processPlaceholder("amount", max).getMessage());
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack item = e.getItemInHand().clone();
|
||||
|
||||
if (Settings.ALLOW_NORMAL_HOPPERS.getBoolean() && !instance.getLevelManager().isEpicHopper(item))
|
||||
if (Settings.ALLOW_NORMAL_HOPPERS.getBoolean() && !plugin.getLevelManager().isEpicHopper(item))
|
||||
return;
|
||||
|
||||
Hopper hopper = instance.getHopperManager().addHopper(
|
||||
Hopper hopper = plugin.getHopperManager().addHopper(
|
||||
new HopperBuilder(e.getBlock())
|
||||
.setLevel(instance.getLevelManager().getLevel(item))
|
||||
.setLevel(plugin.getLevelManager().getLevel(item))
|
||||
.setPlacedBy(player)
|
||||
.setLastPlayerOpened(player).build());
|
||||
EpicHoppers.getInstance().getDataManager().createHopper(hopper);
|
||||
@ -74,7 +70,7 @@ public class BlockListeners implements Listener {
|
||||
if (num > limit)
|
||||
limit = num;
|
||||
}
|
||||
if (limit == -1) limit = instance.getConfig().getInt("Main.Max Hoppers Per Chunk");
|
||||
if (limit == -1) limit = plugin.getConfig().getInt("Main.Max Hoppers Per Chunk");
|
||||
return limit;
|
||||
}
|
||||
|
||||
@ -97,19 +93,19 @@ public class BlockListeners implements Listener {
|
||||
|
||||
if (event.getBlock().getType() != Material.HOPPER) return;
|
||||
|
||||
if (instance.isLiquidtanks() && net.arcaniax.liquidtanks.object.LiquidTankAPI.isLiquidTank(block.getLocation()))
|
||||
if (plugin.isLiquidtanks() && net.arcaniax.liquidtanks.object.LiquidTankAPI.isLiquidTank(block.getLocation()))
|
||||
return;
|
||||
|
||||
if (Settings.ALLOW_NORMAL_HOPPERS.getBoolean() && !instance.getHopperManager().isHopper(block.getLocation()))
|
||||
if (Settings.ALLOW_NORMAL_HOPPERS.getBoolean() && !plugin.getHopperManager().isHopper(block.getLocation()))
|
||||
return;
|
||||
|
||||
Hopper hopper = instance.getHopperManager().getHopper(block);
|
||||
Hopper hopper = plugin.getHopperManager().getHopper(block);
|
||||
|
||||
Level level = hopper.getLevel();
|
||||
|
||||
if (level.getLevel() > 1) {
|
||||
event.setCancelled(true);
|
||||
ItemStack item = instance.newHopperItem(level);
|
||||
ItemStack item = plugin.newHopperItem(level);
|
||||
|
||||
event.getBlock().setType(Material.AIR);
|
||||
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), item);
|
||||
@ -125,9 +121,9 @@ public class BlockListeners implements Listener {
|
||||
filter(m -> m != null)
|
||||
.forEach(m -> event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation(), m));
|
||||
|
||||
instance.getHopperManager().removeHopper(block.getLocation());
|
||||
instance.getDataManager().deleteHopper(hopper);
|
||||
plugin.getHopperManager().removeHopper(block.getLocation());
|
||||
plugin.getDataManager().deleteHopper(hopper);
|
||||
|
||||
instance.getPlayerDataManager().getPlayerData(player).setSyncType(null);
|
||||
plugin.getPlayerDataManager().getPlayerData(player).setSyncType(null);
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package com.songoda.epichoppers.listeners;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
@ -16,7 +15,6 @@ public class InventoryListeners implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
if (event.getCurrentItem() == null) return;
|
||||
|
||||
if (event.getRawSlot() > event.getView().getTopInventory().getSize() - 1) return;
|
||||
|
@ -6,16 +6,10 @@ import java.util.UUID;
|
||||
|
||||
public class PlayerData {
|
||||
|
||||
private final UUID playerUUID;
|
||||
|
||||
private Hopper lastHopper = null;
|
||||
|
||||
private SyncType syncType = null; // Null means off.
|
||||
|
||||
PlayerData(UUID playerUUID) {
|
||||
this.playerUUID = playerUUID;
|
||||
}
|
||||
|
||||
public Hopper getLastHopper() {
|
||||
return lastHopper;
|
||||
}
|
||||
|
@ -13,7 +13,9 @@ public class PlayerDataManager {
|
||||
private final Map<UUID, PlayerData> registeredPlayers = new HashMap<>();
|
||||
|
||||
private PlayerData getPlayerData(UUID uuid) {
|
||||
return (uuid != null) ? registeredPlayers.computeIfAbsent(uuid, PlayerData::new) : null;
|
||||
if (registeredPlayers.containsKey(uuid))
|
||||
registeredPlayers.put(uuid, new PlayerData());
|
||||
return registeredPlayers.get(uuid);
|
||||
}
|
||||
|
||||
public PlayerData getPlayerData(Player player) {
|
||||
|
@ -11,7 +11,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Settings {
|
||||
|
||||
static final Config config = EpicHoppers.getInstance().getCoreConfig();
|
||||
private static final Config config = EpicHoppers.getInstance().getCoreConfig();
|
||||
|
||||
public static final ConfigSetting HOPPER_UPGRADING = new ConfigSetting(config, "Main.Allow hopper Upgrading", true,
|
||||
"Should hoppers be upgradable?");
|
||||
|
@ -50,8 +50,8 @@ public class HopTask extends BukkitRunnable {
|
||||
private boolean legacyFabledSkyblock;
|
||||
private final Plugin fabledSkyblockPlugin;
|
||||
|
||||
public HopTask(EpicHoppers plug) {
|
||||
plugin = plug;
|
||||
public HopTask(EpicHoppers plugin) {
|
||||
HopTask.plugin = plugin;
|
||||
this.hopTicks = Math.max(1, Settings.HOP_TICKS.getInt() / 2); // Purposeful integer division. Don't go below 1.
|
||||
this.runTaskTimer(plugin, 0, 2);
|
||||
if ((this.hasFabledSkyBlock = (fabledSkyblockPlugin = Bukkit.getPluginManager().getPlugin("FabledSkyBlock")) != null)) {
|
||||
|
@ -1,22 +1,16 @@
|
||||
package com.songoda.epichoppers.utils;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@ -24,8 +18,6 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public class Methods {
|
||||
|
||||
private static final Map<String, Location> serializeCache = new HashMap<>();
|
||||
|
||||
public static boolean isSimilarMaterial(ItemStack is1, ItemStack is2) {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ||
|
||||
is1.getDurability() == Short.MAX_VALUE || is2.getDurability() == Short.MAX_VALUE) {
|
||||
@ -106,7 +98,7 @@ public class Methods {
|
||||
.processPlaceholder("level", level).getMessage();
|
||||
|
||||
|
||||
return Methods.formatText(name);
|
||||
return TextUtils.formatText(name);
|
||||
}
|
||||
|
||||
public static void doParticles(Entity entity, Location location) {
|
||||
@ -117,17 +109,6 @@ public class Methods {
|
||||
entity.getWorld().spawnParticle(org.bukkit.Particle.valueOf(instance.getConfig().getString("Main.Upgrade Particle Type")), location, 200, .5, .5, .5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the location of the block specified.
|
||||
*
|
||||
* @param b The block whose location is to be saved.
|
||||
* @return The serialized data.
|
||||
*/
|
||||
public static String serializeLocation(Block b) {
|
||||
if (b == null)
|
||||
return "";
|
||||
return serializeLocation(b.getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the location specified.
|
||||
@ -147,52 +128,6 @@ public class Methods {
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes a location from the string.
|
||||
*
|
||||
* @param str The string to parse.
|
||||
* @return The location that was serialized in the string.
|
||||
*/
|
||||
public static Location unserializeLocation(String str) {
|
||||
if (str == null || str.equals(""))
|
||||
return null;
|
||||
if (serializeCache.containsKey(str)) {
|
||||
return serializeCache.get(str).clone();
|
||||
}
|
||||
String cacheKey = str;
|
||||
str = str.replace("y:", ":").replace("z:", ":").replace("w:", "").replace("x:", ":").replace("/", ".");
|
||||
List<String> args = Arrays.asList(str.split("\\s*:\\s*"));
|
||||
|
||||
World world = Bukkit.getWorld(args.get(0));
|
||||
double x = Double.parseDouble(args.get(1)), y = Double.parseDouble(args.get(2)), z = Double.parseDouble(args.get(3));
|
||||
Location location = new Location(world, x, y, z, 0, 0);
|
||||
serializeCache.put(cacheKey, location.clone());
|
||||
return location;
|
||||
}
|
||||
|
||||
public static String convertToInvisibleString(String s) {
|
||||
if (s == null || s.equals(""))
|
||||
return "";
|
||||
StringBuilder hidden = new StringBuilder();
|
||||
for (char c : s.toCharArray()) hidden.append(ChatColor.COLOR_CHAR + "").append(c);
|
||||
return hidden.toString();
|
||||
}
|
||||
|
||||
|
||||
public static String formatText(String text) {
|
||||
if (text == null || text.equals(""))
|
||||
return "";
|
||||
return formatText(text, false);
|
||||
}
|
||||
|
||||
public static String formatText(String text, boolean cap) {
|
||||
if (text == null || text.equals(""))
|
||||
return "";
|
||||
if (cap)
|
||||
text = text.substring(0, 1).toUpperCase() + text.substring(1);
|
||||
return ChatColor.translateAlternateColorCodes('&', text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the specified Unix Epoch time human readable as per the format settings in the Arconix config.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user