mirror of
https://github.com/PikaMug/Quests.git
synced 2025-01-24 01:02:00 +01:00
Correct erroneous enchantment string functionality, fixes #1538
This commit is contained in:
parent
33f53917f5
commit
900a86fe0a
@ -187,14 +187,14 @@ public abstract class CustomObjective implements Listener {
|
|||||||
|
|
||||||
if (progress >= goal) {
|
if (progress >= goal) {
|
||||||
quester.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
quester.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, goal)), null, null, null, null, null, null, null, obj);
|
new ItemStack(Material.AIR, goal)), null, null, null, null, null, null, obj);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
quester.dispatchMultiplayerObjectives(quest, quester.getCurrentStage(quest), (final Quester q) -> {
|
quester.dispatchMultiplayerObjectives(quest, quester.getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).customObjectiveCounts.put(obj.getName(),
|
q.getQuestData(quest).customObjectiveCounts.put(obj.getName(),
|
||||||
quester.getQuestData(quest).customObjectiveCounts.get(obj.getName()));
|
quester.getQuestData(quest).customObjectiveCounts.get(obj.getName()));
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, goal)), null, null, null, null, null, null, null, obj);
|
new ItemStack(Material.AIR, goal)), null, null, null, null, null, null, obj);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,7 @@ import me.blackvein.quests.util.ItemUtil;
|
|||||||
import me.blackvein.quests.util.Lang;
|
import me.blackvein.quests.util.Lang;
|
||||||
import me.blackvein.quests.util.LocaleQuery;
|
import me.blackvein.quests.util.LocaleQuery;
|
||||||
import me.blackvein.quests.util.MiscUtil;
|
import me.blackvein.quests.util.MiscUtil;
|
||||||
|
import me.blackvein.quests.util.RomanNumeral;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
|
|
||||||
@ -1409,7 +1410,7 @@ public class Quester implements Comparable<Quester> {
|
|||||||
if (getQuestData(quest).blocksBroken.contains(broken)) {
|
if (getQuestData(quest).blocksBroken.contains(broken)) {
|
||||||
getQuestData(quest).blocksBroken.set(getQuestData(quest).blocksBroken.indexOf(broken), newBroken);
|
getQuestData(quest).blocksBroken.set(getQuestData(quest).blocksBroken.indexOf(broken), newBroken);
|
||||||
if (broken.getAmount() == toBreak.getAmount()) {
|
if (broken.getAmount() == toBreak.getAmount()) {
|
||||||
finishObjective(quest, new Objective(type, m, toBreak), null, null, null, null, null, null, null, null);
|
finishObjective(quest, new Objective(type, m, toBreak), null, null, null, null, null, null, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
final ItemStack finalBroken = broken;
|
final ItemStack finalBroken = broken;
|
||||||
@ -1417,7 +1418,7 @@ public class Quester implements Comparable<Quester> {
|
|||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).blocksBroken.set(getQuestData(quest).blocksBroken
|
q.getQuestData(quest).blocksBroken.set(getQuestData(quest).blocksBroken
|
||||||
.indexOf(finalBroken), newBroken);
|
.indexOf(finalBroken), newBroken);
|
||||||
q.finishObjective(quest, new Objective(type, m, finalToBreak), null, null, null, null, null, null,
|
q.finishObjective(quest, new Objective(type, m, finalToBreak), null, null, null, null, null,
|
||||||
null, null);
|
null, null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
@ -1497,7 +1498,7 @@ public class Quester implements Comparable<Quester> {
|
|||||||
if (getQuestData(quest).blocksDamaged.contains(damaged)) {
|
if (getQuestData(quest).blocksDamaged.contains(damaged)) {
|
||||||
getQuestData(quest).blocksDamaged.set(getQuestData(quest).blocksDamaged.indexOf(damaged), newDamaged);
|
getQuestData(quest).blocksDamaged.set(getQuestData(quest).blocksDamaged.indexOf(damaged), newDamaged);
|
||||||
if (damaged.getAmount() == toDamage.getAmount()) {
|
if (damaged.getAmount() == toDamage.getAmount()) {
|
||||||
finishObjective(quest, new Objective(type, m, toDamage), null, null, null, null, null, null, null, null);
|
finishObjective(quest, new Objective(type, m, toDamage), null, null, null, null, null, null, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
final ItemStack finalDamaged = damaged;
|
final ItemStack finalDamaged = damaged;
|
||||||
@ -1505,7 +1506,7 @@ public class Quester implements Comparable<Quester> {
|
|||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).blocksDamaged.set(getQuestData(quest).blocksDamaged
|
q.getQuestData(quest).blocksDamaged.set(getQuestData(quest).blocksDamaged
|
||||||
.indexOf(finalDamaged), newDamaged);
|
.indexOf(finalDamaged), newDamaged);
|
||||||
q.finishObjective(quest, new Objective(type, m, finalToDamage), null, null, null, null, null, null,
|
q.finishObjective(quest, new Objective(type, m, finalToDamage), null, null, null, null, null,
|
||||||
null, null);
|
null, null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
@ -1584,7 +1585,7 @@ public class Quester implements Comparable<Quester> {
|
|||||||
if (getQuestData(quest).blocksPlaced.contains(placed)) {
|
if (getQuestData(quest).blocksPlaced.contains(placed)) {
|
||||||
getQuestData(quest).blocksPlaced.set(getQuestData(quest).blocksPlaced.indexOf(placed), newPlaced);
|
getQuestData(quest).blocksPlaced.set(getQuestData(quest).blocksPlaced.indexOf(placed), newPlaced);
|
||||||
if (placed.getAmount() == toPlace.getAmount()) {
|
if (placed.getAmount() == toPlace.getAmount()) {
|
||||||
finishObjective(quest, new Objective(type, m, toPlace), null, null, null, null, null, null, null, null);
|
finishObjective(quest, new Objective(type, m, toPlace), null, null, null, null, null, null, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
final ItemStack finalPlaced = placed;
|
final ItemStack finalPlaced = placed;
|
||||||
@ -1592,7 +1593,7 @@ public class Quester implements Comparable<Quester> {
|
|||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).blocksPlaced.set(getQuestData(quest).blocksPlaced
|
q.getQuestData(quest).blocksPlaced.set(getQuestData(quest).blocksPlaced
|
||||||
.indexOf(finalPlaced), newPlaced);
|
.indexOf(finalPlaced), newPlaced);
|
||||||
q.finishObjective(quest, new Objective(type, m, finalToPlace), null, null, null, null, null, null,
|
q.finishObjective(quest, new Objective(type, m, finalToPlace), null, null, null, null, null,
|
||||||
null, null);
|
null, null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
@ -1671,7 +1672,7 @@ public class Quester implements Comparable<Quester> {
|
|||||||
if (getQuestData(quest).blocksUsed.contains(used)) {
|
if (getQuestData(quest).blocksUsed.contains(used)) {
|
||||||
getQuestData(quest).blocksUsed.set(getQuestData(quest).blocksUsed.indexOf(used), newUsed);
|
getQuestData(quest).blocksUsed.set(getQuestData(quest).blocksUsed.indexOf(used), newUsed);
|
||||||
if (used.getAmount() == toUse.getAmount()) {
|
if (used.getAmount() == toUse.getAmount()) {
|
||||||
finishObjective(quest, new Objective(type, m, toUse), null, null, null, null, null, null, null, null);
|
finishObjective(quest, new Objective(type, m, toUse), null, null, null, null, null, null, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
final ItemStack finalUsed = used;
|
final ItemStack finalUsed = used;
|
||||||
@ -1679,7 +1680,7 @@ public class Quester implements Comparable<Quester> {
|
|||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).blocksUsed.set(getQuestData(quest).blocksUsed
|
q.getQuestData(quest).blocksUsed.set(getQuestData(quest).blocksUsed
|
||||||
.indexOf(finalUsed), newUsed);
|
.indexOf(finalUsed), newUsed);
|
||||||
q.finishObjective(quest, new Objective(type, m, finalToUse), null, null, null, null, null, null, null,
|
q.finishObjective(quest, new Objective(type, m, finalToUse), null, null, null, null, null, null,
|
||||||
null);
|
null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
@ -1758,14 +1759,14 @@ public class Quester implements Comparable<Quester> {
|
|||||||
if (getQuestData(quest).blocksCut.contains(cut)) {
|
if (getQuestData(quest).blocksCut.contains(cut)) {
|
||||||
getQuestData(quest).blocksCut.set(getQuestData(quest).blocksCut.indexOf(cut), newCut);
|
getQuestData(quest).blocksCut.set(getQuestData(quest).blocksCut.indexOf(cut), newCut);
|
||||||
if (cut.getAmount() == toCut.getAmount()) {
|
if (cut.getAmount() == toCut.getAmount()) {
|
||||||
finishObjective(quest, new Objective(type, m, toCut), null, null, null, null, null, null, null, null);
|
finishObjective(quest, new Objective(type, m, toCut), null, null, null, null, null, null, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
final ItemStack finalCut = cut;
|
final ItemStack finalCut = cut;
|
||||||
final ItemStack finalToCut = toCut;
|
final ItemStack finalToCut = toCut;
|
||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).blocksCut.set(getQuestData(quest).blocksCut.indexOf(finalCut), newCut);
|
q.getQuestData(quest).blocksCut.set(getQuestData(quest).blocksCut.indexOf(finalCut), newCut);
|
||||||
q.finishObjective(quest, new Objective(type, m, finalToCut), null, null, null, null, null, null, null,
|
q.finishObjective(quest, new Objective(type, m, finalToCut), null, null, null, null, null, null,
|
||||||
null);
|
null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
@ -1820,14 +1821,14 @@ public class Quester implements Comparable<Quester> {
|
|||||||
final Material m = i.getType();
|
final Material m = i.getType();
|
||||||
if (newAmount >= req) {
|
if (newAmount >= req) {
|
||||||
getQuestData(quest).itemsCrafted.put(found, req);
|
getQuestData(quest).itemsCrafted.put(found, req);
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null, null, null, null,
|
finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null, null, null,
|
||||||
null, null);
|
null, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
final ItemStack finalFound = found;
|
final ItemStack finalFound = found;
|
||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).itemsCrafted.put(finalFound, req);
|
q.getQuestData(quest).itemsCrafted.put(finalFound, req);
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(m, 1), finalFound), null, null, null, null,
|
q.finishObjective(quest, new Objective(type, new ItemStack(m, 1), finalFound), null, null, null,
|
||||||
null, null, null, null);
|
null, null, null, null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
@ -1882,14 +1883,14 @@ public class Quester implements Comparable<Quester> {
|
|||||||
final Material m = i.getType();
|
final Material m = i.getType();
|
||||||
if (newAmount >= req) {
|
if (newAmount >= req) {
|
||||||
getQuestData(quest).itemsSmelted.put(found, req);
|
getQuestData(quest).itemsSmelted.put(found, req);
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null, null, null, null,
|
finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null, null, null,
|
||||||
null, null);
|
null, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
final ItemStack finalFound = found;
|
final ItemStack finalFound = found;
|
||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).itemsSmelted.put(finalFound, req);
|
q.getQuestData(quest).itemsSmelted.put(finalFound, req);
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(m, 1), finalFound), null, null, null, null,
|
q.finishObjective(quest, new Objective(type, new ItemStack(m, 1), finalFound), null, null, null,
|
||||||
null, null, null, null);
|
null, null, null, null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
@ -1913,9 +1914,16 @@ public class Quester implements Comparable<Quester> {
|
|||||||
final Player player = getPlayer();
|
final Player player = getPlayer();
|
||||||
ItemStack found = null;
|
ItemStack found = null;
|
||||||
for (final ItemStack is : getQuestData(quest).itemsEnchanted.keySet()) {
|
for (final ItemStack is : getQuestData(quest).itemsEnchanted.keySet()) {
|
||||||
if (ItemUtil.compareItems(i, is, true) == 0) {
|
if (!is.getEnchantments().isEmpty()) {
|
||||||
found = is;
|
if (ItemUtil.compareItems(i, is, true) == 0) {
|
||||||
break;
|
found = is;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (ItemUtil.compareItems(i, is, true) == -4) {
|
||||||
|
found = is;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found == null) {
|
if (found == null) {
|
||||||
@ -1944,14 +1952,14 @@ public class Quester implements Comparable<Quester> {
|
|||||||
final Material m = i.getType();
|
final Material m = i.getType();
|
||||||
if (newAmount >= req) {
|
if (newAmount >= req) {
|
||||||
getQuestData(quest).itemsEnchanted.put(found, req);
|
getQuestData(quest).itemsEnchanted.put(found, req);
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null, null, null, null,
|
finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null, null, null,
|
||||||
null, null);
|
null, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
final ItemStack finalFound = found;
|
final ItemStack finalFound = found;
|
||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).itemsEnchanted.put(finalFound, req);
|
q.getQuestData(quest).itemsEnchanted.put(finalFound, req);
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(m, 1), finalFound), null, null, null, null,
|
q.finishObjective(quest, new Objective(type, new ItemStack(m, 1), finalFound), null, null, null,
|
||||||
null, null, null, null);
|
null, null, null, null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
@ -2006,14 +2014,14 @@ public class Quester implements Comparable<Quester> {
|
|||||||
final Material m = i.getType();
|
final Material m = i.getType();
|
||||||
if (newAmount >= req) {
|
if (newAmount >= req) {
|
||||||
getQuestData(quest).itemsBrewed.put(found, req);
|
getQuestData(quest).itemsBrewed.put(found, req);
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null, null, null, null,
|
finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null, null, null,
|
||||||
null, null);
|
null, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
final ItemStack finalFound = found;
|
final ItemStack finalFound = found;
|
||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).itemsBrewed.put(finalFound, req);
|
q.getQuestData(quest).itemsBrewed.put(finalFound, req);
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(m, 1), finalFound), null, null, null, null,
|
q.finishObjective(quest, new Objective(type, new ItemStack(m, 1), finalFound), null, null, null,
|
||||||
null, null, null, null);
|
null, null, null, null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
@ -2068,14 +2076,14 @@ public class Quester implements Comparable<Quester> {
|
|||||||
final Material m = i.getType();
|
final Material m = i.getType();
|
||||||
if (newAmount >= req) {
|
if (newAmount >= req) {
|
||||||
getQuestData(quest).itemsConsumed.put(found, req);
|
getQuestData(quest).itemsConsumed.put(found, req);
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null, null, null, null,
|
finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null, null, null,
|
||||||
null, null);
|
null, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
final ItemStack finalFound = found;
|
final ItemStack finalFound = found;
|
||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).itemsConsumed.put(finalFound, req);
|
q.getQuestData(quest).itemsConsumed.put(finalFound, req);
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(m, 1), finalFound), null, null, null, null,
|
q.finishObjective(quest, new Objective(type, new ItemStack(m, 1), finalFound), null, null, null,
|
||||||
null, null, null, null);
|
null, null, null, null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
@ -2109,13 +2117,13 @@ public class Quester implements Comparable<Quester> {
|
|||||||
|
|
||||||
if (newCowsMilked >= cowsToMilk) {
|
if (newCowsMilked >= cowsToMilk) {
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, cowsToMilk)), null, null, null, null, null, null, null, null);
|
new ItemStack(Material.AIR, cowsToMilk)), null, null, null, null, null, null, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).setCowsMilked(cowsToMilk);
|
q.getQuestData(quest).setCowsMilked(cowsToMilk);
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, cowsToMilk)), null, null, null, null, null, null, null, null);
|
new ItemStack(Material.AIR, cowsToMilk)), null, null, null, null, null, null, null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -2146,13 +2154,13 @@ public class Quester implements Comparable<Quester> {
|
|||||||
|
|
||||||
if (newFishCaught >= fishToCatch) {
|
if (newFishCaught >= fishToCatch) {
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, fishToCatch)), null, null, null, null, null, null, null, null);
|
new ItemStack(Material.AIR, fishToCatch)), null, null, null, null, null, null, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).setFishCaught(fishToCatch);
|
q.getQuestData(quest).setFishCaught(fishToCatch);
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, fishToCatch)), null, null, null, null, null, null, null, null);
|
new ItemStack(Material.AIR, fishToCatch)), null, null, null, null, null, null, null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -2216,15 +2224,13 @@ public class Quester implements Comparable<Quester> {
|
|||||||
questData.mobNumKilled.set(index, newMobsKilled);
|
questData.mobNumKilled.set(index, newMobsKilled);
|
||||||
if (newMobsKilled >= mobsToKill) {
|
if (newMobsKilled >= mobsToKill) {
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, mobsToKill)), null, e, null,
|
new ItemStack(Material.AIR, mobsToKill)), e, null, null, null, null, null, null);
|
||||||
null, null, null, null, null);
|
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
dispatchMultiplayerObjectives(quest, currentStage, (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, currentStage, (final Quester q) -> {
|
||||||
q.getQuestData(quest).mobNumKilled.set(index, newMobsKilled);
|
q.getQuestData(quest).mobNumKilled.set(index, newMobsKilled);
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, mobsToKill)), null, e,
|
new ItemStack(Material.AIR, mobsToKill)), e, null, null, null, null, null, null);
|
||||||
null, null, null, null, null, null);
|
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -2255,13 +2261,13 @@ public class Quester implements Comparable<Quester> {
|
|||||||
getQuestData(quest).setPlayersKilled(newPlayersKilled);
|
getQuestData(quest).setPlayersKilled(newPlayersKilled);
|
||||||
if (newPlayersKilled >= playersToKill) {
|
if (newPlayersKilled >= playersToKill) {
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, playersToKill)), null, null, null, null, null, null, null, null);
|
new ItemStack(Material.AIR, playersToKill)), null, null, null, null, null, null, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).setPlayersKilled(getQuestData(quest).getPlayersKilled());
|
q.getQuestData(quest).setPlayersKilled(getQuestData(quest).getPlayersKilled());
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, playersToKill)), null, null, null, null, null, null, null, null);
|
new ItemStack(Material.AIR, playersToKill)), null, null, null, null, null, null, null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -2332,13 +2338,13 @@ public class Quester implements Comparable<Quester> {
|
|||||||
player.getInventory().setItem(index, null);
|
player.getInventory().setItem(index, null);
|
||||||
}
|
}
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null, null, null,
|
finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null, null,
|
||||||
null, null, null);
|
null, null, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).itemsDelivered.set(items.indexOf(found), newStack);
|
q.getQuestData(quest).itemsDelivered.set(items.indexOf(found), newStack);
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null, null,
|
q.finishObjective(quest, new Objective(type, new ItemStack(m, 1), found), null, null, null,
|
||||||
null, null, null, null);
|
null, null, null, null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
@ -2382,13 +2388,13 @@ public class Quester implements Comparable<Quester> {
|
|||||||
if (b != null && !b) {
|
if (b != null && !b) {
|
||||||
getQuestData(quest).citizensInteracted.put(n.getId(), true);
|
getQuestData(quest).citizensInteracted.put(n.getId(), true);
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, 1)),
|
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, 1)),
|
||||||
null, null, null, n, null, null, null, null);
|
null, null, n, null, null, null, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).citizensInteracted.put(n.getId(), true);
|
q.getQuestData(quest).citizensInteracted.put(n.getId(), true);
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, 1)), null, null, null, n, null, null, null, null);
|
new ItemStack(Material.AIR, 1)), null, null, n, null, null, null, null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -2423,14 +2429,14 @@ public class Quester implements Comparable<Quester> {
|
|||||||
getQuestData(quest).citizenNumKilled.set(index, newNpcsKilled);
|
getQuestData(quest).citizenNumKilled.set(index, newNpcsKilled);
|
||||||
if (newNpcsKilled >= npcsToKill) {
|
if (newNpcsKilled >= npcsToKill) {
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, npcsToKill)), null, null, null, n, null, null, null, null);
|
new ItemStack(Material.AIR, npcsToKill)), null, null, n, null, null, null, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).citizenNumKilled.set(index, getQuestData(quest).citizenNumKilled
|
q.getQuestData(quest).citizenNumKilled.set(index, getQuestData(quest).citizenNumKilled
|
||||||
.get(index));
|
.get(index));
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, npcsToKill)), null, null, null, n, null, null, null, null);
|
new ItemStack(Material.AIR, npcsToKill)), null, null, n, null, null, null, null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -2485,13 +2491,13 @@ public class Quester implements Comparable<Quester> {
|
|||||||
if (locationsReached <= index) {
|
if (locationsReached <= index) {
|
||||||
getQuestData(quest).hasReached.add(true);
|
getQuestData(quest).hasReached.add(true);
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, 1)), null, null, null, null, location, null,
|
new ItemStack(Material.AIR, 1)), null, null, null, location, null, null,
|
||||||
null, null);
|
null);
|
||||||
} else if (getQuestData(quest).hasReached.get(index) == false) {
|
} else if (getQuestData(quest).hasReached.get(index) == false) {
|
||||||
getQuestData(quest).hasReached.set(index, true);
|
getQuestData(quest).hasReached.set(index, true);
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, 1)), null, null, null, null, location, null,
|
new ItemStack(Material.AIR, 1)), null, null, null, location, null, null,
|
||||||
null, null);
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
@ -2500,12 +2506,12 @@ public class Quester implements Comparable<Quester> {
|
|||||||
if (finalIndex >= getQuestData(quest).hasReached.size()) {
|
if (finalIndex >= getQuestData(quest).hasReached.size()) {
|
||||||
q.getQuestData(quest).hasReached.add(true);
|
q.getQuestData(quest).hasReached.add(true);
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, 1)), null, null, null, null, location, null,
|
new ItemStack(Material.AIR, 1)), null, null, null, location, null,
|
||||||
null, null);
|
null, null);
|
||||||
} else {
|
} else {
|
||||||
q.getQuestData(quest).hasReached.set(finalIndex, true);
|
q.getQuestData(quest).hasReached.set(finalIndex, true);
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, 1)), null, null, null, null, location, null,
|
new ItemStack(Material.AIR, 1)), null, null, null, location, null,
|
||||||
null, null);
|
null, null);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -2554,13 +2560,13 @@ public class Quester implements Comparable<Quester> {
|
|||||||
getQuestData(quest).mobsTamed.put(entity, newMobsToTame);
|
getQuestData(quest).mobsTamed.put(entity, newMobsToTame);
|
||||||
if (newMobsToTame >= mobsToTame) {
|
if (newMobsToTame >= mobsToTame) {
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, mobsToTame)), null, entity, null, null, null, null, null, null);
|
new ItemStack(Material.AIR, mobsToTame)), entity, null, null, null, null, null, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).mobsTamed.put(entity, getQuestData(quest).mobsTamed.get(entity));
|
q.getQuestData(quest).mobsTamed.put(entity, getQuestData(quest).mobsTamed.get(entity));
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, mobsToTame)), null, entity, null, null, null, null, null, null);
|
new ItemStack(Material.AIR, mobsToTame)), entity, null, null, null, null, null, null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -2594,13 +2600,13 @@ public class Quester implements Comparable<Quester> {
|
|||||||
getQuestData(quest).sheepSheared.put(color, newSheepSheared);
|
getQuestData(quest).sheepSheared.put(color, newSheepSheared);
|
||||||
if (newSheepSheared >= sheepToShear) {
|
if (newSheepSheared >= sheepToShear) {
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, sheepToShear)), null, null, null, null, null, color, null, null);
|
new ItemStack(Material.AIR, sheepToShear)), null, null, null, null, color, null, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).sheepSheared.put(color, getQuestData(quest).sheepSheared.get(color));
|
q.getQuestData(quest).sheepSheared.put(color, getQuestData(quest).sheepSheared.get(color));
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, sheepToShear)), null, null, null, null, null, color, null, null);
|
new ItemStack(Material.AIR, sheepToShear)), null, null, null, null, color, null, null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -2636,13 +2642,13 @@ public class Quester implements Comparable<Quester> {
|
|||||||
done = true;
|
done = true;
|
||||||
plugin.getServer().getScheduler().runTask(plugin, () -> {
|
plugin.getServer().getScheduler().runTask(plugin, () -> {
|
||||||
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, 1)), null, null, null, null, null, null, display, null);
|
new ItemStack(Material.AIR, 1)), null, null, null, null, null, display, null);
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> {
|
||||||
q.getQuestData(quest).passwordsSaid.put(display, true);
|
q.getQuestData(quest).passwordsSaid.put(display, true);
|
||||||
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
|
||||||
new ItemStack(Material.AIR, 1)), null, null, null, null, null, null, display, null);
|
new ItemStack(Material.AIR, 1)), null, null, null, null, null, display, null);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -2669,8 +2675,6 @@ public class Quester implements Comparable<Quester> {
|
|||||||
* Quest containing the objective
|
* Quest containing the objective
|
||||||
* @param objective
|
* @param objective
|
||||||
* Objective for type, progress and goal
|
* Objective for type, progress and goal
|
||||||
* @param enchantment
|
|
||||||
* Enchantment being applied by user, if any
|
|
||||||
* @param mob
|
* @param mob
|
||||||
* Mob being killed or tamed, if any
|
* Mob being killed or tamed, if any
|
||||||
* @param extra
|
* @param extra
|
||||||
@ -2687,9 +2691,8 @@ public class Quester implements Comparable<Quester> {
|
|||||||
* Custom objective, if any. See {@link me.blackvein.quests.CustomObjective}
|
* Custom objective, if any. See {@link me.blackvein.quests.CustomObjective}
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void finishObjective(final Quest quest, final Objective objective, final Enchantment enchantment,
|
public void finishObjective(final Quest quest, final Objective objective, final EntityType mob, final String extra,
|
||||||
final EntityType mob, final String extra, final NPC npc, final Location location, final DyeColor color,
|
final NPC npc, final Location location, final DyeColor color, final String pass, final CustomObjective co) {
|
||||||
final String pass, final CustomObjective co) {
|
|
||||||
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.getItemProgress() != null ? objective.getItemProgress()
|
||||||
@ -2817,11 +2820,21 @@ public class Quester implements Comparable<Quester> {
|
|||||||
// Legacy
|
// Legacy
|
||||||
message += ChatColor.GREEN + ": " + is.getAmount() + "/" + is.getAmount();
|
message += ChatColor.GREEN + ": " + is.getAmount() + "/" + is.getAmount();
|
||||||
}
|
}
|
||||||
if (plugin.getSettings().canTranslateNames() && !goal.hasItemMeta()
|
if (plugin.getSettings().canTranslateNames() && is.hasItemMeta() && !is.getItemMeta().hasDisplayName()) {
|
||||||
&& !goal.getItemMeta().hasDisplayName()) {
|
// Bukkit version is 1.9+
|
||||||
plugin.getLocaleQuery().sendMessage(p, message, goal.getType(), goal.getDurability(), null);
|
plugin.getLocaleQuery().sendMessage(p, message, goal.getType(), goal.getDurability(),
|
||||||
|
goal.getEnchantments(), goal.getItemMeta());
|
||||||
|
} else if (plugin.getSettings().canTranslateNames() && !is.hasItemMeta()
|
||||||
|
&& Material.getMaterial("LINGERING_POTION") == null) {
|
||||||
|
// Bukkit version is below 1.9
|
||||||
|
plugin.getLocaleQuery().sendMessage(p, message, goal.getType(), goal.getDurability(),
|
||||||
|
goal.getEnchantments());
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(message.replace("<item>", ItemUtil.getName(is)));
|
for (final Entry<Enchantment, Integer> e : is.getEnchantments().entrySet()) {
|
||||||
|
p.sendMessage(message.replace("<item>", ItemUtil.getName(is))
|
||||||
|
.replace("<enchantment>", ItemUtil.getPrettyEnchantmentName(e.getKey()))
|
||||||
|
.replace("<level>", RomanNumeral.getNumeral(e.getValue())));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (type.equals(ObjectiveType.BREW_ITEM)) {
|
} else if (type.equals(ObjectiveType.BREW_ITEM)) {
|
||||||
final ItemStack is = getCurrentStage(quest).itemsToBrew.get(getCurrentStage(quest).itemsToBrew.indexOf(goal));
|
final ItemStack is = getCurrentStage(quest).itemsToBrew.get(getCurrentStage(quest).itemsToBrew.indexOf(goal));
|
||||||
@ -2832,10 +2845,15 @@ public class Quester implements Comparable<Quester> {
|
|||||||
// Legacy
|
// Legacy
|
||||||
message += ChatColor.GREEN + ": " + is.getAmount() + "/" + is.getAmount();
|
message += ChatColor.GREEN + ": " + is.getAmount() + "/" + is.getAmount();
|
||||||
}
|
}
|
||||||
if (plugin.getSettings().canTranslateNames() && goal.hasItemMeta()
|
if (plugin.getSettings().canTranslateNames() && is.hasItemMeta() && !is.getItemMeta().hasDisplayName()) {
|
||||||
&& !goal.getItemMeta().hasDisplayName()) {
|
// Bukkit version is 1.9+
|
||||||
plugin.getLocaleQuery().sendMessage(p, message, goal.getType(), goal.getDurability(), null,
|
plugin.getLocaleQuery().sendMessage(p, message, goal.getType(), goal.getDurability(),
|
||||||
goal.getItemMeta());
|
goal.getEnchantments(), goal.getItemMeta());
|
||||||
|
} else if (plugin.getSettings().canTranslateNames() && !is.hasItemMeta()
|
||||||
|
&& Material.getMaterial("LINGERING_POTION") == null) {
|
||||||
|
// Bukkit version is below 1.9
|
||||||
|
plugin.getLocaleQuery().sendMessage(p, message, goal.getType(), goal.getDurability(),
|
||||||
|
goal.getEnchantments());
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(message.replace("<item>", ItemUtil.getName(is)));
|
p.sendMessage(message.replace("<item>", ItemUtil.getName(is)));
|
||||||
}
|
}
|
||||||
@ -3030,7 +3048,7 @@ public class Quester implements Comparable<Quester> {
|
|||||||
public void finishObjective(final Quest quest, final String objective, final ItemStack increment,
|
public void finishObjective(final Quest quest, final String objective, final ItemStack increment,
|
||||||
final ItemStack goal, final Enchantment enchantment, final EntityType mob, final String extra,
|
final ItemStack goal, final Enchantment enchantment, final EntityType mob, final String extra,
|
||||||
final NPC npc, final Location location, final DyeColor color, final String pass, final CustomObjective co) {
|
final NPC npc, final Location location, final DyeColor color, final String pass, final CustomObjective co) {
|
||||||
finishObjective(quest, new Objective(ObjectiveType.fromName(objective), increment, goal), enchantment, mob, extra, npc,
|
finishObjective(quest, new Objective(ObjectiveType.fromName(objective), increment, goal), mob, extra, npc,
|
||||||
location, color, pass, co);
|
location, color, pass, co);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +104,7 @@ import me.blackvein.quests.util.ItemUtil;
|
|||||||
import me.blackvein.quests.util.Lang;
|
import me.blackvein.quests.util.Lang;
|
||||||
import me.blackvein.quests.util.LocaleQuery;
|
import me.blackvein.quests.util.LocaleQuery;
|
||||||
import me.blackvein.quests.util.MiscUtil;
|
import me.blackvein.quests.util.MiscUtil;
|
||||||
|
import me.blackvein.quests.util.RomanNumeral;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import net.citizensnpcs.api.CitizensAPI;
|
import net.citizensnpcs.api.CitizensAPI;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
@ -1072,17 +1073,27 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (depends.getPlaceholderApi() != null) {
|
if (depends.getPlaceholderApi() != null) {
|
||||||
message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message);
|
message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message);
|
||||||
}
|
}
|
||||||
if (getSettings().canTranslateNames()) {
|
if (getSettings().canTranslateNames() && is.hasItemMeta() && !is.getItemMeta().hasDisplayName()) {
|
||||||
if (is.hasItemMeta() && !is.getItemMeta().hasDisplayName()) {
|
// Bukkit version is 1.9+
|
||||||
// Bukkit version is 1.9+
|
localeQuery.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(),
|
||||||
localeQuery.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(),
|
is.getEnchantments(), is.getItemMeta());
|
||||||
is.getEnchantments(), is.getItemMeta());
|
} else if (getSettings().canTranslateNames() && !is.hasItemMeta()
|
||||||
} else if (Material.getMaterial("LINGERING_POTION") == null && !is.hasItemMeta() ) {
|
&& Material.getMaterial("LINGERING_POTION") == null) {
|
||||||
// Bukkit version is below 1.9
|
// Bukkit version is below 1.9
|
||||||
localeQuery.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(),
|
localeQuery.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(),
|
||||||
is.getEnchantments());
|
is.getEnchantments());
|
||||||
|
} else {
|
||||||
|
if (is.getEnchantments().isEmpty()) {
|
||||||
|
quester.getPlayer().sendMessage(message.replace("<item>", ItemUtil.getName(is))
|
||||||
|
.replace("<enchantment>", "")
|
||||||
|
.replace("<level>", "")
|
||||||
|
.replaceAll("\\s+", " "));
|
||||||
} else {
|
} else {
|
||||||
quester.getPlayer().sendMessage(message.replace("<item>", ItemUtil.getName(is)));
|
for (final Entry<Enchantment, Integer> e : is.getEnchantments().entrySet()) {
|
||||||
|
quester.getPlayer().sendMessage(message.replace("<item>", ItemUtil.getName(is))
|
||||||
|
.replace("<enchantment>", ItemUtil.getPrettyEnchantmentName(e.getKey()))
|
||||||
|
.replace("<level>", RomanNumeral.getNumeral(e.getValue())));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1103,18 +1114,17 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (depends.getPlaceholderApi() != null) {
|
if (depends.getPlaceholderApi() != null) {
|
||||||
message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message);
|
message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message);
|
||||||
}
|
}
|
||||||
if (getSettings().canTranslateNames()) {
|
if (getSettings().canTranslateNames() && is.hasItemMeta() && !is.getItemMeta().hasDisplayName()) {
|
||||||
if (is.hasItemMeta() && !is.getItemMeta().hasDisplayName()) {
|
// Bukkit version is 1.9+
|
||||||
// Bukkit version is 1.9+
|
localeQuery.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(),
|
||||||
localeQuery.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(),
|
is.getEnchantments(), is.getItemMeta());
|
||||||
is.getEnchantments(), is.getItemMeta());
|
} else if (getSettings().canTranslateNames() && !is.hasItemMeta()
|
||||||
} else if (Material.getMaterial("LINGERING_POTION") == null && !is.hasItemMeta() ) {
|
&& Material.getMaterial("LINGERING_POTION") == null) {
|
||||||
// Bukkit version is below 1.9
|
// Bukkit version is below 1.9
|
||||||
localeQuery.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(),
|
localeQuery.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(),
|
||||||
is.getEnchantments());
|
is.getEnchantments());
|
||||||
} else {
|
} else {
|
||||||
quester.getPlayer().sendMessage(message.replace("<item>", ItemUtil.getName(is)));
|
quester.getPlayer().sendMessage(message.replace("<item>", ItemUtil.getName(is)));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (final ItemStack is : stage.itemsToConsume) {
|
for (final ItemStack is : stage.itemsToConsume) {
|
||||||
|
@ -16,6 +16,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -75,7 +76,8 @@ public class LocaleQuery {
|
|||||||
* but note that most Potions use meta for 1.13+.<p>
|
* but note that most Potions use meta for 1.13+.<p>
|
||||||
*
|
*
|
||||||
* Message should contain {@code <item>} string for replacement by
|
* Message should contain {@code <item>} string for replacement by
|
||||||
* this method (along with applicable {@code <enchantment>} strings).
|
* this method (along with applicable {@code <enchantment>} and/or
|
||||||
|
* {@code <level>} strings).
|
||||||
*
|
*
|
||||||
* @param player The player whom the message is to be sent to
|
* @param player The player whom the message is to be sent to
|
||||||
* @param message The message to be sent to the player
|
* @param message The message to be sent to the player
|
||||||
@ -91,6 +93,7 @@ public class LocaleQuery {
|
|||||||
}
|
}
|
||||||
String matKey = "";
|
String matKey = "";
|
||||||
final String[] enchKeys = enchantments != null ? new String[enchantments.size()] : null;
|
final String[] enchKeys = enchantments != null ? new String[enchantments.size()] : null;
|
||||||
|
final String[] lvlKeys = enchantments != null ? new String[enchantments.size()] : null;
|
||||||
if (oldVersion) {
|
if (oldVersion) {
|
||||||
if (material.isBlock()) {
|
if (material.isBlock()) {
|
||||||
if (durability >= 0 && oldBlocks.containsKey(material.name() + "." + durability)) {
|
if (durability >= 0 && oldBlocks.containsKey(material.name() + "." + durability)) {
|
||||||
@ -128,9 +131,10 @@ public class LocaleQuery {
|
|||||||
}
|
}
|
||||||
if (enchantments != null && !enchantments.isEmpty()) {
|
if (enchantments != null && !enchantments.isEmpty()) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (final Enchantment e : enchantments.keySet()) {
|
for (final Entry<Enchantment, Integer> e : enchantments.entrySet()) {
|
||||||
enchKeys[count] = "enchantment." + e.getName().toLowerCase().replace("_", ".")
|
enchKeys[count] = "enchantment." + e.getKey().getName().toLowerCase().replace("_", ".")
|
||||||
.replace("environmental", "all").replace("protection", "protect");
|
.replace("environmental", "all").replace("protection", "protect");
|
||||||
|
lvlKeys[count] = "enchantment.level." + e.getValue();
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,8 +157,9 @@ public class LocaleQuery {
|
|||||||
}
|
}
|
||||||
if (enchantments != null && !enchantments.isEmpty()) {
|
if (enchantments != null && !enchantments.isEmpty()) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (final Enchantment e : enchantments.keySet()) {
|
for (final Entry<Enchantment, Integer> e : enchantments.entrySet()) {
|
||||||
enchKeys[count] = "enchantment." + e.getKey().toString().toLowerCase().replace(":", ".");
|
enchKeys[count] = "enchantment." + e.getKey().getKey().toString().toLowerCase().replace(":", ".");
|
||||||
|
lvlKeys[count] = "enchantment.level." + e.getValue();
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,6 +169,9 @@ public class LocaleQuery {
|
|||||||
for (final String ek : enchKeys) {
|
for (final String ek : enchKeys) {
|
||||||
msg = msg.replace("<enchantment>", "\",{\"translate\":\"" + ek + "\"},\"");
|
msg = msg.replace("<enchantment>", "\",{\"translate\":\"" + ek + "\"},\"");
|
||||||
}
|
}
|
||||||
|
for (final String lk : lvlKeys) {
|
||||||
|
msg = msg.replace("<level>", "\",{\"translate\":\"" + lk + "\"},\"");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " [\"" + msg + "\"]");
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " [\"" + msg + "\"]");
|
||||||
return true;
|
return true;
|
||||||
@ -193,8 +201,8 @@ public class LocaleQuery {
|
|||||||
* Send message with enchantments translated to the client's locale.
|
* Send message with enchantments translated to the client's locale.
|
||||||
* Map of Enchantment+level is required.
|
* Map of Enchantment+level is required.
|
||||||
*
|
*
|
||||||
* Message should contain one {@code <enchantment>} string for each
|
* Message should contain one {@code <enchantment>} and/or {@code <level>}
|
||||||
* replacement by this method.
|
* string for each replacement by this method.
|
||||||
*
|
*
|
||||||
* @param player The player whom the message is to be sent to
|
* @param player The player whom the message is to be sent to
|
||||||
* @param message The message to be sent to the player
|
* @param message The message to be sent to the player
|
||||||
@ -205,20 +213,23 @@ public class LocaleQuery {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final String[] enchKeys = enchantments != null ? new String[enchantments.size()] : null;
|
final String[] enchKeys = enchantments != null ? new String[enchantments.size()] : null;
|
||||||
|
final String[] lvlKeys = enchantments != null ? new String[enchantments.size()] : null;
|
||||||
if (oldVersion) {
|
if (oldVersion) {
|
||||||
if (enchantments != null && !enchantments.isEmpty()) {
|
if (enchantments != null && !enchantments.isEmpty()) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (final Enchantment e : enchantments.keySet()) {
|
for (final Entry<Enchantment, Integer> e : enchantments.entrySet()) {
|
||||||
enchKeys[count] = "enchantment." + e.getName().toLowerCase().replace("_", ".")
|
enchKeys[count] = "enchantment." + e.getKey().getName().toLowerCase().replace("_", ".")
|
||||||
.replace("environmental", "all").replace("protection", "protect");
|
.replace("environmental", "all").replace("protection", "protect");
|
||||||
|
lvlKeys[count] = "enchantment.level." + e.getValue();
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (enchantments != null && !enchantments.isEmpty()) {
|
if (enchantments != null && !enchantments.isEmpty()) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (final Enchantment e : enchantments.keySet()) {
|
for (final Entry<Enchantment, Integer> e : enchantments.entrySet()) {
|
||||||
enchKeys[count] = "enchantment.minecraft." + e.toString().toLowerCase();
|
enchKeys[count] = "enchantment." + e.getKey().getKey().toString().toLowerCase().replace(":", ".");;
|
||||||
|
lvlKeys[count] = "enchantment.level." + e.getValue();
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -228,6 +239,9 @@ public class LocaleQuery {
|
|||||||
for (final String ek : enchKeys) {
|
for (final String ek : enchKeys) {
|
||||||
msg.replaceFirst("<enchantment>", "\",{\"translate\":\"" + ek + "\"},\"");
|
msg.replaceFirst("<enchantment>", "\",{\"translate\":\"" + ek + "\"},\"");
|
||||||
}
|
}
|
||||||
|
for (final String lk : lvlKeys) {
|
||||||
|
msg.replaceFirst("<level>", "\",{\"translate\":\"" + lk + "\"},\"");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " [\"" + msg + "\"]");
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " [\"" + msg + "\"]");
|
||||||
return true;
|
return true;
|
||||||
|
@ -646,7 +646,7 @@ use: "Use <item>: <count>"
|
|||||||
cut: "Shear <item>: <count>"
|
cut: "Shear <item>: <count>"
|
||||||
craftItem: "Craft <item>: <count>"
|
craftItem: "Craft <item>: <count>"
|
||||||
smeltItem: "Smelt <item>: <count>"
|
smeltItem: "Smelt <item>: <count>"
|
||||||
enchItem: "Enchant <item>: <count>"
|
enchItem: "Enchant <enchantment> <level> <item>: <count>"
|
||||||
brewItem: "Brew <item>: <count>"
|
brewItem: "Brew <item>: <count>"
|
||||||
consumeItem: "Consume <item>: <count>"
|
consumeItem: "Consume <item>: <count>"
|
||||||
catchFish: "Catch Fish: <count>"
|
catchFish: "Catch Fish: <count>"
|
||||||
|
Loading…
Reference in New Issue
Block a user