mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-29 06:06:05 +01:00
Bug fixes
This commit is contained in:
parent
c78a1aae05
commit
7c333095fc
@ -69,6 +69,11 @@ public class Event {
|
||||
float health = -1;
|
||||
Location teleport;
|
||||
|
||||
public int hashCode() {
|
||||
assert false : "hashCode not designed";
|
||||
return 42; // any arbitrary constant will do
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
|
@ -272,7 +272,10 @@ public class Quest {
|
||||
}
|
||||
|
||||
for (String q : blockQuests) {
|
||||
if (quester.completedQuests.contains(q) || quester.currentQuests.containsKey(q)) {
|
||||
//TODO make sure this works
|
||||
Quest questObject = new Quest();
|
||||
questObject.name = q;
|
||||
if (quester.completedQuests.contains(q) || quester.currentQuests.containsKey(questObject)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -139,10 +139,10 @@ public class Quester {
|
||||
|
||||
private static final long serialVersionUID = 5475202358792520975L;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
/*@SuppressWarnings("unused")
|
||||
public void hardClear() {
|
||||
super.clear();
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public Integer put(String key, Integer val) {
|
||||
@ -318,11 +318,17 @@ public class Quester {
|
||||
}
|
||||
|
||||
public Stage getCurrentStage(Quest quest) {
|
||||
return quest.getStage(currentQuests.get(quest));
|
||||
if (currentQuests.containsKey(quest)) {
|
||||
return quest.getStage(currentQuests.get(quest));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public QuestData getQuestData(Quest quest) {
|
||||
return questData.get(quest);
|
||||
if (questData.containsKey(quest)) {
|
||||
return questData.get(quest);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void takeQuest(Quest q, boolean override) {
|
||||
@ -609,7 +615,7 @@ public class Quester {
|
||||
for (EntityType e2 : getQuestData(quest).mobsKilled) {
|
||||
|
||||
if (e == e2) {
|
||||
if (getQuestData(quest).mobNumKilled.size() > getQuestData(quest).mobsKilled.indexOf(e2) & getCurrentStage(quest).mobNumToKill.size() > getCurrentStage(quest).mobsToKill.indexOf(e)) {
|
||||
if (getQuestData(quest).mobNumKilled.size() > getQuestData(quest).mobsKilled.indexOf(e2) && getCurrentStage(quest).mobNumToKill.size() > getCurrentStage(quest).mobsToKill.indexOf(e)) {
|
||||
|
||||
if (getQuestData(quest).mobNumKilled.get(getQuestData(quest).mobsKilled.indexOf(e2)) < getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(e))) {
|
||||
|
||||
@ -710,7 +716,7 @@ public class Quester {
|
||||
for (Integer n2 : getQuestData(quest).citizensKilled) {
|
||||
|
||||
if (n.equals(n2)) {
|
||||
if (getQuestData(quest).citizenNumKilled.size() > getQuestData(quest).citizensKilled.indexOf(n2) & getCurrentStage(quest).citizenNumToKill.size() > getCurrentStage(quest).citizensToKill.indexOf(n)) {
|
||||
if (getQuestData(quest).citizenNumKilled.size() > getQuestData(quest).citizensKilled.indexOf(n2) && getCurrentStage(quest).citizenNumToKill.size() > getCurrentStage(quest).citizensToKill.indexOf(n)) {
|
||||
|
||||
if (getQuestData(quest).citizenNumKilled.get(getQuestData(quest).citizensKilled.indexOf(n2)) < getCurrentStage(quest).citizenNumToKill.get(getCurrentStage(quest).citizensToKill.indexOf(n))) {
|
||||
|
||||
|
@ -2618,7 +2618,15 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
if (config.contains("quests." + questName + ".guiDisplay")) {
|
||||
|
||||
String item = config.getString("quests." + questName + ".guiDisplay");
|
||||
quest.guiDisplay = ItemUtil.readItemStack(item);
|
||||
try {
|
||||
ItemStack stack = ItemUtil.readItemStack(item);
|
||||
|
||||
if (stack != null) {
|
||||
quest.guiDisplay = stack;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
instance.getLogger().warning(item + " in items: Gui Display in Quest " + quest.name + "is not properly formatted!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -3514,8 +3522,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
deliveryMessages.addAll(config.getStringList("quests." + questName + ".stages.ordered." + s2 + ".delivery-messages"));
|
||||
|
||||
for (String item : itemsToDeliver) {
|
||||
// TODO
|
||||
getLogger().severe("hello");
|
||||
getLogger().info("hello");
|
||||
getLogger().severe("item: " + item);
|
||||
ItemStack is = ItemUtil.readItemStack(item);
|
||||
ItemStack is = ItemUtil.readItemStack("" + item);
|
||||
|
||||
if (is != null) {
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class Stage {
|
||||
for (Integer i : this) {
|
||||
|
||||
Integer other = otherList.get(this.indexOf(i));
|
||||
if (other != i) {
|
||||
if (!other.equals(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -75,7 +75,7 @@ public class Stage {
|
||||
for (Integer i : this) {
|
||||
|
||||
Integer other = otherList.get(this.indexOf(i));
|
||||
if (other != i) {
|
||||
if (!other.equals(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -102,7 +102,7 @@ public class Stage {
|
||||
for (Integer i : this) {
|
||||
|
||||
Integer other = otherList.get(this.indexOf(i));
|
||||
if (other != i) {
|
||||
if (!other.equals(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -141,6 +141,11 @@ public class Stage {
|
||||
public String startMessage = null;
|
||||
public String objectiveOverride = null;
|
||||
|
||||
public int hashCode() {
|
||||
assert false : "hashCode not designed";
|
||||
return 42; // any arbitrary constant will do
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
|
@ -73,13 +73,11 @@ public class ItemUtil implements ColorUtil {
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Formats -> name-name:amount-amount:data-data:enchantment-enchantment level:displayname-displayname:lore-lore:
|
||||
//Returns null if invalid format
|
||||
public static ItemStack readItemStack(String data) {
|
||||
plugin.getLogger().severe("data: " + data);
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
@ -89,9 +87,13 @@ public class ItemUtil implements ColorUtil {
|
||||
ItemMeta meta = null;
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
for (String arg : args) {
|
||||
|
||||
if (arg.startsWith("name-")) {
|
||||
stack = new ItemStack(Material.matchMaterial(arg.substring(3)));
|
||||
//Attempt to match item name. Returns null if invalid format
|
||||
try {
|
||||
stack = new ItemStack(Material.matchMaterial(arg.substring(5)));
|
||||
} catch (NullPointerException npe) {
|
||||
return null;
|
||||
}
|
||||
meta = stack.getItemMeta();
|
||||
} else if (arg.startsWith("amount-")) {
|
||||
stack.setAmount(Integer.parseInt(arg.substring(7)));
|
||||
@ -106,7 +108,6 @@ public class ItemUtil implements ColorUtil {
|
||||
} else if (arg.startsWith("lore-")) {
|
||||
lore.add(arg.substring(5));
|
||||
} else {
|
||||
plugin.getLogger().severe("Malformed itemstack data in quests.yml: " + arg);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class MiscUtil {
|
||||
}
|
||||
|
||||
if (type.equals("d")) {
|
||||
timeMilliSeconds += t * 86400000;
|
||||
timeMilliSeconds += t * 86400000L;
|
||||
} else if (type.equals("h")) {
|
||||
timeMilliSeconds += t * 3600000;
|
||||
} else if (type.equals("m")) {
|
||||
|
@ -220,6 +220,11 @@ public class QuestMob {
|
||||
return qm;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
assert false : "hashCode not designed";
|
||||
return 42; // any arbitrary constant will do
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ((o instanceof QuestMob) == false) {
|
||||
@ -237,11 +242,11 @@ public class QuestMob {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (entityType != other.entityType) {
|
||||
if (!entityType.equals(other.entityType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dropChances != other.dropChances) {
|
||||
if (!dropChances.equals(other.dropChances)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -255,11 +260,11 @@ public class QuestMob {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (spawnAmounts != other.spawnAmounts) {
|
||||
if (!spawnAmounts.equals(other.spawnAmounts)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (spawnLocation != other.spawnLocation) {
|
||||
if (!spawnLocation.equals(other.spawnLocation)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ quests:
|
||||
redo-delay: 1800000
|
||||
requirements:
|
||||
items:
|
||||
- name-wooden_pickaxe:amount-1
|
||||
- name-wood_pickaxe:amount-1
|
||||
remove-items:
|
||||
- false
|
||||
fail-requirement-message: '<red>You must have a <purple>Wooden Pickaxe<red> first.'
|
||||
|
Loading…
Reference in New Issue
Block a user