mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-24 00:15:16 +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;
|
package net.Indyuce.mmocore.api.experience;
|
||||||
|
|
||||||
public enum EXPSource {
|
public enum EXPSource {
|
||||||
|
SOURCE,
|
||||||
COMMAND,
|
COMMAND,
|
||||||
VANILLA,
|
VANILLA,
|
||||||
QUEST,
|
QUEST,
|
||||||
SOURCE,
|
FISHING,
|
||||||
OTHER;
|
OTHER;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import com.google.gson.JsonObject;
|
|||||||
|
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.ConfigMessage;
|
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.event.PlayerLevelUpEvent;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.util.math.particle.SmallParticleEffect;
|
import net.Indyuce.mmocore.api.util.math.particle.SmallParticleEffect;
|
||||||
@ -102,28 +103,34 @@ public class PlayerProfessions {
|
|||||||
exp.put(profession.getId(), value);
|
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);
|
int total = 0, level = getLevel(profession);
|
||||||
while (value-- > 0)
|
while (value-- > 0)
|
||||||
total += profession.getExpCurve().getExperience(level + value + 1);
|
total += profession.getExpCurve().getExperience(level + value + 1);
|
||||||
giveExperience(profession, total);
|
giveExperience(profession, total, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void giveExperience(Profession profession, int value) {
|
public void giveExperience(Profession profession, int value, EXPSource source) {
|
||||||
giveExperience(profession, value, null);
|
giveExperience(profession, value, null, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasReachedMaxLevel(Profession profession) {
|
public boolean hasReachedMaxLevel(Profession profession) {
|
||||||
return profession.hasMaxLevel() && getLevel(profession) >= profession.getMaxLevel();
|
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)) {
|
if(hasReachedMaxLevel(profession)) {
|
||||||
setExperience(profession, 0);
|
setExperience(profession, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = MMOCore.plugin.boosterManager.calculateExp(profession, value);
|
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);
|
exp.put(profession.getId(), exp.containsKey(profession.getId()) ? exp.get(profession.getId()) + value : value);
|
||||||
|
|
||||||
// display hologram
|
// display hologram
|
||||||
|
@ -47,7 +47,7 @@ public abstract class ExperienceSource<T> {
|
|||||||
|
|
||||||
public void giveExperience(PlayerData player, int amount, Location location) {
|
public void giveExperience(PlayerData player, int amount, Location location) {
|
||||||
if (hasProfession())
|
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
|
else
|
||||||
player.giveExperience(amount, location == null ? player.getPlayer().getLocation() : location, EXPSource.SOURCE);
|
player.giveExperience(amount, location == null ? player.getPlayer().getLocation() : location, EXPSource.SOURCE);
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,10 @@ public class Party {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void removeMember(PlayerData data) {
|
public void removeMember(PlayerData data) {
|
||||||
|
removeMember(data, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeMember(PlayerData data, boolean notify) {
|
||||||
if (data.isOnline() && data.getPlayer().getOpenInventory() != null
|
if (data.isOnline() && data.getPlayer().getOpenInventory() != null
|
||||||
&& data.getPlayer().getOpenInventory().getTopInventory().getHolder() instanceof PartyViewInventory)
|
&& data.getPlayer().getOpenInventory().getTopInventory().getHolder() instanceof PartyViewInventory)
|
||||||
InventoryManager.PARTY_CREATION.newInventory(data).open();
|
InventoryManager.PARTY_CREATION.newInventory(data).open();
|
||||||
@ -72,7 +76,7 @@ public class Party {
|
|||||||
// transfer ownership
|
// transfer ownership
|
||||||
if (owner.equals(data)) {
|
if (owner.equals(data)) {
|
||||||
owner = members.get(0);
|
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)
|
if (profession == null)
|
||||||
player.giveExperience(amount.calculateInt(), EXPSource.QUEST);
|
player.giveExperience(amount.calculateInt(), EXPSource.QUEST);
|
||||||
else
|
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");
|
super(parent, "exp");
|
||||||
|
|
||||||
addFloor(new ActionCommandMap(this, "set", (data, value) -> data.setExperience(value), (professions, profession, value) -> professions.setExperience(profession, value)));
|
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 {
|
public class ActionCommandMap extends CommandEnd {
|
||||||
|
@ -21,7 +21,7 @@ public class LevelCommandMap extends CommandMap {
|
|||||||
super(parent, "level");
|
super(parent, "level");
|
||||||
|
|
||||||
addFloor(new ActionCommandMap(this, "set", (data, value) -> data.setLevel(value), (professions, profession, value) -> professions.setLevel(profession, value)));
|
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 {
|
public class ActionCommandMap extends CommandEnd {
|
||||||
|
@ -24,6 +24,7 @@ import org.bukkit.util.Vector;
|
|||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.droptable.dropitem.fishing.FishingDropItem;
|
import net.Indyuce.mmocore.api.droptable.dropitem.fishing.FishingDropItem;
|
||||||
import net.Indyuce.mmocore.api.event.CustomPlayerFishEvent;
|
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.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.player.stats.StatType;
|
import net.Indyuce.mmocore.api.player.stats.StatType;
|
||||||
import net.Indyuce.mmocore.manager.profession.FishingManager.FishingDropTable;
|
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);
|
location.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, location, 0, 4 * (random.nextDouble() - .5), 2, 4 * (random.nextDouble() - .5), .05);
|
||||||
|
|
||||||
if (MMOCore.plugin.professionManager.has("fishing"))
|
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