Merge branch 'development'

This commit is contained in:
Fernando Pettinelli 2021-02-01 20:50:49 -03:00
commit 062f282922
12 changed files with 52 additions and 8 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -41,6 +41,8 @@ public class GUISmeltable extends CustomizableGui {
this.setOnPage((event) -> showPage());
showPage();
this.setOnClose((event) -> hopper.setActivePlayer(null));
}
void showPage() {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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()))