+>Added isItemCube(item), getCubeType(id), getItemCubeContents(id), and

insertItemsIntoItemCube(id,items) to the API.
>All sets are now categorized internally for re-rolling purposes.
>All types of Item Cubes can no longer be moved or clicked on while
viewing the contents of their inventories. This reduces the risk of
players throwing item cubes into themselves.
>PlayerDodgeEvent() now has getRawDamage() as a returned value. 
>Fixed spawnAdjustedLivingEntity() in the API to accept a proper
EntityType instead.
>Grammar in sentence fixed for inserting items into a chest.
testdev
sigonasr2 8 years ago
parent 02a309d86a
commit 94037dbea6
  1. BIN
      TwosideKeeper.jar
  2. 12
      src/sig/plugin/TwosideKeeper/CustomDamage.java
  3. 14
      src/sig/plugin/TwosideKeeper/Events/PlayerDodgeEvent.java
  4. 6
      src/sig/plugin/TwosideKeeper/HelperStructures/Common/Habitation.java
  5. 26
      src/sig/plugin/TwosideKeeper/HelperStructures/Common/JobRecipe.java
  6. 17
      src/sig/plugin/TwosideKeeper/HelperStructures/CubeType.java
  7. 2
      src/sig/plugin/TwosideKeeper/HelperStructures/ItemCube.java
  8. 38
      src/sig/plugin/TwosideKeeper/HelperStructures/ItemSet.java
  9. 13
      src/sig/plugin/TwosideKeeper/HelperStructures/Utils/InventoryUtils.java
  10. 100
      src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemCubeUtils.java
  11. 2
      src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemUtils.java
  12. 2
      src/sig/plugin/TwosideKeeper/HelperStructures/Utils/MovementUtils.java
  13. 11
      src/sig/plugin/TwosideKeeper/HolidayEvents/Christmas.java
  14. 3
      src/sig/plugin/TwosideKeeper/ItemCubeWindow.java
  15. 10
      src/sig/plugin/TwosideKeeper/MonsterController.java
  16. 4
      src/sig/plugin/TwosideKeeper/PlayerStructure.java
  17. 170
      src/sig/plugin/TwosideKeeper/TwosideKeeper.java
  18. 31
      src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java
  19. 2
      src/sig/plugin/TwosideKeeper/runServerHeartbeat.java

Binary file not shown.

@ -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;

@ -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() {
@ -38,6 +48,10 @@ public class PlayerDodgeEvent extends Event implements Cancellable{
return flags;
}
public double getRawDamage() {
return damage;
}
@Override
public HandlerList getHandlers() {
return handlers;

@ -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));
}
}

@ -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<String,Recipe> newrecipes = aPlugin.API.getAddedRecipes();
for (String namer : newrecipes.keySet()) {
Recipe r = newrecipes.get(namer);
TwosideKeeper.jobrecipes.add(new JobRecipe(namer,r));
}
}
}

@ -31,4 +31,21 @@ public enum CubeType {
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;
}
}
}

@ -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();

@ -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,

@ -191,4 +191,17 @@ public class InventoryUtils {
//TwosideKeeper.log("Item: "+itemStackAdded, 1);
return itemStackAdded;
}
public static List<ItemStack> ConvertInventoryToList(Inventory inv, int size) {
List<ItemStack> newlist = new ArrayList<ItemStack>();
for (int i=0;i<size;i++) {
newlist.add(new ItemStack(Material.AIR));
}
for (int i=0;i<inv.getSize();i++) {
ItemStack item = inv.getItem(i);
if (item!=null) {
newlist.set(i, item);
}
}
return newlist;
}
}

