Add Weaponstand

This commit is contained in:
BuildTools 2015-08-31 16:35:09 +02:00
parent 02a6beee6f
commit 518935b3f8
16 changed files with 366 additions and 52 deletions

View File

@ -0,0 +1,12 @@
WeaponStand:
name: '&cWeaponStand'
material: 383
glow: false
lore: ''
crafting:
disable: false
recipe: E0E,X0X,XXX
index:
X: 5
E: 107
0: 0

View File

@ -15,6 +15,7 @@ import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import de.Ste3et_C0st.Furniture.Objects.RPG.weaponStand;
import de.Ste3et_C0st.Furniture.Objects.electric.billboard; import de.Ste3et_C0st.Furniture.Objects.electric.billboard;
import de.Ste3et_C0st.Furniture.Objects.electric.camera; import de.Ste3et_C0st.Furniture.Objects.electric.camera;
import de.Ste3et_C0st.Furniture.Objects.electric.streetlamp; import de.Ste3et_C0st.Furniture.Objects.electric.streetlamp;
@ -80,6 +81,7 @@ public class main extends JavaPlugin implements Listener{
new Project("Streetlamp", new CraftingFile("Streetlamp", getResource("Crafting/Streetlamp.yml")), this, sunshade.class); new Project("Streetlamp", new CraftingFile("Streetlamp", getResource("Crafting/Streetlamp.yml")), this, sunshade.class);
new Project("Billboard", new CraftingFile("Billboard", getResource("Crafting/Billboard.yml")), this, billboard.class); new Project("Billboard", new CraftingFile("Billboard", getResource("Crafting/Billboard.yml")), this, billboard.class);
new Project("Mailbox", new CraftingFile("Mailbox", getResource("Crafting/Mailbox.yml")), this, mailBox.class); new Project("Mailbox", new CraftingFile("Mailbox", getResource("Crafting/Mailbox.yml")), this, mailBox.class);
new Project("WeaponStand", new CraftingFile("WeaponStand", getResource("Crafting/WeaponStand.yml")), this, weaponStand.class);
List<ObjectID> objList = new ArrayList<ObjectID>(); List<ObjectID> objList = new ArrayList<ObjectID>();
for(ObjectID obj : manager.getObjectList()){ for(ObjectID obj : manager.getObjectList()){
@ -108,6 +110,7 @@ public class main extends JavaPlugin implements Listener{
case "Sunshade":new sunshade(lib, this, obj);break; case "Sunshade":new sunshade(lib, this, obj);break;
case "Streetlamp":new streetlamp(lib, this, obj);break; case "Streetlamp":new streetlamp(lib, this, obj);break;
case "Billboard": new billboard(lib, this, obj); break; case "Billboard": new billboard(lib, this, obj); break;
case "WeaponStand": new weaponStand(lib, this, obj);break;
case "Mailbox" : case "Mailbox" :
mailBox mail = new mailBox(lib, this, obj); mailBox mail = new mailBox(lib, this, obj);
/*try { /*try {
@ -116,7 +119,6 @@ public class main extends JavaPlugin implements Listener{
e.printStackTrace(); e.printStackTrace();
}*/ }*/
break; break;
default:break;
} }
} }
} }
@ -191,7 +193,7 @@ public class main extends JavaPlugin implements Listener{
case "Streetlamp": new streetlamp(lib, this, obj);break; case "Streetlamp": new streetlamp(lib, this, obj);break;
case "Billboard": new billboard(lib, instance, obj);break; case "Billboard": new billboard(lib, instance, obj);break;
case "Mailbox" : new mailBox(lib, instance, obj); break; case "Mailbox" : new mailBox(lib, instance, obj); break;
default: e.getPlayer().sendMessage("A error occorupted");return; case "WeaponStand": new weaponStand(lib, instance, obj); break;
} }
e.finish(); e.finish();
e.removeItem(); e.removeItem();

View File

