forked from Upstream/mmocore
Merge remote-tracking branch 'origin/master'
# Conflicts: # MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java # MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java
This commit is contained in:
commit
f01391c6ab
@ -6,7 +6,7 @@ import io.lumine.mythic.lib.version.SpigotPlugin;
|
|||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.manager.social.PartyManager;
|
import net.Indyuce.mmocore.manager.social.PartyManager;
|
||||||
import net.Indyuce.mmocore.api.ConfigFile;
|
import net.Indyuce.mmocore.api.ConfigFile;
|
||||||
import net.Indyuce.mmocore.api.PlayerActionBar;
|
import net.Indyuce.mmocore.manager.ActionBarManager;
|
||||||
import net.Indyuce.mmocore.api.player.attribute.AttributeModifier;
|
import net.Indyuce.mmocore.api.player.attribute.AttributeModifier;
|
||||||
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
||||||
import net.Indyuce.mmocore.command.*;
|
import net.Indyuce.mmocore.command.*;
|
||||||
@ -64,7 +64,7 @@ public class MMOCore extends JavaPlugin {
|
|||||||
public final SoundManager soundManager = new SoundManager();
|
public final SoundManager soundManager = new SoundManager();
|
||||||
public final RequestManager requestManager = new RequestManager();
|
public final RequestManager requestManager = new RequestManager();
|
||||||
public final ConfigItemManager configItems = new ConfigItemManager();
|
public final ConfigItemManager configItems = new ConfigItemManager();
|
||||||
public final PlayerActionBar actionBarManager = new PlayerActionBar();
|
public final ActionBarManager actionBarManager = new ActionBarManager();
|
||||||
public final SkillManager skillManager = new SkillManager();
|
public final SkillManager skillManager = new SkillManager();
|
||||||
public final ClassManager classManager = new ClassManager();
|
public final ClassManager classManager = new ClassManager();
|
||||||
public final DropTableManager dropTableManager = new DropTableManager();
|
public final DropTableManager dropTableManager = new DropTableManager();
|
||||||
@ -111,11 +111,11 @@ public class MMOCore extends JavaPlugin {
|
|||||||
MythicLib.plugin.getEntities().registerRestriction(new MMOCoreTargetRestriction());
|
MythicLib.plugin.getEntities().registerRestriction(new MMOCoreTargetRestriction());
|
||||||
MythicLib.plugin.getModifiers().registerModifierType("attribute", configObject -> new AttributeModifier(configObject));
|
MythicLib.plugin.getModifiers().registerModifierType("attribute", configObject -> new AttributeModifier(configObject));
|
||||||
|
|
||||||
// Skill creation
|
// Custom scripts
|
||||||
MythicLib.plugin.getSkills().registerMechanic("mana", config -> new ManaMechanic(config));
|
MythicLib.plugin.getSkills().registerMechanic("mana", config -> new ManaMechanic(config));
|
||||||
MythicLib.plugin.getSkills().registerMechanic("stamina", config -> new StaminaMechanic(config));
|
MythicLib.plugin.getSkills().registerMechanic("stamina", config -> new StaminaMechanic(config));
|
||||||
MythicLib.plugin.getSkills().registerMechanic("stellium", config -> new StelliumMechanic(config));
|
MythicLib.plugin.getSkills().registerMechanic("stellium", config -> new StelliumMechanic(config));
|
||||||
MythicLib.plugin.getSkills().registerMechanic("experience", config -> new ExperienceMechanic(config));
|
MythicLib.plugin.getSkills().registerMechanic("mmocore_experience", config -> new ExperienceMechanic(config));
|
||||||
|
|
||||||
// Register extra objective, drop items...
|
// Register extra objective, drop items...
|
||||||
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null)
|
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null)
|
||||||
|
@ -1,81 +0,0 @@
|
|||||||
package net.Indyuce.mmocore.api;
|
|
||||||
|
|
||||||
import io.lumine.mythic.lib.MythicLib;
|
|
||||||
import io.lumine.mythic.lib.manager.StatManager;
|
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
|
||||||
import net.Indyuce.mmocore.api.player.PlayerActivity;
|
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
|
||||||
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import org.bukkit.attribute.Attribute;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
|
|
||||||
public class PlayerActionBar extends BukkitRunnable {
|
|
||||||
boolean initialized = false;
|
|
||||||
|
|
||||||
private ActionBarConfig config;
|
|
||||||
private DecimalFormat digit;
|
|
||||||
|
|
||||||
public void reload(ConfigurationSection cfg) {
|
|
||||||
config = new ActionBarConfig(cfg);
|
|
||||||
digit = MythicLib.plugin.getMMOConfig().newDecimalFormat(config.digit);
|
|
||||||
|
|
||||||
if (!initialized && config.enabled) {
|
|
||||||
runTaskTimer(MMOCore.plugin, 0, config.ticks);
|
|
||||||
initialized = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTimeOut() {
|
|
||||||
return config.timeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
for (PlayerData data : PlayerData.getAll())
|
|
||||||
if (data.isOnline() && !data.getPlayer().isDead() && !data.isCasting() && data.getActivityTimeOut(PlayerActivity.ACTION_BAR_MESSAGE) == 0) {
|
|
||||||
Placeholders holders=getActionBarPlaceholder(data);
|
|
||||||
data.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(
|
|
||||||
holders.apply(data.getPlayer(), data.getProfess().hasActionBar() ? data.getProfess().getActionBar() : config.format)));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Placeholders getActionBarPlaceholder(PlayerData data) {
|
|
||||||
Placeholders holders= new Placeholders();
|
|
||||||
holders.register("health", digit.format(data.getPlayer().getHealth()));
|
|
||||||
holders.register("max_health", StatManager.format("MAX_HEALTH", data.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()));
|
|
||||||
holders.register("mana_icon", data.getProfess().getManaDisplay().getIcon());
|
|
||||||
holders.register("mana", digit.format(data.getMana()));
|
|
||||||
holders.register("max_mana", StatManager.format("MAX_MANA", data.getStats().getStat("MAX_MANA")));
|
|
||||||
holders.register("stamina", digit.format(data.getStamina()));
|
|
||||||
holders.register("max_stamina", StatManager.format("MAX_STAMINA", data.getStats().getStat("MAX_STAMINA")));
|
|
||||||
holders.register("stellium", digit.format(data.getStellium()));
|
|
||||||
holders.register("max_stellium", StatManager.format("MAX_STELLIUM", data.getStats().getStat("MAX_STELLIUM")));
|
|
||||||
holders.register("class", data.getProfess().getName());
|
|
||||||
holders.register("xp", MythicLib.plugin.getMMOConfig().decimal.format(data.getExperience()));
|
|
||||||
holders.register("armor", StatManager.format("ARMOR", data.getPlayer().getAttribute(Attribute.GENERIC_ARMOR).getValue()));
|
|
||||||
holders.register("level", "" + data.getLevel());
|
|
||||||
holders.register("name", data.getPlayer().getDisplayName());
|
|
||||||
return holders;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static class ActionBarConfig {
|
|
||||||
private final boolean enabled;
|
|
||||||
private final int ticks, timeout;
|
|
||||||
private final String digit, format;
|
|
||||||
|
|
||||||
private ActionBarConfig(ConfigurationSection config) {
|
|
||||||
enabled = config.getBoolean("enabled", false);
|
|
||||||
timeout = config.getInt("", 60);
|
|
||||||
digit = config.getString("decimal", "0.#");
|
|
||||||
ticks = config.getInt("ticks-to-update", 5);
|
|
||||||
format = config.getString("format", "please format me :c");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -656,12 +656,12 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
final int x = getPlayer().getLocation().getBlockX();
|
final int x = getPlayer().getLocation().getBlockX();
|
||||||
final int y = getPlayer().getLocation().getBlockY();
|
final int y = getPlayer().getLocation().getBlockY();
|
||||||
final int z = getPlayer().getLocation().getBlockZ();
|
final int z = getPlayer().getLocation().getBlockZ();
|
||||||
|
final int warpTime = target.getWarpTime();
|
||||||
int t;
|
int t;
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!isOnline())
|
if (!isOnline() || getPlayer().getLocation().getBlockX() != x
|
||||||
return;
|
|| getPlayer().getLocation().getBlockY() != y
|
||||||
if (getPlayer().getLocation().getBlockX() != x || getPlayer().getLocation().getBlockY() != y
|
|
||||||
|| getPlayer().getLocation().getBlockZ() != z) {
|
|| getPlayer().getLocation().getBlockZ() != z) {
|
||||||
MMOCore.plugin.soundManager.getSound(SoundEvent.WARP_CANCELLED).playTo(getPlayer());
|
MMOCore.plugin.soundManager.getSound(SoundEvent.WARP_CANCELLED).playTo(getPlayer());
|
||||||
MMOCore.plugin.configManager.getSimpleMessage("warping-canceled").send(getPlayer());
|
MMOCore.plugin.configManager.getSimpleMessage("warping-canceled").send(getPlayer());
|
||||||
@ -670,8 +670,8 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MMOCore.plugin.configManager.getSimpleMessage("warping-comencing", "left", "" + ((MMOCore.plugin.configManager.waypointWarpTime + 20 - t) / 20)).send(getPlayer());
|
MMOCore.plugin.configManager.getSimpleMessage("warping-comencing", "left", String.valueOf((warpTime - t) / 20)).send(getPlayer());
|
||||||
if (t++ >= MMOCore.plugin.configManager.waypointWarpTime) {
|
if (t++ >= warpTime) {
|
||||||
getPlayer().teleport(target.getLocation());
|
getPlayer().teleport(target.getLocation());
|
||||||
getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20, 1, false, false));
|
getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20, 1, false, false));
|
||||||
MMOCore.plugin.soundManager.getSound(SoundEvent.WARP_TELEPORT).playTo(getPlayer());
|
MMOCore.plugin.soundManager.getSound(SoundEvent.WARP_TELEPORT).playTo(getPlayer());
|
||||||
@ -679,12 +679,14 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MMOCore.plugin.soundManager.getSound(SoundEvent.WARP_CHARGE).playTo(getPlayer(), 1, (float) (t / Math.PI * 1.5 / MMOCore.plugin.configManager.waypointWarpTime + .5));
|
MMOCore.plugin.soundManager.getSound(SoundEvent.WARP_CHARGE).playTo(getPlayer(), 1, (float) (.5 + t * 1.5 / warpTime));
|
||||||
double r = Math.sin((double) t / MMOCore.plugin.configManager.waypointWarpTime * Math.PI);
|
final double r = Math.sin((double) t / warpTime * Math.PI);
|
||||||
for (double j = 0; j < Math.PI * 2; j += Math.PI / 4)
|
for (double j = 0; j < Math.PI * 2; j += Math.PI / 4)
|
||||||
getPlayer().getLocation().getWorld().spawnParticle(Particle.REDSTONE,
|
getPlayer().getLocation().getWorld().spawnParticle(Particle.REDSTONE, getPlayer().getLocation().add(
|
||||||
getPlayer().getLocation().add(Math.cos((double) 5 * t / MMOCore.plugin.configManager.waypointWarpTime + j) * r, (double) 2 * t / MMOCore.plugin.configManager.waypointWarpTime, Math.sin((double) 5 * t / MMOCore.plugin.configManager.waypointWarpTime + j) * r), 1,
|
Math.cos((double) 5 * t / warpTime + j) * r,
|
||||||
new Particle.DustOptions(Color.PURPLE, 1.25f));
|
(double) 2 * t / warpTime,
|
||||||
|
Math.sin((double) 5 * t / warpTime + j) * r),
|
||||||
|
1, new Particle.DustOptions(Color.PURPLE, 1.25f));
|
||||||
}
|
}
|
||||||
}.runTaskTimer(MMOCore.plugin, 0, 1);
|
}.runTaskTimer(MMOCore.plugin, 0, 1);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package net.Indyuce.mmocore.api.player.attribute;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import io.lumine.mythic.lib.UtilityMethods;
|
||||||
import io.lumine.mythic.lib.api.player.EquipmentSlot;
|
import io.lumine.mythic.lib.api.player.EquipmentSlot;
|
||||||
import io.lumine.mythic.lib.player.modifier.Closeable;
|
import io.lumine.mythic.lib.player.modifier.Closeable;
|
||||||
import io.lumine.mythic.lib.player.modifier.ModifierSource;
|
import io.lumine.mythic.lib.player.modifier.ModifierSource;
|
||||||
@ -100,7 +101,12 @@ public class PlayerAttributes {
|
|||||||
return getInstance(attribute.getId());
|
return getInstance(attribute.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public int countSkillPoints() {
|
public int countSkillPoints() {
|
||||||
|
return countPoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int countPoints() {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
for (AttributeInstance ins : instances.values())
|
for (AttributeInstance ins : instances.values())
|
||||||
n += ins.getBase();
|
n += ins.getBase();
|
||||||
@ -110,11 +116,12 @@ public class PlayerAttributes {
|
|||||||
public class AttributeInstance {
|
public class AttributeInstance {
|
||||||
private int spent;
|
private int spent;
|
||||||
|
|
||||||
private final String id;
|
private final String id, enumName;
|
||||||
private final Map<String, AttributeModifier> map = new HashMap<>();
|
private final Map<String, AttributeModifier> map = new HashMap<>();
|
||||||
|
|
||||||
public AttributeInstance(String attribute) {
|
public AttributeInstance(String id) {
|
||||||
id = attribute;
|
this.id = id;
|
||||||
|
this.enumName = UtilityMethods.enumName(this.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBase() {
|
public int getBase() {
|
||||||
@ -146,10 +153,14 @@ public class PlayerAttributes {
|
|||||||
if (attr.getType() == ModifierType.FLAT)
|
if (attr.getType() == ModifierType.FLAT)
|
||||||
d += attr.getValue();
|
d += attr.getValue();
|
||||||
|
|
||||||
|
d += data.getMMOPlayerData().getStatMap().getStat("ADDITIONAL_" + enumName);
|
||||||
|
|
||||||
for (AttributeModifier attr : map.values())
|
for (AttributeModifier attr : map.values())
|
||||||
if (attr.getType() == ModifierType.RELATIVE)
|
if (attr.getType() == ModifierType.RELATIVE)
|
||||||
d *= attr.getValue();
|
d *= attr.getValue();
|
||||||
|
|
||||||
|
d *= 1 + data.getMMOPlayerData().getStatMap().getStat("ADDITIONAL_" + enumName + "_PERCENT") / 100;
|
||||||
|
|
||||||
// cast to int at the last moment
|
// cast to int at the last moment
|
||||||
return (int) d;
|
return (int) d;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package net.Indyuce.mmocore.comp.placeholder;
|
package net.Indyuce.mmocore.comp.placeholder;
|
||||||
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
|
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
|
||||||
import io.lumine.mythic.lib.MythicLib;
|
import io.lumine.mythic.lib.MythicLib;
|
||||||
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
public class PlaceholderAPIParser implements PlaceholderParser {
|
public class PlaceholderAPIParser implements PlaceholderParser {
|
||||||
public PlaceholderAPIParser() {
|
public PlaceholderAPIParser() {
|
||||||
@ -12,6 +11,6 @@ public class PlaceholderAPIParser implements PlaceholderParser {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String parse(OfflinePlayer player, String string) {
|
public String parse(OfflinePlayer player, String string) {
|
||||||
return MythicLib.plugin.parseColors(PlaceholderAPI.setPlaceholders(player, string.replace("%player%", player.getName())));
|
return MythicLib.plugin.parseColors(PlaceholderAPI.setPlaceholders(player, string));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ public class RPGPlaceholders extends PlaceholderExpansion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if (identifier.startsWith("profession_experience_"))
|
else if (identifier.startsWith("profession_experience_"))
|
||||||
return String.valueOf(
|
return MythicLib.plugin.getMMOConfig().decimal.format(
|
||||||
playerData.getCollectionSkills().getExperience(identifier.substring(22).replace(" ", "-").replace("_", "-").toLowerCase()));
|
playerData.getCollectionSkills().getExperience(identifier.substring(22).replace(" ", "-").replace("_", "-").toLowerCase()));
|
||||||
|
|
||||||
else if (identifier.startsWith("profession_next_level_"))
|
else if (identifier.startsWith("profession_next_level_"))
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package net.Indyuce.mmocore.experience.source;
|
package net.Indyuce.mmocore.experience.source;
|
||||||
|
|
||||||
|
import io.lumine.mythic.lib.MythicLib;
|
||||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||||
import io.lumine.mythic.lib.api.event.PlayerKillEntityEvent;
|
import io.lumine.mythic.lib.api.event.PlayerKillEntityEvent;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
|
|
||||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||||
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
|
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
|
||||||
|
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
|
||||||
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
|
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
@ -16,23 +17,30 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class KillMobExperienceSource extends SpecificExperienceSource<Entity> {
|
public class KillMobExperienceSource extends SpecificExperienceSource<Entity> {
|
||||||
public final EntityType type;
|
private final EntityType type;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private final String displayName;
|
||||||
|
|
||||||
public KillMobExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) {
|
public KillMobExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) {
|
||||||
super(dispenser, config);
|
super(dispenser, config);
|
||||||
|
|
||||||
config.validate("type");
|
config.validateKeys("type");
|
||||||
|
displayName = config.contains("name") ? MythicLib.plugin.parseColors(config.getString("name")) : null;
|
||||||
type = EntityType.valueOf(config.getString("type").toUpperCase().replace("-", "_").replace(" ", "_"));
|
type = EntityType.valueOf(config.getString("type").toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExperienceSourceManager<KillMobExperienceSource> newManager() {
|
public ExperienceSourceManager<KillMobExperienceSource> newManager() {
|
||||||
return new ExperienceSourceManager<KillMobExperienceSource>() {
|
return new ExperienceSourceManager<KillMobExperienceSource>() {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void a(PlayerKillEntityEvent event) {
|
public void a(PlayerKillEntityEvent event) {
|
||||||
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> {
|
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> {
|
||||||
if (event.getTarget().isDead() && !event.getTarget().getPersistentDataContainer().has(new NamespacedKey(MMOCore.plugin,"spawner_spawned"),PersistentDataType.STRING)) {
|
if (event.getTarget().isDead() && !event.getTarget().getPersistentDataContainer().has(new NamespacedKey(MMOCore.plugin, "spawner_spawned"), PersistentDataType.STRING)) {
|
||||||
PlayerData data = PlayerData.get(event.getPlayer());
|
PlayerData data = PlayerData.get(event.getPlayer());
|
||||||
|
|
||||||
for (KillMobExperienceSource source : getSources())
|
for (KillMobExperienceSource source : getSources())
|
||||||
@ -46,6 +54,6 @@ public class KillMobExperienceSource extends SpecificExperienceSource<Entity> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesParameter(PlayerData player, Entity obj) {
|
public boolean matchesParameter(PlayerData player, Entity obj) {
|
||||||
return obj.getType() == type;
|
return obj.getType() == type && (displayName == null || displayName.equals(obj.getCustomName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
|
|
||||||
public abstract class SpecificExperienceSource<T> extends ExperienceSource<T> {
|
public abstract class SpecificExperienceSource<T> extends ExperienceSource<T> {
|
||||||
private final RandomAmount amount;
|
private final RandomAmount amount;
|
||||||
double counter = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to register experience sources with SPECIFIC experience outputs.
|
* Used to register experience sources with SPECIFIC experience outputs.
|
||||||
@ -20,20 +19,21 @@ public abstract class SpecificExperienceSource<T> extends ExperienceSource<T> {
|
|||||||
public SpecificExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) {
|
public SpecificExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) {
|
||||||
super(dispenser);
|
super(dispenser);
|
||||||
|
|
||||||
config.validate("amount");
|
config.validateKeys("amount");
|
||||||
amount = new RandomAmount(config.getString("amount"));
|
amount = new RandomAmount(config.getString("amount"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for FromExperienceSource
|
* Used for FromExperienceSource
|
||||||
|
*
|
||||||
* @param dispenser
|
* @param dispenser
|
||||||
*/
|
*/
|
||||||
public SpecificExperienceSource(ExperienceDispenser dispenser) {
|
public SpecificExperienceSource(ExperienceDispenser dispenser) {
|
||||||
super(dispenser);
|
super(dispenser);
|
||||||
amount=new RandomAmount(0,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
amount = new RandomAmount(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
public RandomAmount getAmount() {
|
public RandomAmount getAmount() {
|
||||||
return amount;
|
return amount;
|
||||||
|
@ -31,7 +31,7 @@ public class AttributeView extends EditableInventory {
|
|||||||
Placeholders holders = new Placeholders();
|
Placeholders holders = new Placeholders();
|
||||||
holders.register("attribute_points", inv.getPlayerData().getAttributePoints());
|
holders.register("attribute_points", inv.getPlayerData().getAttributePoints());
|
||||||
holders.register("points", inv.getPlayerData().getAttributeReallocationPoints());
|
holders.register("points", inv.getPlayerData().getAttributeReallocationPoints());
|
||||||
holders.register("total", inv.getPlayerData().getAttributes().countSkillPoints());
|
holders.register("total", inv.getPlayerData().getAttributes().countPoints());
|
||||||
return holders;
|
return holders;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -93,7 +93,7 @@ public class AttributeView extends EditableInventory {
|
|||||||
public void whenClicked(InventoryClickContext context, InventoryItem item) {
|
public void whenClicked(InventoryClickContext context, InventoryItem item) {
|
||||||
|
|
||||||
if (item.getFunction().equalsIgnoreCase("reallocation")) {
|
if (item.getFunction().equalsIgnoreCase("reallocation")) {
|
||||||
int spent = playerData.getAttributes().countSkillPoints();
|
int spent = playerData.getAttributes().countPoints();
|
||||||
if (spent < 1) {
|
if (spent < 1) {
|
||||||
MMOCore.plugin.configManager.getSimpleMessage("no-attribute-points-spent").send(player);
|
MMOCore.plugin.configManager.getSimpleMessage("no-attribute-points-spent").send(player);
|
||||||
MMOCore.plugin.soundManager.getSound(SoundEvent.NOT_ENOUGH_POINTS).playTo(getPlayer());
|
MMOCore.plugin.soundManager.getSound(SoundEvent.NOT_ENOUGH_POINTS).playTo(getPlayer());
|
||||||
|
@ -19,15 +19,30 @@ public class Placeholders {
|
|||||||
// Remove conditions first
|
// Remove conditions first
|
||||||
str = removeCondition(str);
|
str = removeCondition(str);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For MMOCore not to loop on unparsable placeholders, it keeps
|
||||||
|
* track of the "last placeholder" parsed. The 'explored' string
|
||||||
|
* has NO parsed placeholder.
|
||||||
|
*/
|
||||||
|
String explored = str;
|
||||||
|
|
||||||
// Internal placeholders
|
// Internal placeholders
|
||||||
while (str.contains("{") && str.substring(str.indexOf("{")).contains("}")) {
|
while (explored.contains("{") && explored.substring(explored.indexOf("{")).contains("}")) {
|
||||||
String holder = str.substring(str.indexOf("{") + 1, str.indexOf("}"));
|
final int begin = explored.indexOf("{"), end = explored.indexOf("}");
|
||||||
|
final String holder = explored.substring(begin + 1, end);
|
||||||
@Nullable String found = placeholders.get(holder);
|
@Nullable String found = placeholders.get(holder);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Do NOT replace the placeholder unless a corresponding value has
|
||||||
|
* been found. This simple workaround fixes an issue with PAPI
|
||||||
|
* math expansions which interferes with MMOCore placeholders since
|
||||||
|
* it uses {....} as well.
|
||||||
|
*/
|
||||||
if (found != null)
|
if (found != null)
|
||||||
str = str.replace("{" + holder + "}", found);
|
str = str.replace("{" + holder + "}", found);
|
||||||
else
|
|
||||||
str = str.replace("{" + holder + "}", "PHE");
|
|
||||||
|
|
||||||
|
// Increase counter
|
||||||
|
explored = explored.substring(end + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// External placeholders
|
// External placeholders
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
package net.Indyuce.mmocore.manager;
|
||||||
|
|
||||||
|
import io.lumine.mythic.lib.MythicLib;
|
||||||
|
import io.lumine.mythic.lib.manager.StatManager;
|
||||||
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
|
import net.Indyuce.mmocore.api.player.PlayerActivity;
|
||||||
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
|
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
||||||
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import org.bukkit.attribute.Attribute;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class ActionBarManager extends BukkitRunnable {
|
||||||
|
private int updateTicks, timeOut;
|
||||||
|
private String barFormat;
|
||||||
|
private boolean enabled, scheduled;
|
||||||
|
|
||||||
|
public void reload(ConfigurationSection config) {
|
||||||
|
enabled = config.getBoolean("enabled", false);
|
||||||
|
timeOut = config.getInt("", 60);
|
||||||
|
updateTicks = config.getInt("ticks-to-update", 5);
|
||||||
|
barFormat = config.getString("format", "<No Action Bar Format Found>");
|
||||||
|
|
||||||
|
if (!scheduled && enabled) {
|
||||||
|
runTaskTimer(MMOCore.plugin, 0, updateTicks);
|
||||||
|
scheduled = true;
|
||||||
|
} else if (scheduled && !enabled) {
|
||||||
|
cancel();
|
||||||
|
scheduled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTimeOut() {
|
||||||
|
return timeOut;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for (PlayerData data : PlayerData.getAll())
|
||||||
|
if (data.isOnline() && !data.getPlayer().isDead() && !data.isCasting() && data.getActivityTimeOut(PlayerActivity.ACTION_BAR_MESSAGE) == 0) {
|
||||||
|
Placeholders holders = getActionBarPlaceholders(data);
|
||||||
|
data.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(
|
||||||
|
holders.apply(data.getPlayer(), data.getProfess().hasActionBar() ? data.getProfess().getActionBar() : barFormat)));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Placeholders getActionBarPlaceholders(PlayerData data) {
|
||||||
|
Placeholders holders = new Placeholders();
|
||||||
|
holders.register("health", StatManager.format("MAX_HEALTH", data.getPlayer().getHealth()));
|
||||||
|
holders.register("max_health", StatManager.format("MAX_HEALTH", data.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()));
|
||||||
|
holders.register("mana_icon", data.getProfess().getManaDisplay().getIcon());
|
||||||
|
holders.register("mana", StatManager.format("MAX_MANA", data.getMana()));
|
||||||
|
holders.register("max_mana", StatManager.format("MAX_MANA", data.getStats().getStat("MAX_MANA")));
|
||||||
|
holders.register("stamina", StatManager.format("MAX_STAMINA", data.getStamina()));
|
||||||
|
holders.register("max_stamina", StatManager.format("MAX_STAMINA", data.getStats().getStat("MAX_STAMINA")));
|
||||||
|
holders.register("stellium", StatManager.format("MAX_STELLIUM", data.getStellium()));
|
||||||
|
holders.register("max_stellium", StatManager.format("MAX_STELLIUM", data.getStats().getStat("MAX_STELLIUM")));
|
||||||
|
holders.register("class", data.getProfess().getName());
|
||||||
|
holders.register("xp", MythicLib.plugin.getMMOConfig().decimal.format(data.getExperience()));
|
||||||
|
holders.register("armor", StatManager.format("ARMOR", data.getPlayer().getAttribute(Attribute.GENERIC_ARMOR).getValue()));
|
||||||
|
holders.register("level", String.valueOf(data.getLevel()));
|
||||||
|
holders.register("name", data.getPlayer().getDisplayName());
|
||||||
|
return holders;
|
||||||
|
}
|
||||||
|
}
|
@ -8,10 +8,13 @@ import java.util.logging.Level;
|
|||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
|
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
|
||||||
import net.Indyuce.mmocore.api.ConfigFile;
|
import net.Indyuce.mmocore.api.ConfigFile;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class AttributeManager implements MMOCoreManager {
|
public class AttributeManager implements MMOCoreManager {
|
||||||
private final Map<String, PlayerAttribute> map = new HashMap<>();
|
private final Map<String, PlayerAttribute> map = new HashMap<>();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public PlayerAttribute get(String id) {
|
public PlayerAttribute get(String id) {
|
||||||
return map.get(id);
|
return map.get(id);
|
||||||
}
|
}
|
||||||
@ -20,6 +23,7 @@ public class AttributeManager implements MMOCoreManager {
|
|||||||
return map.containsKey(id);
|
return map.containsKey(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public Collection<PlayerAttribute> getAll() {
|
public Collection<PlayerAttribute> getAll() {
|
||||||
return map.values();
|
return map.values();
|
||||||
}
|
}
|
||||||
|
@ -74,12 +74,13 @@ public class ConfigManager {
|
|||||||
loadDefaultFile("expcurves", "levels.txt");
|
loadDefaultFile("expcurves", "levels.txt");
|
||||||
loadDefaultFile("expcurves", "mining.txt");
|
loadDefaultFile("expcurves", "mining.txt");
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
if(!new File(MMOCore.plugin.getDataFolder()+"/skilltree").exists()) {
|
if(!new File(MMOCore.plugin.getDataFolder()+"/skilltree").exists()) {
|
||||||
loadDefaultFile("skilltree","combat.yml");
|
loadDefaultFile("skilltree","combat.yml");
|
||||||
loadDefaultFile("skilltree","autocombat.yml");
|
loadDefaultFile("skilltree","autocombat.yml");
|
||||||
loadDefaultFile("skilltree","customcombat.yml");
|
loadDefaultFile("skilltree","customcombat.yml");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
loadDefaultFile("attributes.yml");
|
loadDefaultFile("attributes.yml");
|
||||||
loadDefaultFile("items.yml");
|
loadDefaultFile("items.yml");
|
||||||
loadDefaultFile("messages.yml");
|
loadDefaultFile("messages.yml");
|
||||||
@ -117,8 +118,8 @@ public class ConfigManager {
|
|||||||
canCreativeCast = MMOCore.plugin.getConfig().getBoolean("can-creative-cast");
|
canCreativeCast = MMOCore.plugin.getConfig().getBoolean("can-creative-cast");
|
||||||
cobbleGeneratorXP = MMOCore.plugin.getConfig().getBoolean("should-cobblestone-generators-give-exp");
|
cobbleGeneratorXP = MMOCore.plugin.getConfig().getBoolean("should-cobblestone-generators-give-exp");
|
||||||
saveDefaultClassInfo = MMOCore.plugin.getConfig().getBoolean("save-default-class-info");
|
saveDefaultClassInfo = MMOCore.plugin.getConfig().getBoolean("save-default-class-info");
|
||||||
maxBoundSkills= MMOCore.plugin.getConfig().getInt("max-bound-skills",6);
|
maxBoundSkills = MMOCore.plugin.getConfig().getInt("max-bound-skills", 6);
|
||||||
waypointWarpTime=MMOCore.plugin.getConfig().getInt("waypoint-warp-time",5);
|
overrideVanillaExp = MMOCore.plugin.getConfig().getBoolean("override-vanilla-exp");
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChatColor getColorOrDefault(String key, ChatColor defaultColor) {
|
private ChatColor getColorOrDefault(String key, ChatColor defaultColor) {
|
||||||
|
@ -3,12 +3,12 @@ package net.Indyuce.mmocore.manager;
|
|||||||
import io.lumine.mythic.lib.MythicLib;
|
import io.lumine.mythic.lib.MythicLib;
|
||||||
import io.lumine.mythic.lib.skill.handler.SkillHandler;
|
import io.lumine.mythic.lib.skill.handler.SkillHandler;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
|
import net.Indyuce.mmocore.api.ConfigFile;
|
||||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||||
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
||||||
import net.Indyuce.mmocore.skill.list.Sneaky_Picky;
|
|
||||||
import net.Indyuce.mmocore.api.ConfigFile;
|
|
||||||
import net.Indyuce.mmocore.skill.list.Ambers;
|
import net.Indyuce.mmocore.skill.list.Ambers;
|
||||||
import net.Indyuce.mmocore.skill.list.Neptune_Gift;
|
import net.Indyuce.mmocore.skill.list.Neptune_Gift;
|
||||||
|
import net.Indyuce.mmocore.skill.list.Sneaky_Picky;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@ -83,8 +83,12 @@ public class SkillManager implements MMOCoreManager {
|
|||||||
config.save();
|
config.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisteredSkill skill = new RegisteredSkill(handler, config.getConfig());
|
try {
|
||||||
|
final RegisteredSkill skill = new RegisteredSkill(handler, config.getConfig());
|
||||||
this.skills.put(handler.getId(), skill);
|
this.skills.put(handler.getId(), skill);
|
||||||
|
} catch (RuntimeException exception) {
|
||||||
|
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load skill '" + handler.getId() + "': " + exception.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.Indyuce.mmocore.manager;
|
package net.Indyuce.mmocore.manager;
|
||||||
|
|
||||||
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.ConfigFile;
|
import net.Indyuce.mmocore.api.ConfigFile;
|
||||||
import net.Indyuce.mmocore.api.SoundEvent;
|
import net.Indyuce.mmocore.api.SoundEvent;
|
||||||
import net.Indyuce.mmocore.api.SoundObject;
|
import net.Indyuce.mmocore.api.SoundObject;
|
||||||
@ -9,6 +10,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class SoundManager implements MMOCoreManager {
|
public class SoundManager implements MMOCoreManager {
|
||||||
private final Map<SoundEvent, SoundObject> sounds = new HashMap<>();
|
private final Map<SoundEvent, SoundObject> sounds = new HashMap<>();
|
||||||
@ -25,6 +27,10 @@ public class SoundManager implements MMOCoreManager {
|
|||||||
|
|
||||||
FileConfiguration config = new ConfigFile("sounds").getConfig();
|
FileConfiguration config = new ConfigFile("sounds").getConfig();
|
||||||
for (SoundEvent sound : SoundEvent.values())
|
for (SoundEvent sound : SoundEvent.values())
|
||||||
|
try {
|
||||||
sounds.put(sound, new SoundObject(config.getString(sound.name().replace("_", "-").toLowerCase())));
|
sounds.put(sound, new SoundObject(config.getString(sound.name().replace("_", "-").toLowerCase())));
|
||||||
|
} catch (RuntimeException exception) {
|
||||||
|
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load sound for '" + sound.name() + "': " + exception.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,22 @@ public class MySQLDataProvider extends MMODataSource implements DataProvider {
|
|||||||
executeUpdateAsync(
|
executeUpdateAsync(
|
||||||
"CREATE TABLE IF NOT EXISTS mmocore_playerdata(uuid VARCHAR(36),class_points "
|
"CREATE TABLE IF NOT EXISTS mmocore_playerdata(uuid VARCHAR(36),class_points "
|
||||||
+ "INT(11) DEFAULT 0,skill_points INT(11) DEFAULT 0,attribute_points INT(11) "
|
+ "INT(11) DEFAULT 0,skill_points INT(11) DEFAULT 0,attribute_points INT(11) "
|
||||||
+ "DEFAULT 0,attribute_realloc_points INT(11) DEFAULT 0,level INT(11) DEFAULT 1,"
|
+ "DEFAULT 0,attribute_realloc_points INT(11) DEFAULT 0,skill_reallocation_points INT(11) DEFAULT 0,level INT(11) DEFAULT 1,"
|
||||||
+ "experience INT(11) DEFAULT 0,class VARCHAR(20),guild VARCHAR(20),last_login LONG,"
|
+ "experience INT(11) DEFAULT 0,class VARCHAR(20),guild VARCHAR(20),last_login LONG,"
|
||||||
+ "attributes LONGTEXT,professions LONGTEXT,times_claimed LONGTEXT,quests LONGTEXT,"
|
+ "attributes LONGTEXT,professions LONGTEXT,times_claimed LONGTEXT,quests LONGTEXT,"
|
||||||
+ "waypoints LONGTEXT,friends LONGTEXT,skills LONGTEXT,bound_skills LONGTEXT,"
|
+ "waypoints LONGTEXT,friends LONGTEXT,skills LONGTEXT,bound_skills LONGTEXT,"
|
||||||
+ "class_info LONGTEXT, is_saved TINYINT, PRIMARY KEY (uuid));");
|
+ "class_info LONGTEXT, is_saved TINYINT, PRIMARY KEY (uuid));");
|
||||||
|
|
||||||
|
// Add 'skill_reallocation_points' if it doesn't exist
|
||||||
|
getResultAsync("SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = 'mmocore_playerdata' AND COLUMN_NAME = 'skill_reallocation_points'", result -> {
|
||||||
|
try {
|
||||||
|
if (!result.next())
|
||||||
|
executeUpdateAsync("ALTER TABLE mmocore_playerdata ADD COLUMN skill_reallocation_points INT(11) DEFAULT 0");
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Add 'times_claimed' if it doesn't exist
|
// Add 'times_claimed' if it doesn't exist
|
||||||
getResultAsync("SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = 'mmocore_playerdata' AND COLUMN_NAME = 'times_claimed'", result -> {
|
getResultAsync("SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = 'mmocore_playerdata' AND COLUMN_NAME = 'times_claimed'", result -> {
|
||||||
try {
|
try {
|
||||||
|
@ -1,23 +1,22 @@
|
|||||||
package net.Indyuce.mmocore.manager.data.mysql;
|
package net.Indyuce.mmocore.manager.data.mysql;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
|
|
||||||
public class MySQLTableEditor {
|
public class MySQLTableEditor {
|
||||||
private final Table table;
|
private final Table table;
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
|
|
||||||
private final MySQLDataProvider provider;
|
private final MySQLDataProvider provider;
|
||||||
|
|
||||||
public MySQLTableEditor(Table table, UUID uuid,MySQLDataProvider provider) {
|
public MySQLTableEditor(Table table, UUID uuid, MySQLDataProvider provider) {
|
||||||
this.table = table;
|
this.table = table;
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.provider=provider;
|
this.provider = provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateData(String key, Object value) {
|
public void updateData(String key, Object value) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package net.Indyuce.mmocore.skill.cast.listener;
|
package net.Indyuce.mmocore.skill.cast.listener;
|
||||||
|
|
||||||
import io.lumine.mythic.lib.MythicLib;
|
|
||||||
import io.lumine.mythic.lib.UtilityMethods;
|
import io.lumine.mythic.lib.UtilityMethods;
|
||||||
import io.lumine.mythic.lib.api.event.skill.PlayerCastSkillEvent;
|
import io.lumine.mythic.lib.api.event.skill.PlayerCastSkillEvent;
|
||||||
import io.lumine.mythic.lib.api.player.EquipmentSlot;
|
import io.lumine.mythic.lib.api.player.EquipmentSlot;
|
||||||
@ -8,15 +7,14 @@ import io.lumine.mythic.lib.player.PlayerMetadata;
|
|||||||
import io.lumine.mythic.lib.skill.trigger.TriggerMetadata;
|
import io.lumine.mythic.lib.skill.trigger.TriggerMetadata;
|
||||||
import io.lumine.mythic.lib.skill.trigger.TriggerType;
|
import io.lumine.mythic.lib.skill.trigger.TriggerType;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
|
import net.Indyuce.mmocore.api.SoundObject;
|
||||||
import net.Indyuce.mmocore.api.event.PlayerKeyPressEvent;
|
import net.Indyuce.mmocore.api.event.PlayerKeyPressEvent;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
||||||
import net.Indyuce.mmocore.skill.cast.PlayerKey;
|
|
||||||
import net.Indyuce.mmocore.api.SoundObject;
|
|
||||||
import net.Indyuce.mmocore.skill.cast.KeyCombo;
|
import net.Indyuce.mmocore.skill.cast.KeyCombo;
|
||||||
|
import net.Indyuce.mmocore.skill.cast.PlayerKey;
|
||||||
import net.Indyuce.mmocore.skill.cast.SkillCastingHandler;
|
import net.Indyuce.mmocore.skill.cast.SkillCastingHandler;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -34,15 +32,18 @@ public class KeyCombos implements Listener {
|
|||||||
* hash code method
|
* hash code method
|
||||||
*/
|
*/
|
||||||
private final Map<KeyCombo, Integer> combos = new HashMap<>();
|
private final Map<KeyCombo, Integer> combos = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All the keys that are at the start of a combo.
|
* All the keys that are at the start of a combo.
|
||||||
*/
|
*/
|
||||||
private final Set<PlayerKey> firstComboKeys = new HashSet<>();
|
private final Set<PlayerKey> firstComboKeys = new HashSet<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Key players need to press to start a combo
|
* Key players need to press to start a combo. If it's set to
|
||||||
|
* null then the player can press any key which starts a combo.
|
||||||
|
* These "starting keys" are saved in {@link #firstComboKeys}
|
||||||
*/
|
*/
|
||||||
private final boolean needsInitializerKey;
|
@Nullable
|
||||||
private final PlayerKey initializerKey;
|
private final PlayerKey initializerKey;
|
||||||
private final int longestCombo;
|
private final int longestCombo;
|
||||||
|
|
||||||
@ -58,9 +59,8 @@ public class KeyCombos implements Listener {
|
|||||||
|
|
||||||
public KeyCombos(ConfigurationSection config) {
|
public KeyCombos(ConfigurationSection config) {
|
||||||
|
|
||||||
int longestCombo = 0;
|
|
||||||
|
|
||||||
// Load different combos
|
// Load different combos
|
||||||
|
int currentLongestCombo = 0;
|
||||||
for (String key : config.getConfigurationSection("combos").getKeys(false))
|
for (String key : config.getConfigurationSection("combos").getKeys(false))
|
||||||
try {
|
try {
|
||||||
int spellSlot = Integer.valueOf(key);
|
int spellSlot = Integer.valueOf(key);
|
||||||
@ -72,12 +72,12 @@ public class KeyCombos implements Listener {
|
|||||||
|
|
||||||
combos.put(combo, spellSlot);
|
combos.put(combo, spellSlot);
|
||||||
firstComboKeys.add(combo.getAt(0));
|
firstComboKeys.add(combo.getAt(0));
|
||||||
longestCombo = Math.max(longestCombo, combo.countKeys());
|
currentLongestCombo = Math.max(currentLongestCombo, combo.countKeys());
|
||||||
} catch (RuntimeException exception) {
|
} catch (RuntimeException exception) {
|
||||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load key combo '" + key + "': " + exception.getMessage());
|
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load key combo '" + key + "': " + exception.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.longestCombo = longestCombo;
|
this.longestCombo = currentLongestCombo;
|
||||||
|
|
||||||
// Load player key names
|
// Load player key names
|
||||||
actionBarOptions = config.contains("action-bar") ? new ActionBarOptions(config.getConfigurationSection("action-bar")) : null;
|
actionBarOptions = config.contains("action-bar") ? new ActionBarOptions(config.getConfigurationSection("action-bar")) : null;
|
||||||
@ -87,13 +87,9 @@ public class KeyCombos implements Listener {
|
|||||||
comboClickSound = config.contains("sound.combo-key") ? new SoundObject(config.getConfigurationSection("sound.combo-key")) : null;
|
comboClickSound = config.contains("sound.combo-key") ? new SoundObject(config.getConfigurationSection("sound.combo-key")) : null;
|
||||||
failComboSound = config.contains("sound.fail-combo") ? new SoundObject(config.getConfigurationSection("sound.fail-combo")) : null;
|
failComboSound = config.contains("sound.fail-combo") ? new SoundObject(config.getConfigurationSection("sound.fail-combo")) : null;
|
||||||
|
|
||||||
needsInitializerKey = config.getBoolean("needs-initializer-key", true);
|
|
||||||
|
|
||||||
|
|
||||||
// Find initializer key
|
// Find initializer key
|
||||||
initializerKey = needsInitializerKey ? PlayerKey.valueOf(UtilityMethods.enumName(Objects.requireNonNull(
|
initializerKey = config.contains("initializer-key") ? PlayerKey.valueOf(UtilityMethods.enumName(Objects.requireNonNull(
|
||||||
config.getString("initializer-key"), "Could not find initializer key"))) : null;
|
config.getString("initializer-key"), "Could not find initializer key"))) : null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -102,7 +98,7 @@ public class KeyCombos implements Listener {
|
|||||||
Player player = playerData.getPlayer();
|
Player player = playerData.getPlayer();
|
||||||
|
|
||||||
if (!event.getData().isCasting()) {
|
if (!event.getData().isCasting()) {
|
||||||
if (needsInitializerKey) {
|
if (initializerKey != null) {
|
||||||
if (event.getPressed() == initializerKey) {
|
if (event.getPressed() == initializerKey) {
|
||||||
|
|
||||||
// Always cancel event
|
// Always cancel event
|
||||||
@ -122,7 +118,7 @@ public class KeyCombos implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
// Start combo
|
// Start combo
|
||||||
CustomSkillCastingHandler casting =new CustomSkillCastingHandler(playerData);
|
CustomSkillCastingHandler casting = new CustomSkillCastingHandler(playerData);
|
||||||
playerData.setSkillCasting(casting);
|
playerData.setSkillCasting(casting);
|
||||||
casting.current.registerKey(event.getPressed());
|
casting.current.registerKey(event.getPressed());
|
||||||
if (beginComboSound != null)
|
if (beginComboSound != null)
|
||||||
@ -132,7 +128,6 @@ public class KeyCombos implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Adding pressed key
|
// Adding pressed key
|
||||||
CustomSkillCastingHandler casting = (CustomSkillCastingHandler) playerData.getSkillCasting();
|
CustomSkillCastingHandler casting = (CustomSkillCastingHandler) playerData.getSkillCasting();
|
||||||
casting.current.registerKey(event.getPressed());
|
casting.current.registerKey(event.getPressed());
|
||||||
@ -243,7 +238,7 @@ public class KeyCombos implements Listener {
|
|||||||
|
|
||||||
public String format(CustomSkillCastingHandler casting) {
|
public String format(CustomSkillCastingHandler casting) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
Placeholders holders = MMOCore.plugin.actionBarManager.getActionBarPlaceholder(casting.getCaster());
|
Placeholders holders = MMOCore.plugin.actionBarManager.getActionBarPlaceholders(casting.getCaster());
|
||||||
|
|
||||||
builder.append(prefix);
|
builder.append(prefix);
|
||||||
// Join all keys with separator
|
// Join all keys with separator
|
||||||
|
@ -23,6 +23,7 @@ public class Waypoint extends PostLoadObject implements Unlockable {
|
|||||||
private final Location loc;
|
private final Location loc;
|
||||||
private final List<String> lore;
|
private final List<String> lore;
|
||||||
private final double radiusSquared;
|
private final double radiusSquared;
|
||||||
|
private final int warpTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set that saves all the waypoints accessible when in this waypoint.
|
* Set that saves all the waypoints accessible when in this waypoint.
|
||||||
@ -48,6 +49,7 @@ public class Waypoint extends PostLoadObject implements Unlockable {
|
|||||||
|
|
||||||
loc = readLocation(Objects.requireNonNull(config.getString("location"), "Could not read location"));
|
loc = readLocation(Objects.requireNonNull(config.getString("location"), "Could not read location"));
|
||||||
radiusSquared = Math.pow(config.getDouble("radius"), 2);
|
radiusSquared = Math.pow(config.getDouble("radius"), 2);
|
||||||
|
warpTime = config.getInt("warp-time", 100);
|
||||||
|
|
||||||
dynamicCost = config.getDouble("cost.dynamic-use");
|
dynamicCost = config.getDouble("cost.dynamic-use");
|
||||||
normalCost = config.getDouble("cost.normal-use");
|
normalCost = config.getDouble("cost.normal-use");
|
||||||
@ -95,10 +97,17 @@ public class Waypoint extends PostLoadObject implements Unlockable {
|
|||||||
return loc;
|
return loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getWarpTime() {
|
||||||
|
return warpTime;
|
||||||
|
}
|
||||||
|
|
||||||
public double getDynamicCost() {
|
public double getDynamicCost() {
|
||||||
return dynamicCost;
|
return dynamicCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Not implemented yet
|
||||||
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public double getSetSpawnCost() {
|
public double getSetSpawnCost() {
|
||||||
return setSpawnCost;
|
return setSpawnCost;
|
||||||
|
@ -16,7 +16,7 @@ public class MMOCoreBukkit {
|
|||||||
* all the listeners required for MMOCore to run
|
* all the listeners required for MMOCore to run
|
||||||
*/
|
*/
|
||||||
public MMOCoreBukkit(MMOCore plugin) {
|
public MMOCoreBukkit(MMOCore plugin) {
|
||||||
if (plugin.configManager.overrideVanillaExp = plugin.getConfig().getBoolean("override-vanilla-exp"))
|
if (plugin.configManager.overrideVanillaExp)
|
||||||
Bukkit.getPluginManager().registerEvents(new VanillaExperienceOverride(), plugin);
|
Bukkit.getPluginManager().registerEvents(new VanillaExperienceOverride(), plugin);
|
||||||
|
|
||||||
if (plugin.getConfig().getBoolean("hotbar-swapping.enabled"))
|
if (plugin.getConfig().getBoolean("hotbar-swapping.enabled"))
|
||||||
|
@ -114,11 +114,8 @@ action-bar:
|
|||||||
# (This doesn't change any other action bars provided by MMOCore.)
|
# (This doesn't change any other action bars provided by MMOCore.)
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
# The decimal format for stats (not including stat formats in stats.yml)
|
# The amount of milliseconds the bar will be
|
||||||
decimal: "0.#"
|
# faded out when displaying other action bars.
|
||||||
|
|
||||||
# The amount of miliseconds the bar will be faded
|
|
||||||
#out when displaying other action bars.
|
|
||||||
time-out: 60
|
time-out: 60
|
||||||
|
|
||||||
# The amount of ticks before updating the info
|
# The amount of ticks before updating the info
|
||||||
|
2
pom.xml
2
pom.xml
@ -16,7 +16,7 @@
|
|||||||
<description>Offer your players a brand new RPG experience!!</description>
|
<description>Offer your players a brand new RPG experience!!</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<revision>1.9.5-SNAPSHOT</revision>
|
<revision>1.10.1-SNAPSHOT</revision>
|
||||||
<downloadSources>false</downloadSources>
|
<downloadSources>false</downloadSources>
|
||||||
<downloadJavadocs>false</downloadJavadocs>
|
<downloadJavadocs>false</downloadJavadocs>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
Loading…
Reference in New Issue
Block a user