mirror of
https://github.com/Ste3et/furniture.git
synced 2024-11-22 10:36:12 +01:00
Add Weaponstand
This commit is contained in:
parent
02a6beee6f
commit
518935b3f8
12
src/Crafting/WeaponStand.yml
Normal file
12
src/Crafting/WeaponStand.yml
Normal 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
|
@ -15,6 +15,7 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
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.camera;
|
||||
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("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("WeaponStand", new CraftingFile("WeaponStand", getResource("Crafting/WeaponStand.yml")), this, weaponStand.class);
|
||||
|
||||
List<ObjectID> objList = new ArrayList<ObjectID>();
|
||||
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 "Streetlamp":new streetlamp(lib, this, obj);break;
|
||||
case "Billboard": new billboard(lib, this, obj); break;
|
||||
case "WeaponStand": new weaponStand(lib, this, obj);break;
|
||||
case "Mailbox" :
|
||||
mailBox mail = new mailBox(lib, this, obj);
|
||||
/*try {
|
||||
@ -116,7 +119,6 @@ public class main extends JavaPlugin implements Listener{
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
break;
|
||||
default:break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -191,7 +193,7 @@ public class main extends JavaPlugin implements Listener{
|
||||
case "Streetlamp": new streetlamp(lib, this, obj);break;
|
||||
case "Billboard": new billboard(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.removeItem();
|
||||
|
289
src/de/Ste3et_C0st/Furniture/Objects/RPG/weaponStand.java
Normal file
289
src/de/Ste3et_C0st/Furniture/Objects/RPG/weaponStand.java
Normal 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);
|
||||
}
|
||||
|
||||
}
|
@ -121,10 +121,10 @@ public class billboard extends Furniture implements Listener{
|
||||
|
||||
@EventHandler
|
||||
public void onFurnitureBreak(FurnitureBreakEvent e) {
|
||||
if(obj==null){return;}
|
||||
if(e.isCancelled()){return;}
|
||||
if(!e.getID().equals(obj)){return;}
|
||||
if(!e.canBuild()){return;}
|
||||
if(obj==null){return;}
|
||||
e.remove();
|
||||
obj=null;
|
||||
|
||||
|
@ -131,8 +131,8 @@ public class camera extends Furniture implements Listener{
|
||||
|
||||
@EventHandler
|
||||
public void onFurnitureBreak(FurnitureBreakEvent e) {
|
||||
if(e.isCancelled()){return;}
|
||||
if(obj==null){return;}
|
||||
if(e.isCancelled()){return;}
|
||||
if(!e.getID().equals(obj)){return;}
|
||||
if(!e.canBuild()){return;}
|
||||
e.remove();
|
||||
@ -143,9 +143,9 @@ public class camera extends Furniture implements Listener{
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler
|
||||
public void onFurnitureClick(FurnitureClickEvent e) {
|
||||
if(obj==null){return;}
|
||||
if(e.isCancelled()){return;}
|
||||
if(!e.getID().equals(obj)){return;}
|
||||
if(obj==null){return;}
|
||||
Player p = e.getPlayer();
|
||||
Location pLocation = lutil.getRelativ(p.getLocation().getBlock().getLocation(), b, -1D, 0D).clone();
|
||||
Location locCopy = getLocation().getBlock().getLocation().clone();
|
||||
|
@ -34,7 +34,7 @@ import de.Ste3et_C0st.FurnitureLib.main.Type.EventType;
|
||||
public class streetlamp extends Furniture implements Listener{
|
||||
|
||||
Location loc, light;
|
||||
Vector loc2;
|
||||
Vector loc2, loc3;
|
||||
BlockFace b;
|
||||
World w;
|
||||
ObjectID obj;
|
||||
@ -55,6 +55,7 @@ public class streetlamp extends Furniture implements Listener{
|
||||
this.loc = id.getStartLocation().getBlock().getLocation();
|
||||
this.loc.setYaw(id.getStartLocation().getYaw());
|
||||
this.loc2 = id.getStartLocation().toVector();
|
||||
this.loc3 = id.getStartLocation().getBlock().getRelative(BlockFace.DOWN).getLocation().toVector();
|
||||
this.w = id.getStartLocation().getWorld();
|
||||
this.manager = lib.getFurnitureManager();
|
||||
this.lib = lib;
|
||||
@ -148,12 +149,12 @@ public class streetlamp extends Furniture implements Listener{
|
||||
|
||||
@EventHandler
|
||||
private void onPlayerInteract(PlayerInteractEvent e){
|
||||
if(obj==null) return;
|
||||
if(obj==null){return;}
|
||||
if(e.isCancelled()){return;}
|
||||
if(redstone) return;
|
||||
if(e.getAction()==null) return;
|
||||
if(e.getClickedBlock()==null) return;
|
||||
if(!blockLocation.contains(e.getClickedBlock().getLocation())){return;}
|
||||
if(redstone){return;}
|
||||
if(!lib.canBuild(e.getPlayer(), obj, EventType.INTERACT)){return;}
|
||||
e.setCancelled(true);
|
||||
if(e.getAction().equals(Action.LEFT_CLICK_BLOCK)){
|
||||
@ -174,8 +175,8 @@ public class streetlamp extends Furniture implements Listener{
|
||||
|
||||
@EventHandler
|
||||
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();
|
||||
if(loc2.distance(loc)<=1){
|
||||
if(e.getNewCurrent()==0){
|
||||
@ -185,6 +186,17 @@ public class streetlamp extends Furniture implements Listener{
|
||||
setLight(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();
|
||||
if(packet==null) return;
|
||||
packet.getInventory().setHelmet(new ItemStack(Material.REDSTONE_LAMP_OFF));
|
||||
FurnitureLib.getInstance().getLightManager().removeLight(light);
|
||||
manager.updateFurniture(obj);
|
||||
FurnitureLib.getInstance().getLightManager().removeLight(light);
|
||||
return;
|
||||
}else{
|
||||
ArmorStandPacket packet = getPacket();
|
||||
if(packet==null) return;
|
||||
packet.getInventory().setHelmet(new ItemStack(Material.GLOWSTONE));
|
||||
FurnitureLib.getInstance().getLightManager().addLight(light, 15);
|
||||
manager.updateFurniture(obj);
|
||||
FurnitureLib.getInstance().getLightManager().addLight(light, 15);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,10 +113,10 @@ public class tv extends Furniture implements Listener{
|
||||
|
||||
@EventHandler
|
||||
public void onFurnitureBreak(FurnitureBreakEvent e){
|
||||
if(obj==null){return;}
|
||||
if(e.isCancelled()){return;}
|
||||
if(!e.getID().equals(obj)){return;}
|
||||
if(!e.canBuild()){return;}
|
||||
if(obj==null){return;}
|
||||
e.remove();
|
||||
obj=null;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class fance extends Furniture implements Listener{
|
||||
public ObjectID getObjectID(){return this.obj;}
|
||||
public Location getLocation(){return this.loc;}
|
||||
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(
|
||||
Material.SPRUCE_FENCE,
|
||||
Material.BIRCH_FENCE,
|
||||
@ -127,7 +127,7 @@ public class fance extends Furniture implements Listener{
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler
|
||||
private void onInteract(PlayerInteractEvent e){
|
||||
if(obj==null) return;
|
||||
if(obj==null){return;}
|
||||
if(e.isCancelled()) return;
|
||||
if(this.block==null) return;
|
||||
if(e.getAction()==null)return;
|
||||
@ -137,16 +137,15 @@ public class fance extends Furniture implements Listener{
|
||||
e.setCancelled(true);
|
||||
Player p = e.getPlayer();
|
||||
ItemStack is = p.getItemInHand();
|
||||
if(is==null||!is.getType().isBlock()) return;
|
||||
Material m = p.getItemInHand().getType();
|
||||
byte data = (byte) is.getDurability();
|
||||
if(matList.contains(m)){
|
||||
this.block.setType(m);
|
||||
this.block.setData(data);
|
||||
if(is==null||!is.getType().isBlock()||is.getType().equals(Material.AIR)) return;
|
||||
ItemStack itemStack = is.clone();
|
||||
if(matList.contains(itemStack.getType())){
|
||||
this.block.setType(itemStack.getType());
|
||||
this.block.setData((byte) itemStack.getDurability());
|
||||
remove(p, is);
|
||||
return;
|
||||
}else if(main.materialWhiteList.contains(m)){
|
||||
setTypes(is);
|
||||
}else if(main.materialWhiteList.contains(itemStack.getType())){
|
||||
setTypes(itemStack);
|
||||
remove(p, is);
|
||||
manager.updateFurniture(obj);
|
||||
return;
|
||||
@ -173,28 +172,21 @@ public class fance extends Furniture implements Listener{
|
||||
e.setCancelled(true);
|
||||
Player p = e.getPlayer();
|
||||
ItemStack is = p.getItemInHand();
|
||||
if(is==null || !is.getType().isBlock()) return;
|
||||
Material m = p.getItemInHand().getType();
|
||||
byte data = (byte) is.getDurability();
|
||||
if(matList.contains(m)){
|
||||
this.block.setType(m);
|
||||
this.block.setData(data);
|
||||
if(is==null || !is.getType().isBlock()||is.getType().equals(Material.AIR)) return;
|
||||
ItemStack itemStack = is.clone();
|
||||
if(matList.contains(itemStack.getType())){
|
||||
this.block.setType(itemStack.getType());
|
||||
this.block.setData((byte) itemStack.getDurability());
|
||||
remove(p, is);
|
||||
return;
|
||||
}else if(main.materialWhiteList.contains(m)){
|
||||
setTypes(is);
|
||||
}else if(main.materialWhiteList.contains(itemStack.getType())){
|
||||
setTypes(itemStack);
|
||||
remove(p, is);
|
||||
manager.updateFurniture(obj);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void setTypes(ItemStack is){
|
||||
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
|
||||
packet.getInventory().setHelmet(is);
|
||||
}
|
||||
}
|
||||
|
||||
private void setBlock(){
|
||||
Location location = loc.clone();
|
||||
this.block = location.getBlock();
|
||||
|
@ -197,6 +197,7 @@ public class graveStone extends Furniture implements Listener{
|
||||
|
||||
@EventHandler
|
||||
public void onFurnitureClick(FurnitureClickEvent e){
|
||||
if(obj==null){return;}
|
||||
Player p = e.getPlayer();
|
||||
if(e.isCancelled()) return;
|
||||
if(!e.getID().equals(obj)) return;
|
||||
|
@ -210,10 +210,11 @@ public class mailBox extends Furniture implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onFurnitureBreak(FurnitureBreakEvent e){
|
||||
if(obj==null){return;}
|
||||
if(e.isCancelled()) return;
|
||||
if(!e.getID().equals(obj)) return;
|
||||
if(!e.canBuild()){return;}
|
||||
if(obj==null){return;}
|
||||
|
||||
for(Block b : blockList){
|
||||
b.setType(Material.AIR);
|
||||
}
|
||||
@ -229,9 +230,10 @@ public class mailBox extends Furniture implements Listener {
|
||||
if(obj==null){return;}
|
||||
if(e.isCancelled()){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(e.getAction().equals(Action.LEFT_CLICK_BLOCK)){
|
||||
if(blockList.contains(e.getClickedBlock())){
|
||||
e.setCancelled(true);
|
||||
for(Block b : blockList){
|
||||
b.setType(Material.AIR);
|
||||
@ -239,7 +241,6 @@ public class mailBox extends Furniture implements Listener {
|
||||
blockList.clear();
|
||||
this.obj.remove(e.getPlayer());
|
||||
obj=null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -154,15 +154,15 @@ public class sunshade extends Furniture implements Listener{
|
||||
}
|
||||
}else{
|
||||
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 newS = lutil.getFromDey(s);
|
||||
|
||||
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
|
||||
if(packet.getName().startsWith("#ELEMENT#")){
|
||||
packet.getInventory().setHelmet(is);
|
||||
packet.getInventory().setHelmet(itemstack);
|
||||
}else if(packet.getName().equalsIgnoreCase("#TOP#")){
|
||||
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(e.isCancelled()){return;}
|
||||
if(e.getAction()==null){return;}
|
||||
if(e.getClickedBlock()==null){return;}
|
||||
if(!e.getClickedBlock().getLocation().equals(block.getLocation())){return;}
|
||||
if(e.getAction().equals(Action.LEFT_CLICK_BLOCK)){
|
||||
e.setCancelled(true);
|
||||
@ -220,13 +221,15 @@ public class sunshade extends Furniture implements Listener{
|
||||
}else{
|
||||
e.setCancelled(true);
|
||||
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 newS = lutil.getFromDey(s);
|
||||
|
||||
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
|
||||
if(packet.getName().startsWith("#ELEMENT#")){
|
||||
packet.getInventory().setHelmet(is);
|
||||
packet.getInventory().setHelmet(itemstack);
|
||||
}else if(packet.getName().equalsIgnoreCase("#TOP#")){
|
||||
packet.getInventory().setHelmet(new ItemStack(Material.CARPET, 1, newS));
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ public class barrels extends Furniture implements Listener {
|
||||
if(!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){return;}
|
||||
if(!lib.canBuild(e.getPlayer(), obj, EventType.INTERACT)){return;}
|
||||
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);
|
||||
ItemStack Itemstack = p.getItemInHand().clone();
|
||||
Itemstack.setAmount(1);
|
||||
|
@ -293,7 +293,7 @@ public class campfire_2 extends Furniture implements Listener{
|
||||
this.armorS = manager.createArmorStand(obj, grill);
|
||||
this.armorS.setInvisible(true);
|
||||
this.armorS.getInventory().setItemInHand(is);
|
||||
manager.send(armorS);
|
||||
manager.send(obj);
|
||||
this.timer = main.getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(main.getInstance(), new Runnable() {
|
||||
Integer rounds = lutil.randInt(15, 30);
|
||||
Integer labs = 0;
|
||||
|
@ -243,11 +243,11 @@ public class tent_1 extends Furniture implements Listener{
|
||||
Location crafting = lutil.getCenter(block.getLocation());
|
||||
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));
|
||||
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));
|
||||
aspList.add(asp);
|
||||
|
||||
|
@ -174,10 +174,10 @@ public class tent_3 extends Furniture implements Listener{
|
||||
|
||||
@EventHandler
|
||||
public void onFurnitureBreak(FurnitureBreakEvent e){
|
||||
if(obj==null){return;}
|
||||
if(e.isCancelled()){return;}
|
||||
if(!e.getID().equals(obj)){return;}
|
||||
if(!e.canBuild()){return;}
|
||||
if(obj==null){return;}
|
||||
e.setCancelled(true);
|
||||
bed.setType(Material.AIR);
|
||||
e.remove();
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: DiceFurniture
|
||||
version: 2.2
|
||||
version: 2.3.1
|
||||
description: Add some new Objects to the Server
|
||||
author: Ste3et_C0st
|
||||
website: http://dicecraft.de
|
||||
|
Loading…
Reference in New Issue
Block a user