forked from Upstream/mmocore
!Exp curve refactor
This commit is contained in:
parent
65ce8db793
commit
9105a8744a
@ -70,6 +70,7 @@ import net.Indyuce.mmocore.manager.ConfigManager;
|
|||||||
import net.Indyuce.mmocore.manager.CustomBlockManager;
|
import net.Indyuce.mmocore.manager.CustomBlockManager;
|
||||||
import net.Indyuce.mmocore.manager.DropTableManager;
|
import net.Indyuce.mmocore.manager.DropTableManager;
|
||||||
import net.Indyuce.mmocore.manager.EntityManager;
|
import net.Indyuce.mmocore.manager.EntityManager;
|
||||||
|
import net.Indyuce.mmocore.manager.ExperienceManager;
|
||||||
import net.Indyuce.mmocore.manager.InventoryManager;
|
import net.Indyuce.mmocore.manager.InventoryManager;
|
||||||
import net.Indyuce.mmocore.manager.LootableChestManager;
|
import net.Indyuce.mmocore.manager.LootableChestManager;
|
||||||
import net.Indyuce.mmocore.manager.MMOLoadManager;
|
import net.Indyuce.mmocore.manager.MMOLoadManager;
|
||||||
@ -120,6 +121,7 @@ public class MMOCore extends JavaPlugin {
|
|||||||
public final QuestManager questManager = new QuestManager();
|
public final QuestManager questManager = new QuestManager();
|
||||||
public final ProfessionManager professionManager = new ProfessionManager();
|
public final ProfessionManager professionManager = new ProfessionManager();
|
||||||
public final EntityManager entities = new EntityManager();
|
public final EntityManager entities = new EntityManager();
|
||||||
|
public final ExperienceManager experience = new ExperienceManager();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* professions
|
* professions
|
||||||
@ -131,7 +133,6 @@ public class MMOCore extends JavaPlugin {
|
|||||||
|
|
||||||
public final MMOLoadManager loadManager = new MMOLoadManager();
|
public final MMOLoadManager loadManager = new MMOLoadManager();
|
||||||
|
|
||||||
|
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
plugin = this;
|
plugin = this;
|
||||||
|
|
||||||
@ -378,6 +379,9 @@ public class MMOCore extends JavaPlugin {
|
|||||||
attributeManager.clear();
|
attributeManager.clear();
|
||||||
attributeManager.reload();
|
attributeManager.reload();
|
||||||
|
|
||||||
|
// experience must be loaded before professions and classes
|
||||||
|
experience.reload();
|
||||||
|
|
||||||
professionManager.clear();
|
professionManager.clear();
|
||||||
professionManager.reload();
|
professionManager.reload();
|
||||||
|
|
||||||
|
@ -10,13 +10,19 @@ import org.bukkit.potion.PotionType;
|
|||||||
|
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.load.MMOLoadException;
|
import net.Indyuce.mmocore.api.load.MMOLoadException;
|
||||||
|
import net.Indyuce.mmocore.api.player.ExpCurve;
|
||||||
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
||||||
import net.mmogroup.mmolib.MMOLib;
|
import net.mmogroup.mmolib.MMOLib;
|
||||||
import net.mmogroup.mmolib.api.MMOLineConfig;
|
import net.mmogroup.mmolib.api.MMOLineConfig;
|
||||||
|
|
||||||
public class Profession {
|
public class Profession {
|
||||||
private final String id, name, expCurve;
|
private final String id, name;
|
||||||
|
private final ExpCurve expCurve;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* experience given to the main player level whenever he levels up this
|
||||||
|
* profession
|
||||||
|
*/
|
||||||
private final LinearValue experience;
|
private final LinearValue experience;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -31,7 +37,9 @@ public class Profession {
|
|||||||
this.name = config.getString("name");
|
this.name = config.getString("name");
|
||||||
Validate.notNull(name, "Could not load name");
|
Validate.notNull(name, "Could not load name");
|
||||||
|
|
||||||
expCurve = config.getString("exp-curve", "levels");
|
expCurve = config.contains("exp-curve")
|
||||||
|
? MMOCore.plugin.experience.getOrThrow(config.get("exp-curve").toString().toLowerCase().replace("_", "-").replace(" ", "-"))
|
||||||
|
: ExpCurve.DEFAULT;
|
||||||
experience = new LinearValue(config.getConfigurationSection("experience"));
|
experience = new LinearValue(config.getConfigurationSection("experience"));
|
||||||
|
|
||||||
if (config.contains("exp-sources"))
|
if (config.contains("exp-sources"))
|
||||||
@ -110,7 +118,7 @@ public class Profession {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEXPCurve() {
|
public ExpCurve getExpCurve() {
|
||||||
return expCurve;
|
return expCurve;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
67
src/main/java/net/Indyuce/mmocore/api/player/ExpCurve.java
Normal file
67
src/main/java/net/Indyuce/mmocore/api/player/ExpCurve.java
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
package net.Indyuce.mmocore.api.player;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
|
|
||||||
|
public class ExpCurve {
|
||||||
|
private final String id;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* experience needed to level up. different professions or classes can have
|
||||||
|
* different exp curves so that it is easier to balance.
|
||||||
|
*/
|
||||||
|
private final List<Integer> experience = new ArrayList<>();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* purely arbitrary but MMOCore needs a default exp curve for everything
|
||||||
|
* otherwise there might be divisions by 0 when trying to update the vanilla
|
||||||
|
* exp bar which requires a 0.0 -> 1.0 float as parameter
|
||||||
|
*/
|
||||||
|
public static final ExpCurve DEFAULT = new ExpCurve("default", 100, 200, 300, 400, 500);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* read exp curve from a file, one line after the other
|
||||||
|
*/
|
||||||
|
public ExpCurve(File file) throws IOException {
|
||||||
|
this.id = file.getName().replace(".txt", "").toLowerCase().replace("_", "-").replace(" ", "-");
|
||||||
|
|
||||||
|
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||||
|
String readLine;
|
||||||
|
while ((readLine = reader.readLine()) != null)
|
||||||
|
experience.add(Integer.valueOf(readLine));
|
||||||
|
reader.close();
|
||||||
|
|
||||||
|
Validate.isTrue(!experience.isEmpty(), "There must be at least one exp value in your exp curve");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* can be used by external plugins to register curves and it used by MMOCore
|
||||||
|
* to create the default exp curve if none is selected
|
||||||
|
*/
|
||||||
|
public ExpCurve(String id, int... values) {
|
||||||
|
this.id = id;
|
||||||
|
for (int value : values)
|
||||||
|
experience.add(value);
|
||||||
|
Validate.isTrue(!experience.isEmpty(), "There must be at least one exp value in your exp curve");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* retrieves the experience needed. the level serves as index for the list
|
||||||
|
* checkup. if the level is higher than the amount of exp inputs, just
|
||||||
|
* return the last list value
|
||||||
|
*/
|
||||||
|
public int getExperience(int level) {
|
||||||
|
Validate.isTrue(level > 0, "Level must be stricly positive");
|
||||||
|
return experience.get(Math.min(level, experience.size()) - 1);
|
||||||
|
}
|
||||||
|
}
|
@ -119,7 +119,8 @@ public class PlayerData extends OfflinePlayerData {
|
|||||||
j++;
|
j++;
|
||||||
} catch (NullPointerException notFound) {
|
} catch (NullPointerException notFound) {
|
||||||
boundSkills.remove(j);
|
boundSkills.remove(j);
|
||||||
MMOCore.log(Level.SEVERE, "[Userdata] Could not find skill " + boundSkills.get(j).getSkill().getId() + " in class " + getProfess().getId() + " while refreshing player data.");
|
MMOCore.log(Level.SEVERE, "[Userdata] Could not find skill " + boundSkills.get(j).getSkill().getId() + " in class "
|
||||||
|
+ getProfess().getId() + " while refreshing player data.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,6 +192,13 @@ public class PlayerData extends OfflinePlayerData {
|
|||||||
return skillPoints;
|
return skillPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns level up needed in order to level up
|
||||||
|
*/
|
||||||
|
public int getLevelUpExperience() {
|
||||||
|
return getProfess().getExpCurve().getExperience(getLevel() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
// public int getSkillReallocationPoints() {
|
// public int getSkillReallocationPoints() {
|
||||||
// return skillReallocationPoints;
|
// return skillReallocationPoints;
|
||||||
// }
|
// }
|
||||||
@ -223,19 +231,19 @@ public class PlayerData extends OfflinePlayerData {
|
|||||||
public void giveLevels(int value) {
|
public void giveLevels(int value) {
|
||||||
int total = 0;
|
int total = 0;
|
||||||
while (value-- > 0)
|
while (value-- > 0)
|
||||||
total += MMOCore.plugin.configManager.getNeededExperience(getLevel() + value + 1, getProfess());
|
total += getProfess().getExpCurve().getExperience(getLevel() + value + 1);
|
||||||
giveExperience(total);
|
giveExperience(total);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExperience(int value) {
|
public void setExperience(int value) {
|
||||||
experience = Math.max(0, value);
|
experience = Math.max(0, value);
|
||||||
refreshVanillaExp(MMOCore.plugin.configManager.getNeededExperience(getLevel() + 1, getProfess()));
|
refreshVanillaExp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshVanillaExp(float needed) {
|
public void refreshVanillaExp() {
|
||||||
if (MMOCore.plugin.configManager.overrideVanillaExp) {
|
if (MMOCore.plugin.configManager.overrideVanillaExp) {
|
||||||
player.setLevel(getLevel());
|
player.setLevel(getLevel());
|
||||||
player.setExp((float) experience / needed);
|
player.setExp((float) experience / (float) getLevelUpExperience());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,7 +354,8 @@ public class PlayerData extends OfflinePlayerData {
|
|||||||
setLastFriendRequest(System.currentTimeMillis());
|
setLastFriendRequest(System.currentTimeMillis());
|
||||||
|
|
||||||
FriendRequest request = new FriendRequest(this, target);
|
FriendRequest request = new FriendRequest(this, target);
|
||||||
new ConfigMessage("friend-request").addPlaceholders("player", getPlayer().getName(), "uuid", request.getUniqueId().toString()).sendAsJSon(target.getPlayer());
|
new ConfigMessage("friend-request").addPlaceholders("player", getPlayer().getName(), "uuid", request.getUniqueId().toString())
|
||||||
|
.sendAsJSon(target.getPlayer());
|
||||||
MMOCore.plugin.requestManager.registerRequest(request);
|
MMOCore.plugin.requestManager.registerRequest(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,7 +387,9 @@ public class PlayerData extends OfflinePlayerData {
|
|||||||
player.playSound(player.getLocation(), VersionSound.BLOCK_NOTE_BLOCK_BELL.toSound(), 1, (float) (t / Math.PI * .015 + .5));
|
player.playSound(player.getLocation(), VersionSound.BLOCK_NOTE_BLOCK_BELL.toSound(), 1, (float) (t / Math.PI * .015 + .5));
|
||||||
double r = Math.sin((double) t / 100 * Math.PI);
|
double r = Math.sin((double) t / 100 * Math.PI);
|
||||||
for (double j = 0; j < Math.PI * 2; j += Math.PI / 4)
|
for (double j = 0; j < Math.PI * 2; j += Math.PI / 4)
|
||||||
MMOLib.plugin.getVersion().getWrapper().spawnParticle(Particle.REDSTONE, player.getLocation().add(Math.cos((double) t / 20 + j) * r, (double) t / 50, Math.sin((double) t / 20 + j) * r), 1.25f, Color.PURPLE);
|
MMOLib.plugin.getVersion().getWrapper().spawnParticle(Particle.REDSTONE,
|
||||||
|
player.getLocation().add(Math.cos((double) t / 20 + j) * r, (double) t / 50, Math.sin((double) t / 20 + j) * r), 1.25f,
|
||||||
|
Color.PURPLE);
|
||||||
}
|
}
|
||||||
}.runTaskTimer(MMOCore.plugin, 0, 1);
|
}.runTaskTimer(MMOCore.plugin, 0, 1);
|
||||||
}
|
}
|
||||||
@ -400,7 +411,8 @@ public class PlayerData extends OfflinePlayerData {
|
|||||||
// display hologram
|
// display hologram
|
||||||
if (MMOCore.plugin.getConfig().getBoolean("display-exp-holograms"))
|
if (MMOCore.plugin.getConfig().getBoolean("display-exp-holograms"))
|
||||||
if (loc != null && MMOCore.plugin.hologramSupport != null)
|
if (loc != null && MMOCore.plugin.hologramSupport != null)
|
||||||
MMOCore.plugin.hologramSupport.displayIndicator(loc.add(.5, 1.5, .5), MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + value).message(), getPlayer());
|
MMOCore.plugin.hologramSupport.displayIndicator(loc.add(.5, 1.5, .5),
|
||||||
|
MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + value).message(), getPlayer());
|
||||||
|
|
||||||
value = MMOCore.plugin.boosterManager.calculateExp(null, value);
|
value = MMOCore.plugin.boosterManager.calculateExp(null, value);
|
||||||
value *= 1 + getStats().getStat(StatType.ADDITIONAL_EXPERIENCE) / 100;
|
value *= 1 + getStats().getStat(StatType.ADDITIONAL_EXPERIENCE) / 100;
|
||||||
@ -414,7 +426,7 @@ public class PlayerData extends OfflinePlayerData {
|
|||||||
|
|
||||||
int needed;
|
int needed;
|
||||||
boolean check = false;
|
boolean check = false;
|
||||||
while (experience >= (needed = MMOCore.plugin.configManager.getNeededExperience(getLevel() + 1, getProfess()))) {
|
while (experience >= (needed = getLevelUpExperience())) {
|
||||||
|
|
||||||
if (hasReachedMaxLevel()) {
|
if (hasReachedMaxLevel()) {
|
||||||
experience = 0;
|
experience = 0;
|
||||||
@ -434,7 +446,7 @@ public class PlayerData extends OfflinePlayerData {
|
|||||||
getStats().getMap().updateAll();
|
getStats().getMap().updateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshVanillaExp(needed);
|
refreshVanillaExp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExperience() {
|
public int getExperience() {
|
||||||
|
@ -49,12 +49,12 @@ public class Professions {
|
|||||||
|
|
||||||
public String toJsonString() {
|
public String toJsonString() {
|
||||||
JsonObject json = new JsonObject();
|
JsonObject json = new JsonObject();
|
||||||
for (Profession prof : MMOCore.plugin.professionManager.getAll()) {
|
for (Profession profession : MMOCore.plugin.professionManager.getAll()) {
|
||||||
JsonObject p = new JsonObject();
|
JsonObject object = new JsonObject();
|
||||||
p.addProperty("exp", getExperience(prof));
|
object.addProperty("exp", getExperience(profession));
|
||||||
p.addProperty("level", getLevel(prof));
|
object.addProperty("level", getLevel(profession));
|
||||||
|
|
||||||
json.add(prof.getId(), p);
|
json.add(profession.getId(), object);
|
||||||
}
|
}
|
||||||
return json.toString();
|
return json.toString();
|
||||||
}
|
}
|
||||||
@ -90,6 +90,10 @@ public class Professions {
|
|||||||
return getExperience(profession.getId());
|
return getExperience(profession.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getLevelUpExperience(Profession profession) {
|
||||||
|
return profession.getExpCurve().getExperience(getLevel(profession) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
public void setLevel(Profession profession, int value) {
|
public void setLevel(Profession profession, int value) {
|
||||||
level.put(profession.getId(), value);
|
level.put(profession.getId(), value);
|
||||||
}
|
}
|
||||||
@ -101,7 +105,7 @@ public class Professions {
|
|||||||
public void giveLevels(Profession profession, int value) {
|
public void giveLevels(Profession profession, int value) {
|
||||||
int total = 0, level = getLevel(profession);
|
int total = 0, level = getLevel(profession);
|
||||||
while (value-- > 0)
|
while (value-- > 0)
|
||||||
total += MMOCore.plugin.configManager.getNeededExperience(level + value + 1, profession);
|
total += profession.getExpCurve().getExperience(level + value + 1);
|
||||||
giveExperience(profession, total);
|
giveExperience(profession, total);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,19 +120,21 @@ public class Professions {
|
|||||||
// display hologram
|
// display hologram
|
||||||
if (MMOCore.plugin.getConfig().getBoolean("display-exp-holograms")) {
|
if (MMOCore.plugin.getConfig().getBoolean("display-exp-holograms")) {
|
||||||
if (loc != null && MMOCore.plugin.hologramSupport != null)
|
if (loc != null && MMOCore.plugin.hologramSupport != null)
|
||||||
MMOCore.plugin.hologramSupport.displayIndicator(loc.add(.5, 1.5, .5), MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + value).message(), playerData.getPlayer());
|
MMOCore.plugin.hologramSupport.displayIndicator(loc.add(.5, 1.5, .5),
|
||||||
|
MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + value).message(), playerData.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
int needed, exp, level;
|
int needed, exp, level;
|
||||||
boolean check = false;
|
boolean check = false;
|
||||||
while ((exp = this.exp.get(profession.getId())) >= (needed = MMOCore.plugin.configManager.getNeededExperience((level = getLevel(profession)) + 1, profession))) {
|
while ((exp = this.exp.get(profession.getId())) >= (needed = profession.getExpCurve().getExperience((level = getLevel(profession)) + 1))) {
|
||||||
this.exp.put(profession.getId(), exp - needed);
|
this.exp.put(profession.getId(), exp - needed);
|
||||||
this.level.put(profession.getId(), level + 1);
|
this.level.put(profession.getId(), level + 1);
|
||||||
check = true;
|
check = true;
|
||||||
playerData.giveExperience((int) profession.getExperience().calculate(level), null);
|
playerData.giveExperience((int) profession.getExperience().calculate(level), null);
|
||||||
Bukkit.getPluginManager().callEvent(new PlayerLevelUpEvent(playerData, profession, level + 1));
|
Bukkit.getPluginManager().callEvent(new PlayerLevelUpEvent(playerData, profession, level + 1));
|
||||||
|
|
||||||
new ConfigMessage("profession-level-up").addPlaceholders("level", "" + (level + 1), "profession", profession.getName()).send(playerData.getPlayer());
|
new ConfigMessage("profession-level-up").addPlaceholders("level", "" + (level + 1), "profession", profession.getName())
|
||||||
|
.send(playerData.getPlayer());
|
||||||
playerData.getPlayer().playSound(playerData.getPlayer().getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 2);
|
playerData.getPlayer().playSound(playerData.getPlayer().getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 2);
|
||||||
}
|
}
|
||||||
if (check)
|
if (check)
|
||||||
@ -138,6 +144,7 @@ public class Professions {
|
|||||||
int chars = (int) ((double) exp / needed * 20);
|
int chars = (int) ((double) exp / needed * 20);
|
||||||
for (int j = 0; j < 20; j++)
|
for (int j = 0; j < 20; j++)
|
||||||
bar += (j == chars ? "" + ChatColor.WHITE + ChatColor.BOLD : "") + "|";
|
bar += (j == chars ? "" + ChatColor.WHITE + ChatColor.BOLD : "") + "|";
|
||||||
MMOCore.plugin.configManager.getSimpleMessage("exp-notification", "profession", profession.getName(), "progress", bar, "ratio", MMOCore.plugin.configManager.decimal.format((double) exp / needed * 100)).send(playerData.getPlayer());
|
MMOCore.plugin.configManager.getSimpleMessage("exp-notification", "profession", profession.getName(), "progress", bar, "ratio",
|
||||||
|
MMOCore.plugin.configManager.decimal.format((double) exp / needed * 100)).send(playerData.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import net.Indyuce.mmocore.MMOCore;
|
|||||||
import net.Indyuce.mmocore.api.AltChar;
|
import net.Indyuce.mmocore.api.AltChar;
|
||||||
import net.Indyuce.mmocore.api.experience.source.type.ExperienceSource;
|
import net.Indyuce.mmocore.api.experience.source.type.ExperienceSource;
|
||||||
import net.Indyuce.mmocore.api.load.MMOLoadException;
|
import net.Indyuce.mmocore.api.load.MMOLoadException;
|
||||||
|
import net.Indyuce.mmocore.api.player.ExpCurve;
|
||||||
import net.Indyuce.mmocore.api.player.profess.event.EventTrigger;
|
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.ManaDisplayOptions;
|
||||||
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
||||||
@ -41,12 +42,13 @@ import net.mmogroup.mmolib.api.MMOLineConfig;
|
|||||||
import net.mmogroup.mmolib.version.VersionMaterial;
|
import net.mmogroup.mmolib.version.VersionMaterial;
|
||||||
|
|
||||||
public class PlayerClass {
|
public class PlayerClass {
|
||||||
private final String name, id, fileName, expCurve;
|
private final String name, id, fileName;
|
||||||
private final List<String> description = new ArrayList<>(), attrDescription = new ArrayList<>();
|
private final List<String> description = new ArrayList<>(), attrDescription = new ArrayList<>();
|
||||||
private final ItemStack icon;
|
private final ItemStack icon;
|
||||||
private final Map<ClassOption, Boolean> options = new HashMap<>();
|
private final Map<ClassOption, Boolean> options = new HashMap<>();
|
||||||
private final ManaDisplayOptions manaDisplay;
|
private final ManaDisplayOptions manaDisplay;
|
||||||
private final int maxLevel, displayOrder;
|
private final int maxLevel, displayOrder;
|
||||||
|
private final ExpCurve expCurve;
|
||||||
|
|
||||||
private final Map<StatType, LinearValue> stats = new HashMap<>();
|
private final Map<StatType, LinearValue> stats = new HashMap<>();
|
||||||
private final Map<String, SkillInfo> skills = new LinkedHashMap<>();
|
private final Map<String, SkillInfo> skills = new LinkedHashMap<>();
|
||||||
@ -94,12 +96,16 @@ public class PlayerClass {
|
|||||||
manaDisplay = new ManaDisplayOptions(config.getConfigurationSection("mana"));
|
manaDisplay = new ManaDisplayOptions(config.getConfigurationSection("mana"));
|
||||||
maxLevel = config.getInt("max-level");
|
maxLevel = config.getInt("max-level");
|
||||||
displayOrder = config.getInt("display-order");
|
displayOrder = config.getInt("display-order");
|
||||||
expCurve = config.getString("exp-curve", "levels");
|
|
||||||
|
expCurve = config.contains("exp-curve")
|
||||||
|
? MMOCore.plugin.experience.getOrThrow(config.get("exp-curve").toString().toLowerCase().replace("_", "-").replace(" ", "-"))
|
||||||
|
: ExpCurve.DEFAULT;
|
||||||
|
|
||||||
if (config.contains("attributes"))
|
if (config.contains("attributes"))
|
||||||
for (String key : config.getConfigurationSection("attributes").getKeys(false))
|
for (String key : config.getConfigurationSection("attributes").getKeys(false))
|
||||||
try {
|
try {
|
||||||
stats.put(StatType.valueOf(key.toUpperCase().replace("-", "_")), new LinearValue(config.getConfigurationSection("attributes." + key)));
|
stats.put(StatType.valueOf(key.toUpperCase().replace("-", "_")),
|
||||||
|
new LinearValue(config.getConfigurationSection("attributes." + key)));
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
MMOCore.log(Level.WARNING, "[PlayerClasses:" + id + "] Could not load stat info '" + key + "': " + exception.getMessage());
|
MMOCore.log(Level.WARNING, "[PlayerClasses:" + id + "] Could not load stat info '" + key + "': " + exception.getMessage());
|
||||||
}
|
}
|
||||||
@ -156,9 +162,11 @@ public class PlayerClass {
|
|||||||
for (PlayerResource resource : PlayerResource.values()) {
|
for (PlayerResource resource : PlayerResource.values()) {
|
||||||
if (config.isConfigurationSection("resource." + resource.name().toLowerCase()))
|
if (config.isConfigurationSection("resource." + resource.name().toLowerCase()))
|
||||||
try {
|
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) {
|
} 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));
|
resourceHandlers.put(resource, new ResourceHandler(resource));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -176,7 +184,7 @@ public class PlayerClass {
|
|||||||
manaDisplay = new ManaDisplayOptions(ChatColor.BLUE, "Mana", AltChar.listSquare.charAt(0));
|
manaDisplay = new ManaDisplayOptions(ChatColor.BLUE, "Mana", AltChar.listSquare.charAt(0));
|
||||||
maxLevel = 0;
|
maxLevel = 0;
|
||||||
displayOrder = 0;
|
displayOrder = 0;
|
||||||
expCurve = "";
|
expCurve = ExpCurve.DEFAULT;
|
||||||
|
|
||||||
this.icon = new ItemStack(material);
|
this.icon = new ItemStack(material);
|
||||||
setOption(ClassOption.DISPLAY, false);
|
setOption(ClassOption.DISPLAY, false);
|
||||||
@ -217,7 +225,7 @@ public class PlayerClass {
|
|||||||
return displayOrder;
|
return displayOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEXPCurve() {
|
public ExpCurve getExpCurve() {
|
||||||
return expCurve;
|
return expCurve;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,12 +34,17 @@ public class InfoCommandMap extends CommandEnd {
|
|||||||
sender.sendMessage(ChatColor.YELLOW + "----------------------------------------------------");
|
sender.sendMessage(ChatColor.YELLOW + "----------------------------------------------------");
|
||||||
sender.sendMessage(ChatColor.YELLOW + "Class: " + ChatColor.GOLD + playerData.getProfess().getName());
|
sender.sendMessage(ChatColor.YELLOW + "Class: " + ChatColor.GOLD + playerData.getProfess().getName());
|
||||||
sender.sendMessage(ChatColor.YELLOW + "Level: " + ChatColor.GOLD + playerData.getLevel());
|
sender.sendMessage(ChatColor.YELLOW + "Level: " + ChatColor.GOLD + playerData.getLevel());
|
||||||
sender.sendMessage(ChatColor.YELLOW + "Experience: " + ChatColor.GOLD + playerData.getExperience() + ChatColor.YELLOW + " / " + ChatColor.GOLD + MMOCore.plugin.configManager.getNeededExperience(playerData.getLevel() + 1, playerData.getProfess()));
|
sender.sendMessage(ChatColor.YELLOW + "Experience: " + ChatColor.GOLD + playerData.getExperience() + ChatColor.YELLOW + " / " + ChatColor.GOLD
|
||||||
|
+ playerData.getLevelUpExperience());
|
||||||
sender.sendMessage(ChatColor.YELLOW + "Class Points: " + ChatColor.GOLD + playerData.getClassPoints());
|
sender.sendMessage(ChatColor.YELLOW + "Class Points: " + ChatColor.GOLD + playerData.getClassPoints());
|
||||||
sender.sendMessage(ChatColor.YELLOW + "Quests: " + ChatColor.GOLD + playerData.getQuestData().getFinishedQuests().size() + ChatColor.YELLOW + " / " + ChatColor.GOLD + MMOCore.plugin.questManager.getAll().size());
|
sender.sendMessage(ChatColor.YELLOW + "Quests: " + ChatColor.GOLD + playerData.getQuestData().getFinishedQuests().size() + ChatColor.YELLOW
|
||||||
|
+ " / " + ChatColor.GOLD + MMOCore.plugin.questManager.getAll().size());
|
||||||
sender.sendMessage(ChatColor.YELLOW + "----------------------------------------------------");
|
sender.sendMessage(ChatColor.YELLOW + "----------------------------------------------------");
|
||||||
for (Profession profession : MMOCore.plugin.professionManager.getAll())
|
for (Profession profession : MMOCore.plugin.professionManager.getAll())
|
||||||
sender.sendMessage(ChatColor.YELLOW + profession.getName() + ": Lvl " + ChatColor.GOLD + playerData.getCollectionSkills().getLevel(profession) + ChatColor.YELLOW + " - " + ChatColor.GOLD + playerData.getCollectionSkills().getExperience(profession) + ChatColor.YELLOW + " / " + ChatColor.GOLD + MMOCore.plugin.configManager.getNeededExperience(playerData.getCollectionSkills().getLevel(profession) + 1, profession));
|
sender.sendMessage(
|
||||||
|
ChatColor.YELLOW + profession.getName() + ": Lvl " + ChatColor.GOLD + playerData.getCollectionSkills().getLevel(profession)
|
||||||
|
+ ChatColor.YELLOW + " - " + ChatColor.GOLD + playerData.getCollectionSkills().getExperience(profession)
|
||||||
|
+ ChatColor.YELLOW + " / " + ChatColor.GOLD + playerData.getCollectionSkills().getLevelUpExperience(profession));
|
||||||
sender.sendMessage(ChatColor.YELLOW + "----------------------------------------------------");
|
sender.sendMessage(ChatColor.YELLOW + "----------------------------------------------------");
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
package net.Indyuce.mmocore.command.rpg.debug;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
public class Debug {
|
|
||||||
public static final String cmdPrefix = ChatColor.YELLOW + "[" + ChatColor.RED + "DEBUG" + ChatColor.GOLD + "] " + ChatColor.RESET;
|
|
||||||
}
|
|
@ -1,10 +1,13 @@
|
|||||||
package net.Indyuce.mmocore.command.rpg.debug;
|
package net.Indyuce.mmocore.command.rpg.debug;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.command.api.CommandMap;
|
import net.Indyuce.mmocore.command.api.CommandMap;
|
||||||
|
|
||||||
public class DebugCommandMap extends CommandMap {
|
public class DebugCommandMap extends CommandMap {
|
||||||
|
public static final String commandPrefix = ChatColor.YELLOW + "[" + ChatColor.RED + "DEBUG" + ChatColor.GOLD + "] " + ChatColor.RESET;
|
||||||
|
|
||||||
public DebugCommandMap(CommandMap parent) {
|
public DebugCommandMap(CommandMap parent) {
|
||||||
super(parent, "debug");
|
super(parent, "debug");
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@ public class StatValueCommandMap extends CommandEnd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(args.length > 3 && args[3].equals("true"))
|
if(args.length > 3 && args[3].equals("true"))
|
||||||
sender.sendMessage(Debug.cmdPrefix + "Stat Value (" + ChatColor.BLUE + stat.name() + ChatColor.WHITE + "): " + ChatColor.GREEN + stat.format(data.getStats().getStat(stat)) + ChatColor.WHITE + " *");
|
sender.sendMessage(DebugCommandMap.commandPrefix + "Stat Value (" + ChatColor.BLUE + stat.name() + ChatColor.WHITE + "): " + ChatColor.GREEN + stat.format(data.getStats().getStat(stat)) + ChatColor.WHITE + " *");
|
||||||
else sender.sendMessage(Debug.cmdPrefix + "Stat Value (" + ChatColor.BLUE + stat.name() + ChatColor.WHITE + "): " + ChatColor.GREEN + data.getStats().getStat(stat));
|
else sender.sendMessage(DebugCommandMap.commandPrefix + "Stat Value (" + ChatColor.BLUE + stat.name() + ChatColor.WHITE + "): " + ChatColor.GREEN + data.getStats().getStat(stat));
|
||||||
|
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
|
|||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.AltChar;
|
import net.Indyuce.mmocore.api.AltChar;
|
||||||
|
import net.Indyuce.mmocore.api.experience.Profession;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerQuests;
|
import net.Indyuce.mmocore.api.player.PlayerQuests;
|
||||||
import net.Indyuce.mmocore.api.player.Professions;
|
import net.Indyuce.mmocore.api.player.Professions;
|
||||||
@ -40,7 +41,7 @@ public class RPGPlaceholders
|
|||||||
|
|
||||||
else if (identifier.equals("level_percent")) {
|
else if (identifier.equals("level_percent")) {
|
||||||
PlayerData playerData = PlayerData.get(player);
|
PlayerData playerData = PlayerData.get(player);
|
||||||
double current = playerData.getExperience(), next = MMOCore.plugin.configManager.getNeededExperience(playerData.getLevel() + 1, playerData.getProfess());
|
double current = playerData.getExperience(), next = playerData.getLevelUpExperience();
|
||||||
return MMOCore.plugin.configManager.decimal.format(current / next * 100);
|
return MMOCore.plugin.configManager.decimal.format(current / next * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,8 +56,10 @@ public class RPGPlaceholders
|
|||||||
|
|
||||||
else if (identifier.startsWith("profession_percent_")) {
|
else if (identifier.startsWith("profession_percent_")) {
|
||||||
Professions professions = PlayerData.get(player).getCollectionSkills();
|
Professions professions = PlayerData.get(player).getCollectionSkills();
|
||||||
String profession = identifier.substring(19).replace(" ", "-").replace("_", "-").toLowerCase();
|
String name = identifier.substring(19).replace(" ", "-").replace("_", "-").toLowerCase();
|
||||||
double current = professions.getExperience(profession), next = MMOCore.plugin.configManager.getNeededExperience(professions.getLevel(profession) + 1, profession);
|
Profession profession = MMOCore.plugin.professionManager.get(name);
|
||||||
|
double current = professions.getExperience(profession),
|
||||||
|
next = professions.getLevelUpExperience(profession);
|
||||||
return MMOCore.plugin.configManager.decimal.format(current / next * 100);
|
return MMOCore.plugin.configManager.decimal.format(current / next * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +73,7 @@ public class RPGPlaceholders
|
|||||||
return "" + PlayerData.get(player).getExperience();
|
return "" + PlayerData.get(player).getExperience();
|
||||||
|
|
||||||
else if (identifier.equals("next_level"))
|
else if (identifier.equals("next_level"))
|
||||||
return "" + MMOCore.plugin.configManager.getNeededExperience(PlayerData.get(player).getLevel() + 1, PlayerData.get(player).getProfess());
|
return "" +PlayerData.get(player).getLevelUpExperience();
|
||||||
|
|
||||||
else if (identifier.equals("class_points"))
|
else if (identifier.equals("class_points"))
|
||||||
return "" + PlayerData.get(player).getClassPoints();
|
return "" + PlayerData.get(player).getClassPoints();
|
||||||
@ -135,7 +138,10 @@ public class RPGPlaceholders
|
|||||||
|
|
||||||
else if (identifier.equals("quest_progress")) {
|
else if (identifier.equals("quest_progress")) {
|
||||||
PlayerQuests data = PlayerData.get(player).getQuestData();
|
PlayerQuests data = PlayerData.get(player).getQuestData();
|
||||||
return data.hasCurrent() ? MMOCore.plugin.configManager.decimal.format((int) (double) data.getCurrent().getObjectiveNumber() / data.getCurrent().getQuest().getObjectives().size() * 100) : "0";
|
return data.hasCurrent()
|
||||||
|
? MMOCore.plugin.configManager.decimal
|
||||||
|
.format((int) (double) data.getCurrent().getObjectiveNumber() / data.getCurrent().getQuest().getObjectives().size() * 100)
|
||||||
|
: "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (identifier.equals("quest_objective")) {
|
else if (identifier.equals("quest_objective")) {
|
||||||
|
@ -47,7 +47,7 @@ public class ClassConfirmation extends EditableInventory {
|
|||||||
SavedClassInformation info = inv.getPlayerData().getClassInfo(profess);
|
SavedClassInformation info = inv.getPlayerData().getClassInfo(profess);
|
||||||
Placeholders holders = new Placeholders();
|
Placeholders holders = new Placeholders();
|
||||||
|
|
||||||
int nextLevelExp = MMOCore.plugin.configManager.getNeededExperience(info.getLevel() + 1, profess);
|
int nextLevelExp = inv.getPlayerData().getLevelUpExperience();
|
||||||
double ratio = (double) info.getExperience() / (double) nextLevelExp;
|
double ratio = (double) info.getExperience() / (double) nextLevelExp;
|
||||||
|
|
||||||
String bar = "" + ChatColor.BOLD;
|
String bar = "" + ChatColor.BOLD;
|
||||||
|
@ -79,7 +79,8 @@ public class PlayerStats extends EditableInventory {
|
|||||||
Placeholders holders = new Placeholders();
|
Placeholders holders = new Placeholders();
|
||||||
net.Indyuce.mmocore.api.player.stats.PlayerStats stats = inv.getPlayerData().getStats();
|
net.Indyuce.mmocore.api.player.stats.PlayerStats stats = inv.getPlayerData().getStats();
|
||||||
|
|
||||||
double ratio = (double) inv.getPlayerData().getCollectionSkills().getExperience(profession) / MMOCore.plugin.configManager.getNeededExperience(inv.getPlayerData().getCollectionSkills().getLevel(profession) + 1, profession);
|
double ratio = (double) inv.getPlayerData().getCollectionSkills().getExperience(profession)
|
||||||
|
/ (double) inv.getPlayerData().getCollectionSkills().getLevelUpExperience(profession);
|
||||||
|
|
||||||
String bar = "" + ChatColor.BOLD;
|
String bar = "" + ChatColor.BOLD;
|
||||||
int chars = (int) (ratio * 20);
|
int chars = (int) (ratio * 20);
|
||||||
@ -277,7 +278,7 @@ public class PlayerStats extends EditableInventory {
|
|||||||
PlayerData data = inv.getPlayerData();
|
PlayerData data = inv.getPlayerData();
|
||||||
Placeholders holders = new Placeholders();
|
Placeholders holders = new Placeholders();
|
||||||
|
|
||||||
int nextLevelExp = MMOCore.plugin.configManager.getNeededExperience(data.getLevel() + 1, data.getProfess());
|
int nextLevelExp = inv.getPlayerData().getLevelUpExperience();
|
||||||
double ratio = (double) data.getExperience() / (double) nextLevelExp;
|
double ratio = (double) data.getExperience() / (double) nextLevelExp;
|
||||||
|
|
||||||
String bar = "" + ChatColor.BOLD;
|
String bar = "" + ChatColor.BOLD;
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
package net.Indyuce.mmocore.manager;
|
package net.Indyuce.mmocore.manager;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.DecimalFormatSymbols;
|
import java.text.DecimalFormatSymbols;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -20,9 +15,7 @@ import org.bukkit.util.Consumer;
|
|||||||
|
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.ConfigFile;
|
import net.Indyuce.mmocore.api.ConfigFile;
|
||||||
import net.Indyuce.mmocore.api.experience.Profession;
|
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
|
||||||
import net.Indyuce.mmocore.api.util.input.AnvilGUI;
|
import net.Indyuce.mmocore.api.util.input.AnvilGUI;
|
||||||
import net.Indyuce.mmocore.api.util.input.ChatInput;
|
import net.Indyuce.mmocore.api.util.input.ChatInput;
|
||||||
import net.Indyuce.mmocore.api.util.input.PlayerInput;
|
import net.Indyuce.mmocore.api.util.input.PlayerInput;
|
||||||
@ -39,7 +32,6 @@ public class ConfigManager {
|
|||||||
public final DecimalFormatSymbols formatSymbols = new DecimalFormatSymbols();
|
public final DecimalFormatSymbols formatSymbols = new DecimalFormatSymbols();
|
||||||
public final DecimalFormat decimal = new DecimalFormat("0.#", formatSymbols), decimals = new DecimalFormat("0.##", formatSymbols);
|
public final DecimalFormat decimal = new DecimalFormat("0.#", formatSymbols), decimals = new DecimalFormat("0.##", formatSymbols);
|
||||||
|
|
||||||
private Map<String, List<Integer>> neededExp = new HashMap<String, List<Integer>>();
|
|
||||||
private FileConfiguration messages;
|
private FileConfiguration messages;
|
||||||
private boolean chatInput;
|
private boolean chatInput;
|
||||||
|
|
||||||
@ -115,32 +107,12 @@ public class ConfigManager {
|
|||||||
staminaFull = getColorOrDefault("stamina-whole", ChatColor.GREEN);
|
staminaFull = getColorOrDefault("stamina-whole", ChatColor.GREEN);
|
||||||
staminaHalf = getColorOrDefault("stamina-half", ChatColor.DARK_GREEN);
|
staminaHalf = getColorOrDefault("stamina-half", ChatColor.DARK_GREEN);
|
||||||
staminaEmpty = getColorOrDefault("stamina-empty", ChatColor.WHITE);
|
staminaEmpty = getColorOrDefault("stamina-empty", ChatColor.WHITE);
|
||||||
|
|
||||||
neededExp.clear();
|
|
||||||
for(File txt : new File(MMOCore.plugin.getDataFolder() + "/expcurves").listFiles()) {
|
|
||||||
int line = 0;
|
|
||||||
try {
|
|
||||||
line++;
|
|
||||||
//File txt = new File(MMOCore.plugin.getDataFolder(), "levels.txt");
|
|
||||||
BufferedReader reader = new BufferedReader(new FileReader(txt));
|
|
||||||
String readLine;
|
|
||||||
List<Integer> levels = new ArrayList<>();
|
|
||||||
while ((readLine = reader.readLine()) != null)
|
|
||||||
levels.add(Integer.valueOf(readLine));
|
|
||||||
neededExp.put(txt.getName().toLowerCase().replace(".txt", ""), levels);
|
|
||||||
reader.close();
|
|
||||||
} catch (IOException | IllegalArgumentException e) {
|
|
||||||
MMOCore.plugin.getLogger().log(Level.SEVERE, "Could not read line " + line + " from " + txt.getName());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChatColor getColorOrDefault(String key, ChatColor defaultColor) {
|
private ChatColor getColorOrDefault(String key, ChatColor defaultColor) {
|
||||||
try {
|
try {
|
||||||
return ChatColor.valueOf(MMOCore.plugin.getConfig().getString("resource-bar-colors." + key).toUpperCase());
|
return ChatColor.valueOf(MMOCore.plugin.getConfig().getString("resource-bar-colors." + key).toUpperCase());
|
||||||
}
|
} catch (IllegalArgumentException exception) {
|
||||||
catch(IllegalArgumentException exception) {
|
|
||||||
MMOCore.log(Level.WARNING, "Could not read resource bar color from '" + key + "': using default.");
|
MMOCore.log(Level.WARNING, "Could not read resource bar color from '" + key + "': using default.");
|
||||||
return defaultColor;
|
return defaultColor;
|
||||||
}
|
}
|
||||||
@ -176,24 +148,6 @@ public class ConfigManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNeededExperience(int level, PlayerClass clas) {
|
|
||||||
if(clas == null) return getNeededExperience(level, MMOCore.plugin.classManager.getDefaultClass().getEXPCurve());
|
|
||||||
return getNeededExperience(level, clas.getEXPCurve());
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNeededExperience(int level, Profession prof) {
|
|
||||||
return getNeededExperience(level, prof.getEXPCurve());
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNeededExperience(int level, String curve) {
|
|
||||||
List<Integer> expCurve = neededExp.get(curve);
|
|
||||||
if(expCurve == null) {
|
|
||||||
MMOCore.log(Level.SEVERE, "Couldn't load EXPCurve: '" + curve + "'. Does it exist?");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return expCurve.get(level - 1 >= expCurve.size() ? expCurve.size() - 1 : level - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getMessage(String key) {
|
public List<String> getMessage(String key) {
|
||||||
return messages.getStringList(key);
|
return messages.getStringList(key);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
package net.Indyuce.mmocore.manager;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
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.mmoitems.MMOItems;
|
||||||
|
|
||||||
|
public class ExperienceManager {
|
||||||
|
private final Map<String, ExpCurve> expCurves = new HashMap<>();
|
||||||
|
|
||||||
|
public boolean hasCurve(String id) {
|
||||||
|
return expCurves.containsKey(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExpCurve getOrThrow(String id) {
|
||||||
|
Validate.isTrue(hasCurve(id), "Could not find exp curve with ID '" + id + "'");
|
||||||
|
return expCurves.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExpCurve getCurve(String id) {
|
||||||
|
return expCurves.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<ExpCurve> getCurves() {
|
||||||
|
return expCurves.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reload() {
|
||||||
|
expCurves.clear();
|
||||||
|
for (File file : new File(MMOCore.plugin.getDataFolder() + "/expcurves").listFiles())
|
||||||
|
try {
|
||||||
|
ExpCurve curve = new ExpCurve(file);
|
||||||
|
expCurves.put(curve.getId(), curve);
|
||||||
|
} catch (IllegalArgumentException | IOException exception) {
|
||||||
|
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not load exp curve '" + file.getName() + "': " + exception.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -34,26 +34,28 @@ public abstract class GuildDataManager {
|
|||||||
|
|
||||||
public void unregisterGuild(Guild guild) {
|
public void unregisterGuild(Guild guild) {
|
||||||
guild.getMembers().forEach(member -> guild.removeMember(member, true));
|
guild.getMembers().forEach(member -> guild.removeMember(member, true));
|
||||||
guild.getMembers().clear();
|
// guild.getMembers().clear();
|
||||||
guilds.remove(guild.getId());
|
guilds.remove(guild.getId());
|
||||||
delete(guild);
|
delete(guild);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Guild stillInGuild(UUID uuid, String id) {
|
public Guild stillInGuild(UUID uuid, String id) {
|
||||||
Guild guild = getGuild(id);
|
Guild guild = getGuild(id);
|
||||||
if(guild != null && guild.getMembers().has(uuid))
|
if (guild != null && guild.getMembers().has(uuid))
|
||||||
return guild;
|
return guild;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Guild getGuild(String guild)
|
public Guild getGuild(String guild) {
|
||||||
{ return guilds.get(guild); }
|
return guilds.get(guild);
|
||||||
|
}
|
||||||
|
|
||||||
public Collection<Guild> getAll()
|
public Collection<Guild> getAll() {
|
||||||
{ return guilds.values(); }
|
return guilds.values();
|
||||||
|
}
|
||||||
|
|
||||||
public void reload() {
|
public void reload() {
|
||||||
for(Guild guild : guilds.values())
|
for (Guild guild : guilds.values())
|
||||||
save(guild);
|
save(guild);
|
||||||
guilds.clear();
|
guilds.clear();
|
||||||
load();
|
load();
|
||||||
@ -61,16 +63,20 @@ public abstract class GuildDataManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public abstract void save(Guild guild);
|
public abstract void save(Guild guild);
|
||||||
|
|
||||||
public abstract void load();
|
public abstract void load();
|
||||||
|
|
||||||
public abstract void delete(Guild guild);
|
public abstract void delete(Guild guild);
|
||||||
|
|
||||||
//Shitty code for loading config values for guilds.
|
// Shitty code for loading config values for guilds.
|
||||||
private GuildConfiguration config;
|
private GuildConfiguration config;
|
||||||
|
|
||||||
public GuildConfiguration getConfig() {
|
public GuildConfiguration getConfig() {
|
||||||
if(config == null)
|
if (config == null)
|
||||||
config = new GuildConfiguration();
|
config = new GuildConfiguration();
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GuildConfiguration {
|
public class GuildConfiguration {
|
||||||
private final String prefix;
|
private final String prefix;
|
||||||
private final boolean uppercaseTags;
|
private final boolean uppercaseTags;
|
||||||
@ -85,14 +91,21 @@ public abstract class GuildDataManager {
|
|||||||
this.nameRules = new NamingRules(config.getConfigurationSection("rules.name"));
|
this.nameRules = new NamingRules(config.getConfigurationSection("rules.name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPrefix()
|
public String getPrefix() {
|
||||||
{ return prefix; }
|
return prefix;
|
||||||
public boolean shouldUppercaseTags()
|
}
|
||||||
{ return uppercaseTags; }
|
|
||||||
public NamingRules getTagRules()
|
public boolean shouldUppercaseTags() {
|
||||||
{ return tagRules; }
|
return uppercaseTags;
|
||||||
public NamingRules getNameRules()
|
}
|
||||||
{ return nameRules; }
|
|
||||||
|
public NamingRules getTagRules() {
|
||||||
|
return tagRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamingRules getNameRules() {
|
||||||
|
return nameRules;
|
||||||
|
}
|
||||||
|
|
||||||
public class NamingRules {
|
public class NamingRules {
|
||||||
private final String regex;
|
private final String regex;
|
||||||
@ -104,12 +117,17 @@ public abstract class GuildDataManager {
|
|||||||
max = config.getInt("max-length", 5);
|
max = config.getInt("max-length", 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRegex()
|
public String getRegex() {
|
||||||
{ return regex; }
|
return regex;
|
||||||
public int getMin()
|
}
|
||||||
{ return min; }
|
|
||||||
public int getMax()
|
public int getMin() {
|
||||||
{ return max; }
|
return min;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMax() {
|
||||||
|
return max;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user