@ -0,0 +1,289 @@
package de.Ste3et_C0st.Furniture.Objects.RPG;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.LocationUtil;
import de.Ste3et_C0st.FurnitureLib.main.ArmorStandPacket;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureManager;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
public class weaponStand extends Furniture {
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Plugin plugin;
List<Integer> slotList1 = Arrays.asList(6,11,14,16,19,21,24,29,32,34,42);
List<Integer> slotList2 = Arrays.asList(20, 15, 33);
List<Material> matList = Arrays.asList(
Material.FENCE_GATE,
Material.SPRUCE_FENCE_GATE,
Material.BIRCH_FENCE_GATE,
Material.JUNGLE_FENCE_GATE,
Material.DARK_OAK_FENCE_GATE,
Material.ACACIA_FENCE_GATE);
public weaponStand(FurnitureLib lib, Plugin plugin, ObjectID id) {
super(lib, plugin, id);
this.lutil = main.getLocationUtil();
this.b = lutil.yawToFace(id.getStartLocation().getYaw());
this.loc = id.getStartLocation().getBlock().getLocation();
this.loc.setYaw(id.getStartLocation().getYaw());
this.w = id.getStartLocation().getWorld();
this.manager = lib.getFurnitureManager();
this.lib = lib;
this.plugin = plugin;
this.obj = id;
if(id.isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
spawn(id.getStartLocation());
}
Player p = null;
Inventory inv = null;
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) {
if(obj==null){return;}
if(!e.getID().equals(obj)){return;}
if(e.isCancelled()){return;}
if(!e.canBuild()){return;}
if(p!=null){
p.closeInventory();
}
List<ArmorStandPacket> asList = manager.getArmorStandPacketByObjectID(obj);
for(ArmorStandPacket packet : asList){
if(packet.getName()!=null&&!packet.getName().equalsIgnoreCase("")){
if(packet.getInventory().getItemInHand()!=null){
if(!packet.getInventory().getItemInHand().getType().equals(Material.AIR)){
w.dropItem(loc, packet.getInventory().getItemInHand());
}
}
}
}
e.remove();
inv = null;
obj=null;
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e) {
if(obj==null){return;}
if(p!=null){return;}
if(e.isCancelled()){return;}
if(!e.canBuild()){return;}
if(!e.getID().equals(obj)){return;}
ItemStack is1 = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 15);
ItemStack is3 = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
ItemMeta im1 = is1.getItemMeta();
ItemMeta im3 = is3.getItemMeta();
im1.setDisplayName("§c");
im3.setDisplayName("§c");
is1.setItemMeta(im1);
is3.setItemMeta(im3);
this.p = e.getPlayer();
inv = Bukkit.createInventory(null, 45, "§cWeaponBox");
ItemStack itemstack = p.getItemInHand();
if(itemstack!=null&&matList.contains(itemstack.getType())){
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
if(packet.getInventory().getHelmet()!=null&&packet.getInventory().getHelmet().getType().toString().toLowerCase().endsWith("gate")){
ItemStack itemStack = new ItemStack(itemstack.getType(), 1, (short) 0);
packet.getInventory().setHelmet(itemStack);
}
}
manager.updateFurniture(obj);
return;
}
List<ArmorStandPacket> asList = manager.getArmorStandPacketByObjectID(obj);
int j = 1;
for(int i = 0; i<inv.getSize();i++){
inv.setItem(i, is1);
if(slotList1.contains(i)){
inv.setItem(i, is3);
}else if(slotList2.contains(i)){
for(ArmorStandPacket packet : asList){
if(packet.getName()!=null&&!packet.getName().equalsIgnoreCase("")){
if(packet.getName().equalsIgnoreCase("#SLOT"+j+"#")){
ItemStack is = new ItemStack(Material.AIR);
if(packet.getInventory().getItemInHand()!=null){is = packet.getInventory().getItemInHand();}
inv.setItem(i, is);
}
}
}
j++;
}
}
this.p.openInventory(inv);
this.p.updateInventory();
}
@EventHandler
private void onClick(InventoryClickEvent e){
if(obj==null){return;}
if(p==null){return;}
if(inv==null){return;}
if(e.getInventory()==null){return;}
if(e.getCurrentItem()==null){return;}
if(!e.getInventory().equals(inv)){return;}
ItemStack is = e.getCurrentItem();
Material m = is.getType();
if(!isValid(m)){e.setCancelled(true);}
}
public boolean isValid(Material m){
String matName = m.toString().toLowerCase();
boolean b = false;
if(matName.endsWith("axe")){b=true;}
if(matName.endsWith("hoe")){b=true;}
if(matName.endsWith("pickaxe")){b=true;}
if(matName.endsWith("spade")){b=true;}
if(matName.endsWith("sword")){b=true;}
if(matName.equalsIgnoreCase("air")){b=true;}
return b;
}
@EventHandler
private void onClose(InventoryCloseEvent e){
if(obj==null){return;}
if(p==null){return;}
if(inv==null){return;}
if(!e.getInventory().getTitle().equalsIgnoreCase(inv.getTitle())){return;}
List<ArmorStandPacket> asList = manager.getArmorStandPacketByObjectID(obj);
int j = 1;
for(int i = 0; i<inv.getSize();i++){
if(slotList2.contains(i)){
for(ArmorStandPacket packet : asList){
if(packet.getName()!=null&&!packet.getName().equalsIgnoreCase("")){
if(packet.getName().equalsIgnoreCase("#SLOT"+j+"#")){
ItemStack is = inv.getItem(i);
if(is==null){is = new ItemStack(Material.AIR);}
packet.getInventory().setItemInHand(is);
}
}
}
j++;
}
}
if(e.getPlayer().equals(p)){
this.p = null;
this.inv = null;
manager.updateFurniture(obj);
}
}
@Override
public void spawn(Location loc) {
List<ArmorStandPacket> packList = new ArrayList<ArmorStandPacket>();
Location center = lutil.getCenter(loc);
center = center.add(0, -2.2, 0);
Location center2 = center;
Location center3 = center.clone();
ArmorStandPacket as = manager.createArmorStand(obj, center2);
as.getInventory().setHelmet(new ItemStack(Material.WOOD_PLATE, 1, (short) 0));
as.setPose(lutil.degresstoRad(new EulerAngle(0, 45, 0)), BodyPart.HEAD);
packList.add(as);
as = manager.createArmorStand(obj, center3.add(0, .2, 0));
as.getInventory().setHelmet(new ItemStack(Material.WOOD_PLATE, 1, (short) 0));
as.setPose(lutil.degresstoRad(new EulerAngle(0, 45, 0)), BodyPart.HEAD);
packList.add(as);
Location location = center;
location = location.add(0, 0, 0);
float yaw = 0;
for(int i = 0; i<4;i++){
BlockFace face = lutil.yawToFace(yaw);
Location locat = lutil.getRelativ(location, face, .185D, .185D);
as = manager.createArmorStand(obj, locat);
as.getInventory().setHelmet(new ItemStack(Material.FENCE_GATE, 1, (short) 0));
as.setPose(lutil.degresstoRad(new EulerAngle(0, -45, 0)), BodyPart.HEAD);
packList.add(as);
as = manager.createArmorStand(obj, locat.add(0, .37, 0).clone());
as.getInventory().setHelmet(new ItemStack(Material.FENCE_GATE, 1, (short) 0));
as.setPose(lutil.degresstoRad(new EulerAngle(0, -45, 0)), BodyPart.HEAD);
packList.add(as);
as = manager.createArmorStand(obj, locat.add(0, .37, 0).clone());
as.getInventory().setHelmet(new ItemStack(Material.FENCE_GATE, 1, (short) 0));
as.setPose(lutil.degresstoRad(new EulerAngle(0, -45, 0)), BodyPart.HEAD);
packList.add(as);
yaw +=90;
}
as = manager.createArmorStand(obj, lutil.getRelativ(location, b, .5, .4d).add(0, 1.8, 0));
as.setName("#SLOT1#");
//as.getInventory().setItemInHand(new ItemStack(Material.DIAMOND_SWORD));
as.setPose(lutil.degresstoRad(new EulerAngle(80, 30, 15)), BodyPart.RIGHT_ARM);
as.setMarker(false);
packList.add(as);
BlockFace face = lutil.yawToFace(lutil.FaceToYaw(b) + 90);
as = manager.createArmorStand(obj, lutil.getRelativ(location, face, .5, .45d).add(0, 1.75, 0));
as.setName("#SLOT2#");
//as.getInventory().setItemInHand(new ItemStack(Material.DIAMOND_SWORD));
as.setPose(lutil.degresstoRad(new EulerAngle(80, 30, 20)), BodyPart.RIGHT_ARM);
as.setMarker(false);
packList.add(as);
as = manager.createArmorStand(obj, lutil.getRelativ(location, b.getOppositeFace(), -.30, .65d).add(0, 1.0, 0));
as.setName("#SLOT3#");
//as.getInventory().setItemInHand(new ItemStack(Material.DIAMOND_AXE));
as.setPose(lutil.degresstoRad(new EulerAngle(-80, 30, 15)), BodyPart.RIGHT_ARM);
as.setMarker(false);
packList.add(as);
for(ArmorStandPacket asp : packList){
asp.setGravity(false);
asp.setInvisible(true);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
}
}

