diff --git a/BankEconomyMod/src/me/kaZep/Base/Main.java b/BankEconomyMod/src/me/kaZep/Base/Main.java index 0d7f1af..5e849f8 100644 --- a/BankEconomyMod/src/me/kaZep/Base/Main.java +++ b/BankEconomyMod/src/me/kaZep/Base/Main.java @@ -1450,6 +1450,11 @@ public void onDisable() natural_mats.add(Material.SAND); natural_mats.add(Material.CLAY); natural_mats.add(Material.WEB); + natural_mats.add(Material.LAVA); + natural_mats.add(Material.WATER); + natural_mats.add(Material.AIR); + natural_mats.add(Material.MOSSY_COBBLESTONE); + natural_mats.add(Material.COAL_ORE); natural_mats.add(Material.IRON_ORE); natural_mats.add(Material.GOLD_ORE); natural_mats.add(Material.DIAMOND_ORE); @@ -6523,10 +6528,12 @@ public void payDay(int time) */ public int getMobHeadAmt(MobHead mobhead, List mobheads) { int same_amt=0; - for (int i=0;i newlore = new ArrayList(); if (rare_head_type==MobHeadRareType.RARE_TYPE_A) { newlore.add(ChatColor.LIGHT_PURPLE+"+2 "+ChatColor.GOLD+"second Poison duration"); @@ -452,101 +452,239 @@ public class MobHead { static public MobHead getMobHead(ItemStack item) { if (item!=null && item.getType()==Material.SKULL_ITEM && item.hasItemMeta() && item.getItemMeta().hasLore()) { List getLore = item.getItemMeta().getLore(); + MobHeadType headtype = null; + MobHeadRareType raretype = null; + boolean powered = false; if (getLore.contains(ChatColor.LIGHT_PURPLE+"+5 "+ChatColor.GOLD+"second "+ChatColor.GRAY+"Wither I"+ChatColor.GOLD+" duration")) { - return new MobHead(MobHeadType.WITHER_SKELETON); + //return new MobHead(MobHeadType.WITHER_SKELETON); + headtype=MobHeadType.WITHER_SKELETON; } if (getLore.contains(ChatColor.LIGHT_PURPLE+"+1% "+ChatColor.GOLD+"Ranged Damage")) { - return new MobHead(MobHeadType.SKELETON); + //return new MobHead(MobHeadType.SKELETON); + headtype=MobHeadType.SKELETON; } if (getLore.contains(ChatColor.LIGHT_PURPLE+"+1% "+ChatColor.GOLD+"Lifesteal")) { - return new MobHead(MobHeadType.ZOMBIE); - } - if (getLore.contains(ChatColor.LIGHT_PURPLE+"+5% "+ChatColor.GOLD+"AoE Damage")) { - return new MobHead(MobHeadType.CREEPER); - } - if (getLore.contains(ChatColor.LIGHT_PURPLE+"+5% "+ChatColor.GOLD+"Slow on hit")) { - return new MobHead(MobHeadType.SPIDER); - } - if (getLore.contains(ChatColor.LIGHT_PURPLE+"+1% "+ChatColor.GOLD+"Critical Chance")) { - return new MobHead(MobHeadType.ENDERMAN); - } - if (getLore.contains(ChatColor.LIGHT_PURPLE+"+1 "+ChatColor.GOLD+"second Poison duration")) { - return new MobHead(MobHeadType.CAVE_SPIDER); + //return new MobHead(MobHeadType.ZOMBIE); + headtype=MobHeadType.ZOMBIE; + } + if (getLore.contains(ChatColor.LIGHT_PURPLE+"+5% "+ChatColor.GOLD+"AoE Damage") || + getLore.contains(ChatColor.LIGHT_PURPLE+"+5% "+ChatColor.GOLD+"AoE Damage"+ChatColor.BLUE+" &")) { + //return new MobHead(MobHeadType.CREEPER); + headtype=MobHeadType.CREEPER; + } + if (getLore.contains(ChatColor.LIGHT_PURPLE+"+5% "+ChatColor.GOLD+"Slow on hit") || + getLore.contains(ChatColor.LIGHT_PURPLE+"+5% "+ChatColor.GOLD+"Slow on hit"+ChatColor.BLUE+" &")) { + //return new MobHead(MobHeadType.SPIDER); + headtype=MobHeadType.SPIDER; + } + if (getLore.contains(ChatColor.LIGHT_PURPLE+"+1% "+ChatColor.GOLD+"Critical Chance") || + getLore.contains(ChatColor.LIGHT_PURPLE+"+1% "+ChatColor.GOLD+"Critical Chance"+ChatColor.BLUE+" &")) { + //return new MobHead(MobHeadType.ENDERMAN); + headtype=MobHeadType.ENDERMAN; + } + if ((getLore.contains(ChatColor.LIGHT_PURPLE+"+1 "+ChatColor.GOLD+"second Poison duration") || + getLore.contains(ChatColor.LIGHT_PURPLE+"+2 "+ChatColor.GOLD+"second Poison duration")) && + !getLore.contains(ChatColor.LIGHT_PURPLE+"+5% "+ChatColor.GOLD+"Slow on hit"+ChatColor.BLUE+" &")) { + //return new MobHead(MobHeadType.CAVE_SPIDER); + headtype=MobHeadType.CAVE_SPIDER; } if (getLore.contains(ChatColor.LIGHT_PURPLE+"+1 "+ChatColor.GOLD+"second ignite duration")) { - return new MobHead(MobHeadType.BLAZE); + //return new MobHead(MobHeadType.BLAZE); + headtype=MobHeadType.BLAZE; } - if (getLore.contains(ChatColor.LIGHT_PURPLE+"-1% "+ChatColor.GOLD+"damage taken on hit")) { - return new MobHead(MobHeadType.GHAST); + if (getLore.contains(ChatColor.LIGHT_PURPLE+"-1% "+ChatColor.GOLD+"damage taken on hit") || + getLore.contains(ChatColor.LIGHT_PURPLE+"-1% "+ChatColor.GOLD+"damage taken on hit"+ChatColor.BLUE+" &")) { + //return new MobHead(MobHeadType.GHAST); + headtype=MobHeadType.GHAST; } if (getLore.contains(ChatColor.LIGHT_PURPLE+"+1% "+ChatColor.GOLD+"chance of being fully")) { - return new MobHead(MobHeadType.ZOMBIE_PIGMAN); + //return new MobHead(MobHeadType.ZOMBIE_PIGMAN); + headtype=MobHeadType.ZOMBIE_PIGMAN; } if (getLore.contains(ChatColor.LIGHT_PURPLE+"+1% "+ChatColor.GOLD+"chance of setting the")) { - return new MobHead(MobHeadType.MAGMA_CUBE); - } + //return new MobHead(MobHeadType.MAGMA_CUBE); + headtype=MobHeadType.MAGMA_CUBE; + } + boolean ampersand=false; + for (int i=0;i newLore = new ArrayList(); - newLore.add(ChatColor.LIGHT_PURPLE+"+1 "+ChatColor.GOLD+"second Poison duration"); + newLore.add(ChatColor.LIGHT_PURPLE+"+2 "+ChatColor.GOLD+"second Poison duration"); newLore.add(ChatColor.GOLD+" on hit."+ChatColor.BLUE+" &"); - newLore.add(ChatColor.LIGHT_PURPLE+"+1% "+ChatColor.GOLD+"chance of snaring the"); + newLore.add(ChatColor.LIGHT_PURPLE+"+3% "+ChatColor.GOLD+"chance of snaring the"); newLore.add(ChatColor.GOLD+" target for 5 seconds."); meta.setLore(newLore); newitem.setItemMeta(meta); @@ -710,7 +848,7 @@ public class MobHead { getLore.contains(ChatColor.LIGHT_PURPLE+"+1 "+ChatColor.GOLD+"m/s Projectile Speed")) { ItemMeta meta = newitem.getItemMeta(); List newLore = new ArrayList(); - newLore.add(ChatColor.LIGHT_PURPLE+"+5% "+ChatColor.GOLD+"Ranged Damage "+ChatColor.BLUE+" &"); + newLore.add(ChatColor.LIGHT_PURPLE+"+5% "+ChatColor.GOLD+"Ranged Damage"+ChatColor.BLUE+" &"); newLore.add(ChatColor.LIGHT_PURPLE+"+3 "+ChatColor.GOLD+"m/s Projectile Speed"); meta.setLore(newLore); newitem.setItemMeta(meta); @@ -823,7 +961,7 @@ public class MobHead { } @Override public String toString() { - return "MobHead(Type: "+head_type.name()+", Rare Type: "+rare_head_type.name()+", is_rare:"+rare_head+", is_powered:"+is_powered+")"; + return "MobHead(Type: "+(head_type!=null?head_type.name():"null")+", Rare Type: "+(rare_head_type!=null?rare_head_type.name():"null")+", is_rare:"+rare_head+", is_powered:"+is_powered+")"; } public MobHead(MobHeadType head_type) { MobHead(head_type, false, MobHeadRareType.RARE_TYPE_A, false); diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerBuffData.java b/BankEconomyMod/src/me/kaZep/Base/PlayerBuffData.java index cf5fedb..8263e50 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerBuffData.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerBuffData.java @@ -8,6 +8,8 @@ import java.util.ConcurrentModificationException; import java.util.Iterator; import java.util.List; +import me.kaZep.Base.MobHead.MobHeadRareType; +import me.kaZep.Base.MobHead.MobHeadType; import me.kaZep.Commands.JobsDataInfo.Job; import org.bukkit.Bukkit; @@ -157,6 +159,17 @@ public class PlayerBuffData { } } } + if (p.getInventory()!=null) { + List playerheads = this.plugin.getMobHeads(p); + int zombierarebheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.ZOMBIE,true,MobHeadRareType.RARE_TYPE_B), playerheads); + int zombiepoweredheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.ZOMBIE,false,true), playerheads); + int zombiepoweredrareheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.ZOMBIE,true,true), playerheads); + Bukkit.getLogger().info("Base Health is "+base_hplv+"."); + base_hplv+=zombierarebheads; + base_hplv+=zombiepoweredheads; + base_hplv+=zombiepoweredrareheads*4; + Bukkit.getLogger().info("Base Health is "+base_hplv+"."); + } extra_hp=0; //p.setMaxHealth(base_hplv); boolean hasabsorption=false; diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java index d82f986..5f2a3d1 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java @@ -3,6 +3,7 @@ package me.kaZep.Base; import java.io.File; import java.io.IOException; import java.io.PrintStream; +import java.lang.reflect.Field; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Collection; @@ -16,6 +17,7 @@ import java.util.UUID; import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.EconomyResponse; +//import net.minecraft.server.v1_7_R1.WorldData; //import net.minecraft.server.v1_4_R1.EntityWolf; @@ -207,8 +209,11 @@ import com.google.common.base.Objects; import com.modcrafting.diablodrops.DiabloDrops; import com.sk89q.worldedit.CuboidClipboard; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.EmptyClipboardException; +import com.sk89q.worldedit.FilenameException; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.bukkit.BukkitWorld; +import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.data.DataException; import com.sk89q.worldedit.schematic.SchematicFormat; import com.sk89q.worldedit.util.TreeGenerator.TreeType; @@ -255,6 +260,11 @@ implements Listener natural_mats.add(Material.SAND); natural_mats.add(Material.CLAY); natural_mats.add(Material.WEB); + natural_mats.add(Material.LAVA); + natural_mats.add(Material.WATER); + natural_mats.add(Material.AIR); + natural_mats.add(Material.MOSSY_COBBLESTONE); + natural_mats.add(Material.COAL_ORE); natural_mats.add(Material.IRON_ORE); natural_mats.add(Material.GOLD_ORE); natural_mats.add(Material.DIAMOND_ORE); @@ -339,9 +349,9 @@ implements Listener public void onServerListPing(ServerListPingEvent e) { e.setMaxPlayers(16); if (this.plugin.getConfig().getBoolean("maintenance-mode")) { - e.setMotd(ChatColor.AQUA+"Sig's Minecraft!\n"+ChatColor.RED+"Currently in Maintenance Mode."); + e.setMotd(ChatColor.AQUA+"Sig's Minecraft!\n"+ChatColor.RED+" Currently in Maintenance Mode."); } else { - e.setMotd(ChatColor.AQUA+"Sig's Minecraft!\n"+ChatColor.BLUE+"Currently Online."); + e.setMotd(ChatColor.AQUA+"Sig's Minecraft!\n"+ChatColor.BLUE+" Currently Online."); } return; } @@ -2233,7 +2243,7 @@ implements Listener @EventHandler public void onPlayerInteract(PlayerInteractEntityEvent ev) { - Entity theAnimal = ev.getRightClicked(); + Entity theAnimal = ev.getRightClicked(); if (ev.getPlayer().getItemInHand().getType()==Material.getMaterial(127)) { if (this.plugin.getAccountsConfig().getLong(ev.getPlayer().getName()+".halloween.wand") playerheads = this.plugin.getMobHeads(p); + int witherskeletonheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.WITHER_SKELETON), playerheads); + int witherskeletonrareheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.WITHER_SKELETON,true), playerheads); + int witherskeletonpoweredheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.WITHER_SKELETON,false,true), playerheads); + int witherskeletonpoweredrareheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.WITHER_SKELETON,true,true), playerheads); + int witherduration = 0, witheramplifier = 0; try { Iterator effects = m.getActivePotionEffects().iterator(); //Figure out potion effects when player joins. while (effects.hasNext()) { PotionEffect nexteffect = effects.next(); //Bukkit.getLogger().info("Effect Type is "+nexteffect.getType().getName()+", amplifier is "+nexteffect.getAmplifier()+", duration is "+nexteffect.getDuration()); + if (witherskeletonheads+witherskeletonrareheads+witherskeletonpoweredheads+witherskeletonpoweredrareheads>0 && nexteffect.getType().getName().compareTo(PotionEffectType.WITHER.getName())==0) { + witherduration=nexteffect.getDuration(); + witheramplifier=nexteffect.getAmplifier(); + } if (nexteffect.getType().getName().compareTo(PotionEffectType.SLOW.getName())==0 && nexteffect.getAmplifier()==6 && nexteffect.getDuration()<=60) { m.removePotionEffect(PotionEffectType.SLOW); //Bukkit.getLogger().info("Removed slow."); @@ -10969,6 +10989,21 @@ implements Listener } catch (ConcurrentModificationException ex_e) { Bukkit.getLogger().warning("Potion Effect Collection not accessible while trying to remove slow debuff."); } + if (witherskeletonpoweredrareheads>0) { + if (witherduration==0) {witherduration=400;} + Bukkit.getLogger().info("Adding potion effect WITHER with amplifier "+(witheramplifier+2*witherskeletonpoweredrareheads)+" + duration "+witherduration); + m.addPotionEffect(new PotionEffect(PotionEffectType.WITHER,witherduration,witheramplifier+2*witherskeletonpoweredrareheads),true); + } else if (witherskeletonpoweredheads>0) { + if (witherduration==0) {witherduration=100;} + Bukkit.getLogger().info("Adding potion effect WITHER with amplifier "+(witheramplifier+1*witherskeletonpoweredrareheads)+" + duration "+witherduration); + m.addPotionEffect(new PotionEffect(PotionEffectType.WITHER,witherduration,witheramplifier+1*witherskeletonpoweredrareheads),true); + } else if (witherskeletonrareheads>0) { + Bukkit.getLogger().info("Adding potion effect WITHER with amplifier 2 + duration "+(witherduration+300*witherskeletonrareheads)); + m.addPotionEffect(new PotionEffect(PotionEffectType.WITHER,witherduration+300*witherskeletonrareheads,2),true); + } else if (witherskeletonheads>0) { + Bukkit.getLogger().info("Adding potion effect WITHER with amplifier 0 + duration "+(witherduration+100*witherskeletonrareheads)); + m.addPotionEffect(new PotionEffect(PotionEffectType.WITHER,witherduration+100*witherskeletonrareheads,0),true); + } } if (this.plugin.hasJobBuff("Hunter", p, Job.JOB20) && p.getItemInHand().getType().name().toLowerCase().contains("sword")) { if (e.getEntity() instanceof Monster) { @@ -11020,6 +11055,19 @@ implements Listener } } } + List playerheads = this.plugin.getMobHeads(p); + int zombieheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.ZOMBIE), playerheads); + int zombierareaheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.ZOMBIE,true,MobHeadRareType.RARE_TYPE_A), playerheads); + //int zombierarebheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.ZOMBIE,true,MobHeadRareType.RARE_TYPE_B), playerheads); + int zombiepoweredheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.ZOMBIE,false,true), playerheads); + int zombiepoweredrareheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.ZOMBIE,true,true), playerheads); + Bukkit.getLogger().info("Head counts are "+zombieheads+", "+zombierareaheads+", "+zombiepoweredheads+", "+zombiepoweredrareheads); + Bukkit.getLogger().info("Life Steal is "+life_steal+"%"); + life_steal+=zombieheads; + life_steal+=zombiepoweredheads; + life_steal+=zombierareaheads*3; + life_steal+=zombiepoweredrareheads*5; + Bukkit.getLogger().info("Life Steal is "+life_steal+"%"); if (this.plugin.getPlayerData(p).furytime!=0) { attack_speed+=this.plugin.getPlayerData(p).furyamt; } @@ -15143,7 +15191,7 @@ implements Listener } } @EventHandler - public void onProjectilLaunch(ProjectileLaunchEvent e) { + public void onProjectileLaunch(ProjectileLaunchEvent e) { Projectile thrown_obj = e.getEntity(); if (thrown_obj instanceof Arrow) { if (thrown_obj.getShooter()!=null && (thrown_obj.getShooter() instanceof Player)) { @@ -17459,6 +17507,49 @@ implements Listener double actMon = this.plugin.getAccountsConfig().getDouble(p.getName() + ".money"); int actHand = (int)Main.economy.getBalance(p.getName()); + /* WORKS!!! Now INTEGRATE! */ + /*if (e.getAction()==Action.LEFT_CLICK_AIR) { + //Save the region around ourself. + WorldEditPlugin wep = (WorldEditPlugin)Bukkit.getPluginManager().getPlugin("WorldEdit"); + final TerrainManager tm = new TerrainManager(wep, p); + final Location loc1 = new Location(p.getWorld(),p.getLocation().getBlockX()-32,0,p.getLocation().getBlockZ()-32); + final Location loc2 = new Location(p.getWorld(),p.getLocation().getBlockX()+32,128,p.getLocation().getBlockZ()+32); + final File saveFile = new File("plugins/WorldEdit/schematics/world_save"); + try { + tm.saveTerrain(saveFile, loc1, loc2); + } catch (FilenameException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } catch (DataException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } catch (IOException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } + } + if (e.getAction()==Action.RIGHT_CLICK_AIR) { + File file = new File("plugins/WorldEdit/schematics/world_save.schematic"); + if (file.exists()) { + try { + com.sk89q.worldedit.Vector v = new com.sk89q.worldedit.Vector(p.getLocation().getX()+8, p.getLocation().getY(), p.getLocation().getZ()+8); + World worldf = Bukkit.getWorld("world"); + BukkitWorld BWf = new BukkitWorld(worldf); + EditSession es = new EditSession(BWf, 2000000); + CuboidClipboard c1 = SchematicFormat.MCEDIT.load(file); + c1.place(es, v, true); + } catch (DataException ex) { + Bukkit.getLogger().warning("DataException while trying to create structure."); + } catch (IOException ex) { + Bukkit.getLogger().warning("IOException while trying to create structure."); + } catch (MaxChangedBlocksException ex) { + Bukkit.getLogger().warning("MaxChangedBlocksException while trying to create structure."); + } + } else { + Bukkit.getLogger().warning(("File does not exist.")); + } + }*/ + if (p.hasPotionEffect(PotionEffectType.BLINDNESS)) { e.setCancelled(true); return; diff --git a/BankEconomyMod/src/me/kaZep/Base/TerrainManager.java b/BankEconomyMod/src/me/kaZep/Base/TerrainManager.java new file mode 100644 index 0000000..7398f52 --- /dev/null +++ b/BankEconomyMod/src/me/kaZep/Base/TerrainManager.java @@ -0,0 +1,149 @@ +package me.kaZep.Base; + +import java.io.File; +import java.io.IOException; + +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Player; + +import com.sk89q.worldedit.CuboidClipboard; +import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.EmptyClipboardException; +import com.sk89q.worldedit.FilenameException; +import com.sk89q.worldedit.LocalPlayer; +import com.sk89q.worldedit.LocalSession; +import com.sk89q.worldedit.MaxChangedBlocksException; +import com.sk89q.worldedit.Vector; +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.bukkit.BukkitWorld; +import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import com.sk89q.worldedit.data.DataException; +import com.sk89q.worldedit.schematic.SchematicFormat; + +/** + * @author desht + * + * A wrapper class for the WorldEdit terrain loading & saving API to make things a little + * simple for other plugins to use. + */ +public class TerrainManager { + private static final String EXTENSION = "schematic"; + + private final WorldEdit we; + private final LocalSession localSession; + private final EditSession editSession; + private final LocalPlayer localPlayer; + + /** + * Constructor + * + * @param wep the WorldEdit plugin instance + * @param player the player to work with + */ + public TerrainManager(WorldEditPlugin wep, Player player) { + we = wep.getWorldEdit(); + localPlayer = wep.wrapPlayer(player); + localSession = we.getSession(localPlayer); + editSession = localSession.createEditSession(localPlayer); + } + + /** + * Constructor + * + * @param wep the WorldEdit plugin instance + * @param world the world to work in + */ + public TerrainManager(WorldEditPlugin wep, World world) { + we = wep.getWorldEdit(); + localPlayer = null; + localSession = new LocalSession(we.getConfiguration()); + editSession = new EditSession(new BukkitWorld(world), we.getConfiguration().maxChangeLimit); + } + + /** + * Write the terrain bounded by the given locations to the given file as a MCedit format + * schematic. + * + * @param saveFile a File representing the schematic file to create + * @param l1 one corner of the region to save + * @param l2 the corner of the region to save, opposite to l1 + * @throws DataException + * @throws IOException + */ + public void saveTerrain(File saveFile, Location l1, Location l2) throws FilenameException, DataException, IOException { + Vector min = getMin(l1, l2); + Vector max = getMax(l1, l2); + + saveFile = we.getSafeSaveFile(localPlayer, + saveFile.getParentFile(), saveFile.getName(), + EXTENSION, new String[] { EXTENSION }); + + editSession.enableQueue(); + CuboidClipboard clipboard = new CuboidClipboard(max.subtract(min).add(new Vector(1, 1, 1)), min); + clipboard.copy(editSession); + SchematicFormat.MCEDIT.save(clipboard, saveFile); + editSession.flushQueue(); + } + + /** + * Load the data from the given schematic file and paste it at the given location. If the location is null, then + * paste it at the saved data's origin. + * + * @param saveFile a File representing the schematic file to load + * @param loc the location to paste the clipboard at (may be null) + * @throws FilenameException + * @throws DataException + * @throws IOException + * @throws MaxChangedBlocksException + * @throws EmptyClipboardException + */ + public void loadSchematic(File saveFile, Location loc) throws FilenameException, DataException, IOException, MaxChangedBlocksException, EmptyClipboardException { + saveFile = we.getSafeSaveFile(localPlayer, + saveFile.getParentFile(), saveFile.getName(), + EXTENSION, new String[] { EXTENSION }); + + editSession.enableQueue(); + localSession.setClipboard(SchematicFormat.MCEDIT.load(saveFile)); + localSession.getClipboard().place(editSession, getPastePosition(loc), false); + editSession.flushQueue(); + we.flushBlockBag(localPlayer, editSession); + } + + /** + * Load the data from the given schematic file and paste it at the saved clipboard's origin. + * + * @param saveFile + * @throws FilenameException + * @throws DataException + * @throws IOException + * @throws MaxChangedBlocksException + * @throws EmptyClipboardException + */ + public void loadSchematic(File saveFile) throws FilenameException, DataException, IOException, MaxChangedBlocksException, EmptyClipboardException { + loadSchematic(saveFile, null); + } + + private Vector getPastePosition(Location loc) throws EmptyClipboardException { + if (loc == null) + return localSession.getClipboard().getOrigin(); + else + return new Vector(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); + } + + private Vector getMin(Location l1, Location l2) { + return new Vector( + Math.min(l1.getBlockX(), l2.getBlockX()), + Math.min(l1.getBlockY(), l2.getBlockY()), + Math.min(l1.getBlockZ(), l2.getBlockZ()) + ); + } + + private Vector getMax(Location l1, Location l2) { + return new Vector( + Math.max(l1.getBlockX(), l2.getBlockX()), + Math.max(l1.getBlockY(), l2.getBlockY()), + Math.max(l1.getBlockZ(), l2.getBlockZ()) + ); + } +} diff --git a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java index d8d82b4..e3c339a 100644 --- a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java +++ b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java @@ -8,11 +8,13 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Random; import me.kaZep.Base.Main; import me.kaZep.Base.MobHead; import me.kaZep.Base.MobHead.MobHeadRareType; import me.kaZep.Base.MobHead.MobHeadType; +import me.kaZep.Base.TerrainManager; import me.kaZep.Commands.JobsDataInfo.Job; import net.jmhertlein.mctowns.MCTowns; import net.jmhertlein.mctowns.MCTownsPlugin; @@ -22,6 +24,7 @@ import net.milkbowl.vault.economy.Economy; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.ChunkSnapshot; import org.bukkit.Difficulty; import org.bukkit.Location; import org.bukkit.Material; @@ -30,6 +33,9 @@ import org.bukkit.Server; import org.bukkit.SkullType; import org.bukkit.Sound; import org.bukkit.World; +import org.bukkit.WorldCreator; +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; import org.bukkit.block.Skull; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -46,6 +52,7 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Slime; import org.bukkit.entity.Wolf; import org.bukkit.event.inventory.InventoryType; +import org.bukkit.generator.ChunkGenerator.BiomeGrid; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.MerchantInventory; @@ -61,9 +68,14 @@ import sig.ItemSets.DiabloDropsHook.Tier; import com.sk89q.worldedit.CuboidClipboard; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.EmptyClipboardException; +import com.sk89q.worldedit.FilenameException; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.bukkit.BukkitWorld; +import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.data.DataException; +import com.sk89q.worldedit.regions.Region; +import com.sk89q.worldedit.schematic.MCEditSchematicFormat; import com.sk89q.worldedit.schematic.SchematicFormat; @@ -114,6 +126,40 @@ public class commandBankEconomy this.plugin = plugin; } + short getBlock(short[][] result, int x, int y, int z) { + if (result[y >> 4] == null) { + return (short)0; + } + return result[y >> 4][((y & 0xF) << 8) | (z << 4) | x]; + } + + public boolean naturalBlock(Material mat) { + List natural_mats = new ArrayList(); + natural_mats.add(Material.DIRT); + natural_mats.add(Material.STONE); + natural_mats.add(Material.WOOD); + natural_mats.add(Material.FENCE); + natural_mats.add(Material.GRAVEL); + natural_mats.add(Material.SAND); + natural_mats.add(Material.CLAY); + natural_mats.add(Material.WEB); + natural_mats.add(Material.LAVA); + natural_mats.add(Material.WATER); + natural_mats.add(Material.AIR); + natural_mats.add(Material.MOSSY_COBBLESTONE); + natural_mats.add(Material.COAL_ORE); + natural_mats.add(Material.IRON_ORE); + natural_mats.add(Material.GOLD_ORE); + natural_mats.add(Material.DIAMOND_ORE); + natural_mats.add(Material.EMERALD_ORE); + natural_mats.add(Material.LAPIS_ORE); + natural_mats.add(Material.REDSTONE_ORE); + if (natural_mats.contains(mat)) { + return true; + } else { + return false; + } + } public String convertToItemName(String val) { val=val.replace('_', ' '); @@ -605,9 +651,9 @@ public String convertToItemName(String val) { if (args[0].equalsIgnoreCase("cheatheads")) { if (p.hasPermission("maintenance-mode-admin")) { Inventory i = Bukkit.createInventory(p, 63, "Mob Head Inventory"); - + ItemStack temp = null; - + int count = -1; for (int k=0;kREPLACED "+replaced_layers+" layers. ("+(int)(iterations/10000d*100)+"%)"); + + for (int y=63;y<256;y++) { + for (int x=0;x<16;x++) { + for (int z=0;z<16;z++) { + p2.getWorld().getBlockAt(chunkx2*16+x, y, chunkz2*16+z).setType(Material.AIR); + } + } + } + //p2.getWorld().refreshChunk(chunkx2, chunkz2); + try { + tm.loadSchematic(saveFile); + } catch (FilenameException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (MaxChangedBlocksException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (EmptyClipboardException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (DataException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + /*}},20);*/ + p.getWorld().unloadChunkRequest(chunkx2, chunkz2); + } + } + } + } if (args[0].equalsIgnoreCase("halloween") && args[1].equalsIgnoreCase("end")) { p.sendMessage(ChatColor.GRAY+"Ending Harrowing night... Did you make sure it was night time? If not, type this command again after /time night instead."); this.plugin.harrowing_night=true; @@ -1649,6 +1818,22 @@ public String convertToItemName(String val) { l.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 999999, 1)); } } + if (args[0].equalsIgnoreCase("save_topworld") && args[1].equalsIgnoreCase("5000")) { + com.sk89q.worldedit.Vector v1 = new com.sk89q.worldedit.Vector(2500,77,2500); + com.sk89q.worldedit.Vector v2 = new com.sk89q.worldedit.Vector(p.getLocation().getX(), 63, p.getLocation().getZ()); + World worldf = Bukkit.getWorld("world"); + //BukkitWorld BWf = new BukkitWorld(worldf); + //EditSession es = new EditSession(BWf, 2100000000); + try { + SchematicFormat.MCEDIT.save(new CuboidClipboard(v2,v1),new File("plugins/WorldEdit/schematics/world_save.schematic")); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (DataException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } if (args[0].equalsIgnoreCase("spawn_dungeon") && args[1].equalsIgnoreCase("boss")) { //Empty the whole area. double xoffset = Math.random()*10+15;