Upgrade disable bug fix, other minor bug fix

This commit is contained in:
Esophose 2019-05-30 23:49:43 -06:00
parent 32bdb1f17a
commit eef627afa6
5 changed files with 181 additions and 175 deletions

View File

@ -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,6 +160,29 @@ public class GUIOverview extends AbstractGUI {
}
}
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);
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) {
@ -193,8 +194,6 @@ public class GUIOverview extends AbstractGUI {
}));
}
inventory.setItem(13, item);
if (plugin.getConfig().getBoolean("Main.Upgrade With Economy")
&& player.hasPermission("EpicHoppers.Upgrade.ECO")
&& level.getCostEconomy() != -1) {
@ -205,6 +204,9 @@ public class GUIOverview extends AbstractGUI {
this.hopper.overview(player);
}));
}
}
inventory.setItem(13, item);
inventory.setItem(0, Methods.getBackgroundGlass(true));
inventory.setItem(1, Methods.getBackgroundGlass(true));

View File

@ -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;
@ -182,6 +186,7 @@ public class Hopper {
/**
* 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

View File

@ -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;

View File

@ -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);
}