mirror of
https://github.com/songoda/EpicHoppers.git
synced 2024-11-05 18:19:38 +01:00
Cleaned up some code.
This commit is contained in:
parent
4e7e6f2585
commit
c74c222e16
@ -22,7 +22,7 @@ import com.songoda.epichoppers.commands.CommandReload;
|
|||||||
import com.songoda.epichoppers.commands.CommandSettings;
|
import com.songoda.epichoppers.commands.CommandSettings;
|
||||||
import com.songoda.epichoppers.database.DataManager;
|
import com.songoda.epichoppers.database.DataManager;
|
||||||
import com.songoda.epichoppers.database.migrations._1_InitialMigration;
|
import com.songoda.epichoppers.database.migrations._1_InitialMigration;
|
||||||
import com.songoda.epichoppers.handlers.TeleportHandler;
|
import com.songoda.epichoppers.hopper.teleport.TeleportHandler;
|
||||||
import com.songoda.epichoppers.hopper.HopperManager;
|
import com.songoda.epichoppers.hopper.HopperManager;
|
||||||
import com.songoda.epichoppers.hopper.levels.Level;
|
import com.songoda.epichoppers.hopper.levels.Level;
|
||||||
import com.songoda.epichoppers.hopper.levels.LevelManager;
|
import com.songoda.epichoppers.hopper.levels.LevelManager;
|
||||||
|
@ -9,7 +9,7 @@ import com.songoda.epichoppers.hopper.Hopper;
|
|||||||
import com.songoda.epichoppers.hopper.HopperBuilder;
|
import com.songoda.epichoppers.hopper.HopperBuilder;
|
||||||
import com.songoda.epichoppers.hopper.ItemType;
|
import com.songoda.epichoppers.hopper.ItemType;
|
||||||
import com.songoda.epichoppers.hopper.LinkType;
|
import com.songoda.epichoppers.hopper.LinkType;
|
||||||
import com.songoda.epichoppers.utils.TeleportTrigger;
|
import com.songoda.epichoppers.hopper.teleport.TeleportTrigger;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
@ -14,7 +14,7 @@ import com.songoda.epichoppers.player.SyncType;
|
|||||||
import com.songoda.epichoppers.settings.Settings;
|
import com.songoda.epichoppers.settings.Settings;
|
||||||
import com.songoda.epichoppers.utils.CostType;
|
import com.songoda.epichoppers.utils.CostType;
|
||||||
import com.songoda.epichoppers.utils.Methods;
|
import com.songoda.epichoppers.utils.Methods;
|
||||||
import com.songoda.epichoppers.utils.TeleportTrigger;
|
import com.songoda.epichoppers.hopper.teleport.TeleportTrigger;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.songoda.epichoppers.hopper;
|
package com.songoda.epichoppers.hopper;
|
||||||
|
|
||||||
|
import com.songoda.core.compatibility.CompatibleParticleHandler;
|
||||||
|
import com.songoda.core.compatibility.CompatibleSound;
|
||||||
import com.songoda.core.compatibility.ServerVersion;
|
import com.songoda.core.compatibility.ServerVersion;
|
||||||
import com.songoda.core.gui.GuiManager;
|
import com.songoda.core.gui.GuiManager;
|
||||||
import com.songoda.core.hooks.EconomyManager;
|
import com.songoda.core.hooks.EconomyManager;
|
||||||
@ -7,14 +9,14 @@ import com.songoda.epichoppers.EpicHoppers;
|
|||||||
import com.songoda.epichoppers.api.events.HopperAccessEvent;
|
import com.songoda.epichoppers.api.events.HopperAccessEvent;
|
||||||
import com.songoda.epichoppers.gui.GUIOverview;
|
import com.songoda.epichoppers.gui.GUIOverview;
|
||||||
import com.songoda.epichoppers.hopper.levels.Level;
|
import com.songoda.epichoppers.hopper.levels.Level;
|
||||||
|
import com.songoda.epichoppers.hopper.teleport.TeleportTrigger;
|
||||||
import com.songoda.epichoppers.player.PlayerData;
|
import com.songoda.epichoppers.player.PlayerData;
|
||||||
|
import com.songoda.epichoppers.settings.Settings;
|
||||||
import com.songoda.epichoppers.utils.CostType;
|
import com.songoda.epichoppers.utils.CostType;
|
||||||
import com.songoda.epichoppers.utils.Methods;
|
import com.songoda.epichoppers.utils.Methods;
|
||||||
import com.songoda.epichoppers.utils.TeleportTrigger;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -123,20 +125,16 @@ public class Hopper {
|
|||||||
}
|
}
|
||||||
Location loc = location.clone().add(.5, .5, .5);
|
Location loc = location.clone().add(.5, .5, .5);
|
||||||
|
|
||||||
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) return;
|
CompatibleParticleHandler.spawnParticles(CompatibleParticleHandler.ParticleType.getParticle(Settings.UPGRADE_PARTICLE_TYPE.getString()),
|
||||||
|
loc, 100, .5, .5, .5);
|
||||||
player.getWorld().spawnParticle(org.bukkit.Particle.valueOf(plugin.getConfig().getString("Main.Upgrade Particle Type")), loc, 200, .5, .5, .5);
|
|
||||||
|
|
||||||
if (plugin.getLevelManager().getHighestLevel() != level) {
|
if (plugin.getLevelManager().getHighestLevel() != level) {
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 0.6F, 15.0F);
|
player.playSound(player.getLocation(), CompatibleSound.ENTITY_PLAYER_LEVELUP.getSound(), 0.6F, 15.0F);
|
||||||
} else {
|
} else {
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 2F, 25.0F);
|
player.playSound(player.getLocation(), CompatibleSound.ENTITY_PLAYER_LEVELUP.getSound(), 2F, 25.0F);
|
||||||
|
player.playSound(player.getLocation(), CompatibleSound.BLOCK_NOTE_BLOCK_CHIME.getSound(), 2F, 25.0F);
|
||||||
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) return;
|
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> player.playSound(player.getLocation(), CompatibleSound.BLOCK_NOTE_BLOCK_CHIME.getSound(), 1.2F, 35.0F), 5L);
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> player.playSound(player.getLocation(), CompatibleSound.BLOCK_NOTE_BLOCK_CHIME.getSound(), 1.8F, 35.0F), 10L);
|
||||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_CHIME, 2F, 25.0F);
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_CHIME, 1.2F, 35.0F), 5L);
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_CHIME, 1.8F, 35.0F), 10L);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +153,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") * level.getLinkAmount());
|
}, Settings.LINK_TIMEOUT.getLong() * level.getLinkAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void link(Block toLink, boolean filtered, Player player) {
|
public void link(Block toLink, boolean filtered, Player player) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.songoda.epichoppers.hopper;
|
package com.songoda.epichoppers.hopper;
|
||||||
|
|
||||||
import com.songoda.epichoppers.hopper.levels.Level;
|
import com.songoda.epichoppers.hopper.levels.Level;
|
||||||
import com.songoda.epichoppers.utils.TeleportTrigger;
|
import com.songoda.epichoppers.hopper.teleport.TeleportTrigger;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package com.songoda.epichoppers.handlers;
|
package com.songoda.epichoppers.hopper.teleport;
|
||||||
|
|
||||||
|
import com.songoda.core.compatibility.CompatibleSound;
|
||||||
import com.songoda.core.compatibility.ServerVersion;
|
import com.songoda.core.compatibility.ServerVersion;
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppers;
|
||||||
import com.songoda.epichoppers.hopper.Hopper;
|
import com.songoda.epichoppers.hopper.Hopper;
|
||||||
|
import com.songoda.epichoppers.settings.Settings;
|
||||||
import com.songoda.epichoppers.utils.Methods;
|
import com.songoda.epichoppers.utils.Methods;
|
||||||
import com.songoda.epichoppers.utils.TeleportTrigger;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -24,43 +24,45 @@ public class TeleportHandler {
|
|||||||
|
|
||||||
private final Map<UUID, Long> lastTeleports = new HashMap<>();
|
private final Map<UUID, Long> lastTeleports = new HashMap<>();
|
||||||
|
|
||||||
private EpicHoppers plugin;
|
private final EpicHoppers plugin;
|
||||||
|
|
||||||
public TeleportHandler(EpicHoppers plugin) {
|
public TeleportHandler(EpicHoppers plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, this::teleportRunner, 0, plugin.getConfig().getLong("Main.Amount of Ticks Between Teleport"));
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, this::teleportRunner, 0,
|
||||||
|
Settings.TELEPORT_TICKS.getLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void teleportRunner() {
|
private void teleportRunner() {
|
||||||
if (plugin.getHopperManager().isReady()) {
|
if (!plugin.getHopperManager().isReady())
|
||||||
for (World world : Bukkit.getWorlds()) {
|
return;
|
||||||
for (Entity entity : world.getEntities()) {
|
|
||||||
if (!(entity instanceof LivingEntity) || entity.getType() == EntityType.ARMOR_STAND)
|
for (World world : Bukkit.getWorlds()) {
|
||||||
|
for (Entity entity : world.getEntities()) {
|
||||||
|
if (!(entity instanceof LivingEntity) || entity.getType() == EntityType.ARMOR_STAND)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!Settings.TELEPORT.getBoolean()
|
||||||
|
|| (entity instanceof Player && !entity.hasPermission("EpicHoppers.Teleport")))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Location location = entity.getLocation().getBlock().getRelative(BlockFace.DOWN).getLocation();
|
||||||
|
|
||||||
|
if (!this.plugin.getHopperManager().isHopper(location))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Hopper hopper = this.plugin.getHopperManager().getHopper(location);
|
||||||
|
|
||||||
|
if (hopper.getTeleportTrigger() != TeleportTrigger.WALK_ON)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (this.lastTeleports.containsKey(entity.getUniqueId())) {
|
||||||
|
long duration = (new Date()).getTime() - new Date(this.lastTeleports.get(entity.getUniqueId())).getTime();
|
||||||
|
if (duration <= 5 * 1000)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!this.plugin.getConfig().getBoolean("Main.Allow Players To Teleport Through Hoppers")
|
|
||||||
|| (entity instanceof Player && !entity.hasPermission("EpicHoppers.Teleport")))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Location location = entity.getLocation().getBlock().getRelative(BlockFace.DOWN).getLocation();
|
|
||||||
|
|
||||||
if (!this.plugin.getHopperManager().isHopper(location))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Hopper hopper = this.plugin.getHopperManager().getHopper(location);
|
|
||||||
|
|
||||||
if (hopper.getTeleportTrigger() != TeleportTrigger.WALK_ON)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (this.lastTeleports.containsKey(entity.getUniqueId())) {
|
|
||||||
long duration = (new Date()).getTime() - new Date(this.lastTeleports.get(entity.getUniqueId())).getTime();
|
|
||||||
if (duration <= 5 * 1000)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.tpEntity(entity, hopper);
|
|
||||||
this.lastTeleports.put(entity.getUniqueId(), System.currentTimeMillis());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.tpEntity(entity, hopper);
|
||||||
|
this.lastTeleports.put(entity.getUniqueId(), System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,7 +81,6 @@ public class TeleportHandler {
|
|||||||
*
|
*
|
||||||
* @param lastHopper The previous hopper found in the chain
|
* @param lastHopper The previous hopper found in the chain
|
||||||
* @param currentChainLength The current length of the chain, used to cap the search length
|
* @param currentChainLength The current length of the chain, used to cap the search length
|
||||||
*
|
|
||||||
* @return The hopper at the end of the chain (or up to 15 in depth)
|
* @return The hopper at the end of the chain (or up to 15 in depth)
|
||||||
*/
|
*/
|
||||||
private Hopper getChain(Hopper lastHopper, int currentChainLength) {
|
private Hopper getChain(Hopper lastHopper, int currentChainLength) {
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.songoda.epichoppers.hopper.teleport;
|
||||||
|
|
||||||
|
public enum TeleportTrigger {
|
||||||
|
|
||||||
|
DISABLED, WALK_ON, SNEAK
|
||||||
|
|
||||||
|
}
|
@ -75,7 +75,7 @@ public class BlockListeners implements Listener {
|
|||||||
if (num > limit)
|
if (num > limit)
|
||||||
limit = num;
|
limit = num;
|
||||||
}
|
}
|
||||||
if (limit == -1) limit = plugin.getConfig().getInt("Main.Max Hoppers Per Chunk");
|
if (limit == -1) limit = Settings.MAX_CHUNK.getInt();
|
||||||
return limit;
|
return limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,10 +25,10 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
*/
|
*/
|
||||||
public class HopperListeners implements Listener {
|
public class HopperListeners implements Listener {
|
||||||
|
|
||||||
private final EpicHoppers instance;
|
private final EpicHoppers plugin;
|
||||||
|
|
||||||
public HopperListeners(EpicHoppers instance) {
|
public HopperListeners(EpicHoppers plugin) {
|
||||||
this.instance = instance;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: InventoryMoveItemEvent for filters
|
// todo: InventoryMoveItemEvent for filters
|
||||||
@ -40,7 +40,7 @@ public class HopperListeners implements Listener {
|
|||||||
Location sourceLocation = source.getHolder() instanceof BlockState ? ((BlockState) source.getHolder()).getLocation() : null;
|
Location sourceLocation = source.getHolder() instanceof BlockState ? ((BlockState) source.getHolder()).getLocation() : null;
|
||||||
Location destinationLocation = destination.getHolder() instanceof BlockState ? ((BlockState) destination.getHolder()).getLocation() : null;
|
Location destinationLocation = destination.getHolder() instanceof BlockState ? ((BlockState) destination.getHolder()).getLocation() : null;
|
||||||
|
|
||||||
if (sourceLocation != null && Settings.ALLOW_NORMAL_HOPPERS.getBoolean() && !instance.getHopperManager().isHopper(sourceLocation))
|
if (sourceLocation != null && Settings.ALLOW_NORMAL_HOPPERS.getBoolean() && !plugin.getHopperManager().isHopper(sourceLocation))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Hopper minecarts should be able to take care of themselves
|
// Hopper minecarts should be able to take care of themselves
|
||||||
@ -66,14 +66,14 @@ public class HopperListeners implements Listener {
|
|||||||
|
|
||||||
// Special cases when a hopper is picking up items
|
// Special cases when a hopper is picking up items
|
||||||
if (destination.getHolder() instanceof org.bukkit.block.Hopper) {
|
if (destination.getHolder() instanceof org.bukkit.block.Hopper) {
|
||||||
if (destinationLocation != null && Settings.ALLOW_NORMAL_HOPPERS.getBoolean() && !instance.getHopperManager().isHopper(destinationLocation))
|
if (destinationLocation != null && Settings.ALLOW_NORMAL_HOPPERS.getBoolean() && !plugin.getHopperManager().isHopper(destinationLocation))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Calling HopperManager#getHopper() automatically creates a new Hopper and we don't need to iterate over default-valued hoppers
|
// Calling HopperManager#getHopper() automatically creates a new Hopper and we don't need to iterate over default-valued hoppers
|
||||||
if (!instance.getHopperManager().isHopper(destinationLocation))
|
if (!plugin.getHopperManager().isHopper(destinationLocation))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Hopper toHopper = instance.getHopperManager().getHopper(destinationLocation);
|
Hopper toHopper = plugin.getHopperManager().getHopper(destinationLocation);
|
||||||
// minecraft 1.8 doesn't have a method to get the hopper's location from the inventory, so we use the holder instead
|
// minecraft 1.8 doesn't have a method to get the hopper's location from the inventory, so we use the holder instead
|
||||||
final ItemStack toMove = event.getItem();
|
final ItemStack toMove = event.getItem();
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import com.songoda.epichoppers.hopper.Hopper;
|
|||||||
import com.songoda.epichoppers.player.PlayerData;
|
import com.songoda.epichoppers.player.PlayerData;
|
||||||
import com.songoda.epichoppers.player.SyncType;
|
import com.songoda.epichoppers.player.SyncType;
|
||||||
import com.songoda.epichoppers.settings.Settings;
|
import com.songoda.epichoppers.settings.Settings;
|
||||||
import com.songoda.epichoppers.utils.TeleportTrigger;
|
import com.songoda.epichoppers.hopper.teleport.TeleportTrigger;
|
||||||
import com.songoda.skyblock.SkyBlock;
|
import com.songoda.skyblock.SkyBlock;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -27,26 +27,26 @@ import org.bukkit.inventory.InventoryHolder;
|
|||||||
*/
|
*/
|
||||||
public class InteractListeners implements Listener {
|
public class InteractListeners implements Listener {
|
||||||
|
|
||||||
private final EpicHoppers instance;
|
private final EpicHoppers plugin;
|
||||||
|
|
||||||
public InteractListeners(EpicHoppers instance) {
|
public InteractListeners(EpicHoppers plugin) {
|
||||||
this.instance = instance;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerToggleSneakEvent(PlayerToggleSneakEvent event) {
|
public void onPlayerToggleSneakEvent(PlayerToggleSneakEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (player.isSneaking() && instance.getHopperManager().isReady()) {
|
if (player.isSneaking() && plugin.getHopperManager().isReady()) {
|
||||||
Location location = player.getLocation().getBlock().getRelative(BlockFace.SELF).getLocation();
|
Location location = player.getLocation().getBlock().getRelative(BlockFace.SELF).getLocation();
|
||||||
Location down = location.getBlock().getRelative(BlockFace.DOWN).getLocation();
|
Location down = location.getBlock().getRelative(BlockFace.DOWN).getLocation();
|
||||||
if (instance.getHopperManager().isHopper(down)) {
|
if (plugin.getHopperManager().isHopper(down)) {
|
||||||
Hopper hopper = instance.getHopperManager().getHopper(down);
|
Hopper hopper = plugin.getHopperManager().getHopper(down);
|
||||||
if (hopper.getTeleportTrigger() == TeleportTrigger.SNEAK)
|
if (hopper.getTeleportTrigger() == TeleportTrigger.SNEAK)
|
||||||
instance.getTeleportHandler().tpEntity(player, hopper);
|
plugin.getTeleportHandler().tpEntity(player, hopper);
|
||||||
} else if (instance.getHopperManager().isHopper(location)) {
|
} else if (plugin.getHopperManager().isHopper(location)) {
|
||||||
Hopper hopper = instance.getHopperManager().getHopper(location);
|
Hopper hopper = plugin.getHopperManager().getHopper(location);
|
||||||
if (hopper.getTeleportTrigger() == TeleportTrigger.SNEAK)
|
if (hopper.getTeleportTrigger() == TeleportTrigger.SNEAK)
|
||||||
instance.getTeleportHandler().tpEntity(player, hopper);
|
plugin.getTeleportHandler().tpEntity(player, hopper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ public class InteractListeners implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (Settings.USE_PROTECTION_PLUGINS.getBoolean() && !ProtectionManager.canInteract(player, event.getClickedBlock().getLocation())) {
|
if (Settings.USE_PROTECTION_PLUGINS.getBoolean() && !ProtectionManager.canInteract(player, event.getClickedBlock().getLocation())) {
|
||||||
player.sendMessage(instance.getLocale().getMessage("event.general.protected").getPrefixedMessage());
|
player.sendMessage(plugin.getLocale().getMessage("event.general.protected").getPrefixedMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,22 +80,22 @@ public class InteractListeners implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerData playerData = instance.getPlayerDataManager().getPlayerData(player);
|
PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player);
|
||||||
|
|
||||||
if (playerData.getSyncType() == null) {
|
if (playerData.getSyncType() == null) {
|
||||||
if (event.getClickedBlock().getType() == Material.HOPPER) {
|
if (event.getClickedBlock().getType() == Material.HOPPER) {
|
||||||
if (!instance.getHopperManager().isReady()) {
|
if (!plugin.getHopperManager().isReady()) {
|
||||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.notready").getMessage());
|
player.sendMessage(plugin.getLocale().getMessage("event.hopper.notready").getMessage());
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.ALLOW_NORMAL_HOPPERS.getBoolean() && !instance.getHopperManager().isHopper(event.getClickedBlock().getLocation()))
|
if (Settings.ALLOW_NORMAL_HOPPERS.getBoolean() && !plugin.getHopperManager().isHopper(event.getClickedBlock().getLocation()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Hopper hopper = instance.getHopperManager().getHopper(event.getClickedBlock());
|
Hopper hopper = plugin.getHopperManager().getHopper(event.getClickedBlock());
|
||||||
if (!player.getInventory().getItemInHand().getType().name().contains("PICKAXE")) {
|
if (!player.getInventory().getItemInHand().getType().name().contains("PICKAXE")) {
|
||||||
hopper.overview(instance.getGuiManager(), player);
|
hopper.overview(plugin.getGuiManager(), player);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -103,13 +103,15 @@ public class InteractListeners implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getClickedBlock().getState() instanceof InventoryHolder || (event.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)
|
||||||
|
&& Settings.ENDERCHESTS.getBoolean())) {
|
||||||
Hopper hopper = playerData.getLastHopper();
|
Hopper hopper = playerData.getLastHopper();
|
||||||
if (event.getClickedBlock().getLocation().equals(playerData.getLastHopper().getLocation())) {
|
if (event.getClickedBlock().getLocation().equals(playerData.getLastHopper().getLocation())) {
|
||||||
if (!hopper.getLinkedBlocks().isEmpty())
|
if (!hopper.getLinkedBlocks().isEmpty())
|
||||||
instance.getLocale().getMessage("event.hopper.syncfinish").sendPrefixedMessage(player);
|
plugin.getLocale().getMessage("event.hopper.syncfinish").sendPrefixedMessage(player);
|
||||||
else
|
else
|
||||||
instance.getLocale().getMessage("event.hopper.synccanceled").sendPrefixedMessage(player);
|
plugin.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(event.getClickedBlock(), playerData.getSyncType() == SyncType.FILTERED, player);
|
hopper.link(event.getClickedBlock(), playerData.getSyncType() == SyncType.FILTERED, player);
|
||||||
|
@ -36,7 +36,7 @@ public class Settings {
|
|||||||
public static final ConfigSetting ENDERCHESTS = new ConfigSetting(config, "Main.Support Enderchests", true,
|
public static final ConfigSetting ENDERCHESTS = new ConfigSetting(config, "Main.Support Enderchests", true,
|
||||||
"Should hoppers dump items into a player enderchests?");
|
"Should hoppers dump items into a player enderchests?");
|
||||||
|
|
||||||
public static final ConfigSetting PARTICLE_TYPE = new ConfigSetting(config, "Main.Upgrade Particle Type", "SPELL_WITCH",
|
public static final ConfigSetting UPGRADE_PARTICLE_TYPE = new ConfigSetting(config, "Main.Upgrade Particle Type", "SPELL_WITCH",
|
||||||
"The type of particle shown when a hopper is upgraded.");
|
"The type of particle shown when a hopper is upgraded.");
|
||||||
|
|
||||||
public static final ConfigSetting HOP_TICKS = new ConfigSetting(config, "Main.Amount of Ticks Between Hops", 8L,
|
public static final ConfigSetting HOP_TICKS = new ConfigSetting(config, "Main.Amount of Ticks Between Hops", 8L,
|
||||||
@ -52,7 +52,7 @@ public class Settings {
|
|||||||
"The cooldown between teleports. It prevents players",
|
"The cooldown between teleports. It prevents players",
|
||||||
"from getting stuck in a teleport loop.");
|
"from getting stuck in a teleport loop.");
|
||||||
|
|
||||||
public static final ConfigSetting SYNC_TIMEOUT = new ConfigSetting(config, "Main.Timeout When Syncing Hoppers", 300L,
|
public static final ConfigSetting LINK_TIMEOUT = new ConfigSetting(config, "Main.Timeout When Syncing Hoppers", 300L,
|
||||||
"The amount of time in ticks a player has between hitting the hopper",
|
"The amount of time in ticks a player has between hitting the hopper",
|
||||||
"Link button and performing the link. When the time is up the link event is canceled.");
|
"Link button and performing the link. When the time is up the link event is canceled.");
|
||||||
|
|
||||||
|
@ -1,18 +1,7 @@
|
|||||||
package com.songoda.epichoppers.utils;
|
package com.songoda.epichoppers.utils;
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a cost type when making a purchase from EpicSpawners
|
|
||||||
*/
|
|
||||||
public enum CostType {
|
public enum CostType {
|
||||||
|
|
||||||
/**
|
ECONOMY, EXPERIENCE
|
||||||
* A purchase made with an economy balance (generally an implementation of Vault)
|
|
||||||
*/
|
|
||||||
ECONOMY,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A purchase made with a player's experience levels
|
|
||||||
*/
|
|
||||||
EXPERIENCE
|
|
||||||
|
|
||||||
}
|
}
|
@ -11,12 +11,12 @@ public enum HopperDirection {
|
|||||||
WEST(4, 12, -1, 0, 0),
|
WEST(4, 12, -1, 0, 0),
|
||||||
EAST(5, 13, 1, 0, 0);
|
EAST(5, 13, 1, 0, 0);
|
||||||
|
|
||||||
private int unpowered;
|
private final int unpowered;
|
||||||
private int powered;
|
private final int powered;
|
||||||
|
|
||||||
private int x;
|
private final int x;
|
||||||
private int y;
|
private final int y;
|
||||||
private int z;
|
private final int z;
|
||||||
|
|
||||||
HopperDirection(int unpowered, int powered, int x, int y, int z) {
|
HopperDirection(int unpowered, int powered, int x, int y, int z) {
|
||||||
this.unpowered = unpowered;
|
this.unpowered = unpowered;
|
||||||
@ -28,10 +28,9 @@ public enum HopperDirection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static HopperDirection getDirection(int value) {
|
public static HopperDirection getDirection(int value) {
|
||||||
for (HopperDirection hopperDirection : HopperDirection.values()) {
|
for (HopperDirection hopperDirection : HopperDirection.values())
|
||||||
if (hopperDirection.getPowered() == value
|
if (hopperDirection.getPowered() == value || hopperDirection.getUnpowered() == value)
|
||||||
|| hopperDirection.getUnpowered() == value) return hopperDirection;
|
return hopperDirection;
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
package com.songoda.epichoppers.utils;
|
|
||||||
|
|
||||||
public enum TeleportTrigger {
|
|
||||||
DISABLED,
|
|
||||||
WALK_ON,
|
|
||||||
SNEAK
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user