forked from Upstream/mmocore
Merge branch 'master' of ssh://git@dev.lumine.io:7999/mmo/mmocore.git
This commit is contained in:
commit
b7368d7ffd
@ -62,6 +62,7 @@ import net.Indyuce.mmocore.listener.PlayerListener;
|
||||
import net.Indyuce.mmocore.listener.SpellCast;
|
||||
import net.Indyuce.mmocore.listener.WaypointsListener;
|
||||
import net.Indyuce.mmocore.listener.option.DeathExperienceLoss;
|
||||
import net.Indyuce.mmocore.listener.option.DisableRegeneration;
|
||||
import net.Indyuce.mmocore.listener.option.HealthScale;
|
||||
import net.Indyuce.mmocore.listener.option.NoSpawnerEXP;
|
||||
import net.Indyuce.mmocore.listener.option.VanillaExperienceOverride;
|
||||
@ -231,20 +232,13 @@ public class MMOCore extends JavaPlugin {
|
||||
*/
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
for (PlayerData data : PlayerData.getAll())
|
||||
if (data.isOnline() && !data.getPlayer().isDead()) {
|
||||
|
||||
data.giveStellium(data.getStats().getStat(StatType.STELLIUM_REGENERATION));
|
||||
|
||||
if (data.canRegen(PlayerResource.HEALTH))
|
||||
data.heal(data.calculateRegen(PlayerResource.HEALTH));
|
||||
|
||||
if (data.canRegen(PlayerResource.MANA))
|
||||
data.giveMana(data.calculateRegen(PlayerResource.MANA));
|
||||
|
||||
if (data.canRegen(PlayerResource.STAMINA))
|
||||
data.giveStamina(data.calculateRegen(PlayerResource.STAMINA));
|
||||
}
|
||||
for (PlayerData player : PlayerData.getAll())
|
||||
if (player.isOnline() && !player.getPlayer().isDead())
|
||||
for (PlayerResource resource : PlayerResource.values()) {
|
||||
double d = player.getProfess().getHandler(resource).getRegen(player);
|
||||
if (d > 0)
|
||||
resource.regen(player, d);
|
||||
}
|
||||
}
|
||||
}.runTaskTimerAsynchronously(MMOCore.plugin, 100, 20);
|
||||
|
||||
@ -254,9 +248,9 @@ public class MMOCore extends JavaPlugin {
|
||||
* produced by people not reading the installation guide...
|
||||
*/
|
||||
if (Bukkit.getPluginManager().getPlugin("MMOItemsMana") != null) {
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_RED + "[MMOCore] MMOCore is not meant to be used with the Mana & Stamina MMOItems!!!");
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_RED + "[MMOCore] Please read the installation guide!");
|
||||
Bukkit.broadcastMessage(ChatColor.DARK_RED + "[MMOCore] MMOCore is not meant to be used with the Mana & Stamina MMOItems!!!");
|
||||
getLogger().log(Level.SEVERE, ChatColor.DARK_RED + "MMOCore is not meant to be used with MMOItems ManaAndStamina");
|
||||
getLogger().log(Level.SEVERE, ChatColor.DARK_RED + "Please read the installation guide!");
|
||||
Bukkit.broadcastMessage(ChatColor.DARK_RED + "[MMOCore] MMOCore is not meant to be used with MMOItems ManaAndStamina");
|
||||
Bukkit.broadcastMessage(ChatColor.DARK_RED + "[MMOCore] Please read the installation guide!");
|
||||
return;
|
||||
}
|
||||
@ -288,6 +282,9 @@ public class MMOCore extends JavaPlugin {
|
||||
if (getConfig().getBoolean("death-exp-loss.enabled"))
|
||||
Bukkit.getPluginManager().registerEvents(new DeathExperienceLoss(), this);
|
||||
|
||||
if (getConfig().getBoolean("disable-vanilla-regen"))
|
||||
Bukkit.getPluginManager().registerEvents(new DisableRegeneration(), this);
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(new WaypointsListener(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new PlayerListener(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new GoldPouchesListener(), this);
|
||||
|
@ -94,52 +94,29 @@ public class MMOCoreUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static String intToRoman(int input) {
|
||||
if (input < 1 || input > 499)
|
||||
return ">499";
|
||||
private static final String[] romanChars = { "I", "IV", "V", "IX", "X", "XL", "L", "XC", "C", "CD", "D", "CM", "M" };
|
||||
private static final int[] romanQuantities = { 1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000 };
|
||||
|
||||
String s = "";
|
||||
while (input >= 400) {
|
||||
s += "CD";
|
||||
input -= 400;
|
||||
public static String intToRoman(int input) {
|
||||
if (input < 1)
|
||||
return "<1";
|
||||
if (input > 3999)
|
||||
return ">3999";
|
||||
|
||||
String result = "";
|
||||
|
||||
for (int j = 0; j < romanChars.length; j++) {
|
||||
int i = romanChars.length - j - 1;
|
||||
int q = romanQuantities[i];
|
||||
String c = romanChars[i];
|
||||
|
||||
while (input >= q) {
|
||||
result += c;
|
||||
input -= q;
|
||||
}
|
||||
}
|
||||
while (input >= 100) {
|
||||
s += "C";
|
||||
input -= 100;
|
||||
}
|
||||
while (input >= 90) {
|
||||
s += "XC";
|
||||
input -= 90;
|
||||
}
|
||||
while (input >= 50) {
|
||||
s += "L";
|
||||
input -= 50;
|
||||
}
|
||||
while (input >= 40) {
|
||||
s += "XL";
|
||||
input -= 40;
|
||||
}
|
||||
while (input >= 10) {
|
||||
s += "X";
|
||||
input -= 10;
|
||||
}
|
||||
while (input >= 9) {
|
||||
s += "IX";
|
||||
input -= 9;
|
||||
}
|
||||
while (input >= 5) {
|
||||
s += "V";
|
||||
input -= 5;
|
||||
}
|
||||
while (input >= 4) {
|
||||
s += "IV";
|
||||
input -= 4;
|
||||
}
|
||||
while (input >= 1) {
|
||||
s += "I";
|
||||
input -= 1;
|
||||
}
|
||||
return s;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,40 +1,31 @@
|
||||
package net.Indyuce.mmocore.api.player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.Indyuce.mmocore.api.ConfigFile;
|
||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||
|
||||
public class OfflinePlayerData {
|
||||
public abstract class OfflinePlayerData {
|
||||
private final UUID uuid;
|
||||
private final PlayerData data;
|
||||
|
||||
/*
|
||||
* supports offline player data operations like friend removals which can't
|
||||
* be handled when their player data is not loaded in the data map.
|
||||
*/
|
||||
public OfflinePlayerData(UUID uuid) {
|
||||
data = PlayerData.isLoaded(this.uuid = uuid) ? PlayerData.get(uuid) : null;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public boolean isLoaded() {
|
||||
return data != null;
|
||||
public UUID getUniqueId() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void removeFriend(UUID uuid) {
|
||||
if (isLoaded()) {
|
||||
data.removeFriend(uuid);
|
||||
return;
|
||||
}
|
||||
public abstract void removeFriend(UUID uuid);
|
||||
|
||||
ConfigFile config = new ConfigFile(this.uuid);
|
||||
List<String> friends = config.getConfig().getStringList("friends");
|
||||
friends.remove(uuid.toString());
|
||||
config.getConfig().set("friends", friends);
|
||||
config.save();
|
||||
}
|
||||
public abstract boolean hasFriend(UUID uuid);
|
||||
|
||||
public boolean hasFriend(UUID uuid) {
|
||||
return isLoaded() ? data.hasFriend(uuid) : new ConfigFile(this.uuid).getConfig().getStringList("friends").contains(uuid.toString());
|
||||
public abstract PlayerClass getProfess();
|
||||
|
||||
public abstract int getLevel();
|
||||
|
||||
public abstract long getLastLogin();
|
||||
|
||||
public static OfflinePlayerData get(UUID uuid) {
|
||||
return PlayerData.isLoaded(uuid) ? PlayerData.get(uuid) : new SimpleOfflinePlayerData(uuid);
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ import net.Indyuce.mmocore.api.player.attribute.PlayerAttributes;
|
||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass.Subclass;
|
||||
import net.Indyuce.mmocore.api.player.profess.SavedClassInformation;
|
||||
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
||||
import net.Indyuce.mmocore.api.player.social.FriendRequest;
|
||||
import net.Indyuce.mmocore.api.player.social.Party;
|
||||
import net.Indyuce.mmocore.api.player.social.guilds.Guild;
|
||||
@ -49,14 +48,13 @@ import net.Indyuce.mmocore.api.skill.Skill.SkillInfo;
|
||||
import net.Indyuce.mmocore.api.skill.SkillResult;
|
||||
import net.Indyuce.mmocore.api.skill.SkillResult.CancelReason;
|
||||
import net.Indyuce.mmocore.listener.SpellCast.SkillCasting;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.version.VersionSound;
|
||||
|
||||
public class PlayerData {
|
||||
|
||||
private final UUID uuid;
|
||||
public class PlayerData extends OfflinePlayerData {
|
||||
|
||||
/*
|
||||
* is updated everytime the player joins the server. it is kept when the
|
||||
@ -66,24 +64,23 @@ public class PlayerData {
|
||||
private Player player;
|
||||
|
||||
private PlayerClass profess;
|
||||
private final Map<String, SavedClassInformation> classSlots = new HashMap<>();
|
||||
private int level, experience, classPoints, skillPoints, attributePoints, attributeReallocationPoints;// skillReallocationPoints,
|
||||
private double mana, stamina, stellium;
|
||||
private final Professions collectSkills = new Professions(this);
|
||||
private final PlayerQuests questData;
|
||||
private final Set<String> waypoints = new HashSet<>();
|
||||
private List<UUID> friends;
|
||||
private Party party;
|
||||
private Guild guild;
|
||||
private final Map<String, SavedClassInformation> classSlots = new HashMap<>();
|
||||
private final List<SkillInfo> boundSkills = new ArrayList<>();
|
||||
private final PlayerAttributes attributes = new PlayerAttributes(this);
|
||||
|
||||
private final Professions collectSkills = new Professions(this);
|
||||
private final PlayerQuests questData;
|
||||
private final Set<String> waypoints = new HashSet<>();
|
||||
private final PlayerStats playerStats;
|
||||
private long lastWaypoint, lastLogin, lastFriendRequest, actionBarTimeOut;
|
||||
|
||||
private final Map<String, Integer> skills = new HashMap<>();
|
||||
private final PlayerSkillData skillData = new PlayerSkillData(this);
|
||||
|
||||
private long lastWaypoint, lastLogin, lastFriendRequest, actionBarTimeOut;
|
||||
|
||||
/*
|
||||
* NON-FINAL player data stuff made public to facilitate field change
|
||||
*/
|
||||
@ -95,7 +92,8 @@ public class PlayerData {
|
||||
private static Map<UUID, PlayerData> playerData = new HashMap<>();
|
||||
|
||||
private PlayerData(Player player) {
|
||||
uuid = player.getUniqueId();
|
||||
super(player.getUniqueId());
|
||||
|
||||
setPlayer(player);
|
||||
playerStats = new PlayerStats(this);
|
||||
|
||||
@ -114,7 +112,8 @@ public class PlayerData {
|
||||
this.mana = getStats().getStat(StatType.MAX_MANA);
|
||||
this.stamina = getStats().getStat(StatType.MAX_STAMINA);
|
||||
this.stellium = getStats().getStat(StatType.MAX_STELLIUM);
|
||||
if (config.contains("guild")) this.guild = MMOCore.plugin.guildManager.stillInGuild(getUniqueId(), config.getString("guild"));
|
||||
if (config.contains("guild"))
|
||||
this.guild = MMOCore.plugin.guildManager.stillInGuild(getUniqueId(), config.getString("guild"));
|
||||
if (config.contains("attribute"))
|
||||
attributes.load(config.getConfigurationSection("attribute"));
|
||||
if (config.contains("profession"))
|
||||
@ -161,9 +160,8 @@ public class PlayerData {
|
||||
config.set("waypoints", new ArrayList<>(waypoints));
|
||||
config.set("friends", toStringList(friends));
|
||||
config.set("last-login", lastLogin);
|
||||
if(guild != null) config.set("guild", guild.getId());
|
||||
else config.set("guild", null);
|
||||
|
||||
config.set("guild", guild != null ? guild.getId() : null);
|
||||
|
||||
config.set("skill", null);
|
||||
skills.entrySet().forEach(entry -> config.set("skill." + entry.getKey(), entry.getValue()));
|
||||
|
||||
@ -245,44 +243,6 @@ public class PlayerData {
|
||||
return playerData.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* START OF EXPERIMENTAL CODE
|
||||
*
|
||||
* This must be more simple to do than my 2AM brain could think of...
|
||||
* - Aria
|
||||
*/
|
||||
|
||||
private static Map<UUID, PlayerDataOfflineValues> offlineValues = new HashMap<>();
|
||||
public static PlayerDataOfflineValues getOfflineValues(UUID uuid) {
|
||||
if(!offlineValues.containsKey(uuid))
|
||||
offlineValues.put(uuid, new PlayerDataOfflineValues(uuid));
|
||||
return offlineValues.get(uuid) ;
|
||||
}
|
||||
|
||||
public static class PlayerDataOfflineValues {
|
||||
// Values can be added as they are needed
|
||||
private final PlayerClass profess;
|
||||
private final int level;
|
||||
private final long lastLogin;
|
||||
|
||||
public PlayerDataOfflineValues(UUID uuid) {
|
||||
FileConfiguration config = new ConfigFile(uuid).getConfig();
|
||||
this.profess = MMOCore.plugin.classManager.get(config.getString("class"));
|
||||
this.level = config.getInt("level");
|
||||
this.lastLogin = config.getLong("last-login");
|
||||
}
|
||||
|
||||
public PlayerClass getProfess()
|
||||
{ return profess; }
|
||||
public int getLevel()
|
||||
{ return level; }
|
||||
public long getLastLogin()
|
||||
{ return lastLogin; }
|
||||
}
|
||||
/**
|
||||
* END OF EXPERIMENTAL CODE
|
||||
*/
|
||||
|
||||
private PlayerData setPlayer(Player player) {
|
||||
this.player = player;
|
||||
this.lastLogin = System.currentTimeMillis();
|
||||
@ -305,10 +265,7 @@ public class PlayerData {
|
||||
return player;
|
||||
}
|
||||
|
||||
public UUID getUniqueId() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastLogin() {
|
||||
return lastLogin;
|
||||
}
|
||||
@ -317,6 +274,7 @@ public class PlayerData {
|
||||
return lastFriendRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevel() {
|
||||
return Math.max(1, level);
|
||||
}
|
||||
@ -445,10 +403,12 @@ public class PlayerData {
|
||||
friends.add(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFriend(UUID uuid) {
|
||||
friends.remove(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFriend(UUID uuid) {
|
||||
return friends.contains(uuid);
|
||||
}
|
||||
@ -517,16 +477,18 @@ public class PlayerData {
|
||||
public void giveExperience(int value) {
|
||||
giveExperience(value, null);
|
||||
}
|
||||
|
||||
|
||||
public void giveExperience(int value, Location loc) {
|
||||
if (profess == null || hasReachedMaxLevel()) {
|
||||
setExperience(0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// display hologram
|
||||
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());
|
||||
if (MMOItems.plugin.getConfig().getBoolean("game-indicators.exp.enabled")) {
|
||||
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());
|
||||
}
|
||||
|
||||
value = MMOCore.plugin.boosterManager.calculateExp(null, value);
|
||||
value *= 1 + getStats().getStat(StatType.ADDITIONAL_EXPERIENCE) / 100;
|
||||
@ -567,6 +529,7 @@ public class PlayerData {
|
||||
return experience;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerClass getProfess() {
|
||||
return profess == null ? MMOCore.plugin.classManager.getDefaultClass() : profess;
|
||||
}
|
||||
@ -603,14 +566,6 @@ public class PlayerData {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
public boolean canRegen(PlayerResource resource) {
|
||||
return getProfess().getHandler(resource).isAvailable(this);
|
||||
}
|
||||
|
||||
public double calculateRegen(PlayerResource resource) {
|
||||
return getProfess().getHandler(resource).getRegen(this);
|
||||
}
|
||||
|
||||
public void setMana(double amount) {
|
||||
mana = Math.max(0, Math.min(amount, getStats().getStat(StatType.MAX_MANA)));
|
||||
}
|
||||
@ -634,7 +589,7 @@ public class PlayerData {
|
||||
public boolean canSeeActionBar() {
|
||||
return actionBarTimeOut < System.currentTimeMillis();
|
||||
}
|
||||
|
||||
|
||||
public void setActionBarTimeOut(long timeOut) {
|
||||
actionBarTimeOut = System.currentTimeMillis() + (timeOut * 50);
|
||||
}
|
||||
@ -821,6 +776,6 @@ public class PlayerData {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj != null && obj instanceof PlayerData && ((PlayerData) obj).uuid.equals(uuid);
|
||||
return obj != null && obj instanceof PlayerData && ((PlayerData) obj).getUniqueId().equals(getUniqueId());
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package net.Indyuce.mmocore.api.player;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -86,8 +87,10 @@ public class Professions {
|
||||
exp.put(profession.getId(), exp.containsKey(profession.getId()) ? exp.get(profession.getId()) + value : value);
|
||||
|
||||
// display hologram
|
||||
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());
|
||||
if (MMOItems.plugin.getConfig().getBoolean("game-indicators.exp.enabled")) {
|
||||
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());
|
||||
}
|
||||
|
||||
int needed, exp, level;
|
||||
boolean check = false;
|
||||
|
@ -0,0 +1,50 @@
|
||||
package net.Indyuce.mmocore.api.player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.ConfigFile;
|
||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||
|
||||
public class SimpleOfflinePlayerData extends OfflinePlayerData {
|
||||
private final ConfigFile config;
|
||||
|
||||
/*
|
||||
* supports offline player data operations like friend removals which can't
|
||||
* be handled when their player data is not loaded in the data map.
|
||||
*/
|
||||
public SimpleOfflinePlayerData(UUID uuid) {
|
||||
super(uuid);
|
||||
|
||||
config = new ConfigFile(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFriend(UUID uuid) {
|
||||
List<String> friends = config.getConfig().getStringList("friends");
|
||||
friends.remove(uuid.toString());
|
||||
config.getConfig().set("friends", friends);
|
||||
config.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFriend(UUID uuid) {
|
||||
return config.getConfig().getStringList("friends").contains(uuid.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerClass getProfess() {
|
||||
return config.getConfig().contains("class") ? MMOCore.plugin.classManager.get(config.getConfig().getString("class")) : MMOCore.plugin.classManager.getDefaultClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevel() {
|
||||
return config.getConfig().getInt("level");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastLogin() {
|
||||
return config.getConfig().getLong("last-login");
|
||||
}
|
||||
}
|
@ -31,6 +31,7 @@ import net.Indyuce.mmocore.api.load.MMOLoadException;
|
||||
import net.Indyuce.mmocore.api.math.formula.LinearValue;
|
||||
import net.Indyuce.mmocore.api.math.particle.CastingParticle;
|
||||
import net.Indyuce.mmocore.api.player.profess.event.EventTrigger;
|
||||
import net.Indyuce.mmocore.api.player.profess.resource.ManaDisplayOptions;
|
||||
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
||||
import net.Indyuce.mmocore.api.player.profess.resource.ResourceHandler;
|
||||
import net.Indyuce.mmocore.api.player.stats.StatType;
|
||||
@ -51,9 +52,9 @@ public class PlayerClass {
|
||||
private final Map<String, SkillInfo> skills = new LinkedHashMap<>();
|
||||
private final List<Subclass> subclasses = new ArrayList<>();
|
||||
|
||||
private Map<String, EventTrigger> eventTriggers = new HashMap<>();
|
||||
private final Map<PlayerResource, ResourceHandler> resourceHandlers = new HashMap<>();
|
||||
private final Map<String, EventTrigger> eventTriggers = new HashMap<>();
|
||||
|
||||
private final Map<PlayerResource, ResourceHandler> resources = new HashMap<>();
|
||||
private CastingParticle castParticle = new CastingParticle(Particle.SPELL_INSTANT);
|
||||
|
||||
/*
|
||||
@ -67,9 +68,9 @@ public class PlayerClass {
|
||||
|
||||
name = ChatColor.translateAlternateColorCodes('&', config.getString("display.name"));
|
||||
icon = MMOCoreUtils.readIcon(config.getString("display.item"));
|
||||
|
||||
if(config.contains("display.texture")) {
|
||||
if(icon.getType() == VersionMaterial.PLAYER_HEAD.toMaterial()) {
|
||||
|
||||
if (config.contains("display.texture")) {
|
||||
if (icon.getType() == VersionMaterial.PLAYER_HEAD.toMaterial()) {
|
||||
ItemMeta meta = icon.getItemMeta();
|
||||
try {
|
||||
Field profileField = meta.getClass().getDeclaredField("profile");
|
||||
@ -81,12 +82,11 @@ public class PlayerClass {
|
||||
MMOCore.log(Level.WARNING, "[PlayerClasses:" + id + "] Could not apply playerhead texture: " + exception.getMessage());
|
||||
}
|
||||
icon.setItemMeta(meta);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
MMOCore.log(Level.WARNING, "[PlayerClasses:" + id + "] Could not add player head texture. The item is not a playerhead!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (String string : config.getStringList("display.lore"))
|
||||
description.add(ChatColor.GRAY + ChatColor.translateAlternateColorCodes('&', string));
|
||||
for (String string : config.getStringList("display.attribute-lore"))
|
||||
@ -141,8 +141,6 @@ public class PlayerClass {
|
||||
for (String key : config.getConfigurationSection("triggers").getKeys(false)) {
|
||||
try {
|
||||
String format = key.toLowerCase().replace("_", "-").replace(" ", "-");
|
||||
// Validate.isTrue(MMOCore.plugin.classManager.isEventRegistered(format),
|
||||
// "Could not find trigger event called '" + format + "'");
|
||||
eventTriggers.put(format, new EventTrigger(format, config.getStringList("triggers." + key)));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.log(Level.WARNING, "[PlayerClasses:" + id + "] " + exception.getMessage());
|
||||
@ -150,8 +148,21 @@ public class PlayerClass {
|
||||
}
|
||||
}
|
||||
|
||||
for (PlayerResource resource : PlayerResource.values())
|
||||
resources.put(resource, new ResourceHandler(this, resource));
|
||||
/*
|
||||
* must make sure all the resourceHandlers are registered when the
|
||||
* placer class is initialized.
|
||||
*/
|
||||
for (PlayerResource resource : PlayerResource.values()) {
|
||||
if (config.isConfigurationSection("resource." + resource.name().toLowerCase()))
|
||||
try {
|
||||
resourceHandlers.put(resource, new ResourceHandler(resource, config.getConfigurationSection("resource." + resource.name().toLowerCase())));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.log(Level.WARNING, "[PlayerClasses:" + id + "] Could not load special resource regen for " + resource.name() + ": " + exception.getMessage());
|
||||
resourceHandlers.put(resource, new ResourceHandler(resource));
|
||||
}
|
||||
else
|
||||
resourceHandlers.put(resource, new ResourceHandler(resource));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -170,7 +181,7 @@ public class PlayerClass {
|
||||
setOption(ClassOption.DEFAULT, false);
|
||||
|
||||
for (PlayerResource resource : PlayerResource.values())
|
||||
resources.put(resource, new ResourceHandler(this, resource));
|
||||
resourceHandlers.put(resource, new ResourceHandler(resource));
|
||||
}
|
||||
|
||||
public void loadSubclasses(ClassManager manager) {
|
||||
@ -193,7 +204,7 @@ public class PlayerClass {
|
||||
}
|
||||
|
||||
public ResourceHandler getHandler(PlayerResource resource) {
|
||||
return resources.get(resource);
|
||||
return resourceHandlers.get(resource);
|
||||
}
|
||||
|
||||
public int getMaxLevel() {
|
||||
@ -203,7 +214,7 @@ public class PlayerClass {
|
||||
public int getDisplayOrder() {
|
||||
return displayOrder;
|
||||
}
|
||||
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
@ -311,26 +322,13 @@ public class PlayerClass {
|
||||
*/
|
||||
DISPLAY(true),
|
||||
|
||||
/*
|
||||
* resource regeneration depends on max resource
|
||||
*/
|
||||
MISSING_HEALTH_REGEN,
|
||||
MISSING_MANA_REGEN,
|
||||
MISSING_STAMINA_REGEN,
|
||||
|
||||
/*
|
||||
* resource regeneration depends on missing resource
|
||||
*/
|
||||
MAX_HEALTH_REGEN,
|
||||
MAX_MANA_REGEN,
|
||||
MAX_STAMINA_REGEN,
|
||||
|
||||
/*
|
||||
* only regen resource when out of combat
|
||||
*/
|
||||
OFF_COMBAT_HEALTH_REGEN,
|
||||
OFF_COMBAT_MANA_REGEN(true),
|
||||
OFF_COMBAT_STAMINA_REGEN;
|
||||
OFF_COMBAT_MANA_REGEN,
|
||||
OFF_COMBAT_STAMINA_REGEN,
|
||||
OFF_COMBAT_STELLIUM_REGEN;
|
||||
|
||||
private final boolean def;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.Indyuce.mmocore.api.player.profess;
|
||||
package net.Indyuce.mmocore.api.player.profess.resource;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -27,8 +27,8 @@ public class ManaDisplayOptions {
|
||||
|
||||
public ManaDisplayOptions(ChatColor color, String name, char barCharacter) {
|
||||
Validate.notNull(color, "Color cannot be null");
|
||||
Validate.notNull(name, "name cannot be null");
|
||||
Validate.notNull(barCharacter, "barCharacter cannot be null");
|
||||
Validate.notNull(name, "Name cannot be null");
|
||||
Validate.notNull(barCharacter, "Bar character cannot be null");
|
||||
|
||||
this.color = color;
|
||||
this.name = name;
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmocore.api.player.profess.resource;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.bukkit.attribute.Attribute;
|
||||
@ -13,44 +14,41 @@ public enum PlayerResource {
|
||||
/*
|
||||
* used to handle resource regeneration.
|
||||
*/
|
||||
HEALTH(StatType.HEALTH_REGENERATION, ClassOption.OFF_COMBAT_HEALTH_REGEN, ClassOption.MAX_HEALTH_REGEN, ClassOption.MISSING_HEALTH_REGEN, (data) -> data.getPlayer().getHealth(), (data) -> data.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()),
|
||||
MANA(StatType.MANA_REGENERATION, ClassOption.OFF_COMBAT_MANA_REGEN, ClassOption.MAX_MANA_REGEN, ClassOption.MISSING_MANA_REGEN, (data) -> data.getMana(), (data) -> data.getStats().getStat(StatType.MAX_MANA)),
|
||||
STAMINA(StatType.STAMINA_REGENERATION, ClassOption.OFF_COMBAT_STAMINA_REGEN, ClassOption.MAX_STAMINA_REGEN, ClassOption.MISSING_STAMINA_REGEN, (data) -> data.getStamina(), (data) -> data.getStats().getStat(StatType.MAX_STAMINA));
|
||||
HEALTH(StatType.HEALTH_REGENERATION, ClassOption.OFF_COMBAT_HEALTH_REGEN, (data) -> data.getPlayer().getHealth(), (data) -> data.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue(), (data, d) -> data.heal(d)),
|
||||
MANA(StatType.MANA_REGENERATION, ClassOption.OFF_COMBAT_MANA_REGEN, (data) -> data.getMana(), (data) -> data.getStats().getStat(StatType.MAX_MANA), (data, d) -> data.giveMana(d)),
|
||||
STAMINA(StatType.STAMINA_REGENERATION, ClassOption.OFF_COMBAT_STAMINA_REGEN, (data) -> data.getStamina(), (data) -> data.getStats().getStat(StatType.MAX_STAMINA), (data, d) -> data.giveStamina(d)),
|
||||
STELLIUM(StatType.STELLIUM_REGENERATION, ClassOption.OFF_COMBAT_STELLIUM_REGEN, (data) -> data.getStellium(), (data) -> data.getStats().getStat(StatType.MAX_STELLIUM), (data, d) -> data.giveStellium(d));
|
||||
|
||||
private final StatType regenStat;
|
||||
private final ClassOption offCombatRegen, maxRegen, missingRegen;
|
||||
private final ClassOption offCombatRegen;
|
||||
private final Function<PlayerData, Double> current, max;
|
||||
private final BiConsumer<PlayerData, Double> regen;
|
||||
|
||||
private PlayerResource(StatType regenStat, ClassOption offCombatRegen, ClassOption maxRegen, ClassOption missingRegen, Function<PlayerData, Double> current, Function<PlayerData, Double> max) {
|
||||
private PlayerResource(StatType regenStat, ClassOption offCombatRegen, Function<PlayerData, Double> current, Function<PlayerData, Double> max, BiConsumer<PlayerData, Double> regen) {
|
||||
this.regenStat = regenStat;
|
||||
this.offCombatRegen = offCombatRegen;
|
||||
this.maxRegen = maxRegen;
|
||||
this.missingRegen = missingRegen;
|
||||
this.current = current;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public ClassOption getMaxRegen() {
|
||||
return maxRegen;
|
||||
}
|
||||
|
||||
public ClassOption getMissingRegen() {
|
||||
return missingRegen;
|
||||
}
|
||||
|
||||
public ClassOption getOffCombatRegen() {
|
||||
return offCombatRegen;
|
||||
this.regen = regen;
|
||||
}
|
||||
|
||||
public StatType getRegenStat() {
|
||||
return regenStat;
|
||||
}
|
||||
|
||||
public double getCurrent(PlayerData data) {
|
||||
return current.apply(data);
|
||||
public ClassOption getOffCombatRegen() {
|
||||
return offCombatRegen;
|
||||
}
|
||||
|
||||
public double getMax(PlayerData data) {
|
||||
return max.apply(data);
|
||||
public double getCurrent(PlayerData player) {
|
||||
return current.apply(player);
|
||||
}
|
||||
|
||||
public double getMax(PlayerData player) {
|
||||
return max.apply(player);
|
||||
}
|
||||
|
||||
public void regen(PlayerData player, double amount) {
|
||||
regen.accept(player, amount);
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +1,92 @@
|
||||
package net.Indyuce.mmocore.api.player.profess.resource;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import net.Indyuce.mmocore.api.math.formula.LinearValue;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||
|
||||
public class ResourceHandler {
|
||||
private final Function<PlayerData, Double> regen;
|
||||
private final Predicate<PlayerData> available;
|
||||
|
||||
public ResourceHandler(PlayerClass profess, PlayerResource resource) {
|
||||
available = profess.hasOption(resource.getOffCombatRegen()) ? (data) -> !data.isInCombat() : (data) -> true;
|
||||
regen = profess.hasOption(resource.getMaxRegen()) ? (data) -> resource.getMax(data) * data.getStats().getStat(resource.getRegenStat()) / 100 : profess.hasOption(resource.getMissingRegen()) ? (data) -> Math.max(0, resource.getMax(data) - resource.getCurrent(data)) * data.getStats().getStat(resource.getRegenStat()) / 100 : (data) -> data.getStats().getStat(resource.getRegenStat());
|
||||
/*
|
||||
* resource regeneration only applies when player is off combat
|
||||
*/
|
||||
private final boolean offCombatOnly;
|
||||
|
||||
/*
|
||||
* percentage of scaling which the player regenerates every second
|
||||
*/
|
||||
private final LinearValue scalar;
|
||||
|
||||
/*
|
||||
* whether the resource regeneration scales on missing or max resource. if
|
||||
* TYPE is null, then there is no special regeneration.
|
||||
*/
|
||||
private final HandlerType type;
|
||||
private final PlayerResource resource;
|
||||
|
||||
public ResourceHandler(PlayerResource resource) {
|
||||
this(resource, null, null, false);
|
||||
}
|
||||
|
||||
public boolean isAvailable(PlayerData data) {
|
||||
return available.test(data);
|
||||
public ResourceHandler(PlayerResource resource, ConfigurationSection config) {
|
||||
this.resource = resource;
|
||||
offCombatOnly = config.getBoolean("off-combat");
|
||||
|
||||
Validate.isTrue(config.contains("type"), "Could not find resource regen scaling type");
|
||||
type = HandlerType.valueOf(config.getString("type").toUpperCase());
|
||||
|
||||
Validate.notNull(config.getConfigurationSection("value"), "Could not find resource regen value config section");
|
||||
scalar = new LinearValue(config.getConfigurationSection("value"));
|
||||
}
|
||||
|
||||
public double getRegen(PlayerData data) {
|
||||
return regen.apply(data);
|
||||
public ResourceHandler(PlayerResource resource, HandlerType type, LinearValue scalar, boolean offCombatOnly) {
|
||||
this.resource = resource;
|
||||
this.type = type;
|
||||
this.scalar = scalar;
|
||||
this.offCombatOnly = offCombatOnly;
|
||||
}
|
||||
|
||||
/*
|
||||
* REGENERATION FORMULAS HERE.
|
||||
*/
|
||||
public double getRegen(PlayerData player) {
|
||||
|
||||
double d = 0;
|
||||
|
||||
// base resource regeneration = value of the corresponding regen stat
|
||||
if (!player.isInCombat() || !player.getProfess().hasOption(resource.getOffCombatRegen()))
|
||||
d += player.getStats().getStat(resource.getRegenStat());
|
||||
|
||||
// extra resource regeneration based on CLASS, scales on LEVEL
|
||||
if (type != null && (!player.isInCombat() || !offCombatOnly))
|
||||
d = this.scalar.calculate(player.getLevel()) / 100 * type.getScaling(player, resource);
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
public enum HandlerType {
|
||||
|
||||
/*
|
||||
* resource regeneration scales on max resource
|
||||
*/
|
||||
MAX((player, resource) -> resource.getMax(player)),
|
||||
|
||||
/*
|
||||
* resource regeneration scales on missing resource
|
||||
*/
|
||||
MISSING((player, resource) -> resource.getMax(player) - resource.getCurrent(player));
|
||||
|
||||
private final BiFunction<PlayerData, PlayerResource, Double> calculation;
|
||||
|
||||
private HandlerType(BiFunction<PlayerData, PlayerResource, Double> calculation) {
|
||||
this.calculation = calculation;
|
||||
}
|
||||
|
||||
public double getScaling(PlayerData player, PlayerResource resource) {
|
||||
return calculation.apply(player, resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.Indyuce.mmocore.api.quest.trigger;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
@ -8,7 +7,7 @@ import net.Indyuce.mmocore.api.load.MMOLineConfig;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
|
||||
public class MessageTrigger extends Trigger {
|
||||
private String message;
|
||||
private final String message;
|
||||
|
||||
public MessageTrigger(MMOLineConfig config) {
|
||||
super(config);
|
||||
@ -23,7 +22,6 @@ public class MessageTrigger extends Trigger {
|
||||
}
|
||||
|
||||
private String format(Player player) {
|
||||
message = ChatColor.translateAlternateColorCodes('&', message);
|
||||
return MMOCore.plugin.placeholderParser.parse(player, message.replace("%player%", player.getName()));
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class FriendsCommand extends BukkitCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (new OfflinePlayerData(((Player) sender).getUniqueId()).hasFriend(uuid)) {
|
||||
if (OfflinePlayerData.get(((Player) sender).getUniqueId()).hasFriend(uuid)) {
|
||||
MMOCore.plugin.requestManager.unregisterRequest(uuid);
|
||||
return true;
|
||||
}
|
||||
|
@ -21,10 +21,11 @@ public class AdminCommandMap extends CommandMap {
|
||||
addFloor(new PointsCommandMap("class", this, (data, points) -> data.setClassPoints(points), (data, points) -> data.giveClassPoints(points), (data) -> data.getClassPoints()));
|
||||
addFloor(new PointsCommandMap("attribute", this, (data, points) -> data.setAttributePoints(points), (data, points) -> data.giveAttributePoints(points), (data) -> data.getAttributePoints()));
|
||||
addFloor(new PointsCommandMap("attr-realloc", this, (data, points) -> data.setAttributeReallocationPoints(points), (data, points) -> data.giveAttributeReallocationPoints(points), (data) -> data.getAttributeReallocationPoints()));
|
||||
|
||||
addFloor(new ResourcesCommandMap("mana", this, (data, value) -> data.setMana(value), (data, value) -> data.giveMana(value), (data, value) -> data.giveMana(-value), (data) -> data.getMana()));
|
||||
addFloor(new ResourcesCommandMap("stamina", this, (data, value) -> data.setStamina(value), (data, value) -> data.giveStamina(value), (data, value) -> data.giveStamina(-value), (data) -> data.getStamina()));
|
||||
addFloor(new ResourcesCommandMap("stellium", this, (data, value) -> data.setStellium(value), (data, value) -> data.giveStellium(value), (data, value) -> data.giveStellium(-value), (data) -> data.getStellium()));
|
||||
|
||||
addFloor(new ResourceCommandMap("health", this, (data, value) -> data.getPlayer().setHealth(value), (data, value) -> data.heal(value), (data, value) -> data.heal(-value), (data) -> data.getPlayer().getHealth()));
|
||||
addFloor(new ResourceCommandMap("mana", this, (data, value) -> data.setMana(value), (data, value) -> data.giveMana(value), (data, value) -> data.giveMana(-value), (data) -> data.getMana()));
|
||||
addFloor(new ResourceCommandMap("stamina", this, (data, value) -> data.setStamina(value), (data, value) -> data.giveStamina(value), (data, value) -> data.giveStamina(-value), (data) -> data.getStamina()));
|
||||
addFloor(new ResourceCommandMap("stellium", this, (data, value) -> data.setStellium(value), (data, value) -> data.giveStellium(value), (data, value) -> data.giveStellium(-value), (data) -> data.getStellium()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -13,11 +13,11 @@ import net.Indyuce.mmocore.command.api.CommandEnd;
|
||||
import net.Indyuce.mmocore.command.api.CommandMap;
|
||||
import net.Indyuce.mmocore.command.api.Parameter;
|
||||
|
||||
public class ResourcesCommandMap extends CommandMap {
|
||||
public class ResourceCommandMap extends CommandMap {
|
||||
private final String type;
|
||||
private final Function<PlayerData, Double> get;
|
||||
|
||||
public ResourcesCommandMap(String type, CommandMap parent, BiConsumer<PlayerData, Double> set, BiConsumer<PlayerData, Double> give, BiConsumer<PlayerData, Double> take, Function<PlayerData, Double> get) {
|
||||
public ResourceCommandMap(String type, CommandMap parent, BiConsumer<PlayerData, Double> set, BiConsumer<PlayerData, Double> give, BiConsumer<PlayerData, Double> take, Function<PlayerData, Double> get) {
|
||||
super(parent, "resource-" + type);
|
||||
|
||||
this.type = type;
|
@ -53,7 +53,7 @@ public class EditableFriendRemoval extends EditableInventory {
|
||||
public void whenClicked(InventoryClickEvent event, InventoryItem item) {
|
||||
if (item.getFunction().equals("yes")) {
|
||||
playerData.removeFriend(friend.getUniqueId());
|
||||
new OfflinePlayerData(friend.getUniqueId()).removeFriend(playerData.getUniqueId());
|
||||
OfflinePlayerData.get(friend.getUniqueId()).removeFriend(playerData.getUniqueId());
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
MMOCore.plugin.configManager.getSimpleMessage("no-longer-friends", "unfriend", friend.getName()).send(player);
|
||||
last.open();
|
||||
|
@ -17,8 +17,8 @@ import org.bukkit.inventory.meta.SkullMeta;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.input.PlayerInput.InputType;
|
||||
import net.Indyuce.mmocore.api.math.format.DelayFormat;
|
||||
import net.Indyuce.mmocore.api.player.OfflinePlayerData;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData.PlayerDataOfflineValues;
|
||||
import net.Indyuce.mmocore.gui.api.EditableInventory;
|
||||
import net.Indyuce.mmocore.gui.api.GeneratedInventory;
|
||||
import net.Indyuce.mmocore.gui.api.PluginInventory;
|
||||
@ -36,8 +36,7 @@ public class EditableGuildView extends EditableInventory {
|
||||
|
||||
@Override
|
||||
public InventoryItem load(String function, ConfigurationSection config) {
|
||||
return function.equals("member") ? new MemberItem(config) : (function.equals("next") || function.equals("previous")
|
||||
|| function.equals("disband") || function.equals("invite")) ? new ConditionalItem(function, config) : new NoPlaceholderItem(config);
|
||||
return function.equals("member") ? new MemberItem(config) : (function.equals("next") || function.equals("previous") || function.equals("disband") || function.equals("invite")) ? new ConditionalItem(function, config) : new NoPlaceholderItem(config);
|
||||
}
|
||||
|
||||
public class MemberDisplayItem extends InventoryPlaceholderItem {
|
||||
@ -49,25 +48,16 @@ public class EditableGuildView extends EditableInventory {
|
||||
public Placeholders getPlaceholders(PluginInventory inv, int n) {
|
||||
UUID uuid = inv.getPlayerData().getGuild().getMembers().get(n);
|
||||
Placeholders holders = new Placeholders();
|
||||
/**
|
||||
* Will never be null since a players name
|
||||
* will always be recorded if they've been in a guild
|
||||
*/
|
||||
/*
|
||||
* Will never be null since a players name will always be recorded
|
||||
* if they've been in a guild
|
||||
*/
|
||||
holders.register("name", Bukkit.getOfflinePlayer(uuid).getName());
|
||||
|
||||
if(PlayerData.get(uuid) == null) {
|
||||
PlayerDataOfflineValues pdov = PlayerData.getOfflineValues(uuid);
|
||||
holders.register("class", pdov.getProfess().getName());
|
||||
holders.register("level", "" + pdov.getLevel());
|
||||
holders.register("since", new DelayFormat(2).format(System.currentTimeMillis() - pdov.getLastLogin()));
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerData member = PlayerData.get(uuid);
|
||||
holders.register("class", member.getProfess().getName());
|
||||
holders.register("level", "" + member.getLevel());
|
||||
holders.register("since", new DelayFormat(2).format(System.currentTimeMillis() - member.getLastLogin()));
|
||||
}
|
||||
|
||||
OfflinePlayerData offline = OfflinePlayerData.get(uuid);
|
||||
holders.register("class", offline.getProfess().getName());
|
||||
holders.register("level", offline.getLevel());
|
||||
holders.register("since", new DelayFormat(2).format(System.currentTimeMillis() - offline.getLastLogin()));
|
||||
|
||||
return holders;
|
||||
}
|
||||
@ -121,10 +111,10 @@ public class EditableGuildView extends EditableInventory {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class ConditionalItem extends NoPlaceholderItem {
|
||||
private final String function;
|
||||
|
||||
|
||||
public ConditionalItem(String func, ConfigurationSection config) {
|
||||
super(config);
|
||||
this.function = func;
|
||||
@ -133,14 +123,13 @@ public class EditableGuildView extends EditableInventory {
|
||||
@Override
|
||||
public ItemStack display(GeneratedInventory invpar, int n) {
|
||||
GuildViewInventory inv = (GuildViewInventory) invpar;
|
||||
|
||||
if(function.equals("next"))
|
||||
if(inv.getPage() == (int) Math.ceil((inv.getPlayerData().getGuild().getMembers().count() + 20) / inv.getByFunction("member").getSlots().size()))
|
||||
|
||||
if (function.equals("next"))
|
||||
if (inv.getPage() == (int) Math.ceil((inv.getPlayerData().getGuild().getMembers().count() + 20) / inv.getByFunction("member").getSlots().size()))
|
||||
return null;
|
||||
if(function.equals("previous") && inv.getPage() == 1)
|
||||
if (function.equals("previous") && inv.getPage() == 1)
|
||||
return null;
|
||||
if((function.equals("disband") || function.equals("invite")) && !inv.getPlayerData()
|
||||
.getGuild().getOwner().equals(inv.getPlayer().getUniqueId()))
|
||||
if ((function.equals("disband") || function.equals("invite")) && !inv.getPlayerData().getGuild().getOwner().equals(inv.getPlayer().getUniqueId()))
|
||||
return null;
|
||||
return super.display(inv, n);
|
||||
}
|
||||
@ -157,19 +146,12 @@ public class EditableGuildView extends EditableInventory {
|
||||
public GuildViewInventory(PlayerData playerData, EditableInventory editable) {
|
||||
super(playerData, editable);
|
||||
|
||||
maxpages = (int) Math.ceil((playerData.getGuild().getMembers().count() + 20) /
|
||||
editable.getByFunction("member").getSlots().size());
|
||||
maxpages = (int) Math.ceil((playerData.getGuild().getMembers().count() + 20) / editable.getByFunction("member").getSlots().size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String calculateName() {
|
||||
return getName()
|
||||
.replace("{online_players}", "" + getPlayerData().getGuild().getMembers().countOnline())
|
||||
.replace("{page}", "" + page)
|
||||
.replace("{maxpages}", "" + maxpages)
|
||||
.replace("{players}", "" + getPlayerData().getGuild().getMembers().count())
|
||||
.replace("{tag}", getPlayerData().getGuild().getTag())
|
||||
.replace("{name}", getPlayerData().getGuild().getName());
|
||||
return getName().replace("{online_players}", "" + getPlayerData().getGuild().getMembers().countOnline()).replace("{page}", "" + page).replace("{maxpages}", "" + maxpages).replace("{players}", "" + getPlayerData().getGuild().getMembers().count()).replace("{tag}", getPlayerData().getGuild().getTag()).replace("{name}", getPlayerData().getGuild().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -180,12 +162,18 @@ public class EditableGuildView extends EditableInventory {
|
||||
player.closeInventory();
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getFunction().equals("next") && page != maxpages)
|
||||
{ page++; open(); return; }
|
||||
|
||||
if (item.getFunction().equals("previous") && page != 1)
|
||||
{ page--; open(); return; }
|
||||
if (item.getFunction().equals("next") && page != maxpages) {
|
||||
page++;
|
||||
open();
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getFunction().equals("previous") && page != 1) {
|
||||
page--;
|
||||
open();
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getFunction().equals("disband")) {
|
||||
if (!playerData.getGuild().getOwner().equals(playerData.getUniqueId()))
|
||||
@ -195,16 +183,17 @@ public class EditableGuildView extends EditableInventory {
|
||||
player.closeInventory();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (item.getFunction().equals("invite")) {
|
||||
if (!playerData.getGuild().getOwner().equals(playerData.getUniqueId()))
|
||||
return;
|
||||
|
||||
/**if (playerData.getGuild().getMembers().count() >= max) {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("guild-is-full").send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
|
||||
return;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* if (playerData.getGuild().getMembers().count() >= max) {
|
||||
* MMOCore.plugin.configManager.getSimpleMessage("guild-is-full").send(player);
|
||||
* player.playSound(player.getLocation(),
|
||||
* Sound.ENTITY_VILLAGER_NO, 1, 1); return; }
|
||||
*/
|
||||
|
||||
MMOCore.plugin.configManager.newPlayerInput(player, InputType.GUILD_INVITE, (input) -> {
|
||||
Player target = Bukkit.getPlayer(input);
|
||||
@ -240,7 +229,7 @@ public class EditableGuildView extends EditableInventory {
|
||||
if (item.getFunction().equals("member") && event.getAction() == InventoryAction.PICKUP_HALF && !NBTItem.get(event.getCurrentItem()).getString("uuid").isEmpty()) {
|
||||
if (!playerData.getGuild().getOwner().equals(playerData.getUniqueId()))
|
||||
return;
|
||||
|
||||
|
||||
OfflinePlayer target = Bukkit.getOfflinePlayer(UUID.fromString(NBTItem.get(event.getCurrentItem()).getString("uuid")));
|
||||
if (target.equals(player))
|
||||
return;
|
||||
@ -250,8 +239,9 @@ public class EditableGuildView extends EditableInventory {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public int getPage()
|
||||
{ return page; }
|
||||
|
||||
public int getPage() {
|
||||
return page;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
package net.Indyuce.mmocore.listener.option;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
|
||||
public class DisableRegeneration implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void a(EntityRegainHealthEvent event) {
|
||||
if (event.getEntityType() == EntityType.PLAYER)
|
||||
if (event.getRegainReason() == RegainReason.SATIATED || event.getRegainReason() == RegainReason.REGEN || event.getRegainReason() == RegainReason.EATING)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
@ -124,17 +124,14 @@ public class ConfigManager {
|
||||
}
|
||||
}
|
||||
|
||||
private ChatColor getColorOrDefault(String configKey, ChatColor defaultColor) {
|
||||
ChatColor newColor;
|
||||
private ChatColor getColorOrDefault(String key, ChatColor defaultColor) {
|
||||
try {
|
||||
newColor = ChatColor.valueOf(MMOCore.plugin.getConfig().getString("resource-bar-colors." + configKey).toUpperCase());
|
||||
return ChatColor.valueOf(MMOCore.plugin.getConfig().getString("resource-bar-colors." + key).toUpperCase());
|
||||
}
|
||||
catch(Exception e) {
|
||||
MMOCore.log(Level.WARNING, "Resource Bar color config '" + configKey + "' is invalid... Using default color.");
|
||||
newColor = defaultColor;
|
||||
catch(IllegalArgumentException exception) {
|
||||
MMOCore.log(Level.WARNING, "Could not read resource bar color from '" + key + "': using default.");
|
||||
return defaultColor;
|
||||
}
|
||||
|
||||
return newColor;
|
||||
}
|
||||
|
||||
public DecimalFormat newFormat(String pattern) {
|
||||
|
@ -70,6 +70,16 @@ health-scale:
|
||||
enabled: true
|
||||
scale: 20
|
||||
|
||||
# Disable player health regen due to saturation and eating
|
||||
# to control health regen via MMOCore resource regen.
|
||||
# Requires a SERVER reload when changed.
|
||||
disable-vanilla-regen: false
|
||||
|
||||
# Allows to toggle exp hologram from gaining experiences
|
||||
game-indicators:
|
||||
exp:
|
||||
enabled: false
|
||||
|
||||
# Players can swap their hotbar with the 9 inventory slots
|
||||
# right above it by pressing [swap items] while crouching.
|
||||
hotbar-swap: true
|
||||
|
@ -5,14 +5,6 @@ options:
|
||||
default: true
|
||||
display: false
|
||||
|
||||
# Health/mana regen scales on missing health/mana
|
||||
missing-health-regen: false
|
||||
missing-mana-regen: false
|
||||
|
||||
# Resource regen scales on max mana/health
|
||||
max-health-regen: false
|
||||
max-mana-regen: false
|
||||
|
||||
# Only regens when out of combat
|
||||
off-combat-health-regen: false
|
||||
off-combat-mana-regen: false
|
||||
|
@ -44,6 +44,25 @@ cast-particle:
|
||||
options:
|
||||
off-combat-health-regen: true
|
||||
|
||||
# Special resource regeneration: (when out of combat),
|
||||
# players can regen a set % of their maximum mana/missing mana.
|
||||
# This % can scale with the player level.
|
||||
# It also works with other player resources: health, stellium and stamina!
|
||||
resource:
|
||||
mana:
|
||||
|
||||
# Scales with max mana.
|
||||
type: MAX
|
||||
|
||||
# Regen from 3 to 10% of max mana every second
|
||||
value:
|
||||
base: 3
|
||||
per-level: .1
|
||||
max: 10
|
||||
|
||||
# Only regen when out of combat.
|
||||
off-combat: true
|
||||
|
||||
attributes:
|
||||
max-health:
|
||||
base: 18
|
||||
|
@ -40,6 +40,25 @@ mana:
|
||||
cast-particle:
|
||||
particle: CRIT
|
||||
|
||||
# Special resource regeneration: (when out of combat),
|
||||
# players can regen a set % of their stamina mana/missing stamina.
|
||||
# This % can scale with the player level.
|
||||
# It also works with other player resources: health, stellium and mana!
|
||||
resource:
|
||||
stamina:
|
||||
|
||||
# Regen scales with missing stamina.
|
||||
type: MISSING
|
||||
|
||||
# Regen from 3 to 10% of missing stamina every second
|
||||
value:
|
||||
base: 5
|
||||
per-level: .2
|
||||
max: 13
|
||||
|
||||
# Only regen when out of combat.
|
||||
off-combat: true
|
||||
|
||||
skills:
|
||||
WEAKEN:
|
||||
level: 3
|
||||
|
@ -35,7 +35,6 @@ triggers:
|
||||
options:
|
||||
off-combat-mana-regen: true
|
||||
off-combat-health-regen: true
|
||||
missing-health-regen: true
|
||||
|
||||
cast-particle:
|
||||
particle: SPELL_WITCH
|
||||
|
Loading…
Reference in New Issue
Block a user