mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-27 00:45:40 +01:00
!More minor API changes
This commit is contained in:
parent
168d4a46b5
commit
0926641839
@ -1,9 +1,10 @@
|
||||
package net.Indyuce.mmocore.api.experience;
|
||||
|
||||
public enum EXPSource {
|
||||
SOURCE,
|
||||
COMMAND,
|
||||
VANILLA,
|
||||
QUEST,
|
||||
SOURCE,
|
||||
FISHING,
|
||||
OTHER;
|
||||
}
|
||||
|
@ -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,28 +103,34 @@ 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);
|
||||
|
||||
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);
|
||||
|
||||
// display hologram
|
||||
|
@ -47,7 +47,7 @@ public abstract class ExperienceSource<T> {
|
||||
|
||||
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, EXPSource.SOURCE);
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class ExperienceTrigger extends Trigger {
|
||||
if (profession == null)
|
||||
player.giveExperience(amount.calculateInt(), EXPSource.QUEST);
|
||||
else
|
||||
player.getCollectionSkills().giveExperience(profession, amount.calculateInt());
|
||||
player.getCollectionSkills().giveExperience(profession, amount.calculateInt(), EXPSource.QUEST);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -21,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(), EXPSource.COMMAND), (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 {
|
||||
|
@ -21,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, EXPSource.COMMAND), (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 {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user