fallback to deprecated method for now to fix NoSuchMethodError
This commit is contained in:
parent
2f95176cf0
commit
b1994806c2
@ -158,7 +158,7 @@ public final class VillagerOptimizer extends JavaPlugin {
|
||||
VillagerOptimizerModule.reloadModules();
|
||||
config.saveConfig();
|
||||
} catch (Exception exception) {
|
||||
logger.error("Error loading config!", exception);
|
||||
logger.error("Error during config reload!", exception);
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ public final class VillagerOptimizer extends JavaPlugin {
|
||||
if (logFancy) logger.error(Component.text("│ ").style(GenericUtil.STYLE)
|
||||
.append(Component.text("LANG ERROR").color(NamedTextColor.RED).decorate(TextDecoration.BOLD))
|
||||
.append(Component.text(" │").style(GenericUtil.STYLE)), t);
|
||||
else logger.error("Error loading language files!", t);
|
||||
else logger.error("Error while loading translation files!", t);
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ public final class VillagerOptimizer extends JavaPlugin {
|
||||
.map(matcher -> matcher.group(1))
|
||||
.collect(Collectors.toCollection(TreeSet::new));
|
||||
} catch (Throwable t) {
|
||||
logger.error("Failed querying for available translations!", t);
|
||||
logger.error("Failed while searching for available translations!", t);
|
||||
return new TreeSet<>();
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import me.xginko.villageroptimizer.VillagerCache;
|
||||
import me.xginko.villageroptimizer.VillagerOptimizer;
|
||||
import me.xginko.villageroptimizer.config.Config;
|
||||
import me.xginko.villageroptimizer.modules.VillagerOptimizerModule;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -13,10 +14,7 @@ import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PreventOptimizedDamage implements VillagerOptimizerModule, Listener {
|
||||
@ -49,7 +47,7 @@ public class PreventOptimizedDamage implements VillagerOptimizerModule, Listener
|
||||
}
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toCollection(HashSet::new));
|
||||
.collect(Collectors.toCollection(() -> EnumSet.noneOf(EntityDamageEvent.DamageCause.class)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,10 +26,7 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -62,7 +59,7 @@ public class OptimizeByBlock implements VillagerOptimizerModule, Listener {
|
||||
}
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toCollection(HashSet::new));
|
||||
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Material.class)));
|
||||
this.cooldown_millis = TimeUnit.SECONDS.toMillis(
|
||||
config.getInt(configPath() + ".optimize-cooldown-seconds", 600,
|
||||
"Cooldown in seconds until a villager can be optimized again by using specific blocks.\n" +
|
||||
|
@ -11,8 +11,8 @@ import me.xginko.villageroptimizer.events.VillagerUnoptimizeEvent;
|
||||
import me.xginko.villageroptimizer.modules.VillagerOptimizerModule;
|
||||
import me.xginko.villageroptimizer.utils.GenericUtil;
|
||||
import me.xginko.villageroptimizer.utils.KyoriUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextReplacementConfig;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -81,6 +81,7 @@ public class OptimizeByNametag implements VillagerOptimizerModule, Listener {
|
||||
return VillagerOptimizer.getConfiguration().getBoolean(configPath() + ".enable", true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
private void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||
if (!event.getRightClicked().getType().equals(EntityType.VILLAGER)) return;
|
||||
@ -93,10 +94,7 @@ public class OptimizeByNametag implements VillagerOptimizerModule, Listener {
|
||||
final ItemMeta meta = usedItem.getItemMeta();
|
||||
if (!meta.hasDisplayName()) return;
|
||||
|
||||
// Get component name first, so we can manually name the villager when canceling the event to avoid item consumption.
|
||||
final Component newVillagerName = meta.displayName();
|
||||
assert newVillagerName != null; // Legitimate since we checked for hasDisplayName()
|
||||
final String nameTagPlainText = GenericUtil.plainTextSerializer.serialize(newVillagerName);
|
||||
final String nameTagPlainText = ChatColor.stripColor(meta.getDisplayName());
|
||||
final Villager villager = (Villager) event.getRightClicked();
|
||||
final WrappedVillager wVillager = villagerCache.getOrAdd(villager);
|
||||
|
||||
@ -112,8 +110,7 @@ public class OptimizeByNametag implements VillagerOptimizerModule, Listener {
|
||||
if (!optimizeEvent.callEvent()) return;
|
||||
|
||||
if (!consume_nametag) {
|
||||
event.setCancelled(true);
|
||||
villager.customName(newVillagerName);
|
||||
usedItem.add();
|
||||
}
|
||||
|
||||
wVillager.setOptimizationType(optimizeEvent.getOptimizationType());
|
||||
|
@ -17,7 +17,6 @@ public class GenericUtil {
|
||||
|
||||
public static final @NotNull TextColor COLOR = TextColor.color(102,255,230);
|
||||
public static final @NotNull Style STYLE = Style.style(COLOR, TextDecoration.BOLD);
|
||||
public static final @NotNull PlainTextComponentSerializer plainTextSerializer = PlainTextComponentSerializer.plainText();
|
||||
|
||||
public static @NotNull String formatDuration(@NotNull Duration duration) {
|
||||
if (duration.isNegative()) duration = duration.negated();
|
||||
|
Loading…
x
Reference in New Issue
Block a user