mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-28 00:55:29 +01:00
PAPI update
This commit is contained in:
parent
cc9a22d828
commit
16da9772ee
BIN
lib/PlaceholderAPI.jar
Normal file
BIN
lib/PlaceholderAPI.jar
Normal file
Binary file not shown.
13
pom.xml
13
pom.xml
@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>net.Indyuce</groupId>
|
<groupId>net.Indyuce</groupId>
|
||||||
<artifactId>MMOCore</artifactId>
|
<artifactId>MMOCore</artifactId>
|
||||||
<version>1.4.2-SNAPSHOT</version>
|
<version>1.4.3</version>
|
||||||
<name>MMOCore</name>
|
<name>MMOCore</name>
|
||||||
<description>Offer your players a brand new RPG experience.</description>
|
<description>Offer your players a brand new RPG experience.</description>
|
||||||
|
|
||||||
@ -66,10 +66,6 @@
|
|||||||
<id>sk89q-repo</id>
|
<id>sk89q-repo</id>
|
||||||
<url>https://maven.enginehub.org/repo/</url>
|
<url>https://maven.enginehub.org/repo/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
|
||||||
<id>placeholderapi</id>
|
|
||||||
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
@ -160,5 +156,12 @@
|
|||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
<version>5.1.41</version>
|
<version>5.1.41</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.clip</groupId>
|
||||||
|
<artifactId>placeholderapi</artifactId>
|
||||||
|
<version>2.10.7</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${basedir}/lib/PlaceholderAPI.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -3,10 +3,12 @@ package net.Indyuce.mmocore.comp.placeholder;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
|
|
||||||
public class PlaceholderAPIParser implements PlaceholderParser {
|
public class PlaceholderAPIParser implements PlaceholderParser {
|
||||||
public PlaceholderAPIParser() {
|
public PlaceholderAPIParser() {
|
||||||
new RPGPlaceholders().register();
|
PlaceholderExpansion expansion = new RPGPlaceholders();
|
||||||
|
expansion.getPlaceholderAPI().getLocalExpansionManager().register(expansion);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package net.Indyuce.mmocore.comp.placeholder;
|
package net.Indyuce.mmocore.comp.placeholder;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.entity.Player;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
@ -14,9 +17,7 @@ import net.Indyuce.mmocore.api.player.stats.StatType;
|
|||||||
import net.Indyuce.mmocore.api.quest.PlayerQuests;
|
import net.Indyuce.mmocore.api.quest.PlayerQuests;
|
||||||
import net.mmogroup.mmolib.api.util.AltChar;
|
import net.mmogroup.mmolib.api.util.AltChar;
|
||||||
|
|
||||||
public class RPGPlaceholders
|
public class RPGPlaceholders extends PlaceholderExpansion {
|
||||||
extends PlaceholderExpansion /** implements Relational */
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAuthor() {
|
public String getAuthor() {
|
||||||
@ -34,7 +35,7 @@ public class RPGPlaceholders
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String onPlaceholderRequest(Player player, String identifier) {
|
public String onRequest(@Nullable OfflinePlayer player, @NotNull String identifier) {
|
||||||
|
|
||||||
if (identifier.equals("level"))
|
if (identifier.equals("level"))
|
||||||
return "" + PlayerData.get(player).getLevel();
|
return "" + PlayerData.get(player).getLevel();
|
||||||
@ -48,8 +49,10 @@ public class RPGPlaceholders
|
|||||||
else if (identifier.equals("combat"))
|
else if (identifier.equals("combat"))
|
||||||
return String.valueOf(PlayerData.get(player).isInCombat());
|
return String.valueOf(PlayerData.get(player).isInCombat());
|
||||||
|
|
||||||
else if (identifier.equals("health"))
|
else if (identifier.equals("health")) {
|
||||||
return StatType.MAX_HEALTH.format(player.getHealth());
|
Validate.isTrue(player.isOnline(), "Player must be online");
|
||||||
|
return StatType.MAX_HEALTH.format(player.getPlayer().getHealth());
|
||||||
|
}
|
||||||
|
|
||||||
else if (identifier.equals("class"))
|
else if (identifier.equals("class"))
|
||||||
return PlayerData.get(player).getProfess().getName();
|
return PlayerData.get(player).getProfess().getName();
|
||||||
@ -73,8 +76,10 @@ public class RPGPlaceholders
|
|||||||
return "" + PlayerData.get(player).getCollectionSkills()
|
return "" + PlayerData.get(player).getCollectionSkills()
|
||||||
.getLevel(identifier.substring(11).replace(" ", "-").replace("_", "-").toLowerCase());
|
.getLevel(identifier.substring(11).replace(" ", "-").replace("_", "-").toLowerCase());
|
||||||
|
|
||||||
else if (identifier.equals("max_health"))
|
else if (identifier.equals("max_health")) {
|
||||||
return StatType.MAX_HEALTH.format(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
Validate.isTrue(player.isOnline(), "Player must be online");
|
||||||
|
return StatType.MAX_HEALTH.format(player.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
||||||
|
}
|
||||||
|
|
||||||
else if (identifier.equals("experience"))
|
else if (identifier.equals("experience"))
|
||||||
return "" + PlayerData.get(player).getExperience();
|
return "" + PlayerData.get(player).getExperience();
|
||||||
@ -95,15 +100,16 @@ public class RPGPlaceholders
|
|||||||
return "" + PlayerData.get(player).getAttributeReallocationPoints();
|
return "" + PlayerData.get(player).getAttributeReallocationPoints();
|
||||||
|
|
||||||
else if (identifier.startsWith("attribute_"))
|
else if (identifier.startsWith("attribute_"))
|
||||||
return String.valueOf(PlayerData.get(player).getAttributes()
|
return String.valueOf(PlayerData.get(player).getAttributes().getAttribute(
|
||||||
.getAttribute(MMOCore.plugin.attributeManager.get(identifier.substring(10).toLowerCase().replace("_", "-"))));
|
MMOCore.plugin.attributeManager.get(identifier.substring(10).toLowerCase().replace("_", "-"))));
|
||||||
|
|
||||||
else if (identifier.equals("mana"))
|
else if (identifier.equals("mana"))
|
||||||
return MMOCore.plugin.configManager.decimal.format(PlayerData.get(player).getMana());
|
return MMOCore.plugin.configManager.decimal.format(PlayerData.get(player).getMana());
|
||||||
|
|
||||||
else if (identifier.equals("mana_bar")) {
|
else if (identifier.equals("mana_bar")) {
|
||||||
PlayerData data = PlayerData.get(player);
|
PlayerData data = PlayerData.get(player);
|
||||||
return data.getProfess().getManaDisplay().generateBar(data.getMana(), data.getStats().getStat(StatType.MAX_MANA));
|
return data.getProfess().getManaDisplay().generateBar(data.getMana(),
|
||||||
|
data.getStats().getStat(StatType.MAX_MANA));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (identifier.equals("stamina"))
|
else if (identifier.equals("stamina"))
|
||||||
@ -115,7 +121,8 @@ public class RPGPlaceholders
|
|||||||
double ratio = 20 * data.getStamina() / data.getStats().getStat(StatType.MAX_STAMINA);
|
double ratio = 20 * data.getStamina() / data.getStats().getStat(StatType.MAX_STAMINA);
|
||||||
for (double j = 1; j < 20; j++)
|
for (double j = 1; j < 20; j++)
|
||||||
format += (ratio >= j ? MMOCore.plugin.configManager.staminaFull
|
format += (ratio >= j ? MMOCore.plugin.configManager.staminaFull
|
||||||
: ratio >= j - .5 ? MMOCore.plugin.configManager.staminaHalf : MMOCore.plugin.configManager.staminaEmpty)
|
: ratio >= j - .5 ? MMOCore.plugin.configManager.staminaHalf
|
||||||
|
: MMOCore.plugin.configManager.staminaEmpty)
|
||||||
+ AltChar.listSquare;
|
+ AltChar.listSquare;
|
||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
@ -133,7 +140,8 @@ public class RPGPlaceholders
|
|||||||
PlayerData data = PlayerData.get(player);
|
PlayerData data = PlayerData.get(player);
|
||||||
double ratio = 20 * data.getStellium() / data.getStats().getStat(StatType.MAX_STELLIUM);
|
double ratio = 20 * data.getStellium() / data.getStats().getStat(StatType.MAX_STELLIUM);
|
||||||
for (double j = 1; j < 20; j++)
|
for (double j = 1; j < 20; j++)
|
||||||
format += (ratio >= j ? ChatColor.BLUE : ratio >= j - .5 ? ChatColor.AQUA : ChatColor.WHITE) + AltChar.listSquare;
|
format += (ratio >= j ? ChatColor.BLUE : ratio >= j - .5 ? ChatColor.AQUA : ChatColor.WHITE)
|
||||||
|
+ AltChar.listSquare;
|
||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,8 +153,8 @@ public class RPGPlaceholders
|
|||||||
else if (identifier.equals("quest_progress")) {
|
else if (identifier.equals("quest_progress")) {
|
||||||
PlayerQuests data = PlayerData.get(player).getQuestData();
|
PlayerQuests data = PlayerData.get(player).getQuestData();
|
||||||
return data.hasCurrent()
|
return data.hasCurrent()
|
||||||
? MMOCore.plugin.configManager.decimal
|
? MMOCore.plugin.configManager.decimal.format((int) (double) data.getCurrent().getObjectiveNumber()
|
||||||
.format((int) (double) data.getCurrent().getObjectiveNumber() / data.getCurrent().getQuest().getObjectives().size() * 100)
|
/ data.getCurrent().getQuest().getObjectives().size() * 100)
|
||||||
: "0";
|
: "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user