mirror of
https://github.com/songoda/EpicHoppers.git
synced 2024-09-19 19:41:04 +02:00
Merge branch 'development'
This commit is contained in:
commit
b9cc12ae0e
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>EpicHoppers</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>4.6.4</version>
|
||||
<version>4.6.5</version>
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>EpicHoppers-${project.version}</finalName>
|
||||
|
@ -54,7 +54,10 @@ public class GUIAutoSellFilter extends Gui {
|
||||
|
||||
setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.ARROW.getItem(),
|
||||
plugin.getLocale().getMessage("general.nametag.back").getMessage()),
|
||||
(event) -> hopper.overview(guiManager, event.player));
|
||||
(event) -> {
|
||||
hopper.overview(guiManager, event.player);
|
||||
compile();
|
||||
});
|
||||
|
||||
// Whitelist
|
||||
ItemStack indicatorItem = CompatibleMaterial.WHITE_STAINED_GLASS_PANE.getItem();
|
||||
|
@ -58,7 +58,10 @@ public class GUIFilter extends Gui {
|
||||
|
||||
setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.ARROW.getItem(),
|
||||
plugin.getLocale().getMessage("general.nametag.back").getMessage()),
|
||||
(event) -> hopper.overview(guiManager, event.player));
|
||||
(event) -> {
|
||||
hopper.overview(guiManager, event.player);
|
||||
compile();
|
||||
});
|
||||
|
||||
int[] whiteSlots = {0, 1, 45, 46};
|
||||
for (int nu : whiteSlots) {
|
||||
|
@ -324,7 +324,7 @@ public class ModuleAutoCrafting extends Module {
|
||||
}
|
||||
|
||||
public void addRecipes(Collection<Recipe> recipes) {
|
||||
recipes.forEach(recipe -> this.addRecipe(recipe));
|
||||
recipes.forEach(this::addRecipe);
|
||||
}
|
||||
|
||||
public boolean hasRecipes() {
|
||||
@ -347,7 +347,12 @@ public class ModuleAutoCrafting extends Module {
|
||||
|
||||
for (int i = 0; i < recipe.getIngredientList().size(); i++) {
|
||||
ItemStack item = recipe.getIngredientList().get(i);
|
||||
RecipeChoice rChoice = recipe.getChoiceList().get(i);
|
||||
RecipeChoice rChoice = null;
|
||||
|
||||
try {
|
||||
rChoice = recipe.getChoiceList().get(i);
|
||||
} catch (NoSuchMethodError ignore) { // Method missing in Spigot 1.12.2
|
||||
}
|
||||
|
||||
processIngredient(ingredients, item, rChoice);
|
||||
}
|
||||
@ -362,7 +367,12 @@ public class ModuleAutoCrafting extends Module {
|
||||
|
||||
for (Map.Entry<Character, ItemStack> entry : recipe.getIngredientMap().entrySet()) {
|
||||
ItemStack item = entry.getValue();
|
||||
RecipeChoice rChoice = recipe.getChoiceMap().get(entry.getKey());
|
||||
RecipeChoice rChoice = null;
|
||||
|
||||
try {
|
||||
rChoice = recipe.getChoiceMap().get(entry.getKey());
|
||||
} catch (NoSuchMethodError ignore) { // Method missing in Spigot 1.12.2
|
||||
}
|
||||
|
||||
if (item == null) continue;
|
||||
|
||||
|
@ -62,7 +62,6 @@ public class HopTask extends BukkitRunnable {
|
||||
public void run() {
|
||||
Set<Location> toRemove = new HashSet<>();
|
||||
|
||||
main:
|
||||
for (final com.songoda.epichoppers.hopper.Hopper hopper : plugin.getHopperManager().getHoppers().values()) {
|
||||
|
||||
try {
|
||||
@ -108,13 +107,17 @@ public class HopTask extends BukkitRunnable {
|
||||
hopper.getLevel().getRegisteredModules().stream()
|
||||
.filter(Objects::nonNull)
|
||||
.forEach(module -> {
|
||||
// Run Module
|
||||
module.run(hopper, hopperCache);
|
||||
try {
|
||||
// Run Module
|
||||
module.run(hopper, hopperCache);
|
||||
|
||||
// Add banned materials to list.
|
||||
List<Material> materials = module.getBlockedItems(hopper);
|
||||
if (materials != null && !materials.isEmpty())
|
||||
blockedMaterials.addAll(materials);
|
||||
// Add banned materials to list.
|
||||
List<Material> materials = module.getBlockedItems(hopper);
|
||||
if (materials != null && !materials.isEmpty())
|
||||
blockedMaterials.addAll(materials);
|
||||
} catch (Throwable th) {
|
||||
th.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
// Process extra hopper pull
|
||||
|
@ -2,15 +2,12 @@ package com.songoda.epichoppers.utils;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import java.lang.reflect.Method;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
@ -30,7 +27,9 @@ public class Methods {
|
||||
private static final Map<String, Location> serializeCache = new HashMap<>();
|
||||
|
||||
public static boolean isSimilarMaterial(ItemStack is1, ItemStack is2) {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ||
|
||||
is1.getDurability() == Short.MAX_VALUE || is2.getDurability() == Short.MAX_VALUE) {
|
||||
// Durability of Short.MAX_VALUE is used in recipes if the durability should be ignored
|
||||
return is1.getType() == is2.getType();
|
||||
} else {
|
||||
return is1.getType() == is2.getType() && (is1.getDurability() == -1 || is2.getDurability() == -1 || is1.getDurability() == is2.getDurability());
|
||||
@ -102,20 +101,20 @@ public class Methods {
|
||||
}
|
||||
|
||||
public static String formatName(int level) {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
String name = instance.getLocale().getMessage("general.nametag.nameformat")
|
||||
.processPlaceholder("level", level).getMessage();
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
String name = instance.getLocale().getMessage("general.nametag.nameformat")
|
||||
.processPlaceholder("level", level).getMessage();
|
||||
|
||||
|
||||
return Methods.formatText(name);
|
||||
return Methods.formatText(name);
|
||||
}
|
||||
|
||||
public static void doParticles(Entity entity, Location location) {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
location.setX(location.getX() + .5);
|
||||
location.setY(location.getY() + .5);
|
||||
location.setZ(location.getZ() + .5);
|
||||
entity.getWorld().spawnParticle(org.bukkit.Particle.valueOf(instance.getConfig().getString("Main.Upgrade Particle Type")), location, 200, .5, .5, .5);
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
location.setX(location.getX() + .5);
|
||||
location.setY(location.getY() + .5);
|
||||
location.setZ(location.getZ() + .5);
|
||||
entity.getWorld().spawnParticle(org.bukkit.Particle.valueOf(instance.getConfig().getString("Main.Upgrade Particle Type")), location, 200, .5, .5, .5);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -170,6 +169,7 @@ public class Methods {
|
||||
serializeCache.put(cacheKey, location.clone());
|
||||
return location;
|
||||
}
|
||||
|
||||
public static String convertToInvisibleString(String s) {
|
||||
if (s == null || s.equals(""))
|
||||
return "";
|
||||
|
Loading…
Reference in New Issue
Block a user