mirror of
https://github.com/songoda/EpicHoppers.git
synced 2024-11-29 13:45:24 +01:00
Fixes dupe
This commit is contained in:
parent
c46972e3d3
commit
7c02e0e37c
@ -21,6 +21,8 @@ public interface Hopper {
|
|||||||
|
|
||||||
UUID getLastPlayer();
|
UUID getLastPlayer();
|
||||||
|
|
||||||
|
void setLastPlayer(UUID uuid);
|
||||||
|
|
||||||
boolean isWalkOnTeleport();
|
boolean isWalkOnTeleport();
|
||||||
|
|
||||||
void setWalkOnTeleport(boolean walkOnTeleport);
|
void setWalkOnTeleport(boolean walkOnTeleport);
|
||||||
|
@ -2,6 +2,7 @@ package com.songoda.epichoppers.api.hopper;
|
|||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -18,4 +19,6 @@ public interface HopperManager {
|
|||||||
boolean isHopper(Location location);
|
boolean isHopper(Location location);
|
||||||
|
|
||||||
Map<Location, Hopper> getHoppers();
|
Map<Location, Hopper> getHoppers();
|
||||||
|
|
||||||
|
Hopper getHopperFromPlayer(Player player);
|
||||||
}
|
}
|
||||||
|
@ -208,10 +208,19 @@ public class InventoryListeners implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onClose(InventoryCloseEvent event) {
|
public void onClose(InventoryCloseEvent event) {
|
||||||
try {
|
try {
|
||||||
PlayerData playerData = instance.getPlayerDataManager().getPlayerData((Player)event.getPlayer());
|
Player player = (Player)event.getPlayer();
|
||||||
|
PlayerData playerData = instance.getPlayerDataManager().getPlayerData(player);
|
||||||
|
if (playerData.getInMenu() != MenuType.NOT_IN) {
|
||||||
|
Hopper hopper = instance.getHopperManager().getHopperFromPlayer(player);
|
||||||
|
hopper.setLastPlayer(null);
|
||||||
|
}
|
||||||
|
if (playerData.getInMenu() == MenuType.FILTER) {
|
||||||
|
Hopper hopper = instance.getHopperManager().getHopperFromPlayer(player);
|
||||||
|
((EHopper)hopper).compile(player);
|
||||||
|
}
|
||||||
playerData.setInMenu(MenuType.NOT_IN);
|
playerData.setInMenu(MenuType.NOT_IN);
|
||||||
if (playerData.getSyncType() == SyncType.FILTERED) {
|
if (playerData.getSyncType() == SyncType.FILTERED) {
|
||||||
((EHopper)playerData.getLastHopper()).compile((Player)event.getPlayer());
|
((EHopper)playerData.getLastHopper()).compile(player);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
|
@ -53,6 +53,10 @@ public class EHopper implements Hopper {
|
|||||||
EpicHoppersPlugin instance = EpicHoppersPlugin.getInstance();
|
EpicHoppersPlugin instance = EpicHoppersPlugin.getInstance();
|
||||||
if (!player.hasPermission("epichoppers.overview")) return;
|
if (!player.hasPermission("epichoppers.overview")) return;
|
||||||
|
|
||||||
|
if (lastPlayer != null) {
|
||||||
|
Bukkit.getPlayer(lastPlayer).closeInventory();
|
||||||
|
}
|
||||||
|
|
||||||
instance.getPlayerDataManager().getPlayerData(player).setLastHopper(this);
|
instance.getPlayerDataManager().getPlayerData(player).setLastHopper(this);
|
||||||
|
|
||||||
com.songoda.epichoppers.api.hopper.Level nextLevel = instance.getLevelManager().getHighestLevel().getLevel() > level.getLevel() ? instance.getLevelManager().getLevel(level.getLevel() + 1) : null;
|
com.songoda.epichoppers.api.hopper.Level nextLevel = instance.getLevelManager().getHighestLevel().getLevel() > level.getLevel() ? instance.getLevelManager().getLevel(level.getLevel() + 1) : null;
|
||||||
@ -176,6 +180,7 @@ public class EHopper implements Hopper {
|
|||||||
|
|
||||||
player.openInventory(i);
|
player.openInventory(i);
|
||||||
instance.getPlayerDataManager().getPlayerData(player).setInMenu(MenuType.OVERVIEW);
|
instance.getPlayerDataManager().getPlayerData(player).setInMenu(MenuType.OVERVIEW);
|
||||||
|
lastPlayer = player.getUniqueId();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
@ -302,6 +307,7 @@ public class EHopper implements Hopper {
|
|||||||
|
|
||||||
player.openInventory(i);
|
player.openInventory(i);
|
||||||
instance.getPlayerDataManager().getPlayerData(player).setInMenu(MenuType.FILTER);
|
instance.getPlayerDataManager().getPlayerData(player).setInMenu(MenuType.FILTER);
|
||||||
|
lastPlayer = player.getUniqueId();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Debugger.runReport(e);
|
Debugger.runReport(e);
|
||||||
}
|
}
|
||||||
@ -490,6 +496,11 @@ public class EHopper implements Hopper {
|
|||||||
return lastPlayer;
|
return lastPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLastPlayer(UUID uuid) {
|
||||||
|
lastPlayer = uuid;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWalkOnTeleport() {
|
public boolean isWalkOnTeleport() {
|
||||||
return walkOnTeleport;
|
return walkOnTeleport;
|
||||||
|
@ -4,8 +4,10 @@ import com.songoda.epichoppers.EpicHoppersPlugin;
|
|||||||
import com.songoda.epichoppers.api.hopper.Filter;
|
import com.songoda.epichoppers.api.hopper.Filter;
|
||||||
import com.songoda.epichoppers.api.hopper.Hopper;
|
import com.songoda.epichoppers.api.hopper.Hopper;
|
||||||
import com.songoda.epichoppers.api.hopper.HopperManager;
|
import com.songoda.epichoppers.api.hopper.HopperManager;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -48,6 +50,16 @@ public class EHopperManager implements HopperManager {
|
|||||||
return Collections.unmodifiableMap(registeredHoppers);
|
return Collections.unmodifiableMap(registeredHoppers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Hopper getHopperFromPlayer(Player player) {
|
||||||
|
for (Hopper hopper : registeredHoppers.values()) {
|
||||||
|
if (hopper.getLastPlayer() == player.getUniqueId()) {
|
||||||
|
return hopper;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private Location roundLocation(Location location) {
|
private Location roundLocation(Location location) {
|
||||||
location = location.clone();
|
location = location.clone();
|
||||||
location.setX(location.getBlockX());
|
location.setX(location.getBlockX());
|
||||||
|
Loading…
Reference in New Issue
Block a user