mirror of
https://github.com/songoda/EpicHoppers.git
synced 2024-09-17 18:41:03 +02:00
Merge branch 'development'
This commit is contained in:
commit
2c4cdc2aaf
16
pom.xml
16
pom.xml
@ -2,7 +2,7 @@
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>EpicHoppers</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>4.6.13</version>
|
||||
<version>4.6.14</version>
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>EpicHoppers-${project.version}</finalName>
|
||||
@ -82,19 +82,11 @@
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>private</id>
|
||||
<url>https://repo.songoda.com/artifactory/private/</url>
|
||||
<url>https://repo.songoda.com/repository/private/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>public</id>
|
||||
<url>https://repo.songoda.com/artifactory/public/</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>
|
||||
<url>https://repo.songoda.com/repository/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
@ -146,7 +138,7 @@
|
||||
<dependency>
|
||||
<groupId>com.bgsoftware</groupId>
|
||||
<artifactId>WildStacker</artifactId>
|
||||
<version>2-9-0</version>
|
||||
<version>b20</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -86,7 +86,7 @@ public class ModuleAutoSell extends Module {
|
||||
value = 0;
|
||||
}
|
||||
} else
|
||||
value = Settings.AUTOSELL_PRICES.getStringList().stream().filter(line -> Material.valueOf(line.split(",")[0]) == itemStack.getType()).findFirst()
|
||||
value = Settings.AUTOSELL_PRICES.getStringList().stream().filter(line -> CompatibleMaterial.valueOf(line.split(",")[0]) == CompatibleMaterial.getMaterial(itemStack)).findFirst()
|
||||
.map(s -> Double.valueOf(s.split(",")[1])).orElse(0.0);
|
||||
|
||||
if (value <= 0) continue;
|
||||
|
@ -13,7 +13,7 @@ public class PlayerDataManager {
|
||||
private final Map<UUID, PlayerData> registeredPlayers = new HashMap<>();
|
||||
|
||||
private PlayerData getPlayerData(UUID uuid) {
|
||||
if (registeredPlayers.containsKey(uuid))
|
||||
if (!registeredPlayers.containsKey(uuid))
|
||||
registeredPlayers.put(uuid, new PlayerData());
|
||||
return registeredPlayers.get(uuid);
|
||||
}
|
||||
|
@ -47,26 +47,17 @@ public class HopTask extends BukkitRunnable {
|
||||
|
||||
private final int hopTicks;
|
||||
private final boolean hasFabledSkyBlock;
|
||||
private boolean legacyFabledSkyblock;
|
||||
private final Plugin fabledSkyblockPlugin;
|
||||
|
||||
public HopTask(EpicHoppers plugin) {
|
||||
HopTask.plugin = plugin;
|
||||
this.hopTicks = Math.max(1, Settings.HOP_TICKS.getInt() / 2); // Purposeful integer division. Don't go below 1.
|
||||
this.runTaskTimer(plugin, 0, 2);
|
||||
if ((this.hasFabledSkyBlock = (fabledSkyblockPlugin = Bukkit.getPluginManager().getPlugin("FabledSkyBlock")) != null)) {
|
||||
try {
|
||||
Class.forName("me.goodandevil.skyblock.SkyBlock");
|
||||
legacyFabledSkyblock = true;
|
||||
} catch (ClassNotFoundException ex) {
|
||||
}
|
||||
}
|
||||
this.hasFabledSkyBlock = (fabledSkyblockPlugin = Bukkit.getPluginManager().getPlugin("FabledSkyBlock")) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Set<Location> toRemove = new HashSet<>();
|
||||
|
||||
for (final com.songoda.epichoppers.hopper.Hopper hopper : plugin.getHopperManager().getHoppers().values()) {
|
||||
|
||||
try {
|
||||
@ -81,10 +72,8 @@ public class HopTask extends BukkitRunnable {
|
||||
Block block = location.getBlock();
|
||||
|
||||
// If block is not a hopper remove and continue.
|
||||
if (block.getType() != Material.HOPPER) {
|
||||
toRemove.add(location);
|
||||
if (block.getType() != Material.HOPPER)
|
||||
continue;
|
||||
}
|
||||
|
||||
// If hopper block is powered, update its redstone state and continue.
|
||||
if (block.getBlockPower() > 0) {
|
||||
@ -154,32 +143,6 @@ public class HopTask extends BukkitRunnable {
|
||||
|
||||
// Support for FabledSkyBlock stackables.
|
||||
if (this.hasFabledSkyBlock) {
|
||||
if (legacyFabledSkyblock) {
|
||||
Object stackableManager = fabledSkyblockPlugin.getClass().getMethod("getStackableManager").invoke(fabledSkyblockPlugin);
|
||||
boolean isStacked = stackableManager != null && (boolean) stackableManager.getClass().getMethod("isStacked", Location.class).invoke(stackableManager, pointingLocation);
|
||||
if (isStacked) {
|
||||
Material mat = pointingLocation.getBlock().getType();
|
||||
Object stackable = stackableManager.getClass().getMethod("getStack", Location.class, Material.class).invoke(stackableManager, pointingLocation, mat);
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
final ItemStack item = hopperCache.cachedInventory[i];
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.getType() == mat) {
|
||||
stackable.getClass().getMethod("addOne").invoke(stackable);
|
||||
if (item.getAmount() == 1) {
|
||||
hopperCache.removeItem(i);
|
||||
} else {
|
||||
item.setAmount(item.getAmount() - 1);
|
||||
hopperCache.dirty = hopperCache.cacheChanged[i] = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
com.songoda.skyblock.stackable.StackableManager stackableManager = ((com.songoda.skyblock.SkyBlock) fabledSkyblockPlugin).getStackableManager();
|
||||
if (stackableManager != null && stackableManager.isStacked(pointingLocation)) {
|
||||
Block pointingBlock = pointingLocation.getBlock();
|
||||
@ -207,7 +170,6 @@ public class HopTask extends BukkitRunnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Move items into destination containers
|
||||
pushItemsIntoContainers(hopper, hopperCache, maxToMove, blockedMaterials, hopperDirection);
|
||||
@ -219,14 +181,6 @@ public class HopTask extends BukkitRunnable {
|
||||
|
||||
// push out inventory changes
|
||||
StorageContainerCache.update();
|
||||
|
||||
// Clear out invalid hoppers
|
||||
HopperManager hopperManager = plugin.getHopperManager();
|
||||
toRemove.forEach(h -> {
|
||||
com.songoda.epichoppers.hopper.Hopper
|
||||
hopper = hopperManager.removeHopper(h);
|
||||
plugin.getDataManager().deleteHopper(hopper);
|
||||
});
|
||||
}
|
||||
|
||||
private void debt(ItemStack item, int amountToMove, InventoryHolder currentHolder) {
|
||||
|
Loading…
Reference in New Issue
Block a user