mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-22 10:36:09 +01:00
Translate mob names in Quest Journal. Bump version
This commit is contained in:
parent
77d392dba2
commit
d07a777818
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>me.blackvein.quests</groupId>
|
<groupId>me.blackvein.quests</groupId>
|
||||||
<artifactId>quests-parent</artifactId>
|
<artifactId>quests-parent</artifactId>
|
||||||
<version>4.2.4</version>
|
<version>4.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>quests-api</artifactId>
|
<artifactId>quests-api</artifactId>
|
||||||
|
|
||||||
|
@ -143,8 +143,6 @@ public interface IQuester extends Comparable<IQuester> {
|
|||||||
|
|
||||||
LinkedList<String> getCurrentObjectives(final IQuest quest, final boolean ignoreOverrides);
|
LinkedList<String> getCurrentObjectives(final IQuest quest, final boolean ignoreOverrides);
|
||||||
|
|
||||||
LinkedList<Objective> getCurrentObjectivesTemp(final IQuest quest, final boolean ignoreOverrides, final boolean formatItems);
|
|
||||||
|
|
||||||
LinkedList<String> getObjectives(final IQuest quest, final boolean ignoreOverrides);
|
LinkedList<String> getObjectives(final IQuest quest, final boolean ignoreOverrides);
|
||||||
|
|
||||||
boolean containsObjective(final IQuest quest, final String name);
|
boolean containsObjective(final IQuest quest, final String name);
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
package me.blackvein.quests.quests;
|
package me.blackvein.quests.quests;
|
||||||
|
|
||||||
import me.blackvein.quests.enums.ObjectiveType;
|
import me.blackvein.quests.enums.ObjectiveType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public interface Objective {
|
public interface Objective {
|
||||||
ObjectiveType getType();
|
ObjectiveType getType();
|
||||||
@ -24,7 +24,7 @@ public interface Objective {
|
|||||||
|
|
||||||
int getGoal();
|
int getGoal();
|
||||||
|
|
||||||
ItemStack getItemProgress();
|
@NotNull Object getProgressObject();
|
||||||
|
|
||||||
ItemStack getItemGoal();
|
@NotNull Object getGoalObject();
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>me.blackvein.quests</groupId>
|
<groupId>me.blackvein.quests</groupId>
|
||||||
<artifactId>quests-parent</artifactId>
|
<artifactId>quests-parent</artifactId>
|
||||||
<version>4.2.4</version>
|
<version>4.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>quests-core</artifactId>
|
<artifactId>quests-core</artifactId>
|
||||||
|
|
||||||
@ -132,7 +132,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.PikaMug</groupId>
|
<groupId>com.github.PikaMug</groupId>
|
||||||
<artifactId>LocaleLib</artifactId>
|
<artifactId>LocaleLib</artifactId>
|
||||||
<version>5fb19ed10c</version>
|
<version>35b50bfd53</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>xyz.upperlevel.spigot.book</groupId>
|
<groupId>xyz.upperlevel.spigot.book</groupId>
|
||||||
|
@ -20,9 +20,9 @@ import me.blackvein.quests.conditions.ICondition;
|
|||||||
import me.blackvein.quests.config.ISettings;
|
import me.blackvein.quests.config.ISettings;
|
||||||
import me.blackvein.quests.convo.misc.QuestAbandonPrompt;
|
import me.blackvein.quests.convo.misc.QuestAbandonPrompt;
|
||||||
import me.blackvein.quests.dependencies.IDependencies;
|
import me.blackvein.quests.dependencies.IDependencies;
|
||||||
import me.blackvein.quests.events.quest.QuestQuitEvent;
|
import me.blackvein.quests.entity.CountableMob;
|
||||||
import me.blackvein.quests.module.ICustomObjective;
|
|
||||||
import me.blackvein.quests.enums.ObjectiveType;
|
import me.blackvein.quests.enums.ObjectiveType;
|
||||||
|
import me.blackvein.quests.events.quest.QuestQuitEvent;
|
||||||
import me.blackvein.quests.events.quest.QuestTakeEvent;
|
import me.blackvein.quests.events.quest.QuestTakeEvent;
|
||||||
import me.blackvein.quests.events.quester.QuesterPostStartQuestEvent;
|
import me.blackvein.quests.events.quester.QuesterPostStartQuestEvent;
|
||||||
import me.blackvein.quests.events.quester.QuesterPostUpdateObjectiveEvent;
|
import me.blackvein.quests.events.quester.QuesterPostUpdateObjectiveEvent;
|
||||||
@ -30,6 +30,7 @@ import me.blackvein.quests.events.quester.QuesterPreOpenGUIEvent;
|
|||||||
import me.blackvein.quests.events.quester.QuesterPreStartQuestEvent;
|
import me.blackvein.quests.events.quester.QuesterPreStartQuestEvent;
|
||||||
import me.blackvein.quests.events.quester.QuesterPreUpdateObjectiveEvent;
|
import me.blackvein.quests.events.quester.QuesterPreUpdateObjectiveEvent;
|
||||||
import me.blackvein.quests.item.QuestJournal;
|
import me.blackvein.quests.item.QuestJournal;
|
||||||
|
import me.blackvein.quests.module.ICustomObjective;
|
||||||
import me.blackvein.quests.nms.TitleProvider;
|
import me.blackvein.quests.nms.TitleProvider;
|
||||||
import me.blackvein.quests.player.IQuester;
|
import me.blackvein.quests.player.IQuester;
|
||||||
import me.blackvein.quests.quests.BukkitObjective;
|
import me.blackvein.quests.quests.BukkitObjective;
|
||||||
@ -1567,12 +1568,12 @@ public class Quester implements IQuester {
|
|||||||
*
|
*
|
||||||
* @param quest The quest to get objectives of
|
* @param quest The quest to get objectives of
|
||||||
* @param ignoreOverrides Whether to ignore objective-overrides
|
* @param ignoreOverrides Whether to ignore objective-overrides
|
||||||
* @param formatItems Whether to format item names, if applicable
|
* @param formatNames Whether to format item/entity names, if applicable
|
||||||
* @return List of detailed objectives
|
* @return List of detailed objectives
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public LinkedList<Objective> getCurrentObjectivesTemp(final IQuest quest, final boolean ignoreOverrides,
|
public LinkedList<BukkitObjective> getCurrentObjectivesTemp(final IQuest quest, final boolean ignoreOverrides,
|
||||||
final boolean formatItems) {
|
final boolean formatNames) {
|
||||||
if (quest == null) {
|
if (quest == null) {
|
||||||
plugin.getLogger().severe("Quest was null when getting objectives for " + getLastKnownName());
|
plugin.getLogger().severe("Quest was null when getting objectives for " + getLastKnownName());
|
||||||
return new LinkedList<>();
|
return new LinkedList<>();
|
||||||
@ -1587,7 +1588,7 @@ public class Quester implements IQuester {
|
|||||||
}
|
}
|
||||||
final IDependencies depends = plugin.getDependencies();
|
final IDependencies depends = plugin.getDependencies();
|
||||||
if (!ignoreOverrides && !getCurrentStage(quest).getObjectiveOverrides().isEmpty()) {
|
if (!ignoreOverrides && !getCurrentStage(quest).getObjectiveOverrides().isEmpty()) {
|
||||||
final LinkedList<Objective> objectives = new LinkedList<>();
|
final LinkedList<BukkitObjective> objectives = new LinkedList<>();
|
||||||
for (final String s: getCurrentStage(quest).getObjectiveOverrides()) {
|
for (final String s: getCurrentStage(quest).getObjectiveOverrides()) {
|
||||||
String message = ChatColor.GREEN + ConfigUtil.parseString(s, quest, getPlayer());
|
String message = ChatColor.GREEN + ConfigUtil.parseString(s, quest, getPlayer());
|
||||||
if (depends.getPlaceholderApi() != null) {
|
if (depends.getPlaceholderApi() != null) {
|
||||||
@ -1600,7 +1601,7 @@ public class Quester implements IQuester {
|
|||||||
}
|
}
|
||||||
final QuestData data = getQuestData(quest);
|
final QuestData data = getQuestData(quest);
|
||||||
final IStage stage = getCurrentStage(quest);
|
final IStage stage = getCurrentStage(quest);
|
||||||
final LinkedList<Objective> objectives = new LinkedList<>();
|
final LinkedList<BukkitObjective> objectives = new LinkedList<>();
|
||||||
for (final ItemStack goal : stage.getBlocksToBreak()) {
|
for (final ItemStack goal : stage.getBlocksToBreak()) {
|
||||||
for (final ItemStack progress : data.blocksBroken) {
|
for (final ItemStack progress : data.blocksBroken) {
|
||||||
if (progress.getType().equals(goal.getType()) && progress.getDurability() == goal.getDurability()) {
|
if (progress.getType().equals(goal.getType()) && progress.getDurability() == goal.getDurability()) {
|
||||||
@ -1616,7 +1617,7 @@ public class Quester implements IQuester {
|
|||||||
if (depends.getPlaceholderApi() != null) {
|
if (depends.getPlaceholderApi() != null) {
|
||||||
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
||||||
}
|
}
|
||||||
if (formatItems) {
|
if (formatNames) {
|
||||||
message = message.replace("<item>", ItemUtil.getName(progress));
|
message = message.replace("<item>", ItemUtil.getName(progress));
|
||||||
}
|
}
|
||||||
objectives.add(new BukkitObjective(ObjectiveType.BREAK_BLOCK, message, progress, goal));
|
objectives.add(new BukkitObjective(ObjectiveType.BREAK_BLOCK, message, progress, goal));
|
||||||
@ -1638,7 +1639,7 @@ public class Quester implements IQuester {
|
|||||||
if (depends.getPlaceholderApi() != null) {
|
if (depends.getPlaceholderApi() != null) {
|
||||||
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
||||||
}
|
}
|
||||||
if (formatItems) {
|
if (formatNames) {
|
||||||
message = message.replace("<item>", ItemUtil.getName(progress));
|
message = message.replace("<item>", ItemUtil.getName(progress));
|
||||||
}
|
}
|
||||||
objectives.add(new BukkitObjective(ObjectiveType.DAMAGE_BLOCK, message, progress, goal));
|
objectives.add(new BukkitObjective(ObjectiveType.DAMAGE_BLOCK, message, progress, goal));
|
||||||
@ -1660,7 +1661,7 @@ public class Quester implements IQuester {
|
|||||||
if (depends.getPlaceholderApi() != null) {
|
if (depends.getPlaceholderApi() != null) {
|
||||||
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
||||||
}
|
}
|
||||||
if (formatItems) {
|
if (formatNames) {
|
||||||
message = message.replace("<item>", ItemUtil.getName(progress));
|
message = message.replace("<item>", ItemUtil.getName(progress));
|
||||||
}
|
}
|
||||||
objectives.add(new BukkitObjective(ObjectiveType.PLACE_BLOCK, message, progress, goal));
|
objectives.add(new BukkitObjective(ObjectiveType.PLACE_BLOCK, message, progress, goal));
|
||||||
@ -1682,7 +1683,7 @@ public class Quester implements IQuester {
|
|||||||
if (depends.getPlaceholderApi() != null) {
|
if (depends.getPlaceholderApi() != null) {
|
||||||
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
||||||
}
|
}
|
||||||
if (formatItems) {
|
if (formatNames) {
|
||||||
message = message.replace("<item>", ItemUtil.getName(progress));
|
message = message.replace("<item>", ItemUtil.getName(progress));
|
||||||
}
|
}
|
||||||
objectives.add(new BukkitObjective(ObjectiveType.USE_BLOCK, message, progress, goal));
|
objectives.add(new BukkitObjective(ObjectiveType.USE_BLOCK, message, progress, goal));
|
||||||
@ -1704,7 +1705,7 @@ public class Quester implements IQuester {
|
|||||||
if (depends.getPlaceholderApi() != null) {
|
if (depends.getPlaceholderApi() != null) {
|
||||||
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
||||||
}
|
}
|
||||||
if (formatItems) {
|
if (formatNames) {
|
||||||
message = message.replace("<item>", ItemUtil.getName(progress));
|
message = message.replace("<item>", ItemUtil.getName(progress));
|
||||||
}
|
}
|
||||||
objectives.add(new BukkitObjective(ObjectiveType.CUT_BLOCK, message, progress, goal));
|
objectives.add(new BukkitObjective(ObjectiveType.CUT_BLOCK, message, progress, goal));
|
||||||
@ -1728,7 +1729,7 @@ public class Quester implements IQuester {
|
|||||||
if (depends.getPlaceholderApi() != null) {
|
if (depends.getPlaceholderApi() != null) {
|
||||||
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
||||||
}
|
}
|
||||||
if (formatItems) {
|
if (formatNames) {
|
||||||
message = message.replace("<item>", ItemUtil.getName(goal));
|
message = message.replace("<item>", ItemUtil.getName(goal));
|
||||||
}
|
}
|
||||||
objectives.add(new BukkitObjective(ObjectiveType.CRAFT_ITEM, message, progress, goal));
|
objectives.add(new BukkitObjective(ObjectiveType.CRAFT_ITEM, message, progress, goal));
|
||||||
@ -1752,7 +1753,7 @@ public class Quester implements IQuester {
|
|||||||
if (depends.getPlaceholderApi() != null) {
|
if (depends.getPlaceholderApi() != null) {
|
||||||
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
||||||
}
|
}
|
||||||
if (formatItems) {
|
if (formatNames) {
|
||||||
message = message.replace("<item>", ItemUtil.getName(goal));
|
message = message.replace("<item>", ItemUtil.getName(goal));
|
||||||
}
|
}
|
||||||
objectives.add(new BukkitObjective(ObjectiveType.SMELT_ITEM, message, progress, goal));
|
objectives.add(new BukkitObjective(ObjectiveType.SMELT_ITEM, message, progress, goal));
|
||||||
@ -1776,7 +1777,7 @@ public class Quester implements IQuester {
|
|||||||
if (depends.getPlaceholderApi() != null) {
|
if (depends.getPlaceholderApi() != null) {
|
||||||
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
||||||
}
|
}
|
||||||
if (formatItems) {
|
if (formatNames) {
|
||||||
message = message.replace("<item>", ItemUtil.getName(goal));
|
message = message.replace("<item>", ItemUtil.getName(goal));
|
||||||
}
|
}
|
||||||
if (goal.getEnchantments().isEmpty()) {
|
if (goal.getEnchantments().isEmpty()) {
|
||||||
@ -1811,7 +1812,7 @@ public class Quester implements IQuester {
|
|||||||
if (depends.getPlaceholderApi() != null) {
|
if (depends.getPlaceholderApi() != null) {
|
||||||
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
||||||
}
|
}
|
||||||
if (formatItems) {
|
if (formatNames) {
|
||||||
message = message.replace("<item>", ItemUtil.getName(goal));
|
message = message.replace("<item>", ItemUtil.getName(goal));
|
||||||
}
|
}
|
||||||
objectives.add(new BukkitObjective(ObjectiveType.BREW_ITEM, message, progress, goal));
|
objectives.add(new BukkitObjective(ObjectiveType.BREW_ITEM, message, progress, goal));
|
||||||
@ -1835,7 +1836,7 @@ public class Quester implements IQuester {
|
|||||||
if (depends.getPlaceholderApi() != null) {
|
if (depends.getPlaceholderApi() != null) {
|
||||||
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
||||||
}
|
}
|
||||||
if (formatItems) {
|
if (formatNames) {
|
||||||
message = message.replace("<item>", ItemUtil.getName(goal));
|
message = message.replace("<item>", ItemUtil.getName(goal));
|
||||||
}
|
}
|
||||||
objectives.add(new BukkitObjective(ObjectiveType.CONSUME_ITEM, message, progress, goal));
|
objectives.add(new BukkitObjective(ObjectiveType.CONSUME_ITEM, message, progress, goal));
|
||||||
@ -1860,7 +1861,7 @@ public class Quester implements IQuester {
|
|||||||
if (depends.getPlaceholderApi() != null) {
|
if (depends.getPlaceholderApi() != null) {
|
||||||
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
||||||
}
|
}
|
||||||
if (formatItems) {
|
if (formatNames) {
|
||||||
message = message.replace("<item>", ItemUtil.getName(goal));
|
message = message.replace("<item>", ItemUtil.getName(goal));
|
||||||
}
|
}
|
||||||
objectives.add(new BukkitObjective(ObjectiveType.DELIVER_ITEM, message, progress, goal));
|
objectives.add(new BukkitObjective(ObjectiveType.DELIVER_ITEM, message, progress, goal));
|
||||||
@ -1937,16 +1938,20 @@ public class Quester implements IQuester {
|
|||||||
if (depends.getPlaceholderApi() != null) {
|
if (depends.getPlaceholderApi() != null) {
|
||||||
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
message = PlaceholderAPI.setPlaceholders(getPlayer(), message);
|
||||||
}
|
}
|
||||||
|
if (formatNames) {
|
||||||
message = message.replace("<mob>", MiscUtil.getProperMobName(e));
|
message = message.replace("<mob>", MiscUtil.getProperMobName(e));
|
||||||
objectives.add(new BukkitObjective(ObjectiveType.KILL_MOB, message, mobKilled, toMobKill));
|
}
|
||||||
|
objectives.add(new BukkitObjective(ObjectiveType.KILL_MOB, message,
|
||||||
|
new CountableMob(e, mobKilled), new CountableMob(e, toMobKill)));
|
||||||
mobKillIndex++;
|
mobKillIndex++;
|
||||||
}
|
}
|
||||||
int tameIndex = 0;
|
int tameIndex = 0;
|
||||||
for (final int toTame : stage.getMobNumToTame()) {
|
for (final EntityType e : stage.getMobsToTame()) {
|
||||||
int tamed = 0;
|
int tamed = 0;
|
||||||
if (data.mobsTamed.size() > tameIndex) {
|
if (data.mobsTamed.size() > tameIndex) {
|
||||||
tamed = data.mobsTamed.get(tameIndex);
|
tamed = data.mobsTamed.get(tameIndex);
|
||||||
}
|
}
|
||||||
|
final int toTame = stage.getMobNumToTame().get(tameIndex);
|
||||||
final ChatColor color = tamed < toTame ? ChatColor.GREEN : ChatColor.GRAY;
|
final ChatColor color = tamed < toTame ? ChatColor.GREEN : ChatColor.GRAY;
|
||||||
String message = color + Lang.get(getPlayer(), "tame");
|
String message = color + Lang.get(getPlayer(), "tame");
|
||||||
if (!message.contains("<mob>")) {
|
if (!message.contains("<mob>")) {
|
||||||
@ -1958,8 +1963,11 @@ public class Quester implements IQuester {
|
|||||||
// Legacy
|
// Legacy
|
||||||
message += color + ": " + tamed + "/" + toTame;
|
message += color + ": " + tamed + "/" + toTame;
|
||||||
}
|
}
|
||||||
|
if (formatNames) {
|
||||||
message = message.replace("<mob>", MiscUtil.getProperMobName(stage.getMobsToTame().get(tameIndex)));
|
message = message.replace("<mob>", MiscUtil.getProperMobName(stage.getMobsToTame().get(tameIndex)));
|
||||||
objectives.add(new BukkitObjective(ObjectiveType.TAME_MOB, message, tamed, toTame));
|
}
|
||||||
|
objectives.add(new BukkitObjective(ObjectiveType.TAME_MOB, message,
|
||||||
|
new CountableMob(e, tamed), new CountableMob(e, toTame)));
|
||||||
tameIndex++;
|
tameIndex++;
|
||||||
}
|
}
|
||||||
if (stage.getFishToCatch() != null) {
|
if (stage.getFishToCatch() != null) {
|
||||||
@ -3629,9 +3637,9 @@ public class Quester implements IQuester {
|
|||||||
}
|
}
|
||||||
final Player p = getPlayer();
|
final Player p = getPlayer();
|
||||||
final ObjectiveType type = objective.getType();
|
final ObjectiveType type = objective.getType();
|
||||||
final ItemStack increment = objective.getItemProgress() != null ? objective.getItemProgress()
|
final ItemStack increment = objective.getGoalObject() instanceof ItemStack ? (ItemStack) objective
|
||||||
: new ItemStack(Material.AIR, objective.getProgress());
|
: new ItemStack(Material.AIR, objective.getProgress());
|
||||||
final ItemStack goal = objective.getItemGoal() != null ? objective.getItemGoal()
|
final ItemStack goal = objective.getGoalObject() instanceof ItemStack ? (ItemStack) objective
|
||||||
: new ItemStack(Material.AIR, objective.getGoal());
|
: new ItemStack(Material.AIR, objective.getGoal());
|
||||||
if (!getCurrentStage(quest).getObjectiveOverrides().isEmpty()) {
|
if (!getCurrentStage(quest).getObjectiveOverrides().isEmpty()) {
|
||||||
for (final String s: getCurrentStage(quest).getObjectiveOverrides()) {
|
for (final String s: getCurrentStage(quest).getObjectiveOverrides()) {
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||||
|
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.blackvein.quests.entity;
|
||||||
|
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
|
public class CountableMob {
|
||||||
|
|
||||||
|
private EntityType entityType;
|
||||||
|
private int count;
|
||||||
|
|
||||||
|
public CountableMob(EntityType entityType, int count) {
|
||||||
|
this.entityType = entityType;
|
||||||
|
this.count = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityType getEntityType() {
|
||||||
|
return entityType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEntityType(final EntityType entityType) {
|
||||||
|
this.entityType = entityType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCount() {
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCount(final int count) {
|
||||||
|
this.count = count;
|
||||||
|
}
|
||||||
|
}
|
@ -12,12 +12,14 @@
|
|||||||
|
|
||||||
package me.blackvein.quests.item;
|
package me.blackvein.quests.item;
|
||||||
|
|
||||||
|
import me.blackvein.quests.Quester;
|
||||||
import me.blackvein.quests.Quests;
|
import me.blackvein.quests.Quests;
|
||||||
import me.blackvein.quests.player.IQuester;
|
import me.blackvein.quests.player.IQuester;
|
||||||
|
import me.blackvein.quests.quests.BukkitObjective;
|
||||||
import me.blackvein.quests.quests.IQuest;
|
import me.blackvein.quests.quests.IQuest;
|
||||||
import me.blackvein.quests.quests.Objective;
|
|
||||||
import me.blackvein.quests.util.ItemUtil;
|
import me.blackvein.quests.util.ItemUtil;
|
||||||
import me.blackvein.quests.util.Lang;
|
import me.blackvein.quests.util.Lang;
|
||||||
|
import me.blackvein.quests.util.MiscUtil;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import net.md_5.bungee.api.chat.TranslatableComponent;
|
import net.md_5.bungee.api.chat.TranslatableComponent;
|
||||||
@ -72,23 +74,40 @@ public class QuestJournal {
|
|||||||
title.setColor(net.md_5.bungee.api.ChatColor.DARK_PURPLE);
|
title.setColor(net.md_5.bungee.api.ChatColor.DARK_PURPLE);
|
||||||
title.setBold(true);
|
title.setBold(true);
|
||||||
final BookUtil.PageBuilder builder = new BookUtil.PageBuilder().add(title).newLine();
|
final BookUtil.PageBuilder builder = new BookUtil.PageBuilder().add(title).newLine();
|
||||||
for (final Objective obj : owner.getCurrentObjectivesTemp(quest, false, false)) {
|
for (final BukkitObjective obj : ((Quester)owner).getCurrentObjectivesTemp(quest, false, false)) {
|
||||||
if (obj.getMessage() != null && obj.getMessage().contains("<item>")) {
|
if (obj.getMessage() != null) {
|
||||||
final String[] split = obj.getMessage().split("<item>");
|
String[] split = null;
|
||||||
|
if (obj.getMessage().contains("<item>") && obj.getGoalAsItem() != null) {
|
||||||
|
split = obj.getMessage().split("<item>");
|
||||||
builder.add(split[0]);
|
builder.add(split[0]);
|
||||||
if (plugin.getSettings().canTranslateNames() && obj.getItemGoal() != null) {
|
if (plugin.getSettings().canTranslateNames()) {
|
||||||
final TranslatableComponent tc = new TranslatableComponent(plugin.getLocaleManager()
|
final TranslatableComponent tc = new TranslatableComponent(plugin.getLocaleManager()
|
||||||
.queryItemStack(obj.getItemGoal()));
|
.queryItemStack(obj.getGoalAsItem()));
|
||||||
tc.setColor(net.md_5.bungee.api.ChatColor.DARK_AQUA);
|
tc.setColor(net.md_5.bungee.api.ChatColor.DARK_AQUA);
|
||||||
builder.add(tc);
|
builder.add(tc);
|
||||||
} else {
|
} else {
|
||||||
builder.add(ItemUtil.getName(obj.getItemGoal()));
|
builder.add(ItemUtil.getName(obj.getGoalAsItem()));
|
||||||
}
|
}
|
||||||
builder.add(split[1]).newLine();
|
builder.add(split[1]).newLine();
|
||||||
|
}
|
||||||
|
if (obj.getMessage().contains("<mob>") && obj.getGoalAsMob() != null) {
|
||||||
|
split = obj.getMessage().split("<mob>");
|
||||||
|
builder.add(split[0]);
|
||||||
|
if (plugin.getSettings().canTranslateNames()) {
|
||||||
|
final TranslatableComponent tc = new TranslatableComponent(plugin.getLocaleManager()
|
||||||
|
.queryEntityType(obj.getGoalAsMob().getEntityType(), null)); // TODO extra data
|
||||||
|
tc.setColor(net.md_5.bungee.api.ChatColor.DARK_RED);
|
||||||
|
builder.add(tc);
|
||||||
} else {
|
} else {
|
||||||
|
builder.add(MiscUtil.snakeCaseToUpperCamelCase(obj.getGoalAsMob().getEntityType().name()));
|
||||||
|
}
|
||||||
|
builder.add(split[1]).newLine();
|
||||||
|
}
|
||||||
|
if (split == null) {
|
||||||
builder.add(obj.getMessage()).newLine();
|
builder.add(obj.getMessage()).newLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
pages.add(builder.build());
|
pages.add(builder.build());
|
||||||
}
|
}
|
||||||
return pages;
|
return pages;
|
||||||
|
@ -12,17 +12,19 @@
|
|||||||
|
|
||||||
package me.blackvein.quests.quests;
|
package me.blackvein.quests.quests;
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import me.blackvein.quests.entity.CountableMob;
|
||||||
|
|
||||||
import me.blackvein.quests.enums.ObjectiveType;
|
import me.blackvein.quests.enums.ObjectiveType;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class BukkitObjective implements Objective {
|
public class BukkitObjective implements Objective {
|
||||||
private final ObjectiveType type;
|
private final ObjectiveType type;
|
||||||
private final String message;
|
private final String message;
|
||||||
private final int progress;
|
private final int progress;
|
||||||
private final int goal;
|
private final int goal;
|
||||||
private final ItemStack progressStack;
|
private final Object progressObj;
|
||||||
private final ItemStack goalStack;
|
private final Object goalObj;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #BukkitObjective(ObjectiveType, String, int, int)} with null message
|
* @deprecated Use {@link #BukkitObjective(ObjectiveType, String, int, int)} with null message
|
||||||
@ -32,61 +34,97 @@ public class BukkitObjective implements Objective {
|
|||||||
this.message = null;
|
this.message = null;
|
||||||
this.progress = progress;
|
this.progress = progress;
|
||||||
this.goal = goal;
|
this.goal = goal;
|
||||||
this.progressStack = null;
|
this.progressObj = new Object();
|
||||||
this.goalStack = null;
|
this.goalObj = new Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #BukkitObjective(ObjectiveType, String, ItemStack, ItemStack)} with null message
|
* @deprecated Use {@link #BukkitObjective(ObjectiveType, String, Object, Object)} with null message
|
||||||
*/
|
*/
|
||||||
public BukkitObjective(final ObjectiveType type, final ItemStack progress, final ItemStack goal) {
|
public BukkitObjective(final ObjectiveType type, final ItemStack progress, final ItemStack goal) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.message = null;
|
this.message = null;
|
||||||
this.progress = progress.getAmount();
|
this.progress = progress.getAmount();
|
||||||
this.goal = goal.getAmount();
|
this.goal = goal.getAmount();
|
||||||
this.progressStack = progress;
|
this.progressObj = progress;
|
||||||
this.goalStack = goal;
|
this.goalObj = goal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BukkitObjective(final ObjectiveType type, final String message, final int progress, final int goal) {
|
public BukkitObjective(final ObjectiveType type, @Nullable final String message, final int progress,
|
||||||
|
final int goal) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.progress = progress;
|
this.progress = progress;
|
||||||
this.goal = goal;
|
this.goal = goal;
|
||||||
this.progressStack = null;
|
this.progressObj = new Object();
|
||||||
this.goalStack = null;
|
this.goalObj = new Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BukkitObjective(final ObjectiveType type, final String message, final ItemStack progress, final ItemStack goal) {
|
public BukkitObjective(final ObjectiveType type, @Nullable final String message, final @NotNull Object progress,
|
||||||
|
final @NotNull Object goal) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.progress = progress.getAmount();
|
this.progressObj = progress;
|
||||||
this.goal = goal.getAmount();
|
this.goalObj = goal;
|
||||||
this.progressStack = progress;
|
if (progressObj instanceof ItemStack) {
|
||||||
this.goalStack = goal;
|
this.progress = ((ItemStack) progressObj).getAmount();
|
||||||
|
} else if (progressObj instanceof CountableMob) {
|
||||||
|
this.progress = ((CountableMob) progressObj).getCount();
|
||||||
|
} else {
|
||||||
|
this.progress = 0;
|
||||||
|
}
|
||||||
|
if (goalObj instanceof ItemStack) {
|
||||||
|
this.goal = ((ItemStack) goalObj).getAmount();
|
||||||
|
} else if (goalObj instanceof CountableMob) {
|
||||||
|
this.goal = ((CountableMob) goalObj).getCount();
|
||||||
|
} else {
|
||||||
|
this.goal = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ObjectiveType getType() {
|
public ObjectiveType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getProgress() {
|
public int getProgress() {
|
||||||
return progress;
|
return progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getGoal() {
|
public int getGoal() {
|
||||||
return goal;
|
return goal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItemProgress() {
|
@Override
|
||||||
return progressStack;
|
public @NotNull Object getProgressObject() {
|
||||||
|
return progressObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItemGoal() {
|
@Override
|
||||||
return goalStack;
|
public @NotNull Object getGoalObject() {
|
||||||
|
return goalObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable ItemStack getProgressAsItem() {
|
||||||
|
return progressObj instanceof ItemStack ? (ItemStack) progressObj : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable ItemStack getGoalAsItem() {
|
||||||
|
return goalObj instanceof ItemStack ? (ItemStack) goalObj : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable CountableMob getProgressAsMob() {
|
||||||
|
return progressObj instanceof CountableMob ? (CountableMob) progressObj : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable CountableMob getGoalAsMob() {
|
||||||
|
return goalObj instanceof CountableMob ? (CountableMob) goalObj : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
dist/pom.xml
vendored
2
dist/pom.xml
vendored
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>me.blackvein.quests</groupId>
|
<groupId>me.blackvein.quests</groupId>
|
||||||
<artifactId>quests-parent</artifactId>
|
<artifactId>quests-parent</artifactId>
|
||||||
<version>4.2.4</version>
|
<version>4.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>quests-dist</artifactId>
|
<artifactId>quests-dist</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
4
pom.xml
4
pom.xml
@ -6,12 +6,12 @@
|
|||||||
<groupId>me.blackvein.quests</groupId>
|
<groupId>me.blackvein.quests</groupId>
|
||||||
|
|
||||||
<artifactId>quests-parent</artifactId>
|
<artifactId>quests-parent</artifactId>
|
||||||
<version>4.2.4</version>
|
<version>4.3.0</version>
|
||||||
<name>quests</name>
|
<name>quests</name>
|
||||||
<url>https://github.com/PikaMug/Quests/</url>
|
<url>https://github.com/PikaMug/Quests/</url>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<revision>4.2.4</revision>
|
<revision>4.3.0</revision>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>me.blackvein.quests</groupId>
|
<groupId>me.blackvein.quests</groupId>
|
||||||
<artifactId>quests-parent</artifactId>
|
<artifactId>quests-parent</artifactId>
|
||||||
<version>4.2.4</version>
|
<version>4.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>me.blackvein.quests</groupId>
|
<groupId>me.blackvein.quests</groupId>
|
||||||
<artifactId>quests-parent</artifactId>
|
<artifactId>quests-parent</artifactId>
|
||||||
<version>4.2.4</version>
|
<version>4.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>me.blackvein.quests</groupId>
|
<groupId>me.blackvein.quests</groupId>
|
||||||
<artifactId>quests-parent</artifactId>
|
<artifactId>quests-parent</artifactId>
|
||||||
<version>4.2.4</version>
|
<version>4.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
Loading…
Reference in New Issue
Block a user