mirror of
https://github.com/songoda/EpicHoppers.git
synced 2024-11-06 02:29:42 +01:00
Merge branch 'development'
This commit is contained in:
commit
062f282922
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>EpicHoppers</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>4.6.17</version>
|
||||
<version>4.6.18</version>
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>EpicHoppers-${project.version}</finalName>
|
||||
|
@ -36,7 +36,10 @@ public class GUIAutoSellFilter extends CustomizableGui {
|
||||
setDefaultItem(null);
|
||||
setAcceptsItems(true);
|
||||
|
||||
setOnClose((event) -> compile());
|
||||
setOnClose((event) -> {
|
||||
hopper.setActivePlayer(null);
|
||||
compile();
|
||||
});
|
||||
|
||||
Filter filter = hopper.getFilter();
|
||||
|
||||
|
@ -18,7 +18,10 @@ public class GUICrafting extends CustomizableGui {
|
||||
super(EpicHoppers.getInstance(), "crafting");
|
||||
setRows(3);
|
||||
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);
|
||||
|
||||
ItemStack glass1 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_1.getMaterial());
|
||||
|
@ -37,7 +37,10 @@ public class GUIFilter extends CustomizableGui {
|
||||
setDefaultItem(null);
|
||||
setAcceptsItems(true);
|
||||
|
||||
setOnClose((event) -> compile());
|
||||
setOnClose((event) -> {
|
||||
hopper.setActivePlayer(null);
|
||||
compile();
|
||||
});
|
||||
|
||||
Filter filter = hopper.getFilter();
|
||||
|
||||
|
@ -46,7 +46,10 @@ public class GUIOverview extends CustomizableGui {
|
||||
setTitle(Methods.formatName(hopper.getLevel().getLevel()));
|
||||
runTask();
|
||||
constructGUI();
|
||||
this.setOnClose(action -> Bukkit.getScheduler().cancelTask(task));
|
||||
this.setOnClose(action -> {
|
||||
hopper.setActivePlayer(null);
|
||||
Bukkit.getScheduler().cancelTask(task);
|
||||
});
|
||||
}
|
||||
|
||||
private void constructGUI() {
|
||||
@ -212,7 +215,10 @@ public class GUIOverview extends CustomizableGui {
|
||||
});
|
||||
canTeleport = false;
|
||||
} 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;
|
||||
} else {
|
||||
if (modules.isEmpty()) break;
|
||||
|
@ -41,6 +41,8 @@ public class GUISmeltable extends CustomizableGui {
|
||||
|
||||
this.setOnPage((event) -> showPage());
|
||||
showPage();
|
||||
|
||||
this.setOnClose((event) -> hopper.setActivePlayer(null));
|
||||
}
|
||||
|
||||
void showPage() {
|
||||
|
@ -44,6 +44,8 @@ public class Hopper {
|
||||
|
||||
private int syncId = -1;
|
||||
|
||||
private Player activePlayer;
|
||||
|
||||
private final Map<String, Object> moduleCache = new HashMap<>();
|
||||
|
||||
public Hopper(Location location) {
|
||||
@ -67,9 +69,16 @@ public class Hopper {
|
||||
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
if (!player.hasPermission("epichoppers.overview")) return;
|
||||
|
||||
setActivePlayer(player);
|
||||
guiManager.showGUI(player, new GUIOverview(instance, this, player));
|
||||
}
|
||||
|
||||
public void forceClose() {
|
||||
if (activePlayer != null)
|
||||
activePlayer.closeInventory();
|
||||
}
|
||||
|
||||
public void upgrade(Player player, CostType type) {
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
if (!plugin.getLevelManager().getLevels().containsKey(this.level.getLevel() + 1)) return;
|
||||
@ -327,4 +336,12 @@ public class Hopper {
|
||||
public void setId(int 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
|
||||
public void runButtonPress(Player player, Hopper hopper, ClickType type) {
|
||||
hopper.setActivePlayer(player);
|
||||
EpicHoppers.getInstance().getGuiManager().showGUI(player, new GUICrafting(this, hopper, player));
|
||||
}
|
||||
|
||||
|
@ -145,6 +145,7 @@ public class ModuleAutoSell extends Module {
|
||||
setNotifying(hopper, !isNotifying(hopper));
|
||||
} else if (type == ClickType.SHIFT_LEFT || type == ClickType.SHIFT_RIGHT) {
|
||||
// Any shift click opens AutoSell filter configuration GUI
|
||||
hopper.setActivePlayer(player);
|
||||
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) {
|
||||
if (type == ClickType.LEFT)
|
||||
if (type == ClickType.LEFT) {
|
||||
hopper.setActivePlayer(player);
|
||||
EpicHoppers.getInstance().getGuiManager().showGUI(player, new GUISmeltable(this, plugin, hopper));
|
||||
else if (type == ClickType.RIGHT)
|
||||
} else if (type == ClickType.RIGHT)
|
||||
toggleEnabled(hopper);
|
||||
}
|
||||
|
||||
|
@ -105,6 +105,8 @@ public class BlockListeners implements Listener {
|
||||
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), item);
|
||||
}
|
||||
|
||||
hopper.forceClose();
|
||||
|
||||
hopper.getFilter().getWhiteList().stream()
|
||||
.filter(m -> m != null)
|
||||
.forEach(m -> event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation(), m));
|
||||
|
@ -80,8 +80,13 @@ public class InteractListeners implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!instance.getHopperManager().isHopper(event.getClickedBlock().getLocation())) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerData playerData = instance.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
|
||||
if (playerData.getSyncType() == null) {
|
||||
if (event.getClickedBlock().getType() == Material.HOPPER) {
|
||||
if (Settings.ALLOW_NORMAL_HOPPERS.getBoolean() && !instance.getHopperManager().isHopper(event.getClickedBlock().getLocation()))
|
||||
|
Loading…
Reference in New Issue
Block a user