mirror of
https://github.com/songoda/EpicHoppers.git
synced 2025-02-19 05:11:33 +01:00
Merge branch 'development' into 'master'
4.2.6 See merge request Songoda/epichoppers!47
This commit is contained in:
commit
a14d99d924
@ -4,7 +4,7 @@ stages:
|
|||||||
variables:
|
variables:
|
||||||
name: "EpicHoppers"
|
name: "EpicHoppers"
|
||||||
path: "/builds/$CI_PROJECT_PATH"
|
path: "/builds/$CI_PROJECT_PATH"
|
||||||
version: "4.2.3"
|
version: "4.2.6"
|
||||||
|
|
||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
|
14
pom.xml
14
pom.xml
@ -54,18 +54,22 @@
|
|||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>private</id>
|
<id>private</id>
|
||||||
<url>http://repo.songoda.com/artifactory/private/</url>
|
<url>https://repo.songoda.com/artifactory/private/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>reserve-repo</id>
|
<id>reserve-repo</id>
|
||||||
<url>https://dl.bintray.com/theneweconomy/java/</url>
|
<url>https://dl.bintray.com/theneweconomy/java/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>spigot-repo</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.14.1</version>
|
<version>1.14.4-R0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.songoda</groupId>
|
<groupId>com.songoda</groupId>
|
||||||
@ -75,7 +79,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.songoda</groupId>
|
<groupId>com.songoda</groupId>
|
||||||
<artifactId>UltimateStacker</artifactId>
|
<artifactId>UltimateStacker</artifactId>
|
||||||
<version>1.6.9</version>
|
<version>1.9.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.arcaniax</groupId>
|
<groupId>net.arcaniax</groupId>
|
||||||
@ -103,7 +107,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.songoda</groupId>
|
<groupId>com.songoda</groupId>
|
||||||
<artifactId>fabledskyblock</artifactId>
|
<artifactId>fabledskyblock</artifactId>
|
||||||
<version>72</version>
|
<version>78.5</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -14,7 +14,11 @@ import com.songoda.epichoppers.hopper.HopperBuilder;
|
|||||||
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;
|
||||||
import com.songoda.epichoppers.hopper.levels.modules.*;
|
import com.songoda.epichoppers.hopper.levels.modules.Module;
|
||||||
|
import com.songoda.epichoppers.hopper.levels.modules.ModuleAutoCrafting;
|
||||||
|
import com.songoda.epichoppers.hopper.levels.modules.ModuleAutoSell;
|
||||||
|
import com.songoda.epichoppers.hopper.levels.modules.ModuleBlockBreak;
|
||||||
|
import com.songoda.epichoppers.hopper.levels.modules.ModuleSuction;
|
||||||
import com.songoda.epichoppers.listeners.*;
|
import com.songoda.epichoppers.listeners.*;
|
||||||
import com.songoda.epichoppers.player.PlayerDataManager;
|
import com.songoda.epichoppers.player.PlayerDataManager;
|
||||||
import com.songoda.epichoppers.storage.Storage;
|
import com.songoda.epichoppers.storage.Storage;
|
||||||
|
@ -56,7 +56,8 @@ public class ModuleAutoSell extends Module {
|
|||||||
|
|
||||||
OfflinePlayer player = Bukkit.getOfflinePlayer(hopper.getPlacedBy());
|
OfflinePlayer player = Bukkit.getOfflinePlayer(hopper.getPlacedBy());
|
||||||
|
|
||||||
for (int i = 0; i < hopperCache.cachedInventory.length - 1; i++) {
|
// -1
|
||||||
|
for (int i = 0; i < hopperCache.cachedInventory.length; i++) {
|
||||||
final ItemStack itemStack = hopperCache.cachedInventory[i];
|
final ItemStack itemStack = hopperCache.cachedInventory[i];
|
||||||
if (itemStack == null) continue;
|
if (itemStack == null) continue;
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@ import com.songoda.epichoppers.hopper.Hopper;
|
|||||||
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 com.songoda.epichoppers.utils.StorageContainerCache;
|
import com.songoda.epichoppers.utils.StorageContainerCache;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -20,6 +22,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ModuleSuction extends Module {
|
public class ModuleSuction extends Module {
|
||||||
@ -30,6 +34,19 @@ public class ModuleSuction extends Module {
|
|||||||
|
|
||||||
private final static boolean wildStacker = Bukkit.getPluginManager().isPluginEnabled("WildStacker");
|
private final static boolean wildStacker = Bukkit.getPluginManager().isPluginEnabled("WildStacker");
|
||||||
private final static boolean ultimateStacker = Bukkit.getPluginManager().isPluginEnabled("UltimateStacker");
|
private final static boolean ultimateStacker = Bukkit.getPluginManager().isPluginEnabled("UltimateStacker");
|
||||||
|
private static boolean oldUltimateStacker;
|
||||||
|
private static Method oldUltimateStacker_updateItemAmount;
|
||||||
|
static {
|
||||||
|
if (ultimateStacker) {
|
||||||
|
try {
|
||||||
|
oldUltimateStacker_updateItemAmount = com.songoda.ultimatestacker.utils.Methods.class.getDeclaredMethod("updateItemAmount", Item.class, int.class);
|
||||||
|
oldUltimateStacker = true;
|
||||||
|
} catch (NoSuchMethodException | SecurityException ex) {
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
oldUltimateStacker = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ModuleSuction(EpicHoppers plugin, int amount) {
|
public ModuleSuction(EpicHoppers plugin, int amount) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
@ -134,9 +151,17 @@ public class ModuleSuction extends Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateAmount(Item item, int amount) {
|
private void updateAmount(Item item, int amount) {
|
||||||
if (ultimateStacker)
|
if (ultimateStacker) {
|
||||||
com.songoda.ultimatestacker.utils.Methods.updateItemAmount(item, amount);
|
if (oldUltimateStacker) {
|
||||||
else if (wildStacker)
|
try {
|
||||||
|
oldUltimateStacker_updateItemAmount.invoke(null, item, amount);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
item.remove(); // not the best solution, but they should update, anyway..
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
com.songoda.ultimatestacker.utils.Methods.updateItemAmount(item, item.getItemStack(), amount);
|
||||||
|
}
|
||||||
|
} else if (wildStacker)
|
||||||
WildStackerAPI.getStackedItem(item).setStackAmount(amount, true);
|
WildStackerAPI.getStackedItem(item).setStackAmount(amount, true);
|
||||||
else
|
else
|
||||||
item.getItemStack().setAmount(amount > item.getItemStack().getMaxStackSize()
|
item.getItemStack().setAmount(amount > item.getItemStack().getMaxStackSize()
|
||||||
|
@ -4,12 +4,12 @@ import com.songoda.epichoppers.EpicHoppers;
|
|||||||
import com.songoda.epichoppers.hopper.Hopper;
|
import com.songoda.epichoppers.hopper.Hopper;
|
||||||
import com.songoda.epichoppers.hopper.levels.modules.Module;
|
import com.songoda.epichoppers.hopper.levels.modules.Module;
|
||||||
import com.songoda.epichoppers.hopper.levels.modules.ModuleAutoCrafting;
|
import com.songoda.epichoppers.hopper.levels.modules.ModuleAutoCrafting;
|
||||||
import com.songoda.epichoppers.tasks.HopTask;
|
|
||||||
import com.songoda.epichoppers.utils.HopperDirection;
|
import com.songoda.epichoppers.utils.HopperDirection;
|
||||||
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.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
import org.bukkit.block.DoubleChest;
|
import org.bukkit.block.DoubleChest;
|
||||||
import org.bukkit.entity.Minecart;
|
import org.bukkit.entity.Minecart;
|
||||||
@ -38,6 +38,8 @@ public class HopperListeners implements Listener {
|
|||||||
public void onHop(InventoryMoveItemEvent event) {
|
public void onHop(InventoryMoveItemEvent event) {
|
||||||
Inventory source = event.getSource();
|
Inventory source = event.getSource();
|
||||||
Inventory destination = event.getDestination();
|
Inventory destination = event.getDestination();
|
||||||
|
Location sourceLocation = source.getHolder() instanceof BlockState ? ((BlockState) source.getHolder()).getLocation() : null;
|
||||||
|
Location destinationLocation = destination.getHolder() instanceof BlockState ? ((BlockState) destination.getHolder()).getLocation() : null;
|
||||||
|
|
||||||
// Hopper minecarts should be able to take care of themselves
|
// Hopper minecarts should be able to take care of themselves
|
||||||
// Let EpicHoppers take over if the hopper is pointing down though
|
// Let EpicHoppers take over if the hopper is pointing down though
|
||||||
@ -47,26 +49,27 @@ public class HopperListeners implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Shulker boxes have a mind of their own and relentlessly steal items from hoppers
|
// Shulker boxes have a mind of their own and relentlessly steal items from hoppers
|
||||||
if (this.instance.isServerVersionAtLeast(ServerVersion.V1_11) && destination.getHolder() instanceof org.bukkit.block.ShulkerBox && destination.getHolder() instanceof org.bukkit.block.Hopper) {
|
if (this.instance.isServerVersionAtLeast(ServerVersion.V1_11)
|
||||||
|
&& destination.getHolder() instanceof org.bukkit.block.ShulkerBox
|
||||||
|
&& source.getHolder() instanceof org.bukkit.block.Hopper) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hopper going into minecarts
|
// Hopper going into minecarts
|
||||||
if (destination.getHolder() instanceof Minecart && source.getHolder() instanceof org.bukkit.block.Hopper) {
|
if (destination.getHolder() instanceof Minecart && source.getHolder() instanceof org.bukkit.block.Hopper) {
|
||||||
instance.getHopperManager().getHopper(((org.bukkit.block.Hopper) source.getHolder()).getLocation());
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't touch liquid tank hoppers
|
// Don't touch liquid tank hoppers
|
||||||
if (instance.isLiquidtanks() && net.arcaniax.liquidtanks.object.LiquidTankAPI.isLiquidTank(event.getDestination().getLocation()))
|
if (instance.isLiquidtanks() && net.arcaniax.liquidtanks.object.LiquidTankAPI.isLiquidTank(destinationLocation))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 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) {
|
||||||
// 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
|
||||||
Hopper toHopper = instance.getHopperManager().getHopper(((org.bukkit.block.Hopper) destination.getHolder()).getLocation());
|
Hopper toHopper = instance.getHopperManager().getHopper(destinationLocation);
|
||||||
final ItemStack toMove = event.getItem();
|
final ItemStack toMove = event.getItem();
|
||||||
|
|
||||||
// Don't fill the last inventory slot on crafting hoppers (fixes crafters getting stuck)
|
// Don't fill the last inventory slot on crafting hoppers (fixes crafters getting stuck)
|
||||||
@ -132,10 +135,10 @@ public class HopperListeners implements Listener {
|
|||||||
//event.setItem(moveInstead);
|
//event.setItem(moveInstead);
|
||||||
// we need to instead cancel and manually remove the item to move
|
// we need to instead cancel and manually remove the item to move
|
||||||
source.removeItem(moveInstead);
|
source.removeItem(moveInstead);
|
||||||
Methods.updateAdjacentComparators(source.getLocation());
|
Methods.updateAdjacentComparators(sourceLocation);
|
||||||
// now add it to the hopper
|
// now add it to the hopper
|
||||||
destination.addItem(moveInstead);
|
destination.addItem(moveInstead);
|
||||||
Methods.updateAdjacentComparators(destination.getLocation());
|
Methods.updateAdjacentComparators(destinationLocation);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -145,26 +148,8 @@ public class HopperListeners implements Listener {
|
|||||||
if (!(source.getHolder() instanceof org.bukkit.block.Hopper))
|
if (!(source.getHolder() instanceof org.bukkit.block.Hopper))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
org.bukkit.block.Hopper sourceHopper = (org.bukkit.block.Hopper) source.getHolder();
|
if(destinationLocation == null)
|
||||||
|
|
||||||
Location destinationLocation;
|
|
||||||
if (destination.getHolder() instanceof org.bukkit.block.Hopper) {
|
|
||||||
destinationLocation = ((org.bukkit.block.Hopper) destination.getHolder()).getLocation();
|
|
||||||
} else if (destination.getHolder() instanceof Chest) {
|
|
||||||
destinationLocation = ((Chest) destination.getHolder()).getLocation();
|
|
||||||
} else if (destination.getHolder() instanceof DoubleChest) {
|
|
||||||
destinationLocation = ((DoubleChest) destination.getHolder()).getLocation();
|
|
||||||
} else {
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (!(destinationLocation.getBlock().getState() instanceof InventoryHolder))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Hopper hopper = instance.getHopperManager().getHopper(sourceHopper.getLocation());
|
|
||||||
|
|
||||||
hopper.clearLinkedBlocks();
|
|
||||||
hopper.addLinkedBlock(destinationLocation);
|
|
||||||
|
|
||||||
// Handle hopper push events elsewhere
|
// Handle hopper push events elsewhere
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -29,6 +29,7 @@ public class Methods {
|
|||||||
private static final Map<String, Location> serializeCache = new HashMap<>();
|
private static final Map<String, Location> serializeCache = new HashMap<>();
|
||||||
|
|
||||||
public static boolean isLegacyFuel(Material material) {
|
public static boolean isLegacyFuel(Material material) {
|
||||||
|
|
||||||
if (material == null) return false;
|
if (material == null) return false;
|
||||||
switch(material.ordinal() + 1) {
|
switch(material.ordinal() + 1) {
|
||||||
case 6:
|
case 6:
|
||||||
@ -70,6 +71,7 @@ public class Methods {
|
|||||||
case 191:
|
case 191:
|
||||||
case 192:
|
case 192:
|
||||||
case 193:
|
case 193:
|
||||||
|
case 206:
|
||||||
case 260:
|
case 260:
|
||||||
case 262:
|
case 262:
|
||||||
case 267:
|
case 267:
|
||||||
@ -260,11 +262,11 @@ public class Methods {
|
|||||||
if (location == null || location.getWorld() == null)
|
if (location == null || location.getWorld() == null)
|
||||||
return "";
|
return "";
|
||||||
String w = location.getWorld().getName();
|
String w = location.getWorld().getName();
|
||||||
double x = location.getBlockX();
|
double x = location.getX();
|
||||||
double y = location.getBlockY();
|
double y = location.getY();
|
||||||
double z = location.getBlockZ();
|
double z = location.getZ();
|
||||||
String str = w + ":" + x + ":" + y + ":" + z;
|
String str = w + ":" + x + ":" + y + ":" + z;
|
||||||
str = str.replace(".0", "").replace("/", "");
|
str = str.replace(".0", "").replace(".", "/");
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,10 +297,14 @@ public class Methods {
|
|||||||
private static Method getHandle, updateAdjacentComparators, getNMSBlock;
|
private static Method getHandle, updateAdjacentComparators, getNMSBlock;
|
||||||
|
|
||||||
public static void updateAdjacentComparators(Location location) {
|
public static void updateAdjacentComparators(Location location) {
|
||||||
|
if(location == null || location.getWorld() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
// Cache reflection.
|
// Cache reflection.
|
||||||
if (clazzCraftWorld == null) {
|
if (clazzCraftWorld == null) {
|
||||||
String ver = Bukkit.getServer().getClass().getPackage().getName().substring(23);
|
String serverPackagePath = Bukkit.getServer().getClass().getPackage().getName();
|
||||||
|
String ver = serverPackagePath.substring(serverPackagePath.lastIndexOf('.') + 1);
|
||||||
clazzCraftWorld = Class.forName("org.bukkit.craftbukkit." + ver + ".CraftWorld");
|
clazzCraftWorld = Class.forName("org.bukkit.craftbukkit." + ver + ".CraftWorld");
|
||||||
clazzCraftBlock = Class.forName("org.bukkit.craftbukkit." + ver + ".block.CraftBlock");
|
clazzCraftBlock = Class.forName("org.bukkit.craftbukkit." + ver + ".block.CraftBlock");
|
||||||
clazzBlockPosition = Class.forName("net.minecraft.server." + ver + ".BlockPosition");
|
clazzBlockPosition = Class.forName("net.minecraft.server." + ver + ".BlockPosition");
|
||||||
|
Loading…
Reference in New Issue
Block a user