package chest;
import java.util.ArrayList; import java.util.List; import java.util.Random;
import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack;
import main.RandomChestLoot;
public class ChestManager implements Listener {
private RandomChestLoot plugin;
public ChestManager(RandomChestLoot plugin) {
this.plugin = plugin;
}
@EventHandler
public void onClick(PlayerInteractEvent e) {
Player p = e.getPlayer();
if((e.getAction() == Action.RIGHT_CLICK_BLOCK) &&
(e.getClickedBlock().getType() == Material.JUKEBOX)) {
if(this.plugin.sgchest.containsKey(e.getClickedBlock().getLocation())) {
p.openInventory((Inventory)this.plugin.sgchest.get(e.getClickedBlock().getLocation()));
p.playSound(p.getLocation(), Sound.DOOR_OPEN, 2, 0);
} else {
Random rnd = new Random();
int n = 1;
n = rnd.nextInt(6);
Inventory inv = Bukkit.createInventory(null, InventoryType.CHEST);
List<ItemStack> items = new ArrayList<ItemStack>();
List<ItemStack> items2 = new ArrayList<ItemStack>();
List<ItemStack> items3 = new ArrayList<ItemStack>();
/*Essen*/
items.add(new ItemStack(Material.APPLE));
items.add(new ItemStack(Material.APPLE, 2));
items.add(new ItemStack(Material.APPLE, 3));
items.add(new ItemStack(Material.APPLE, 4));
items.add(new ItemStack(Material.COOKED_BEEF));
items.add(new ItemStack(Material.COOKED_BEEF, 2));
items.add(new ItemStack(Material.COOKED_BEEF, 3));
items.add(new ItemStack(Material.COOKED_BEEF, 4));
items.add(new ItemStack(Material.RAW_BEEF));
items.add(new ItemStack(Material.RAW_BEEF, 2));
items.add(new ItemStack(Material.RAW_BEEF, 3));
items.add(new ItemStack(Material.RAW_BEEF, 4));
items.add(new ItemStack(Material.COOKED_CHICKEN));
items.add(new ItemStack(Material.COOKED_CHICKEN, 2));
items.add(new ItemStack(Material.COOKED_CHICKEN, 3));
items.add(new ItemStack(Material.COOKED_CHICKEN, 4));
items.add(new ItemStack(Material.GRILLED_PORK));
items.add(new ItemStack(Material.GRILLED_PORK, 2));
items.add(new ItemStack(Material.GRILLED_PORK, 3));
items.add(new ItemStack(Material.GRILLED_PORK, 4));
items.add(new ItemStack(Material.CARROT));
items.add(new ItemStack(Material.CARROT, 2));
items.add(new ItemStack(Material.CARROT, 3));
items.add(new ItemStack(Material.CARROT, 4));
/*Waffen*/
items.add(new ItemStack(Material.STONE_SWORD));
items.add(new ItemStack(Material.WOOD_SWORD));
items.add(new ItemStack(Material.WOOD_AXE));
items.add(new ItemStack(Material.STONE_AXE));
items.add(new ItemStack(