mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-12-26 20:27:38 +01:00
Cleaned up code
This commit is contained in:
parent
57c69994a7
commit
31b968088f
@ -4,16 +4,12 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Alchemy extends EcoEnchant {
|
||||
public Alchemy() {
|
||||
|
@ -1,11 +1,7 @@
|
||||
package com.willfp.ecoenchants.effects;
|
||||
|
||||
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import com.willfp.ecoenchants.effects.enchants.JumpBoost;
|
||||
import com.willfp.ecoenchants.effects.enchants.NightVision;
|
||||
import com.willfp.ecoenchants.effects.enchants.Regeneration;
|
||||
import com.willfp.ecoenchants.effects.enchants.Speed;
|
||||
import com.willfp.ecoenchants.effects.enchants.WaterBreathing;
|
||||
import com.willfp.ecoenchants.effects.enchants.*;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.extensions.Extension;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -8,7 +8,6 @@ import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.SoundCategory;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EnderPearl;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -4,15 +4,12 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
@ -11,12 +11,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Mob;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Trident;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
@ -3,11 +3,7 @@ package com.willfp.ecoenchants.summoning;
|
||||
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.extensions.Extension;
|
||||
import com.willfp.ecoenchants.summoning.enchants.Crawler;
|
||||
import com.willfp.ecoenchants.summoning.enchants.Firestorm;
|
||||
import com.willfp.ecoenchants.summoning.enchants.Ghoul;
|
||||
import com.willfp.ecoenchants.summoning.enchants.Metallic;
|
||||
import com.willfp.ecoenchants.summoning.enchants.Mortality;
|
||||
import com.willfp.ecoenchants.summoning.enchants.*;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class SummoningMain extends Extension {
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -15,7 +16,6 @@ public abstract class AbstractCommand implements CommandExecutor, Registerable {
|
||||
private final String name;
|
||||
private final String permission;
|
||||
private final boolean playersOnly;
|
||||
private AbstractTabCompleter tabCompleter = null;
|
||||
|
||||
protected AbstractCommand(String name, String permission, boolean playersOnly) {
|
||||
this.name = name;
|
||||
@ -36,7 +36,7 @@ public abstract class AbstractCommand implements CommandExecutor, Registerable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
public boolean onCommand(@NotNull CommandSender sender, Command command, @NotNull String label, String[] args) {
|
||||
if(!command.getName().equalsIgnoreCase(name)) return false;
|
||||
|
||||
if(playersOnly && !(sender instanceof Player)) {
|
||||
@ -58,7 +58,7 @@ public abstract class AbstractCommand implements CommandExecutor, Registerable {
|
||||
public final void register() {
|
||||
Bukkit.getPluginCommand(name).setExecutor(this);
|
||||
|
||||
this.tabCompleter = this.getTab();
|
||||
AbstractTabCompleter tabCompleter = this.getTab();
|
||||
if(tabCompleter != null) {
|
||||
Bukkit.getPluginCommand(name).setTabCompleter(tabCompleter);
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import com.willfp.ecoenchants.command.AbstractCommand;
|
||||
import com.willfp.ecoenchants.display.EnchantmentCache;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.extensions.loader.ExtensionLoader;
|
||||
import com.willfp.ecoenchants.util.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -14,11 +13,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -1,10 +1,6 @@
|
||||
package com.willfp.ecoenchants.config;
|
||||
|
||||
import com.willfp.ecoenchants.config.configs.Config;
|
||||
import com.willfp.ecoenchants.config.configs.EnchantmentConfig;
|
||||
import com.willfp.ecoenchants.config.configs.Lang;
|
||||
import com.willfp.ecoenchants.config.configs.Rarity;
|
||||
import com.willfp.ecoenchants.config.configs.Target;
|
||||
import com.willfp.ecoenchants.config.configs.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -54,6 +50,7 @@ public class ConfigManager {
|
||||
* @param permissionName The permission name to match
|
||||
* @return The matching {@link EnchantmentConfig}
|
||||
*/
|
||||
@SuppressWarnings("OptionalGetWithoutIsPresent")
|
||||
public static EnchantmentConfig getEnchantmentConfig(String permissionName) {
|
||||
return enchantmentConfigs.stream().filter(config -> config.getName().equalsIgnoreCase(permissionName)).findFirst().get();
|
||||
}
|
||||
|
@ -6,13 +6,7 @@ import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
@ -27,7 +21,6 @@ public abstract class EnchantmentYamlConfig {
|
||||
private final JavaPlugin plugin = EcoEnchantsPlugin.getInstance();
|
||||
private final Class<?> source;
|
||||
private final EcoEnchant.EnchantmentType type;
|
||||
private final File basedir = new File(this.plugin.getDataFolder(), "enchants/");
|
||||
|
||||
/**
|
||||
* Create new config yml
|
||||
@ -41,6 +34,7 @@ public abstract class EnchantmentYamlConfig {
|
||||
this.source = plugin;
|
||||
this.type = type;
|
||||
|
||||
File basedir = new File(this.plugin.getDataFolder(), "enchants/");
|
||||
if(!basedir.exists()) basedir.mkdirs();
|
||||
|
||||
File dir = new File(basedir, type.getName() + "/");
|
||||
|
@ -5,11 +5,7 @@ import com.willfp.ecoenchants.util.Logger;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public abstract class UpdatingYamlConfig {
|
||||
|
@ -16,11 +16,7 @@ import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -8,12 +8,7 @@ import com.willfp.ecoenchants.util.Logger;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class EnchantmentCache {
|
||||
|
@ -15,7 +15,6 @@ import java.lang.reflect.Modifier;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class PacketOpenWindowMerchant extends AbstractPacketAdapter {
|
||||
public PacketOpenWindowMerchant() {
|
||||
super(PacketType.Play.Server.OPEN_WINDOW_MERCHANT);
|
||||
|
@ -5,9 +5,7 @@ import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.willfp.ecoenchants.display.AbstractPacketAdapter;
|
||||
import com.willfp.ecoenchants.display.EnchantDisplay;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class PacketSetSlot extends AbstractPacketAdapter {
|
||||
public PacketSetSlot() {
|
||||
super(PacketType.Play.Server.SET_SLOT);
|
||||
|
@ -5,9 +5,7 @@ import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.willfp.ecoenchants.display.AbstractPacketAdapter;
|
||||
import com.willfp.ecoenchants.display.EnchantDisplay;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class PacketWindowItems extends AbstractPacketAdapter {
|
||||
public PacketWindowItems() {
|
||||
super(PacketType.Play.Server.WINDOW_ITEMS);
|
||||
|
@ -23,6 +23,7 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
@ -70,7 +71,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
|
||||
"Allows getting " + permissionName + " from an Enchanting Table",
|
||||
PermissionDefault.TRUE
|
||||
);
|
||||
permission.addParent(Bukkit.getPluginManager().getPermission("ecoenchants.fromtable.*"), true);
|
||||
permission.addParent(Objects.requireNonNull(Bukkit.getPluginManager().getPermission("ecoenchants.fromtable.*")), true);
|
||||
Bukkit.getPluginManager().addPermission(permission);
|
||||
}
|
||||
|
||||
@ -345,7 +346,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
|
||||
* @return The display name
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
public @NotNull String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@ -376,7 +377,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public EnchantmentTarget getItemTarget() {
|
||||
public @NotNull EnchantmentTarget getItemTarget() {
|
||||
return EnchantmentTarget.ALL;
|
||||
}
|
||||
|
||||
@ -407,7 +408,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
|
||||
* @return If conflicts
|
||||
*/
|
||||
@Override
|
||||
public boolean conflictsWith(Enchantment enchantment) {
|
||||
public boolean conflictsWith(@NotNull Enchantment enchantment) {
|
||||
return conflicts.contains(enchantment);
|
||||
}
|
||||
|
||||
|
@ -1,22 +1,10 @@
|
||||
package com.willfp.ecoenchants.enchantments;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.*;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.BreaklessnessCurse;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.CallingCurse;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.DecayCurse;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.FragilityCurse;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.HarmlessnessCurse;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.HungerCurse;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.InaccuracyCurse;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.MisfortuneCurse;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.PermanenceCurse;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.*;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.*;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.*;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Charge;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Dynamite;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Missile;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Quake;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Vitalize;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.spell.*;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
@ -5,7 +5,6 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import com.willfp.ecoenchants.util.DurabilityUtils;
|
||||
import com.willfp.ecoenchants.util.Logger;
|
||||
import com.willfp.ecoenchants.util.interfaces.EcoRunnable;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -30,7 +30,7 @@ public class Abrasion extends EcoEnchant {
|
||||
if (attacker instanceof Player && Cooldown.getCooldown((Player) attacker) != 1.0f && !notcharged)
|
||||
return;
|
||||
|
||||
ArrayList<ItemStack> armor = new ArrayList<ItemStack>(Arrays.asList(victim.getInventory().getArmorContents()));
|
||||
ArrayList<ItemStack> armor = new ArrayList<>(Arrays.asList(victim.getInventory().getArmorContents()));
|
||||
if (armor.isEmpty())
|
||||
return;
|
||||
|
||||
|
@ -25,7 +25,7 @@ public class Corrosive extends EcoEnchant {
|
||||
if(!(uncastVictim instanceof Player)) return;
|
||||
Player victim = (Player) uncastVictim;
|
||||
|
||||
ArrayList<ItemStack> armor = new ArrayList<ItemStack>(Arrays.asList(victim.getInventory().getArmorContents()));
|
||||
ArrayList<ItemStack> armor = new ArrayList<>(Arrays.asList(victim.getInventory().getArmorContents()));
|
||||
if (armor.isEmpty())
|
||||
return;
|
||||
|
||||
|
@ -17,7 +17,7 @@ public class EnderSlayer extends EcoEnchant {
|
||||
|
||||
// START OF LISTENERS
|
||||
|
||||
private static Set<EntityType> endMobs = new HashSet<EntityType>() {{
|
||||
private static final Set<EntityType> endMobs = new HashSet<EntityType>() {{
|
||||
add(EntityType.ENDERMITE);
|
||||
add(EntityType.ENDERMAN);
|
||||
add(EntityType.ENDER_DRAGON);
|
||||
|
@ -5,11 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.nms.Cooldown;
|
||||
import com.willfp.ecoenchants.util.VectorUtils;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.PigZombie;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
public class Fury extends EcoEnchant {
|
||||
|
@ -18,15 +18,7 @@ import org.bukkit.inventory.FurnaceRecipe;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class InfernalTouch extends EcoEnchant {
|
||||
|
@ -4,11 +4,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.VectorUtils;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.PigZombie;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
|
@ -2,11 +2,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Blaze;
|
||||
import org.bukkit.entity.Enderman;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.MagmaCube;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
public class LiquidShot extends EcoEnchant {
|
||||
public LiquidShot() {
|
||||
|
@ -4,11 +4,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||
import com.willfp.ecoenchants.util.VectorUtils;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.PigZombie;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
|
@ -22,7 +22,7 @@ public class Slicing extends EcoEnchant {
|
||||
|
||||
// START OF LISTENERS
|
||||
|
||||
ArrayList<LivingEntity> entities = new ArrayList<LivingEntity>();
|
||||
private final ArrayList<LivingEntity> entities = new ArrayList<>();
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerCollide(PlayerMoveEvent event) {
|
||||
@ -49,11 +49,7 @@ public class Slicing extends EcoEnchant {
|
||||
victim.damage(level * damage, player);
|
||||
entities.add(victim);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), new Runnable() {
|
||||
public void run() {
|
||||
entities.remove(victim);
|
||||
}
|
||||
}, this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "cooldown"));
|
||||
Bukkit.getServer().getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> entities.remove(victim), this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "cooldown"));
|
||||
if (this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "damage-elytra")) {
|
||||
DurabilityUtils.damageItem(player, player.getInventory().getChestplate(), 1, 38);
|
||||
}
|
||||
|
@ -6,11 +6,7 @@ import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
|
||||
import com.willfp.ecoenchants.nms.TridentStack;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Trident;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
@ -11,11 +11,7 @@ import com.willfp.ecoenchants.util.DropQueue;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Trident;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
@ -20,7 +20,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({"unchecked", "unused"})
|
||||
public class Aiming extends EcoEnchant {
|
||||
public Aiming() {
|
||||
super(
|
||||
|
@ -34,7 +34,7 @@ public class Confusion extends EcoEnchant {
|
||||
if(!EnchantmentUtils.passedChance(this, level))
|
||||
return;
|
||||
|
||||
List<ItemStack> hotbar = new ArrayList<ItemStack>();
|
||||
List<ItemStack> hotbar = new ArrayList<>();
|
||||
for (int i = 0; i < 9; i++) {
|
||||
hotbar.add(victim.getInventory().getItem(i));
|
||||
}
|
||||
|
@ -29,8 +29,7 @@ public class Frenzy extends EcoEnchant {
|
||||
int level = EnchantChecks.getMainhandLevel(player, this);
|
||||
|
||||
int duration = (int) (level * 20 * this.getConfig().getDouble((EcoEnchants.CONFIG_LOCATION + "seconds-per-level")));
|
||||
int amplifier = level;
|
||||
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, duration, amplifier, true, true, true));
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, duration, level, true, true, true));
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import com.willfp.ecoenchants.util.DurabilityUtils;
|
||||
import com.willfp.ecoenchants.util.Logger;
|
||||
import com.willfp.ecoenchants.util.interfaces.EcoRunnable;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -10,11 +10,7 @@ import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
public class Soulbound extends EcoEnchant {
|
||||
public Soulbound() {
|
||||
super(
|
||||
|
@ -24,7 +24,7 @@ public class Spring extends EcoEnchant {
|
||||
|
||||
@Override
|
||||
public void onJump(Player player, int level, PlayerMoveEvent event) {
|
||||
double multiplier = 0.5 + (double) ((level * level) / 4 - 0.2) / 3;
|
||||
double multiplier = 0.5 + ((double) (level * level) / 4 - 0.2) / 3;
|
||||
player.setVelocity(player.getLocation().getDirection().multiply(multiplier).setY(multiplier));
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public abstract class Artifact extends EcoEnchant {
|
||||
|
||||
public Particle.DustOptions getDustOptions() {
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBreak(BlockBreakEvent event) {
|
||||
@ -144,7 +144,7 @@ public abstract class Artifact extends EcoEnchant {
|
||||
|
||||
int ticks = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "particle-tick-delay");
|
||||
|
||||
int noteColor = 0;
|
||||
int noteColor;
|
||||
AtomicDouble color = new AtomicDouble(0);
|
||||
if(particle.equals(Particle.NOTE)) {
|
||||
noteColor = NumberUtils.randInt(0, 24);
|
||||
|
@ -17,12 +17,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Wrapper for Spell enchantments
|
||||
@ -75,7 +70,7 @@ public abstract class Spell extends EcoEnchant {
|
||||
int level = EnchantChecks.getMainhandLevel(player, this);
|
||||
|
||||
if(!cooldownTracker.containsKey(player.getUniqueId()))
|
||||
cooldownTracker.put(player.getUniqueId(), new SpellRunnable(player, this));
|
||||
cooldownTracker.put(player.getUniqueId(), new SpellRunnable(this));
|
||||
|
||||
SpellRunnable runnable = cooldownTracker.get(player.getUniqueId());
|
||||
runnable.setTask(() -> {
|
||||
@ -101,7 +96,7 @@ public abstract class Spell extends EcoEnchant {
|
||||
|
||||
public static int getCooldown(Spell spell, Player player) {
|
||||
if(!spell.cooldownTracker.containsKey(player.getUniqueId()))
|
||||
spell.cooldownTracker.put(player.getUniqueId(), new SpellRunnable(player, spell));
|
||||
spell.cooldownTracker.put(player.getUniqueId(), new SpellRunnable(spell));
|
||||
|
||||
SpellRunnable runnable = spell.cooldownTracker.get(player.getUniqueId());
|
||||
|
||||
|
@ -145,7 +145,6 @@ public class EnchantmentRarity implements Registerable {
|
||||
public static void update() {
|
||||
Set<String> raritiesNames = ConfigManager.getRarity().getRarities();
|
||||
raritiesNames.forEach((rarity) -> {
|
||||
String name = rarity;
|
||||
double probability = ConfigManager.getRarity().getDouble("rarities." + rarity + ".table-probability");
|
||||
int minimumLevel = ConfigManager.getRarity().getInt("rarities." + rarity + ".minimum-level");
|
||||
double villagerProbability = ConfigManager.getRarity().getDouble("rarities." + rarity + ".villager-probability");
|
||||
@ -155,7 +154,7 @@ public class EnchantmentRarity implements Registerable {
|
||||
customColor = StringUtils.translate(ConfigManager.getRarity().getString("rarities." + rarity + ".custom-color.color"));
|
||||
}
|
||||
|
||||
new EnchantmentRarity(name, probability, minimumLevel, villagerProbability, lootProbability, customColor).register();
|
||||
new EnchantmentRarity(rarity, probability, minimumLevel, villagerProbability, lootProbability, customColor).register();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import com.willfp.ecoenchants.config.ConfigManager;
|
||||
import com.willfp.ecoenchants.integrations.anvilgui.AnvilGUIManager;
|
||||
import com.willfp.ecoenchants.nms.RepairCost;
|
||||
import com.willfp.ecoenchants.util.Logger;
|
||||
import com.willfp.ecoenchants.util.NumberUtils;
|
||||
import com.willfp.ecoenchants.util.tuplets.Pair;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -12,7 +12,6 @@ import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
@ -18,12 +18,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class EnchantingListeners implements Listener {
|
||||
@ -34,7 +29,7 @@ public class EnchantingListeners implements Listener {
|
||||
add(Material.SHEARS);
|
||||
add(Material.CARROT_ON_A_STICK);
|
||||
}};
|
||||
public static HashMap<Player, int[]> currentlyEnchantingSecondary = new HashMap<>();
|
||||
public static final HashMap<Player, int[]> currentlyEnchantingSecondary = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerLeave(PlayerQuitEvent event) {
|
||||
|
@ -14,11 +14,7 @@ import org.bukkit.inventory.MerchantRecipe;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class VillagerListeners implements Listener {
|
||||
@ -66,7 +62,7 @@ public class VillagerListeners implements Listener {
|
||||
level = (int) Math.ceil(enchantlevel2 / enchantlevel3);
|
||||
} else {
|
||||
int cost = event.getRecipe().getIngredients().get(0).getAmount();
|
||||
double enchantlevel1 = cost / 64;
|
||||
double enchantlevel1 = (double) cost / 64;
|
||||
double enchantlevel2 = NumberUtils.triangularDistribution(0, 1, enchantlevel1);
|
||||
double enchantlevel3 = 1 / (double) enchantment.getMaxLevel();
|
||||
level = (int) Math.ceil(enchantlevel2 / enchantlevel3);
|
||||
@ -147,7 +143,7 @@ public class VillagerListeners implements Listener {
|
||||
level = (int) Math.ceil(enchantlevel2 / enchantlevel3);
|
||||
} else {
|
||||
int cost = event.getRecipe().getIngredients().get(0).getAmount();
|
||||
double enchantlevel1 = cost / 64;
|
||||
double enchantlevel1 = (double) cost / 64;
|
||||
double enchantlevel2 = NumberUtils.triangularDistribution(0, 1, enchantlevel1);
|
||||
double enchantlevel3 = 1 / (double) enchantment.getMaxLevel();
|
||||
level = (int) Math.ceil(enchantlevel2 / enchantlevel3);
|
||||
|
@ -2,18 +2,13 @@ package com.willfp.ecoenchants.enchantments.util;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.itemtypes.Spell;
|
||||
import com.willfp.ecoenchants.util.interfaces.Callable;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpellRunnable {
|
||||
private final UUID player;
|
||||
private final Spell spell;
|
||||
private long endTime = 0;
|
||||
private Callable callable = () -> {};
|
||||
|
||||
public SpellRunnable(Player player, Spell spell) {
|
||||
this.player = player.getUniqueId();
|
||||
public SpellRunnable(Spell spell) {
|
||||
this.spell = spell;
|
||||
}
|
||||
|
||||
|
@ -8,11 +8,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Trident;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public interface Watcher {
|
||||
|
@ -10,20 +10,12 @@ import com.willfp.ecoenchants.nms.TridentStack;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Trident;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Arnah
|
||||
@ -34,7 +35,7 @@ public class ArmorEquipEvent extends PlayerEvent implements Cancellable {
|
||||
*/
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
@ -10,11 +10,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.inventory.*;
|
||||
import org.bukkit.event.inventory.InventoryType.SlotType;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemBreakEvent;
|
||||
|
@ -34,12 +34,12 @@ public class EntityDeathByEntityEvent extends Event {
|
||||
/**
|
||||
* The entity drops
|
||||
*/
|
||||
private List<ItemStack> drops;
|
||||
private final List<ItemStack> drops;
|
||||
|
||||
/**
|
||||
* The xp to drop
|
||||
*/
|
||||
private int xp;
|
||||
private final int xp;
|
||||
|
||||
/**
|
||||
* Create event based off parameters
|
||||
@ -49,7 +49,7 @@ public class EntityDeathByEntityEvent extends Event {
|
||||
* @param xp The amount of xp to drop
|
||||
* @param deathEvent The associated {@link EntityDeathEvent}
|
||||
*/
|
||||
public EntityDeathByEntityEvent(@NotNull LivingEntity victim, @NotNull Entity damager, @NotNull List<ItemStack> drops, @NotNull int xp, @NotNull EntityDeathEvent deathEvent) {
|
||||
public EntityDeathByEntityEvent(@NotNull LivingEntity victim, @NotNull Entity damager, @NotNull List<ItemStack> drops, int xp, @NotNull EntityDeathEvent deathEvent) {
|
||||
this.victim = victim;
|
||||
this.damager = damager;
|
||||
this.drops = drops;
|
||||
@ -99,7 +99,7 @@ public class EntityDeathByEntityEvent extends Event {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class EntityDeathByEntityListeners implements Listener {
|
||||
|
||||
Set<EntityDeathByEntityBuilder> events = new HashSet<>();
|
||||
final Set<EntityDeathByEntityBuilder> events = new HashSet<>();
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event) {
|
||||
@ -35,8 +35,7 @@ public class EntityDeathByEntityListeners implements Listener {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(events.contains(builtEvent))
|
||||
events.remove(builtEvent);
|
||||
events.remove(builtEvent);
|
||||
}
|
||||
}.runTaskLater(EcoEnchantsPlugin.getInstance(), 1);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.player.PlayerExpChangeEvent;
|
||||
|
||||
class NaturalExpGainBuilder {
|
||||
private LivingEntity victim = null;
|
||||
private final LivingEntity victim = null;
|
||||
private boolean cancelled = false;
|
||||
private PlayerExpChangeEvent event;
|
||||
private Location loc;
|
||||
|
@ -34,7 +34,7 @@ public class NaturalExpGainEvent extends Event {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class NaturalExpGainListeners implements Listener {
|
||||
|
||||
Set<NaturalExpGainBuilder> events = new HashSet<>();
|
||||
final Set<NaturalExpGainBuilder> events = new HashSet<>();
|
||||
|
||||
@EventHandler
|
||||
public void onExpChange(PlayerExpChangeEvent event) {
|
||||
|
@ -1,11 +1,8 @@
|
||||
package com.willfp.ecoenchants.extensions.loader;
|
||||
|
||||
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.extensions.Extension;
|
||||
import com.willfp.ecoenchants.extensions.MalformedExtensionException;
|
||||
import com.willfp.ecoenchants.util.Logger;
|
||||
import com.willfp.ecoenchants.util.tuplets.Pair;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
@ -15,8 +12,10 @@ import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Class containing method to load extensions
|
||||
|
@ -1,10 +1,6 @@
|
||||
package com.willfp.ecoenchants.integrations.antigrief.plugins;
|
||||
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.perms.PermissibleAction;
|
||||
import com.willfp.ecoenchants.integrations.antigrief.AntigriefWrapper;
|
||||
import org.bukkit.Location;
|
||||
|
@ -6,6 +6,7 @@ import com.willfp.ecoenchants.integrations.placeholder.PlaceholderManager;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlaceholderIntegrationPAPI extends PlaceholderExpansion implements PlaceholderIntegration {
|
||||
@Override
|
||||
@ -19,22 +20,22 @@ public class PlaceholderIntegrationPAPI extends PlaceholderExpansion implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthor() {
|
||||
public @NotNull String getAuthor() {
|
||||
return "Auxilor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
public @NotNull String getIdentifier() {
|
||||
return "ecoenchants";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
public @NotNull String getVersion() {
|
||||
return EcoEnchantsPlugin.getInstance().getDescription().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player player, String identifier) {
|
||||
public String onPlaceholderRequest(Player player, @NotNull String identifier) {
|
||||
return PlaceholderManager.getResult(player, identifier);
|
||||
}
|
||||
|
||||
|
@ -2,11 +2,7 @@ package com.willfp.ecoenchants.util;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.SoundCategory;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -27,19 +27,13 @@ import com.willfp.ecoenchants.events.armorequip.ArmorListener;
|
||||
import com.willfp.ecoenchants.events.armorequip.DispenserArmorListener;
|
||||
import com.willfp.ecoenchants.events.entitydeathbyentity.EntityDeathByEntityListeners;
|
||||
import com.willfp.ecoenchants.events.naturalexpgainevent.NaturalExpGainListeners;
|
||||
import com.willfp.ecoenchants.extensions.loader.ExtensionLoader;
|
||||
import com.willfp.ecoenchants.integrations.anticheat.AnticheatManager;
|
||||
import com.willfp.ecoenchants.integrations.anticheat.plugins.AnticheatAAC;
|
||||
import com.willfp.ecoenchants.integrations.anticheat.plugins.AnticheatMatrix;
|
||||
import com.willfp.ecoenchants.integrations.anticheat.plugins.AnticheatNCP;
|
||||
import com.willfp.ecoenchants.integrations.anticheat.plugins.AnticheatSpartan;
|
||||
import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
|
||||
import com.willfp.ecoenchants.integrations.antigrief.plugins.AntigriefFactionsUUID;
|
||||
import com.willfp.ecoenchants.integrations.antigrief.plugins.AntigriefGriefPrevention;
|
||||
import com.willfp.ecoenchants.integrations.antigrief.plugins.AntigriefKingdoms;
|
||||
import com.willfp.ecoenchants.integrations.antigrief.plugins.AntigriefLands;
|
||||
import com.willfp.ecoenchants.integrations.antigrief.plugins.AntigriefTowny;
|
||||
import com.willfp.ecoenchants.integrations.antigrief.plugins.AntigriefWorldGuard;
|
||||
import com.willfp.ecoenchants.integrations.antigrief.plugins.*;
|
||||
import com.willfp.ecoenchants.integrations.anvilgui.AnvilGUIManager;
|
||||
import com.willfp.ecoenchants.integrations.anvilgui.plugins.AnvilGUIImpl;
|
||||
import com.willfp.ecoenchants.integrations.essentials.EssentialsManager;
|
||||
@ -50,11 +44,7 @@ import com.willfp.ecoenchants.integrations.placeholder.PlaceholderManager;
|
||||
import com.willfp.ecoenchants.integrations.placeholder.plugins.PlaceholderIntegrationPAPI;
|
||||
import com.willfp.ecoenchants.listeners.ArrowListeners;
|
||||
import com.willfp.ecoenchants.listeners.PlayerJoinListener;
|
||||
import com.willfp.ecoenchants.nms.BlockBreak;
|
||||
import com.willfp.ecoenchants.nms.Cooldown;
|
||||
import com.willfp.ecoenchants.nms.OpenInventory;
|
||||
import com.willfp.ecoenchants.nms.RepairCost;
|
||||
import com.willfp.ecoenchants.nms.TridentStack;
|
||||
import com.willfp.ecoenchants.nms.*;
|
||||
import com.willfp.ecoenchants.util.interfaces.Callable;
|
||||
import com.willfp.ecoenchants.util.interfaces.EcoRunnable;
|
||||
import com.willfp.ecoenchants.util.optional.Prerequisite;
|
||||
@ -65,11 +55,7 @@ import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -12,20 +12,20 @@ import static net.md_5.bungee.api.ChatColor.COLOR_CHAR;
|
||||
public class StringUtils {
|
||||
public static String translate(String message, Player player) {
|
||||
message = PlaceholderManager.translatePlaceholders(message, player);
|
||||
message = translateHexColorCodes("&#", "", message);
|
||||
message = translateHexColorCodes(message);
|
||||
message = ChatColor.translateAlternateColorCodes('&', message);
|
||||
return ChatColor.translateAlternateColorCodes('&', translateHexColorCodes("&#", "", message));
|
||||
return ChatColor.translateAlternateColorCodes('&', translateHexColorCodes(message));
|
||||
}
|
||||
|
||||
public static String translate(String message) {
|
||||
message = PlaceholderManager.translatePlaceholders(message, null);
|
||||
message = translateHexColorCodes("&#", "", message);
|
||||
message = translateHexColorCodes(message);
|
||||
message = ChatColor.translateAlternateColorCodes('&', message);
|
||||
return ChatColor.translateAlternateColorCodes('&', translateHexColorCodes("&#", "", message));
|
||||
return ChatColor.translateAlternateColorCodes('&', translateHexColorCodes(message));
|
||||
}
|
||||
|
||||
private static String translateHexColorCodes(String startTag, String endTag, String message) {
|
||||
Pattern hexPattern = Pattern.compile(startTag + "([A-Fa-f0-9]{6})" + endTag);
|
||||
private static String translateHexColorCodes(String message) {
|
||||
Pattern hexPattern = Pattern.compile("&#" + "([A-Fa-f0-9]{6})" + "");
|
||||
Matcher matcher = hexPattern.matcher(message);
|
||||
StringBuffer buffer = new StringBuffer(message.length() + 4 * 8);
|
||||
while(matcher.find()) {
|
||||
|
@ -12,7 +12,7 @@ public class VectorShapes {
|
||||
* @return An array of {@link Vector}s
|
||||
*/
|
||||
public static Vector[] getCircle(int radius) {
|
||||
ArrayList<Vector> circleVecs = new ArrayList<Vector>();
|
||||
ArrayList<Vector> circleVecs = new ArrayList<>();
|
||||
|
||||
int xoffset = -radius;
|
||||
int zoffset = -radius;
|
||||
@ -40,7 +40,7 @@ public class VectorShapes {
|
||||
* @return An array of {@link Vector}s
|
||||
*/
|
||||
public static Vector[] getSquare(int radius) {
|
||||
ArrayList<Vector> circleVecs = new ArrayList<Vector>();
|
||||
ArrayList<Vector> circleVecs = new ArrayList<>();
|
||||
|
||||
int xoffset = -radius;
|
||||
int zoffset = -radius;
|
||||
@ -63,7 +63,7 @@ public class VectorShapes {
|
||||
* @return An array of {@link Vector}s
|
||||
*/
|
||||
public static Vector[] getCube(int radius) {
|
||||
ArrayList<Vector> cubeVecs = new ArrayList<Vector>();
|
||||
ArrayList<Vector> cubeVecs = new ArrayList<>();
|
||||
|
||||
int xoffset = -radius;
|
||||
int zoffset = -radius;
|
||||
|
Loading…
Reference in New Issue
Block a user