mirror of
https://github.com/PikaMug/Quests.git
synced 2024-12-25 10:38:21 +01:00
Update /quests info, code cleanup
This commit is contained in:
parent
f74879aa74
commit
3370e50417
@ -13,8 +13,6 @@ import java.util.Random;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -676,33 +674,7 @@ public class Quester {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void damageBlock(Quest quest, ItemStack m) {
|
|
||||||
ItemStack temp = m;
|
|
||||||
temp.setAmount(0);
|
|
||||||
ItemStack damaged = temp;
|
|
||||||
ItemStack toDamage = temp;
|
|
||||||
for (ItemStack is : getQuestData(quest).blocksDamaged) {
|
|
||||||
if (m.getType() == is.getType() && m.getDurability() == is.getDurability()) {
|
|
||||||
damaged = is;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (ItemStack is : getCurrentStage(quest).blocksToDamage) {
|
|
||||||
if (m.getType() == is.getType() && m.getDurability() == is.getDurability()) {
|
|
||||||
toDamage = is;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (damaged.getAmount() < toDamage.getAmount()) {
|
|
||||||
ItemStack newDamaged = damaged;
|
|
||||||
newDamaged.setAmount(damaged.getAmount() + 1);
|
|
||||||
// TODO is this correct?
|
|
||||||
getQuestData(quest).blocksDamaged.set(getQuestData(quest).blocksDamaged.indexOf(damaged), newDamaged);
|
|
||||||
if (damaged.getAmount() == toDamage.getAmount()) {
|
|
||||||
finishObjective(quest, "damageBlock", m, null, null, null, null, null, null, null, null, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void breakBlock(Quest quest, ItemStack m) {
|
public void breakBlock(Quest quest, ItemStack m) {
|
||||||
ItemStack temp = m;
|
ItemStack temp = m;
|
||||||
temp.setAmount(0);
|
temp.setAmount(0);
|
||||||
@ -728,6 +700,32 @@ public class Quester {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void damageBlock(Quest quest, ItemStack m) {
|
||||||
|
ItemStack temp = m;
|
||||||
|
temp.setAmount(0);
|
||||||
|
ItemStack damaged = temp;
|
||||||
|
ItemStack toDamage = temp;
|
||||||
|
for (ItemStack is : getQuestData(quest).blocksDamaged) {
|
||||||
|
if (m.getType() == is.getType() && m.getDurability() == is.getDurability()) {
|
||||||
|
damaged = is;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (ItemStack is : getCurrentStage(quest).blocksToDamage) {
|
||||||
|
if (m.getType() == is.getType() && m.getDurability() == is.getDurability()) {
|
||||||
|
toDamage = is;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (damaged.getAmount() < toDamage.getAmount()) {
|
||||||
|
ItemStack newDamaged = damaged;
|
||||||
|
newDamaged.setAmount(damaged.getAmount() + 1);
|
||||||
|
// TODO is this correct?
|
||||||
|
getQuestData(quest).blocksDamaged.set(getQuestData(quest).blocksDamaged.indexOf(damaged), newDamaged);
|
||||||
|
if (damaged.getAmount() == toDamage.getAmount()) {
|
||||||
|
finishObjective(quest, "damageBlock", m, null, null, null, null, null, null, null, null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void placeBlock(Quest quest, ItemStack m) {
|
public void placeBlock(Quest quest, ItemStack m) {
|
||||||
ItemStack temp = m;
|
ItemStack temp = m;
|
||||||
@ -1061,14 +1059,6 @@ public class Quester {
|
|||||||
if (testComplete(quest)) {
|
if (testComplete(quest)) {
|
||||||
quest.nextStage(this);
|
quest.nextStage(this);
|
||||||
}
|
}
|
||||||
} else if (objective.equalsIgnoreCase("damageBlock")) {
|
|
||||||
String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("damage") + " " + prettyItemString(material.getType().name());
|
|
||||||
String stack = getQuestData(quest).blocksDamaged.toString();
|
|
||||||
String amount = stack.substring(stack.lastIndexOf(" x ") + 3).replace("}]", "");
|
|
||||||
message = message + " " + amount + "/" + amount;
|
|
||||||
if (testComplete(quest)) {
|
|
||||||
quest.nextStage(this);
|
|
||||||
}
|
|
||||||
} else if (objective.equalsIgnoreCase("breakBlock")) {
|
} else if (objective.equalsIgnoreCase("breakBlock")) {
|
||||||
String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("break") + " " + prettyItemString(material.getType().name());
|
String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("break") + " " + prettyItemString(material.getType().name());
|
||||||
String stack = getQuestData(quest).blocksBroken.toString();
|
String stack = getQuestData(quest).blocksBroken.toString();
|
||||||
@ -1078,6 +1068,14 @@ public class Quester {
|
|||||||
if (testComplete(quest)) {
|
if (testComplete(quest)) {
|
||||||
quest.nextStage(this);
|
quest.nextStage(this);
|
||||||
}
|
}
|
||||||
|
} else if (objective.equalsIgnoreCase("damageBlock")) {
|
||||||
|
String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("damage") + " " + prettyItemString(material.getType().name());
|
||||||
|
String stack = getQuestData(quest).blocksDamaged.toString();
|
||||||
|
String amount = stack.substring(stack.lastIndexOf(" x ") + 3).replace("}]", "");
|
||||||
|
message = message + " " + amount + "/" + amount;
|
||||||
|
if (testComplete(quest)) {
|
||||||
|
quest.nextStage(this);
|
||||||
|
}
|
||||||
} else if (objective.equalsIgnoreCase("placeBlock")) {
|
} else if (objective.equalsIgnoreCase("placeBlock")) {
|
||||||
String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("place") + " " + prettyItemString(material.getType().name());
|
String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("place") + " " + prettyItemString(material.getType().name());
|
||||||
String stack = getQuestData(quest).blocksPlaced.toString();
|
String stack = getQuestData(quest).blocksPlaced.toString();
|
||||||
@ -1224,18 +1222,6 @@ public class Quester {
|
|||||||
public void addEmpties(Quest quest) {
|
public void addEmpties(Quest quest) {
|
||||||
QuestData data = new QuestData(this);
|
QuestData data = new QuestData(this);
|
||||||
data.setDoJournalUpdate(false);
|
data.setDoJournalUpdate(false);
|
||||||
if (quest.getStage(0).blocksToDamage.isEmpty() == false) {
|
|
||||||
for (ItemStack i : quest.getStage(0).blocksToDamage) {
|
|
||||||
if (data.blocksDamaged.indexOf(i) != -1) {
|
|
||||||
// TODO Will this ever happen?
|
|
||||||
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
|
||||||
data.blocksDamaged.set(data.blocksDamaged.indexOf(temp), temp);
|
|
||||||
} else {
|
|
||||||
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
|
||||||
data.blocksDamaged.add(temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (quest.getStage(0).blocksToBreak.isEmpty() == false) {
|
if (quest.getStage(0).blocksToBreak.isEmpty() == false) {
|
||||||
for (ItemStack i : quest.getStage(0).blocksToBreak) {
|
for (ItemStack i : quest.getStage(0).blocksToBreak) {
|
||||||
if (data.blocksBroken.indexOf(i) != -1) {
|
if (data.blocksBroken.indexOf(i) != -1) {
|
||||||
@ -1248,6 +1234,18 @@ public class Quester {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (quest.getStage(0).blocksToDamage.isEmpty() == false) {
|
||||||
|
for (ItemStack i : quest.getStage(0).blocksToDamage) {
|
||||||
|
if (data.blocksDamaged.indexOf(i) != -1) {
|
||||||
|
// TODO Will this ever happen?
|
||||||
|
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
||||||
|
data.blocksDamaged.set(data.blocksDamaged.indexOf(temp), temp);
|
||||||
|
} else {
|
||||||
|
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
||||||
|
data.blocksDamaged.add(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (quest.getStage(0).blocksToPlace.isEmpty() == false) {
|
if (quest.getStage(0).blocksToPlace.isEmpty() == false) {
|
||||||
for (ItemStack i : quest.getStage(0).blocksToPlace) {
|
for (ItemStack i : quest.getStage(0).blocksToPlace) {
|
||||||
if (data.blocksPlaced.indexOf(i) != -1) {
|
if (data.blocksPlaced.indexOf(i) != -1) {
|
||||||
@ -1354,18 +1352,6 @@ public class Quester {
|
|||||||
public void addEmptiesFor(Quest quest, int stage) {
|
public void addEmptiesFor(Quest quest, int stage) {
|
||||||
QuestData data = new QuestData(this);
|
QuestData data = new QuestData(this);
|
||||||
data.setDoJournalUpdate(false);
|
data.setDoJournalUpdate(false);
|
||||||
if (quest.getStage(stage).blocksToDamage.isEmpty() == false) {
|
|
||||||
for (ItemStack i : quest.getStage(stage).blocksToDamage) {
|
|
||||||
if (data.blocksDamaged.indexOf(i) != -1) {
|
|
||||||
// TODO Will this ever happen?
|
|
||||||
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
|
||||||
data.blocksDamaged.set(data.blocksDamaged.indexOf(temp), temp);
|
|
||||||
} else {
|
|
||||||
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
|
||||||
data.blocksDamaged.add(temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (quest.getStage(stage).blocksToBreak.isEmpty() == false) {
|
if (quest.getStage(stage).blocksToBreak.isEmpty() == false) {
|
||||||
for (ItemStack i : quest.getStage(stage).blocksToBreak) {
|
for (ItemStack i : quest.getStage(stage).blocksToBreak) {
|
||||||
if (data.blocksBroken.indexOf(i) != -1) {
|
if (data.blocksBroken.indexOf(i) != -1) {
|
||||||
@ -1378,6 +1364,18 @@ public class Quester {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (quest.getStage(stage).blocksToDamage.isEmpty() == false) {
|
||||||
|
for (ItemStack i : quest.getStage(stage).blocksToDamage) {
|
||||||
|
if (data.blocksDamaged.indexOf(i) != -1) {
|
||||||
|
// TODO Will this ever happen?
|
||||||
|
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
||||||
|
data.blocksDamaged.set(data.blocksDamaged.indexOf(temp), temp);
|
||||||
|
} else {
|
||||||
|
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
||||||
|
data.blocksDamaged.add(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (quest.getStage(stage).blocksToPlace.isEmpty() == false) {
|
if (quest.getStage(stage).blocksToPlace.isEmpty() == false) {
|
||||||
for (ItemStack i : quest.getStage(stage).blocksToPlace) {
|
for (ItemStack i : quest.getStage(stage).blocksToPlace) {
|
||||||
if (data.blocksPlaced.indexOf(i) != -1) {
|
if (data.blocksPlaced.indexOf(i) != -1) {
|
||||||
@ -1967,7 +1965,7 @@ public class Quester {
|
|||||||
stage = getCurrentStage(quest);
|
stage = getCurrentStage(quest);
|
||||||
if (stage == null) {
|
if (stage == null) {
|
||||||
quest.completeQuest(this);
|
quest.completeQuest(this);
|
||||||
plugin.getLogger().log(Level.SEVERE, "[Quests] Invalid stage number for player: \"" + id + "\" on Quest \"" + quest.name + "\". Quest ended.");
|
plugin.getLogger().severe("[Quests] Invalid stage number for player: \"" + id + "\" on Quest \"" + quest.name + "\". Quest ended.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
addEmpties(quest);
|
addEmpties(quest);
|
||||||
@ -2533,7 +2531,7 @@ public class Quester {
|
|||||||
questData.remove(quest);
|
questData.remove(quest);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(Quests.class.getName()).log(Level.SEVERE, null, ex);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2541,7 +2539,7 @@ public class Quester {
|
|||||||
try {
|
try {
|
||||||
completedQuests.remove(quest.name);
|
completedQuests.remove(quest.name);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(Quests.class.getName()).log(Level.SEVERE, null, ex);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2551,7 +2549,7 @@ public class Quester {
|
|||||||
questData.clear();
|
questData.clear();
|
||||||
amountsCompleted.clear();
|
amountsCompleted.clear();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(Quests.class.getName()).log(Level.SEVERE, null, ex);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2559,7 +2557,7 @@ public class Quester {
|
|||||||
try {
|
try {
|
||||||
currentQuests.put(key, val);
|
currentQuests.put(key, val);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(Quests.class.getName()).log(Level.SEVERE, null, ex);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2567,7 +2565,7 @@ public class Quester {
|
|||||||
try {
|
try {
|
||||||
questData.put(key, val);
|
questData.put(key, val);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(Quests.class.getName()).log(Level.SEVERE, null, ex);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import java.util.UUID;
|
|||||||
import java.util.jar.JarEntry;
|
import java.util.jar.JarEntry;
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -1274,7 +1274,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
|
|
||||||
private boolean questsInfo(final CommandSender cs) {
|
private boolean questsInfo(final CommandSender cs) {
|
||||||
cs.sendMessage(ChatColor.GOLD + Lang.get("quests") + " " + this.getDescription().getVersion());
|
cs.sendMessage(ChatColor.GOLD + Lang.get("quests") + " " + this.getDescription().getVersion());
|
||||||
cs.sendMessage(ChatColor.GOLD + Lang.get("createdBy") + " " + ChatColor.DARK_RED + "Blackvein");
|
cs.sendMessage(ChatColor.GOLD + Lang.get("createdBy") + " " + ChatColor.DARK_RED + "Blackvein"
|
||||||
|
+ ChatColor.GOLD + " " + Lang.get("continuedBy") + " " + ChatColor.DARK_RED + "FlyingPikachu");
|
||||||
|
cs.sendMessage(ChatColor.AQUA + "" + ChatColor.UNDERLINE + "https://www.spigotmc.org/resources/quests.3711/");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3912,8 +3914,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
int numQuesters = 0;
|
int numQuesters = 0;
|
||||||
int succeeded = 0;
|
int succeeded = 0;
|
||||||
int failed = 0;
|
int failed = 0;
|
||||||
final File dataFolder = new File(this.getDataFolder(), "data/");
|
final File dataFolder = new File(this.getDataFolder(), "data" + File.separator);
|
||||||
final File oldDataFolder = new File(this.getDataFolder(), "data/old/");
|
final File oldDataFolder = new File(this.getDataFolder(), "data" + File.separator + "old" + File.separator);
|
||||||
if (oldDataFolder.exists() == false || oldDataFolder.exists() && oldDataFolder.isDirectory() == false) {
|
if (oldDataFolder.exists() == false || oldDataFolder.exists() && oldDataFolder.isDirectory() == false) {
|
||||||
oldDataFolder.mkdir();
|
oldDataFolder.mkdir();
|
||||||
}
|
}
|
||||||
@ -3960,7 +3962,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
idMap = fetcher.call();
|
idMap = fetcher.call();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
getLogger().severe("Error retrieving data from Mojang account database. Error log:");
|
getLogger().severe("Error retrieving data from Mojang account database. Error log:");
|
||||||
Logger.getLogger(Quests.class.getName()).log(Level.SEVERE, null, ex);
|
ex.printStackTrace();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Entry<String, UUID> entry : idMap.entrySet()) {
|
for (Entry<String, UUID> entry : idMap.entrySet()) {
|
||||||
@ -3990,7 +3992,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
getLogger().info("Conversion completed: " + converted + " Converted. " + failed + " Failed.");
|
getLogger().info("Conversion completed: " + converted + " Converted. " + failed + " Failed.");
|
||||||
getLogger().info("Old data files stored in /Quests/data/old");
|
getLogger().info("Old data files stored in "
|
||||||
|
+ File.separator + "Quests" + File.separator + "data" + File.separator + "old");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -930,6 +930,7 @@ public class Lang {
|
|||||||
langMap.put("quest", "Quest");
|
langMap.put("quest", "Quest");
|
||||||
langMap.put("quests", "Quests");
|
langMap.put("quests", "Quests");
|
||||||
langMap.put("createdBy", "Created by");
|
langMap.put("createdBy", "Created by");
|
||||||
|
langMap.put("continuedBy", "and continued by");
|
||||||
langMap.put("questPoints", "Quest Points");
|
langMap.put("questPoints", "Quest Points");
|
||||||
langMap.put("complete", "Complete");
|
langMap.put("complete", "Complete");
|
||||||
langMap.put("redoable", "Redoable");
|
langMap.put("redoable", "Redoable");
|
||||||
|
Loading…
Reference in New Issue
Block a user