Waterlogged support, more comparator updates

This commit is contained in:
Esophose 2019-06-03 22:31:45 -06:00
parent 6196d9b36d
commit c3685e8600
6 changed files with 40 additions and 10 deletions

View File

@ -3,6 +3,7 @@ package com.songoda.epichoppers.hopper.levels.modules;
import com.songoda.epichoppers.EpicHoppers;
import com.songoda.epichoppers.gui.GUICrafting;
import com.songoda.epichoppers.hopper.Hopper;
import com.songoda.epichoppers.tasks.HopTask;
import com.songoda.epichoppers.utils.Methods;
import com.songoda.epichoppers.utils.ServerVersion;
import org.bukkit.Bukkit;
@ -48,6 +49,8 @@ public class ModuleAutoCrafting implements Module {
if (cachedRecipes.get(hopper.getAutoCrafting()) == null) return;
boolean updateComparators = false;
top:
for (Recipe recipe : cachedRecipes.get(hopper.getAutoCrafting()).getRecipes()) {
if (!(recipe instanceof ShapedRecipe) && !(recipe instanceof ShapelessRecipe)) continue;
@ -95,8 +98,11 @@ public class ModuleAutoCrafting implements Module {
}
}
hopperInventory.addItem(recipe.getResult());
updateComparators = true;
}
if (updateComparators)
HopTask.updateAdjacentComparators(hopper.getLocation());
}
}

View File

@ -2,6 +2,7 @@ package com.songoda.epichoppers.hopper.levels.modules;
import com.songoda.epichoppers.EpicHoppers;
import com.songoda.epichoppers.hopper.Hopper;
import com.songoda.epichoppers.tasks.HopTask;
import com.songoda.epichoppers.utils.Methods;
import com.songoda.epichoppers.utils.ServerVersion;
import org.bukkit.Bukkit;
@ -41,6 +42,8 @@ public class ModuleAutoSell implements Module {
if (instance.getEconomy() == null) return;
boolean updateComparators = false;
List<String> list = instance.getConfig().getStringList("Main.AutoSell Prices");
for (String line : list) {
@ -55,11 +58,16 @@ public class ModuleAutoSell implements Module {
instance.getEconomy().deposit(Bukkit.getOfflinePlayer(hopper.getPlacedBy()), price * itemStack.getAmount());
hopperInventory.removeItem(itemStack);
updateComparators = true;
}
} catch (Exception ignored) {
}
}
hopper.setAutoSellTimer(timeOut);
if (updateComparators)
HopTask.updateAdjacentComparators(hopper.getLocation());
}
hopper.setAutoSellTimer(hopper.getAutoSellTimer() - hopperTickRate);
}

View File

@ -74,7 +74,17 @@ public class ModuleBlockBreak implements Module {
if (EpicHoppers.getInstance().isServerVersionAtLeast(ServerVersion.V1_9))
above.getWorld().spawnParticle(Particle.valueOf(EpicHoppers.getInstance().getConfig().getString("Main.BlockBreak Particle Type")), locationAbove, 15, xx, yy, zz);
boolean waterlogged = false;
if (EpicHoppers.getInstance().isServerVersionAtLeast(ServerVersion.V1_13)
&& above.getBlockData() instanceof org.bukkit.block.data.Waterlogged
&& ((org.bukkit.block.data.Waterlogged)above.getBlockData()).isWaterlogged()) {
waterlogged = true;
}
above.breakNaturally();
if (waterlogged)
above.setType(Material.WATER);
}
blockTick.remove(block);
}

View File

@ -2,10 +2,12 @@ package com.songoda.epichoppers.listeners;
import com.songoda.epichoppers.EpicHoppers;
import com.songoda.epichoppers.hopper.Hopper;
import com.songoda.epichoppers.utils.HopperDirection;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Chest;
import org.bukkit.block.DoubleChest;
import org.bukkit.block.ShulkerBox;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.minecart.HopperMinecart;
import org.bukkit.entity.minecart.StorageMinecart;
@ -31,15 +33,18 @@ public class HopperListeners implements Listener {
Inventory source = event.getSource();
Inventory destination = event.getDestination();
if (destination.getHolder() instanceof StorageMinecart || destination.getHolder() instanceof HopperMinecart) {
if (source.getHolder() instanceof org.bukkit.block.Hopper)
event.setCancelled(true);
// 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 && (!(source.getHolder() instanceof org.bukkit.block.Hopper)
|| HopperDirection.getDirection(((org.bukkit.block.Hopper)destination.getHolder()).getRawData()) != HopperDirection.DOWN))
return;
// Shulker boxes have a mind of their own and relentlessly steal items from hoppers
if (destination.getHolder() instanceof ShulkerBox || !(source.getHolder() instanceof org.bukkit.block.Hopper)) {
event.setCancelled(true);
return;
}
if (!(source.getHolder() instanceof org.bukkit.block.Hopper))
return;
if (instance.isLiquidtanks() && net.arcaniax.liquidtanks.object.LiquidTankAPI.isLiquidTank(event.getDestination().getLocation()))
return;

View File

@ -55,4 +55,4 @@ public class InventoryListeners implements Listener {
}
}
}
}
}

View File

@ -1,6 +1,7 @@
package com.songoda.epichoppers.utils;
import com.songoda.epichoppers.EpicHoppers;
import org.bukkit.Bukkit;
import java.sql.Connection;
import java.sql.DriverManager;
@ -44,8 +45,8 @@ public class MySQLDatabase {
")");
} catch (ClassNotFoundException | SQLException e) {
System.err.println("Database connection failed.");
System.err.println(e.getMessage());
Bukkit.getLogger().severe("Database connection failed.");
Bukkit.getLogger().severe(e.getMessage());
}
}