forked from Upstream/mmocore
Added new options to disable profession exp holos
This commit is contained in:
parent
4472198da3
commit
568d6da795
@ -1,5 +1,7 @@
|
|||||||
package net.Indyuce.mmocore.api.event;
|
package net.Indyuce.mmocore.api.event;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
@ -21,7 +23,7 @@ public class PlayerExperienceGainEvent extends PlayerDataEvent implements Cancel
|
|||||||
this(player, null, experience, source);
|
this(player, null, experience, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerExperienceGainEvent(PlayerData player, Profession profession, int experience, EXPSource source) {
|
public PlayerExperienceGainEvent(PlayerData player, @Nullable Profession profession, int experience, EXPSource source) {
|
||||||
super(player);
|
super(player);
|
||||||
|
|
||||||
this.profession = profession;
|
this.profession = profession;
|
||||||
|
@ -4,8 +4,8 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.manager.SoundManager;
|
import javax.annotation.Nullable;
|
||||||
import net.mmogroup.mmolib.MMOLib;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -22,6 +22,8 @@ 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;
|
||||||
|
import net.Indyuce.mmocore.manager.SoundManager;
|
||||||
|
import net.mmogroup.mmolib.MMOLib;
|
||||||
|
|
||||||
public class PlayerProfessions {
|
public class PlayerProfessions {
|
||||||
private final Map<String, Integer> exp = new HashMap<>();
|
private final Map<String, Integer> exp = new HashMap<>();
|
||||||
@ -121,14 +123,14 @@ public class PlayerProfessions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void giveExperience(Profession profession, int value, EXPSource source) {
|
public void giveExperience(Profession profession, int value, EXPSource source) {
|
||||||
giveExperience(profession, value, null, source);
|
giveExperience(profession, value, source, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
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, EXPSource source) {
|
public void giveExperience(Profession profession, int value, EXPSource source, @Nullable Location hologramLocation) {
|
||||||
if (hasReachedMaxLevel(profession)) {
|
if (hasReachedMaxLevel(profession)) {
|
||||||
setExperience(profession, 0);
|
setExperience(profession, 0);
|
||||||
return;
|
return;
|
||||||
@ -137,9 +139,8 @@ public class PlayerProfessions {
|
|||||||
value = MMOCore.plugin.boosterManager.calculateExp(profession, value);
|
value = MMOCore.plugin.boosterManager.calculateExp(profession, value);
|
||||||
|
|
||||||
// display hologram
|
// display hologram
|
||||||
if (MMOCore.plugin.getConfig().getBoolean("display-exp-holograms") && playerData.isOnline())
|
if (hologramLocation != null && playerData.isOnline() && MMOCore.plugin.hasHolograms())
|
||||||
if (loc != null && MMOCore.plugin.hasHolograms())
|
MMOCore.plugin.hologramSupport.displayIndicator(hologramLocation.add(.5, 1.5, .5),
|
||||||
MMOCore.plugin.hologramSupport.displayIndicator(loc.add(.5, 1.5, .5),
|
|
||||||
MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + value).message(), playerData.getPlayer());
|
MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + value).message(), playerData.getPlayer());
|
||||||
|
|
||||||
PlayerExperienceGainEvent event = new PlayerExperienceGainEvent(playerData, profession, value, source);
|
PlayerExperienceGainEvent event = new PlayerExperienceGainEvent(playerData, profession, value, source);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package net.Indyuce.mmocore.api.experience;
|
package net.Indyuce.mmocore.api.experience;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
@ -19,6 +21,7 @@ public class Profession extends PostLoadObject {
|
|||||||
private final String id, name;
|
private final String id, name;
|
||||||
private final ExpCurve expCurve;
|
private final ExpCurve expCurve;
|
||||||
private final int maxLevel;
|
private final int maxLevel;
|
||||||
|
private final Map<ProfessionOption, Boolean> options = new HashMap<>();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* experience given to the main player level whenever he levels up this
|
* experience given to the main player level whenever he levels up this
|
||||||
@ -34,21 +37,29 @@ public class Profession extends PostLoadObject {
|
|||||||
Validate.notNull(name, "Could not load name");
|
Validate.notNull(name, "Could not load name");
|
||||||
|
|
||||||
expCurve = config.contains("exp-curve")
|
expCurve = config.contains("exp-curve")
|
||||||
? MMOCore.plugin.experience.getOrThrow(
|
? MMOCore.plugin.experience.getOrThrow(config.get("exp-curve").toString().toLowerCase().replace("_", "-").replace(" ", "-"))
|
||||||
config.get("exp-curve").toString().toLowerCase().replace("_", "-").replace(" ", "-"))
|
|
||||||
: ExpCurve.DEFAULT;
|
: ExpCurve.DEFAULT;
|
||||||
experience = new LinearValue(config.getConfigurationSection("experience"));
|
experience = new LinearValue(config.getConfigurationSection("experience"));
|
||||||
|
|
||||||
|
if (config.contains("options"))
|
||||||
|
for (String key : config.getConfigurationSection("options").getKeys(false))
|
||||||
|
try {
|
||||||
|
ProfessionOption option = ProfessionOption.valueOf(key.toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||||
|
options.put(option, config.getBoolean("options." + key));
|
||||||
|
} catch (IllegalArgumentException exception) {
|
||||||
|
MMOCore.plugin.getLogger().log(Level.WARNING,
|
||||||
|
"Could not load option '" + key + "' from profession '" + id + "': " + exception.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
maxLevel = config.getInt("max-level");
|
maxLevel = config.getInt("max-level");
|
||||||
|
|
||||||
if (config.contains("exp-sources"))
|
if (config.contains("exp-sources"))
|
||||||
for (String key : config.getStringList("exp-sources"))
|
for (String key : config.getStringList("exp-sources"))
|
||||||
try {
|
try {
|
||||||
MMOCore.plugin.professionManager.registerExpSource(
|
MMOCore.plugin.professionManager.registerExpSource(MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key), this));
|
||||||
MMOCore.plugin.loadManager.loadExperienceSource(new MMOLineConfig(key), this));
|
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not register exp source '" + key
|
MMOCore.plugin.getLogger().log(Level.WARNING,
|
||||||
+ "' from profession '" + id + "': " + exception.getMessage());
|
"Could not register exp source '" + key + "' from profession '" + id + "': " + exception.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,16 +78,14 @@ public class Profession extends PostLoadObject {
|
|||||||
if (config.contains("alchemy-experience")) {
|
if (config.contains("alchemy-experience")) {
|
||||||
|
|
||||||
MMOCore.plugin.alchemyManager.splash = 1 + config.getDouble("alchemy-experience.special.splash") / 100;
|
MMOCore.plugin.alchemyManager.splash = 1 + config.getDouble("alchemy-experience.special.splash") / 100;
|
||||||
MMOCore.plugin.alchemyManager.lingering = 1
|
MMOCore.plugin.alchemyManager.lingering = 1 + config.getDouble("alchemy-experience.special.lingering") / 100;
|
||||||
+ config.getDouble("alchemy-experience.special.lingering") / 100;
|
|
||||||
MMOCore.plugin.alchemyManager.extend = 1 + config.getDouble("alchemy-experience.special.extend") / 100;
|
MMOCore.plugin.alchemyManager.extend = 1 + config.getDouble("alchemy-experience.special.extend") / 100;
|
||||||
MMOCore.plugin.alchemyManager.upgrade = 1 + config.getDouble("alchemy-experience.special.upgrade") / 100;
|
MMOCore.plugin.alchemyManager.upgrade = 1 + config.getDouble("alchemy-experience.special.upgrade") / 100;
|
||||||
|
|
||||||
for (String key : config.getConfigurationSection("alchemy-experience.effects").getKeys(false))
|
for (String key : config.getConfigurationSection("alchemy-experience.effects").getKeys(false))
|
||||||
try {
|
try {
|
||||||
PotionType type = PotionType.valueOf(key.toUpperCase().replace("-", "_").replace(" ", "_"));
|
PotionType type = PotionType.valueOf(key.toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||||
MMOCore.plugin.alchemyManager.registerBaseExperience(type,
|
MMOCore.plugin.alchemyManager.registerBaseExperience(type, config.getDouble("alchemy-experience.effects." + key));
|
||||||
config.getDouble("alchemy-experience.effects." + key));
|
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
MMOCore.log(Level.WARNING, "[PlayerProfessions:" + id + "] Could not read potion type from " + key);
|
MMOCore.log(Level.WARNING, "[PlayerProfessions:" + id + "] Could not read potion type from " + key);
|
||||||
}
|
}
|
||||||
@ -85,10 +94,8 @@ public class Profession extends PostLoadObject {
|
|||||||
if (config.contains("base-enchant-exp"))
|
if (config.contains("base-enchant-exp"))
|
||||||
for (String key : config.getConfigurationSection("base-enchant-exp").getKeys(false))
|
for (String key : config.getConfigurationSection("base-enchant-exp").getKeys(false))
|
||||||
try {
|
try {
|
||||||
Enchantment enchant = MMOLib.plugin.getVersion().getWrapper()
|
Enchantment enchant = MMOLib.plugin.getVersion().getWrapper().getEnchantmentFromString(key.toLowerCase().replace("-", "_"));
|
||||||
.getEnchantmentFromString(key.toLowerCase().replace("-", "_"));
|
MMOCore.plugin.enchantManager.registerBaseExperience(enchant, config.getDouble("base-enchant-exp." + key));
|
||||||
MMOCore.plugin.enchantManager.registerBaseExperience(enchant,
|
|
||||||
config.getDouble("base-enchant-exp." + key));
|
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
MMOCore.log(Level.WARNING, "[PlayerProfessions:" + id + "] Could not read enchant from " + key);
|
MMOCore.log(Level.WARNING, "[PlayerProfessions:" + id + "] Could not read enchant from " + key);
|
||||||
}
|
}
|
||||||
@ -97,8 +104,7 @@ public class Profession extends PostLoadObject {
|
|||||||
for (String key : config.getConfigurationSection("repair-exp").getKeys(false))
|
for (String key : config.getConfigurationSection("repair-exp").getKeys(false))
|
||||||
try {
|
try {
|
||||||
Material material = Material.valueOf(key.toUpperCase().replace("-", "_").replace(" ", "_"));
|
Material material = Material.valueOf(key.toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||||
MMOCore.plugin.smithingManager.registerBaseExperience(material,
|
MMOCore.plugin.smithingManager.registerBaseExperience(material, config.getDouble("repair-exp." + key));
|
||||||
config.getDouble("repair-exp." + key));
|
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
MMOCore.log(Level.WARNING, "[PlayerProfessions:" + id + "] Could not read material from " + key);
|
MMOCore.log(Level.WARNING, "[PlayerProfessions:" + id + "] Could not read material from " + key);
|
||||||
}
|
}
|
||||||
@ -116,6 +122,10 @@ public class Profession extends PostLoadObject {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getOption(ProfessionOption option) {
|
||||||
|
return options.getOrDefault(option, option.getDefault());
|
||||||
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -143,4 +153,22 @@ public class Profession extends PostLoadObject {
|
|||||||
public LinearValue getExperience() {
|
public LinearValue getExperience() {
|
||||||
return experience;
|
return experience;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static enum ProfessionOption {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When disabled, removes exp holograms when mined
|
||||||
|
*/
|
||||||
|
EXP_HOLOGRAMS(true);
|
||||||
|
|
||||||
|
private final boolean def;
|
||||||
|
|
||||||
|
private ProfessionOption(boolean def) {
|
||||||
|
this.def = def;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getDefault() {
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,22 @@
|
|||||||
package net.Indyuce.mmocore.api.experience.source.type;
|
package net.Indyuce.mmocore.api.experience.source.type;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.experience.EXPSource;
|
import net.Indyuce.mmocore.api.experience.EXPSource;
|
||||||
import net.Indyuce.mmocore.api.experience.Profession;
|
import net.Indyuce.mmocore.api.experience.Profession;
|
||||||
|
import net.Indyuce.mmocore.api.experience.Profession.ProfessionOption;
|
||||||
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.player.profess.PlayerClass;
|
||||||
import net.Indyuce.mmocore.manager.profession.ExperienceManager;
|
import net.Indyuce.mmocore.manager.profession.ExperienceManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Atrocious API that really needs rewriting
|
||||||
|
*
|
||||||
|
* @author cympe
|
||||||
|
*/
|
||||||
public abstract class ExperienceSource<T> {
|
public abstract class ExperienceSource<T> {
|
||||||
private final Profession profession;
|
private final Profession profession;
|
||||||
private PlayerClass profess;
|
private PlayerClass profess;
|
||||||
@ -46,11 +55,24 @@ public abstract class ExperienceSource<T> {
|
|||||||
|
|
||||||
public abstract boolean matches(PlayerData player, T obj);
|
public abstract boolean matches(PlayerData player, T obj);
|
||||||
|
|
||||||
public void giveExperience(PlayerData player, int amount, Location location) {
|
/**
|
||||||
if (hasProfession())
|
* Gives experience to the right profession/class
|
||||||
player.getCollectionSkills().giveExperience(profession, amount, location == null ? getPlayerLocation(player) : location, EXPSource.SOURCE);
|
*
|
||||||
else
|
* @param player Player to give exp to
|
||||||
player.giveExperience(amount, location == null ? getPlayerLocation(player) : location, EXPSource.SOURCE);
|
* @param amount Amount of experience given
|
||||||
|
* @param hologramLocation If location is null the default location will be
|
||||||
|
* the player's torso
|
||||||
|
*/
|
||||||
|
public void giveExperience(PlayerData player, int amount, @Nullable Location hologramLocation) {
|
||||||
|
if (hasProfession()) {
|
||||||
|
hologramLocation = !profession.getOption(ProfessionOption.EXP_HOLOGRAMS) ? null
|
||||||
|
: hologramLocation == null ? getPlayerLocation(player) : hologramLocation;
|
||||||
|
player.getCollectionSkills().giveExperience(profession, amount, EXPSource.SOURCE, hologramLocation);
|
||||||
|
} else {
|
||||||
|
hologramLocation = !MMOCore.plugin.getConfig().getBoolean("display-main-class-exp-holograms") ? null
|
||||||
|
: hologramLocation == null ? getPlayerLocation(player) : hologramLocation;
|
||||||
|
player.giveExperience(amount, EXPSource.SOURCE, hologramLocation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Location getPlayerLocation(PlayerData player) {
|
private Location getPlayerLocation(PlayerData player) {
|
||||||
|
@ -10,6 +10,8 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -453,19 +455,28 @@ public class PlayerData extends OfflinePlayerData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void giveExperience(int value, EXPSource source) {
|
public void giveExperience(int value, EXPSource source) {
|
||||||
giveExperience(value, null, source);
|
giveExperience(value, source, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void giveExperience(int value, Location loc, EXPSource source) {
|
/**
|
||||||
|
* Called when giving experience to a player
|
||||||
|
*
|
||||||
|
* @param value Experience to give the player
|
||||||
|
* @param source How the player earned experience
|
||||||
|
* @param loc Location used to display the hologram. If it's null, no
|
||||||
|
* hologram will be displayed
|
||||||
|
*/
|
||||||
|
public void giveExperience(int value, EXPSource source, @Nullable Location hologramLocation) {
|
||||||
if (hasReachedMaxLevel()) {
|
if (hasReachedMaxLevel()) {
|
||||||
setExperience(0);
|
setExperience(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// display hologram
|
/*
|
||||||
if (MMOCore.plugin.getConfig().getBoolean("display-exp-holograms") && isOnline())
|
* Handle experience hologram
|
||||||
if (loc != null && MMOCore.plugin.hasHolograms())
|
*/
|
||||||
MMOCore.plugin.hologramSupport.displayIndicator(loc.add(.5, 1.5, .5),
|
if (hologramLocation != null && isOnline() && MMOCore.plugin.hasHolograms())
|
||||||
|
MMOCore.plugin.hologramSupport.displayIndicator(hologramLocation.add(.5, 1.5, .5),
|
||||||
MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + value).message(), getPlayer());
|
MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + value).message(), getPlayer());
|
||||||
|
|
||||||
value = MMOCore.plugin.boosterManager.calculateExp(null, value);
|
value = MMOCore.plugin.boosterManager.calculateExp(null, value);
|
||||||
@ -755,8 +766,8 @@ public class PlayerData extends OfflinePlayerData {
|
|||||||
return new SkillResult(this, skill, CancelReason.OTHER);
|
return new SkillResult(this, skill, CancelReason.OTHER);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* skill, mana stamina aand cooldown requirements are all calculated in the
|
* skill, mana stamina aand cooldown requirements are all calculated in
|
||||||
* SkillResult instances. this cast(SkillResult) method only applies
|
* the SkillResult instances. this cast(SkillResult) method only applies
|
||||||
* cooldown, reduces mana and/or stamina and send messages
|
* cooldown, reduces mana and/or stamina and send messages
|
||||||
*/
|
*/
|
||||||
SkillResult cast = skill.getSkill().whenCast(this, skill);
|
SkillResult cast = skill.getSkill().whenCast(this, skill);
|
||||||
|
@ -2,7 +2,6 @@ package net.Indyuce.mmocore.command.rpg.admin;
|
|||||||
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.command.CommandVerbose;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -13,6 +12,7 @@ import net.Indyuce.mmocore.api.experience.EXPSource;
|
|||||||
import net.Indyuce.mmocore.api.experience.PlayerProfessions;
|
import net.Indyuce.mmocore.api.experience.PlayerProfessions;
|
||||||
import net.Indyuce.mmocore.api.experience.Profession;
|
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.command.CommandVerbose;
|
||||||
import net.Indyuce.mmocore.command.MMOCoreCommandTreeRoot;
|
import net.Indyuce.mmocore.command.MMOCoreCommandTreeRoot;
|
||||||
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
import net.mmogroup.mmolib.command.api.CommandTreeNode;
|
||||||
import net.mmogroup.mmolib.command.api.Parameter;
|
import net.mmogroup.mmolib.command.api.Parameter;
|
||||||
@ -22,7 +22,8 @@ public class ExperienceCommandTreeNode extends CommandTreeNode {
|
|||||||
super(parent, "exp");
|
super(parent, "exp");
|
||||||
|
|
||||||
addChild(new ActionCommandTreeNode(this, "set", PlayerData::setExperience, PlayerProfessions::setExperience));
|
addChild(new ActionCommandTreeNode(this, "set", PlayerData::setExperience, PlayerProfessions::setExperience));
|
||||||
addChild(new ActionCommandTreeNode(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)));
|
addChild(new ActionCommandTreeNode(this, "give", (data, value) -> data.giveExperience(value, EXPSource.COMMAND), (professions, profession,
|
||||||
|
value) -> professions.giveExperience(profession, value, EXPSource.COMMAND, professions.getPlayerData().getPlayer().getLocation())));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ActionCommandTreeNode extends CommandTreeNode {
|
public static class ActionCommandTreeNode extends CommandTreeNode {
|
||||||
@ -63,8 +64,8 @@ public class ExperienceCommandTreeNode extends CommandTreeNode {
|
|||||||
PlayerData data = PlayerData.get(player);
|
PlayerData data = PlayerData.get(player);
|
||||||
if (args[4].equalsIgnoreCase("main")) {
|
if (args[4].equalsIgnoreCase("main")) {
|
||||||
main.accept(data, amount);
|
main.accept(data, amount);
|
||||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.EXPERIENCE, ChatColor.GOLD + player.getName()
|
CommandVerbose.verbose(sender, CommandVerbose.CommandType.EXPERIENCE, ChatColor.GOLD + player.getName() + ChatColor.YELLOW
|
||||||
+ ChatColor.YELLOW + " now has " + ChatColor.GOLD + data.getExperience() + ChatColor.YELLOW + " EXP.");
|
+ " now has " + ChatColor.GOLD + data.getExperience() + ChatColor.YELLOW + " EXP.");
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,8 +77,9 @@ public class ExperienceCommandTreeNode extends CommandTreeNode {
|
|||||||
|
|
||||||
Profession profession = MMOCore.plugin.professionManager.get(format);
|
Profession profession = MMOCore.plugin.professionManager.get(format);
|
||||||
this.profession.accept(data.getCollectionSkills(), profession, amount);
|
this.profession.accept(data.getCollectionSkills(), profession, amount);
|
||||||
CommandVerbose.verbose(sender, CommandVerbose.CommandType.EXPERIENCE, ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " now has "
|
CommandVerbose.verbose(sender, CommandVerbose.CommandType.EXPERIENCE,
|
||||||
+ ChatColor.GOLD + data.getCollectionSkills().getExperience(profession) + ChatColor.YELLOW + " EXP in " + profession.getName() + ".");
|
ChatColor.GOLD + player.getName() + ChatColor.YELLOW + " now has " + ChatColor.GOLD
|
||||||
|
+ data.getCollectionSkills().getExperience(profession) + ChatColor.YELLOW + " EXP in " + profession.getName() + ".");
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public abstract class HologramSupport {
|
public abstract class HologramSupport {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a message using a hologram
|
* Displays a message using a hologram
|
||||||
*
|
*
|
||||||
|
@ -5,7 +5,6 @@ import java.util.Random;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -31,6 +30,7 @@ import net.Indyuce.mmocore.api.experience.EXPSource;
|
|||||||
import net.Indyuce.mmocore.api.loot.LootBuilder;
|
import net.Indyuce.mmocore.api.loot.LootBuilder;
|
||||||
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.api.util.MMOCoreUtils;
|
||||||
import net.Indyuce.mmocore.manager.profession.FishingManager.FishingDropTable;
|
import net.Indyuce.mmocore.manager.profession.FishingManager.FishingDropTable;
|
||||||
import net.mmogroup.mmolib.version.VersionSound;
|
import net.mmogroup.mmolib.version.VersionSound;
|
||||||
|
|
||||||
@ -47,10 +47,9 @@ public class FishingListener implements Listener {
|
|||||||
if (event.getState() == State.BITE && !fishing.contains(player.getUniqueId()) && !player.hasMetadata("NPC")) {
|
if (event.getState() == State.BITE && !fishing.contains(player.getUniqueId()) && !player.hasMetadata("NPC")) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* checks for drop tables. if no drop table, just plain vanilla
|
* Checks for drop tables. If no drop table, just plain vanilla
|
||||||
* fishing OTHERWISE initialize fishing, register other listener.
|
* fishing OTHERWISE initialize fishing, register other listener.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
FishingDropTable table = MMOCore.plugin.fishingManager.calculateDropTable(player);
|
FishingDropTable table = MMOCore.plugin.fishingManager.calculateDropTable(player);
|
||||||
if (table == null)
|
if (table == null)
|
||||||
return;
|
return;
|
||||||
@ -127,7 +126,7 @@ public class FishingListener implements Listener {
|
|||||||
&& (event.getState() == State.CAUGHT_FISH || event.getState() == State.FAILED_ATTEMPT || event.getState() == State.REEL_IN)) {
|
&& (event.getState() == State.CAUGHT_FISH || event.getState() == State.FAILED_ATTEMPT || event.getState() == State.REEL_IN)) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* lose the catch if the current fish is gone!
|
* Lose the catch if the current fish is gone!
|
||||||
*/
|
*/
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if (isTimedOut()) {
|
if (isTimedOut()) {
|
||||||
@ -140,19 +139,20 @@ public class FishingListener implements Listener {
|
|||||||
criticalFish();
|
criticalFish();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* checks for enough pulls. if not, return and wait for next
|
* Checks for enough pulls. if not, return and wait for next
|
||||||
* fish event.
|
* fish event.
|
||||||
*/
|
*/
|
||||||
if (!pull())
|
if (!pull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* successfully pulls the fish
|
* Successfully pulls the fish
|
||||||
*/
|
*/
|
||||||
close();
|
close();
|
||||||
|
|
||||||
ItemStack mainhand = player.getInventory().getItem(EquipmentSlot.HAND);
|
ItemStack mainhand = player.getInventory().getItem(EquipmentSlot.HAND);
|
||||||
MMOCoreUtils.decreaseDurability(player, (mainhand != null && mainhand.getType() == Material.FISHING_ROD) ? EquipmentSlot.HAND : EquipmentSlot.OFF_HAND, 1);
|
MMOCoreUtils.decreaseDurability(player,
|
||||||
|
(mainhand != null && mainhand.getType() == Material.FISHING_ROD) ? EquipmentSlot.HAND : EquipmentSlot.OFF_HAND, 1);
|
||||||
|
|
||||||
if (!isCrit() && random.nextDouble() < PlayerData.get(player).getStats().getStat(StatType.CRITICAL_FISHING_FAILURE_CHANCE) / 100) {
|
if (!isCrit() && random.nextDouble() < PlayerData.get(player).getStats().getStat(StatType.CRITICAL_FISHING_FAILURE_CHANCE) / 100) {
|
||||||
player.setVelocity(hook.getLocation().subtract(player.getLocation()).toVector().setY(0).multiply(3).setY(.5));
|
player.setVelocity(hook.getLocation().subtract(player.getLocation()).toVector().setY(0).multiply(3).setY(.5));
|
||||||
@ -187,8 +187,8 @@ public class FishingListener implements Listener {
|
|||||||
4 * (random.nextDouble() - .5), .05);
|
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, EXPSource.FISHING,
|
||||||
EXPSource.FISHING);
|
location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
# a Spigot Plugin by Team Requiem
|
# a Spigot Plugin by Team Requiem
|
||||||
|
|
||||||
# DO NOT TOUCH
|
# DO NOT TOUCH
|
||||||
config-version: 5
|
config-version: 6
|
||||||
|
|
||||||
# Auto-Save feature automatically saves playerdata
|
# Auto-Save feature automatically saves playerdata
|
||||||
# (class, level, etc.) and guild data
|
# (class, level, etc.) and guild data
|
||||||
@ -113,6 +113,10 @@ vanilla-exp-redirection:
|
|||||||
# Requires a SERVER reload when changed.
|
# Requires a SERVER reload when changed.
|
||||||
override-vanilla-exp: true
|
override-vanilla-exp: true
|
||||||
|
|
||||||
|
# If main class experience holograms should be displayed
|
||||||
|
# whenever a player earns main class exp
|
||||||
|
display-main-class-exp-holograms: true
|
||||||
|
|
||||||
# Requires a SERVER reload when changed.
|
# Requires a SERVER reload when changed.
|
||||||
death-exp-loss:
|
death-exp-loss:
|
||||||
enabled: false
|
enabled: false
|
||||||
@ -120,9 +124,6 @@ death-exp-loss:
|
|||||||
# Percentage of current EXP you lose when dying.
|
# Percentage of current EXP you lose when dying.
|
||||||
percent: 30
|
percent: 30
|
||||||
|
|
||||||
# Allows to toggle exp hologram from gaining experience
|
|
||||||
display-exp-holograms: true
|
|
||||||
|
|
||||||
# Put the "value" of the action you want.
|
# Put the "value" of the action you want.
|
||||||
# If the value is invalid or empty it will
|
# If the value is invalid or empty it will
|
||||||
# default to the vanilla minecraft action.
|
# default to the vanilla minecraft action.
|
||||||
|
Loading…
Reference in New Issue
Block a user