@ -1,6 +1,9 @@
package sig.plugin.TwosideKeeper.HelperStructures.Utils;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
@ -10,12 +13,15 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Hopper;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import sig.plugin.TwosideKeeper.TwosideKeeper;
import sig.plugin.TwosideKeeper.HelperStructures.CubeType;
import sig.plugin.TwosideKeeper.HelperStructures.ItemCube;
public class ItemCubeUtils {
@ -98,4 +104,98 @@ public class ItemCubeUtils {
return false;
}
}
public static boolean isItemCube(ItemStack it) {
if (ItemUtils.isValidLoreItem(it) &&
isItemCubeMaterial(it.getType()) &&
ItemUtils.LoreContainsSubstring(it, ChatColor.DARK_PURPLE+"ID#")) {
return true;
}
return false;
}
public static CubeType 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"));
}
public static List<ItemStack> getItemCubeContents(int id) {
return loadConfig(id);
}
public static List<ItemStack> loadConfig(int id){
List<ItemStack> ItemCube_items = new ArrayList<ItemStack>();
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<type.getSize();i++) {
ItemCube_items.add(workable.getItemStack("item"+i, new ItemStack(Material.AIR)));
}
return ItemCube_items;
}
public static List<ItemStack> loadFilterConfig(int id){
List<ItemStack> ItemCube_items = new ArrayList<ItemStack>();
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<ItemStack> items){
saveConfig(id,items,null);
}
public static void saveConfig(int id, List<ItemStack> items, CubeType cubetype){
File config;
config = new File(TwosideKeeper.filesave,"itemcubes/ItemCube"+id+".data");
FileConfiguration workable = YamlConfiguration.loadConfiguration(config);
for (int i=0;i<items.size();i++) {
workable.set("item"+i, items.get(i));
}
if (cubetype!=null) {
workable.set("cubetype", cubetype.getID());
}
try {
workable.save(config);
} catch (IOException e) {
e.printStackTrace();
}
}
public static Collection<ItemStack> addItems(int id, ItemStack...items) {
List<ItemStack> currentcontents = getItemCubeContents(id);
List<ItemStack> leftovers = new ArrayList<ItemStack>();
//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<slots;i++) {
inv.setItem(i, currentcontents.get(i));
}
for (ItemStack item : items) {
if (item!=null) {
ItemStack tempitem = item.clone();
HashMap<Integer,ItemStack> 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;
}
}

@ -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) {

@ -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();

@ -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));
}

@ -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);

