*Added text ids,

This commit is contained in:
Zino 2013-07-16 13:28:44 +02:00
parent f791619337
commit 016facfc6a
3 changed files with 304 additions and 2 deletions

View File

@ -0,0 +1,76 @@
package me.blackvein.quests;
import java.util.HashMap;
import java.util.Scanner;
import me.blackvein.quests.ItemData.Data;
public class ItemData {
public HashMap<String, Data> map = new HashMap<String, Data>();
private static ItemData instance = null;
public static ItemData getInstance() {
if (instance != null) {
return instance;
} else {
instance = new ItemData();
return instance;
}
}
private ItemData() {
Scanner scanner = new Scanner(this.getClass().getClassLoader().getResourceAsStream("items.txt"));
while(scanner.hasNextLine()) {
String[] line = scanner.nextLine().split("=");
if (line.length > 1) {
String name = line[0];
Data data;
String[] str = line[1].split(",");
int id = -1;
byte mdata = 0;
try {
id = Integer.parseInt(str[0]);
} catch (Exception e) {
}
if (str.length > 1) {
mdata = Byte.parseByte(str[1]);
}
data = new Data(name, id, mdata);
map.put(name, data);
}
}
}
public Data getItem(String input) {
if (map.containsKey(input)) {
return map.get(input);
} else {
return null;
}
}
public class Data {
private String name_;
private int id_;
private byte data_;
public Data(String name, int id, byte mdata) {
this.name_ = name;
this.id_ = id;
this.data_ = mdata;
}
public int getId() {
return id_;
}
public byte getData() {
return data_;
}
}
}

View File

@ -0,0 +1,215 @@
Stone=1
Grass=2
Dirt=3
Cobblestone=4
WoodenPlank=5,0
RedwoodPlank=5,1
BirchPlank=5,2
Sapling=6
Bedrock=7
Water=8
StationaryWater=9
Lava=10
StationaryLava=11
Sand=12
Gravel=13
GoldOre=14
IronOre=15
CoalOre=16
Wood=17
Leaves=18,0
RedwoodLeaves=18,1
BirchLeaves=18,2
Sponge=19
Glass=20
LapisLazuliOre=21
LapisLazuliBlock=22
Dispenser=23
Sandstone=24
NoteBlock=25
Wool=35,0
OrangeWool=35,1
MagentaWool=35,2
LightBlueWool=35,3
YellowWool=35,4
LightGreenWool=35,5
PinkWool=35,6
GrayWool=35,7
LightGrayWool=35,8
CyanWool=35,9
PurpleWool=35,10
BlueWool=35,11
BrownWool=35,12
DarkGreenWool=35,13
RedWool=35,14
BlackWool=35,15
YellowFlower=37
RedRose=38
BrownMushroom=39
RedMushroom=40
GoldBlock=41
IronBlock=42
DoubleSlab=43
StoneSlab=44,0
SandstoneSlab=44,1
WoodenSlab=44,2
CobblestoneSlab=44,3
BrickBlock=45
TNT=46
Bookshelf=47
MossStone=48
Obsidian=49
Torch=50
MonsterSpawner=52
WoodenStairs=53
Chest=54
DiamondOre=56
DiamondBlock=57
CraftingTable=58
Crops=59
Farmland=60
Furnace=61
Ladder=65
Rails=66
CobblestoneStairs=67
Lever=69
StonePressurePlate=70
WoodenPressurePlate=72
RedstoneOre=73
GlowingRedstoneOre=74
RedstoneTorch=76
StoneButton=77
Snow=78
Ice=79
SnowBlock=80
Cactus=81
ClayBlock=82
Jukebox=84
Fence=85
Pumpkin=86
Netherrack=87
SoulSand=88
GlowstoneBlock=89
Portal=90
Jack-O-Lantern=91
CakeBlock=92
IronShovel=256
IronPickaxe=257
IronAxe=258
FlintandSteel=259
Apple=260
Bow=261
Arrow=262
Coal=263,0
Charcoal=263,1
Diamond=264
IronIngot=265
GoldIngot=266
IronSword=267
WoodenSword=268
WoodenShovel=269
WoodenPickaxe=270
WoodenAxe=271
StoneSword=272
StoneShovel=273
StonePickaxe=274
StoneAxe=275
DiamondSword=276
DiamondShovel=277
DiamondPickaxe=278
DiamondAxe=279
Stick=280
Bowl=281
MushroomSoup=282
GoldSword=283
GoldShovel=284
GoldPickaxe=285
GoldAxe=286
String=287
Feather=288
Gunpowder=289
WoodenHoe=290
StoneHoe=291
IronHoe=292
DiamondHoe=293
GoldHoe=294
Seeds=295
Wheat=296
Bread=297
LeatherHelmet=298
LeatherChestplate=299
LeatherLeggings=300
LeatherBoots=301
ChainmailHelmet=302
ChainmailChestplate=303
ChainmailLeggings=304
ChainmailBoots=305
IronHelmet=306
IronChestplate=307
IronLeggings=308
IronBoots=309
DiamondHelmet=310
DiamondChestplate=311
DiamondLeggings=312
DiamondBoots=313
GoldHelmet=314
GoldChestplate=315
GoldLeggings=316
GoldBoots=317
Flint=318
RawPorkchop=319
CookedPorkchop=320
Paintings=321
Goldenapple=322
Sign=323
Woodendoor=324
Bucket=325
Waterbucket=326
Lavabucket=327
Minecart=328
Saddle=329
Irondoor=330
Redstone=331
Snowball=332
Boat=333
Leather=334
Milk=335
ClayBrick=336
ClayBalls=337
SugarCane=338
Paper=339
Book=340
Slimeball=341
StorageMinecart=342
PoweredMinecart=343
Egg=344
Compass=345
FishingRod=346
Clock=347
GlowstoneDust=348
RawFish=349
CookedFish=350
InkSac=351,0
RoseRed=351,1
CactusGreen=351,2
CocoaBeans=351,3
LapisLazuliDye=351,4
PurpleDye=351,5
CyanDye=351,6
LightGrayDye=351,7
GrayDye=351,8
PinkDye=351,9
LimeDye=351,10
DandelionYellow=351,11
LightBlueDye=351,12
MagentaDye=351,13
OrangeDye=351,14
BoneMeal=351,15
Bone=352
Sugar=353
Cake=354
Bed=355
RedstoneRepeater=356
Cookie=357
GoldMusicDisc=2256
GreenMusicDisc=2257

View File

@ -5,9 +5,13 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import me.blackvein.quests.ColorUtil;
import me.blackvein.quests.ItemData;
import me.blackvein.quests.ItemData.Data;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.conversations.ConversationContext;
@ -236,8 +240,15 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil{
}
}catch(Exception e){
Data data = ItemData.getInstance().getItem(input);
if (data == null) {
cc.getForWhom().sendRawMessage(RED + "Invalid item ID!");
return new IDPrompt();
} else {
cc.setSessionData("tempId", data.getId());
cc.setSessionData("tempData", data.getData());
return new ItemStackPrompt(oldPrompt);
}
}
}else{