Added the ability for a distinction between epic and normal hoppers.

This commit is contained in:
Brianna 2020-01-17 15:47:28 -05:00
parent 26d9dbcbd3
commit addc99e966
5 changed files with 29 additions and 0 deletions

View File

@ -29,6 +29,14 @@ public class LevelManager {
}
}
public boolean isEpicHopper(ItemStack item) {
if (item.hasItemMeta() && item.getItemMeta().getDisplayName().contains(":")) {
return true;
} else {
return false;
}
}
public Level getLowestLevel() {
return registeredLevels.firstEntry().getValue();

View File

@ -6,6 +6,7 @@ import com.songoda.epichoppers.EpicHoppers;
import com.songoda.epichoppers.hopper.Hopper;
import com.songoda.epichoppers.hopper.HopperBuilder;
import com.songoda.epichoppers.hopper.levels.Level;
import com.songoda.epichoppers.settings.Settings;
import com.songoda.epichoppers.utils.Methods;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
@ -65,6 +66,9 @@ public class BlockListeners implements Listener {
ItemStack item = e.getItemInHand().clone();
if (Settings.ALLOW_NORMAL_HOPPERS.getBoolean() && !instance.getLevelManager().isEpicHopper(item))
return;
instance.getHopperManager().addHopper(
new HopperBuilder(e.getBlock())
.setLevel(instance.getLevelManager().getLevel(item))
@ -108,6 +112,9 @@ public class BlockListeners implements Listener {
if (instance.isLiquidtanks() && net.arcaniax.liquidtanks.object.LiquidTankAPI.isLiquidTank(block.getLocation()))
return;
if (Settings.ALLOW_NORMAL_HOPPERS.getBoolean() && !instance.getHopperManager().isHopper(block.getLocation()))
return;
Hopper hopper = instance.getHopperManager().getHopper(block);
Level level = hopper.getLevel();

View File

@ -5,6 +5,7 @@ import com.songoda.epichoppers.EpicHoppers;
import com.songoda.epichoppers.hopper.Hopper;
import com.songoda.epichoppers.hopper.levels.modules.Module;
import com.songoda.epichoppers.hopper.levels.modules.ModuleAutoCrafting;
import com.songoda.epichoppers.settings.Settings;
import com.songoda.epichoppers.utils.HopperDirection;
import com.songoda.epichoppers.utils.Methods;
import org.bukkit.Location;
@ -38,6 +39,9 @@ public class HopperListeners implements Listener {
Location sourceLocation = source.getHolder() instanceof BlockState ? ((BlockState) source.getHolder()).getLocation() : null;
Location destinationLocation = destination.getHolder() instanceof BlockState ? ((BlockState) destination.getHolder()).getLocation() : null;
if (Settings.ALLOW_NORMAL_HOPPERS.getBoolean() && !instance.getHopperManager().isHopper(sourceLocation))
return;
// Hopper minecarts should be able to take care of themselves
// Let EpicHoppers take over if the hopper is pointing down though
if (destination.getHolder() instanceof HopperMinecart
@ -65,6 +69,8 @@ public class HopperListeners implements Listener {
// Special cases when a hopper is picking up items
if (destination.getHolder() instanceof org.bukkit.block.Hopper) {
if (Settings.ALLOW_NORMAL_HOPPERS.getBoolean() && !instance.getHopperManager().isHopper(destinationLocation))
return;
// minecraft 1.8 doesn't have a method to get the hopper's location from the inventory, so we use the holder instead
Hopper toHopper = instance.getHopperManager().getHopper(destinationLocation);
final ItemStack toMove = event.getItem();

View File

@ -4,6 +4,7 @@ import com.songoda.epichoppers.EpicHoppers;
import com.songoda.epichoppers.hopper.Hopper;
import com.songoda.epichoppers.player.PlayerData;
import com.songoda.epichoppers.player.SyncType;
import com.songoda.epichoppers.settings.Settings;
import com.songoda.epichoppers.utils.Methods;
import com.songoda.epichoppers.utils.TeleportTrigger;
import org.bukkit.Bukkit;
@ -89,6 +90,10 @@ public class InteractListeners implements Listener {
if (event.getClickedBlock().getType() == Material.HOPPER) {
if (instance.isLiquidtanks() && net.arcaniax.liquidtanks.object.LiquidTankAPI.isLiquidTank(event.getClickedBlock().getLocation()))
return;
if (Settings.ALLOW_NORMAL_HOPPERS.getBoolean() && !instance.getHopperManager().isHopper(event.getClickedBlock().getLocation()))
return;
Hopper hopper = instance.getHopperManager().getHopper(event.getClickedBlock());
if (!player.getInventory().getItemInHand().getType().name().contains("PICKAXE")) {
hopper.overview(instance.getGuiManager(), player);

View File

@ -22,6 +22,9 @@ public class Settings {
public static final ConfigSetting UPGRADE_WITH_XP = new ConfigSetting(config, "Main.Upgrade With XP", true,
"Should you be able to upgrade hoppers with experience?");
public static final ConfigSetting ALLOW_NORMAL_HOPPERS = new ConfigSetting(config, "Main.Allow Normal Hoppers", false,
"Should natural hoppers not be epic hoppers?");
public static final ConfigSetting TELEPORT = new ConfigSetting(config, "Main.Allow Players To Teleport Through Hoppers", true,
"Should players be able to teleport through hoppers?");