diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 00000000..a10c4c08
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,33 @@
+image: maven:3-openjdk-8-slim
+
+variables:
+ MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
+ MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
+
+before_script:
+ - apt-get update -qq
+ # Setup SSH deploy keys
+ - 'which ssh-agent || ( apt-get install -qq openssh-client )'
+ - eval $(ssh-agent -s)
+ - ssh-add <(echo "$SSH_PRIVATE_KEY")
+ - mkdir -p ~/.ssh
+ - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
+
+cache:
+ paths:
+ - .m2/repository/
+ - target/
+
+build:
+ stage: build
+ script:
+ - mvn $MAVEN_CLI_OPTS package
+
+deploy:
+ stage: deploy
+ script:
+ - mvn $MAVEN_CLI_OPTS deploy
+ - ssh lumine@proxy.mythiccraft.io -p 2222 "mkdir -p /tmp/builds/$CI_JOB_ID && exit"
+ - scp -rp -o StrictHostKeyChecking=no -o Port=2222 ./target/ lumine@proxy.mythiccraft.io:/tmp/builds/$CI_JOB_ID/
+ only:
+ - master
diff --git a/.m2/settings.xml b/.m2/settings.xml
new file mode 100644
index 00000000..f9f19f1d
--- /dev/null
+++ b/.m2/settings.xml
@@ -0,0 +1,9 @@
+
+
+
+ nexus
+ ${env.M2_REPO_USER}
+ ${env.M2_REPO_PASS}
+
+
+
diff --git a/lib/PlaceholderAPI.jar b/lib/PlaceholderAPI.jar
new file mode 100644
index 00000000..d74e6c13
Binary files /dev/null and b/lib/PlaceholderAPI.jar differ
diff --git a/pom.xml b/pom.xml
index 1e72516e..468c91e5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
net.Indyuce
MMOCore
- 1.4.2-SNAPSHOT
+ 1.4.3
MMOCore
Offer your players a brand new RPG experience.
@@ -66,10 +66,6 @@
sk89q-repo
https://maven.enginehub.org/repo/
-
- placeholderapi
- http://repo.extendedclip.com/content/repositories/placeholderapi/
-
@@ -160,5 +156,12 @@
mysql-connector-java
5.1.41
+
+ me.clip
+ placeholderapi
+ 2.10.7
+ system
+ ${basedir}/lib/PlaceholderAPI.jar
+
\ No newline at end of file
diff --git a/src/main/java/net/Indyuce/mmocore/api/quest/PlayerQuests.java b/src/main/java/net/Indyuce/mmocore/api/quest/PlayerQuests.java
index 6459dc99..30c44d60 100644
--- a/src/main/java/net/Indyuce/mmocore/api/quest/PlayerQuests.java
+++ b/src/main/java/net/Indyuce/mmocore/api/quest/PlayerQuests.java
@@ -150,7 +150,7 @@ public class PlayerQuests {
// close current objective progress if quest is active
if (hasCurrent())
- current.closeObjectiveProgress();
+ current.getProgress().close();
// apply newer quest
current = quest == null ? null : quest.generateNewProgress(playerData);
diff --git a/src/main/java/net/Indyuce/mmocore/api/quest/QuestProgress.java b/src/main/java/net/Indyuce/mmocore/api/quest/QuestProgress.java
index 3589a490..e5bb6953 100644
--- a/src/main/java/net/Indyuce/mmocore/api/quest/QuestProgress.java
+++ b/src/main/java/net/Indyuce/mmocore/api/quest/QuestProgress.java
@@ -43,16 +43,12 @@ public class QuestProgress {
return quest.getObjectives().get(objective);
}
- public void closeObjectiveProgress() {
- objectiveProgress.close();
- }
-
public void completeObjective() {
objective++;
- closeObjectiveProgress();
+ objectiveProgress.close();
// apply triggers
- objectiveProgress.getObjective().getTriggers().forEach(trigger -> trigger.apply(getPlayer()));
+ objectiveProgress.getObjective().getTriggers().forEach(trigger -> trigger.schedule(getPlayer()));
// end quest
if (objective >= quest.getObjectives().size())
diff --git a/src/main/java/net/Indyuce/mmocore/api/quest/trigger/Trigger.java b/src/main/java/net/Indyuce/mmocore/api/quest/trigger/Trigger.java
index ae4a61e2..fb95975c 100644
--- a/src/main/java/net/Indyuce/mmocore/api/quest/trigger/Trigger.java
+++ b/src/main/java/net/Indyuce/mmocore/api/quest/trigger/Trigger.java
@@ -10,7 +10,7 @@ public abstract class Trigger {
private final long delay;
public Trigger(MMOLineConfig config) {
- delay = config.contains("delay") ? (long) (config.getDouble("delay") * 20) : 0;
+ delay = config.contains("delay") ? (long) (config.getDouble("delay") * 20.) : 0;
}
public boolean hasDelay() {
@@ -22,8 +22,16 @@ public abstract class Trigger {
}
public void schedule(PlayerData player) {
- Bukkit.getScheduler().scheduleSyncDelayedTask(MMOCore.plugin, () -> apply(player), delay);
+ if (delay <= 0)
+ apply(player);
+ else
+ Bukkit.getScheduler().scheduleSyncDelayedTask(MMOCore.plugin, () -> apply(player), delay);
}
+ /*
+ * this method must not be used directly when executing triggers after quest
+ * objectives for example, because this method does NOT take into account
+ * trigger delay
+ */
public abstract void apply(PlayerData player);
}
diff --git a/src/main/java/net/Indyuce/mmocore/comp/placeholder/PlaceholderAPIParser.java b/src/main/java/net/Indyuce/mmocore/comp/placeholder/PlaceholderAPIParser.java
index 431110e4..5d653dc8 100644
--- a/src/main/java/net/Indyuce/mmocore/comp/placeholder/PlaceholderAPIParser.java
+++ b/src/main/java/net/Indyuce/mmocore/comp/placeholder/PlaceholderAPIParser.java
@@ -1,16 +1,19 @@
package net.Indyuce.mmocore.comp.placeholder;
+import net.asangarin.hexcolors.ColorParse;
import org.bukkit.OfflinePlayer;
import me.clip.placeholderapi.PlaceholderAPI;
+import me.clip.placeholderapi.expansion.PlaceholderExpansion;
public class PlaceholderAPIParser implements PlaceholderParser {
public PlaceholderAPIParser() {
- new RPGPlaceholders().register();
+ PlaceholderExpansion expansion = new RPGPlaceholders();
+ expansion.getPlaceholderAPI().getLocalExpansionManager().register(expansion);
}
@Override
public String parse(OfflinePlayer player, String string) {
- return PlaceholderAPI.setPlaceholders(player, string.replace("%player%", player.getName()));
+ return new ColorParse('&', PlaceholderAPI.setPlaceholders(player, string.replace("%player%", player.getName()))).toChatColor();
}
}
diff --git a/src/main/java/net/Indyuce/mmocore/comp/placeholder/RPGPlaceholders.java b/src/main/java/net/Indyuce/mmocore/comp/placeholder/RPGPlaceholders.java
index 721d8e89..a6710cd6 100644
--- a/src/main/java/net/Indyuce/mmocore/comp/placeholder/RPGPlaceholders.java
+++ b/src/main/java/net/Indyuce/mmocore/comp/placeholder/RPGPlaceholders.java
@@ -1,9 +1,12 @@
package net.Indyuce.mmocore.comp.placeholder;
+import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
+import org.bukkit.OfflinePlayer;
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 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.mmogroup.mmolib.api.util.AltChar;
-public class RPGPlaceholders
- extends PlaceholderExpansion /** implements Relational */
-{
+public class RPGPlaceholders extends PlaceholderExpansion {
@Override
public String getAuthor() {
@@ -34,7 +35,7 @@ public class RPGPlaceholders
}
@Override
- public String onPlaceholderRequest(Player player, String identifier) {
+ public String onRequest(@Nullable OfflinePlayer player, @NotNull String identifier) {
if (identifier.equals("level"))
return "" + PlayerData.get(player).getLevel();
@@ -48,8 +49,10 @@ public class RPGPlaceholders
else if (identifier.equals("combat"))
return String.valueOf(PlayerData.get(player).isInCombat());
- else if (identifier.equals("health"))
- return StatType.MAX_HEALTH.format(player.getHealth());
+ else if (identifier.equals("health")) {
+ Validate.isTrue(player.isOnline(), "Player must be online");
+ return StatType.MAX_HEALTH.format(player.getPlayer().getHealth());
+ }
else if (identifier.equals("class"))
return PlayerData.get(player).getProfess().getName();
@@ -68,13 +71,15 @@ public class RPGPlaceholders
return playerData.hasSkillBound(slot) ? playerData.getBoundSkill(slot).getSkill().getName()
: MMOCore.plugin.configManager.noSkillBoundPlaceholder;
}
-
+
else if (identifier.startsWith("profession_"))
return "" + PlayerData.get(player).getCollectionSkills()
.getLevel(identifier.substring(11).replace(" ", "-").replace("_", "-").toLowerCase());
- else if (identifier.equals("max_health"))
- return StatType.MAX_HEALTH.format(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
+ else if (identifier.equals("max_health")) {
+ 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"))
return "" + PlayerData.get(player).getExperience();
@@ -95,15 +100,16 @@ public class RPGPlaceholders
return "" + PlayerData.get(player).getAttributeReallocationPoints();
else if (identifier.startsWith("attribute_"))
- return String.valueOf(PlayerData.get(player).getAttributes()
- .getAttribute(MMOCore.plugin.attributeManager.get(identifier.substring(10).toLowerCase().replace("_", "-"))));
+ return String.valueOf(PlayerData.get(player).getAttributes().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());
else if (identifier.equals("mana_bar")) {
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"))
@@ -115,7 +121,8 @@ public class RPGPlaceholders
double ratio = 20 * data.getStamina() / data.getStats().getStat(StatType.MAX_STAMINA);
for (double j = 1; j < 20; j++)
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;
return format;
}
@@ -133,7 +140,8 @@ public class RPGPlaceholders
PlayerData data = PlayerData.get(player);
double ratio = 20 * data.getStellium() / data.getStats().getStat(StatType.MAX_STELLIUM);
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;
}
@@ -145,8 +153,8 @@ public class RPGPlaceholders
else if (identifier.equals("quest_progress")) {
PlayerQuests data = PlayerData.get(player).getQuestData();
return data.hasCurrent()
- ? MMOCore.plugin.configManager.decimal
- .format((int) (double) data.getCurrent().getObjectiveNumber() / data.getCurrent().getQuest().getObjectives().size() * 100)
+ ? MMOCore.plugin.configManager.decimal.format((int) (double) data.getCurrent().getObjectiveNumber()
+ / data.getCurrent().getQuest().getObjectives().size() * 100)
: "0";
}
diff --git a/src/main/java/net/Indyuce/mmocore/listener/profession/FishingListener.java b/src/main/java/net/Indyuce/mmocore/listener/profession/FishingListener.java
index fbd078d4..19063bfa 100644
--- a/src/main/java/net/Indyuce/mmocore/listener/profession/FishingListener.java
+++ b/src/main/java/net/Indyuce/mmocore/listener/profession/FishingListener.java
@@ -41,12 +41,13 @@ public class FishingListener implements Listener {
Player player = event.getPlayer();
FishHook hook = event.getHook();
- if (event.getState() == State.BITE && !fishing.contains(player.getUniqueId())) {
+ if (event.getState() == State.BITE && !fishing.contains(player.getUniqueId()) && !player.hasMetadata("NPC")) {
/*
* checks for drop tables. if no drop table, just plain vanilla
* fishing OTHERWISE initialize fishing, register other listener.
*/
+
FishingDropTable table = MMOCore.plugin.fishingManager.calculateDropTable(player);
if (table == null)
return;
@@ -118,7 +119,7 @@ public class FishingListener implements Listener {
@EventHandler
public void a(PlayerFishEvent event) {
- if (event.getPlayer().equals(player) && (event.getState() == State.CAUGHT_FISH || event.getState() == State.FAILED_ATTEMPT || (MMOLib.plugin.getVersion().isStrictlyHigher(1, 12) ? event.getState() == State.valueOf("REEL_IN") : false))) {
+ if (event.getPlayer().equals(player) && !player.hasMetadata("NPC") && (event.getState() == State.CAUGHT_FISH || event.getState() == State.FAILED_ATTEMPT || (MMOLib.plugin.getVersion().isStrictlyHigher(1, 12) ? event.getState() == State.valueOf("REEL_IN") : false))) {
/*
* lose the catch if the current fish is gone!