diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index 8bc20c6..af56a79 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/sig/plugin/TwosideKeeper/CustomDamage.java b/src/sig/plugin/TwosideKeeper/CustomDamage.java index 4e8c4f8..8bc7ae0 100644 --- a/src/sig/plugin/TwosideKeeper/CustomDamage.java +++ b/src/sig/plugin/TwosideKeeper/CustomDamage.java @@ -123,7 +123,7 @@ public class CustomDamage { PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); pd.lasthitproperties=NONE; } - if (!InvulnerableCheck(damager,target,reason,flags)) { + if (!InvulnerableCheck(damager,damage,target,weapon,reason,flags)) { double dmg = 0.0; if (isFlagSet(flags,TRUEDMG)) { //TwosideKeeper.log("Reason: "+reason, 0); @@ -1492,7 +1492,11 @@ public class CustomDamage { } static public boolean InvulnerableCheck(Entity damager, LivingEntity target) { - return InvulnerableCheck(damager,target,"",NONE); + return InvulnerableCheck(damager,0,target,null); + } + + static public boolean InvulnerableCheck(Entity damager, double damage, LivingEntity target, ItemStack weapon) { + return InvulnerableCheck(damager,damage,target,weapon,"",NONE); } /** @@ -1501,7 +1505,7 @@ public class CustomDamage { * @param target * @return Returns true if the target cannot be hit. False otherwise. */ - static public boolean InvulnerableCheck(Entity damager, LivingEntity target, String reason, int flags) { + static public boolean InvulnerableCheck(Entity damager, double damage, LivingEntity target, ItemStack weapon, String reason, int flags) { if (target.isDead()) { return true; //Cancel all damage events if they are dead. } @@ -1539,7 +1543,7 @@ public class CustomDamage { } else { if (target instanceof Player) { Player p = (Player)target; - PlayerDodgeEvent ev = new PlayerDodgeEvent(p,damager,reason,flags); + PlayerDodgeEvent ev = new PlayerDodgeEvent(p,damage,damager,reason,flags); Bukkit.getPluginManager().callEvent(ev); if (ev.isCancelled()) { return false; diff --git a/src/sig/plugin/TwosideKeeper/Events/PlayerDodgeEvent.java b/src/sig/plugin/TwosideKeeper/Events/PlayerDodgeEvent.java index 12bc68e..b15a50b 100644 --- a/src/sig/plugin/TwosideKeeper/Events/PlayerDodgeEvent.java +++ b/src/sig/plugin/TwosideKeeper/Events/PlayerDodgeEvent.java @@ -12,14 +12,24 @@ public class PlayerDodgeEvent extends Event implements Cancellable{ private Entity damager; private String reason; private int flags; + private double damage; private boolean cancelled=false; private static final HandlerList handlers = new HandlerList(); - + + @Deprecated public PlayerDodgeEvent(Player p, Entity damager, String reason, int flags) { this.p=p; this.damager=damager; this.reason=reason; this.flags=flags; + this.damage=0; + } + + public PlayerDodgeEvent(Player p, double damage, Entity damager, String reason, int flags) { + this.p=p; + this.damager=damager; + this.reason=reason; + this.flags=flags; } public Player getPlayer() { @@ -37,6 +47,10 @@ public class PlayerDodgeEvent extends Event implements Cancellable{ public int getFlags() { return flags; } + + public double getRawDamage() { + return damage; + } @Override public HandlerList getHandlers() { diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/Habitation.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/Habitation.java index 9127134..87c19ba 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/Habitation.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/Habitation.java @@ -54,9 +54,9 @@ public class Habitation { int spawnamt = locationhashes.get(hash); spawnamt+=1; locationhashes.put(hash,spawnamt); - for (int x=-2;x<3;x++) { - for (int z=-2;z<3;z++) { - if (x!=0^z!=0) { + for (int x=-4;x<5;x++) { + for (int z=-4;z<5;z++) { + if (x!=0 && z!=0) { addKillToLocation(l.getLocation().add(x*16,0,z*16)); } } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/JobRecipe.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/JobRecipe.java new file mode 100644 index 0000000..11df2a1 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/JobRecipe.java @@ -0,0 +1,26 @@ +package sig.plugin.TwosideKeeper.HelperStructures.Common; + +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.inventory.Recipe; + +import sig.plugin.TwosideKeeper.TwosideKeeper; + +public class JobRecipe { + String name = ""; + Recipe rec; + + public JobRecipe(String name, Recipe rec) { + this.name=name; + this.rec=rec; + } + + public static void InitializeJobRecipes() { + Map newrecipes = aPlugin.API.getAddedRecipes(); + for (String namer : newrecipes.keySet()) { + Recipe r = newrecipes.get(namer); + TwosideKeeper.jobrecipes.add(new JobRecipe(namer,r)); + } + } +} diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/CubeType.java b/src/sig/plugin/TwosideKeeper/HelperStructures/CubeType.java index 4c4b669..d3eb00c 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/CubeType.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/CubeType.java @@ -30,5 +30,22 @@ public enum CubeType { TwosideKeeper.log("INVALID CUBE ID SPECIFIED: "+id+". THIS SHOULD NOT BE HAPPENING!", 0); return null; } + + public static int getSlotsFromType(CubeType size) { + switch (size) { + case ENDER: + return 27; + case FILTER: + return 27; + case LARGE: + return 27; + case NORMAL: + return 9; + case VACUUM: + return 54; + default: + return 27; + } + } } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/ItemCube.java b/src/sig/plugin/TwosideKeeper/HelperStructures/ItemCube.java index 5821f15..aba5a61 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/ItemCube.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/ItemCube.java @@ -25,7 +25,7 @@ public class ItemCube { } public static Inventory getViewingItemCubeInventory(int id, Player checker) { for (Player p : Bukkit.getOnlinePlayers()) { - if (!p.equals(checker)) { + if (checker==null || !p.equals(checker)) { if (p.getOpenInventory()!=null && p.getOpenInventory().getTitle().contains("Item Cube #"+id)) { //This is an item cube. Check if it's the same number. return p.getOpenInventory().getTopInventory(); diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/ItemSet.java b/src/sig/plugin/TwosideKeeper/HelperStructures/ItemSet.java index c83884f..a837231 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/ItemSet.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/ItemSet.java @@ -2,7 +2,9 @@ package sig.plugin.TwosideKeeper.HelperStructures; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.bukkit.ChatColor; import org.bukkit.entity.LivingEntity; @@ -46,6 +48,42 @@ public enum ItemSet { int baseval_bonus4; int increase_val_bonus4; + public static final ItemSet[] RANGER = new ItemSet[]{ + ItemSet.JAMDAK, + ItemSet.DARNYS, + ItemSet.ALIKAHN, + ItemSet.LORASAADI, + }; + public static final ItemSet[] MELEE = new ItemSet[]{ + ItemSet.DAWNTRACKER, + ItemSet.PANROS, + ItemSet.SONGSTEEL, + }; + public static final ItemSet[] TRINKET = new ItemSet[]{ + ItemSet.GLADOMAIN, + ItemSet.ALUSTINE, + ItemSet.MOONSHADOW, + ItemSet.WOLFSBANE, + }; + public static final ItemSet[] HOLIDAY = new ItemSet[]{ + ItemSet.BLITZEN, + ItemSet.COMET, + ItemSet.CUPID, + ItemSet.DANCER, + ItemSet.DASHER, + ItemSet.DONNER, + ItemSet.OLIVE, + ItemSet.PRANCER, + ItemSet.RUDOLPH, + ItemSet.VIXEN, + }; + + public static final ItemSet[][] REROLLABLE_ITEM_SETS = new ItemSet[][]{ + RANGER, + MELEE, + TRINKET, + HOLIDAY}; + ItemSet(int baseval,int increase_val, int baseval2,int increase_val2, int baseval3,int increase_val3, diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/InventoryUtils.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/InventoryUtils.java index 1b6d635..582682f 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/InventoryUtils.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/InventoryUtils.java @@ -191,4 +191,17 @@ public class InventoryUtils { //TwosideKeeper.log("Item: "+itemStackAdded, 1); return itemStackAdded; } + public static List ConvertInventoryToList(Inventory inv, int size) { + List newlist = new ArrayList(); + for (int i=0;i getItemCubeContents(int id) { + return loadConfig(id); + } + + public static List loadConfig(int id){ + List ItemCube_items = new ArrayList(); + File config; + config = new File(TwosideKeeper.filesave,"itemcubes/ItemCube"+id+".data"); + FileConfiguration workable = YamlConfiguration.loadConfiguration(config); + CubeType type = CubeType.getCubeTypeFromID(workable.getInt("cubetype")); + for (int i=0;i loadFilterConfig(int id){ + List ItemCube_items = new ArrayList(); + File config; + config = new File(TwosideKeeper.filesave,"itemcubes/ItemCube"+id+".data"); + FileConfiguration workable = YamlConfiguration.loadConfiguration(config); + + for (int i=0;i<5;i++) { + ItemCube_items.add(workable.getItemStack("filter"+i, new ItemStack(Material.AIR))); + } + return ItemCube_items; + } + + public static void saveConfig(int id, List items){ + saveConfig(id,items,null); + } + + public static void saveConfig(int id, List items, CubeType cubetype){ + File config; + config = new File(TwosideKeeper.filesave,"itemcubes/ItemCube"+id+".data"); + FileConfiguration workable = YamlConfiguration.loadConfiguration(config); + + for (int i=0;i addItems(int id, ItemStack...items) { + List currentcontents = getItemCubeContents(id); + List leftovers = new ArrayList(); + //Attempt to add them to an inventory. + CubeType size = getCubeType(id); + int slots = size.getSize(); + Inventory inv = Bukkit.createInventory(null, slots); + for (int i=0;i remaining = inv.addItem(tempitem.clone()); + if (remaining.size()>0) { + tempitem.setAmount(tempitem.getAmount()-remaining.get(0).getAmount()); + if (tempitem.getAmount()-remaining.get(0).getAmount()>0) { + ItemCube.addToViewersOfItemCube(id,tempitem,null); + } + leftovers.add(remaining.get(0).clone()); + } else { + ItemCube.addToViewersOfItemCube(id,tempitem,null); + } + } + } + saveConfig(id,InventoryUtils.ConvertInventoryToList(inv,slots),size); + return leftovers; + } } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemUtils.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemUtils.java index a3c793c..1feb9d3 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemUtils.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemUtils.java @@ -14,8 +14,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.FireworkMeta; import org.bukkit.inventory.meta.ItemMeta; -import sig.plugin.TwosideKeeper.TwosideKeeper; - public class ItemUtils { public static void addLore(ItemStack item, String string) { diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/MovementUtils.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/MovementUtils.java index 89afa22..047f29b 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/MovementUtils.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/MovementUtils.java @@ -3,8 +3,6 @@ package sig.plugin.TwosideKeeper.HelperStructures.Utils; import org.bukkit.Location; import org.bukkit.util.Vector; -import sig.plugin.TwosideKeeper.TwosideKeeper; - public class MovementUtils { public static Vector moveTowardsLocation(Location currloc, Location targetloc, double spd) { /*double deltax = currloc.getX()-targetloc.getX(); diff --git a/src/sig/plugin/TwosideKeeper/HolidayEvents/Christmas.java b/src/sig/plugin/TwosideKeeper/HolidayEvents/Christmas.java index 735ee39..ec24855 100644 --- a/src/sig/plugin/TwosideKeeper/HolidayEvents/Christmas.java +++ b/src/sig/plugin/TwosideKeeper/HolidayEvents/Christmas.java @@ -458,8 +458,8 @@ public class Christmas { Dispenser d = (Dispenser)b.getState(); Inventory inv = d.getInventory(); inv.addItem(getFireworkShooterToken()); - } else - if ((b.getType()==Material.CHEST || + } + /*if ((b.getType()==Material.CHEST || b.getType()==Material.TRAPPED_CHEST) && (isChristmasBox(itemplaced) || isChristmasDecorationBox(itemplaced))) { Chest c = (Chest)b.getState(); @@ -483,7 +483,7 @@ public class Christmas { } } } - } + }*/ } private static ItemStack HandleGoodieBeforeAdding(Inventory inv, ItemStack item) { @@ -512,6 +512,9 @@ public class Christmas { public static void InitializeChristmasBox() { Chests c = aPlugin.API.Chests.LOOT_CUSTOM_2; + c.setName(getChristmasBox().getItemMeta().getDisplayName()); + c.setLore(getChristmasBox().getItemMeta().getLore()); + c.setProbability(1.0); c.addDrop(new DropMaterial(Material.COAL,1,4,10)); c.addDrop(new DropMaterial(Material.IRON_INGOT,1,4,10)); c.addDrop(new DropMaterial(Material.GOLD_INGOT,1,4,10)); @@ -561,6 +564,8 @@ public class Christmas { Mini_Box.addDrop(new SigDrop(1,10,"Holiday Set Item",true,true,0,LivingEntityDifficulty.HELLFIRE)); //aPlugin.API.getChestItem(c); Chests dec_box = aPlugin.API.Chests.LOOT_CUSTOM_3; + dec_box.setName(getChristmasDecorationBox().getItemMeta().getDisplayName()); + dec_box.setLore(getChristmasDecorationBox().getItemMeta().getLore()); for (int i=0;i<16;i++) { dec_box.addDrop(new DropMaterial(Material.STAINED_GLASS,32,64,12,(short)i)); } diff --git a/src/sig/plugin/TwosideKeeper/ItemCubeWindow.java b/src/sig/plugin/TwosideKeeper/ItemCubeWindow.java index 3d8f114..ec85e29 100644 --- a/src/sig/plugin/TwosideKeeper/ItemCubeWindow.java +++ b/src/sig/plugin/TwosideKeeper/ItemCubeWindow.java @@ -8,6 +8,7 @@ import org.bukkit.inventory.InventoryView; import sig.plugin.TwosideKeeper.HelperStructures.CubeType; import sig.plugin.TwosideKeeper.HelperStructures.ItemCube; +import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemCubeUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils; public class ItemCubeWindow { @@ -29,7 +30,7 @@ public class ItemCubeWindow { public void run() { if (!ItemCube.isSomeoneViewingItemCube(itemcubeid,p)) { //pd.itemcubeviews.add(p.getOpenInventory()); - CubeType size = TwosideKeeper.itemCube_getCubeType(itemcubeid); + CubeType size = ItemCubeUtils.getCubeType(itemcubeid); int inv_size = 9; if (size==CubeType.VACUUM) { TwosideKeeper.log("Opening Vacuum cube.", 5); diff --git a/src/sig/plugin/TwosideKeeper/MonsterController.java b/src/sig/plugin/TwosideKeeper/MonsterController.java index e2a1b71..2a4be3f 100644 --- a/src/sig/plugin/TwosideKeeper/MonsterController.java +++ b/src/sig/plugin/TwosideKeeper/MonsterController.java @@ -1247,8 +1247,14 @@ public class MonsterController { } } - public static LivingEntity spawnAdjustedLivingEntity(LivingEntity et, Location loc) { - return MonsterController.convertLivingEntity(et); + public static LivingEntity spawnAdjustedLivingEntity(EntityType et, Location loc) { + if (TwosideKeeper.LIVING_ENTITY_TYPES.contains(et)) { + LivingEntity le = (LivingEntity)loc.getWorld().spawnEntity(loc, et); + return MonsterController.convertLivingEntity(le); + } else { + TwosideKeeper.log("Tried to spawn an entity that is NOT LIVING! ("+et.name()+") Do not do this!", 0); + return null; + } } /** diff --git a/src/sig/plugin/TwosideKeeper/PlayerStructure.java b/src/sig/plugin/TwosideKeeper/PlayerStructure.java index 3b7824d..c5357f7 100644 --- a/src/sig/plugin/TwosideKeeper/PlayerStructure.java +++ b/src/sig/plugin/TwosideKeeper/PlayerStructure.java @@ -27,6 +27,8 @@ import sig.plugin.TwosideKeeper.HelperStructures.PlayerMode; import sig.plugin.TwosideKeeper.HelperStructures.ServerType; import sig.plugin.TwosideKeeper.Logging.DamageLogger; +//import com.google.common.graph.*; + /*PLAYER STRUCTURE * * Keeps external data and info about the player @@ -179,7 +181,7 @@ public class PlayerStructure { public boolean holidaychest2=false; public boolean holidaychest3=false; public boolean holidaychest4=false; - + //public MutableGraph graph = GraphBuilder.undirected().build(); public HashMap blockscanlist=new HashMap(); public long lastusedrocketbooster=0; public long lastActionBarMessageTime=0; diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index f67bfbe..69a66ae 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -164,6 +164,11 @@ import org.bukkit.potion.PotionType; import org.bukkit.util.Vector; import org.inventivetalent.glow.GlowAPI; +import com.google.common.collect.ImmutableSet; + +//import com.google.common.graph.GraphBuilder; +//import com.google.common.graph.MutableGraph; + import aPlugin.API.Chests; import events.PlayerGainItemEvent; import events.PluginLoadEvent; @@ -202,15 +207,14 @@ import sig.plugin.TwosideKeeper.HelperStructures.Common.ArrowQuiver; import sig.plugin.TwosideKeeper.HelperStructures.Common.BlockModifyQueue; import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; import sig.plugin.TwosideKeeper.HelperStructures.Common.Habitation; +import sig.plugin.TwosideKeeper.HelperStructures.Common.JobRecipe; import sig.plugin.TwosideKeeper.HelperStructures.Common.RecipeCategory; import sig.plugin.TwosideKeeper.HelperStructures.Common.RecipeLinker; import sig.plugin.TwosideKeeper.HelperStructures.Effects.EarthWaveTask; import sig.plugin.TwosideKeeper.HelperStructures.Effects.LavaPlume; import sig.plugin.TwosideKeeper.HelperStructures.Effects.TemporaryIce; import sig.plugin.TwosideKeeper.HelperStructures.Effects.TemporaryLava; -import sig.plugin.TwosideKeeper.HelperStructures.Utils.ArrayUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.BlockUtils; -import sig.plugin.TwosideKeeper.HelperStructures.Utils.DirtBlockReply; import sig.plugin.TwosideKeeper.HelperStructures.Utils.EntityUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.InventoryUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemCubeUtils; @@ -419,7 +423,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public static String lastActionBarMessage=""; public static long last_snow_golem = 0; - public static File filesave; public static HashMap playerdata; public static HashMap livingentitydata; @@ -435,6 +438,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public static List temporary_ice_list = new ArrayList(); public static List temporary_chunks = new ArrayList(); public static List blockqueue = new ArrayList(); + public static List jobrecipes = new ArrayList(); long LastClearStructureTime = 0; public int TeamCounter = 0; @@ -460,6 +464,16 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public final static boolean CHRISTMASEVENT_ACTIVATED=false; public final static boolean CHRISTMASLINGERINGEVENT_ACTIVATED=true; //Limited Christmas drops/functionality remain while the majority of it is turned off. + public static final Set LIVING_ENTITY_TYPES = ImmutableSet.of( + EntityType.BAT,EntityType.BLAZE,EntityType.CAVE_SPIDER,EntityType.CHICKEN, + EntityType.COW,EntityType.CREEPER,EntityType.HORSE,EntityType.GUARDIAN,EntityType.ENDER_DRAGON, + EntityType.ENDERMAN,EntityType.ENDERMITE,EntityType.GHAST,EntityType.GIANT, + EntityType.IRON_GOLEM,EntityType.PLAYER,EntityType.MAGMA_CUBE,EntityType.MUSHROOM_COW, + EntityType.OCELOT,EntityType.PIG,EntityType.PIG_ZOMBIE,EntityType.RABBIT, + EntityType.SHEEP,EntityType.SHULKER,EntityType.SILVERFISH,EntityType.SKELETON, + EntityType.SLIME,EntityType.SNOWMAN,EntityType.SPIDER,EntityType.SQUID, + EntityType.VILLAGER,EntityType.WITCH,EntityType.WOLF,EntityType.ZOMBIE); + boolean reloadedchunk=false; int[] lampblocks = {1626,71,-255, //List of all lamp blocks in the city to be lit. @@ -1318,7 +1332,23 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } delay++; } - } + }break; + case "ADDCUBE":{ + Collection remaining = ItemCubeUtils.addItems(Integer.parseInt(args[1]), p.getEquipment().getItemInMainHand()); + if (remaining.size()>0) { + for (ItemStack item : remaining) { + p.sendMessage("Could not fit "+GenericFunctions.UserFriendlyMaterialName(item)+" "+((item.getAmount()>1)?"x"+item.getAmount():"")); + } + } + }break; + case "ADDHOTBARCUBE":{ + Collection remaining = ItemCubeUtils.addItems(Integer.parseInt(args[1]), GenericFunctions.getHotbarItems(p)); + if (remaining.size()>0) { + for (ItemStack item : remaining) { + p.sendMessage("Could not fit "+GenericFunctions.UserFriendlyMaterialName(item)+" "+((item.getAmount()>1)?"x"+item.getAmount():"")); + } + } + }break; } } //LivingEntity m = MonsterController.convertMonster((Monster)p.getWorld().spawnEntity(p.getLocation(),EntityType.ZOMBIE), MonsterDifficulty.ELITE); @@ -1810,6 +1840,23 @@ public class TwosideKeeper extends JavaPlugin implements Listener { fin.addExtra(tc); } } + /*if (RecipeCategory.valueOf(arg)==RecipeCategory.MISC_ITEMS) { + //Display the Custom Recipes. + j++; + JobRecipe jr = + TextComponent tc = new TextComponent(ChatColor.values()[j+2]+"["+val.getColor()+val.getName()+ChatColor.values()[j+2]+"] "); + if (p.hasPermission("createViaCraftMenu") && (getServerType()==ServerType.TEST || getServerType()==ServerType.QUIET)) { + tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,new ComponentBuilder("Click to be given a "+val.getColor()+val.getName()).create())); + } else { + tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,new ComponentBuilder("Click to view the recipe for "+val.getColor()+val.getName()).create())); + } + tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,"/craft "+val.name()+" view")); + if (j>2) { + tc.addExtra("\n"); + j=0; + } + fin.addExtra(tc); + }*/ p.spigot().sendMessage(fin); } @@ -3094,7 +3141,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } else { if (count>0) { - ev.getPlayer().sendMessage("Stored "+ChatColor.AQUA+count+ChatColor.WHITE+" items inside the chest."); + ev.getPlayer().sendMessage("Stored "+ChatColor.AQUA+count+ChatColor.WHITE+" item"+(count==1?"":"s")+" inside the chest."); } } virtualinventory.clear(); @@ -4585,11 +4632,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } //This is an Item Cube. //Check to see if the cursor item is an item cube. - if ((ev.getCurrentItem().getType()==Material.CHEST || - ev.getCurrentItem().getType()==Material.STORAGE_MINECART || - ev.getCurrentItem().getType()==Material.ENDER_CHEST) && - ev.getCurrentItem().hasItemMeta() && - ev.getCurrentItem().getItemMeta().hasLore()) { + if ((ItemCubeUtils.isItemCubeMaterial(ev.getCurrentItem().getType()) && + ItemCubeUtils.isItemCube(ev.getCurrentItem()))) { log("The clicked item has lore...",5); for (int i=0;i items = itemCube_loadConfig(id); + for (int i=0;i=0) || (ev.getInventory().getType()==InventoryType.WORKBENCH && ev.getRawSlot()>9)) && ev.getCurrentItem()!=null) { @@ -4849,7 +4936,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ev.getWhoClicked().getOpenInventory().getTitle().contains("Item Cube #")) { itemcubeid = Integer.parseInt(ev.getWhoClicked().getOpenInventory().getTitle().split("#")[1]); //This is the ID of the window we are looking at, if one exists. - cubetype = itemCube_getCubeType(itemcubeid); + cubetype = ItemCubeUtils.getCubeType(itemcubeid); if (cubetype==CubeType.VACUUM) { //TwosideKeeper.log(ev.getCurrentItem()+"|||"+ev.getCursor(), 0); if ((ev.getCurrentItem().getType()!=Material.AIR && !ev.getCurrentItem().getType().isBlock()) || (ev.getCursor().getType()!=Material.AIR && !ev.getCursor().getType().isBlock())) { @@ -5164,7 +5251,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { double dmgdealt = ev.getDamage(DamageModifier.BASE); CustomDamage.setupTrueDamage(ev); //boolean applieddmg = CustomDamage.ApplyDamage(dmgdealt, null, (LivingEntity)ev.getEntity(), null, ev.getCause().name(), CustomDamage.TRUEDMG); - if (!CustomDamage.InvulnerableCheck(null, (LivingEntity)ev.getEntity(),ev.getCause().name(), CustomDamage.TRUEDMG)) { + if (!CustomDamage.InvulnerableCheck(null, dmgdealt, (LivingEntity)ev.getEntity(), null, ev.getCause().name(), CustomDamage.TRUEDMG)) { boolean applieddmg=true; dmgdealt = CustomDamage.CalculateDamage(dmgdealt, null, (LivingEntity)ev.getEntity(), null, ev.getCause().name(), CustomDamage.TRUEDMG); //TwosideKeeper.log("Damage: "+dmgdealt+" Event cause: "+ev.getCause(), 0); @@ -5178,10 +5265,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } dmgdealt *= GenericFunctions.CalculateFallResistance((LivingEntity)ev.getEntity()); } - TwosideKeeper.log("Damage: "+dmgdealt, 0); + //TwosideKeeper.log("Damage: "+dmgdealt, 0); dmgdealt = CustomDamage.subtractAbsorptionHearts(dmgdealt, (LivingEntity)ev.getEntity()); dmgdealt = CustomDamage.applyOnHitEffects(dmgdealt,null,(LivingEntity)ev.getEntity(),null ,ev.getCause().name(),CustomDamage.TRUEDMG); - TwosideKeeper.log("Damage: "+dmgdealt, 0); + //TwosideKeeper.log("Damage: "+dmgdealt, 0); /*if ((ev.getCause()==DamageCause.CONTACT || ev.getCause()==DamageCause.LIGHTNING || ev.getCause()==DamageCause.FALLING_BLOCK || @@ -5627,6 +5714,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } if (em!=null && em.targetlist.size()==0) { + if (em.targetlist.size()==0 && em.participantlist.size()==0) { + ev.setCancelled(true); + return; + } if ((ev.getTarget() instanceof Player) && !em.targetlist.contains((Player)ev.getTarget())) { Player p = (Player)ev.getTarget(); PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); @@ -5945,6 +6036,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener { participants_list.append(", "+pl.getName()); } } + } else { + Item it = m.getWorld().dropItemNaturally(m.getLocation(), aPlugin.API.getChestItem(Chests.ELITE)); + it.setInvulnerable(true); + it.setPickupDelay(0); } } Bukkit.getServer().broadcastMessage(ChatColor.YELLOW+"DPS Breakdown:"); @@ -7854,58 +7949,25 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } //Item Cube Loading. + @Deprecated public static List itemCube_loadConfig(int id){ - List ItemCube_items = new ArrayList(); - File config; - config = new File(TwosideKeeper.filesave,"itemcubes/ItemCube"+id+".data"); - FileConfiguration workable = YamlConfiguration.loadConfiguration(config); - CubeType type = CubeType.getCubeTypeFromID(workable.getInt("cubetype")); - for (int i=0;i itemCube_loadFilterConfig(int id){ - List ItemCube_items = new ArrayList(); - File config; - config = new File(TwosideKeeper.filesave,"itemcubes/ItemCube"+id+".data"); - FileConfiguration workable = YamlConfiguration.loadConfiguration(config); - - for (int i=0;i<5;i++) { - ItemCube_items.add(workable.getItemStack("filter"+i, new ItemStack(Material.AIR))); - } - return ItemCube_items; - } - - public static CubeType itemCube_getCubeType(int id){ - File config; - config = new File(TwosideKeeper.filesave,"itemcubes/ItemCube"+id+".data"); - FileConfiguration workable = YamlConfiguration.loadConfiguration(config); - return CubeType.getCubeTypeFromID(workable.getInt("cubetype")); + return ItemCubeUtils.loadFilterConfig(id); } //Item Cube Saving. + @Deprecated public static void itemCube_saveConfig(int id, List items){ itemCube_saveConfig(id,items,null); } - + + @Deprecated public static void itemCube_saveConfig(int id, List items, CubeType cubetype){ - File config; - config = new File(TwosideKeeper.filesave,"itemcubes/ItemCube"+id+".data"); - FileConfiguration workable = YamlConfiguration.loadConfiguration(config); - - for (int i=0;i getItemCubeContents(int id) { + return ItemCubeUtils.getItemCubeContents(id); + } + /** + * Handles everything regarding inserting items into an Item Cube including saving + * it and updating it in all open players' InventoryViews. + * @return Returns items that could not fit in the Item Cube. It's your responsibility + * to properly handle what did not fit. + */ + public static Collection insertItemsIntoItemCube(int id, ItemStack...items) { + return ItemCubeUtils.addItems(id, items); + } + //Hardened Item Commands. public static boolean isHardenedItem(ItemStack i) { return GenericFunctions.isHardenedItem(i); diff --git a/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java b/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java index 0489298..fa21ef5 100644 --- a/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java +++ b/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java @@ -460,6 +460,7 @@ final class runServerHeartbeat implements Runnable { Item it = (Item)ent; if (it.getPickupDelay()<=0) { events.PlayerManualPickupItemEvent ev = new events.PlayerManualPickupItemEvent(p, it.getItemStack()); + Bukkit.getPluginManager().callEvent(ev); if (!ev.isCancelled()) { ItemStack[] remaining = InventoryUtils.insertItemsInFilterCube(p, it.getItemStack()); if (remaining.length==0) { @@ -469,6 +470,7 @@ final class runServerHeartbeat implements Runnable { } } } + count++; if (count>8) { return; }