Merge remote-tracking branch 'origin/master_event'

master_event
sigonasr2 11 years ago
commit 60b158cede
  1. 103
      BankEconomyMod/src/me/kaZep/Base/Main.java
  2. 98
      BankEconomyMod/src/me/kaZep/Base/PlayerListener.java
  3. 18
      BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java

@ -83,6 +83,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scoreboard.Team;
import org.bukkit.util.Vector;
import org.bukkit.enchantments.Enchantment;
@ -2907,7 +2908,13 @@ public void checkJukeboxes() {
}
}
}
list[i].getScoreboard().getTeam(list[i].getName()).setSuffix(healthbar(list[i].getHealth(),list[i].getMaxHealth(),list[i].getFoodLevel()));
list[i].getScoreboard().getTeam(list[i].getName().toLowerCase()).setSuffix(healthbar(list[i].getHealth(),list[i].getMaxHealth(),list[i].getFoodLevel()));
/* Team t = list[i].getScoreboard().getTeam(list[i].getName());
double hp = list[i].getHealth();
double maxhp = list[i].getMaxHealth();
int food = list[i].getFoodLevel();
t.setSuffix(healthbar(hp, maxhp, food)); */
}
LOGGING_UPDATE_COUNTS++; //3
for (int i=0;i<supportmoblist.size();i++) {
@ -4688,6 +4695,100 @@ public void payDay(int time)
return false;
}
public int get_LootChestTier(ItemStack chest) {
if (chest.hasItemMeta() && chest.getItemMeta().hasLore()) {
//Check to see if the Lore contains anything.
for (int i=0;i<chest.getItemMeta().getLore().size();i++) {
if (chest.getItemMeta().getLore().get(i).equalsIgnoreCase(ChatColor.GRAY+""+ChatColor.ITALIC+"Something is rattling")) {
return 1; // Single loot
}
if (chest.getItemMeta().getLore().get(i).equalsIgnoreCase(ChatColor.GRAY+""+ChatColor.ITALIC+"You feel powerful magic")) {
return 2; // Mythic loot
}
if (chest.getItemMeta().getLore().get(i).equalsIgnoreCase(ChatColor.GRAY+""+ChatColor.ITALIC+"It is very heavy; there")) {
return 3; // Quantity loot
}
if (chest.getItemMeta().getLore().get(i).equalsIgnoreCase(ChatColor.GRAY+""+ChatColor.ITALIC+"You can feel a variety of")) {
return 4; // Multiloot
}
}
}
return 0;
}
public ItemStack generate_LootChest() {
return generate_LootChest(-1);
}
public ItemStack generate_LootChest(int tier) {
ItemStack chest = new ItemStack(Material.CHEST);
ItemMeta chest_name = chest.getItemMeta();
List<String> chestlore = new ArrayList<String>();
double rand = 1; // Randomly generated number determined by fair dice roll.
if (tier == -1) {
rand = Math.random();
// No argument, randomize
}
if (tier == 0) {
// Invalid chest, don't return anything
Bukkit.getLogger().warning("Invalid loot chest detected! This should never happen.");
return null;
}
if (rand < 0.005 || tier == 2) {
// Generate a mythic chest
chest_name.setDisplayName(ChatColor.LIGHT_PURPLE+"Mythic Chest");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"A mysterious chest!");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"You feel powerful magic");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"emanating from within;");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"it must contain epic");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"equipment!");
chest_name.setLore(chestlore);
chest.setItemMeta(chest_name);
} else if (rand < 0.02 || tier == 3) {
// Generate a loaded goods chest
chest_name.setDisplayName(ChatColor.AQUA+"Heavy Chest");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"A mysterious chest!");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"It is very heavy; there");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"may be lots of loot within!");
chest_name.setLore(chestlore);
chest.setItemMeta(chest_name);
} else if (rand < 0.1 || tier == 4) {
// Generate a double chest
chest_name.setDisplayName(ChatColor.YELLOW+"Closed Chest");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"A mysterious chest!");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"You can feel a variety of");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"items rattling around inside.");
chest_name.setLore(chestlore);
chest.setItemMeta(chest_name);
} else {
chest_name.setDisplayName(ChatColor.YELLOW+"Closed Chest");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"A mysterious chest!");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"Something is rattling");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"around inside; it may");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"contain valuables!");
chest_name.setLore(chestlore);
chest.setItemMeta(chest_name);
}
return chest;
}
public PlayerListener.Cube get_ItemCubeType(ItemStack item_cube) {
if (item_cube.hasItemMeta() && item_cube.getItemMeta().hasLore()) {
//Check to see if the Lore contains anything.

@ -20,6 +20,7 @@ import net.milkbowl.vault.economy.EconomyResponse;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
@ -5248,6 +5249,70 @@ implements Listener
}
}
}
public void open_LootChest(int tier, Location loc) {
// 1 = single item
// 2 = mythic item
// 3 = plentiful items
// 4 = multiple items
switch (tier) {
case 1: {
loc.getWorld().dropItemNaturally(loc, getGoodie(0));
}break;
case 2: {
loc.getWorld().dropItemNaturally(loc, getGoodie(1));
}break;
case 3: {
if (Math.random() < 0.1) {
loc.getWorld().dropItemNaturally(loc, new ItemStack(Material.LOG, (int)(Math.random() * 64) + 1));
} else
if (Math.random() < 0.1) {
loc.getWorld().dropItemNaturally(loc, new ItemStack(Material.RAW_FISH, (int)(Math.random() * 64) + 1));
} else
if (Math.random() < 0.1) {
loc.getWorld().dropItemNaturally(loc, new ItemStack(Material.BOOKSHELF, (int)(Math.random() * 64) + 1));
} else
if (Math.random() < 0.1) {
loc.getWorld().dropItemNaturally(loc, new ItemStack(Material.CLAY, (int)(Math.random() * 64) + 1));
} else
if (Math.random() < 0.1) {
loc.getWorld().dropItemNaturally(loc, new ItemStack(Material.EXP_BOTTLE, (int)(Math.random() * 64) + 1));
} else
if (Math.random() < 0.1) {
loc.getWorld().dropItemNaturally(loc, new ItemStack(Material.OBSIDIAN, (int)(Math.random() * 64) + 1));
} else
if (Math.random() < 0.1) {
loc.getWorld().dropItemNaturally(loc, new ItemStack(Material.MOSSY_COBBLESTONE, (int)(Math.random() * 64) + 1));
} else
if (Math.random() < 0.1) {
loc.getWorld().dropItemNaturally(loc, new ItemStack(Material.HAY_BLOCK, (int)(Math.random() * 64) + 1));
} else
if (Math.random() < 0.1) {
loc.getWorld().dropItemNaturally(loc, new ItemStack(Material.QUARTZ_BLOCK, (int)(Math.random() * 64) + 1));
} else
if (Math.random() < 0.1) {
loc.getWorld().dropItemNaturally(loc, new ItemStack(Material.NETHER_BRICK, (int)(Math.random() * 64) + 1));
} else {
loc.getWorld().dropItemNaturally(loc, new ItemStack(Material.WOOL, (int)(Math.random() * 64) + 1));
}
}break;
case 4: {
// Drop at least one stack, and five rolls for a 20% chance at an extra stack.
loc.getWorld().dropItemNaturally(loc, getGoodie(0));
for (int i = 0; i < 5; i++) {
if (Math.random() < 0.2) {
loc.getWorld().dropItemNaturally(loc, getGoodie(0));
}
}
}break;
case 5: {
// OMG NOT CODED YET WTF THIS SHOULDN'T HAPPEN
}break;
}
}
public ItemStack getGoodie() {
return getGoodie(0);
@ -5989,22 +6054,9 @@ implements Listener
f.getType()==EntityType.ENDERMAN) {
if (this.plugin.getConfig().getBoolean("thanksgiving-enabled") && Math.random()<=0.005) {
if (this.plugin.getConfig().getBoolean("thanksgiving-enabled") && Math.random()<=0.01) {
// 0.5% chance of loot chest dropping
ItemStack chest = new ItemStack(Material.CHEST);
ItemMeta chest_name = chest.getItemMeta();
chest_name.setDisplayName(ChatColor.YELLOW+"Closed Chest");
List<String> chestlore = new ArrayList<String>();
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"A mysterious chest!");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"It feels heavy; there");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"might be items inside.");
chest_name.setLore(chestlore);
chest.setItemMeta(chest_name);
f.getWorld().dropItemNaturally(f.getLocation(), chest);
f.getWorld().dropItemNaturally(f.getLocation(), this.plugin.generate_LootChest());
}
//if (Math.random()<=0.005) {
/*
@ -6403,6 +6455,10 @@ implements Listener
@EventHandler
public void onFishCatch(PlayerFishEvent e) {
if (e.getState()==State.CAUGHT_FISH) {
if (this.plugin.getConfig().getBoolean("thanksgiving-enabled") && Math.random() < 0.10) {
// 5% chance of fishing up a loot chest
e.getPlayer().getWorld().dropItemNaturally(e.getPlayer().getLocation(), this.plugin.generate_LootChest());
}
Player p = e.getPlayer();
if (this.plugin.PlayerinJob(p, "Fisherman")) {
this.plugin.gainMoneyExp(p,"Fisherman",0.175,3);
@ -9068,13 +9124,17 @@ implements Listener
return;
}
if (this.plugin.is_LootChest(e.getItemInHand())) {
open_LootChest(this.plugin.get_LootChestTier(e.getItemInHand()), e.getBlockPlaced().getLocation());
e.setCancelled(true);
if (e.getItemInHand().getAmount() > 1) {
e.getItemInHand().setAmount(e.getItemInHand().getAmount() - 1);
} else {
e.getPlayer().setItemInHand(null);
}
e.getPlayer().getWorld().dropItemNaturally(e.getBlockPlaced().getLocation(), getGoodie());
// e.getPlayer().getWorld().dropItemNaturally(e.getBlockPlaced().getLocation(), getGoodie());
p.sendMessage(ChatColor.GREEN+"You open the chest and find treasure inside!");
p.playSound(p.getLocation(), Sound.ORB_PICKUP, 10, 1);
p.updateInventory();
@ -12978,7 +13038,7 @@ implements Listener
//We have to attempt to insert the item in the Item Cube.
Cube cube_type = null;
int identifier=-1;
if (item_cube.getItemMeta().getLore()!=null) {
if (item_cube.getItemMeta().getLore()!=null && isItemCube(item_cube)) {
//Check to see if the Lore contains anything.
for (int i=0;i<item_cube.getItemMeta().getLore().size();i++) {
if (item_cube.getItemMeta().getLore().get(i).equalsIgnoreCase(ChatColor.AQUA+"Contains 9 item slots.")) {
@ -13085,13 +13145,15 @@ implements Listener
return;
}
if (this.plugin.is_LootChest(p.getItemInHand())) {
open_LootChest(this.plugin.get_LootChestTier(p.getItemInHand()), p.getLocation());
e.setCancelled(true);
if (p.getItemInHand().getAmount() > 1) {
p.getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
} else {
p.setItemInHand(null);
}
p.getWorld().dropItemNaturally(p.getLocation(), getGoodie());
p.sendMessage(ChatColor.GREEN+"You open the chest and find treasure inside!");
p.playSound(p.getLocation(), Sound.ORB_PICKUP, 10, 1);
p.updateInventory();

@ -524,21 +524,7 @@ public String convertToItemName(String val) {
this.plugin.saveConfig();
}
if (args[0].equalsIgnoreCase("loot")) {
ItemStack chest = new ItemStack(Material.CHEST);
ItemMeta chest_name = chest.getItemMeta();
chest_name.setDisplayName(ChatColor.YELLOW+"Closed Chest");
List<String> chestlore = new ArrayList<String>();
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"A mysterious chest!");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"It feels heavy; there");
chestlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"might be items inside.");
chest_name.setLore(chestlore);
chest.setItemMeta(chest_name);
p.getWorld().dropItemNaturally(p.getLocation(), chest);
}
p.getWorld().dropItemNaturally(p.getLocation(), this.plugin.generate_LootChest()); }
} else
if (cmd.getName().toLowerCase().equalsIgnoreCase("event") && args.length==2 && p.hasPermission("maintenance-mode-admin")) {
if (args[0].equalsIgnoreCase("head")) {
@ -1974,4 +1960,4 @@ public String convertToItemName(String val) {
return false;
}
}
}

Loading…
Cancel
Save