Merge branch 'development'

This commit is contained in:
Brianna 2020-01-17 15:54:37 -05:00
commit b6570ce41e
8 changed files with 42 additions and 3 deletions

View File

@ -2,7 +2,7 @@
<groupId>com.songoda</groupId>
<artifactId>EpicHoppers</artifactId>
<modelVersion>4.0.0</modelVersion>
<version>4.4.1</version>
<version>4.4.2</version>
<build>
<defaultGoal>clean install</defaultGoal>
<finalName>EpicHoppers-${project.version}</finalName>

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

@ -132,8 +132,11 @@ public class ModuleAutoCrafting extends Module {
cachedCrafting.remove(hopper);
}
Recipes getRecipes(ItemStack toCraft) {
private Recipes getRecipes(ItemStack toCraft) {
Recipes recipes = cachedRecipes.get(toCraft);
if (Settings.AUTOCRAFT_BLACKLIST.getStringList().stream()
.anyMatch(r -> r.equalsIgnoreCase(toCraft.getType().name())))
return new Recipes();
if (recipes == null) {
try {
recipes = new Recipes(Bukkit.getServer().getRecipesFor(toCraft));
@ -145,6 +148,7 @@ public class ModuleAutoCrafting extends Module {
while (recipeIterator.hasNext()) {
try {
Recipe recipe = recipeIterator.next();
ItemStack stack = recipe.getResult();
if (Methods.isSimilarMaterial(stack, toCraft))
recipes.addRecipe(recipe);

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?");
@ -63,6 +66,9 @@ public class Settings {
"Normally, crafting hoppers won't grab items that would fill that slot.",
"This option ejects items if that last slot is forcibly filled");
public static final ConfigSetting AUTOCRAFT_BLACKLIST = new ConfigSetting(config, "Main.AutoCraft Blacklist", Arrays.asList("BEDROCK", "EGG"),
"Anything listed here will not be able to be auto crafted.");
public static final ConfigSetting AUTOSELL_PRICES = new ConfigSetting(config, "Main.AutoSell Prices",
Arrays.asList("STONE,0.50", "COBBLESTONE,0.20", "IRON_ORE,0.35", "COAL_ORE,0.20"),
"These are the prices used by the auto sell module.");

View File

@ -31,7 +31,10 @@ public abstract class Storage {
* Dump HopperManager to file.
*/
for (Hopper hopper : new ArrayList<>(instance.getHopperManager().getHoppers().values())) {
if (hopper.getLevel() == null || hopper.getLocation() == null || hopper.getLevel() == instance.getLevelManager().getLowestLevel())
if (hopper.getLevel() == null
|| hopper.getLocation() == null
|| hopper.getLevel() == instance.getLevelManager().getLowestLevel()
&& (hopper.getLinkedBlocks() == null || hopper.getLinkedBlocks().isEmpty()))
continue;
String locationStr = Methods.serializeLocation(hopper.getLocation());