Starting rewards item data

Unstable
This commit is contained in:
136S-Clarke 2013-04-22 14:06:28 -07:00
parent 91e1fd840d
commit 0474f20933
17 changed files with 83 additions and 30 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@ -1,4 +1,4 @@
#Fri, 12 Apr 2013 13:03:10 -0700
#Mon, 22 Apr 2013 13:58:51 -0700
/Users/136-aclarke/Desktop/Quests=

View File

@ -16,8 +16,11 @@
# debug-mode: true/false
# Should debugging information be printed out to console?
#
# kill-time: number
# kill-delay: number
# How long (in seconds) should a player have to wait before they can kill the same player for a Quest?
#
# prompt-timeout: number
# How long (in seconds) should a player be prompted for a Quest before it auto-cancels? (0 = Infinite)
allow-command-questing: true
allow-command-quests-with-npcs: false
show-requirements: true
@ -25,6 +28,7 @@ allow-quitting: true
debug-mode: false
kill-delay: 600
snoop: true
prompt-timeout: 20
quester-blacklist:
- "SomeGuy12345"
- "somePrefix*"

Binary file not shown.

BIN
dist/.DS_Store vendored Executable file

Binary file not shown.

BIN
dist/lib/ProtocolLib-2.4.1.jar vendored Normal file

Binary file not shown.

BIN
lib/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -16,8 +16,11 @@
# debug-mode: true/false
# Should debugging information be printed out to console?
#
# kill-time: number
# kill-delay: number
# How long (in seconds) should a player have to wait before they can kill the same player for a Quest?
#
# prompt-timeout: number
# How long (in seconds) should a player be prompted for a Quest before it auto-cancels? (0 = Infinite)
allow-command-questing: true
allow-command-quests-with-npcs: false
show-requirements: true
@ -25,8 +28,12 @@ allow-quitting: true
debug-mode: false
kill-delay: 600
snoop: true
<<<<<<< HEAD
show-npc-effects: true
npc-effect: "note"
=======
prompt-timeout: 20
>>>>>>> Starting rewards item data
quester-blacklist:
- "SomeGuy12345"
- "somePrefix*"

View File

@ -0,0 +1,45 @@
package me.blackvein.quests;
import java.util.LinkedList;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
public class ItemUtil {
public static Quests plugin = null;
//Format - id-id:amount-amount:data-data:enchantment-enchantment level:name-name:lore-lore:
public static ItemStack parseItem(String s){
String[] args = s.split(":");
ItemStack stack = null;
LinkedList<String> lore = new LinkedList<String>();
for(String arg : args){
if(arg.startsWith("id-"))
stack = new ItemStack(Integer.parseInt(arg.substring(3)));
else if(arg.startsWith("amount-"))
stack.setAmount(Integer.parseInt(arg.substring(7)));
else if(arg.startsWith("data-"))
stack.setDurability(Short.parseShort(arg.substring(5)));
else if(arg.startsWith("enchantment-")){
String[] ench = arg.substring(12).split(" ");
Enchantment e = Quests.getEnchantment(ench[0]);
stack.addEnchantment(e, Integer.parseInt(ench[1]));
}else if(arg.startsWith("name-"))
stack.getItemMeta().setDisplayName(arg.substring(5));
else if(arg.startsWith("lore-"))
lore.add(arg.substring(5));
}
if(lore.isEmpty() == false)
stack.getItemMeta().setLore(lore);
return stack;
}
}

View File

@ -47,7 +47,6 @@ public class Quest {
List<String> commands = new LinkedList<String>();
List<String> permissions = new LinkedList<String>();
LinkedList<ItemStack> itemRewards = new LinkedList<ItemStack>();
LinkedList<Integer> itemRewardAmounts = new LinkedList<Integer>();
//mcMMO
List<String> mcmmoSkills = new LinkedList<String>();
@ -253,7 +252,7 @@ public class Quest {
}
for(ItemStack i : itemRewards){
player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getTypeId()) + ChatColor.GRAY + " x " + itemRewardAmounts.get(itemRewards.indexOf(i)));
player.sendMessage("- " + ChatColor.DARK_GREEN + i.getItemMeta().getDisplayName() + ChatColor.GRAY + " x " + i.getAmount());
none = null;
}