View File

@ -121,10 +121,10 @@ public class billboard extends Furniture implements Listener{
@EventHandler @EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) { public void onFurnitureBreak(FurnitureBreakEvent e) {
if(obj==null){return;}
if(e.isCancelled()){return;} if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;} if(!e.getID().equals(obj)){return;}
if(!e.canBuild()){return;} if(!e.canBuild()){return;}
if(obj==null){return;}
e.remove(); e.remove();
obj=null; obj=null;

View File

@ -131,8 +131,8 @@ public class camera extends Furniture implements Listener{
@EventHandler @EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) { public void onFurnitureBreak(FurnitureBreakEvent e) {
if(e.isCancelled()){return;}
if(obj==null){return;} if(obj==null){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;} if(!e.getID().equals(obj)){return;}
if(!e.canBuild()){return;} if(!e.canBuild()){return;}
e.remove(); e.remove();
@ -143,9 +143,9 @@ public class camera extends Furniture implements Listener{
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@EventHandler @EventHandler
public void onFurnitureClick(FurnitureClickEvent e) { public void onFurnitureClick(FurnitureClickEvent e) {
if(obj==null){return;}
if(e.isCancelled()){return;} if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;} if(!e.getID().equals(obj)){return;}
if(obj==null){return;}
Player p = e.getPlayer(); Player p = e.getPlayer();
Location pLocation = lutil.getRelativ(p.getLocation().getBlock().getLocation(), b, -1D, 0D).clone(); Location pLocation = lutil.getRelativ(p.getLocation().getBlock().getLocation(), b, -1D, 0D).clone();
Location locCopy = getLocation().getBlock().getLocation().clone(); Location locCopy = getLocation().getBlock().getLocation().clone();

View File

@ -34,7 +34,7 @@ import de.Ste3et_C0st.FurnitureLib.main.Type.EventType;
public class streetlamp extends Furniture implements Listener{ public class streetlamp extends Furniture implements Listener{
Location loc, light; Location loc, light;
Vector loc2; Vector loc2, loc3;
BlockFace b; BlockFace b;
World w; World w;
ObjectID obj; ObjectID obj;
@ -55,6 +55,7 @@ public class streetlamp extends Furniture implements Listener{
this.loc = id.getStartLocation().getBlock().getLocation(); this.loc = id.getStartLocation().getBlock().getLocation();
this.loc.setYaw(id.getStartLocation().getYaw()); this.loc.setYaw(id.getStartLocation().getYaw());
this.loc2 = id.getStartLocation().toVector(); this.loc2 = id.getStartLocation().toVector();
this.loc3 = id.getStartLocation().getBlock().getRelative(BlockFace.DOWN).getLocation().toVector();
this.w = id.getStartLocation().getWorld(); this.w = id.getStartLocation().getWorld();
this.manager = lib.getFurnitureManager(); this.manager = lib.getFurnitureManager();
this.lib = lib; this.lib = lib;
@ -148,12 +149,12 @@ public class streetlamp extends Furniture implements Listener{
@EventHandler @EventHandler
private void onPlayerInteract(PlayerInteractEvent e){ private void onPlayerInteract(PlayerInteractEvent e){
if(obj==null) return; if(obj==null){return;}
if(e.isCancelled()){return;} if(e.isCancelled()){return;}
if(redstone) return;
if(e.getAction()==null) return; if(e.getAction()==null) return;
if(e.getClickedBlock()==null) return; if(e.getClickedBlock()==null) return;
if(!blockLocation.contains(e.getClickedBlock().getLocation())){return;} if(!blockLocation.contains(e.getClickedBlock().getLocation())){return;}
if(redstone){return;}
if(!lib.canBuild(e.getPlayer(), obj, EventType.INTERACT)){return;} if(!lib.canBuild(e.getPlayer(), obj, EventType.INTERACT)){return;}
e.setCancelled(true); e.setCancelled(true);
if(e.getAction().equals(Action.LEFT_CLICK_BLOCK)){ if(e.getAction().equals(Action.LEFT_CLICK_BLOCK)){
@ -174,8 +175,8 @@ public class streetlamp extends Furniture implements Listener{
@EventHandler @EventHandler
private void onBlockPowered(BlockRedstoneEvent e){ private void onBlockPowered(BlockRedstoneEvent e){
if(e.getBlock()==null) return; if(obj==null){return;}
if(obj==null) return; if(e.getBlock()==null){return;}
Vector loc = e.getBlock().getLocation().toVector(); Vector loc = e.getBlock().getLocation().toVector();
if(loc2.distance(loc)<=1){ if(loc2.distance(loc)<=1){
if(e.getNewCurrent()==0){ if(e.getNewCurrent()==0){
@ -185,6 +186,17 @@ public class streetlamp extends Furniture implements Listener{
setLight(true); setLight(true);
redstone = true; redstone = true;
} }
return;
}
if(loc3.distance(loc)<=1){
if(e.getNewCurrent()==0){
setLight(false);
redstone = false;
}else{
setLight(true);
redstone = true;
}
return;
} }
} }
@ -193,14 +205,16 @@ public class streetlamp extends Furniture implements Listener{
ArmorStandPacket packet = getPacket(); ArmorStandPacket packet = getPacket();
if(packet==null) return; if(packet==null) return;
packet.getInventory().setHelmet(new ItemStack(Material.REDSTONE_LAMP_OFF)); packet.getInventory().setHelmet(new ItemStack(Material.REDSTONE_LAMP_OFF));
FurnitureLib.getInstance().getLightManager().removeLight(light);
manager.updateFurniture(obj); manager.updateFurniture(obj);
FurnitureLib.getInstance().getLightManager().removeLight(light);
return;
}else{ }else{
ArmorStandPacket packet = getPacket(); ArmorStandPacket packet = getPacket();
if(packet==null) return; if(packet==null) return;
packet.getInventory().setHelmet(new ItemStack(Material.GLOWSTONE)); packet.getInventory().setHelmet(new ItemStack(Material.GLOWSTONE));
FurnitureLib.getInstance().getLightManager().addLight(light, 15);
manager.updateFurniture(obj); manager.updateFurniture(obj);
FurnitureLib.getInstance().getLightManager().addLight(light, 15);
return;
} }
} }

View File

@ -113,10 +113,10 @@ public class tv extends Furniture implements Listener{
@EventHandler @EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){ public void onFurnitureBreak(FurnitureBreakEvent e){
if(obj==null){return;}
if(e.isCancelled()){return;} if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;} if(!e.getID().equals(obj)){return;}
if(!e.canBuild()){return;} if(!e.canBuild()){return;}
if(obj==null){return;}
e.remove(); e.remove();
obj=null; obj=null;
} }

View File

@ -44,7 +44,7 @@ public class fance extends Furniture implements Listener{
public ObjectID getObjectID(){return this.obj;} public ObjectID getObjectID(){return this.obj;}
public Location getLocation(){return this.loc;} public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;} public BlockFace getBlockFace(){return this.b;}
private void setTypes(ItemStack is){for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){packet.getInventory().setHelmet(is);}}
List<Material> matList = Arrays.asList( List<Material> matList = Arrays.asList(
Material.SPRUCE_FENCE, Material.SPRUCE_FENCE,
Material.BIRCH_FENCE, Material.BIRCH_FENCE,
@ -127,7 +127,7 @@ public class fance extends Furniture implements Listener{
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@EventHandler @EventHandler
private void onInteract(PlayerInteractEvent e){ private void onInteract(PlayerInteractEvent e){
if(obj==null) return; if(obj==null){return;}
if(e.isCancelled()) return; if(e.isCancelled()) return;
if(this.block==null) return; if(this.block==null) return;
if(e.getAction()==null)return; if(e.getAction()==null)return;
@ -137,16 +137,15 @@ public class fance extends Furniture implements Listener{
e.setCancelled(true); e.setCancelled(true);
Player p = e.getPlayer(); Player p = e.getPlayer();
ItemStack is = p.getItemInHand(); ItemStack is = p.getItemInHand();
if(is==null||!is.getType().isBlock()) return; if(is==null||!is.getType().isBlock()||is.getType().equals(Material.AIR)) return;
Material m = p.getItemInHand().getType(); ItemStack itemStack = is.clone();
byte data = (byte) is.getDurability(); if(matList.contains(itemStack.getType())){
if(matList.contains(m)){ this.block.setType(itemStack.getType());
this.block.setType(m); this.block.setData((byte) itemStack.getDurability());
this.block.setData(data);
remove(p, is); remove(p, is);
return; return;
}else if(main.materialWhiteList.contains(m)){ }else if(main.materialWhiteList.contains(itemStack.getType())){
setTypes(is); setTypes(itemStack);
remove(p, is); remove(p, is);
manager.updateFurniture(obj); manager.updateFurniture(obj);
return; return;
@ -173,28 +172,21 @@ public class fance extends Furniture implements Listener{
e.setCancelled(true); e.setCancelled(true);
Player p = e.getPlayer(); Player p = e.getPlayer();
ItemStack is = p.getItemInHand(); ItemStack is = p.getItemInHand();
if(is==null || !is.getType().isBlock()) return; if(is==null || !is.getType().isBlock()||is.getType().equals(Material.AIR)) return;
Material m = p.getItemInHand().getType(); ItemStack itemStack = is.clone();
byte data = (byte) is.getDurability(); if(matList.contains(itemStack.getType())){
if(matList.contains(m)){ this.block.setType(itemStack.getType());
this.block.setType(m); this.block.setData((byte) itemStack.getDurability());
this.block.setData(data);
remove(p, is); remove(p, is);
return; return;
}else if(main.materialWhiteList.contains(m)){ }else if(main.materialWhiteList.contains(itemStack.getType())){
setTypes(is); setTypes(itemStack);
remove(p, is); remove(p, is);
manager.updateFurniture(obj); manager.updateFurniture(obj);
return; return;
} }
} }
private void setTypes(ItemStack is){
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
packet.getInventory().setHelmet(is);
}
}
private void setBlock(){ private void setBlock(){
Location location = loc.clone(); Location location = loc.clone();
this.block = location.getBlock(); this.block = location.getBlock();

View File

@ -197,6 +197,7 @@ public class graveStone extends Furniture implements Listener{
@EventHandler @EventHandler
public void onFurnitureClick(FurnitureClickEvent e){ public void onFurnitureClick(FurnitureClickEvent e){
if(obj==null){return;}
Player p = e.getPlayer(); Player p = e.getPlayer();
if(e.isCancelled()) return; if(e.isCancelled()) return;
if(!e.getID().equals(obj)) return; if(!e.getID().equals(obj)) return;

View File

@ -210,10 +210,11 @@ public class mailBox extends Furniture implements Listener {
@EventHandler @EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){ public void onFurnitureBreak(FurnitureBreakEvent e){
if(obj==null){return;}
if(e.isCancelled()) return; if(e.isCancelled()) return;
if(!e.getID().equals(obj)) return; if(!e.getID().equals(obj)) return;
if(!e.canBuild()){return;} if(!e.canBuild()){return;}
if(obj==null){return;}
for(Block b : blockList){ for(Block b : blockList){
b.setType(Material.AIR); b.setType(Material.AIR);
} }
@ -229,9 +230,10 @@ public class mailBox extends Furniture implements Listener {
if(obj==null){return;} if(obj==null){return;}
if(e.isCancelled()){return;} if(e.isCancelled()){return;}
if(e.getAction()==null){return;} if(e.getAction()==null){return;}
if(e.getClickedBlock()==null){return;}
if(!blockList.contains(e.getClickedBlock())){return;}
if(!lib.canBuild(e.getPlayer(), obj, EventType.INTERACT)){return;} if(!lib.canBuild(e.getPlayer(), obj, EventType.INTERACT)){return;}
if(e.getAction().equals(Action.LEFT_CLICK_BLOCK)){ if(e.getAction().equals(Action.LEFT_CLICK_BLOCK)){
if(blockList.contains(e.getClickedBlock())){
e.setCancelled(true); e.setCancelled(true);
for(Block b : blockList){ for(Block b : blockList){
b.setType(Material.AIR); b.setType(Material.AIR);
@ -242,4 +244,3 @@ public class mailBox extends Furniture implements Listener {
} }
} }
} }
}

View File

@ -154,15 +154,15 @@ public class sunshade extends Furniture implements Listener{
} }
}else{ }else{
if(isRunning()){return;} if(isRunning()){return;}
if(!is.hasItemMeta()){return;}
ItemStack itemstack = is.clone();
BannerMeta banner = (BannerMeta) is.getItemMeta(); BannerMeta banner = (BannerMeta) itemstack.getItemMeta();
Short s = lutil.getfromDyeColor(banner.getBaseColor()); Short s = lutil.getfromDyeColor(banner.getBaseColor());
Short newS = lutil.getFromDey(s); Short newS = lutil.getFromDey(s);
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){ for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
if(packet.getName().startsWith("#ELEMENT#")){ if(packet.getName().startsWith("#ELEMENT#")){
packet.getInventory().setHelmet(is); packet.getInventory().setHelmet(itemstack);
}else if(packet.getName().equalsIgnoreCase("#TOP#")){ }else if(packet.getName().equalsIgnoreCase("#TOP#")){
packet.getInventory().setHelmet(new ItemStack(Material.CARPET, 1, newS)); packet.getInventory().setHelmet(new ItemStack(Material.CARPET, 1, newS));
} }
@ -189,6 +189,7 @@ public class sunshade extends Furniture implements Listener{
if(obj==null){return;} if(obj==null){return;}
if(e.isCancelled()){return;} if(e.isCancelled()){return;}
if(e.getAction()==null){return;} if(e.getAction()==null){return;}
if(e.getClickedBlock()==null){return;}
if(!e.getClickedBlock().getLocation().equals(block.getLocation())){return;} if(!e.getClickedBlock().getLocation().equals(block.getLocation())){return;}
if(e.getAction().equals(Action.LEFT_CLICK_BLOCK)){ if(e.getAction().equals(Action.LEFT_CLICK_BLOCK)){
e.setCancelled(true); e.setCancelled(true);
@ -220,13 +221,15 @@ public class sunshade extends Furniture implements Listener{
}else{ }else{
e.setCancelled(true); e.setCancelled(true);
if(isRunning()){return;} if(isRunning()){return;}
BannerMeta banner = (BannerMeta) is.getItemMeta(); if(!is.hasItemMeta()){return;}
ItemStack itemstack = is.clone();
BannerMeta banner = (BannerMeta) itemstack.getItemMeta();
Short s = lutil.getfromDyeColor(banner.getBaseColor()); Short s = lutil.getfromDyeColor(banner.getBaseColor());
Short newS = lutil.getFromDey(s); Short newS = lutil.getFromDey(s);
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){ for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
if(packet.getName().startsWith("#ELEMENT#")){ if(packet.getName().startsWith("#ELEMENT#")){
packet.getInventory().setHelmet(is); packet.getInventory().setHelmet(itemstack);
}else if(packet.getName().equalsIgnoreCase("#TOP#")){ }else if(packet.getName().equalsIgnoreCase("#TOP#")){
packet.getInventory().setHelmet(new ItemStack(Material.CARPET, 1, newS)); packet.getInventory().setHelmet(new ItemStack(Material.CARPET, 1, newS));
} }

View File

@ -111,7 +111,7 @@ public class barrels extends Furniture implements Listener {
if(!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){return;} if(!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){return;}
if(!lib.canBuild(e.getPlayer(), obj, EventType.INTERACT)){return;} if(!lib.canBuild(e.getPlayer(), obj, EventType.INTERACT)){return;}
Player p = e.getPlayer(); Player p = e.getPlayer();
if(!p.getItemInHand().getType().isBlock()&&!p.getItemInHand().getType().equals(Material.AIR)){e.getPlayer().sendMessage("03");return;} if(!p.getItemInHand().getType().isBlock()&&!p.getItemInHand().getType().equals(Material.AIR)){return;}
e.setCancelled(true); e.setCancelled(true);
ItemStack Itemstack = p.getItemInHand().clone(); ItemStack Itemstack = p.getItemInHand().clone();
Itemstack.setAmount(1); Itemstack.setAmount(1);

View File

@ -293,7 +293,7 @@ public class campfire_2 extends Furniture implements Listener{
this.armorS = manager.createArmorStand(obj, grill); this.armorS = manager.createArmorStand(obj, grill);
this.armorS.setInvisible(true); this.armorS.setInvisible(true);
this.armorS.getInventory().setItemInHand(is); this.armorS.getInventory().setItemInHand(is);
manager.send(armorS); manager.send(obj);
this.timer = main.getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(main.getInstance(), new Runnable() { this.timer = main.getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(main.getInstance(), new Runnable() {
Integer rounds = lutil.randInt(15, 30); Integer rounds = lutil.randInt(15, 30);
Integer labs = 0; Integer labs = 0;

View File

@ -243,11 +243,11 @@ public class tent_1 extends Furniture implements Listener{
Location crafting = lutil.getCenter(block.getLocation()); Location crafting = lutil.getCenter(block.getLocation());
crafting.setYaw(lutil.FaceToYaw(b)+90); crafting.setYaw(lutil.FaceToYaw(b)+90);
asp = manager.createArmorStand(obj, crafting.add(0,-1,0)); asp = manager.createArmorStand(obj, crafting.add(0,-1,0).clone());
asp.getInventory().setHelmet(new ItemStack(Material.LADDER)); asp.getInventory().setHelmet(new ItemStack(Material.LADDER));
aspList.add(asp); aspList.add(asp);
asp = manager.createArmorStand(obj, crafting.add(0,.62,0)); asp = manager.createArmorStand(obj, crafting.add(0,.62,0).clone());
asp.getInventory().setHelmet(new ItemStack(Material.LADDER)); asp.getInventory().setHelmet(new ItemStack(Material.LADDER));
aspList.add(asp); aspList.add(asp);

View File

@ -174,10 +174,10 @@ public class tent_3 extends Furniture implements Listener{
@EventHandler @EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){ public void onFurnitureBreak(FurnitureBreakEvent e){
if(obj==null){return;}
if(e.isCancelled()){return;} if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;} if(!e.getID().equals(obj)){return;}
if(!e.canBuild()){return;} if(!e.canBuild()){return;}
if(obj==null){return;}
e.setCancelled(true); e.setCancelled(true);
bed.setType(Material.AIR); bed.setType(Material.AIR);
e.remove(); e.remove();

View File

@ -1,5 +1,5 @@
name: DiceFurniture name: DiceFurniture
version: 2.2 version: 2.3.1
description: Add some new Objects to the Server description: Add some new Objects to the Server
author: Ste3et_C0st author: Ste3et_C0st
website: http://dicecraft.de website: http://dicecraft.de