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