Merge branch 'development'

This commit is contained in:
Brianna 2019-10-15 13:51:47 -04:00
commit b8ee217f25
4 changed files with 30 additions and 25 deletions

View File

@ -4,7 +4,7 @@ stages:
variables: variables:
name: "EpicHoppers" name: "EpicHoppers"
path: "/builds/$CI_PROJECT_PATH" path: "/builds/$CI_PROJECT_PATH"
version: "4.3.4" version: "4.3.5"
build: build:
stage: build stage: build

View File

@ -165,14 +165,16 @@ public class GUIOverview extends Gui {
if (ii == 0) { if (ii == 0) {
setButton(slot, hook, setButton(slot, hook,
(event) -> { (event) -> {
hopper.clearLinkedBlocks();
if (event.clickType == ClickType.RIGHT) {
plugin.getLocale().getMessage("event.hopper.desync").sendPrefixedMessage(player);
} else {
if (hopper.getLastPlayerOpened() != null && !hopper.getLastPlayerOpened().equals(player.getUniqueId())) { if (hopper.getLastPlayerOpened() != null && !hopper.getLastPlayerOpened().equals(player.getUniqueId())) {
plugin.getLocale().getMessage("event.hopper.syncdidnotplace").sendPrefixedMessage(player); plugin.getLocale().getMessage("event.hopper.syncdidnotplace").sendPrefixedMessage(player);
return; return;
} }
hopper.clearLinkedBlocks();
if (event.clickType == ClickType.RIGHT) {
plugin.getLocale().getMessage("event.hopper.desync").sendPrefixedMessage(player);
constructGUI();
return;
} else {
plugin.getPlayerDataManager().getPlayerData(player).setSyncType(SyncType.REGULAR); plugin.getPlayerDataManager().getPlayerData(player).setSyncType(SyncType.REGULAR);
plugin.getLocale().getMessage("event.hopper.syncnext").sendPrefixedMessage(player); plugin.getLocale().getMessage("event.hopper.syncnext").sendPrefixedMessage(player);
@ -257,6 +259,9 @@ public class GUIOverview extends Gui {
} }
private void runTask() { private void runTask() {
task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, this::constructGUI, 5L, 5L); task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
if (inventory.getViewers().size() != 0)
this.constructGUI();
}, 5L, 5L);
} }
} }

View File

@ -126,7 +126,7 @@ public class Hopper {
instance.getLocale().getMessage("event.hopper.synctimeout").sendPrefixedMessage(player); instance.getLocale().getMessage("event.hopper.synctimeout").sendPrefixedMessage(player);
playerData.setSyncType(null); playerData.setSyncType(null);
} }
}, instance.getConfig().getLong("Main.Timeout When Syncing Hoppers")); }, instance.getConfig().getLong("Main.Timeout When Syncing Hoppers") * level.getLinkAmount());
} }
public void link(Block toLink, boolean filtered, Player player) { public void link(Block toLink, boolean filtered, Player player) {

View File

@ -6,6 +6,7 @@ import com.songoda.epichoppers.player.PlayerData;
import com.songoda.epichoppers.player.SyncType; import com.songoda.epichoppers.player.SyncType;
import com.songoda.epichoppers.utils.Methods; import com.songoda.epichoppers.utils.Methods;
import com.songoda.epichoppers.utils.TeleportTrigger; import com.songoda.epichoppers.utils.TeleportTrigger;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
@ -49,18 +50,18 @@ public class InteractListeners implements Listener {
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockInteract(PlayerInteractEvent e) { public void onBlockInteract(PlayerInteractEvent event) {
Player player = e.getPlayer(); Player player = event.getPlayer();
if (e.getAction() != Action.LEFT_CLICK_BLOCK if (event.getAction() != Action.LEFT_CLICK_BLOCK
|| e.getClickedBlock() == null || event.getClickedBlock() == null
|| player.isSneaking() || player.isSneaking()
|| !player.hasPermission("EpicHoppers.overview") || !player.hasPermission("EpicHoppers.overview")
|| !(e.getClickedBlock().getState() instanceof InventoryHolder || e.getClickedBlock().getType().equals(Material.ENDER_CHEST))) { || !(event.getClickedBlock().getState() instanceof InventoryHolder || event.getClickedBlock().getType().equals(Material.ENDER_CHEST))) {
return; return;
} }
if (e.getClickedBlock().getType() == Material.CHEST && Methods.isSync(player)) { if (event.getClickedBlock().getType() == Material.CHEST && Methods.isSync(player)) {
ItemStack item = e.getPlayer().getInventory().getItemInHand(); ItemStack item = event.getPlayer().getInventory().getItemInHand();
boolean isLinked = false; boolean isLinked = false;
for (String lore : item.getItemMeta().getLore()) { for (String lore : item.getItemMeta().getLore()) {
@ -76,41 +77,40 @@ public class InteractListeners implements Listener {
} else { } else {
instance.getLocale().getMessage("event.hopper.syncchest") instance.getLocale().getMessage("event.hopper.syncchest")
.processPlaceholder("name", item.getType().toString()).sendPrefixedMessage(player); .processPlaceholder("name", item.getType().toString()).sendPrefixedMessage(player);
instance.enchantmentHandler.createSyncTouch(item, e.getClickedBlock()); instance.enchantmentHandler.createSyncTouch(item, event.getClickedBlock());
} }
e.setCancelled(true); event.setCancelled(true);
return; return;
} }
PlayerData playerData = instance.getPlayerDataManager().getPlayerData(player); PlayerData playerData = instance.getPlayerDataManager().getPlayerData(player);
if (playerData.getSyncType() == null) { if (playerData.getSyncType() == null) {
if (e.getClickedBlock().getType() == Material.HOPPER) { if (event.getClickedBlock().getType() == Material.HOPPER) {
if (instance.isLiquidtanks() && net.arcaniax.liquidtanks.object.LiquidTankAPI.isLiquidTank(e.getClickedBlock().getLocation())) if (instance.isLiquidtanks() && net.arcaniax.liquidtanks.object.LiquidTankAPI.isLiquidTank(event.getClickedBlock().getLocation()))
return; return;
Hopper hopper = instance.getHopperManager().getHopper(e.getClickedBlock()); Hopper hopper = instance.getHopperManager().getHopper(event.getClickedBlock());
playerData.setLastHopper(hopper);
if (!player.getInventory().getItemInHand().getType().name().contains("PICKAXE")) { if (!player.getInventory().getItemInHand().getType().name().contains("PICKAXE")) {
hopper.overview(instance.getGuiManager(), player); hopper.overview(instance.getGuiManager(), player);
e.setCancelled(true); event.setCancelled(true);
return; return;
} }
} }
return; return;
} }
if (e.getClickedBlock().getState() instanceof InventoryHolder || (e.getClickedBlock().getType().equals(Material.ENDER_CHEST) && instance.getConfig().getBoolean("Main.Support Enderchests"))) { if (event.getClickedBlock().getState() instanceof InventoryHolder || (event.getClickedBlock().getType().equals(Material.ENDER_CHEST) && instance.getConfig().getBoolean("Main.Support Enderchests"))) {
Hopper hopper = playerData.getLastHopper(); Hopper hopper = playerData.getLastHopper();
if (playerData.getSyncType() != null && e.getClickedBlock().getLocation().equals(playerData.getLastHopper().getLocation())) { if (event.getClickedBlock().getLocation().equals(playerData.getLastHopper().getLocation())) {
if (hopper.getLinkedBlocks().size() != 0) if (hopper.getLinkedBlocks().size() != 0)
instance.getLocale().getMessage("event.hopper.syncfinish").sendPrefixedMessage(player); instance.getLocale().getMessage("event.hopper.syncfinish").sendPrefixedMessage(player);
else else
instance.getLocale().getMessage("event.hopper.synccanceled").sendPrefixedMessage(player); instance.getLocale().getMessage("event.hopper.synccanceled").sendPrefixedMessage(player);
hopper.cancelSync(player); hopper.cancelSync(player);
} else if (playerData.getSyncType() != null) { } else if (playerData.getSyncType() != null) {
hopper.link(e.getClickedBlock(), playerData.getSyncType() == SyncType.FILTERED, player); hopper.link(event.getClickedBlock(), playerData.getSyncType() == SyncType.FILTERED, player);
} }
e.setCancelled(true); event.setCancelled(true);
int amountLinked = hopper.getLevel().getLinkAmount(); int amountLinked = hopper.getLevel().getLinkAmount();
if (hopper.getLinkedBlocks().size() >= amountLinked) { if (hopper.getLinkedBlocks().size() >= amountLinked) {
playerData.setSyncType(null); playerData.setSyncType(null);