mirror of
https://github.com/songoda/EpicHoppers.git
synced 2024-11-23 02:35:18 +01:00
Upgrade disable bug fix, other minor bug fix
This commit is contained in:
parent
32bdb1f17a
commit
eef627afa6
@ -156,59 +156,59 @@ public class GUIFilter extends AbstractGUI {
|
||||
|
||||
|
||||
private void compile(Player p) {
|
||||
ItemStack[] items = p.getOpenInventory().getTopInventory().getContents();
|
||||
ItemStack[] items = p.getOpenInventory().getTopInventory().getContents();
|
||||
|
||||
Filter filter = hopper.getFilter();
|
||||
Filter filter = hopper.getFilter();
|
||||
|
||||
List<ItemStack> owhite = new ArrayList<>();
|
||||
List<ItemStack> oblack = new ArrayList<>();
|
||||
List<ItemStack> ovoid = new ArrayList<>();
|
||||
List<ItemStack> owhite = new ArrayList<>();
|
||||
List<ItemStack> oblack = new ArrayList<>();
|
||||
List<ItemStack> ovoid = new ArrayList<>();
|
||||
|
||||
int[] awhite = {9, 10, 18, 19, 27, 28, 36, 37};
|
||||
int[] ablack = {11, 12, 20, 21, 29, 30, 38, 39};
|
||||
int[] avoid = {13, 14, 22, 23, 31, 32, 40, 41};
|
||||
int[] awhite = {9, 10, 18, 19, 27, 28, 36, 37};
|
||||
int[] ablack = {11, 12, 20, 21, 29, 30, 38, 39};
|
||||
int[] avoid = {13, 14, 22, 23, 31, 32, 40, 41};
|
||||
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
for (int aa : awhite) {
|
||||
if (aa != i) continue;
|
||||
if (items[i] != null && items[i].getType() != Material.AIR) {
|
||||
ItemStack item = items[i];
|
||||
if (item.getAmount() != 1) {
|
||||
item.setAmount(item.getAmount() - 1);
|
||||
Bukkit.getPlayer(hopper.getLastPlayer()).getInventory().addItem(item);
|
||||
item.setAmount(1);
|
||||
}
|
||||
owhite.add(item);
|
||||
}
|
||||
}
|
||||
for (int aa : ablack) {
|
||||
if (aa != i) continue;
|
||||
if (items[i] != null && items[i].getType() != Material.AIR) {
|
||||
ItemStack item = items[i];
|
||||
if (item.getAmount() != 1) {
|
||||
item.setAmount(item.getAmount() - 1);
|
||||
Bukkit.getPlayer(hopper.getLastPlayer()).getInventory().addItem(item);
|
||||
item.setAmount(1);
|
||||
}
|
||||
oblack.add(item);
|
||||
}
|
||||
}
|
||||
for (int aa : avoid) {
|
||||
if (aa != i) continue;
|
||||
if (items[i] != null && items[i].getType() != Material.AIR) {
|
||||
ItemStack item = items[i];
|
||||
if (item.getAmount() != 1) {
|
||||
item.setAmount(item.getAmount() - 1);
|
||||
Bukkit.getPlayer(hopper.getLastPlayer()).getInventory().addItem(item);
|
||||
item.setAmount(1);
|
||||
}
|
||||
ovoid.add(item);
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
for (int aa : awhite) {
|
||||
if (aa != i) continue;
|
||||
if (items[i] != null && items[i].getType() != Material.AIR) {
|
||||
ItemStack item = items[i];
|
||||
if (item.getAmount() != 1) {
|
||||
item.setAmount(item.getAmount() - 1);
|
||||
Bukkit.getPlayer(hopper.getLastPlayer()).getInventory().addItem(item);
|
||||
item.setAmount(1);
|
||||
}
|
||||
owhite.add(item);
|
||||
}
|
||||
}
|
||||
filter.setWhiteList(owhite);
|
||||
filter.setBlackList(oblack);
|
||||
filter.setVoidList(ovoid);
|
||||
for (int aa : ablack) {
|
||||
if (aa != i) continue;
|
||||
if (items[i] != null && items[i].getType() != Material.AIR) {
|
||||
ItemStack item = items[i];
|
||||
if (item.getAmount() != 1) {
|
||||
item.setAmount(item.getAmount() - 1);
|
||||
Bukkit.getPlayer(hopper.getLastPlayer()).getInventory().addItem(item);
|
||||
item.setAmount(1);
|
||||
}
|
||||
oblack.add(item);
|
||||
}
|
||||
}
|
||||
for (int aa : avoid) {
|
||||
if (aa != i) continue;
|
||||
if (items[i] != null && items[i].getType() != Material.AIR) {
|
||||
ItemStack item = items[i];
|
||||
if (item.getAmount() != 1) {
|
||||
item.setAmount(item.getAmount() - 1);
|
||||
Bukkit.getPlayer(hopper.getLastPlayer()).getInventory().addItem(item);
|
||||
item.setAmount(1);
|
||||
}
|
||||
ovoid.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
filter.setWhiteList(owhite);
|
||||
filter.setBlackList(oblack);
|
||||
filter.setVoidList(ovoid);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -111,28 +111,6 @@ public class GUIOverview extends AbstractGUI {
|
||||
hookmeta.setLore(lorehook);
|
||||
hook.setItemMeta(hookmeta);
|
||||
|
||||
ItemStack itemXP = new ItemStack(Material.valueOf(plugin.getConfig().getString("Interfaces.XP Icon")), 1);
|
||||
ItemMeta itemmetaXP = itemXP.getItemMeta();
|
||||
itemmetaXP.setDisplayName(plugin.getLocale().getMessage("interface.hopper.upgradewithxp"));
|
||||
ArrayList<String> loreXP = new ArrayList<>();
|
||||
if (nextLevel != null)
|
||||
loreXP.add(plugin.getLocale().getMessage("interface.hopper.upgradewithxplore", nextLevel.getCostExperience()));
|
||||
else
|
||||
loreXP.add(plugin.getLocale().getMessage("interface.hopper.alreadymaxed"));
|
||||
itemmetaXP.setLore(loreXP);
|
||||
itemXP.setItemMeta(itemmetaXP);
|
||||
|
||||
ItemStack itemECO = new ItemStack(Material.valueOf(plugin.getConfig().getString("Interfaces.Economy Icon")), 1);
|
||||
ItemMeta itemmetaECO = itemECO.getItemMeta();
|
||||
itemmetaECO.setDisplayName(plugin.getLocale().getMessage("interface.hopper.upgradewitheconomy"));
|
||||
ArrayList<String> loreECO = new ArrayList<>();
|
||||
if (nextLevel != null)
|
||||
loreECO.add(plugin.getLocale().getMessage("interface.hopper.upgradewitheconomylore", Methods.formatEconomy(nextLevel.getCostEconomy())));
|
||||
else
|
||||
loreECO.add(plugin.getLocale().getMessage("interface.hopper.alreadymaxed"));
|
||||
itemmetaECO.setLore(loreECO);
|
||||
itemECO.setItemMeta(itemmetaECO);
|
||||
|
||||
int nu = 0;
|
||||
while (nu != 27) {
|
||||
inventory.setItem(nu, Methods.getGlass());
|
||||
@ -182,30 +160,54 @@ public class GUIOverview extends AbstractGUI {
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getConfig().getBoolean("Main.Upgrade With XP")
|
||||
&& player.hasPermission("EpicHoppers.Upgrade.XP")
|
||||
&& level.getCostExperience() != -1) {
|
||||
inventory.setItem(11, itemXP);
|
||||
if (plugin.getConfig().getBoolean("Main.Allow hopper Upgrading")) {
|
||||
ItemStack itemXP = new ItemStack(Material.valueOf(plugin.getConfig().getString("Interfaces.XP Icon")), 1);
|
||||
ItemMeta itemmetaXP = itemXP.getItemMeta();
|
||||
itemmetaXP.setDisplayName(plugin.getLocale().getMessage("interface.hopper.upgradewithxp"));
|
||||
ArrayList<String> loreXP = new ArrayList<>();
|
||||
if (nextLevel != null)
|
||||
loreXP.add(plugin.getLocale().getMessage("interface.hopper.upgradewithxplore", nextLevel.getCostExperience()));
|
||||
else
|
||||
loreXP.add(plugin.getLocale().getMessage("interface.hopper.alreadymaxed"));
|
||||
itemmetaXP.setLore(loreXP);
|
||||
itemXP.setItemMeta(itemmetaXP);
|
||||
|
||||
registerClickable(11, ((player, inventory, cursor, slot, type) -> {
|
||||
hopper.upgrade(player, CostType.EXPERIENCE);
|
||||
this.hopper.overview(player);
|
||||
}));
|
||||
ItemStack itemECO = new ItemStack(Material.valueOf(plugin.getConfig().getString("Interfaces.Economy Icon")), 1);
|
||||
ItemMeta itemmetaECO = itemECO.getItemMeta();
|
||||
itemmetaECO.setDisplayName(plugin.getLocale().getMessage("interface.hopper.upgradewitheconomy"));
|
||||
ArrayList<String> loreECO = new ArrayList<>();
|
||||
if (nextLevel != null)
|
||||
loreECO.add(plugin.getLocale().getMessage("interface.hopper.upgradewitheconomylore", Methods.formatEconomy(nextLevel.getCostEconomy())));
|
||||
else
|
||||
loreECO.add(plugin.getLocale().getMessage("interface.hopper.alreadymaxed"));
|
||||
itemmetaECO.setLore(loreECO);
|
||||
itemECO.setItemMeta(itemmetaECO);
|
||||
|
||||
if (plugin.getConfig().getBoolean("Main.Upgrade With XP")
|
||||
&& player.hasPermission("EpicHoppers.Upgrade.XP")
|
||||
&& level.getCostExperience() != -1) {
|
||||
inventory.setItem(11, itemXP);
|
||||
|
||||
registerClickable(11, ((player, inventory, cursor, slot, type) -> {
|
||||
hopper.upgrade(player, CostType.EXPERIENCE);
|
||||
this.hopper.overview(player);
|
||||
}));
|
||||
}
|
||||
|
||||
if (plugin.getConfig().getBoolean("Main.Upgrade With Economy")
|
||||
&& player.hasPermission("EpicHoppers.Upgrade.ECO")
|
||||
&& level.getCostEconomy() != -1) {
|
||||
inventory.setItem(15, itemECO);
|
||||
|
||||
registerClickable(15, ((player, inventory, cursor, slot, type) -> {
|
||||
hopper.upgrade(player, CostType.ECONOMY);
|
||||
this.hopper.overview(player);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
inventory.setItem(13, item);
|
||||
|
||||
if (plugin.getConfig().getBoolean("Main.Upgrade With Economy")
|
||||
&& player.hasPermission("EpicHoppers.Upgrade.ECO")
|
||||
&& level.getCostEconomy() != -1) {
|
||||
inventory.setItem(15, itemECO);
|
||||
|
||||
registerClickable(15, ((player, inventory, cursor, slot, type) -> {
|
||||
hopper.upgrade(player, CostType.ECONOMY);
|
||||
this.hopper.overview(player);
|
||||
}));
|
||||
}
|
||||
|
||||
inventory.setItem(0, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(1, Methods.getBackgroundGlass(true));
|
||||
inventory.setItem(2, Methods.getBackgroundGlass(false));
|
||||
|
@ -8,7 +8,11 @@ import com.songoda.epichoppers.utils.CostType;
|
||||
import com.songoda.epichoppers.utils.Methods;
|
||||
import com.songoda.epichoppers.utils.ServerVersion;
|
||||
import com.songoda.epichoppers.utils.TeleportTrigger;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -53,16 +57,16 @@ public class Hopper {
|
||||
}
|
||||
|
||||
public void overview(Player player) {
|
||||
if (lastPlayer != null
|
||||
&& lastPlayer != player.getUniqueId()
|
||||
&& Bukkit.getPlayer(lastPlayer) != null) {
|
||||
Bukkit.getPlayer(lastPlayer).closeInventory();
|
||||
}
|
||||
if (placedBy == null) placedBy = player.getUniqueId();
|
||||
if (lastPlayer != null
|
||||
&& lastPlayer != player.getUniqueId()
|
||||
&& Bukkit.getPlayer(lastPlayer) != null) {
|
||||
Bukkit.getPlayer(lastPlayer).closeInventory();
|
||||
}
|
||||
if (placedBy == null) placedBy = player.getUniqueId();
|
||||
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
if (!player.hasPermission("epichoppers.overview")) return;
|
||||
new GUIOverview(instance, this, player);
|
||||
if (!player.hasPermission("epichoppers.overview")) return;
|
||||
new GUIOverview(instance, this, player);
|
||||
}
|
||||
|
||||
public void upgrade(Player player, CostType type) {
|
||||
@ -70,118 +74,119 @@ public class Hopper {
|
||||
if (plugin.getLevelManager().getLevels().containsKey(this.level.getLevel() + 1)) {
|
||||
|
||||
Level level = plugin.getLevelManager().getLevel(this.level.getLevel() + 1);
|
||||
int cost = type == CostType.ECONOMY ? level.getCostEconomy() : level.getCostExperience();
|
||||
int cost = type == CostType.ECONOMY ? level.getCostEconomy() : level.getCostExperience();
|
||||
|
||||
if (type == CostType.ECONOMY) {
|
||||
if (plugin.getEconomy() == null) {
|
||||
player.sendMessage("Economy not enabled.");
|
||||
return;
|
||||
if (type == CostType.ECONOMY) {
|
||||
if (plugin.getEconomy() == null) {
|
||||
player.sendMessage("Economy not enabled.");
|
||||
return;
|
||||
}
|
||||
if (!plugin.getEconomy().hasBalance(player, cost)) {
|
||||
player.sendMessage(plugin.references.getPrefix() + plugin.getInstance().getLocale().getMessage("event.upgrade.cannotafford"));
|
||||
return;
|
||||
}
|
||||
plugin.getEconomy().withdrawBalance(player, cost);
|
||||
upgradeFinal(level, player);
|
||||
} else if (type == CostType.EXPERIENCE) {
|
||||
if (player.getLevel() >= cost || player.getGameMode() == GameMode.CREATIVE) {
|
||||
if (player.getGameMode() != GameMode.CREATIVE) {
|
||||
player.setLevel(player.getLevel() - cost);
|
||||
}
|
||||
if (!plugin.getEconomy().hasBalance(player, cost)) {
|
||||
player.sendMessage(plugin.references.getPrefix() + plugin.getInstance().getLocale().getMessage("event.upgrade.cannotafford"));
|
||||
return;
|
||||
}
|
||||
plugin.getEconomy().withdrawBalance(player, cost);
|
||||
upgradeFinal(level, player);
|
||||
} else if (type == CostType.EXPERIENCE) {
|
||||
if (player.getLevel() >= cost || player.getGameMode() == GameMode.CREATIVE) {
|
||||
if (player.getGameMode() != GameMode.CREATIVE) {
|
||||
player.setLevel(player.getLevel() - cost);
|
||||
}
|
||||
upgradeFinal(level, player);
|
||||
} else {
|
||||
player.sendMessage(plugin.references.getPrefix() + plugin.getLocale().getMessage("event.upgrade.cannotafford"));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(plugin.references.getPrefix() + plugin.getLocale().getMessage("event.upgrade.cannotafford"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void upgradeFinal(Level level, Player player) {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
this.level = level;
|
||||
syncName();
|
||||
if (instance.getLevelManager().getHighestLevel() != level) {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.upgrade.success", level.getLevel()));
|
||||
} else {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.upgrade.maxed", level.getLevel()));
|
||||
}
|
||||
Location loc = location.clone().add(.5, .5, .5);
|
||||
this.level = level;
|
||||
syncName();
|
||||
if (instance.getLevelManager().getHighestLevel() != level) {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.upgrade.success", level.getLevel()));
|
||||
} else {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.upgrade.maxed", level.getLevel()));
|
||||
}
|
||||
Location loc = location.clone().add(.5, .5, .5);
|
||||
|
||||
if (!instance.isServerVersionAtLeast(ServerVersion.V1_12)) return;
|
||||
if (!instance.isServerVersionAtLeast(ServerVersion.V1_12)) return;
|
||||
|
||||
player.getWorld().spawnParticle(org.bukkit.Particle.valueOf(instance.getConfig().getString("Main.Upgrade Particle Type")), loc, 200, .5, .5, .5);
|
||||
player.getWorld().spawnParticle(org.bukkit.Particle.valueOf(instance.getConfig().getString("Main.Upgrade Particle Type")), loc, 200, .5, .5, .5);
|
||||
|
||||
if (instance.getLevelManager().getHighestLevel() != level) {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 0.6F, 15.0F);
|
||||
} else {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 2F, 25.0F);
|
||||
if (instance.getLevelManager().getHighestLevel() != level) {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 0.6F, 15.0F);
|
||||
} else {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 2F, 25.0F);
|
||||
|
||||
if (!instance.isServerVersionAtLeast(ServerVersion.V1_13)) return;
|
||||
if (!instance.isServerVersionAtLeast(ServerVersion.V1_13)) return;
|
||||
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_CHIME, 2F, 25.0F);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_CHIME, 1.2F, 35.0F), 5L);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_CHIME, 1.8F, 35.0F), 10L);
|
||||
}
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_CHIME, 2F, 25.0F);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_CHIME, 1.2F, 35.0F), 5L);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_CHIME, 1.8F, 35.0F), 10L);
|
||||
}
|
||||
}
|
||||
|
||||
private void syncName() {
|
||||
org.bukkit.block.Hopper hopper = (org.bukkit.block.Hopper)location.getBlock().getState();
|
||||
org.bukkit.block.Hopper hopper = (org.bukkit.block.Hopper) location.getBlock().getState();
|
||||
if (EpicHoppers.getInstance().isServerVersionAtLeast(ServerVersion.V1_10))
|
||||
hopper.setCustomName(Methods.formatName(level.getLevel(), false));
|
||||
hopper.update(true);
|
||||
hopper.update(true);
|
||||
}
|
||||
|
||||
public void timeout(Player player) {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
PlayerData playerData = instance.getPlayerDataManager().getPlayerData(player);
|
||||
if (playerData.getSyncType() != null) {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.synctimeout"));
|
||||
playerData.setSyncType(null);
|
||||
}
|
||||
}, instance.getConfig().getLong("Main.Timeout When Syncing Hoppers"));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
PlayerData playerData = instance.getPlayerDataManager().getPlayerData(player);
|
||||
if (playerData.getSyncType() != null) {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.synctimeout"));
|
||||
playerData.setSyncType(null);
|
||||
}
|
||||
}, instance.getConfig().getLong("Main.Timeout When Syncing Hoppers"));
|
||||
}
|
||||
|
||||
public void link(Block toLink, boolean filtered, Player player) {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
|
||||
if (location.getWorld().equals(toLink.getLocation().getWorld())
|
||||
&& !player.hasPermission("EpicHoppers.Override")
|
||||
&& !player.hasPermission("EpicHoppers.Admin")
|
||||
&& location.distance(toLink.getLocation()) > level.getRange()) {
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncoutofrange"));
|
||||
return;
|
||||
}
|
||||
if (location.getWorld().equals(toLink.getLocation().getWorld())
|
||||
&& !player.hasPermission("EpicHoppers.Override")
|
||||
&& !player.hasPermission("EpicHoppers.Admin")
|
||||
&& location.distance(toLink.getLocation()) > level.getRange()) {
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncoutofrange"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (linkedBlocks.contains(toLink)) {
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.already"));
|
||||
return;
|
||||
}
|
||||
if (linkedBlocks.contains(toLink)) {
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.already"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!filtered)
|
||||
this.linkedBlocks.add(toLink.getLocation());
|
||||
else {
|
||||
this.filter.setEndPoint(toLink.getLocation());
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncsuccess"));
|
||||
instance.getPlayerDataManager().getPlayerData(player).setSyncType(null);
|
||||
return;
|
||||
}
|
||||
this.lastPlayer = player.getUniqueId();
|
||||
|
||||
if (level.getLinkAmount() > 1) {
|
||||
if (getLinkedBlocks().size() == level.getLinkAmount()) {
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncdone"));
|
||||
return;
|
||||
}
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncsuccessmore", level.getLinkAmount() - getLinkedBlocks().size()));
|
||||
return;
|
||||
}
|
||||
if (!filtered)
|
||||
this.linkedBlocks.add(toLink.getLocation());
|
||||
else {
|
||||
this.filter.setEndPoint(toLink.getLocation());
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncsuccess"));
|
||||
instance.getPlayerDataManager().getPlayerData(player).setSyncType(null);
|
||||
return;
|
||||
}
|
||||
this.lastPlayer = player.getUniqueId();
|
||||
|
||||
if (level.getLinkAmount() > 1) {
|
||||
if (getLinkedBlocks().size() == level.getLinkAmount()) {
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncdone"));
|
||||
return;
|
||||
}
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncsuccessmore", level.getLinkAmount() - getLinkedBlocks().size()));
|
||||
return;
|
||||
}
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncsuccess"));
|
||||
instance.getPlayerDataManager().getPlayerData(player).setSyncType(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticks a hopper to determine when it can transfer items next
|
||||
*
|
||||
* @param maxTick The maximum amount the hopper can be ticked before next transferring items
|
||||
* @param allowLooping If true, the hopper is allowed to transfer items if the tick is also valid
|
||||
* @return true if the hopper should transfer an item, otherwise false
|
||||
|
@ -80,8 +80,7 @@ public class InteractListeners implements Listener {
|
||||
return;
|
||||
Hopper hopper = instance.getHopperManager().getHopper(e.getClickedBlock());
|
||||
playerData.setLastHopper(hopper);
|
||||
if (instance.getConfig().getBoolean("Main.Allow hopper Upgrading")
|
||||
&& !player.getInventory().getItemInHand().getType().name().contains("PICKAXE")) {
|
||||
if (!player.getInventory().getItemInHand().getType().name().contains("PICKAXE")) {
|
||||
hopper.overview(player);
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
|
@ -43,7 +43,7 @@ public class HopTask extends BukkitRunnable {
|
||||
|
||||
public HopTask(EpicHoppers plug) {
|
||||
plugin = plug;
|
||||
this.hopTicks = Setting.HOP_TICKS.getInt() / 2; // Purposeful integer division
|
||||
this.hopTicks = Math.max(1, Setting.HOP_TICKS.getInt() / 2); // Purposeful integer division. Don't go below 1.
|
||||
this.runTaskTimer(plugin, 0, 2);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user