mirror of
https://github.com/songoda/EpicHoppers.git
synced 2024-11-09 20:21:41 +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:
|
||||
name: "EpicHoppers"
|
||||
path: "/builds/$CI_PROJECT_PATH"
|
||||
version: "4.2.3"
|
||||
version: "4.2.6"
|
||||
|
||||
build:
|
||||
stage: build
|
||||
|
14
pom.xml
14
pom.xml
@ -54,18 +54,22 @@
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>private</id>
|
||||
<url>http://repo.songoda.com/artifactory/private/</url>
|
||||
<url>https://repo.songoda.com/artifactory/private/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>reserve-repo</id>
|
||||
<url>https://dl.bintray.com/theneweconomy/java/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.14.1</version>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.14.4-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
@ -75,7 +79,7 @@
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>UltimateStacker</artifactId>
|
||||
<version>1.6.9</version>
|
||||
<version>1.9.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.arcaniax</groupId>
|
||||
@ -103,7 +107,7 @@
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>fabledskyblock</artifactId>
|
||||
<version>72</version>
|
||||
<version>78.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -14,7 +14,11 @@ import com.songoda.epichoppers.hopper.HopperBuilder;
|
||||
import com.songoda.epichoppers.hopper.HopperManager;
|
||||
import com.songoda.epichoppers.hopper.levels.Level;
|
||||
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.player.PlayerDataManager;
|
||||
import com.songoda.epichoppers.storage.Storage;
|
||||
|
@ -56,7 +56,8 @@ public class ModuleAutoSell extends Module {
|
||||
|
||||
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];
|
||||
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.ServerVersion;
|
||||
import com.songoda.epichoppers.utils.StorageContainerCache;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@ -20,6 +22,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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 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) {
|
||||
super(plugin);
|
||||
@ -134,9 +151,17 @@ public class ModuleSuction extends Module {
|
||||
}
|
||||
|
||||
private void updateAmount(Item item, int amount) {
|
||||
if (ultimateStacker)
|
||||
com.songoda.ultimatestacker.utils.Methods.updateItemAmount(item, amount);
|
||||
else if (wildStacker)
|
||||
if (ultimateStacker) {
|
||||
if (oldUltimateStacker) {
|
||||
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);
|
||||
else
|
||||
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.levels.modules.Module;
|
||||
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.Methods;
|
||||
import com.songoda.epichoppers.utils.ServerVersion;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.block.DoubleChest;
|
||||
import org.bukkit.entity.Minecart;
|
||||
@ -38,6 +38,8 @@ public class HopperListeners implements Listener {
|
||||
public void onHop(InventoryMoveItemEvent event) {
|
||||
Inventory source = event.getSource();
|
||||
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
|
||||
// Let EpicHoppers take over if the hopper is pointing down though
|
||||
@ -47,26 +49,27 @@ public class HopperListeners implements Listener {
|
||||
return;
|
||||
|
||||
// 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);
|
||||
return;
|
||||
}
|
||||
|
||||
// Hopper going into minecarts
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
// Special cases when a hopper is picking up items
|
||||
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
|
||||
Hopper toHopper = instance.getHopperManager().getHopper(((org.bukkit.block.Hopper) destination.getHolder()).getLocation());
|
||||
Hopper toHopper = instance.getHopperManager().getHopper(destinationLocation);
|
||||
final ItemStack toMove = event.getItem();
|
||||
|
||||
// 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);
|
||||
// we need to instead cancel and manually remove the item to move
|
||||
source.removeItem(moveInstead);
|
||||
Methods.updateAdjacentComparators(source.getLocation());
|
||||
Methods.updateAdjacentComparators(sourceLocation);
|
||||
// now add it to the hopper
|
||||
destination.addItem(moveInstead);
|
||||
Methods.updateAdjacentComparators(destination.getLocation());
|
||||
Methods.updateAdjacentComparators(destinationLocation);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -145,26 +148,8 @@ public class HopperListeners implements Listener {
|
||||
if (!(source.getHolder() instanceof org.bukkit.block.Hopper))
|
||||
return;
|
||||
|
||||
org.bukkit.block.Hopper sourceHopper = (org.bukkit.block.Hopper) source.getHolder();
|
||||
|
||||
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 {
|
||||
if(destinationLocation == null)
|
||||
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
|
||||
event.setCancelled(true);
|
||||
|
@ -29,6 +29,7 @@ public class Methods {
|
||||
private static final Map<String, Location> serializeCache = new HashMap<>();
|
||||
|
||||
public static boolean isLegacyFuel(Material material) {
|
||||
|
||||
if (material == null) return false;
|
||||
switch(material.ordinal() + 1) {
|
||||
case 6:
|
||||
@ -70,6 +71,7 @@ public class Methods {
|
||||
case 191:
|
||||
case 192:
|
||||
case 193:
|
||||
case 206:
|
||||
case 260:
|
||||
case 262:
|
||||
case 267:
|
||||
@ -260,11 +262,11 @@ public class Methods {
|
||||
if (location == null || location.getWorld() == null)
|
||||
return "";
|
||||
String w = location.getWorld().getName();
|
||||
double x = location.getBlockX();
|
||||
double y = location.getBlockY();
|
||||
double z = location.getBlockZ();
|
||||
double x = location.getX();
|
||||
double y = location.getY();
|
||||
double z = location.getZ();
|
||||
String str = w + ":" + x + ":" + y + ":" + z;
|
||||
str = str.replace(".0", "").replace("/", "");
|
||||
str = str.replace(".0", "").replace(".", "/");
|
||||
return str;
|
||||
}
|
||||
|
||||
@ -295,10 +297,14 @@ public class Methods {
|
||||
private static Method getHandle, updateAdjacentComparators, getNMSBlock;
|
||||
|
||||
public static void updateAdjacentComparators(Location location) {
|
||||
if(location == null || location.getWorld() == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// Cache reflection.
|
||||
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");
|
||||
clazzCraftBlock = Class.forName("org.bukkit.craftbukkit." + ver + ".block.CraftBlock");
|
||||
clazzBlockPosition = Class.forName("net.minecraft.server." + ver + ".BlockPosition");
|
||||
|
Loading…
Reference in New Issue
Block a user