forked from Upstream/mmocore
> MMOCore 1.6 - API Handling Rewrite
REQUIRES MMOLIB 1.7!!! - Rewrote MMOLib compatibility API (MMOLib is still a dependency!) - Lootsplosions are now a part of MMOItems.
This commit is contained in:
parent
7b53c18dd4
commit
30452a3cd8
62
pom.xml
62
pom.xml
@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.Indyuce</groupId>
|
||||
<artifactId>MMOCore</artifactId>
|
||||
<version>1.5</version>
|
||||
<version>1.6</version>
|
||||
<name>MMOCore</name>
|
||||
<description>Offer your players a brand new RPG experience.</description>
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
@ -57,6 +58,14 @@
|
||||
<shadedPattern>net.indyuce.mmocore.shaded.paperlib</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>net/mmogroup/**</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
@ -67,32 +76,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>properties-maven-plugin</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>initialize</phase>
|
||||
<goals>
|
||||
<goal>read-project-properties</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<files>
|
||||
<file>../build.properties</file>
|
||||
</files>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<configuration>
|
||||
<outputDirectory>${jar.path}</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
@ -114,23 +97,6 @@
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
|
||||
<!-- MMOs -->
|
||||
<dependency>
|
||||
<groupId>net.Indyuce</groupId>
|
||||
<artifactId>mmoitems</artifactId>
|
||||
<version>6.1.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/MMOItems.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.mmogroup</groupId>
|
||||
<artifactId>MMOLib</artifactId>
|
||||
<version>1.5</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/MMOLib.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<!-- Minecraft -->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
@ -140,6 +106,14 @@
|
||||
<systemPath>${basedir}/lib/spigot.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<!-- MMOs -->
|
||||
<dependency>
|
||||
<groupId>net.Indyuce</groupId>
|
||||
<artifactId>MMOLib</artifactId>
|
||||
<version>1.6</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- APIs -->
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
|
@ -306,7 +306,7 @@ public class MMOCore extends JavaPlugin {
|
||||
* that after registering all the professses otherwise the player datas can't
|
||||
* recognize what profess the player has and professes will be lost
|
||||
*/
|
||||
Bukkit.getOnlinePlayers().forEach(player -> dataProvider.getDataManager().setup(player));
|
||||
Bukkit.getOnlinePlayers().forEach(player -> dataProvider.getDataManager().setup(player.getUniqueId()));
|
||||
|
||||
/*
|
||||
* load guild data after loading player data
|
||||
|
@ -21,7 +21,7 @@ public class PlayerActionBar extends BukkitRunnable {
|
||||
|
||||
public void reload(ConfigurationSection cfg) {
|
||||
config = new ActionBarConfig(cfg);
|
||||
digit = new DecimalFormat(config.digit, MMOCore.plugin.configManager.formatSymbols);
|
||||
digit = new DecimalFormat(config.digit, MMOLib.plugin.getMMOConfig().formatSymbols);
|
||||
|
||||
if(!initialized && config.enabled) {
|
||||
runTaskTimer(MMOCore.plugin, 0, config.ticks);
|
||||
|
@ -1,30 +1,29 @@
|
||||
package net.Indyuce.mmocore.api.droptable.condition;
|
||||
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.mmogroup.mmolib.api.MMOLineConfig;
|
||||
import net.mmogroup.mmolib.api.player.MMOPlayerData;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LevelCondition extends Condition {
|
||||
private final int amount;
|
||||
private final int amount;
|
||||
|
||||
private final String profession;
|
||||
private final String profession;
|
||||
|
||||
public LevelCondition(MMOLineConfig config) {
|
||||
super(config);
|
||||
public LevelCondition(MMOLineConfig config) {
|
||||
super(config);
|
||||
|
||||
config.validate("amount");
|
||||
config.validate("amount");
|
||||
|
||||
amount = config.getInt("amount");
|
||||
profession = config.contains("profession") ? config.getString("profession") : null;
|
||||
}
|
||||
amount = config.getInt("amount");
|
||||
profession = config.contains("profession") ? config.getString("profession") : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMet(ConditionInstance entity) {
|
||||
if (entity.getEntity() instanceof Player) {
|
||||
int level = (profession != null) ? MMOPlayerData.get((Player) entity.getEntity()).getMMOCore().getCollectionSkills().getLevel(profession)
|
||||
: MMOPlayerData.get((Player) entity.getEntity()).getMMOCore().getLevel();
|
||||
return level >= amount;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isMet(ConditionInstance entity) {
|
||||
if (entity.getEntity() instanceof Player) {
|
||||
int level = (profession != null) ? PlayerData.get(entity.getEntity().getUniqueId()).getCollectionSkills().getLevel(profession) : PlayerData.get(entity.getEntity().getUniqueId()).getLevel();
|
||||
return level >= amount;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -184,6 +185,6 @@ public class PlayerProfessions {
|
||||
bar.append(j == chars ? "" + ChatColor.WHITE + ChatColor.BOLD : "").append("|");
|
||||
if(playerData.isOnline())
|
||||
MMOCore.plugin.configManager.getSimpleMessage("exp-notification", "profession", profession.getName(), "progress", bar.toString(), "ratio",
|
||||
MMOCore.plugin.configManager.decimal.format((double) exp / needed * 100)).send(playerData.getPlayer());
|
||||
MMOLib.plugin.getMMOConfig().decimal.format((double) exp / needed * 100)).send(playerData.getPlayer());
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,6 @@ public class PlayerData extends OfflinePlayerData {
|
||||
|
||||
public PlayerData(MMOPlayerData mmoData) {
|
||||
super(mmoData.getUniqueId());
|
||||
mmoData.setMMOCore(this);
|
||||
|
||||
this.mmoData = mmoData;
|
||||
this.playerStats = new PlayerStats(this);
|
||||
@ -116,8 +115,6 @@ public class PlayerData extends OfflinePlayerData {
|
||||
super(UUID.randomUUID());
|
||||
|
||||
mmoData = new MMOPlayerData(null, null);
|
||||
mmoData.setMMOCore(this);
|
||||
|
||||
playerStats = new PlayerStats(this);
|
||||
questData = new PlayerQuests(this, null);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class AttackEventTrigger implements EventTriggerHandler {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void a(PlayerAttackEvent event) {
|
||||
PlayerData player = event.getData().getMMOCore();
|
||||
PlayerData player = PlayerData.get(event.getData().getUniqueId());
|
||||
PlayerClass profess = player.getProfess();
|
||||
|
||||
for (DamageType type : event.getAttack().getTypes()) {
|
||||
|
@ -1,13 +1,13 @@
|
||||
package net.Indyuce.mmocore.api.player.stats;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.ConfigFile;
|
||||
import net.Indyuce.mmocore.api.experience.Profession;
|
||||
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public enum StatType {
|
||||
|
||||
@ -51,7 +51,7 @@ public enum StatType {
|
||||
PROJECTILE_DAMAGE,
|
||||
WEAPON_DAMAGE,
|
||||
SKILL_DAMAGE,
|
||||
|
||||
|
||||
PVP_DAMAGE,
|
||||
PVE_DAMAGE,
|
||||
|
||||
@ -124,7 +124,7 @@ public enum StatType {
|
||||
FileConfiguration config = new ConfigFile("stats").getConfig();
|
||||
for (StatType stat : values()) {
|
||||
stat.defaultInfo = config.contains("default." + stat.name()) ? new LinearValue(config.getConfigurationSection("default." + stat.name())) : new LinearValue(0, 0);
|
||||
stat.format = MMOCore.plugin.configManager.newFormat(config.contains("decimal-format." + stat.name()) ? config.getString("decimal-format." + stat.name()) : "0.#");
|
||||
stat.format = MMOLib.plugin.getMMOConfig().newFormat(config.contains("decimal-format." + stat.name()) ? config.getString("decimal-format." + stat.name()) : "0.#");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
package net.Indyuce.mmocore.api.util.math.formula;
|
||||
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
|
||||
public class LinearValue {
|
||||
private final double base, perLevel, min, max;
|
||||
private final boolean hasmin, hasmax;
|
||||
@ -75,17 +74,15 @@ public class LinearValue {
|
||||
}
|
||||
|
||||
public String getDisplay(int level) {
|
||||
return MMOCore.plugin.configManager.decimals.format(calculate(level));
|
||||
return MMOLib.plugin.getMMOConfig().decimals.format(calculate(level));
|
||||
}
|
||||
|
||||
public double calculate(int level) {
|
||||
double value = base + perLevel * (level - 1);
|
||||
|
||||
if (hasmin)
|
||||
value = Math.max(min, value);
|
||||
if (hasmin) value = Math.max(min, value);
|
||||
|
||||
if (hasmax)
|
||||
value = Math.min(max, value);
|
||||
if (hasmax) value = Math.min(max, value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class ListCommandTreeNode extends CommandTreeNode {
|
||||
for (Booster booster : MMOCore.plugin.boosterManager.getBoosters())
|
||||
if (!booster.isTimedOut())
|
||||
MMOLib.plugin.getVersion().getWrapper().sendJson((Player) sender, "{\"text\":\"" + ChatColor.YELLOW + "- " + ChatColor.GOLD
|
||||
+ MMOCore.plugin.configManager.decimal.format((1 + booster.getExtra())) + "x" + ChatColor.YELLOW + " Booster - "
|
||||
+ MMOLib.plugin.getMMOConfig().decimal.format((1 + booster.getExtra())) + "x" + ChatColor.YELLOW + " Booster - "
|
||||
+ ChatColor.GOLD + (!booster.hasProfession() ? "ExploreAttributesCommand" : booster.getProfession().getName())
|
||||
+ ChatColor.YELLOW + " - " + ChatColor.GOLD
|
||||
+ new DelayFormat().format(booster.getCreationDate() + booster.getLength() - System.currentTimeMillis())
|
||||
|
@ -1,32 +0,0 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
|
||||
public class LootColor extends BukkitRunnable {
|
||||
private final Item item;
|
||||
private final Color color;
|
||||
|
||||
private int j = 0;
|
||||
|
||||
public LootColor(Item item, Color color) {
|
||||
this.item = item;
|
||||
this.color = color;
|
||||
|
||||
runTaskTimer(MMOCore.plugin, 0, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (j++ > 100 || item.isDead() || item.isOnGround()) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
item.getWorld().spawnParticle(Particle.REDSTONE, item.getLocation(), 1, new Particle.DustOptions(color, 1.3f));
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.ItemTier;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.item.NBTItem;
|
||||
|
||||
public class Lootsplosion implements Listener {
|
||||
private static final Random random = new Random();
|
||||
|
||||
private final boolean colored;
|
||||
|
||||
public Lootsplosion() {
|
||||
colored = Bukkit.getPluginManager().getPlugin("MMOItems") != null && MMOCore.plugin.getConfig().getBoolean("lootsplosion.mmoitems-color");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void b(MythicMobDeathEvent event) {
|
||||
if (event.getMob().getVariables().has("Lootsplosion"))
|
||||
new LootsplosionHandler(event);
|
||||
}
|
||||
|
||||
public class LootsplosionHandler implements Listener {
|
||||
|
||||
private final List<ItemStack> drops;
|
||||
|
||||
/*
|
||||
* Y coordinate offset so the velocity is not directly negated when the
|
||||
* item spawns on the ground
|
||||
*/
|
||||
private final double offset;
|
||||
|
||||
public LootsplosionHandler(MythicMobDeathEvent event) {
|
||||
offset = event.getEntity().getHeight() / 2;
|
||||
drops = new ArrayList<>(event.getDrops());
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(this, MMOCore.plugin);
|
||||
}
|
||||
|
||||
private void close() {
|
||||
ItemSpawnEvent.getHandlerList().unregister(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(ItemSpawnEvent event) {
|
||||
Item item = event.getEntity();
|
||||
if (!drops.contains(item.getItemStack())) {
|
||||
close();
|
||||
return;
|
||||
}
|
||||
|
||||
drops.remove(item.getItemStack());
|
||||
item.teleport(item.getLocation().add(0, offset, 0));
|
||||
item.setVelocity(randomVector());
|
||||
|
||||
if (colored)
|
||||
Bukkit.getScheduler().runTask(MMOCore.plugin, () -> {
|
||||
NBTItem nbt = MMOLib.plugin.getVersion().getWrapper().getNBTItem(item.getItemStack());
|
||||
if (nbt.hasTag("MMOITEMS_TIER")) {
|
||||
ItemTier tier = MMOItems.plugin.getTiers().get(nbt.getString("MMOITEMS_TIER"));
|
||||
if (tier.hasColor())
|
||||
new LootColor(item, tier.getColor().toBukkit());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Vector randomVector() {
|
||||
double offset = MMOCore.plugin.getConfig().getDouble("lootsplosion.offset"),
|
||||
height = MMOCore.plugin.getConfig().getDouble("lootsplosion.height");
|
||||
return new Vector(Math.cos(random.nextDouble() * Math.PI * 2) * offset, height, Math.sin(random.nextDouble() * Math.PI * 2) * offset);
|
||||
}
|
||||
}
|
@ -1,22 +1,17 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import io.lumine.xikage.mythicmobs.MythicMobs;
|
||||
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicDropLoadEvent;
|
||||
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicReloadedEvent;
|
||||
import io.lumine.xikage.mythicmobs.skills.placeholders.Placeholder;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.comp.mythicmobs.load.CurrencyItemDrop;
|
||||
import net.Indyuce.mmocore.comp.mythicmobs.load.GoldPouchDrop;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class MythicMobsDrops implements Listener {
|
||||
public MythicMobsDrops() {
|
||||
if (MMOCore.plugin.getConfig().getBoolean("lootsplosion.enabled"))
|
||||
Bukkit.getPluginManager().registerEvents(new Lootsplosion(), MMOCore.plugin);
|
||||
registerPlaceholders();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs.skill.handlers;
|
||||
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicMobSkill;
|
||||
@ -17,6 +18,6 @@ public class PlayerAttackSkillHandler extends PassiveMythicMobSkillHandler {
|
||||
|
||||
@EventHandler
|
||||
private void event(PlayerAttackEvent e) {
|
||||
castSkill(e.getData().getMMOCore(), e.getEntity());
|
||||
castSkill(PlayerData.get(e.getData().getUniqueId()), e.getEntity());
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import net.Indyuce.mmocore.api.experience.Profession;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.stats.StatType;
|
||||
import net.Indyuce.mmocore.api.quest.PlayerQuests;
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import net.mmogroup.mmolib.api.util.AltChar;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -55,7 +56,7 @@ public class RPGPlaceholders extends PlaceholderExpansion {
|
||||
else if (identifier.equals("level_percent")) {
|
||||
PlayerData playerData = PlayerData.get(player);
|
||||
double current = playerData.getExperience(), next = playerData.getLevelUpExperience();
|
||||
return MMOCore.plugin.configManager.decimal.format(current / next * 100);
|
||||
return MMOLib.plugin.getMMOConfig().decimal.format(current / next * 100);
|
||||
}
|
||||
|
||||
else if (identifier.equals("combat"))
|
||||
@ -86,7 +87,7 @@ public class RPGPlaceholders extends PlaceholderExpansion {
|
||||
String name = identifier.substring(19).replace(" ", "-").replace("_", "-").toLowerCase();
|
||||
Profession profession = MMOCore.plugin.professionManager.get(name);
|
||||
double current = professions.getExperience(profession), next = professions.getLevelUpExperience(profession);
|
||||
return MMOCore.plugin.configManager.decimal.format(current / next * 100);
|
||||
return MMOLib.plugin.getMMOConfig().decimal.format(current / next * 100);
|
||||
}
|
||||
|
||||
else if (identifier.startsWith("bound_")) {
|
||||
@ -131,7 +132,7 @@ public class RPGPlaceholders extends PlaceholderExpansion {
|
||||
.getAttribute(MMOCore.plugin.attributeManager.get(identifier.substring(10).toLowerCase().replace("_", "-"))));
|
||||
|
||||
else if (identifier.equals("mana"))
|
||||
return MMOCore.plugin.configManager.decimal.format(PlayerData.get(player).getMana());
|
||||
return MMOLib.plugin.getMMOConfig().decimal.format(PlayerData.get(player).getMana());
|
||||
|
||||
else if (identifier.equals("mana_bar")) {
|
||||
PlayerData data = PlayerData.get(player);
|
||||
@ -141,17 +142,17 @@ public class RPGPlaceholders extends PlaceholderExpansion {
|
||||
else if (identifier.startsWith("exp_multiplier_")) {
|
||||
String format = identifier.substring(15).toLowerCase().replace("_", "-").replace(" ", "-");
|
||||
Profession profession = format.equals("main") ? null : MMOCore.plugin.professionManager.get(format);
|
||||
return MMOCore.plugin.configManager.decimal.format(MMOCore.plugin.boosterManager.getMultiplier(profession) * 100);
|
||||
return MMOLib.plugin.getMMOConfig().decimal.format(MMOCore.plugin.boosterManager.getMultiplier(profession) * 100);
|
||||
}
|
||||
|
||||
else if (identifier.startsWith("exp_boost_")) {
|
||||
String format = identifier.substring(10).toLowerCase().replace("_", "-").replace(" ", "-");
|
||||
Profession profession = format.equals("main") ? null : MMOCore.plugin.professionManager.get(format);
|
||||
return MMOCore.plugin.configManager.decimal.format((MMOCore.plugin.boosterManager.getMultiplier(profession) - 1) * 100);
|
||||
return MMOLib.plugin.getMMOConfig().decimal.format((MMOCore.plugin.boosterManager.getMultiplier(profession) - 1) * 100);
|
||||
}
|
||||
|
||||
else if (identifier.equals("stamina"))
|
||||
return MMOCore.plugin.configManager.decimal.format(PlayerData.get(player).getStamina());
|
||||
return MMOLib.plugin.getMMOConfig().decimal.format(PlayerData.get(player).getStamina());
|
||||
|
||||
else if (identifier.equals("stamina_bar")) {
|
||||
StringBuilder format = new StringBuilder();
|
||||
@ -168,7 +169,7 @@ public class RPGPlaceholders extends PlaceholderExpansion {
|
||||
}
|
||||
|
||||
else if (identifier.equals("stellium"))
|
||||
return MMOCore.plugin.configManager.decimal.format(PlayerData.get(player).getStellium());
|
||||
return MMOLib.plugin.getMMOConfig().decimal.format(PlayerData.get(player).getStellium());
|
||||
|
||||
else if (identifier.equals("stellium_bar")) {
|
||||
StringBuilder format = new StringBuilder();
|
||||
@ -187,7 +188,7 @@ public class RPGPlaceholders extends PlaceholderExpansion {
|
||||
else if (identifier.equals("quest_progress")) {
|
||||
PlayerQuests data = PlayerData.get(player).getQuestData();
|
||||
return data.hasCurrent()
|
||||
? MMOCore.plugin.configManager.decimal
|
||||
? MMOLib.plugin.getMMOConfig().decimal
|
||||
.format((int) (double) data.getCurrent().getObjectiveNumber() / data.getCurrent().getQuest().getObjectives().size() * 100)
|
||||
: "0";
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.mmogroup.mmolib.MMOLib;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -25,7 +26,7 @@ public abstract class EditableInventory {
|
||||
*/
|
||||
private final Set<InventoryItem> items = new LinkedHashSet<>();
|
||||
|
||||
protected static final DecimalFormat decimal = MMOCore.plugin.configManager.decimal;
|
||||
protected static final DecimalFormat decimal = MMOLib.plugin.getMMOConfig().decimal;
|
||||
|
||||
public EditableInventory(String id) {
|
||||
this.id = id;
|
||||
|
@ -51,7 +51,7 @@ public class PartyListener implements Listener {
|
||||
LivingEntity entity = event.getEntity();
|
||||
if (entity instanceof Player && !entity.hasMetadata("NPC")) {
|
||||
PlayerData targetData = PlayerData.get((Player) event.getEntity());
|
||||
if (targetData.hasParty() && targetData.getParty().getMembers().has(event.getData().getMMOCore()))
|
||||
if (targetData.hasParty() && targetData.getParty().getMembers().has(PlayerData.get(event.getData().getUniqueId())))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class PlayerListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void a(PlayerJoinEvent event) {
|
||||
MMOCore.plugin.dataProvider.getDataManager().setup(event.getPlayer());
|
||||
MMOCore.plugin.dataProvider.getDataManager().setup(event.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -17,8 +17,6 @@ import org.bukkit.util.Consumer;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@ -31,9 +29,6 @@ public class ConfigManager {
|
||||
public ChatColor staminaFull, staminaHalf, staminaEmpty;
|
||||
public long combatLogTimer, lootChestExpireTime, lootChestPlayerCooldown;
|
||||
|
||||
public final DecimalFormatSymbols formatSymbols = new DecimalFormatSymbols();
|
||||
public final DecimalFormat decimal = new DecimalFormat("0.#", formatSymbols), decimals = new DecimalFormat("0.##", formatSymbols);
|
||||
|
||||
private final FileConfiguration messages;
|
||||
private final boolean chatInput;
|
||||
|
||||
@ -97,7 +92,6 @@ public class ConfigManager {
|
||||
hotbarSwap = MMOCore.plugin.getConfig().getBoolean("hotbar-swap");
|
||||
chatInput = MMOCore.plugin.getConfig().getBoolean("use-chat-input");
|
||||
partyChatPrefix = MMOCore.plugin.getConfig().getString("party.chat-prefix");
|
||||
formatSymbols.setDecimalSeparator(getFirstChar(MMOCore.plugin.getConfig().getString("number-format.decimal-separator")));
|
||||
combatLogTimer = MMOCore.plugin.getConfig().getInt("combat-log.timer") * 1000;
|
||||
lootChestExpireTime = Math.max(MMOCore.plugin.getConfig().getInt("loot-chests.chest-expire-time"), 1) * 1000;
|
||||
lootChestPlayerCooldown = MMOCore.plugin.getConfig().getInt("player-cooldown") * 1000;
|
||||
@ -117,14 +111,6 @@ public class ConfigManager {
|
||||
}
|
||||
}
|
||||
|
||||
public DecimalFormat newFormat(String pattern) {
|
||||
return new DecimalFormat(pattern, formatSymbols);
|
||||
}
|
||||
|
||||
private char getFirstChar(String str) {
|
||||
return str == null || str.isEmpty() ? ',' : str.charAt(0);
|
||||
}
|
||||
|
||||
public PlayerInput newPlayerInput(Player player, InputType type, Consumer<String> output) {
|
||||
return chatInput ? new ChatInput(player, type, output) : new AnvilGUI(player, type, output);
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import org.apache.commons.lang.Validate;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.experience.ExpCurve;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
|
||||
public class ExperienceManager {
|
||||
private final Map<String, ExpCurve> expCurves = new HashMap<>();
|
||||
@ -40,7 +39,7 @@ public class ExperienceManager {
|
||||
ExpCurve curve = new ExpCurve(file);
|
||||
expCurves.put(curve.getId(), curve);
|
||||
} catch (IllegalArgumentException | IOException exception) {
|
||||
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not load exp curve '" + file.getName() + "': " + exception.getMessage());
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load exp curve '" + file.getName() + "': " + exception.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,21 @@
|
||||
package net.Indyuce.mmocore.manager.data;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.event.PlayerDataLoadEvent;
|
||||
import net.Indyuce.mmocore.api.player.OfflinePlayerData;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.mmogroup.mmolib.api.player.MMOPlayerData;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class PlayerDataManager {
|
||||
private final static Map<UUID, PlayerData> data = new HashMap<>();
|
||||
private DefaultPlayerData defaultData = new DefaultPlayerData();
|
||||
|
||||
public PlayerData get(OfflinePlayer player) {
|
||||
@ -23,37 +23,36 @@ public abstract class PlayerDataManager {
|
||||
}
|
||||
|
||||
public PlayerData get(UUID uuid) {
|
||||
PlayerData found = MMOPlayerData.get(uuid).getMMOCore();
|
||||
return found == null ? PlayerData.NOT_LOADED : found;
|
||||
return data.getOrDefault(uuid, setup(uuid));
|
||||
}
|
||||
|
||||
public void remove(UUID uuid) {
|
||||
if (MMOPlayerData.isLoaded(uuid))
|
||||
MMOPlayerData.get(uuid).setMMOCore(null);
|
||||
data.remove(uuid);
|
||||
}
|
||||
|
||||
public abstract OfflinePlayerData getOffline(UUID uuid);
|
||||
|
||||
public void setup(Player player) {
|
||||
|
||||
public PlayerData setup(UUID uuid) {
|
||||
/*
|
||||
* Setup playerData based on loadData method to support both MySQL and
|
||||
* YAML data storage
|
||||
*/
|
||||
MMOPlayerData mmoData = MMOPlayerData.get(player);
|
||||
if (mmoData.getMMOCore() == null) {
|
||||
PlayerData generated = new PlayerData(mmoData);
|
||||
PlayerData playerData = data.get(uuid);
|
||||
if (playerData == null) {
|
||||
playerData = data.put(uuid, new PlayerData(MMOPlayerData.get(uuid)));
|
||||
|
||||
/*
|
||||
* Loads player data and ONLY THEN refresh the player statistics and
|
||||
* calls the load event on the MAIN thread
|
||||
*/
|
||||
Bukkit.getScheduler().runTaskAsynchronously(MMOCore.plugin, () -> {
|
||||
loadData(generated);
|
||||
Bukkit.getScheduler().runTask(MMOCore.plugin, () -> Bukkit.getPluginManager().callEvent(new PlayerDataLoadEvent(generated)));
|
||||
generated.getStats().updateStats();
|
||||
PlayerData loaded = PlayerData.get(uuid);
|
||||
loadData(loaded);
|
||||
Bukkit.getScheduler().runTask(MMOCore.plugin, () -> Bukkit.getPluginManager().callEvent(new PlayerDataLoadEvent(loaded)));
|
||||
loaded.getStats().updateStats();
|
||||
});
|
||||
}
|
||||
return playerData;
|
||||
}
|
||||
|
||||
public DefaultPlayerData getDefaultData() {
|
||||
@ -65,12 +64,11 @@ public abstract class PlayerDataManager {
|
||||
}
|
||||
|
||||
public boolean isLoaded(UUID uuid) {
|
||||
return MMOPlayerData.isLoaded(uuid) && MMOPlayerData.get(uuid).getMMOCore() != null;
|
||||
return data.containsKey(uuid);
|
||||
}
|
||||
|
||||
public Collection<PlayerData> getLoaded() {
|
||||
return MMOPlayerData.getLoaded().stream().filter(data -> data.getMMOCore() != null).map(MMOPlayerData::getMMOCore)
|
||||
.collect(Collectors.toSet());
|
||||
return data.values();
|
||||
}
|
||||
|
||||
public abstract void loadData(PlayerData data);
|
||||
|
@ -22,7 +22,7 @@ public class YAMLPlayerDataManager extends PlayerDataManager {
|
||||
|
||||
@Override
|
||||
public void loadData(PlayerData data) {
|
||||
FileConfiguration config = new ConfigFile(data.getPlayer()).getConfig();
|
||||
FileConfiguration config = new ConfigFile(data.getUniqueId()).getConfig();
|
||||
|
||||
data.setClassPoints(config.getInt("class-points", getDefaultData().getClassPoints()));
|
||||
data.setSkillPoints(config.getInt("skill-points", getDefaultData().getSkillPoints()));
|
||||
|
@ -37,7 +37,7 @@ public class Ambers extends Skill implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerAttackEvent event) {
|
||||
PlayerData data = event.getData().getMMOCore();
|
||||
PlayerData data = PlayerData.get(event.getData().getUniqueId());
|
||||
if (!event.getAttack().hasType(DamageType.SKILL) || !data.getProfess().hasSkill(this))
|
||||
return;
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class Backstab extends Skill implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerAttackEvent event) {
|
||||
PlayerData data = event.getData().getMMOCore();
|
||||
PlayerData data = PlayerData.get(event.getData().getUniqueId());
|
||||
LivingEntity target = event.getEntity();
|
||||
if (data.isInCombat() || !event.getAttack().hasType(DamageType.WEAPON)
|
||||
|| event.getPlayer().getEyeLocation().getDirection().angle(target.getEyeLocation().getDirection()) > Math.PI / 6
|
||||
|
@ -69,7 +69,7 @@ public class Evade extends Skill {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void b(PlayerAttackEvent event) {
|
||||
if (event.getAttack().hasType(DamageType.WEAPON) && !event.isCancelled() && event.getData().getMMOCore().equals(data))
|
||||
if (event.getAttack().hasType(DamageType.WEAPON) && !event.isCancelled() && PlayerData.get(event.getData().getUniqueId()).equals(data))
|
||||
close();
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class Fire_Berserker extends Skill implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void a(PlayerAttackEvent event) {
|
||||
PlayerData data = event.getData().getMMOCore();
|
||||
PlayerData data = PlayerData.get(event.getData().getUniqueId());
|
||||
if (event.getPlayer().getFireTicks() > 0) {
|
||||
Optional<SkillInfo> skill = data.getProfess().findSkill(this);
|
||||
skill.ifPresent(skillInfo -> event.getAttack().multiplyDamage(1 + skillInfo.getModifier("extra", data.getSkillLevel(this)) / 100));
|
||||
|
@ -46,7 +46,7 @@ public class Power_Mark extends Skill implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerAttackEvent event) {
|
||||
PlayerData data = event.getData().getMMOCore();
|
||||
PlayerData data = PlayerData.get(event.getData().getUniqueId());
|
||||
if (!event.getAttack().hasType(DamageType.WEAPON) || !data.getProfess().hasSkill(this))
|
||||
return;
|
||||
|
||||
@ -89,7 +89,7 @@ public class Power_Mark extends Skill implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void stackDamage(PlayerAttackEvent event) {
|
||||
if (!event.isCancelled() && j < 20 * (duration - 2) && radiusCheck(event.getEntity().getLocation()) && event.getData().getMMOCore().equals(data)) {
|
||||
if (!event.isCancelled() && j < 20 * (duration - 2) && radiusCheck(event.getEntity().getLocation()) && PlayerData.get(event.getData().getUniqueId()).equals(data)) {
|
||||
accumulate += event.getAttack().getDamage() * ratio;
|
||||
new ParabolicProjectile(event.getEntity().getLocation().add(0, event.getEntity().getHeight() / 2, 0), loc, () -> loc.getWorld().playSound(loc, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1), Color.PURPLE);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class Sneaky_Picky extends Skill implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerAttackEvent event) {
|
||||
PlayerData data = event.getData().getMMOCore();
|
||||
PlayerData data = PlayerData.get(event.getData().getUniqueId());
|
||||
if (!event.getAttack().hasType(DamageType.WEAPON) || data.isInCombat() || !data.getProfess().hasSkill(this))
|
||||
return;
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
# a Spigot Plugin by Team Requiem
|
||||
|
||||
# DO NOT TOUCH
|
||||
config-version: 2
|
||||
config-version: 3
|
||||
|
||||
# Auto-Save feature automatically saves playerdata
|
||||
# (class, level, etc.) and guild data
|
||||
@ -55,18 +55,7 @@ custom-mine-conditions:
|
||||
# broken when custom mining conditions are met
|
||||
protect-custom-mine: false
|
||||
|
||||
# Offset is the distance traveled on X and Y coordinates
|
||||
# Height is the Y velocity coordinate. Lootsplosions
|
||||
# only trigger with MythicMobs monsters.
|
||||
# Requires a SERVER reload when changed.
|
||||
lootsplosion:
|
||||
enabled: true
|
||||
mmoitems-color: true
|
||||
offset: .2
|
||||
height: .6
|
||||
|
||||
loot-chests:
|
||||
|
||||
# Time in seconds it takes for a loot chest to
|
||||
# expire after it was spawned. 600 is 10 minutes.
|
||||
chest-expire-time: 600
|
||||
@ -127,17 +116,6 @@ death-exp-loss:
|
||||
# Percentage of current EXP you lose when dying.
|
||||
percent: 30
|
||||
|
||||
# Edit general plugin number formatting here.
|
||||
number-format:
|
||||
decimal-separator: .
|
||||
|
||||
# Allows to scale health up/down to a specific
|
||||
# amount so extra health does not fill up the screen.
|
||||
# Requires a SERVER reload when changed.
|
||||
health-scale:
|
||||
enabled: true
|
||||
scale: 20
|
||||
|
||||
# Allows to toggle exp hologram from gaining experience
|
||||
display-exp-holograms: true
|
||||
|
||||
|
@ -107,7 +107,7 @@ attributes:
|
||||
base: 24
|
||||
per-level: 0.5
|
||||
movement-speed:
|
||||
base: .905
|
||||
base: .12
|
||||
per-level: 0
|
||||
attack-damage:
|
||||
base: 2
|
||||
|
Loading…
Reference in New Issue
Block a user