mirror of
https://github.com/songoda/EpicHoppers.git
synced 2025-02-19 13:21:34 +01:00
Waterlogged support, more comparator updates
This commit is contained in:
parent
6196d9b36d
commit
c3685e8600
@ -3,6 +3,7 @@ package com.songoda.epichoppers.hopper.levels.modules;
|
|||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppers;
|
||||||
import com.songoda.epichoppers.gui.GUICrafting;
|
import com.songoda.epichoppers.gui.GUICrafting;
|
||||||
import com.songoda.epichoppers.hopper.Hopper;
|
import com.songoda.epichoppers.hopper.Hopper;
|
||||||
|
import com.songoda.epichoppers.tasks.HopTask;
|
||||||
import com.songoda.epichoppers.utils.Methods;
|
import com.songoda.epichoppers.utils.Methods;
|
||||||
import com.songoda.epichoppers.utils.ServerVersion;
|
import com.songoda.epichoppers.utils.ServerVersion;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -48,6 +49,8 @@ public class ModuleAutoCrafting implements Module {
|
|||||||
|
|
||||||
if (cachedRecipes.get(hopper.getAutoCrafting()) == null) return;
|
if (cachedRecipes.get(hopper.getAutoCrafting()) == null) return;
|
||||||
|
|
||||||
|
boolean updateComparators = false;
|
||||||
|
|
||||||
top:
|
top:
|
||||||
for (Recipe recipe : cachedRecipes.get(hopper.getAutoCrafting()).getRecipes()) {
|
for (Recipe recipe : cachedRecipes.get(hopper.getAutoCrafting()).getRecipes()) {
|
||||||
if (!(recipe instanceof ShapedRecipe) && !(recipe instanceof ShapelessRecipe)) continue;
|
if (!(recipe instanceof ShapedRecipe) && !(recipe instanceof ShapelessRecipe)) continue;
|
||||||
@ -95,8 +98,11 @@ public class ModuleAutoCrafting implements Module {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
hopperInventory.addItem(recipe.getResult());
|
hopperInventory.addItem(recipe.getResult());
|
||||||
|
updateComparators = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (updateComparators)
|
||||||
|
HopTask.updateAdjacentComparators(hopper.getLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package com.songoda.epichoppers.hopper.levels.modules;
|
|||||||
|
|
||||||
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.tasks.HopTask;
|
||||||
import com.songoda.epichoppers.utils.Methods;
|
import com.songoda.epichoppers.utils.Methods;
|
||||||
import com.songoda.epichoppers.utils.ServerVersion;
|
import com.songoda.epichoppers.utils.ServerVersion;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -41,6 +42,8 @@ public class ModuleAutoSell implements Module {
|
|||||||
|
|
||||||
if (instance.getEconomy() == null) return;
|
if (instance.getEconomy() == null) return;
|
||||||
|
|
||||||
|
boolean updateComparators = false;
|
||||||
|
|
||||||
List<String> list = instance.getConfig().getStringList("Main.AutoSell Prices");
|
List<String> list = instance.getConfig().getStringList("Main.AutoSell Prices");
|
||||||
|
|
||||||
for (String line : list) {
|
for (String line : list) {
|
||||||
@ -55,11 +58,16 @@ public class ModuleAutoSell implements Module {
|
|||||||
|
|
||||||
instance.getEconomy().deposit(Bukkit.getOfflinePlayer(hopper.getPlacedBy()), price * itemStack.getAmount());
|
instance.getEconomy().deposit(Bukkit.getOfflinePlayer(hopper.getPlacedBy()), price * itemStack.getAmount());
|
||||||
hopperInventory.removeItem(itemStack);
|
hopperInventory.removeItem(itemStack);
|
||||||
|
|
||||||
|
updateComparators = true;
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hopper.setAutoSellTimer(timeOut);
|
hopper.setAutoSellTimer(timeOut);
|
||||||
|
|
||||||
|
if (updateComparators)
|
||||||
|
HopTask.updateAdjacentComparators(hopper.getLocation());
|
||||||
}
|
}
|
||||||
hopper.setAutoSellTimer(hopper.getAutoSellTimer() - hopperTickRate);
|
hopper.setAutoSellTimer(hopper.getAutoSellTimer() - hopperTickRate);
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,17 @@ public class ModuleBlockBreak implements Module {
|
|||||||
if (EpicHoppers.getInstance().isServerVersionAtLeast(ServerVersion.V1_9))
|
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);
|
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();
|
above.breakNaturally();
|
||||||
|
|
||||||
|
if (waterlogged)
|
||||||
|
above.setType(Material.WATER);
|
||||||
}
|
}
|
||||||
blockTick.remove(block);
|
blockTick.remove(block);
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,12 @@ package com.songoda.epichoppers.listeners;
|
|||||||
|
|
||||||
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.utils.HopperDirection;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
import org.bukkit.block.DoubleChest;
|
import org.bukkit.block.DoubleChest;
|
||||||
|
import org.bukkit.block.ShulkerBox;
|
||||||
import org.bukkit.entity.Minecart;
|
import org.bukkit.entity.Minecart;
|
||||||
import org.bukkit.entity.minecart.HopperMinecart;
|
import org.bukkit.entity.minecart.HopperMinecart;
|
||||||
import org.bukkit.entity.minecart.StorageMinecart;
|
import org.bukkit.entity.minecart.StorageMinecart;
|
||||||
@ -31,15 +33,18 @@ public class HopperListeners implements Listener {
|
|||||||
Inventory source = event.getSource();
|
Inventory source = event.getSource();
|
||||||
Inventory destination = event.getDestination();
|
Inventory destination = event.getDestination();
|
||||||
|
|
||||||
if (destination.getHolder() instanceof StorageMinecart || destination.getHolder() instanceof HopperMinecart) {
|
// Hopper minecarts should be able to take care of themselves
|
||||||
if (source.getHolder() instanceof org.bukkit.block.Hopper)
|
// Let EpicHoppers take over if the hopper is pointing down though
|
||||||
event.setCancelled(true);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(source.getHolder() instanceof org.bukkit.block.Hopper))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (instance.isLiquidtanks() && net.arcaniax.liquidtanks.object.LiquidTankAPI.isLiquidTank(event.getDestination().getLocation()))
|
if (instance.isLiquidtanks() && net.arcaniax.liquidtanks.object.LiquidTankAPI.isLiquidTank(event.getDestination().getLocation()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -55,4 +55,4 @@ public class InventoryListeners implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.songoda.epichoppers.utils;
|
package com.songoda.epichoppers.utils;
|
||||||
|
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppers;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
@ -44,8 +45,8 @@ public class MySQLDatabase {
|
|||||||
")");
|
")");
|
||||||
|
|
||||||
} catch (ClassNotFoundException | SQLException e) {
|
} catch (ClassNotFoundException | SQLException e) {
|
||||||
System.err.println("Database connection failed.");
|
Bukkit.getLogger().severe("Database connection failed.");
|
||||||
System.err.println(e.getMessage());
|
Bukkit.getLogger().severe(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user