mirror of
https://github.com/Ste3et/furniture.git
synced 2024-11-22 18:46:08 +01:00
Add CampChair
This commit is contained in:
parent
87ddd4ce16
commit
d4be65a9d4
12
src/Crafting/CampChair.yml
Normal file
12
src/Crafting/CampChair.yml
Normal file
@ -0,0 +1,12 @@
|
||||
CampChair:
|
||||
name: '&cCampChair'
|
||||
material: 383
|
||||
glow: false
|
||||
lore: ''
|
||||
crafting:
|
||||
disable: false
|
||||
recipe: XXX,XEX,AXA
|
||||
index:
|
||||
E: 126
|
||||
X: 0
|
||||
A: 65
|
@ -20,6 +20,7 @@ import de.Ste3et_C0st.Furniture.Objects.electric.billboard;
|
||||
import de.Ste3et_C0st.Furniture.Objects.electric.camera;
|
||||
import de.Ste3et_C0st.Furniture.Objects.electric.streetlamp;
|
||||
import de.Ste3et_C0st.Furniture.Objects.electric.tv;
|
||||
import de.Ste3et_C0st.Furniture.Objects.garden.campchair;
|
||||
import de.Ste3et_C0st.Furniture.Objects.garden.fance;
|
||||
import de.Ste3et_C0st.Furniture.Objects.garden.graveStone;
|
||||
import de.Ste3et_C0st.Furniture.Objects.garden.mailBox;
|
||||
@ -84,6 +85,7 @@ public class main extends JavaPlugin implements Listener{
|
||||
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);
|
||||
new Project("Hammock", new CraftingFile("Hammock", getResource("Crafting/Hammock.yml")), this, hammock.class);
|
||||
new Project("CampChair", new CraftingFile("CampChair", getResource("Crafting/CampChair.yml")), this, campchair.class);
|
||||
|
||||
List<ObjectID> objList = new ArrayList<ObjectID>();
|
||||
for(ObjectID obj : manager.getObjectList()){
|
||||
@ -114,6 +116,7 @@ public class main extends JavaPlugin implements Listener{
|
||||
case "Billboard": new billboard(lib, this, obj); break;
|
||||
case "WeaponStand": new weaponStand(lib, this, obj);break;
|
||||
case "Hammock": new hammock(lib, this, obj); break;
|
||||
case "CampChair": new campchair(lib, this, obj); break;
|
||||
case "Mailbox" :
|
||||
mailBox mail = new mailBox(lib, this, obj);
|
||||
/*try {
|
||||
@ -197,6 +200,7 @@ public class main extends JavaPlugin implements Listener{
|
||||
case "Mailbox" : new mailBox(lib, instance, obj); break;
|
||||
case "WeaponStand": new weaponStand(lib, instance, obj); break;
|
||||
case "Hammock": new hammock(lib, instance, obj); break;
|
||||
case "CampChair": new campchair(lib, instance, obj); break;
|
||||
}
|
||||
e.finish();
|
||||
e.removeItem();
|
||||
|
130
src/de/Ste3et_C0st/Furniture/Objects/garden/campchair.java
Normal file
130
src/de/Ste3et_C0st/Furniture/Objects/garden/campchair.java
Normal file
@ -0,0 +1,130 @@
|
||||
package de.Ste3et_C0st.Furniture.Objects.garden;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
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;
|
||||
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
|
||||
|
||||
public class campchair extends Furniture implements Listener {
|
||||
|
||||
Location loc;
|
||||
BlockFace b;
|
||||
World w;
|
||||
ObjectID obj;
|
||||
FurnitureManager manager;
|
||||
FurnitureLib lib;
|
||||
LocationUtil lutil;
|
||||
Integer id;
|
||||
Plugin plugin;
|
||||
|
||||
public ObjectID getObjectID(){return this.obj;}
|
||||
public Location getLocation(){return this.loc;}
|
||||
public BlockFace getBlockFace(){return this.b;}
|
||||
|
||||
public campchair(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());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFurnitureBreak(FurnitureBreakEvent e) {
|
||||
if(obj==null){return;}
|
||||
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
|
||||
if(e.isCancelled()){return;}
|
||||
if(!e.getID().equals(obj)){return;}
|
||||
if(!e.canBuild()){return;}
|
||||
e.remove();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFurnitureClick(FurnitureClickEvent e) {
|
||||
if(obj==null){return;}
|
||||
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
|
||||
if(e.isCancelled()){return;}
|
||||
if(!e.getID().equals(obj)){return;}
|
||||
if(!e.canBuild()){return;}
|
||||
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
|
||||
if(packet.getName().equalsIgnoreCase("#SITZ#")){
|
||||
if(packet.getPessanger()==null){
|
||||
packet.setPessanger(e.getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawn(Location location) {
|
||||
List<ArmorStandPacket> aspList = new ArrayList<ArmorStandPacket>();
|
||||
Location middle = lutil.getCenter(location);
|
||||
middle.add(0, -1.05, 0);
|
||||
middle.setYaw(lutil.FaceToYaw(b));
|
||||
|
||||
Location l1 = lutil.getRelativ(middle, b, .25, .4);
|
||||
ArmorStandPacket packet = manager.createArmorStand(obj, l1);
|
||||
packet.getInventory().setItemInHand(new ItemStack(Material.LADDER));
|
||||
packet.setPose(lutil.degresstoRad(new EulerAngle(50, 0, 0)), BodyPart.RIGHT_ARM);
|
||||
aspList.add(packet);
|
||||
|
||||
l1 = lutil.getRelativ(middle, b.getOppositeFace(), .25, .4);
|
||||
packet = manager.createArmorStand(obj, l1);
|
||||
packet.getInventory().setItemInHand(new ItemStack(Material.LADDER));
|
||||
packet.setPose(lutil.degresstoRad(new EulerAngle(50, 0, 0)), BodyPart.RIGHT_ARM);
|
||||
aspList.add(packet);
|
||||
|
||||
l1 = middle.clone();
|
||||
l1.add(0, -.65, 0);
|
||||
packet = manager.createArmorStand(obj, l1);
|
||||
packet.getInventory().setHelmet(new ItemStack(Material.WOOD_PLATE));
|
||||
aspList.add(packet);
|
||||
|
||||
middle.add(0,-0.6,0);
|
||||
middle.setYaw(lutil.FaceToYaw(b.getOppositeFace()));
|
||||
packet = manager.createArmorStand(obj, middle);
|
||||
packet.setName("#SITZ#");
|
||||
aspList.add(packet);
|
||||
|
||||
for(ArmorStandPacket as : aspList){
|
||||
as.setInvisible(true);
|
||||
as.setBasePlate(false);
|
||||
as.setGravity(false);
|
||||
}
|
||||
|
||||
manager.send(obj);
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user