!Small cleanup

This commit is contained in:
Indyuce 2020-09-20 12:56:39 +02:00
parent 239e3c9eff
commit a50d9619fd
3 changed files with 26 additions and 29 deletions

View File

@ -514,9 +514,6 @@ public class PlayerData {
public enum CooldownType { public enum CooldownType {
// either for consumables or for commands
ITEM,
// simple attack cooldown // simple attack cooldown
ATTACK, ATTACK,

View File

@ -1,17 +1,18 @@
package net.Indyuce.mmoitems.manager; package net.Indyuce.mmoitems.manager;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ConfigFile;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.manager.ConfigManager.DefaultFile;
import org.apache.commons.lang.Validate;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
import org.apache.commons.lang.Validate;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ConfigFile;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.manager.ConfigManager.DefaultFile;
public class TypeManager { public class TypeManager {
private final Map<String, Type> map = new LinkedHashMap<>(); private final Map<String, Type> map = new LinkedHashMap<>();
@ -71,7 +72,6 @@ public class TypeManager {
register(type); register(type);
} }
// TODO minor refactor, use Optional<Type>
public Type get(String id) { public Type get(String id) {
return map.get(id); return map.get(id);
} }

View File

@ -1,5 +1,23 @@
package net.Indyuce.mmoitems.manager; package net.Indyuce.mmoitems.manager;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
import java.util.logging.Level;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ConfigFile; import net.Indyuce.mmoitems.api.ConfigFile;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
@ -13,23 +31,6 @@ import net.Indyuce.mmoitems.api.util.TemplateMap;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.item.NBTItem; import net.mmogroup.mmolib.api.item.NBTItem;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
import java.util.logging.Level;
public class UpdaterManager implements Listener { public class UpdaterManager implements Listener {
private final TemplateMap<UpdaterData> data = new TemplateMap<>(); private final TemplateMap<UpdaterData> data = new TemplateMap<>();
@ -43,7 +44,7 @@ public class UpdaterManager implements Listener {
MMOItemTemplate template = MMOItems.plugin.getTemplates().getTemplateOrThrow(type, id); MMOItemTemplate template = MMOItems.plugin.getTemplates().getTemplateOrThrow(type, id);
enable(new UpdaterData(template, config.getConfigurationSection(typeFormat + "." + id))); enable(new UpdaterData(template, config.getConfigurationSection(typeFormat + "." + id)));
} }
} catch (IllegalArgumentException | NullPointerException exception) { } catch (IllegalArgumentException exception) {
MMOItems.plugin.getLogger().log(Level.WARNING, MMOItems.plugin.getLogger().log(Level.WARNING,
"An issue occurred while trying to load dynamic updater data: " + exception.getMessage()); "An issue occurred while trying to load dynamic updater data: " + exception.getMessage());
} }
@ -128,7 +129,6 @@ public class UpdaterManager implements Listener {
* need to be updated * need to be updated
*/ */
Type type = item.getType(); Type type = item.getType();
if (type == null || !data.hasValue(type, item.getString("MMOITEMS_ITEM_ID"))) if (type == null || !data.hasValue(type, item.getString("MMOITEMS_ITEM_ID")))
return item.getItem(); return item.getItem();