@ -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;
}
}
/**

@ -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<Integer> graph = GraphBuilder.undirected().build();
public HashMap<Material,Block> blockscanlist=new HashMap<Material,Block>();
public long lastusedrocketbooster=0;
public long lastActionBarMessageTime=0;

@ -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<UUID,PlayerStructure> playerdata;
public static HashMap<UUID,LivingEntityStructure> livingentitydata;
@ -435,6 +438,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
public static List<TemporaryIce> temporary_ice_list = new ArrayList<TemporaryIce>();
public static List<Chunk> temporary_chunks = new ArrayList<Chunk>();
public static List<BlockModifyQueue> blockqueue = new ArrayList<BlockModifyQueue>();
public static List<JobRecipe> jobrecipes = new ArrayList<JobRecipe>();
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<EntityType> 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<ItemStack> 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<ItemStack> 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<ev.getCurrentItem().getItemMeta().getLore().size();i++) {
if (ev.getCurrentItem().getItemMeta().getLore().get(i).contains(ChatColor.DARK_PURPLE+"ID#")) {
@ -4814,6 +4858,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
Inventory temp = Bukkit.getServer().createInventory(p, inventory_size, "Item Cube #"+idnumb);
openItemCubeInventory(temp);
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {@Override public void run() {p.openInventory(temp);
//TODO Implement Graphs. //BuildItemCubeGraph(p);
pd2.opened_another_cube=false;
pd2.isViewingItemCube=true;}},1);
SoundUtils.playLocalSound(p,Sound.BLOCK_CHEST_OPEN,1.0f,1.0f);
@ -4825,6 +4870,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
//pd.itemcubeviews.add(p.getOpenInventory());
pd.opened_another_cube=true;
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {@Override public void run() {p.openInventory(ItemCube.getViewingItemCubeInventory(idnumb, p));
//TODO Implement Graphs. //BuildItemCubeGraph(p);
pd2.opened_another_cube=false;
pd2.isViewingItemCube=true;}},1);
SoundUtils.playLocalSound(p, Sound.BLOCK_CHEST_OPEN, 1.0f, 1.0f);
@ -4837,6 +4883,47 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
}
//TODO Implement Graphs.
/*protected void BuildItemCubeGraph(Player p) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
pd.graph = GraphBuilder.undirected().build();
for (ItemStack it : p.getInventory().getContents()) {
if (ItemCubeUtils.isItemCube(it)) {
int id = ItemCubeUtils.getItemCubeID(it);
pd.graph.addNode(id);
TwosideKeeper.log("Added Node "+id+" ["+pd.graph.nodes().size()+"]", 0);
ContinueBuildingItemCubeGraph(id,p);
}
}
}*/
//TODO Implement Graphs.
/*private void ContinueBuildingItemCubeGraph(int id, Player p) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
CubeType size = ItemCubeUtils.getCubeType(id);
int slots = CubeType.getSlotsFromType(size);
Inventory virtualinventory = null;
virtualinventory = ItemCube.getViewingItemCubeInventory(id, p);
if (virtualinventory==null) {
virtualinventory = Bukkit.createInventory(p, slots);
List<ItemStack> items = itemCube_loadConfig(id);
for (int i=0;i<virtualinventory.getSize();i++) {
if (items.get(i)!=null) {
ItemStack testitem = items.get(i);
if (ItemCubeUtils.isItemCube(testitem)) {
int newid = ItemCubeUtils.getItemCubeID(testitem);
pd.graph.addNode(newid);
pd.graph.putEdge(id, newid);
TwosideKeeper.log("Added Node "+newid+" ["+pd.graph.nodes().size()+"]", 0);
ContinueBuildingItemCubeGraph(newid,p);
}
}
}
}
}*/
public void PerformVacuumCubeChecks(InventoryClickEvent ev) {
if (((ev.getInventory().getType()!=InventoryType.WORKBENCH && ev.getRawSlot()>=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<ItemStack> itemCube_loadConfig(int id){
List<ItemStack> ItemCube_items = new ArrayList<ItemStack>();
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<type.getSize();i++) {
ItemCube_items.add(workable.getItemStack("item"+i, new ItemStack(Material.AIR)));
}
return ItemCube_items;
return ItemCubeUtils.loadConfig(id);
}
@Deprecated
public static List<ItemStack> itemCube_loadFilterConfig(int id){
List<ItemStack> ItemCube_items = new ArrayList<ItemStack>();
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<ItemStack> items){
itemCube_saveConfig(id,items,null);
}
@Deprecated
public static void itemCube_saveConfig(int id, List<ItemStack> items, CubeType cubetype){
File config;
config = new File(TwosideKeeper.filesave,"itemcubes/ItemCube"+id+".data");
FileConfiguration workable = YamlConfiguration.loadConfiguration(config);
for (int i=0;i<items.size();i++) {
workable.set("item"+i, items.get(i));
}
if (cubetype!=null) {
workable.set("cubetype", cubetype.getID());
}
try {
workable.save(config);
} catch (IOException e) {
e.printStackTrace();
}
ItemCubeUtils.saveConfig(id, items, cubetype);
}
public static final void adjustServerTime(long amt) {

@ -1,5 +1,6 @@
package sig.plugin.TwosideKeeper;
import java.util.Collection;
import java.util.List;
import org.bukkit.Location;
@ -7,6 +8,7 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;
@ -14,6 +16,7 @@ import org.bukkit.inventory.ItemStack;
import sig.plugin.TwosideKeeper.HelperStructures.ArtifactAbility;
import sig.plugin.TwosideKeeper.HelperStructures.ArtifactItem;
import sig.plugin.TwosideKeeper.HelperStructures.CubeType;
import sig.plugin.TwosideKeeper.HelperStructures.ItemSet;
import sig.plugin.TwosideKeeper.HelperStructures.LivingEntityDifficulty;
import sig.plugin.TwosideKeeper.HelperStructures.Loot;
@ -24,6 +27,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.ServerType;
import sig.plugin.TwosideKeeper.HelperStructures.WorldShop;
import sig.plugin.TwosideKeeper.HelperStructures.Common.ArrowQuiver;
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemCubeUtils;
public final class TwosideKeeperAPI {
//MONEY COMMANDS.
@ -83,7 +87,7 @@ public final class TwosideKeeperAPI {
public static MonsterDifficulty getMonsterDifficulty(Monster m) {
return MonsterController.getMonsterDifficulty(m);
}
public static LivingEntity spawnAdjustedLivingEntity(LivingEntity ent,Location loc) {
public static LivingEntity spawnAdjustedLivingEntity(EntityType ent,Location loc) {
return MonsterController.spawnAdjustedLivingEntity(ent,loc);
}
public static LivingEntity autoAdjustLivingEntity(LivingEntity m) {
@ -176,6 +180,31 @@ public final class TwosideKeeperAPI {
return TwosideKeeper.getServerTickTime();
}
//Item Cube Commands.
public static boolean isItemCube(ItemStack item) {
return ItemCubeUtils.isItemCube(item);
}
/**
* Returns the CubeType of a given Item Cube ID.
* CubeType contains the number of slots each type is supposed to have
* via CubeType.getSize().
*/
public static CubeType getCubeType(int id) {
return ItemCubeUtils.getCubeType(id);
}
public static Collection<ItemStack> 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<ItemStack> insertItemsIntoItemCube(int id, ItemStack...items) {
return ItemCubeUtils.addItems(id, items);
}
//Hardened Item Commands.
public static boolean isHardenedItem(ItemStack i) {
return GenericFunctions.isHardenedItem(i);

@ -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;
}

Loading…
Cancel
Save