mirror of
https://github.com/songoda/EpicHoppers.git
synced 2024-11-05 18:19:38 +01:00
Fixed dupe bug and fixed normal hoppers.
This commit is contained in:
parent
12ed362bfa
commit
17a6218b2c
@ -36,7 +36,10 @@ public class GUIAutoSellFilter extends CustomizableGui {
|
|||||||
setDefaultItem(null);
|
setDefaultItem(null);
|
||||||
setAcceptsItems(true);
|
setAcceptsItems(true);
|
||||||
|
|
||||||
setOnClose((event) -> compile());
|
setOnClose((event) -> {
|
||||||
|
hopper.setActivePlayer(null);
|
||||||
|
compile();
|
||||||
|
});
|
||||||
|
|
||||||
Filter filter = hopper.getFilter();
|
Filter filter = hopper.getFilter();
|
||||||
|
|
||||||
|
@ -18,7 +18,10 @@ public class GUICrafting extends CustomizableGui {
|
|||||||
super(EpicHoppers.getInstance(), "crafting");
|
super(EpicHoppers.getInstance(), "crafting");
|
||||||
setRows(3);
|
setRows(3);
|
||||||
setTitle(Methods.formatName(hopper.getLevel().getLevel()) + TextUtils.formatText(" &8-&f Crafting"));
|
setTitle(Methods.formatName(hopper.getLevel().getLevel()) + TextUtils.formatText(" &8-&f Crafting"));
|
||||||
setOnClose((event) -> setItem(module, hopper, player));
|
setOnClose((event) -> {
|
||||||
|
hopper.setActivePlayer(null);
|
||||||
|
setItem(module, hopper, player);
|
||||||
|
});
|
||||||
setAcceptsItems(true);
|
setAcceptsItems(true);
|
||||||
|
|
||||||
ItemStack glass1 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_1.getMaterial());
|
ItemStack glass1 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_1.getMaterial());
|
||||||
|
@ -37,7 +37,10 @@ public class GUIFilter extends CustomizableGui {
|
|||||||
setDefaultItem(null);
|
setDefaultItem(null);
|
||||||
setAcceptsItems(true);
|
setAcceptsItems(true);
|
||||||
|
|
||||||
setOnClose((event) -> compile());
|
setOnClose((event) -> {
|
||||||
|
hopper.setActivePlayer(null);
|
||||||
|
compile();
|
||||||
|
});
|
||||||
|
|
||||||
Filter filter = hopper.getFilter();
|
Filter filter = hopper.getFilter();
|
||||||
|
|
||||||
|
@ -46,7 +46,10 @@ public class GUIOverview extends CustomizableGui {
|
|||||||
setTitle(Methods.formatName(hopper.getLevel().getLevel()));
|
setTitle(Methods.formatName(hopper.getLevel().getLevel()));
|
||||||
runTask();
|
runTask();
|
||||||
constructGUI();
|
constructGUI();
|
||||||
this.setOnClose(action -> Bukkit.getScheduler().cancelTask(task));
|
this.setOnClose(action -> {
|
||||||
|
hopper.setActivePlayer(null);
|
||||||
|
Bukkit.getScheduler().cancelTask(task);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void constructGUI() {
|
private void constructGUI() {
|
||||||
@ -212,7 +215,10 @@ public class GUIOverview extends CustomizableGui {
|
|||||||
});
|
});
|
||||||
canTeleport = false;
|
canTeleport = false;
|
||||||
} else if (canFilter) {
|
} else if (canFilter) {
|
||||||
setButton("filter", slot, filter, (event) -> guiManager.showGUI(player, new GUIFilter(plugin, hopper, player)));
|
setButton("filter", slot, filter, (event) -> {
|
||||||
|
hopper.setActivePlayer(player);
|
||||||
|
guiManager.showGUI(player, new GUIFilter(plugin, hopper, player));
|
||||||
|
});
|
||||||
canFilter = false;
|
canFilter = false;
|
||||||
} else {
|
} else {
|
||||||
if (modules.isEmpty()) break;
|
if (modules.isEmpty()) break;
|
||||||
|
@ -41,6 +41,8 @@ public class GUISmeltable extends CustomizableGui {
|
|||||||
|
|
||||||
this.setOnPage((event) -> showPage());
|
this.setOnPage((event) -> showPage());
|
||||||
showPage();
|
showPage();
|
||||||
|
|
||||||
|
this.setOnClose((event) -> hopper.setActivePlayer(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
void showPage() {
|
void showPage() {
|
||||||
|
@ -44,6 +44,8 @@ public class Hopper {
|
|||||||
|
|
||||||
private int syncId = -1;
|
private int syncId = -1;
|
||||||
|
|
||||||
|
private Player activePlayer;
|
||||||
|
|
||||||
private final Map<String, Object> moduleCache = new HashMap<>();
|
private final Map<String, Object> moduleCache = new HashMap<>();
|
||||||
|
|
||||||
public Hopper(Location location) {
|
public Hopper(Location location) {
|
||||||
@ -67,9 +69,16 @@ public class Hopper {
|
|||||||
|
|
||||||
EpicHoppers instance = EpicHoppers.getInstance();
|
EpicHoppers instance = EpicHoppers.getInstance();
|
||||||
if (!player.hasPermission("epichoppers.overview")) return;
|
if (!player.hasPermission("epichoppers.overview")) return;
|
||||||
|
|
||||||
|
setActivePlayer(player);
|
||||||
guiManager.showGUI(player, new GUIOverview(instance, this, player));
|
guiManager.showGUI(player, new GUIOverview(instance, this, player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void forceClose() {
|
||||||
|
if (activePlayer != null)
|
||||||
|
activePlayer.closeInventory();
|
||||||
|
}
|
||||||
|
|
||||||
public void upgrade(Player player, CostType type) {
|
public void upgrade(Player player, CostType type) {
|
||||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||||
if (!plugin.getLevelManager().getLevels().containsKey(this.level.getLevel() + 1)) return;
|
if (!plugin.getLevelManager().getLevels().containsKey(this.level.getLevel() + 1)) return;
|
||||||
@ -327,4 +336,12 @@ public class Hopper {
|
|||||||
public void setId(int id) {
|
public void setId(int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Player getActivePlayer() {
|
||||||
|
return activePlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivePlayer(Player activePlayer) {
|
||||||
|
this.activePlayer = activePlayer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,6 +195,7 @@ public class ModuleAutoCrafting extends Module {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runButtonPress(Player player, Hopper hopper, ClickType type) {
|
public void runButtonPress(Player player, Hopper hopper, ClickType type) {
|
||||||
|
hopper.setActivePlayer(player);
|
||||||
EpicHoppers.getInstance().getGuiManager().showGUI(player, new GUICrafting(this, hopper, player));
|
EpicHoppers.getInstance().getGuiManager().showGUI(player, new GUICrafting(this, hopper, player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +145,7 @@ public class ModuleAutoSell extends Module {
|
|||||||
setNotifying(hopper, !isNotifying(hopper));
|
setNotifying(hopper, !isNotifying(hopper));
|
||||||
} else if (type == ClickType.SHIFT_LEFT || type == ClickType.SHIFT_RIGHT) {
|
} else if (type == ClickType.SHIFT_LEFT || type == ClickType.SHIFT_RIGHT) {
|
||||||
// Any shift click opens AutoSell filter configuration GUI
|
// Any shift click opens AutoSell filter configuration GUI
|
||||||
|
hopper.setActivePlayer(player);
|
||||||
EpicHoppers.getInstance().getGuiManager().showGUI(player, new GUIAutoSellFilter(EpicHoppers.getInstance(), hopper));
|
EpicHoppers.getInstance().getGuiManager().showGUI(player, new GUIAutoSellFilter(EpicHoppers.getInstance(), hopper));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,9 +89,10 @@ public class ModuleAutoSmelter extends Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void runButtonPress(Player player, Hopper hopper, ClickType type) {
|
public void runButtonPress(Player player, Hopper hopper, ClickType type) {
|
||||||
if (type == ClickType.LEFT)
|
if (type == ClickType.LEFT) {
|
||||||
|
hopper.setActivePlayer(player);
|
||||||
EpicHoppers.getInstance().getGuiManager().showGUI(player, new GUISmeltable(this, plugin, hopper));
|
EpicHoppers.getInstance().getGuiManager().showGUI(player, new GUISmeltable(this, plugin, hopper));
|
||||||
else if (type == ClickType.RIGHT)
|
} else if (type == ClickType.RIGHT)
|
||||||
toggleEnabled(hopper);
|
toggleEnabled(hopper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +105,8 @@ public class BlockListeners implements Listener {
|
|||||||
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), item);
|
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hopper.forceClose();
|
||||||
|
|
||||||
hopper.getFilter().getWhiteList().stream()
|
hopper.getFilter().getWhiteList().stream()
|
||||||
.filter(m -> m != null)
|
.filter(m -> m != null)
|
||||||
.forEach(m -> event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation(), m));
|
.forEach(m -> event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation(), m));
|
||||||
|
@ -80,8 +80,13 @@ public class InteractListeners implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!instance.getHopperManager().isHopper(event.getClickedBlock().getLocation())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PlayerData playerData = instance.getPlayerDataManager().getPlayerData(player);
|
PlayerData playerData = instance.getPlayerDataManager().getPlayerData(player);
|
||||||
|
|
||||||
|
|
||||||
if (playerData.getSyncType() == null) {
|
if (playerData.getSyncType() == null) {
|
||||||
if (event.getClickedBlock().getType() == Material.HOPPER) {
|
if (event.getClickedBlock().getType() == Material.HOPPER) {
|
||||||
if (Settings.ALLOW_NORMAL_HOPPERS.getBoolean() && !instance.getHopperManager().isHopper(event.getClickedBlock().getLocation()))
|
if (Settings.ALLOW_NORMAL_HOPPERS.getBoolean() && !instance.getHopperManager().isHopper(event.getClickedBlock().getLocation()))
|
||||||
|
Loading…
Reference in New Issue
Block a user