View File

@ -41,8 +41,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
public static Permission permission = null;
public static mcMMO mcmmo = null;
public static boolean snoop = true;
<<<<<<< HEAD
public static boolean npcEffects = true;
public static String effect = "note";
=======
public static int timeout = 20;
>>>>>>> Starting rewards item data
List<String> questerBlacklist = new LinkedList<String>();
ConversationFactory conversationFactory;
QuestFactory questFactory;
@ -79,7 +83,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
.withModality(false)
.withPrefix(new QuestsPrefix())
.withFirstPrompt(new QuestPrompt())
.withTimeout(20)
.withTimeout(timeout)
.thatExcludesNonPlayersWithMessage("Console may not perform this conversation!")
.addConversationAbandonedListener(this);
@ -174,6 +178,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
snoop();
}
}, 5L);
ItemUtil.plugin = Quests.this;
}
@ -253,10 +259,16 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
showQuestReqs = config.getBoolean("show-requirements");
allowQuitting = config.getBoolean("allow-quitting");
snoop = config.getBoolean("snoop", true);
<<<<<<< HEAD
npcEffects = config.getBoolean("show-npc-effects", true);
effect = config.getString("npc-effect", "note");
debug = config.getBoolean("debug-mode");
killDelay = config.getInt("kill-delay");
=======
debug = config.getBoolean("debug-mode", false);
killDelay = config.getInt("kill-delay", 600);
timeout = config.getInt("prompt-timeout", 20);
>>>>>>> Starting rewards item data
for (String s : config.getStringList("quester-blacklist"))
questerBlacklist.add(s);
@ -2719,27 +2731,23 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
//Load rewards
if (config.contains("quests." + s + ".rewards.item-ids")) {
if (config.contains("quests." + s + ".rewards.items")) {
if (Quests.checkList(config.getList("quests." + s + ".rewards.item-ids"), Integer.class)) {
if (config.contains("quests." + s + ".rewards.item-amounts")) {
if (Quests.checkList(config.getList("quests." + s + ".rewards.item-amounts"), Integer.class)) {
if (Quests.checkList(config.getList("quests." + s + ".rewards.items"), String.class)) {
boolean failed = false;
for (int i : config.getIntegerList("quests." + s + ".rewards.item-ids")) {
for (String item : config.getStringList("quests." + s + ".rewards.items")) {
Material m = Material.getMaterial(i);
if (m == null) {
printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + i + ChatColor.GOLD + " in " + ChatColor.GREEN + "item-amounts: " + ChatColor.AQUA + "Reward " + ChatColor.GOLD + "in Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is not a list of numbers!");
try{
ItemStack stack = ItemUtil.parseItem(item);
quest.itemRewards.add(stack);
}catch(Exception e){
printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + item + ChatColor.GOLD + " in " + ChatColor.GREEN + "items: " + ChatColor.AQUA + "Reward " + ChatColor.GOLD + "in Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is not formatted properly!");
failed = true;
break;
}
int amnt = config.getIntegerList("quests." + s + ".rewards.item-amounts").get(config.getIntegerList("quests." + s + ".rewards.item-ids").indexOf(i));
ItemStack stack = new ItemStack(m, amnt);
quest.itemRewards.add(stack);
quest.itemRewardAmounts.add(amnt);
}
@ -2747,16 +2755,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
continue;
}
} else {
printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "item-amounts: " + ChatColor.AQUA + "Reward " + ChatColor.GOLD + "in Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is not a list of numbers!");
continue;
}
} else {
printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.AQUA + "Rewards " + ChatColor.GOLD + "for Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is missing " + ChatColor.RED + "item-amounts:");
continue;
}
} else {
printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "item-ids: " + ChatColor.AQUA + "Reward " + ChatColor.GOLD + "in Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is not a list of item ids!");
continue;