}
@EventHandler(priority = EventPriority.HIGH)
public void onCraftEvent(CraftItemEvent event) {
SpoutPlayer player = (SpoutPlayer) event.getWhoClicked();
//********** skillFoodBone ****************
if ((event.getCurrentItem().getTypeId() == 351 && event.getCurrentItem().getData().getData() == 0xf)){ //Knochenmehl
if(ConflictPlugin.skillFoodBone.get(player.getName())>0){
event.getCurrentItem().setAmount(event.getCurrentItem().getAmount() +1);
//player.getWorld().dropItem(player.getLocation(), new ItemStack(351));
}
}
// falls Bogen/Waffen/R�stungen/Werkzeuge gecraftet
int id = event.getCurrentItem().getTypeId();
if ((id >= 256 && id <= 259) || id == 261 || (id >= 267 && id <= 279) ||
(id >= 283 && id <= 286) || (id >= 290 && id <= 294) || (id >= 298 && id <= 317)) {
//Shift-Click verbieten
if(event.isShiftClick()){
event.setCancelled(true);
return;
}
// Daten holen
//int id = event.getCurrentItem().getTypeId();
Material mat = Material.getMaterial(id);
short max = mat.getMaxDurability();
if (ConflictPlugin.skillCraftQual.get(player.getName()) >= 2) {
// voll
} else if (ConflictPlugin.skillCraftQual.get(player.getName()) >= 1) {
event.getCurrentItem().setDurability((short) (max / 4)); // 3/4 voll
} else {
event.getCurrentItem().setDurability((short) (max / 2)); // halb voll
}
// ****************** Werkzeuge Metall, Gold, Diamant ********************
if (event.getCurrentItem().getTypeId() == 256 || event.getCurrentItem().getTypeId() == 257
|| event.getCurrentItem().getTypeId() == 258 || event.getCurrentItem().getTypeId() == 277
|| event.getCurrentItem().getTypeId() == 278 || event.getCurrentItem().getTypeId() == 279
|| event.getCurrentItem().getTypeId() == 284 || event.getCurrentItem().getTypeId() == 285
|| event.getCurrentItem().getTypeId() == 286 || event.getCurrentItem().getTypeId() == 292
|| event.getCurrentItem().getTypeId() == 293 || event.getCurrentItem().getTypeId() == 294) {
switch (ConflictPlugin.skillCraftTool.get(player.getName())) {
// nichts
case 0:
break;
// 1x Lvl 1
case 1:
int n = generator.nextInt(3);
switch (n) {
case 0:
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(32), 1); // efficiency
break;
case 1:
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(34), 1); // unbreaking
break;
case 2:
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(35), 1); // fortune
break;
}
break;
// 2x Lvl 1
case 2:
n = generator.nextInt(3);
switch (n) {
case 0:
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(32), 1);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(34), 1);
break;
case 1:
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(32), 1);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(35), 1);
break;
case 2:
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(34), 1);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(35), 1);
break;
}
break;
// 1x 2, 1x 1
case 3:
n = generator.nextInt(3);
switch (n) {
case 0:
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(32), 2);
n = generator.nextInt(2);
if (n == 0) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(34), 1);
} else {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(35), 1);
}
break;
case 1:
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(34), 2);
n = generator.nextInt(2);
if (n == 0) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(32), 1);
} else {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(35), 1);
}
break;
case 2:
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(35), 2);
n = generator.nextInt(2);
if (n == 0) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(32), 1);
} else {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(34), 1);
}
break;
}
break;
// 2x 2, 1x 1
case 4:
n = generator.nextInt(3);
switch (n) {
case 0:
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(32), 1);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(34), 2);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(35), 2);
break;
case 1:
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(32), 2);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(34), 1);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(35), 2);
break;
case 2:
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(32), 2);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(34), 2);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(35), 1);
break;
}
break;
// 1x 3, 2x 1
case 5:
n = generator.nextInt(3);
switch (n) {
case 0:
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(32), 3);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(34), 1);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(35), 1);
break;
case 1:
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(34), 3);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(32), 1);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(35), 1);
break;
case 2:
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(35), 3);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(32), 1);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(34), 1);
break;
}
break;
// 1x 3, 1x 2, 1x 1
case 6:
n = generator.nextInt(3);
switch (n) {
case 0:
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(32), 2);
n = generator.nextInt(2);
if (n == 0) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(34), 2);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(35), 1);
} else {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(35), 2);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(34), 1);
}
break;
case 1:
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(34), 3);
n = generator.nextInt(2);
if (n == 0) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(32), 2);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(35), 1);
} else {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(35), 2);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(32), 1);
}
break;
case 2:
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(35), 3);
n = generator.nextInt(2);
if (n == 0) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(34), 2);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(32), 1);
} else {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(32), 2);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(34), 1);
}
break;
}
break;
}
}
// ****************** Bogen ********************
if (event.getCurrentItem().getTypeId() == 261) {
switch (ConflictPlugin.skillCraftBow.get(player.getName())) {
case 1:
int n = generator.nextInt(2);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(48), 1); // Damage 1
break;
case 2:
n = generator.nextInt(2);
if (n == 0) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(48), 2); // Damage 2
} else {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(49), 1); // Punch 1
}
break;
case 3:
n = generator.nextInt(2);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(48), 2); // Damage 2
if (n == 0) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(50), 1); // Flame
} else {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(49), 1); // Punch 1
}
break;
case 4:
n = generator.nextInt(2);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(48), 1); // Damage 1
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(50), 1); // Flame
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(49), 1); // Punch 1
break;
case 5:
n = generator.nextInt(2);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(48), 2); // Damage 2
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(50), 1); // Flame
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(49), 1); // Punch 1
break;
case 6:
n = generator.nextInt(2);
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(48), 3); // Damage 3
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(50), 1); // Flame
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(49), 1); // Punch 1
break;
}
}
// ****************** Sword ********************
if (event.getCurrentItem().getTypeId() == 267 || event.getCurrentItem().getTypeId() == 276
|| event.getCurrentItem().getTypeId() == 283) {
switch (ConflictPlugin.skillCraftSword.get(player.getName())) {
case 1:
int n = generator.nextInt(4);
if (n == 0) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(16), 1); // Damage 1
} else if (n == 1) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(17), 1); // Undead 1
} else if (n == 2) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(18), 1); // Arthropod 1
} else {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(19), 1); // Punch 1
}
break;
case 2:
n = generator.nextInt(5);
if (n == 0) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(16), 2); // Damage 2
} else if (n == 1) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(17), 2); // Undead
} else if (n == 2) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(18), 2); // Arth
} else if (n == 3) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(19), 1); // Punch
} else {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(20), 1); // fire
}
break;
case 3:
n = generator.nextInt(3);
if (n == 0) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(16), 2); // Damage 2
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(19), 1); // Punch 1
} else if (n == 1) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(16), 2); // Dam 2
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(20), 1); // Fire
} else {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(19), 2); // Knock 2
}
break;
case 4:
n = generator.nextInt(3);
if (n == 0) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(16), 3); // Damage 2
} else if (n == 1) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(16), 2); // Dam 2
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(20), 1); // Fire
} else {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(16), 2); // Damage 2
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(19), 1); // Knock 2
}
break;
case 5:
n = generator.nextInt(3);
if (n == 0) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(16), 3); // Damage 2
} else if (n == 1) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(16), 3); // Dam 2
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(20), 1); // Fire
} else {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(16), 3); // Damage 2
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(19), 1); // Knock 2
}
break;
case 6:
n = generator.nextInt(3);
if (n == 0) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(16), 3); // Damage 2
} else if (n == 1) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(16), 3); // Dam 2
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(19), 1); // Knock
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(20), 1); // Fire
} else {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(16), 3); // Damage 2
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(19), 1); // Knock
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(20), 1); // Fire
}
break;
}
}
// ****************** Armor ********************
if (event.getCurrentItem().getTypeId() >= 306 && event.getCurrentItem().getTypeId() <= 317) {
switch (ConflictPlugin.skillCraftArmor.get(player.getName())) {
case 1:
int n = generator.nextInt(3);
if (n == 0) {
event.getCurrentItem().addEnchantment(new EnchantmentWrapper(0), 1);
} else if (n == 1) {