diff --git a/lib/MMOLib.jar b/lib/MMOLib.jar index b15f19fd..acd624c1 100644 Binary files a/lib/MMOLib.jar and b/lib/MMOLib.jar differ diff --git a/lib/spigot-sources.jar b/lib/spigot-sources.jar index 2c101366..fd6a4d47 100644 Binary files a/lib/spigot-sources.jar and b/lib/spigot-sources.jar differ diff --git a/lib/spigot.jar b/lib/spigot.jar index f4651170..f3626ea7 100644 Binary files a/lib/spigot.jar and b/lib/spigot.jar differ diff --git a/pom.xml b/pom.xml index 8dce9cea..53946afb 100644 --- a/pom.xml +++ b/pom.xml @@ -1,97 +1,100 @@ - - 4.0.0 - net.Indyuce - MMOCore - 1.3 - Offer your players a brand new RPG experience. - - - SNAPSHOT - false + + 4.0.0 + net.Indyuce + MMOCore + 1.4.1 + MMOCore + Offer your players a brand new RPG experience. + + + SNAPSHOT + false false UTF-8 UTF-8 - - + + - nexus - Lumine Releases - http://mvn.lumine.io/repository/maven-releases/ - - - nexus - Lumine Snapshots - http://mvn.lumine.io/repository/maven-snapshots/ - - - - - ${project.name}-${project.version} - - - true - ${basedir}/src/main/resources/ - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - junit:junit - UTF-8 - UTF-8 - UTF-8 - -ea -Dfile.encoding=UTF-8 - - - - - - - jitpack.io - https://jitpack.io + nexus + Lumine Releases + http://mvn.lumine.io/repository/maven-releases/ - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - - sk89q-repo - https://maven.enginehub.org/repo/ - - - placeholderapi - http://repo.extendedclip.com/content/repositories/placeholderapi/ - - - - - - net.Indyuce - mmoitems - 5.1.2 - system - ${basedir}/lib/MMOItems.jar - + + nexus + Lumine Snapshots + http://mvn.lumine.io/repository/maven-snapshots/ + + + + + ${project.name}-${project.version} + + + true + ${basedir}/src/main/resources/ + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + junit:junit + UTF-8 + UTF-8 + UTF-8 + -ea -Dfile.encoding=UTF-8 + + + + + + + jitpack.io + https://jitpack.io + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + sk89q-repo + https://maven.enginehub.org/repo/ + + + placeholderapi + http://repo.extendedclip.com/content/repositories/placeholderapi/ + + + + + + net.Indyuce + mmoitems + 5.1.2 + system + ${basedir}/lib/MMOItems.jar + net.Indyuce MMOLib 1.0 - system - ${basedir}/lib/MMOLib.jar + system + ${basedir}/lib/MMOLib.jar + + + + org.spigotmc + spigot-api + 1.14.4 + system + ${basedir}/lib/spigot.jar - - - org.spigotmc - spigot-api - 1.14.4 - system - ${basedir}/lib/spigot.jar - com.bekvon.bukkit Residence @@ -99,63 +102,63 @@ system ${basedir}/lib/Residence.jar - - com.Zrips - CMI - 8.6.5.0 - system - ${basedir}/lib/CMI.jar - - - com.sainttx.holograms - holograms - 2.9.1 - system - ${basedir}/lib/Holograms.jar - - - com.gmail.filoghost - HolographicDisplays - 6.9.1 - system - ${basedir}/lib/HolographicDisplays.jar - - - io.lumine.xikage - MythicMobs - 4.8.0 - system - ${basedir}/lib/MythicMobs.jar - - - com.github.MilkBowl - VaultAPI - 1.7 - provided - - - com.sk89q.worldguard - worldguard-bukkit - 7.0.1-SNAPSHOT - provided - - - net.citizensnpcs - citizens - 2.0.25-SNAPSHOT - system - ${basedir}/lib/Citizens.jar - - - me.clip - placeholderapi - 2.10.3 - provided - - - mysql - mysql-connector-java - 5.1.41 - - + + com.Zrips + CMI + 8.6.5.0 + system + ${basedir}/lib/CMI.jar + + + com.sainttx.holograms + holograms + 2.9.1 + system + ${basedir}/lib/Holograms.jar + + + com.gmail.filoghost + HolographicDisplays + 6.9.1 + system + ${basedir}/lib/HolographicDisplays.jar + + + io.lumine.xikage + MythicMobs + 4.8.0 + system + ${basedir}/lib/MythicMobs.jar + + + com.github.MilkBowl + VaultAPI + 1.7 + provided + + + com.sk89q.worldguard + worldguard-bukkit + 7.0.2-SNAPSHOT + provided + + + net.citizensnpcs + citizens + 2.0.25-SNAPSHOT + system + ${basedir}/lib/Citizens.jar + + + me.clip + placeholderapi + 2.10.3 + provided + + + mysql + mysql-connector-java + 5.1.41 + + \ No newline at end of file diff --git a/src/main/java/net/Indyuce/mmocore/MMOCore.java b/src/main/java/net/Indyuce/mmocore/MMOCore.java index 1e273cde..c3646c6c 100644 --- a/src/main/java/net/Indyuce/mmocore/MMOCore.java +++ b/src/main/java/net/Indyuce/mmocore/MMOCore.java @@ -151,6 +151,13 @@ public class MMOCore extends JavaPlugin { if (Bukkit.getPluginManager().getPlugin("MythicMobs") != null) loadManager.registerLoader(new MythicMobsMMOLoader()); + + /* + * WorldGuard closes the flag registry after 'onLoad()', + * so it must be registered here or it will throw an IllegalStateException + */ + if(Bukkit.getPluginManager().getPlugin("WorldGuard") != null) + flagPlugin = new WorldGuardFlags(); } public void onEnable() { @@ -176,7 +183,6 @@ public class MMOCore extends JavaPlugin { if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null) { regionHandler = new WorldGuardRegionHandler(); - flagPlugin = new WorldGuardFlags(); getLogger().log(Level.INFO, "Hooked onto WorldGuard"); } else if (Bukkit.getPluginManager().getPlugin("Residence") != null) { flagPlugin = new ResidenceFlags(); @@ -256,8 +262,8 @@ public class MMOCore extends JavaPlugin { /* * enable debug mode for extra debug tools. */ - if (getConfig().getBoolean("debug")) - new DebugMode(); + if (getConfig().contains("debug")) + new DebugMode(getConfig().getInt("debug", 0)); if (configManager.overrideVanillaExp = getConfig().getBoolean("override-vanilla-exp")) Bukkit.getPluginManager().registerEvents(new VanillaExperienceOverride(), this); @@ -295,7 +301,9 @@ public class MMOCore extends JavaPlugin { */ dataProvider.getGuildManager().load(); - // commands + /* + * commands + */ try { final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap"); @@ -385,6 +393,10 @@ public class MMOCore extends JavaPlugin { // experience must be loaded before professions and classes experience.reload(); + + // drop tables must be loaded before professions + dropTableManager.clear(); + dropTableManager.reload(); professionManager.clear(); professionManager.reload(); @@ -394,9 +406,6 @@ public class MMOCore extends JavaPlugin { inventoryManager = new InventoryManager(); - dropTableManager.clear(); - dropTableManager.reload(); - questManager.clear(); questManager.reload(); @@ -414,10 +423,19 @@ public class MMOCore extends JavaPlugin { log(Level.INFO, message); } + public static void debug(int value, String message) { + debug(value, Level.INFO, message); + } + public static void log(Level level, String message) { plugin.getLogger().log(level, message); } + public static void debug(int value, Level level, String message) { + if(DebugMode.level > (value - 1)) + plugin.getLogger().log(level, message); + } + public File getJarFile() { return getFile(); } diff --git a/src/main/java/net/Indyuce/mmocore/api/ConfigMessage.java b/src/main/java/net/Indyuce/mmocore/api/ConfigMessage.java index ce6578fd..f97c6682 100644 --- a/src/main/java/net/Indyuce/mmocore/api/ConfigMessage.java +++ b/src/main/java/net/Indyuce/mmocore/api/ConfigMessage.java @@ -3,11 +3,11 @@ package net.Indyuce.mmocore.api; import java.util.Collection; import java.util.List; -import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import net.Indyuce.mmocore.MMOCore; +import net.asangarin.hexcolors.ColorParse; import net.mmogroup.mmolib.MMOLib; public class ConfigMessage { @@ -31,14 +31,14 @@ public class ConfigMessage { } public void send(CommandSender sender) { - messages.forEach(line -> sender.sendMessage(ChatColor.translateAlternateColorCodes('&', line))); + messages.forEach(line -> sender.sendMessage(new ColorParse('&', line).toChatColor())); } public void send(Collection players) { - players.forEach(player -> messages.forEach(line -> player.sendMessage(ChatColor.translateAlternateColorCodes('&', MMOCore.plugin.placeholderParser.parse(player, line))))); + players.forEach(player -> messages.forEach(line -> player.sendMessage(new ColorParse('&', MMOCore.plugin.placeholderParser.parse(player, line)).toChatColor()))); } public void sendAsJSon(Player player) { - messages.forEach(line -> MMOLib.plugin.getNMS().sendJson(player, ChatColor.translateAlternateColorCodes('&', line))); + messages.forEach(line -> MMOLib.plugin.getNMS().sendJson(player, new ColorParse('&', line).toChatColor())); } } diff --git a/src/main/java/net/Indyuce/mmocore/api/PlayerActionBar.java b/src/main/java/net/Indyuce/mmocore/api/PlayerActionBar.java index 3d704b6d..7f21d210 100644 --- a/src/main/java/net/Indyuce/mmocore/api/PlayerActionBar.java +++ b/src/main/java/net/Indyuce/mmocore/api/PlayerActionBar.java @@ -2,7 +2,6 @@ package net.Indyuce.mmocore.api; import java.text.DecimalFormat; -import org.bukkit.ChatColor; import org.bukkit.attribute.Attribute; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.scheduler.BukkitRunnable; @@ -10,6 +9,7 @@ import org.bukkit.scheduler.BukkitRunnable; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.stats.StatType; +import net.asangarin.hexcolors.ColorParse; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; @@ -31,7 +31,7 @@ public class PlayerActionBar extends BukkitRunnable { for (PlayerData data : PlayerData.getAll()) if (data.isOnline() && !data.getPlayer().isDead() && !data.isCasting() && data.canSeeActionBar()) { data.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(MMOCore.plugin.placeholderParser.parse(data.getPlayer(), - ChatColor.translateAlternateColorCodes('&', new String(format) + new ColorParse('&', new String(format) .replace("{health}", digit.format(data.getPlayer().getHealth())) .replace("{max_health}", "" + StatType.MAX_HEALTH.format(data.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue())) .replace("{mana_icon}", data.getProfess().getManaDisplay().getIcon()) @@ -45,7 +45,7 @@ public class PlayerActionBar extends BukkitRunnable { .replace("{xp}", "" + data.getExperience()) .replace("{armor}", "" + StatType.ARMOR.format(data.getPlayer().getAttribute(Attribute.GENERIC_ARMOR).getValue())) .replace("{level}", "" + data.getLevel()) - .replace("{name}", data.getPlayer().getDisplayName()))))); + .replace("{name}", data.getPlayer().getDisplayName())).toChatColor()))); } } } diff --git a/src/main/java/net/Indyuce/mmocore/api/event/MMOCommandEvent.java b/src/main/java/net/Indyuce/mmocore/api/event/MMOCommandEvent.java new file mode 100644 index 00000000..2e6527cc --- /dev/null +++ b/src/main/java/net/Indyuce/mmocore/api/event/MMOCommandEvent.java @@ -0,0 +1,42 @@ +package net.Indyuce.mmocore.api.event; + +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +import net.Indyuce.mmocore.api.player.PlayerData; + +public class MMOCommandEvent extends PlayerDataEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + + private final String command; + + public MMOCommandEvent(PlayerData player, String command) { + super(player); + + this.command = command; + } + + public String getCommand() { + return command; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean b) { + cancelled = b; + } +} diff --git a/src/main/java/net/Indyuce/mmocore/api/event/PlayerExperienceGainEvent.java b/src/main/java/net/Indyuce/mmocore/api/event/PlayerExperienceGainEvent.java index eb740b08..1d3e04cf 100644 --- a/src/main/java/net/Indyuce/mmocore/api/event/PlayerExperienceGainEvent.java +++ b/src/main/java/net/Indyuce/mmocore/api/event/PlayerExperienceGainEvent.java @@ -3,6 +3,7 @@ package net.Indyuce.mmocore.api.event; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import net.Indyuce.mmocore.api.experience.EXPSource; import net.Indyuce.mmocore.api.experience.Profession; import net.Indyuce.mmocore.api.player.PlayerData; @@ -11,19 +12,21 @@ public class PlayerExperienceGainEvent extends PlayerDataEvent implements Cancel // if null, this is main experience private final Profession profession; + private final EXPSource source; private int experience; private boolean cancelled; - public PlayerExperienceGainEvent(PlayerData player, int experience) { - this(player, null, experience); + public PlayerExperienceGainEvent(PlayerData player, int experience, EXPSource source) { + this(player, null, experience, source); } - public PlayerExperienceGainEvent(PlayerData player, Profession profession, int experience) { + public PlayerExperienceGainEvent(PlayerData player, Profession profession, int experience, EXPSource source) { super(player); this.profession = profession; this.experience = experience; + this.source = source; } public int getExperience() { @@ -52,6 +55,10 @@ public class PlayerExperienceGainEvent extends PlayerDataEvent implements Cancel return profession; } + public EXPSource getSource() { + return source; + } + @Override public HandlerList getHandlers() { return handlers; diff --git a/src/main/java/net/Indyuce/mmocore/api/experience/Booster.java b/src/main/java/net/Indyuce/mmocore/api/experience/Booster.java index 69670310..5aa99ed2 100644 --- a/src/main/java/net/Indyuce/mmocore/api/experience/Booster.java +++ b/src/main/java/net/Indyuce/mmocore/api/experience/Booster.java @@ -4,11 +4,15 @@ import java.util.UUID; public class Booster { private final UUID uuid = UUID.randomUUID(); - private final long date = System.currentTimeMillis(), length; + private final long date = System.currentTimeMillis(); private final Profession profession; private final double extra; private final String author; + // length not final because boosters can stack, this allows to reduce the + // amount of boosters + private long length; + public Booster(double extra, long length) { this(null, null, extra, length); } @@ -40,6 +44,10 @@ public class Booster { return length; } + public void addLength(long length) { + this.length += length; + } + public boolean hasProfession() { return profession != null; } @@ -67,4 +75,8 @@ public class Booster { public String getAuthor() { return author; } + + public boolean canStackWith(Booster booster) { + return extra == booster.extra && (profession != null ? profession.equals(booster.getProfession()) : booster.getProfession() == null); + } } diff --git a/src/main/java/net/Indyuce/mmocore/api/experience/EXPSource.java b/src/main/java/net/Indyuce/mmocore/api/experience/EXPSource.java new file mode 100644 index 00000000..df28b5f7 --- /dev/null +++ b/src/main/java/net/Indyuce/mmocore/api/experience/EXPSource.java @@ -0,0 +1,10 @@ +package net.Indyuce.mmocore.api.experience; + +public enum EXPSource { + SOURCE, + COMMAND, + VANILLA, + QUEST, + FISHING, + OTHER; +} diff --git a/src/main/java/net/Indyuce/mmocore/api/player/ExpCurve.java b/src/main/java/net/Indyuce/mmocore/api/experience/ExpCurve.java similarity index 94% rename from src/main/java/net/Indyuce/mmocore/api/player/ExpCurve.java rename to src/main/java/net/Indyuce/mmocore/api/experience/ExpCurve.java index 9f8a66e7..798d8b49 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/ExpCurve.java +++ b/src/main/java/net/Indyuce/mmocore/api/experience/ExpCurve.java @@ -1,4 +1,4 @@ -package net.Indyuce.mmocore.api.player; +package net.Indyuce.mmocore.api.experience; import java.io.BufferedReader; import java.io.File; diff --git a/src/main/java/net/Indyuce/mmocore/api/experience/PlayerProfessions.java b/src/main/java/net/Indyuce/mmocore/api/experience/PlayerProfessions.java index 81e4d533..42904ccc 100644 --- a/src/main/java/net/Indyuce/mmocore/api/experience/PlayerProfessions.java +++ b/src/main/java/net/Indyuce/mmocore/api/experience/PlayerProfessions.java @@ -17,6 +17,7 @@ import com.google.gson.JsonObject; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.ConfigMessage; +import net.Indyuce.mmocore.api.event.PlayerExperienceGainEvent; import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.util.math.particle.SmallParticleEffect; @@ -102,29 +103,28 @@ public class PlayerProfessions { exp.put(profession.getId(), value); } - public void giveLevels(Profession profession, int value) { + public void giveLevels(Profession profession, int value, EXPSource source) { int total = 0, level = getLevel(profession); while (value-- > 0) total += profession.getExpCurve().getExperience(level + value + 1); - giveExperience(profession, total); + giveExperience(profession, total, source); } - public void giveExperience(Profession profession, int value) { - giveExperience(profession, value, null); + public void giveExperience(Profession profession, int value, EXPSource source) { + giveExperience(profession, value, null, source); } public boolean hasReachedMaxLevel(Profession profession) { return profession.hasMaxLevel() && getLevel(profession) >= profession.getMaxLevel(); } - public void giveExperience(Profession profession, int value, Location loc) { + public void giveExperience(Profession profession, int value, Location loc, EXPSource source) { if(hasReachedMaxLevel(profession)) { setExperience(profession, 0); return; } value = MMOCore.plugin.boosterManager.calculateExp(profession, value); - exp.put(profession.getId(), exp.containsKey(profession.getId()) ? exp.get(profession.getId()) + value : value); // display hologram if (MMOCore.plugin.getConfig().getBoolean("display-exp-holograms")) @@ -132,6 +132,12 @@ public class PlayerProfessions { MMOCore.plugin.hologramSupport.displayIndicator(loc.add(.5, 1.5, .5), MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + value).message(), playerData.getPlayer()); + PlayerExperienceGainEvent event = new PlayerExperienceGainEvent(playerData, profession, value, source); + Bukkit.getPluginManager().callEvent(event); + if (event.isCancelled()) + return; + + exp.put(profession.getId(), exp.containsKey(profession.getId()) ? exp.get(profession.getId()) + value : value); int needed, exp, level, oldLevel = getLevel(profession); /* @@ -155,7 +161,7 @@ public class PlayerProfessions { if (check) { Bukkit.getPluginManager().callEvent(new PlayerLevelUpEvent(playerData, profession, oldLevel, level)); new SmallParticleEffect(playerData.getPlayer(), Particle.SPELL_INSTANT); - new ConfigMessage("profession-level-up").addPlaceholders("level", "" + (level), "profession", profession.getName()) + new ConfigMessage("profession-level-up").addPlaceholders("level", "" + level, "profession", profession.getName()) .send(playerData.getPlayer()); playerData.getPlayer().playSound(playerData.getPlayer().getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 2); playerData.getStats().updateStats(); diff --git a/src/main/java/net/Indyuce/mmocore/api/experience/Profession.java b/src/main/java/net/Indyuce/mmocore/api/experience/Profession.java index 46317d6f..e535c4b4 100644 --- a/src/main/java/net/Indyuce/mmocore/api/experience/Profession.java +++ b/src/main/java/net/Indyuce/mmocore/api/experience/Profession.java @@ -11,7 +11,6 @@ import org.bukkit.potion.PotionType; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.load.PostLoadObject; -import net.Indyuce.mmocore.api.player.ExpCurve; import net.Indyuce.mmocore.api.util.math.formula.LinearValue; import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.api.MMOLineConfig; diff --git a/src/main/java/net/Indyuce/mmocore/api/experience/source/SmeltItemExperienceSource.java b/src/main/java/net/Indyuce/mmocore/api/experience/source/SmeltItemExperienceSource.java index 60ebf6c9..ff74f34e 100644 --- a/src/main/java/net/Indyuce/mmocore/api/experience/source/SmeltItemExperienceSource.java +++ b/src/main/java/net/Indyuce/mmocore/api/experience/source/SmeltItemExperienceSource.java @@ -33,7 +33,7 @@ public class SmeltItemExperienceSource extends SpecificExperienceSource player = getNearbyPlayer(event.getBlock().getLocation(), 10); + Optional player = getNearestPlayer(event.getBlock().getLocation(), 10); if (!player.isPresent()) return; @@ -50,9 +50,20 @@ public class SmeltItemExperienceSource extends SpecificExperienceSource getNearbyPlayer(Location loc, double d) { - double d2 = d * d; - return loc.getWorld().getPlayers().stream().filter(player -> player.getLocation().distanceSquared(loc) < d2).findAny(); + private Optional getNearestPlayer(Location loc, double d) { + final double d2 = d * d; + final Player[] nearby = loc.getWorld().getPlayers().stream() + .filter(player -> player.getLocation().distanceSquared(loc) < d2).toArray(Player[]::new); + Player selected = null; + double lastDist = d2; + for(Player p : nearby) { + double currDist = p.getLocation().distance(loc); + if(currDist < lastDist) { + lastDist = currDist; + selected = p; + } + } + return Optional.ofNullable(selected); } @Override diff --git a/src/main/java/net/Indyuce/mmocore/api/experience/source/type/ExperienceSource.java b/src/main/java/net/Indyuce/mmocore/api/experience/source/type/ExperienceSource.java index d1f44567..39d1d93b 100644 --- a/src/main/java/net/Indyuce/mmocore/api/experience/source/type/ExperienceSource.java +++ b/src/main/java/net/Indyuce/mmocore/api/experience/source/type/ExperienceSource.java @@ -2,6 +2,7 @@ package net.Indyuce.mmocore.api.experience.source.type; import org.bukkit.Location; +import net.Indyuce.mmocore.api.experience.EXPSource; import net.Indyuce.mmocore.api.experience.Profession; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.profess.PlayerClass; @@ -46,8 +47,8 @@ public abstract class ExperienceSource { public void giveExperience(PlayerData player, int amount, Location location) { if (hasProfession()) - player.getCollectionSkills().giveExperience(profession, amount, location == null ? player.getPlayer().getLocation() : location); + player.getCollectionSkills().giveExperience(profession, amount, location == null ? player.getPlayer().getLocation() : location, EXPSource.SOURCE); else - player.giveExperience(amount, location == null ? player.getPlayer().getLocation() : location); + player.giveExperience(amount, location == null ? player.getPlayer().getLocation() : location, EXPSource.SOURCE); } } diff --git a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java index 756a440b..db7943f6 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java @@ -29,6 +29,7 @@ import net.Indyuce.mmocore.api.event.PlayerCastSkillEvent; import net.Indyuce.mmocore.api.event.PlayerExperienceGainEvent; import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent; import net.Indyuce.mmocore.api.event.PlayerRegenResourceEvent; +import net.Indyuce.mmocore.api.experience.EXPSource; import net.Indyuce.mmocore.api.experience.PlayerProfessions; import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute; import net.Indyuce.mmocore.api.player.attribute.PlayerAttributes; @@ -245,11 +246,11 @@ public class PlayerData extends OfflinePlayerData { getStats().updateStats(); } - public void giveLevels(int value) { + public void giveLevels(int value, EXPSource source) { int total = 0; while (value-- > 0) total += getProfess().getExpCurve().getExperience(getLevel() + value + 1); - giveExperience(total); + giveExperience(total, source); } public void setExperience(int value) { @@ -422,11 +423,11 @@ public class PlayerData extends OfflinePlayerData { return getProfess().getMaxLevel() > 0 && getLevel() >= getProfess().getMaxLevel(); } - public void giveExperience(int value) { - giveExperience(value, null); + public void giveExperience(int value, EXPSource source) { + giveExperience(value, null, source); } - public void giveExperience(int value, Location loc) { + public void giveExperience(int value, Location loc, EXPSource source) { if (hasReachedMaxLevel()) { setExperience(0); return; @@ -441,7 +442,7 @@ public class PlayerData extends OfflinePlayerData { value = MMOCore.plugin.boosterManager.calculateExp(null, value); value *= 1 + getStats().getStat(StatType.ADDITIONAL_EXPERIENCE) / 100; - PlayerExperienceGainEvent event = new PlayerExperienceGainEvent(this, value); + PlayerExperienceGainEvent event = new PlayerExperienceGainEvent(this, value, source); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) return; diff --git a/src/main/java/net/Indyuce/mmocore/api/player/attribute/PlayerAttribute.java b/src/main/java/net/Indyuce/mmocore/api/player/attribute/PlayerAttribute.java index 4bf8ddaa..76da07ad 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/attribute/PlayerAttribute.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/attribute/PlayerAttribute.java @@ -2,15 +2,13 @@ package net.Indyuce.mmocore.api.player.attribute; import java.util.HashMap; import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; import java.util.logging.Level; import org.apache.commons.lang.Validate; -import org.bukkit.ChatColor; import org.bukkit.configuration.ConfigurationSection; import net.Indyuce.mmocore.MMOCore; +import net.asangarin.hexcolors.ColorParse; import net.mmogroup.mmolib.api.stat.modifier.StatModifier; public class PlayerAttribute { @@ -18,8 +16,8 @@ public class PlayerAttribute { private final int max; /* - * used to store stats using StatType, but attributes also need to access non - * basic MMOCore stats hence the string maps keys + * used to store stats using StatType, but attributes also need to access + * non basic MMOCore stats hence the string maps keys */ private final Map buffs = new HashMap<>(); @@ -38,8 +36,7 @@ public class PlayerAttribute { String stat = key.toUpperCase().replace("-", "_").replace(" ", "_"); buffs.put(stat, new StatModifier(config.getString("buff." + key))); } catch (IllegalArgumentException exception) { - MMOCore.log(Level.WARNING, - "Could not load buff '" + key + "' from attribute '" + id + "': " + exception.getMessage()); + MMOCore.log(Level.WARNING, "Could not load buff '" + key + "' from attribute '" + id + "': " + exception.getMessage()); } } @@ -48,7 +45,7 @@ public class PlayerAttribute { } public String getName() { - return ChatColor.translateAlternateColorCodes('&', name); + return new ColorParse('&', name).toChatColor(); } public boolean hasMax() { @@ -59,7 +56,7 @@ public class PlayerAttribute { return max; } - public Set> getBuffs() { - return buffs.entrySet(); + public Map getBuffs() { + return buffs; } } diff --git a/src/main/java/net/Indyuce/mmocore/api/player/attribute/PlayerAttributes.java b/src/main/java/net/Indyuce/mmocore/api/player/attribute/PlayerAttributes.java index 2eabaca2..bb2fc929 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/attribute/PlayerAttributes.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/attribute/PlayerAttributes.java @@ -193,8 +193,8 @@ public class PlayerAttributes { public void update() { PlayerAttribute attribute = MMOCore.plugin.attributeManager.get(id); int total = getTotal(); - attribute.getBuffs().forEach(buff -> data.getStats().getInstance(buff.getKey()).addModifier("attribute." + attribute.getId(), - buff.getValue().multiply(total))); + attribute.getBuffs() + .forEach((key, buff) -> data.getStats().getInstance(key).addModifier("attribute." + attribute.getId(), buff.multiply(total))); } public String getId() { diff --git a/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java b/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java index 7690955d..2ba25795 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java @@ -13,7 +13,6 @@ import java.util.UUID; import java.util.logging.Level; import org.apache.commons.lang.Validate; -import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.Particle; import org.bukkit.configuration.ConfigurationSection; @@ -25,9 +24,9 @@ import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; import net.Indyuce.mmocore.MMOCore; +import net.Indyuce.mmocore.api.experience.ExpCurve; import net.Indyuce.mmocore.api.experience.source.type.ExperienceSource; import net.Indyuce.mmocore.api.load.PostLoadObject; -import net.Indyuce.mmocore.api.player.ExpCurve; import net.Indyuce.mmocore.api.player.profess.event.EventTrigger; import net.Indyuce.mmocore.api.player.profess.resource.ManaDisplayOptions; import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource; @@ -38,6 +37,8 @@ import net.Indyuce.mmocore.api.skill.Skill.SkillInfo; import net.Indyuce.mmocore.api.util.MMOCoreUtils; import net.Indyuce.mmocore.api.util.math.formula.LinearValue; import net.Indyuce.mmocore.api.util.math.particle.CastingParticle; +import net.asangarin.hexcolors.ColorParse; +import net.md_5.bungee.api.ChatColor; import net.mmogroup.mmolib.api.MMOLineConfig; import net.mmogroup.mmolib.version.VersionMaterial; @@ -64,7 +65,7 @@ public class PlayerClass extends PostLoadObject { this.id = id.toUpperCase().replace("-", "_").replace(" ", "_"); - name = ChatColor.translateAlternateColorCodes('&', config.getString("display.name")); + name = new ColorParse('&', config.getString("display.name")).toChatColor(); icon = MMOCoreUtils.readIcon(config.getString("display.item", "BARRIER")); if (config.contains("display.texture") && icon.getType() == VersionMaterial.PLAYER_HEAD.toMaterial()) @@ -76,20 +77,23 @@ public class PlayerClass extends PostLoadObject { gp.getProperties().put("textures", new Property("textures", config.getString("display.texture"))); profileField.set(meta, gp); icon.setItemMeta(meta); - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException exception) { + } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException + | SecurityException exception) { throw new IllegalArgumentException("Could not apply playerhead texture: " + exception.getMessage()); } for (String string : config.getStringList("display.lore")) - description.add(ChatColor.GRAY + ChatColor.translateAlternateColorCodes('&', string)); + description.add(ChatColor.GRAY + new ColorParse('&', string).toChatColor()); for (String string : config.getStringList("display.attribute-lore")) - attrDescription.add(ChatColor.GRAY + ChatColor.translateAlternateColorCodes('&', string)); - manaDisplay = config.contains("mana") ? new ManaDisplayOptions(config.getConfigurationSection("mana")) : ManaDisplayOptions.DEFAULT; + attrDescription.add(ChatColor.GRAY + new ColorParse('&', string).toChatColor()); + manaDisplay = config.contains("mana") ? new ManaDisplayOptions(config.getConfigurationSection("mana")) + : ManaDisplayOptions.DEFAULT; maxLevel = config.getInt("max-level"); displayOrder = config.getInt("display.order"); expCurve = config.contains("exp-curve") - ? MMOCore.plugin.experience.getOrThrow(config.get("exp-curve").toString().toLowerCase().replace("_", "-").replace(" ", "-")) + ? MMOCore.plugin.experience.getOrThrow( + config.get("exp-curve").toString().toLowerCase().replace("_", "-").replace(" ", "-")) : ExpCurve.DEFAULT; if (config.contains("attributes")) @@ -98,27 +102,30 @@ public class PlayerClass extends PostLoadObject { stats.put(StatType.valueOf(key.toUpperCase().replace("-", "_")), new LinearValue(config.getConfigurationSection("attributes." + key))); } catch (IllegalArgumentException exception) { - MMOCore.plugin.getLogger().log(Level.WARNING, - "Could not load stat info '" + key + "' from class '" + id + "': " + exception.getMessage()); + MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load stat info '" + key + "' from class '" + + id + "': " + exception.getMessage()); } if (config.contains("skills")) for (String key : config.getConfigurationSection("skills").getKeys(false)) try { Validate.isTrue(MMOCore.plugin.skillManager.has(key), "Could not find skill " + key); - skills.put(key.toUpperCase(), MMOCore.plugin.skillManager.get(key).newSkillInfo(config.getConfigurationSection("skills." + key))); + skills.put(key.toUpperCase(), MMOCore.plugin.skillManager.get(key) + .newSkillInfo(config.getConfigurationSection("skills." + key))); } catch (IllegalArgumentException exception) { - MMOCore.plugin.getLogger().log(Level.WARNING, - "Could not load skill info '" + key + "' from class '" + id + "': " + exception.getMessage()); + MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load skill info '" + key + "' from class '" + + id + "': " + exception.getMessage()); } - castParticle = config.contains("cast-particle") ? new CastingParticle(config.getConfigurationSection("cast-particle")) + castParticle = config.contains("cast-particle") + ? new CastingParticle(config.getConfigurationSection("cast-particle")) : new CastingParticle(Particle.SPELL_INSTANT); if (config.contains("options")) for (String key : config.getConfigurationSection("options").getKeys(false)) try { - setOption(ClassOption.valueOf(key.toUpperCase().replace("-", "_").replace(" ", "_")), config.getBoolean("options." + key)); + setOption(ClassOption.valueOf(key.toUpperCase().replace("-", "_").replace(" ", "_")), + config.getBoolean("options." + key)); } catch (IllegalArgumentException exception) { MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load option '" + key + "' from class '" + key + "': " + exception.getMessage()); @@ -127,12 +134,13 @@ public class PlayerClass extends PostLoadObject { if (config.contains("main-exp-sources")) for (String key : config.getStringList("main-exp-sources")) try { - ExperienceSource source = MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key), null); + ExperienceSource source = MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key), + null); source.setClass(this); MMOCore.plugin.professionManager.registerExpSource(source); } catch (IllegalArgumentException exception) { - MMOCore.plugin.getLogger().log(Level.WARNING, - "Could not load exp source '" + key + "' from class '" + id + "': " + exception.getMessage()); + MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load exp source '" + key + "' from class '" + + id + "': " + exception.getMessage()); } if (config.contains("triggers")) @@ -146,17 +154,17 @@ public class PlayerClass extends PostLoadObject { } /* - * must make sure all the resourceHandlers are registered when the - * placer class is initialized. + * must make sure all the resourceHandlers are registered when the placer class + * is initialized. */ for (PlayerResource resource : PlayerResource.values()) { if (config.isConfigurationSection("resource." + resource.name().toLowerCase())) try { - resourceHandlers.put(resource, - new ResourceHandler(resource, config.getConfigurationSection("resource." + resource.name().toLowerCase()))); + resourceHandlers.put(resource, new ResourceHandler(resource, + config.getConfigurationSection("resource." + resource.name().toLowerCase()))); } catch (IllegalArgumentException exception) { - MMOCore.log(Level.WARNING, "[PlayerClasses:" + id + "] Could not load special resource regen for " + resource.name() + ": " - + exception.getMessage()); + MMOCore.log(Level.WARNING, "[PlayerClasses:" + id + "] Could not load special resource regen for " + + resource.name() + ": " + exception.getMessage()); resourceHandlers.put(resource, new ResourceHandler(resource)); } else @@ -191,11 +199,13 @@ public class PlayerClass extends PostLoadObject { if (config.contains("subclasses")) for (String key : config.getConfigurationSection("subclasses").getKeys(false)) try { - subclasses.add(new Subclass(MMOCore.plugin.classManager.getOrThrow(key.toUpperCase().replace("-", "_").replace(" ", "_")), + subclasses.add(new Subclass( + MMOCore.plugin.classManager + .getOrThrow(key.toUpperCase().replace("-", "_").replace(" ", "_")), config.getInt("subclasses." + key))); } catch (IllegalArgumentException exception) { - MMOCore.plugin.getLogger().log(Level.WARNING, - "Could not load subclass '" + key + "' from class '" + getId() + "': " + exception.getMessage()); + MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load subclass '" + key + "' from class '" + + getId() + "': " + exception.getMessage()); } } diff --git a/src/main/java/net/Indyuce/mmocore/api/player/profess/event/trigger/LevelUpEventTrigger.java b/src/main/java/net/Indyuce/mmocore/api/player/profess/event/trigger/LevelUpEventTrigger.java index 17bc5438..9ef60028 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/profess/event/trigger/LevelUpEventTrigger.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/profess/event/trigger/LevelUpEventTrigger.java @@ -3,6 +3,7 @@ package net.Indyuce.mmocore.api.player.profess.event.trigger; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.profess.PlayerClass; @@ -22,9 +23,11 @@ public class LevelUpEventTrigger implements EventTriggerHandler { if(event.hasProfession()) { String prof = event.getProfession().getId().toLowerCase(); + MMOCore.debug(2, "[DEBUG] Looking for triggers: level-up-" + prof); processTrigger(player, profess, "level-up-" + prof); processTrigger(player, profess, "level-up-" + prof + "-" + event.getNewLevel()); } else { + MMOCore.debug(2, "[DEBUG] Normal level up trigger."); processTrigger(player, profess, "level-up"); processTrigger(player, profess, "level-up-" + event.getNewLevel()); if(profess.getMaxLevel() == event.getNewLevel()) diff --git a/src/main/java/net/Indyuce/mmocore/api/player/profess/resource/ManaDisplayOptions.java b/src/main/java/net/Indyuce/mmocore/api/player/profess/resource/ManaDisplayOptions.java index fb1b010e..bdab062a 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/profess/resource/ManaDisplayOptions.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/profess/resource/ManaDisplayOptions.java @@ -1,9 +1,10 @@ package net.Indyuce.mmocore.api.player.profess.resource; import org.apache.commons.lang.Validate; -import org.bukkit.ChatColor; import org.bukkit.configuration.ConfigurationSection; +import net.asangarin.hexcolors.ColorParse; +import net.md_5.bungee.api.ChatColor; import net.mmogroup.mmolib.api.util.AltChar; public class ManaDisplayOptions { @@ -21,15 +22,15 @@ public class ManaDisplayOptions { Validate.notNull(name, "Could not load mana name"); Validate.notNull(config.getConfigurationSection("color"), "Could not find mana color config"); - full = ChatColor.valueOf(config.getString("color.full", "NO_INPUT").toUpperCase().replace("-", "_").replace(" ", "_")); - half = ChatColor.valueOf(config.getString("color.half", "NO_INPUT").toUpperCase().replace("-", "_").replace(" ", "_")); - empty = ChatColor.valueOf(config.getString("color.empty", "NO_INPUT").toUpperCase().replace("-", "_").replace(" ", "_")); + full = ColorParse.getColor(config.getString("color.full", "NO_INPUT")); + half = ColorParse.getColor(config.getString("color.half", "NO_INPUT")); + empty = ColorParse.getColor(config.getString("color.empty", "NO_INPUT")); String format = config.getString("char", ""); Validate.notEmpty(format, "Could not load mana bar character"); barCharacter = format.charAt(0); - icon = ChatColor.translateAlternateColorCodes('&', config.getString("icon", "")); + icon = new ColorParse('&', config.getString("icon", "")).toChatColor(); Validate.notEmpty(format, "Could not load mana action bar icon"); } diff --git a/src/main/java/net/Indyuce/mmocore/api/player/social/Party.java b/src/main/java/net/Indyuce/mmocore/api/player/social/Party.java index 6e99c540..1fa364cc 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/social/Party.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/social/Party.java @@ -54,6 +54,10 @@ public class Party { } public void removeMember(PlayerData data) { + removeMember(data, true); + } + + public void removeMember(PlayerData data, boolean notify) { if (data.isOnline() && data.getPlayer().getOpenInventory() != null && data.getPlayer().getOpenInventory().getTopInventory().getHolder() instanceof PartyViewInventory) InventoryManager.PARTY_CREATION.newInventory(data).open(); @@ -72,7 +76,7 @@ public class Party { // transfer ownership if (owner.equals(data)) { owner = members.get(0); - MMOCore.plugin.configManager.getSimpleMessage("transfer-party-ownership").send(owner.getPlayer()); + if(notify) MMOCore.plugin.configManager.getSimpleMessage("transfer-party-ownership").send(owner.getPlayer()); } } diff --git a/src/main/java/net/Indyuce/mmocore/api/player/stats/StatType.java b/src/main/java/net/Indyuce/mmocore/api/player/stats/StatType.java index 535b4820..33628a8e 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/stats/StatType.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/stats/StatType.java @@ -52,6 +52,9 @@ public enum StatType { WEAPON_DAMAGE, SKILL_DAMAGE, + PVP_DAMAGE, + PVE_DAMAGE, + DAMAGE_REDUCTION, PHYSICAL_DAMAGE_REDUCTION, PROJECTILE_DAMAGE_REDUCTION, diff --git a/src/main/java/net/Indyuce/mmocore/api/quest/QuestProgress.java b/src/main/java/net/Indyuce/mmocore/api/quest/QuestProgress.java index 6ac9cea1..3589a490 100644 --- a/src/main/java/net/Indyuce/mmocore/api/quest/QuestProgress.java +++ b/src/main/java/net/Indyuce/mmocore/api/quest/QuestProgress.java @@ -1,9 +1,8 @@ package net.Indyuce.mmocore.api.quest; -import org.bukkit.ChatColor; - import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.quest.objective.Objective; +import net.asangarin.hexcolors.ColorParse; public class QuestProgress { private final Quest quest; @@ -65,6 +64,6 @@ public class QuestProgress { } public String getFormattedLore() { - return ChatColor.translateAlternateColorCodes('&', objectiveProgress.formatLore(objectiveProgress.getObjective().getDefaultLore())); + return new ColorParse('&', objectiveProgress.formatLore(objectiveProgress.getObjective().getDefaultLore())).toChatColor(); } } \ No newline at end of file diff --git a/src/main/java/net/Indyuce/mmocore/api/quest/trigger/ExperienceTrigger.java b/src/main/java/net/Indyuce/mmocore/api/quest/trigger/ExperienceTrigger.java index 9ca30293..ca0a87ad 100644 --- a/src/main/java/net/Indyuce/mmocore/api/quest/trigger/ExperienceTrigger.java +++ b/src/main/java/net/Indyuce/mmocore/api/quest/trigger/ExperienceTrigger.java @@ -3,6 +3,7 @@ package net.Indyuce.mmocore.api.quest.trigger; import org.apache.commons.lang.Validate; import net.Indyuce.mmocore.MMOCore; +import net.Indyuce.mmocore.api.experience.EXPSource; import net.Indyuce.mmocore.api.experience.ExperienceInfo; import net.Indyuce.mmocore.api.experience.Profession; import net.Indyuce.mmocore.api.player.PlayerData; @@ -29,9 +30,9 @@ public class ExperienceTrigger extends Trigger { @Override public void apply(PlayerData player) { if (profession == null) - player.giveExperience(amount.calculateInt()); + player.giveExperience(amount.calculateInt(), EXPSource.QUEST); else - player.getCollectionSkills().giveExperience(profession, amount.calculateInt()); + player.getCollectionSkills().giveExperience(profession, amount.calculateInt(), EXPSource.QUEST); } /* diff --git a/src/main/java/net/Indyuce/mmocore/api/util/debug/DebugMode.java b/src/main/java/net/Indyuce/mmocore/api/util/debug/DebugMode.java index 6497f94c..6e441059 100644 --- a/src/main/java/net/Indyuce/mmocore/api/util/debug/DebugMode.java +++ b/src/main/java/net/Indyuce/mmocore/api/util/debug/DebugMode.java @@ -3,8 +3,20 @@ package net.Indyuce.mmocore.api.util.debug; import net.Indyuce.mmocore.MMOCore; public class DebugMode { - public DebugMode() { - if (MMOCore.plugin.getConfig().getBoolean("debug-action-bar.enabled")) + /* + * Debug Levels: + * 1: + * - Print WorldGuard Flag Registry + * 2: + * - Print Profession Trigger Things + * 3: + * - Debug Action Bar + */ + public static int level = 0; + + public DebugMode(int i) { + level = i; + if (level > 2 && MMOCore.plugin.getConfig().getBoolean("debug-action-bar.enabled")) new ActionBarRunnable().runTaskTimer(MMOCore.plugin, 0, 10); } } diff --git a/src/main/java/net/Indyuce/mmocore/api/util/item/ConfigItem.java b/src/main/java/net/Indyuce/mmocore/api/util/item/ConfigItem.java index 3230d2ea..fb6c018f 100644 --- a/src/main/java/net/Indyuce/mmocore/api/util/item/ConfigItem.java +++ b/src/main/java/net/Indyuce/mmocore/api/util/item/ConfigItem.java @@ -9,7 +9,6 @@ import java.util.UUID; import java.util.logging.Level; import org.apache.commons.lang.Validate; -import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.inventory.ItemFlag; @@ -20,6 +19,7 @@ import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; import net.Indyuce.mmocore.MMOCore; +import net.asangarin.hexcolors.ColorParse; import net.mmogroup.mmolib.MMOLib; import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.NBTItem; @@ -138,6 +138,6 @@ public class ConfigItem { for (String placeholder : placeholders.keySet()) if (string.contains("{" + placeholder + "}")) string = string.replace("{" + placeholder + "}", "" + placeholders.get(placeholder)); - return ChatColor.translateAlternateColorCodes('&', string); + return new ColorParse('&', string).toChatColor(); } } diff --git a/src/main/java/net/Indyuce/mmocore/api/util/item/NamedItemStack.java b/src/main/java/net/Indyuce/mmocore/api/util/item/NamedItemStack.java index 8a46934e..6121bd97 100644 --- a/src/main/java/net/Indyuce/mmocore/api/util/item/NamedItemStack.java +++ b/src/main/java/net/Indyuce/mmocore/api/util/item/NamedItemStack.java @@ -1,16 +1,17 @@ package net.Indyuce.mmocore.api.util.item; -import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import net.asangarin.hexcolors.ColorParse; + public class NamedItemStack extends ItemStack { public NamedItemStack(Material material, String name) { super(material); ItemMeta meta = getItemMeta(); - meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name)); + meta.setDisplayName(new ColorParse('&', name).toChatColor()); setItemMeta(meta); } } diff --git a/src/main/java/net/Indyuce/mmocore/command/AttributesCommand.java b/src/main/java/net/Indyuce/mmocore/command/AttributesCommand.java index 2799e166..4c5240b0 100644 --- a/src/main/java/net/Indyuce/mmocore/command/AttributesCommand.java +++ b/src/main/java/net/Indyuce/mmocore/command/AttributesCommand.java @@ -1,11 +1,13 @@ package net.Indyuce.mmocore.command; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.command.defaults.BukkitCommand; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; +import net.Indyuce.mmocore.api.event.MMOCommandEvent; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.manager.InventoryManager; @@ -24,7 +26,10 @@ public class AttributesCommand extends BukkitCommand { return true; } - InventoryManager.ATTRIBUTE_VIEW.newInventory(PlayerData.get((Player) sender)).open(); + PlayerData data = PlayerData.get((Player) sender); + MMOCommandEvent event = new MMOCommandEvent(data, "attributes"); + Bukkit.getServer().getPluginManager().callEvent(event); + if(!event.isCancelled()) InventoryManager.ATTRIBUTE_VIEW.newInventory(data).open(); return true; } } diff --git a/src/main/java/net/Indyuce/mmocore/command/ClassCommand.java b/src/main/java/net/Indyuce/mmocore/command/ClassCommand.java index ec788c16..43bdd134 100644 --- a/src/main/java/net/Indyuce/mmocore/command/ClassCommand.java +++ b/src/main/java/net/Indyuce/mmocore/command/ClassCommand.java @@ -7,6 +7,7 @@ import org.bukkit.command.defaults.BukkitCommand; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; +import net.Indyuce.mmocore.api.event.MMOCommandEvent; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.manager.InventoryManager; @@ -30,6 +31,9 @@ public class ClassCommand extends BukkitCommand { } PlayerData data = PlayerData.get(player); + MMOCommandEvent event = new MMOCommandEvent(data, "class"); + Bukkit.getServer().getPluginManager().callEvent(event); + if(event.isCancelled()) return true; if (data.getProfess().getSubclasses().stream().filter(sub -> sub.getLevel() <= data.getLevel()).count() > 0) InventoryManager.SUBCLASS_SELECT.newInventory(data).open(); else diff --git a/src/main/java/net/Indyuce/mmocore/command/FriendsCommand.java b/src/main/java/net/Indyuce/mmocore/command/FriendsCommand.java index 8b9e26c6..bb57a151 100644 --- a/src/main/java/net/Indyuce/mmocore/command/FriendsCommand.java +++ b/src/main/java/net/Indyuce/mmocore/command/FriendsCommand.java @@ -2,6 +2,7 @@ package net.Indyuce.mmocore.command; import java.util.UUID; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.command.defaults.BukkitCommand; @@ -9,6 +10,7 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; import net.Indyuce.mmocore.MMOCore; +import net.Indyuce.mmocore.api.event.MMOCommandEvent; import net.Indyuce.mmocore.api.player.OfflinePlayerData; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.social.FriendRequest; @@ -30,6 +32,11 @@ public class FriendsCommand extends BukkitCommand { return true; } + PlayerData data = PlayerData.get((Player) sender); + MMOCommandEvent event = new MMOCommandEvent(data, "friends"); + Bukkit.getServer().getPluginManager().callEvent(event); + if(event.isCancelled()) return true; + if (args.length > 1) { UUID uuid; try { @@ -59,7 +66,7 @@ public class FriendsCommand extends BukkitCommand { return true; } - InventoryManager.FRIEND_LIST.newInventory(PlayerData.get((Player) sender)).open(); + InventoryManager.FRIEND_LIST.newInventory(data).open(); return true; } } diff --git a/src/main/java/net/Indyuce/mmocore/command/GuildCommand.java b/src/main/java/net/Indyuce/mmocore/command/GuildCommand.java index 2458a334..bdf6784d 100644 --- a/src/main/java/net/Indyuce/mmocore/command/GuildCommand.java +++ b/src/main/java/net/Indyuce/mmocore/command/GuildCommand.java @@ -2,6 +2,7 @@ package net.Indyuce.mmocore.command; import java.util.UUID; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; @@ -10,6 +11,7 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; import net.Indyuce.mmocore.MMOCore; +import net.Indyuce.mmocore.api.event.MMOCommandEvent; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.social.Request; import net.Indyuce.mmocore.api.player.social.guilds.GuildInvite; @@ -31,6 +33,11 @@ public class GuildCommand extends BukkitCommand { return true; } + PlayerData data = PlayerData.get((OfflinePlayer) sender); + MMOCommandEvent event = new MMOCommandEvent(data, "guild"); + Bukkit.getServer().getPluginManager().callEvent(event); + if(event.isCancelled()) return true; + if (args.length > 1) { UUID uuid; try { @@ -60,7 +67,6 @@ public class GuildCommand extends BukkitCommand { return true; } - PlayerData data = PlayerData.get((OfflinePlayer) sender); if (data.inGuild()) InventoryManager.GUILD_VIEW.newInventory(data).open(); else diff --git a/src/main/java/net/Indyuce/mmocore/command/MMOCoreCommand.java b/src/main/java/net/Indyuce/mmocore/command/MMOCoreCommand.java index 955b85b1..2c870325 100644 --- a/src/main/java/net/Indyuce/mmocore/command/MMOCoreCommand.java +++ b/src/main/java/net/Indyuce/mmocore/command/MMOCoreCommand.java @@ -54,6 +54,7 @@ public class MMOCoreCommand extends CommandRoot implements CommandExecutor, TabC CommandParser reader = readCommand(args); List list = reader.readTabCompletion(); - return args[args.length - 1].isEmpty() ? list : list.stream().filter(string -> string.toLowerCase().startsWith(args[args.length - 1].toLowerCase())).collect(Collectors.toList()); + return args[args.length - 1].isEmpty() ? list + : list.stream().filter(string -> string.toLowerCase().startsWith(args[args.length - 1].toLowerCase())).collect(Collectors.toList()); } } diff --git a/src/main/java/net/Indyuce/mmocore/command/PartyCommand.java b/src/main/java/net/Indyuce/mmocore/command/PartyCommand.java index c2d8e9e1..8cf39f66 100644 --- a/src/main/java/net/Indyuce/mmocore/command/PartyCommand.java +++ b/src/main/java/net/Indyuce/mmocore/command/PartyCommand.java @@ -2,6 +2,7 @@ package net.Indyuce.mmocore.command; import java.util.UUID; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; @@ -10,6 +11,7 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; import net.Indyuce.mmocore.MMOCore; +import net.Indyuce.mmocore.api.event.MMOCommandEvent; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.social.PartyInvite; import net.Indyuce.mmocore.api.player.social.Request; @@ -31,6 +33,11 @@ public class PartyCommand extends BukkitCommand { return true; } + PlayerData data = PlayerData.get((OfflinePlayer) sender); + MMOCommandEvent event = new MMOCommandEvent(data, "party"); + Bukkit.getServer().getPluginManager().callEvent(event); + if(event.isCancelled()) return true; + if (args.length > 1) { UUID uuid; try { @@ -60,7 +67,6 @@ public class PartyCommand extends BukkitCommand { return true; } - PlayerData data = PlayerData.get((OfflinePlayer) sender); if (data.hasParty()) InventoryManager.PARTY_VIEW.newInventory(data).open(); else diff --git a/src/main/java/net/Indyuce/mmocore/command/PlayerStatsCommand.java b/src/main/java/net/Indyuce/mmocore/command/PlayerStatsCommand.java index b5bca585..a8bfe6fa 100644 --- a/src/main/java/net/Indyuce/mmocore/command/PlayerStatsCommand.java +++ b/src/main/java/net/Indyuce/mmocore/command/PlayerStatsCommand.java @@ -1,11 +1,13 @@ package net.Indyuce.mmocore.command; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.command.defaults.BukkitCommand; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; +import net.Indyuce.mmocore.api.event.MMOCommandEvent; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.manager.InventoryManager; @@ -23,8 +25,11 @@ public class PlayerStatsCommand extends BukkitCommand { sender.sendMessage(ChatColor.RED + "This command is for players only."); return true; } - - InventoryManager.PLAYER_STATS.newInventory(PlayerData.get((Player) sender)).open(); + + PlayerData data = PlayerData.get((Player) sender); + MMOCommandEvent event = new MMOCommandEvent(data, "profile"); + Bukkit.getServer().getPluginManager().callEvent(event); + if(!event.isCancelled()) InventoryManager.PLAYER_STATS.newInventory(data).open(); return true; } } diff --git a/src/main/java/net/Indyuce/mmocore/command/QuestsCommand.java b/src/main/java/net/Indyuce/mmocore/command/QuestsCommand.java index fdd3db7b..2eebc76b 100644 --- a/src/main/java/net/Indyuce/mmocore/command/QuestsCommand.java +++ b/src/main/java/net/Indyuce/mmocore/command/QuestsCommand.java @@ -1,10 +1,12 @@ package net.Indyuce.mmocore.command; +import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.command.defaults.BukkitCommand; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; +import net.Indyuce.mmocore.api.event.MMOCommandEvent; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.manager.InventoryManager; @@ -18,8 +20,12 @@ public class QuestsCommand extends BukkitCommand { @Override public boolean execute(CommandSender sender, String label, String[] args) { - if (sender instanceof Player) - InventoryManager.QUEST_LIST.newInventory(PlayerData.get((Player) sender)).open(); + if (sender instanceof Player) { + PlayerData data = PlayerData.get((Player) sender); + MMOCommandEvent event = new MMOCommandEvent(data, "quests"); + Bukkit.getServer().getPluginManager().callEvent(event); + if(!event.isCancelled()) InventoryManager.QUEST_LIST.newInventory(data).open(); + } return true; } } diff --git a/src/main/java/net/Indyuce/mmocore/command/SkillsCommand.java b/src/main/java/net/Indyuce/mmocore/command/SkillsCommand.java index b512c021..a13b5c1f 100644 --- a/src/main/java/net/Indyuce/mmocore/command/SkillsCommand.java +++ b/src/main/java/net/Indyuce/mmocore/command/SkillsCommand.java @@ -1,11 +1,13 @@ package net.Indyuce.mmocore.command; +import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.command.defaults.BukkitCommand; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; import net.Indyuce.mmocore.MMOCore; +import net.Indyuce.mmocore.api.event.MMOCommandEvent; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.manager.InventoryManager; @@ -21,6 +23,10 @@ public class SkillsCommand extends BukkitCommand { public boolean execute(CommandSender sender, String label, String[] args) { if (sender instanceof Player) { PlayerData data = PlayerData.get((Player) sender); + MMOCommandEvent event = new MMOCommandEvent(data, "skills"); + Bukkit.getServer().getPluginManager().callEvent(event); + if(event.isCancelled()) return true; + if (data.getProfess().getSkills().size() < 1) { MMOCore.plugin.configManager.getSimpleMessage("no-class-skill").send((Player) sender); return true; diff --git a/src/main/java/net/Indyuce/mmocore/command/WaypointsCommand.java b/src/main/java/net/Indyuce/mmocore/command/WaypointsCommand.java index e826cdbc..0e958636 100644 --- a/src/main/java/net/Indyuce/mmocore/command/WaypointsCommand.java +++ b/src/main/java/net/Indyuce/mmocore/command/WaypointsCommand.java @@ -1,10 +1,12 @@ package net.Indyuce.mmocore.command; +import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.command.defaults.BukkitCommand; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; +import net.Indyuce.mmocore.api.event.MMOCommandEvent; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.manager.InventoryManager; @@ -18,8 +20,12 @@ public class WaypointsCommand extends BukkitCommand { @Override public boolean execute(CommandSender sender, String label, String[] args) { - if (sender instanceof Player && sender.hasPermission("mmocore.waypoints")) - InventoryManager.WAYPOINTS.newInventory(PlayerData.get((Player) sender)).open(); + if (sender instanceof Player && sender.hasPermission("mmocore.waypoints")) { + PlayerData data = PlayerData.get((Player) sender); + MMOCommandEvent event = new MMOCommandEvent(data, "waypoints"); + Bukkit.getServer().getPluginManager().callEvent(event); + if(!event.isCancelled()) InventoryManager.WAYPOINTS.newInventory(data).open(); + } return true; } } diff --git a/src/main/java/net/Indyuce/mmocore/command/rpg/admin/ExperienceCommandMap.java b/src/main/java/net/Indyuce/mmocore/command/rpg/admin/ExperienceCommandMap.java index 1347a859..14177d52 100644 --- a/src/main/java/net/Indyuce/mmocore/command/rpg/admin/ExperienceCommandMap.java +++ b/src/main/java/net/Indyuce/mmocore/command/rpg/admin/ExperienceCommandMap.java @@ -9,6 +9,7 @@ import org.bukkit.entity.Player; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.experience.Profession; +import net.Indyuce.mmocore.api.experience.EXPSource; import net.Indyuce.mmocore.api.experience.PlayerProfessions; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.command.api.CommandEnd; @@ -20,7 +21,7 @@ public class ExperienceCommandMap extends CommandMap { super(parent, "exp"); addFloor(new ActionCommandMap(this, "set", (data, value) -> data.setExperience(value), (professions, profession, value) -> professions.setExperience(profession, value))); - addFloor(new ActionCommandMap(this, "give", (data, value) -> data.giveExperience(value, data.getPlayer().getLocation()), (professions, profession, value) -> professions.giveExperience(profession, value, professions.getPlayerData().getPlayer().getLocation()))); + addFloor(new ActionCommandMap(this, "give", (data, value) -> data.giveExperience(value, data.getPlayer().getLocation(), EXPSource.COMMAND), (professions, profession, value) -> professions.giveExperience(profession, value, professions.getPlayerData().getPlayer().getLocation(), EXPSource.COMMAND))); } public class ActionCommandMap extends CommandEnd { diff --git a/src/main/java/net/Indyuce/mmocore/command/rpg/admin/LevelCommandMap.java b/src/main/java/net/Indyuce/mmocore/command/rpg/admin/LevelCommandMap.java index 40912324..c1550458 100644 --- a/src/main/java/net/Indyuce/mmocore/command/rpg/admin/LevelCommandMap.java +++ b/src/main/java/net/Indyuce/mmocore/command/rpg/admin/LevelCommandMap.java @@ -9,6 +9,7 @@ import org.bukkit.entity.Player; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.experience.Profession; +import net.Indyuce.mmocore.api.experience.EXPSource; import net.Indyuce.mmocore.api.experience.PlayerProfessions; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.command.api.CommandEnd; @@ -20,7 +21,7 @@ public class LevelCommandMap extends CommandMap { super(parent, "level"); addFloor(new ActionCommandMap(this, "set", (data, value) -> data.setLevel(value), (professions, profession, value) -> professions.setLevel(profession, value))); - addFloor(new ActionCommandMap(this, "give", (data, value) -> data.giveLevels(value), (professions, profession, value) -> professions.giveLevels(profession, value))); + addFloor(new ActionCommandMap(this, "give", (data, value) -> data.giveLevels(value, EXPSource.COMMAND), (professions, profession, value) -> professions.giveLevels(profession, value, EXPSource.COMMAND))); } public class ActionCommandMap extends CommandEnd { diff --git a/src/main/java/net/Indyuce/mmocore/command/rpg/debug/StatModifiersCommandMap.java b/src/main/java/net/Indyuce/mmocore/command/rpg/debug/StatModifiersCommandMap.java index af7217a6..a3e8f9a8 100644 --- a/src/main/java/net/Indyuce/mmocore/command/rpg/debug/StatModifiersCommandMap.java +++ b/src/main/java/net/Indyuce/mmocore/command/rpg/debug/StatModifiersCommandMap.java @@ -44,7 +44,7 @@ public class StatModifiersCommandMap extends CommandEnd { StatInstance instance = data.getStats().getInstance(stat); sender.sendMessage("Stat Modifiers (" + instance.getKeys().size() + "):"); for (String key : instance.getKeys()) { - StatModifier mod = instance.getByKey(key); + StatModifier mod = instance.getAttribute(key); sender.sendMessage("- " + key + ": " + mod.getValue() + " " + mod.getType().name()); } diff --git a/src/main/java/net/Indyuce/mmocore/comp/flags/WorldGuardFlags.java b/src/main/java/net/Indyuce/mmocore/comp/flags/WorldGuardFlags.java index ba0c8740..982416f3 100644 --- a/src/main/java/net/Indyuce/mmocore/comp/flags/WorldGuardFlags.java +++ b/src/main/java/net/Indyuce/mmocore/comp/flags/WorldGuardFlags.java @@ -2,6 +2,7 @@ package net.Indyuce.mmocore.comp.flags; import java.util.HashMap; import java.util.Map; +import java.util.logging.Level; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -14,6 +15,8 @@ import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.flags.StateFlag; import com.sk89q.worldguard.protection.flags.registry.FlagRegistry; +import net.Indyuce.mmocore.MMOCore; + public class WorldGuardFlags implements FlagPlugin { private final WorldGuard worldguard; private final WorldGuardPlugin worldguardPlugin; @@ -30,7 +33,11 @@ public class WorldGuardFlags implements FlagPlugin { try { registry.register(flag); flags.put(customFlag.getPath(), flag); + MMOCore.debug(1, "[FLAGDEBUG] Registered WG Flag\n" + + " - Info{name=" + flag.getName() + ",path=" + customFlag.getPath() + "}"); } catch (Exception exception) { + MMOCore.debug(1, Level.SEVERE, "[FLAGDEBUG] FAILED to register WG Flag\n" + + " - Info{name=" + flag.getName() + ",path=" + customFlag.getPath() + "}"); exception.printStackTrace(); } } diff --git a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/MythicMobsMMOLoader.java b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/MythicMobsMMOLoader.java index b2593233..43426510 100644 --- a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/MythicMobsMMOLoader.java +++ b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/MythicMobsMMOLoader.java @@ -7,6 +7,8 @@ import net.Indyuce.mmocore.api.experience.source.type.ExperienceSource; import net.Indyuce.mmocore.api.load.MMOLoader; import net.Indyuce.mmocore.api.quest.objective.Objective; import net.Indyuce.mmocore.api.quest.trigger.Trigger; +import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicFactionExperienceSource; +import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicFactionObjective; import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicMobExperienceSource; import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicMobObjective; import net.Indyuce.mmocore.comp.mythicmobs.load.MythicMobSkillTrigger; @@ -28,6 +30,8 @@ public class MythicMobsMMOLoader extends MMOLoader { if (config.getKey().equalsIgnoreCase("killmythicmob")) return new KillMythicMobObjective(section, config); + if (config.getKey().equalsIgnoreCase("killmythicfaction")) + return new KillMythicFactionObjective(section, config); return null; } @@ -37,6 +41,8 @@ public class MythicMobsMMOLoader extends MMOLoader { if (config.getKey().equalsIgnoreCase("killmythicmob")) return new KillMythicMobExperienceSource(profession, config); + if (config.getKey().equalsIgnoreCase("killmythicfaction")) + return new KillMythicFactionExperienceSource(profession, config); return null; } diff --git a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/load/KillMythicFactionExperienceSource.java b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/load/KillMythicFactionExperienceSource.java new file mode 100644 index 00000000..09f3beda --- /dev/null +++ b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/load/KillMythicFactionExperienceSource.java @@ -0,0 +1,51 @@ +package net.Indyuce.mmocore.comp.mythicmobs.load; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent; +import net.Indyuce.mmocore.MMOCore; +import net.Indyuce.mmocore.api.experience.Profession; +import net.Indyuce.mmocore.api.experience.source.type.SpecificExperienceSource; +import net.Indyuce.mmocore.api.player.PlayerData; +import net.Indyuce.mmocore.manager.profession.ExperienceManager; +import net.mmogroup.mmolib.api.MMOLineConfig; + +public class KillMythicFactionExperienceSource extends SpecificExperienceSource { + private final String factionName; + + public KillMythicFactionExperienceSource(Profession profession, MMOLineConfig config) { + super(profession, config); + + config.validate("name"); + factionName = config.getString("name"); + } + + @Override + public ExperienceManager newManager() { + return new ExperienceManager() { + @EventHandler + public void a(MythicMobDeathEvent event) { + Bukkit.getScheduler().runTaskLater(MMOCore.plugin, new Runnable() { + @Override + public void run() { + if (!event.getEntity().isDead()) return; + if (!event.getMob().hasFaction()) return; + if (!(event.getKiller() instanceof Player) || event.getKiller().hasMetadata("NPC")) return; + + PlayerData data = PlayerData.get((Player) event.getKiller()); + for (KillMythicFactionExperienceSource source : getSources()) + if (source.matches(data, event.getMob().getFaction())) + source.giveExperience(data, event.getEntity().getLocation()); + } + }, 2); + } + }; + } + + @Override + public boolean matches(PlayerData player, String name) { + return hasRightClass(player) && name.equals(factionName); + } +} diff --git a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/load/KillMythicFactionObjective.java b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/load/KillMythicFactionObjective.java new file mode 100644 index 00000000..afcd8c3a --- /dev/null +++ b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/load/KillMythicFactionObjective.java @@ -0,0 +1,56 @@ +package net.Indyuce.mmocore.comp.mythicmobs.load; + +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent; +import net.Indyuce.mmocore.api.quest.ObjectiveProgress; +import net.Indyuce.mmocore.api.quest.QuestProgress; +import net.Indyuce.mmocore.api.quest.objective.Objective; +import net.mmogroup.mmolib.api.MMOLineConfig; + +public class KillMythicFactionObjective extends Objective { + private final String factionName; + private final int required; + + public KillMythicFactionObjective(ConfigurationSection section, MMOLineConfig config) { + super(section); + + config.validate("amount", "name"); + + factionName = config.getString("name"); + required = config.getInt("amount"); + } + + @Override + public ObjectiveProgress newProgress(QuestProgress questProgress) { + return new KillFactionProgress(questProgress, this); + } + + public class KillFactionProgress extends ObjectiveProgress implements Listener { + private int count; + + public KillFactionProgress(QuestProgress questProgress, Objective objective) { + super(questProgress, objective); + } + + @EventHandler + public void a(MythicMobDeathEvent event) { + if (event.getKiller() instanceof Player + && event.getKiller().equals(getQuestProgress().getPlayer().getPlayer()) + && event.getMob().hasFaction() && event.getMob().getFaction().equals(factionName)) { + count++; + getQuestProgress().getPlayer().getQuestData().updateBossBar(); + if (count >= required) + getQuestProgress().completeObjective(); + } + } + + @Override + public String formatLore(String lore) { + return lore.replace("{left}", "" + (required - count)); + } + } +} diff --git a/src/main/java/net/Indyuce/mmocore/comp/placeholder/DefaultParser.java b/src/main/java/net/Indyuce/mmocore/comp/placeholder/DefaultParser.java index a2bb8392..a9b55887 100644 --- a/src/main/java/net/Indyuce/mmocore/comp/placeholder/DefaultParser.java +++ b/src/main/java/net/Indyuce/mmocore/comp/placeholder/DefaultParser.java @@ -1,11 +1,12 @@ package net.Indyuce.mmocore.comp.placeholder; -import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; +import net.asangarin.hexcolors.ColorParse; + public class DefaultParser implements PlaceholderParser { @Override public String parse(OfflinePlayer player, String string) { - return ChatColor.translateAlternateColorCodes('&', string.replace("%player%", player.getName())); + return new ColorParse('&', string.replace("%player%", player.getName())).toChatColor(); } } diff --git a/src/main/java/net/Indyuce/mmocore/gui/AttributeView.java b/src/main/java/net/Indyuce/mmocore/gui/AttributeView.java index 57fb2705..bdb82aca 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/AttributeView.java +++ b/src/main/java/net/Indyuce/mmocore/gui/AttributeView.java @@ -1,7 +1,5 @@ package net.Indyuce.mmocore.gui; -import java.util.Map.Entry; - import org.bukkit.Sound; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.event.inventory.InventoryClickEvent; @@ -17,7 +15,6 @@ import net.Indyuce.mmocore.gui.api.item.InventoryItem; import net.Indyuce.mmocore.gui.api.item.InventoryPlaceholderItem; import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem; import net.Indyuce.mmocore.gui.api.item.Placeholders; -import net.mmogroup.mmolib.api.stat.modifier.StatModifier; public class AttributeView extends EditableInventory { public AttributeView() { @@ -52,7 +49,8 @@ public class AttributeView extends EditableInventory { public AttributeItem(String function, ConfigurationSection config) { super(config); - attribute = MMOCore.plugin.attributeManager.get(function.substring("attribute_".length()).toLowerCase().replace(" ", "-").replace("_", "-")); + attribute = MMOCore.plugin.attributeManager + .get(function.substring("attribute_".length()).toLowerCase().replace(" ", "-").replace("_", "-")); } @Override @@ -66,10 +64,10 @@ public class AttributeView extends EditableInventory { holders.register("max", attribute.getMax()); holders.register("current", total); holders.register("attribute_points", inv.getPlayerData().getAttributePoints()); - for (Entry entry : attribute.getBuffs()) { - holders.register("buff_" + entry.getKey().toLowerCase(), entry.getValue()); - holders.register("total_" + entry.getKey().toLowerCase(), entry.getValue().multiply(total)); - } + attribute.getBuffs().forEach((key, buff) -> { + holders.register("buff_" + key.toLowerCase(), buff); + holders.register("total_" + key.toLowerCase(), buff.multiply(total)); + }); return holders; } } diff --git a/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java b/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java index 3e5250e3..eac3757a 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java +++ b/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java @@ -5,7 +5,6 @@ import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; -import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.configuration.ConfigurationSection; @@ -24,6 +23,7 @@ import net.Indyuce.mmocore.gui.api.GeneratedInventory; import net.Indyuce.mmocore.gui.api.item.InventoryItem; import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem; import net.Indyuce.mmocore.manager.InventoryManager; +import net.asangarin.hexcolors.ColorParse; import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.NBTItem; @@ -68,7 +68,7 @@ public class ClassSelect extends EditableInventory { ItemMeta meta = item.getItemMeta(); if (hideFlags()) meta.addItemFlags(ItemFlag.values()); - meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name).replace("{name}", profess.getName())); + meta.setDisplayName(new ColorParse('&', name).toChatColor().replace("{name}", profess.getName())); List lore = new ArrayList<>(this.lore); int index = lore.indexOf("{lore}"); diff --git a/src/main/java/net/Indyuce/mmocore/gui/SkillList.java b/src/main/java/net/Indyuce/mmocore/gui/SkillList.java index 308cc556..211017a2 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/SkillList.java +++ b/src/main/java/net/Indyuce/mmocore/gui/SkillList.java @@ -27,6 +27,7 @@ import net.Indyuce.mmocore.gui.api.item.InventoryItem; import net.Indyuce.mmocore.gui.api.item.InventoryPlaceholderItem; import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem; import net.Indyuce.mmocore.gui.api.item.Placeholders; +import net.asangarin.hexcolors.ColorParse; import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.NBTItem; @@ -70,7 +71,7 @@ public class SkillList extends EditableInventory { if (function.equals("slot")) return new InventoryPlaceholderItem(config) { - private final String none = ChatColor.translateAlternateColorCodes('&', config.getString("no-skill")); + private final String none = new ColorParse('&', config.getString("no-skill")).toChatColor(); private final Material emptyMaterial = Material .valueOf(config.getString("empty-item").toUpperCase().replace("-", "_").replace(" ", "_")); @@ -169,12 +170,12 @@ public class SkillList extends EditableInventory { lore.add(index + j, skillLore.get(j)); for (int j = 0; j < lore.size(); j++) - lore.set(j, ChatColor.GRAY + ChatColor.translateAlternateColorCodes('&', lore.get(j))); + lore.set(j, ChatColor.GRAY + new ColorParse('&', lore.get(j)).toChatColor()); ItemStack item = cloneItem(); ItemMeta meta = item.getItemMeta(); - meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', getName().replace("{skill}", skill.getSkill().getName()) - .replace("{roman}", MMOCoreUtils.intToRoman(skillLevel)).replace("{level}", "" + skillLevel))); + meta.setDisplayName(new ColorParse('&', getName().replace("{skill}", skill.getSkill().getName()) + .replace("{roman}", MMOCoreUtils.intToRoman(skillLevel)).replace("{level}", "" + skillLevel)).toChatColor()); meta.addItemFlags(ItemFlag.values()); meta.setLore(lore); item.setItemMeta(meta); diff --git a/src/main/java/net/Indyuce/mmocore/gui/SubclassSelect.java b/src/main/java/net/Indyuce/mmocore/gui/SubclassSelect.java index 5b85da0b..ab867b50 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/SubclassSelect.java +++ b/src/main/java/net/Indyuce/mmocore/gui/SubclassSelect.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; -import org.bukkit.ChatColor; import org.bukkit.Sound; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.event.inventory.InventoryClickEvent; @@ -21,6 +20,7 @@ import net.Indyuce.mmocore.gui.api.GeneratedInventory; import net.Indyuce.mmocore.gui.api.item.InventoryItem; import net.Indyuce.mmocore.gui.api.item.NoPlaceholderItem; import net.Indyuce.mmocore.manager.InventoryManager; +import net.asangarin.hexcolors.ColorParse; import net.mmogroup.mmolib.api.item.ItemTag; import net.mmogroup.mmolib.api.item.NBTItem; @@ -65,7 +65,7 @@ public class SubclassSelect extends EditableInventory { ItemStack item = profess.getIcon(); ItemMeta meta = item.getItemMeta(); - meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name).replace("{name}", profess.getName())); + meta.setDisplayName(new ColorParse('&', name).toChatColor().replace("{name}", profess.getName())); List lore = new ArrayList<>(this.lore); int index = lore.indexOf("{lore}"); diff --git a/src/main/java/net/Indyuce/mmocore/gui/api/GeneratedInventory.java b/src/main/java/net/Indyuce/mmocore/gui/api/GeneratedInventory.java index 8af87c23..d1595869 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/api/GeneratedInventory.java +++ b/src/main/java/net/Indyuce/mmocore/gui/api/GeneratedInventory.java @@ -4,13 +4,13 @@ import java.util.ArrayList; import java.util.List; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.Inventory; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.gui.api.item.InventoryItem; import net.Indyuce.mmocore.gui.api.item.TriggerItem; +import net.asangarin.hexcolors.ColorParse; public abstract class GeneratedInventory extends PluginInventory { private final EditableInventory editable; @@ -54,7 +54,7 @@ public abstract class GeneratedInventory extends PluginInventory { @Override public Inventory getInventory() { - Inventory inv = Bukkit.createInventory(this, editable.getSlots(), ChatColor.translateAlternateColorCodes('&', calculateName())); + Inventory inv = Bukkit.createInventory(this, editable.getSlots(), new ColorParse('&', calculateName()).toChatColor()); for (InventoryItem item : editable.getItems()) if (item.canDisplay(this)) diff --git a/src/main/java/net/Indyuce/mmocore/gui/social/party/EditablePartyView.java b/src/main/java/net/Indyuce/mmocore/gui/social/party/EditablePartyView.java index 6cc3b822..c8e88cda 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/social/party/EditablePartyView.java +++ b/src/main/java/net/Indyuce/mmocore/gui/social/party/EditablePartyView.java @@ -65,10 +65,11 @@ public class EditablePartyView extends EditableInventory { /* * run async to save performance */ - if (meta instanceof SkullMeta) { - ((SkullMeta) meta).setOwningPlayer(member.getPlayer()); - disp.setItemMeta(meta); - } + if (meta instanceof SkullMeta) + Bukkit.getScheduler().runTaskAsynchronously(MMOCore.plugin, () -> { + ((SkullMeta) meta).setOwningPlayer(member.getPlayer()); + disp.setItemMeta(meta); + }); return NBTItem.get(disp).addTag(new ItemTag("uuid", member.getUniqueId().toString())).toItem(); } diff --git a/src/main/java/net/Indyuce/mmocore/listener/PlayerListener.java b/src/main/java/net/Indyuce/mmocore/listener/PlayerListener.java index 87169277..7c0319dc 100644 --- a/src/main/java/net/Indyuce/mmocore/listener/PlayerListener.java +++ b/src/main/java/net/Indyuce/mmocore/listener/PlayerListener.java @@ -70,6 +70,8 @@ public class PlayerListener implements Listener { PlayerData playerData = PlayerData.get(event.getPlayer()); if (playerData.hasParty()) playerData.getParty().removeMember(playerData); + + MMOCore.plugin.dataProvider.getDataManager().remove(playerData); } /* diff --git a/src/main/java/net/Indyuce/mmocore/listener/WaypointsListener.java b/src/main/java/net/Indyuce/mmocore/listener/WaypointsListener.java index 990ef103..a8525d88 100644 --- a/src/main/java/net/Indyuce/mmocore/listener/WaypointsListener.java +++ b/src/main/java/net/Indyuce/mmocore/listener/WaypointsListener.java @@ -33,6 +33,7 @@ public class WaypointsListener implements Listener { return; } + player.setSneaking(false); InventoryManager.WAYPOINTS.newInventory(data, waypoint).open(); } } diff --git a/src/main/java/net/Indyuce/mmocore/listener/option/RedirectVanillaExp.java b/src/main/java/net/Indyuce/mmocore/listener/option/RedirectVanillaExp.java index 6e007941..bc47393c 100644 --- a/src/main/java/net/Indyuce/mmocore/listener/option/RedirectVanillaExp.java +++ b/src/main/java/net/Indyuce/mmocore/listener/option/RedirectVanillaExp.java @@ -4,6 +4,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerExpChangeEvent; +import net.Indyuce.mmocore.api.experience.EXPSource; import net.Indyuce.mmocore.api.player.PlayerData; public class RedirectVanillaExp implements Listener { @@ -17,6 +18,6 @@ public class RedirectVanillaExp implements Listener { public void a(PlayerExpChangeEvent event) { int a = (int) (event.getAmount() * ratio); if (a > 0) - PlayerData.get(event.getPlayer()).giveExperience(a); + PlayerData.get(event.getPlayer()).giveExperience(a, EXPSource.VANILLA); } } diff --git a/src/main/java/net/Indyuce/mmocore/listener/profession/FishingListener.java b/src/main/java/net/Indyuce/mmocore/listener/profession/FishingListener.java index 374eb0fe..fbd078d4 100644 --- a/src/main/java/net/Indyuce/mmocore/listener/profession/FishingListener.java +++ b/src/main/java/net/Indyuce/mmocore/listener/profession/FishingListener.java @@ -24,6 +24,7 @@ import org.bukkit.util.Vector; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.droptable.dropitem.fishing.FishingDropItem; import net.Indyuce.mmocore.api.event.CustomPlayerFishEvent; +import net.Indyuce.mmocore.api.experience.EXPSource; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.stats.StatType; import net.Indyuce.mmocore.manager.profession.FishingManager.FishingDropTable; @@ -176,7 +177,7 @@ public class FishingListener implements Listener { location.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, location, 0, 4 * (random.nextDouble() - .5), 2, 4 * (random.nextDouble() - .5), .05); if (MMOCore.plugin.professionManager.has("fishing")) - playerData.getCollectionSkills().giveExperience(MMOCore.plugin.professionManager.get("fishing"), exp, location); + playerData.getCollectionSkills().giveExperience(MMOCore.plugin.professionManager.get("fishing"), exp, location, EXPSource.FISHING); } } } diff --git a/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java b/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java index 76197ce5..9e6113fe 100644 --- a/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java +++ b/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java @@ -20,6 +20,7 @@ import net.Indyuce.mmocore.api.util.input.AnvilGUI; import net.Indyuce.mmocore.api.util.input.ChatInput; import net.Indyuce.mmocore.api.util.input.PlayerInput; import net.Indyuce.mmocore.api.util.input.PlayerInput.InputType; +import net.asangarin.hexcolors.ColorParse; public class ConfigManager { @@ -155,28 +156,32 @@ public class ConfigManager { String format = messages.getString(key, ""); for (int j = 0; j < placeholders.length - 1; j += 2) format = format.replace("{" + placeholders[j] + "}", placeholders[j + 1]); - return new SimpleMessage(ChatColor.translateAlternateColorCodes('&', format)); + return new SimpleMessage(new ColorParse('&', format).toChatColor()); } public class SimpleMessage { private final String message; + private final boolean actionbar; + private final boolean hasPlaceholders; public SimpleMessage(String message) { - this.message = message; + this.actionbar = message.startsWith("%"); + this.message = actionbar ? message.substring(1) : message; + this.hasPlaceholders = this.message.contains("%"); } public String message() { - return message.startsWith("%") ? message.substring(1) : message; + return message; } public boolean send(Player player) { - if (!message.isEmpty()) { - if (message.startsWith("%")) - PlayerData.get(player.getUniqueId()).displayActionBar(message.substring(1)); - else - player.sendMessage(message); + String msg = hasPlaceholders ? MMOCore.plugin.placeholderParser.parse(player, message) : message; + + if (!msg.isEmpty()) { + if (actionbar) PlayerData.get(player.getUniqueId()).displayActionBar(msg); + else player.sendMessage(msg); } - return !message.isEmpty(); + return !msg.isEmpty(); } } } diff --git a/src/main/java/net/Indyuce/mmocore/manager/ExperienceManager.java b/src/main/java/net/Indyuce/mmocore/manager/ExperienceManager.java index 6b2c1566..cd98c02a 100644 --- a/src/main/java/net/Indyuce/mmocore/manager/ExperienceManager.java +++ b/src/main/java/net/Indyuce/mmocore/manager/ExperienceManager.java @@ -10,7 +10,7 @@ import java.util.logging.Level; import org.apache.commons.lang.Validate; import net.Indyuce.mmocore.MMOCore; -import net.Indyuce.mmocore.api.player.ExpCurve; +import net.Indyuce.mmocore.api.experience.ExpCurve; import net.Indyuce.mmoitems.MMOItems; public class ExperienceManager { diff --git a/src/main/java/net/Indyuce/mmocore/manager/data/PlayerDataManager.java b/src/main/java/net/Indyuce/mmocore/manager/data/PlayerDataManager.java index 7b8cdb49..014487c9 100644 --- a/src/main/java/net/Indyuce/mmocore/manager/data/PlayerDataManager.java +++ b/src/main/java/net/Indyuce/mmocore/manager/data/PlayerDataManager.java @@ -25,6 +25,10 @@ public abstract class PlayerDataManager { return map.getOrDefault(uuid, PlayerData.NOT_LOADED); } + public void remove(UUID uuid) { + map.remove(uuid); + } + public abstract OfflinePlayerData getOffline(UUID uuid); public void setup(Player player) { @@ -54,7 +58,7 @@ public abstract class PlayerDataManager { public boolean isLoaded(UUID uuid) { return map.containsKey(uuid); } - + public Collection getLoaded() { return map.values(); } @@ -62,4 +66,6 @@ public abstract class PlayerDataManager { public abstract void loadData(PlayerData data); public abstract void saveData(PlayerData data); + + public abstract void remove(PlayerData data); } diff --git a/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java b/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java index 3b33783d..f126bdfd 100644 --- a/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java +++ b/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MySQLPlayerDataManager.java @@ -231,4 +231,10 @@ public class MySQLPlayerDataManager extends PlayerDataManager { return lastLogin; } } + + @Override + public void remove(PlayerData data) { + saveData(data); + remove(data.getUniqueId()); + } } diff --git a/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java b/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java index d0ae7292..67f9f0e8 100644 --- a/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java +++ b/src/main/java/net/Indyuce/mmocore/manager/data/yaml/YAMLPlayerDataManager.java @@ -127,4 +127,7 @@ public class YAMLPlayerDataManager extends PlayerDataManager { public OfflinePlayerData getOffline(UUID uuid) { return isLoaded(uuid) ? get(uuid) : new YAMLOfflinePlayerData(uuid); } + + @Override + public void remove(PlayerData data) {} } diff --git a/src/main/java/net/Indyuce/mmocore/manager/social/BoosterManager.java b/src/main/java/net/Indyuce/mmocore/manager/social/BoosterManager.java index cc24a641..5bfcd259 100644 --- a/src/main/java/net/Indyuce/mmocore/manager/social/BoosterManager.java +++ b/src/main/java/net/Indyuce/mmocore/manager/social/BoosterManager.java @@ -11,7 +11,16 @@ public class BoosterManager { private List map = new ArrayList<>(); public void register(Booster booster) { + + // always flush booster list to reduce future calculations flush(); + + for (Booster active : map) + if (active.canStackWith(booster)) { + active.addLength(booster.getLength()); + return; + } + map.add(booster); } @@ -25,17 +34,20 @@ public class BoosterManager { public int calculateExp(Profession profession, double exp) { flush(); + for (Booster booster : map) if (booster.getProfession() == profession) exp = booster.calculateExp(exp); + return (int) exp; } public List getBoosters() { flush(); + return map; } - + public Booster get(int index) { return map.get(index); }