mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-22 02:25:42 +01:00
Unstable commit (unfinished)
This commit is contained in:
parent
35244379a5
commit
d1c7a169e6
@ -73,16 +73,22 @@ public class PlayerListener implements Listener {
|
||||
quester.currentStage = q.stages.getFirst();
|
||||
quester.addEmpties();
|
||||
quester.isTalking = false;
|
||||
if(q.moneyReq > 0){
|
||||
if (q.moneyReq > 0) {
|
||||
Quests.economy.withdrawPlayer(quester.name, q.moneyReq);
|
||||
}
|
||||
player.sendMessage(ChatColor.GREEN + "Quest accepted: " + q.name);
|
||||
player.sendMessage("");
|
||||
player.sendMessage(ChatColor.GOLD + "---(Objectives)---");
|
||||
for(String s : quester.getObjectives()){
|
||||
player.sendMessage(s);
|
||||
|
||||
for(int i : q.itemIds){
|
||||
if (q.removeItems.get(q.itemIds.indexOf(i)) == true)
|
||||
Quests.removeItem(player.getInventory(), Material.getMaterial(i), q.itemAmounts.get(q.itemIds.indexOf(i)));
|
||||
}
|
||||
|
||||
player.sendMessage(ChatColor.GREEN + "Quest accepted: " + q.name);
|
||||
player.sendMessage("");
|
||||
player.sendMessage(ChatColor.GOLD + "---(Objectives)---");
|
||||
for (String s : quester.getObjectives()) {
|
||||
player.sendMessage(s);
|
||||
}
|
||||
|
||||
}else {
|
||||
|
||||
player.sendMessage(q.failRequirements);
|
||||
@ -356,7 +362,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
Player player = (Player) p.getShooter();
|
||||
if(plugin.citizens.getNPCRegistry().isNPC(player) == false){
|
||||
|
||||
|
||||
Quester quester = plugin.getQuester(player.getName());
|
||||
if(quester.hasObjective("killMob"))
|
||||
quester.killMob(evt.getEntity().getLocation(), evt.getEntity().getType());
|
||||
@ -367,7 +373,7 @@ public class PlayerListener implements Listener {
|
||||
}else if(damager instanceof Player){
|
||||
|
||||
if(plugin.citizens.getNPCRegistry().isNPC(damager) == false){
|
||||
|
||||
|
||||
Player player = (Player) damager;
|
||||
Quester quester = plugin.getQuester(player.getName());
|
||||
if(quester.hasObjective("killMob"))
|
||||
@ -401,11 +407,11 @@ public class PlayerListener implements Listener {
|
||||
|
||||
Player player = (Player) p.getShooter();
|
||||
if(plugin.citizens.getNPCRegistry().isNPC(player) == false){
|
||||
|
||||
|
||||
Quester quester = plugin.getQuester(player.getName());
|
||||
if(quester.hasObjective("killPlayer"))
|
||||
quester.killPlayer(evt.getEntity().getName());
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -414,7 +420,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
Player player = (Player) damager;
|
||||
if(plugin.citizens.getNPCRegistry().isNPC(player) == false){
|
||||
|
||||
|
||||
Quester quester = plugin.getQuester(player.getName());
|
||||
if(quester.hasObjective("killPlayer"))
|
||||
quester.killPlayer(evt.getEntity().getName());
|
||||
@ -489,7 +495,7 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerMove(PlayerMoveEvent evt){
|
||||
|
||||
if(plugin.citizens.getNPCRegistry().isNPC(evt.getPlayer()) == false){
|
||||
|
||||
|
||||
Quester quester = plugin.getQuester(evt.getPlayer().getName());
|
||||
|
||||
if(quester.hasObjective("reachLocation")){
|
||||
@ -497,7 +503,7 @@ public class PlayerListener implements Listener {
|
||||
quester.reachLocation(evt.getTo());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -578,8 +578,9 @@ public class Quests extends JavaPlugin {
|
||||
}
|
||||
|
||||
for(int i : quest.itemIds){
|
||||
if (quest.removeItems.get(quest.itemIds.indexOf(i)) == true)
|
||||
if (quest.removeItems.get(quest.itemIds.indexOf(i)) == true){
|
||||
removeItem(((Player) sender).getInventory(), Material.getMaterial(i), quest.itemAmounts.get(quest.itemIds.indexOf(i)));
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Quest accepted: " + quest.name);
|
||||
@ -1344,17 +1345,17 @@ public class Quests extends JavaPlugin {
|
||||
|
||||
if (config.contains("quests." + s + ".requirements.item-ids")) {
|
||||
quest.itemIds = config.getIntegerList("quests." + s + ".requirements.item-ids");
|
||||
|
||||
|
||||
if(config.getIntegerList("quests." + s + ".requirements.item-amounts") == null)
|
||||
failedToLoad = true;
|
||||
else
|
||||
quest.itemAmounts = config.getIntegerList("quests." + s + ".requirements.item-amounts");
|
||||
|
||||
|
||||
if(config.getBooleanList("quests." + s + ".requirements.remove-items").isEmpty())
|
||||
failedToLoad = true;
|
||||
else
|
||||
quest.removeItems = config.getBooleanList("quests." + s + ".requirements.remove-items");
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (config.contains("quests." + s + ".requirements.money")) {
|
||||
@ -2064,7 +2065,7 @@ public class Quests extends JavaPlugin {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(failedToLoad == true)
|
||||
log.log(Level.SEVERE, "[Quests] Failed to load Quest \"" + s + "\". Skipping.");
|
||||
|
||||
@ -2683,12 +2684,12 @@ public class Quests extends JavaPlugin {
|
||||
}
|
||||
|
||||
public static boolean removeItem(Inventory inventory, Material type, int amount) {
|
||||
|
||||
|
||||
HashMap<Integer, ? extends ItemStack> allItems = inventory.all(type);
|
||||
HashMap<Integer, Integer> removeFrom = new HashMap<Integer, Integer>();
|
||||
int foundAmount = 0;
|
||||
for (Map.Entry<Integer, ? extends ItemStack> item : allItems.entrySet()) {
|
||||
|
||||
|
||||
if (item.getValue().getAmount() >= amount - foundAmount) {
|
||||
removeFrom.put(item.getKey(), amount - foundAmount);
|
||||
foundAmount = amount;
|
||||
@ -2699,13 +2700,13 @@ public class Quests extends JavaPlugin {
|
||||
if (foundAmount >= amount) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (foundAmount == amount) {
|
||||
|
||||
|
||||
for (Map.Entry<Integer, Integer> toRemove : removeFrom.entrySet()) {
|
||||
|
||||
|
||||
ItemStack item = inventory.getItem(toRemove.getKey());
|
||||
if (item.getAmount() - toRemove.getValue() <= 0) {
|
||||
inventory.clear(toRemove.getKey());
|
||||
@ -2713,10 +2714,10 @@ public class Quests extends JavaPlugin {
|
||||
item.setAmount(item.getAmount() - toRemove.getValue());
|
||||
inventory.setItem(toRemove.getKey(), item);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user