Make the Plugin Compatible with the newes FurnitureLib

This commit is contained in:
BuildTools 2015-10-31 23:50:14 +01:00
parent d4be65a9d4
commit 358a44962e
57 changed files with 4513 additions and 1876 deletions

12
src/Crafting/BearTrap.yml Normal file
View File

@ -0,0 +1,12 @@
BearTrap:
name: '&cBearTrap'
material: 383
glow: false
lore: ''
crafting:
disable: false
recipe: XXX,AAA,XOX
index:
X: 0
A: 101
O: 167

View File

@ -0,0 +1,11 @@
BlackBoard:
name: '&cBlackBoard'
material: 383
glow: false
lore: ''
crafting:
disable: false
recipe: AAA,AAA,OOO
index:
A: 425
O: 72

View File

@ -0,0 +1,11 @@
CactusPlant:
name: '&cCactusPlant'
material: 383
glow: true
lore: ''
crafting:
disable: true
recipe: X0X,X0X,XXX
index:
'0': 0
X: 280

12
src/Crafting/Catapult.yml Normal file
View File

@ -0,0 +1,12 @@
Catapult:
name: '&cCatapult'
material: 383
glow: false
lore: ''
crafting:
disable: false
recipe: AXA,ABA,AAA
index:
X: 0
A: 17
B: 261

13
src/Crafting/Crossbow.yml Normal file
View File

@ -0,0 +1,13 @@
Crossbow:
name: '&cCrossbow'
material: 383
glow: false
lore: ''
crafting:
disable: false
recipe: XAX,XOX,OBO
index:
X: 0
A: 261
O: 280
B: 44

View File

@ -0,0 +1,12 @@
FlowerPot:
name: '&cFlowerPot'
material: 383
glow: false
lore: ''
crafting:
disable: true
recipe: XTX,ATA,TAT
index:
T: 0
X: 280
A: 336

View File

@ -0,0 +1,12 @@
HumanSkeleton:
name: '&cHumanSkeleton'
material: 383
glow: false
lore: ''
crafting:
disable: false
recipe: XAX,XOX,XOX
index:
X: 0
A: 397
O: 352

View File

@ -0,0 +1,12 @@
SchoolChair:
name: '&cSchoolChair'
material: 383
glow: false
lore: ''
crafting:
disable: false
recipe: XXA,XAA,XOO
index:
X: 0
A: 148
O: 280

View File

@ -0,0 +1,12 @@
SchoolTable:
name: '&cSchoolTable'
material: 383
glow: false
lore: ''
crafting:
disable: false
recipe: AAA,OXO,OXO
index:
X: 0
A: 72
O: 280

View File

@ -0,0 +1,12 @@
SleepingBag:
name: '&cSleepingBag'
material: 383
glow: false
lore: ''
crafting:
disable: true
recipe: XXX,AOA,AAA
index:
X: 0
A: 35
O: 355

11
src/Crafting/TrashCan.yml Normal file
View File

@ -0,0 +1,11 @@
TrashCan:
name: '&cTrashCan'
material: 383
glow: false
lore: ''
crafting:
disable: false
recipe: XOX,XOX,OXO
index:
O: 0
X: 101

11
src/Crafting/Trunk.yml Normal file
View File

@ -0,0 +1,11 @@
Trunk:
name: '&cTrunk'
material: 383
glow: false
lore: ''
crafting:
disable: false
recipe: XXX,XXX,AAA
index:
X: 0
A: 17

View File

@ -0,0 +1,12 @@
WaterBottle:
name: '&cWaterBottle'
material: 383
glow: false
lore: ''
crafting:
disable: true
recipe: XXX,XAX,XOX
index:
X: 0
A: 373
O: 111

13
src/Crafting/flag.yml Normal file
View File

@ -0,0 +1,13 @@
Flag:
name: '&cFlag'
material: 383
glow: false
lore: ''
crafting:
disable: false
recipe: XAX,XBO,XAX
index:
X: 0
A: 44
B: 280
O: 425

View File

@ -0,0 +1,10 @@
Guillotine:
name: '&cGuillotine'
material: 383
glow: false
lore: ''
crafting:
disable: true
recipe: XXX,XXX,XXX
index:
X: 0

12
src/Crafting/log.yml Normal file
View File

@ -0,0 +1,12 @@
Log:
name: '&cLog'
material: 383
glow: false
lore: ''
crafting:
disable: false
recipe: XXX,XAX,XOX
index:
X: 0
A: 389
O: 17

1
src/damage.yml Normal file
View File

@ -0,0 +1 @@
damage: 2.0

View File

@ -15,14 +15,28 @@ import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import de.Ste3et_C0st.Furniture.Objects.RPG.Crossbow;
import de.Ste3et_C0st.Furniture.Objects.RPG.HumanSkeleton;
import de.Ste3et_C0st.Furniture.Objects.RPG.catapult;
import de.Ste3et_C0st.Furniture.Objects.RPG.flag;
import de.Ste3et_C0st.Furniture.Objects.RPG.guillotine;
import de.Ste3et_C0st.Furniture.Objects.RPG.weaponStand;
import de.Ste3et_C0st.Furniture.Objects.School.BlackBoard;
import de.Ste3et_C0st.Furniture.Objects.School.SchoolChair;
import de.Ste3et_C0st.Furniture.Objects.School.SchoolTable;
import de.Ste3et_C0st.Furniture.Objects.School.TrashCan;
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.SleepingBag;
import de.Ste3et_C0st.Furniture.Objects.garden.TFlowerPot;
import de.Ste3et_C0st.Furniture.Objects.garden.Trunk;
import de.Ste3et_C0st.Furniture.Objects.garden.WaterBottle;
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.log;
import de.Ste3et_C0st.Furniture.Objects.garden.mailBox;
import de.Ste3et_C0st.Furniture.Objects.garden.sunshade;
import de.Ste3et_C0st.Furniture.Objects.indoor.chair;
@ -30,6 +44,7 @@ import de.Ste3et_C0st.Furniture.Objects.indoor.largeTable;
import de.Ste3et_C0st.Furniture.Objects.indoor.lantern;
import de.Ste3et_C0st.Furniture.Objects.indoor.sofa;
import de.Ste3et_C0st.Furniture.Objects.indoor.table;
import de.Ste3et_C0st.Furniture.Objects.outdoor.CactusPlant;
import de.Ste3et_C0st.Furniture.Objects.outdoor.barrels;
import de.Ste3et_C0st.Furniture.Objects.outdoor.campfire_1;
import de.Ste3et_C0st.Furniture.Objects.outdoor.campfire_2;
@ -37,13 +52,15 @@ import de.Ste3et_C0st.Furniture.Objects.outdoor.hammock;
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_1;
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_2;
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_3;
import de.Ste3et_C0st.FurnitureLib.Crafting.CraftingFile;
import de.Ste3et_C0st.Furniture.Objects.trap.BearTrap;
import de.Ste3et_C0st.FurnitureLib.Crafting.Project;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureItemEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.LocationUtil;
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.CenterType;
import de.Ste3et_C0st.FurnitureLib.main.Type.PlaceableSide;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
public class main extends JavaPlugin implements Listener{
@ -52,6 +69,7 @@ public class main extends JavaPlugin implements Listener{
FurnitureManager manager;
config c;
FileConfiguration file;
public static double damage = 0;
static main instance;
static LocationUtil util;
public static List<Material> materialWhiteList = new ArrayList<Material>();
@ -64,29 +82,44 @@ public class main extends JavaPlugin implements Listener{
util = lib.getLocationUtil();
Bukkit.getPluginManager().registerEvents(this, this);
new Project("Camera", new CraftingFile("Camera", getResource("Crafting/Camera.yml")),this, camera.class);
new Project("TV", new CraftingFile("TV", getResource("Crafting/TV.yml")),this, tv.class);
new Project("GraveStone", new CraftingFile("GraveStone", getResource("Crafting/GraveStone.yml")),this, graveStone.class);
new Project("Chair", new CraftingFile("Chair", getResource("Crafting/Chair.yml")),this, chair.class);
new Project("LargeTable", new CraftingFile("LargeTable", getResource("Crafting/LargeTable.yml")),this, largeTable.class).setSize(2, 1, 2);
new Project("Lantern", new CraftingFile("Lantern", getResource("Crafting/Lantern.yml")),this, lantern.class);
new Project("Sofa", new CraftingFile("Sofa", getResource("Crafting/Sofa.yml")),this, sofa.class).setSize(0, 1, 2);
new Project("Table", new CraftingFile("Table", getResource("Crafting/Table.yml")),this, table.class);
new Project("Barrels", new CraftingFile("Barrels", getResource("Crafting/Barrels.yml")),this, barrels.class);
new Project("Campfire1", new CraftingFile("Campfire1", getResource("Crafting/Campfire1.yml")),this, campfire_1.class);
new Project("Campfire2", new CraftingFile("Campfire2", getResource("Crafting/Campfire2.yml")),this, campfire_2.class).setSize(1, 1, 1);
new Project("Tent1", new CraftingFile("Tent1", getResource("Crafting/Tent1.yml")),this, tent_1.class).setSize(3, 4, 4);
new Project("Tent2", new CraftingFile("Tent2", getResource("Crafting/Tent2.yml")),this, tent_2.class).setSize(3, 3, 5);
new Project("Tent3", new CraftingFile("Tent3", getResource("Crafting/Tent3.yml")),this, tent_3.class).setSize(1, 2, 3);
new Project("Fence", new CraftingFile("Fence", getResource("Crafting/fence.yml")), this, fance.class);
new Project("Sunshade", new CraftingFile("Sunshade", getResource("Crafting/Sunshade.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("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);
new Project("Camera", this,getResource("Crafting/Camera.yml"),PlaceableSide.TOP, camera.class);
new Project("TV", this,getResource("Crafting/TV.yml"),PlaceableSide.TOP, tv.class).setSize(1, 2, 3, CenterType.CENTER);
new Project("GraveStone", this,getResource("Crafting/GraveStone.yml"),PlaceableSide.TOP, graveStone.class).setSize(1, 2, 3, CenterType.CENTER);
new Project("Chair", this,getResource("Crafting/Chair.yml"),PlaceableSide.TOP, chair.class);
new Project("LargeTable", this,getResource("Crafting/LargeTable.yml"),PlaceableSide.TOP, largeTable.class).setSize(2, 1, 2, CenterType.RIGHT);
new Project("Lantern", this,getResource("Crafting/Lantern.yml"),PlaceableSide.TOP, lantern.class);
new Project("Sofa", this,getResource("Crafting/Sofa.yml"),PlaceableSide.TOP, sofa.class).setSize(1, 1, 3, CenterType.RIGHT);
new Project("Table", this,getResource("Crafting/Table.yml"),PlaceableSide.TOP, table.class);
new Project("Barrels", this,getResource("Crafting/Barrels.yml"),PlaceableSide.TOP, barrels.class);
new Project("Campfire1", this,getResource("Crafting/Campfire1.yml"),PlaceableSide.TOP, campfire_1.class);
new Project("Campfire2", this,getResource("Crafting/Campfire2.yml"),PlaceableSide.TOP, campfire_2.class).setSize(1, 1, 1, CenterType.RIGHT);
new Project("Tent1", this,getResource("Crafting/Tent1.yml"),PlaceableSide.TOP, tent_1.class).setSize(4, 3, 5, CenterType.RIGHT);
new Project("Tent2", this,getResource("Crafting/Tent2.yml"),PlaceableSide.TOP, tent_2.class).setSize(4, 3, 5, CenterType.RIGHT);
new Project("Tent3", this,getResource("Crafting/Tent3.yml"),PlaceableSide.TOP, tent_3.class).setSize(3, 2, 3, CenterType.CENTER);
new Project("Fence", this, getResource("Crafting/fence.yml"),PlaceableSide.TOP, fance.class);
new Project("Sunshade", this, getResource("Crafting/Sunshade.yml"),PlaceableSide.TOP, sunshade.class).setSize(1, 3, 1, CenterType.RIGHT);
new Project("Streetlamp", this, getResource("Crafting/Streetlamp.yml"),PlaceableSide.TOP, streetlamp.class).setSize(2, 4, 1, CenterType.FRONT);
new Project("Billboard", this, getResource("Crafting/Billboard.yml"),PlaceableSide.TOP, billboard.class).setSize(1, 3, 3, CenterType.RIGHT);
new Project("Mailbox", this, getResource("Crafting/Mailbox.yml"),PlaceableSide.TOP, mailBox.class).setSize(1, 2, 1, CenterType.RIGHT);
new Project("WeaponStand", this, getResource("Crafting/WeaponStand.yml"),PlaceableSide.TOP, weaponStand.class).setSize(1, 1, 1, CenterType.RIGHT);
new Project("Hammock", this, getResource("Crafting/Hammock.yml"),PlaceableSide.TOP, hammock.class).setSize(1, 2, 7, CenterType.RIGHT);
new Project("CampChair", this, getResource("Crafting/CampChair.yml"),PlaceableSide.TOP, campchair.class);
new Project("CactusPlant", this, getResource("Crafting/CactusPlant.yml"),PlaceableSide.TOP, CactusPlant.class);
new Project("Guillotine", this, getResource("Crafting/guillotine.yml"),PlaceableSide.TOP, guillotine.class).setSize(1, 5, 2, CenterType.RIGHT);
new Project("Log", this, getResource("Crafting/log.yml"), PlaceableSide.TOP, log.class);
new Project("FlowerPot", this, getResource("Crafting/FlowerPot.yml"),PlaceableSide.BOTTOM, TFlowerPot.class);
new Project("WaterBottle", this, getResource("Crafting/WaterBottle.yml"), PlaceableSide.WATER, WaterBottle.class);
new Project("SleepingBag", this, getResource("Crafting/SleepingBag.yml"), PlaceableSide.TOP, SleepingBag.class).setSize(1, 1, 2, CenterType.RIGHT);
new Project("BearTrap", this, getResource("Crafting/BearTrap.yml"), PlaceableSide.TOP, BearTrap.class);
new Project("Trunk", this, getResource("Crafting/Trunk.yml"), PlaceableSide.TOP, Trunk.class).setSize(1, 1, 4, CenterType.RIGHT);
new Project("SchoolTable", this, getResource("Crafting/SchoolTable.yml"), PlaceableSide.TOP, SchoolTable.class);
new Project("SchoolChair", this, getResource("Crafting/SchoolChair.yml"), PlaceableSide.TOP, SchoolChair.class);
new Project("BlackBoard", this, getResource("Crafting/BlackBoard.yml"), PlaceableSide.SIDE, BlackBoard.class).setSize(1, 2, 3, CenterType.RIGHT);
new Project("TrashCan", this, getResource("Crafting/TrashCan.yml"), PlaceableSide.TOP, TrashCan.class);
new Project("HumanSkeleton", this, getResource("Crafting/HumanSkeleton.yml"), PlaceableSide.TOP, HumanSkeleton.class).setSize(3, 1, 2, CenterType.RIGHT);
new Project("Crossbow", this, getResource("Crafting/Crossbow.yml"), PlaceableSide.TOP, Crossbow.class);
new Project("Catapult", this, getResource("Crafting/Catapult.yml"), PlaceableSide.TOP, catapult.class).setSize(3, 2, 3, CenterType.RIGHT);
new Project("Flag", this, getResource("Crafting/flag.yml"), PlaceableSide.TOP, flag.class);
List<ObjectID> objList = new ArrayList<ObjectID>();
for(ObjectID obj : manager.getObjectList()){
if(obj==null) continue;
@ -96,29 +129,45 @@ public class main extends JavaPlugin implements Listener{
if(obj.getSQLAction().equals(SQLAction.REMOVE)) continue;
if(obj.getPlugin().equalsIgnoreCase(this.getName())){
switch (obj.getProject()) {
case "Camera":new camera(lib, this, obj);break;
case "TV":new tv(lib, this, obj);break;
case "GraveStone":new graveStone(lib, this, obj);break;
case "Chair":new chair(lib, this, obj);break;
case "LargeTable":new largeTable(lib, this, obj);break;
case "Lantern":new lantern(lib, this, obj);break;
case "Sofa":new sofa(lib, this, obj);break;
case "Table":new table(lib, this, obj);break;
case "Barrels":new barrels(lib, this, obj);break;
case "Campfire1":new campfire_1(lib, this, obj);break;
case "Campfire2":new campfire_2(lib, this, obj);break;
case "Tent1":new tent_1(lib, this, obj);break;
case "Tent2":new tent_2(lib, this, obj);break;
case "Tent3":new tent_3(lib, this, obj);break;
case "Fence":new fance(lib, this, obj);break;
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 "Hammock": new hammock(lib, this, obj); break;
case "CampChair": new campchair(lib, this, obj); break;
case "Camera":new camera(this, obj);break;
case "TV":new tv(this, obj);break;
case "GraveStone":new graveStone(this, obj);break;
case "Chair":new chair(this, obj);break;
case "LargeTable":new largeTable(this, obj);break;
case "Lantern":new lantern(this, obj);break;
case "Sofa":new sofa(this, obj);break;
case "Table":new table(this, obj);break;
case "Barrels":new barrels(this, obj);break;
case "Campfire1":new campfire_1(this, obj);break;
case "Campfire2":new campfire_2(this, obj);break;
case "Tent1":new tent_1(this, obj);break;
case "Tent2":new tent_2(this, obj);break;
case "Tent3":new tent_3(this, obj);break;
case "Fence":new fance(this, obj);break;
case "Sunshade":new sunshade(this, obj);break;
case "Streetlamp":new streetlamp(this, obj);break;
case "Billboard": new billboard(this, obj); break;
case "WeaponStand": new weaponStand(this, obj);break;
case "Hammock": new hammock(this, obj); break;
case "CampChair": new campchair(this, obj); break;
case "CactusPlant": new CactusPlant(this, obj); break;
case "Guillotine": new guillotine(this, obj); break;
case "FlowerPot": new TFlowerPot(this, obj);break;
case "WaterBottle": new WaterBottle(this, obj); break;
case "SleepingBag": new SleepingBag(this, obj); break;
case "BearTrap": new BearTrap(this, obj); break;
case "Trunk": new Trunk(this, obj); break;
case "SchoolTable": new SchoolTable(this, obj); break;
case "SchoolChair": new SchoolChair(this, obj); break;
case "BlackBoard": new BlackBoard(this, obj); break;
case "TrashCan": new TrashCan(this, obj); break;
case "HumanSkeleton": new HumanSkeleton(this, obj);break;
case "Crossbow": new Crossbow(this, obj);break;
case "Catapult": new catapult(this, obj); break;
case "Flag": new flag(this, obj); break;
case "Log": new log(this, obj);
case "Mailbox" :
mailBox mail = new mailBox(lib, this, obj);
mailBox mail = new mailBox(lib, obj);
/*try {
mail.addMailbox(loadPlayerMailBox(obj));
} catch (Exception e) {
@ -139,8 +188,21 @@ public class main extends JavaPlugin implements Listener{
this.file.options().copyDefaults(true);
this.c.saveConfig("whiteList", this.file, "plugin/fence/");
setDefaults();
c = new config();
this.file = c.getConfig("damage", "plugin/bearTrap/");
this.file.addDefaults(YamlConfiguration.loadConfiguration(getResource("damage.yml")));
this.file.options().copyDefaults(true);
this.c.saveConfig("damage", this.file, "plugin/bearTrap/");
setDefaults_2();
}
private void setDefaults_2(){
c = new config();
this.file = c.getConfig("damage", "plugin/bearTrap/");
damage = this.file.getDouble("damage");
}
private void setDefaults(){
c = new config();
this.file = c.getConfig("whiteList", "plugin/fence/");
@ -179,28 +241,44 @@ public class main extends JavaPlugin implements Listener{
ObjectID obj = e.getObjID();
if(!e.canBuild()){return;}
switch(e.getProject().getName()){
case "Camera" : new camera(lib, instance, obj);break;
case "TV" : new tv(lib, instance, obj);break;
case "GraveStone" : new graveStone(lib, instance, obj);break;
case "Chair" : new chair(lib, instance, obj); break;
case "LargeTable" : new largeTable(lib, instance, obj);break;
case "Lantern" : new lantern(lib, instance, obj);break;
case "Sofa" : new sofa(lib, instance, obj);break;
case "Table" : new table(lib, instance, obj);break;
case "Barrels" : new barrels(lib, instance, obj);break;
case "Campfire1" : new campfire_1(lib, instance, obj);break;
case "Campfire2" : new campfire_2(lib, instance, obj);break;
case "Tent1" : new tent_1(lib, instance, obj);break;
case "Tent2" : new tent_2(lib, instance, obj);break;
case "Tent3" : new tent_3(lib, instance, obj);break;
case "Fence" : new fance(lib, instance, obj);break;
case "Sunshade": new sunshade(lib, instance, obj);break;
case "Streetlamp": new streetlamp(lib, this, obj);break;
case "Billboard": new billboard(lib, instance, obj);break;
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;
case "Camera" : new camera(this, obj);break;
case "TV" : new tv(this, obj);break;
case "GraveStone" : new graveStone(this, obj);break;
case "Chair" : new chair(this, obj); break;
case "LargeTable" : new largeTable(this, obj);break;
case "Lantern" : new lantern(this, obj);break;
case "Sofa" : new sofa(this, obj);break;
case "Table" : new table(this, obj);break;
case "Barrels" : new barrels(this, obj);break;
case "Campfire1" : new campfire_1(this, obj);break;
case "Campfire2" : new campfire_2(this, obj);break;
case "Tent1" : new tent_1(this, obj);break;
case "Tent2" : new tent_2(this, obj);break;
case "Tent3" : new tent_3(this, obj);break;
case "Fence" : new fance(this, obj);break;
case "Sunshade": new sunshade(this, obj);break;
case "Streetlamp": new streetlamp(this, obj);break;
case "Billboard": new billboard(this, obj);break;
case "Mailbox" : new mailBox(this, obj); break;
case "WeaponStand": new weaponStand(this, obj); break;
case "Hammock": new hammock(this, obj); break;
case "CampChair": new campchair(this, obj); break;
case "CactusPlant": new CactusPlant(this, obj); break;
case "Guillotine": new guillotine(this, obj); break;
case "FlowerPot":new TFlowerPot(this, obj);break;
case "Log": new log(this, obj); break;
case "WaterBottle": new WaterBottle(this,obj);break;
case "SleepingBag": new SleepingBag(this, obj); break;
case "BearTrap": new BearTrap(this, obj); break;
case "Trunk": new Trunk(this, obj); break;
case "SchoolTable": new SchoolTable(this, obj); break;
case "SchoolChair": new SchoolChair(this, obj); break;
case "BlackBoard": new BlackBoard(this, obj); break;
case "TrashCan": new TrashCan(this, obj); break;
case "HumanSkeleton": new HumanSkeleton(this, obj);break;
case "Crossbow": new Crossbow(this, obj);break;
case "Catapult": new catapult(this, obj); break;
case "Flag": new flag(this, obj); break;
}
e.finish();
e.removeItem();

View File

@ -0,0 +1,254 @@
package de.Ste3et_C0st.Furniture.Objects.RPG;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
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 org.bukkit.util.Vector;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBlockBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBlockClickEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class Crossbow extends Furniture implements Listener {
public Crossbow(Plugin plugin, ObjectID id){
super(plugin, id);
setBlock();
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
spawn(id.getStartLocation());
}
private void setBlock(){
Block b = getLocation().getBlock();
if(b.getType()==null||!b.getType().equals(Material.STEP)){
b.setType(Material.STEP);
}
getObjID().addBlock(Arrays.asList(b));
}
@Override
public void spawn(Location paramLocation) {
List<fArmorStand> asList = new ArrayList<fArmorStand>();
float yaw = 90;
for(int i = 0; i<4;i++){
Location loc = getLutil().getRelativ(getCenter().add(0, -1.7, 0), getLutil().yawToFace(yaw), .34, .4);
loc.setYaw(yaw+45);
fArmorStand stand = spawnArmorStand(loc);
stand.setItemInHand(new ItemStack(Material.STICK));
stand.setMarker(false);
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(90,270,135)));
asList.add(stand);
yaw+=90;
}
fArmorStand stand = spawnArmorStand(getCenter().add(0, -0.7, 0));
stand.setHelmet(new ItemStack(Material.LOG));
stand.setSmall(true);
asList.add(stand);
Location loc = getRelative(getCenter().add(0, -.74, 0), getBlockFace(), -.6, .48);
loc.setYaw(getYaw()-90);
stand = spawnArmorStand(loc);
stand.setItemInHand(new ItemStack(Material.STICK));
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(80,0,90)));
stand.setMarker(false);
asList.add(stand);
loc = getRelative(getCenter().add(0, -.62, 0),getBlockFace(), -.4,.07);
loc.setYaw(getYaw()-90);
stand = spawnArmorStand(loc);
stand.setItemInHand(new ItemStack(Material.BOW));
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(0,10,90)));
stand.setMarker(false);
asList.add(stand);
loc = getRelative(getCenter().add(0, -.08, 0), getBlockFace(), -.1, .25);
loc.setYaw(getYaw()-90);
stand = spawnArmorStand(loc);
stand.setName("#ARROW#");
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(0,135,0)));
stand.setMarker(false);
asList.add(stand);
for(fArmorStand asp : asList){
asp.setGravity(false);
asp.setInvisible(true);
asp.setBasePlate(false);
}
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()) return;
if(!e.getID().equals(getObjID())) return;
if(!e.canBuild()){return;}
e.remove();
delete();
}
@EventHandler
public void onFurnitureBreak(FurnitureBlockBreakEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()) return;
if(!e.getID().equals(getObjID())) return;
if(!e.canBuild()){return;}
e.remove();
delete();
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()) return;
if(!e.getID().equals(getObjID())) return;
if(!e.canBuild()){return;}
fArmorStand stand = getArmorStand();
if(stand==null){return;}
ItemStack is = e.getPlayer().getItemInHand();
if(!hasArrow()||(is!=null&&is.getType()!=null&&is.getType().equals(Material.ARROW))){
if(e.getPlayer().getItemInHand()==null){return;}
if(e.getPlayer().getItemInHand().getType()==null){return;}
if(!e.getPlayer().getItemInHand().getType().equals(Material.ARROW)){return;}
addArmor(is, stand);
}else{
spawnArrow();
removeArrow(stand);
}
}
@EventHandler
public void onFurnitureClick(FurnitureBlockClickEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()) return;
if(!e.getID().equals(getObjID())) return;
if(!e.canBuild()){return;}
fArmorStand stand = getArmorStand();
if(stand==null){return;}
ItemStack is = e.getPlayer().getItemInHand();
if(!hasArrow()||(is!=null&&is.getType()!=null&&is.getType().equals(Material.ARROW))){
if(e.getPlayer().getItemInHand()==null){return;}
if(e.getPlayer().getItemInHand().getType()==null){return;}
if(!e.getPlayer().getItemInHand().getType().equals(Material.ARROW)){return;}
addArmor(is, stand);
}else{
spawnArrow();
removeArrow(stand);
}
}
private void spawnArrow(){
Location loc = getRelative(getCenter(), getBlockFace(), 0,18);
loc.setYaw(getYaw());
Vector v=null;
switch (getBlockFace()) {
case NORTH:v= new Vector(0, 0.5, 1.2);break;
case SOUTH:v= new Vector(0, 0.5, -1.2);break;
case EAST: v= new Vector(-1.2, 0.5, 0);break;
case WEST: v= new Vector(1.2, 0.5, 0);break;
default:break;
}
getWorld().playSound(getLocation(), Sound.SHOOT_ARROW, 1, 1);
Location start = getRelative(getCenter(), getBlockFace(), 0,0);
start.setYaw(getYaw());
start = start.add(0, 1.8, 0);
Arrow a = getWorld().spawnArrow(start, v.multiply(2), 2F, 3F);
a.setCritical(true);
}
public static Set<Entity> getEntitiesInChunks(Location l, int chunkRadius) {
Block b = l.getBlock();
Set<Entity> entities = new HashSet<Entity>();
for (int x = -16 * chunkRadius; x <= 16 * chunkRadius; x += 16) {
for (int z = -16 * chunkRadius; z <= 16 * chunkRadius; z += 16) {
for (Entity e : b.getRelative(x, 0, z).getChunk().getEntities()) {
entities.add(e);
}
}
}
return entities;
}
private void removeArrow(fArmorStand stand){
ItemStack is = stand.getItemInHand();
if(is.getAmount()-1<=0){
stand.setItemInHand(new ItemStack(Material.AIR));
update();
return;
}
is.setAmount(is.getAmount()-1);
stand.setItemInHand(is);
update();
}
private void addArmor(ItemStack is, fArmorStand stand){
if(getArrow()!=null){is.setAmount(getArrow().getAmount());}
stand.setItemInHand(is);
update();
}
private fArmorStand getArmorStand(){
for(fArmorStand stand : getfAsList()){
if(stand.getName().equalsIgnoreCase("#ARROW#")){
return stand;
}
}
return null;
}
private ItemStack getArrow(){
for(fArmorStand stand : getfAsList()){
if(stand.getName().equalsIgnoreCase("#ARROW#")){
if(!(stand.getItemInHand()==null||stand.getItemInHand().getType()==null||stand.getItemInHand().getType().equals(Material.AIR))){
return stand.getItemInHand();
}
}
}
return null;
}
private boolean hasArrow(){
for(fArmorStand stand : getfAsList()){
if(stand.getName().equalsIgnoreCase("#ARROW#")){
if(stand.getItemInHand()==null||stand.getItemInHand().getType()==null||stand.getItemInHand().getType().equals(Material.AIR)){
return false;
}else{
return true;
}
}
}
return false;
}
}

View File

@ -0,0 +1,96 @@
package de.Ste3et_C0st.Furniture.Objects.RPG;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
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.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class HumanSkeleton extends Furniture implements Listener {
public HumanSkeleton(Plugin plugin, ObjectID id) {
super(plugin, id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
spawn(id.getStartLocation());
}
@Override
public void spawn(Location paramLocation) {
List<fArmorStand> asList = new ArrayList<fArmorStand>();
fArmorStand stand = spawnArmorStand(getRelative(getLocation().add(0, -1.4, 0), -.25, 0));
stand.setItemInHand(new ItemStack(Material.BONE));
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(-40,0,90)));
asList.add(stand);
stand = spawnArmorStand(getRelative(getLocation().add(0, -1.4, 0), .2, 1.2));
stand.setItemInHand(new ItemStack(Material.BONE));
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(40,0,90)));
asList.add(stand);
stand = spawnArmorStand(getRelative(getLocation().add(0, -1.4, 0), .3, .75));
stand.setItemInHand(new ItemStack(Material.BONE));
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(0,0,90)));
asList.add(stand);
stand = spawnArmorStand(getRelative(getLocation().add(0, -1.4, 0), .9, .42));
stand.setItemInHand(new ItemStack(Material.BONE));
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(-30,0,90)));
asList.add(stand);
stand = spawnArmorStand(getRelative(getLocation().add(0, -1.4, 0), 1.1, -.6));
stand.setItemInHand(new ItemStack(Material.BONE));
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(-80,0,90)));
asList.add(stand);
stand = spawnArmorStand(getRelative(getLocation().add(0, -1.4, 0), 1.6, 1.3));
stand.setItemInHand(new ItemStack(Material.BONE));
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(30,0,90)));
asList.add(stand);
Location loc = getRelative(getLocation().add(0, -1.4, 0), getBlockFace(), 2.0, -.1);
loc.setYaw(getYaw()+180);
stand = spawnArmorStand(loc);
stand.setHelmet(new ItemStack(Material.SKULL_ITEM));
stand.setHeadPose(getLutil().degresstoRad(new EulerAngle(-90,13,-5)));
asList.add(stand);
for(fArmorStand asp : asList){
asp.setGravity(false);
asp.setInvisible(true);
asp.setBasePlate(false);
}
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
delete();
e.remove();
}
@Override
public void onFurnitureClick(FurnitureClickEvent paramFurnitureClickEvent) {}
}

View File

@ -0,0 +1,196 @@
package de.Ste3et_C0st.Furniture.Objects.RPG;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.EntityEffect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.TNTPrimed;
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 org.bukkit.util.Vector;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class catapult extends Furniture implements Listener {
public catapult(Plugin plugin, ObjectID id) {
super(plugin, id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
spawn(id.getStartLocation());
}
@Override
public void spawn(Location paramLocation) {
List<fArmorStand> asList = new ArrayList<fArmorStand>();
double d = .05;
for(int i =0;i<5;i++){
Location loc = getRelative(getCenter(), -.5+i*.61, -.26-d).add(0, -1.8, 0);
fArmorStand stand = spawnArmorStand(loc);
stand.setHelmet(new ItemStack(Material.LOG));
stand.setHeadPose(getLutil().degresstoRad(new EulerAngle(90, 0, 0)));
asList.add(stand);
}
for(int i =0;i<5;i++){
Location loc = getRelative(getCenter(), -.5+i*.61, -2+.28+d).add(0, -1.8, 0);
fArmorStand stand = spawnArmorStand(loc);
stand.setHelmet(new ItemStack(Material.LOG));
stand.setHeadPose(getLutil().degresstoRad(new EulerAngle(90, 0, 0)));
asList.add(stand);
}
for(int i =0;i<4;i++){
Location loc = getRelative(getCenter(), .9 , -.26-d).add(0, -.9+i*.44, 0);
fArmorStand stand = spawnArmorStand(loc);
stand.setHelmet(new ItemStack(Material.LOG));
stand.setSmall(true);
asList.add(stand);
}
for(int i =0;i<4;i++){
Location loc = getRelative(getCenter(), .9 , -2+.28+d).add(0, -.9+i*.44, 0);
fArmorStand stand = spawnArmorStand(loc);
stand.setHelmet(new ItemStack(Material.LOG));
stand.setSmall(true);
asList.add(stand);
}
Location loc = getRelative(getCenter(), getBlockFace(), .15, -.2).add(0, -1.6, 0);
fArmorStand stand = spawnArmorStand(loc);
stand.setItemInHand(new ItemStack(Material.STICK));
stand.setMarker(false);
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(80,0,90)));
asList.add(stand);
loc = getRelative(getCenter(), getBlockFace(), 2.8-.12, -.2).add(0, -1.6, 0);
stand = spawnArmorStand(loc);
stand.setItemInHand(new ItemStack(Material.STICK));
stand.setMarker(false);
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(80,0,90)));
asList.add(stand);
loc = getRelative(getCenter(), getBlockFace(), 1.5-.12, -.2).add(0, -1.6, 0);
stand = spawnArmorStand(loc);
stand.setItemInHand(new ItemStack(Material.STICK));
stand.setMarker(false);
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(80,0,90)));
asList.add(stand);
loc = getRelative(getCenter(), getBlockFace(), 1.5-.12, -.2).add(0, 0, 0);
stand = spawnArmorStand(loc);
stand.setItemInHand(new ItemStack(Material.STICK));
stand.setMarker(false);
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(80,0,90)));
asList.add(stand);
loc = getRelative(getCenter(), getBlockFace(), 1.5-.3, -1.4).add(0, -1.1, 0);
loc.setYaw(getYaw()+180);
stand = spawnArmorStand(loc);
stand.setItemInHand(new ItemStack(Material.STICK));
stand.setMarker(false);
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(335,0,0)));
asList.add(stand);
loc = getRelative(getCenter(), getBlockFace(), .4, -1.4).add(0, -.9, 0);
loc.setYaw(getYaw()+180);
stand = spawnArmorStand(loc);
stand.setItemInHand(new ItemStack(Material.STICK));
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(335,0,0)));
stand.setMarker(false);
asList.add(stand);
loc = getRelative(getCenter(), getBlockFace(), -.8, -1.03).add(0, -1.2, 0);
loc.setYaw(getYaw());
stand = spawnArmorStand(loc);
stand.setHelmet(new ItemStack(Material.STEP));
stand.setHeadPose(getLutil().degresstoRad(new EulerAngle(15,0,0)));
asList.add(stand);
for(fArmorStand asp : asList){
asp.setGravity(false);
asp.setInvisible(true);
}
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()) return;
if(!e.getID().equals(getObjID())) return;
if(!e.canBuild()){return;}
e.remove();
delete();
}
@SuppressWarnings("deprecation")
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()) return;
if(!e.getID().equals(getObjID())) return;
if(!e.canBuild()){return;}
if(e.getPlayer().getItemInHand()==null){return;}
if(e.getPlayer().getItemInHand().getType()==null){return;}
if(!e.getPlayer().getItemInHand().getType().isBlock()){return;}
Location loc = getRelative(getCenter(), getBlockFace(), -.8, -1.03).add(0, -.2, 0);
loc.setYaw(getYaw());
ItemStack stack = e.getPlayer().getItemInHand();
if(stack.getType().equals(Material.TNT)){
TNTPrimed tnt = (TNTPrimed) getWorld().spawnEntity(loc, EntityType.PRIMED_TNT);
Vector v=null;
switch (getBlockFace()) {
case NORTH:v= new Vector(0, 0.5, 1.2);break;
case SOUTH:v= new Vector(0, 0.5, -1.2);break;
case EAST: v= new Vector(-1.2, 0.5, 0);break;
case WEST: v= new Vector(1.2, 0.5, 0);break;
default:break;
}
tnt.playEffect(EntityEffect.WITCH_MAGIC);
tnt.setVelocity(v.multiply(1));
}else{
FallingBlock block = getWorld().spawnFallingBlock(loc, stack.getType().getId(), (byte) stack.getDurability());
Vector v=null;
switch (getBlockFace()) {
case NORTH:v= new Vector(0, 0.5, 1.2);break;
case SOUTH:v= new Vector(0, 0.5, -1.2);break;
case EAST: v= new Vector(-1.2, 0.5, 0);break;
case WEST: v= new Vector(1.2, 0.5, 0);break;
default:break;
}
block.playEffect(EntityEffect.WITCH_MAGIC);
block.setDropItem(false);
//block.setHurtEntities(true);
block.setVelocity(v.multiply(1));
}
if(e.getPlayer().getGameMode().equals(GameMode.CREATIVE) && getLib().useGamemode()) return;
Integer i = e.getPlayer().getInventory().getHeldItemSlot();
ItemStack is = e.getPlayer().getItemInHand();
is.setAmount(is.getAmount()-1);
e.getPlayer().getInventory().setItem(i, is);
e.getPlayer().updateInventory();
}
}

View File

@ -0,0 +1,209 @@
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.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
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.FurnitureLib.Events.FurnitureBlockBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBlockClickEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class flag extends Furniture implements Listener {
public flag(Plugin plugin, ObjectID id){
super(plugin, id);
setBlock();
if(isFinish()){
setState(3, getStand());
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
spawn(id.getStartLocation());
}
private void setBlock(){
Block b = getLocation().getBlock();
if(b.getType()==null||!b.getType().equals(Material.STEP)){
b.setType(Material.STEP);
}
getObjID().addBlock(Arrays.asList(b));
}
@Override
public void spawn(Location location) {
List<fArmorStand> asList = new ArrayList<fArmorStand>();
Location center = getLutil().getCenter(location).clone();
center.add(0, -0.45, 0);
for(int i = 0; i<=2;i++){
Location loc = getLutil().getRelativ(center.clone(), getBlockFace(), .47, .38).add(0, .88*i, 0);
loc.setYaw(getYaw());
fArmorStand packet = spawnArmorStand(loc);
packet.getInventory().setItemInHand(new ItemStack(Material.STICK));
packet.setPose(new EulerAngle(1.39, 0, 0), BodyPart.RIGHT_ARM);
asList.add(packet);
}
fArmorStand as = spawnArmorStand(getCenter().add(0, 1.9, 0));
as.setHelmet(new ItemStack(Material.STEP));
as.setSmall(true);
asList.add(as);
Location loc = getRelative(getCenter().add(0, 0.7, 0), getBlockFace(), -.35,-.28);
loc.setYaw(getYaw()+90);
as = spawnArmorStand(loc);
as.setHelmet(new ItemStack(Material.BANNER));
as.setHeadPose(getLutil().degresstoRad(new EulerAngle(0, 0, 90)));
as.setName("#FLAG:3");
asList.add(as);
for(fArmorStand packet : asList){
packet.setInvisible(true);
packet.setGravity(false);
packet.setBasePlate(false);
}
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
public int getState(){
for(fArmorStand stand : getfAsList()){
if(stand.getName().startsWith("#FLAG")){
return Integer.parseInt(stand.getName().split(":")[1]);
}
}
return 1;
}
public fArmorStand getStand(){
for(fArmorStand stand : getfAsList()){
if(stand.getName().startsWith("#FLAG")){
return stand;
}
}
return null;
}
public void setState(int i, fArmorStand stand){
if(i<1||i>3){return;}
if(stand==null){return;}
switch (i) {
case 3:
Location loc = getRelative(getCenter().add(0, 0.7, 0), getBlockFace(), -.35,-.28);
loc.setYaw(getYaw()+90);
stand.teleport(loc);
stand.setName("#FLAG:" + i);
break;
case 2:
loc = getRelative(getCenter().add(0, -.2, 0), getBlockFace(), -.35,-.28);
loc.setYaw(getYaw()+90);
stand.teleport(loc);
stand.setName("#FLAG:" + i);
break;
case 1:
loc = getRelative(getCenter().add(0, -.9, 0), getBlockFace(), -.35,-.28);
loc.setYaw(getYaw()+90);
stand.teleport(loc);
stand.setName("#FLAG:" + i);
break;
}
update();
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
delete();
e.remove();
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
if(e.getPlayer().getItemInHand()!=null&&e.getPlayer().getItemInHand().getType()!=null){
if(e.getPlayer().getItemInHand().getType().equals(Material.BANNER)){
getStand().setHelmet(e.getPlayer().getItemInHand());update();
if(e.getPlayer().getGameMode().equals(GameMode.CREATIVE) && getLib().useGamemode()) return;
Integer i = e.getPlayer().getInventory().getHeldItemSlot();
ItemStack is = e.getPlayer().getItemInHand();
is.setAmount(is.getAmount()-1);
e.getPlayer().getInventory().setItem(i, is);
e.getPlayer().updateInventory();
return;
}
}
int state = getState();
switch (state) {
case 3:state=2;break;
case 2:state=1;break;
case 1:state=3;break;
}
setState(state, getStand());
}
@EventHandler
public void onFurnitureBreak(FurnitureBlockBreakEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
delete();
e.remove();
}
@EventHandler
public void onFurnitureClick(FurnitureBlockClickEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
if(e.getPlayer().getItemInHand()!=null&&e.getPlayer().getItemInHand().getType()!=null){
if(e.getPlayer().getItemInHand().getType().equals(Material.BANNER)){
getStand().setHelmet(e.getPlayer().getItemInHand());update();
if(e.getPlayer().getGameMode().equals(GameMode.CREATIVE) && getLib().useGamemode()) return;
Integer i = e.getPlayer().getInventory().getHeldItemSlot();
ItemStack is = e.getPlayer().getItemInHand();
is.setAmount(is.getAmount()-1);
e.getPlayer().getInventory().setItem(i, is);
e.getPlayer().updateInventory();
return;
}
}
int state = getState();
switch (state) {
case 3:state=2;break;
case 2:state=1;break;
case 1:state=3;break;
}
setState(state, getStand());
}
}

View File

@ -0,0 +1,642 @@
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.ChatColor;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
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.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
import de.Ste3et_C0st.FurnitureLib.main.Type.EventType;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class guillotine extends Furniture implements Listener{
Boolean soundPlaying = false, isFinish = false;
fArmorStand packet1, packet2, packet3;
Inventory invI, invII, invIII;
Integer timer;
Player p;
List<Integer> intList = Arrays.asList(10,16,19,28,37,43);
List<Material> matList = Arrays.asList(
Material.WOOD_SWORD,Material.WOOD_AXE,Material.WOOD_HOE,
Material.STONE_SWORD, Material.STONE_AXE, Material.STONE_HOE,
Material.IRON_SWORD, Material.IRON_AXE, Material.IRON_HOE,
Material.GOLD_SWORD, Material.GOLD_AXE, Material.GOLD_HOE,
Material.DIAMOND_SWORD, Material.DIAMOND_AXE, Material.DIAMOND_HOE);
List<Material> matListI = Arrays.asList(
Material.LEATHER_CHESTPLATE,Material.IRON_CHESTPLATE,Material.GOLD_CHESTPLATE,
Material.DIAMOND_CHESTPLATE, Material.CHAINMAIL_CHESTPLATE);
List<Material> matListII = Arrays.asList(
Material.LEATHER_LEGGINGS,Material.IRON_LEGGINGS,Material.GOLD_LEGGINGS,
Material.DIAMOND_LEGGINGS, Material.CHAINMAIL_LEGGINGS);
List<Material> matListIII = Arrays.asList(
Material.LEATHER_BOOTS,Material.IRON_BOOTS,Material.GOLD_BOOTS,
Material.DIAMOND_BOOTS, Material.CHAINMAIL_BOOTS);
List<fArmorStand> armorStandList = new ArrayList<fArmorStand>();
ItemStack pane = new ItemStack(Material.STAINED_GLASS_PANE);
public guillotine(Plugin plugin, ObjectID id) {
super(plugin, id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
setDefault();
initializeInventory();
return;
}
spawn(id.getStartLocation());
initializeInventory();
}
private void initializeInventory(){
pane = new ItemStack(Material.STAINED_GLASS_PANE);
pane.setDurability((short) 15);
ItemMeta im = pane.getItemMeta();
im.setDisplayName("§c");
pane.setItemMeta(im);
String s = getObjID().getProjectOBJ().getCraftingFile().getRecipe().getResult().getItemMeta().getDisplayName();
invI = Bukkit.createInventory(null, 9, s + "I");
invII = Bukkit.createInventory(null, 54, s + "II");
invIII = Bukkit.createInventory(null, 54, s + "III");
}
private void setDefault(){
armorStandList.clear();
for(fArmorStand packets : getManager().getfArmorStandByObjectID(getObjID())){
if(!packets.getName().equalsIgnoreCase("")){
if(packets.getName().startsWith("#Oblation#")){
packet2 = packets;
}else if(packets.getName().equalsIgnoreCase("#Head#")){
packet3 = packets;
if(packet3.getHelmet()!=null&&packet3.getHelmet().getType().equals(Material.SKULL_ITEM)){
packet2.getInventory().setHelmet(packet3.getHelmet());
packet3.getInventory().setHelmet(new ItemStack(Material.AIR));
}
}else if(packets.getName().startsWith("iron")){
armorStandList.add(packets);
Location loc = getStartLocation(packets.getName());
packets.teleport(loc);
}else{
packet1 = packets;
}
}
}
soundPlaying = false;
packet1.setPose(getLutil().degresstoRad(new EulerAngle(190,0,329)), BodyPart.RIGHT_ARM);
packet1.setLeftArmPose(BodyPart.LEFT_ARM.getDefAngle());
Location loc13 = getStartLocation(packet2.getName());
packet2.teleport(loc13);
packet2.setPose(getLutil().degresstoRad(new EulerAngle(40,0,320)), BodyPart.RIGHT_ARM);
packet2.setPose(getLutil().degresstoRad(new EulerAngle(33,0,41)), BodyPart.LEFT_ARM);
packet2.setPose(getLutil().degresstoRad(new EulerAngle(40,25,0)), BodyPart.HEAD);
timer = Bukkit.getScheduler().scheduleSyncRepeatingTask(getPlugin(), new Runnable() {
int x = 0;
@Override
public void run() {
if(x!=3){
update();
x++;
}else{
stopTimer();
}
}
}, 0, 10);
isFinish=false;
}
private Location getStartLocation(String s){
String[] split = s.split(":");
double x = Double.parseDouble(split[1]);
double y = Double.parseDouble(split[2]);
double z = Double.parseDouble(split[3]);
Location loc = new Location(getWorld(), x, y, z);
loc.setYaw(getLutil().FaceToYaw(getBlockFace()));
return loc;
}
@Override
public void spawn(Location loc) {
List<fArmorStand> packList = new ArrayList<fArmorStand>();
Location center = getLutil().getCenter(loc);
center.add(0, -2.3, 0);
for(int i = 1;i<=7;i++){
Location location = getLutil().getRelativ(center, getBlockFace(), 0d, .2d).add(0, i*.62, 0);
location.setYaw(getLutil().FaceToYaw(getBlockFace())+90);
fArmorStand packet = getManager().createArmorStand(getObjID(), location);
packet.getInventory().setHelmet(new ItemStack(Material.WOOD_STEP));
packet.setPose(getLutil().degresstoRad(new EulerAngle(90, 0, 0)), BodyPart.HEAD);
packList.add(packet);
location = getLutil().getRelativ(center, getBlockFace(), 0d, -1.2d).add(0, i*.62, 0);
location.setYaw(getLutil().FaceToYaw(getBlockFace())-90);
packet = getManager().createArmorStand(getObjID(), location);
packet.getInventory().setHelmet(new ItemStack(Material.WOOD_STEP));
packet.setPose(getLutil().degresstoRad(new EulerAngle(90, 0, 0)), BodyPart.HEAD);
packList.add(packet);
}
double j = .44;
Location loc1 = getLutil().getRelativ(center.clone(), getBlockFace(), 0d, -.32d).add(0, .9+j, 0);
Location loc2 = getLutil().getRelativ(center.clone(), getBlockFace(), 0d, -.65d).add(0, .9+j, 0);
Location loc3 = getLutil().getRelativ(center.clone(), getBlockFace(), 0d, -.32d).add(0, 1.53+j, 0);
Location loc4 = getLutil().getRelativ(center.clone(), getBlockFace(), 0d, -.65d).add(0, 1.53+j, 0);
Location loc5 = getLutil().getRelativ(center.clone(), getBlockFace(), 0d, -.22d).add(0, 4.2, 0);
Location loc6 = getLutil().getRelativ(center.clone(), getBlockFace(), 0d, -.75d).add(0, 4.2, 0);
Location loc7 = getLutil().getRelativ(center.clone(), getBlockFace(), -.43d, 0d).add(0, 4.5, 0);
Location loc8 = getLutil().getRelativ(center.clone(), getBlockFace(), -.32d, -.22d).add(0, 3.6, 0);
Location loc9 = getLutil().getRelativ(center.clone(), getBlockFace(), -.32d, -.75d).add(0, 3.6, 0);
Location loc10 = getLutil().getRelativ(center.clone(), getBlockFace(), -.32d, -.33d).add(0, 3.5, 0);
Location loc11 = getLutil().getRelativ(center.clone(), getBlockFace(), -.32d, -.82d).add(0, 3.3, 0);
loc1.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()));
loc2.setYaw(getLutil().FaceToYaw(getBlockFace()));
loc3.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()));
loc4.setYaw(getLutil().FaceToYaw(getBlockFace()));
loc5.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()));
loc6.setYaw(getLutil().FaceToYaw(getBlockFace()));
loc7.setYaw(getLutil().FaceToYaw(getBlockFace())-90);
loc8.setYaw(getLutil().FaceToYaw(getBlockFace()));
loc9.setYaw(getLutil().FaceToYaw(getBlockFace()));
loc10.setYaw(getLutil().FaceToYaw(getBlockFace()));
loc11.setYaw(getLutil().FaceToYaw(getBlockFace()));
fArmorStand packet = getManager().createArmorStand(getObjID(), loc1);
packet.getInventory().setHelmet(new ItemStack(Material.WOOD_STAIRS));
packList.add(packet);
packet = getManager().createArmorStand(getObjID(), loc2);
packet.getInventory().setHelmet(new ItemStack(Material.WOOD_STAIRS));
packList.add(packet);
packet = getManager().createArmorStand(getObjID(), loc3);
packet.getInventory().setHelmet(new ItemStack(Material.WOOD_STEP));
packList.add(packet);
packet = getManager().createArmorStand(getObjID(), loc4);
packet.getInventory().setHelmet(new ItemStack(Material.WOOD_STEP));
packList.add(packet);
packet = getManager().createArmorStand(getObjID(), loc5);
packet.getInventory().setHelmet(new ItemStack(Material.STONE_PLATE));
packList.add(packet);
packet = getManager().createArmorStand(getObjID(), loc6);
packet.getInventory().setHelmet(new ItemStack(Material.STONE_PLATE));
packList.add(packet);
packet = getManager().createArmorStand(getObjID(), loc7);
packet.getInventory().setItemInHand(new ItemStack(Material.STICK));
packet.setPose(new EulerAngle(1.39, 0, 0), BodyPart.RIGHT_ARM);
packList.add(packet);
packet = getManager().createArmorStand(getObjID(), loc8);
packet.getInventory().setHelmet(new ItemStack(Material.IRON_PLATE));
packet.setPose(getLutil().degresstoRad(new EulerAngle(90, 0, 0)), BodyPart.HEAD);
packet.setName("iron1:" + loc8.getX() + ":" + loc8.getY() + ":" + loc8.getZ());
packList.add(packet);
armorStandList.add(packet);
packet = getManager().createArmorStand(getObjID(), loc9);
packet.getInventory().setHelmet(new ItemStack(Material.IRON_PLATE));
packet.setPose(getLutil().degresstoRad(new EulerAngle(90, 0, 0)), BodyPart.HEAD);
packet.setName("iron2:" + loc9.getX() + ":" + loc9.getY() + ":" + loc9.getZ());
packList.add(packet);
armorStandList.add(packet);
packet = getManager().createArmorStand(getObjID(), loc10);
packet.getInventory().setHelmet(new ItemStack(Material.IRON_PLATE));
packet.setPose(getLutil().degresstoRad(new EulerAngle(90, 0, -22)), BodyPart.HEAD);
packet.setName("iron3:" + loc10.getX() + ":" + loc10.getY() + ":" + loc10.getZ());
packList.add(packet);
armorStandList.add(packet);
packet = getManager().createArmorStand(getObjID(), loc11);
packet.getInventory().setHelmet(new ItemStack(Material.IRON_PLATE));
packet.setPose(getLutil().degresstoRad(new EulerAngle(90, 0, -22)), BodyPart.HEAD);
packet.setName("iron4:" + loc11.getX() + ":" + loc11.getY() + ":" + loc11.getZ());
packList.add(packet);
armorStandList.add(packet);
Location loc12 = getLutil().getRelativ(center, getBlockFace(), -.9d, .5d).add(0, 1.7, 0);
loc12.setYaw(getLutil().FaceToYaw(getBlockFace())+135);
packet1 = getManager().createArmorStand(getObjID(), loc12);
packet1.setPose(getLutil().degresstoRad(new EulerAngle(190,0,329)), BodyPart.RIGHT_ARM);
packet1.setName("#Executioner#");
packet1.setArms(true);
packet1.setMarker(false);
packet1.setBasePlate(false);
packList.add(packet1);
Location loc13 = getLutil().getRelativ(center, getBlockFace(), -1d, -.5d).add(0, 1.7, 0);
loc13.setYaw(getLutil().FaceToYaw(getBlockFace()));
packet2 = getManager().createArmorStand(getObjID(), loc13);
packet2.setPose(getLutil().degresstoRad(new EulerAngle(40,0,320)), BodyPart.RIGHT_ARM);
packet2.setPose(getLutil().degresstoRad(new EulerAngle(33,0,41)), BodyPart.LEFT_ARM);
packet2.setPose(getLutil().degresstoRad(new EulerAngle(40,25,0)), BodyPart.HEAD);
packet2.setName("#Oblation#:" + loc13.getX() + ":" + loc13.getY() + ":" + loc13.getZ());
packet2.setArms(true);
packet2.setMarker(false);
packet2.setBasePlate(false);
packList.add(packet2);
Location loc14 = getLutil().getRelativ(center, getBlockFace(), 1d, -1d).add(0, +.3, 0);
loc14.setYaw(getLutil().FaceToYaw(getBlockFace())+45);
packet3 = getManager().createArmorStand(getObjID(), loc14);
packet3.setMarker(false);
packet3.setName("#HEAD#");
packList.add(packet3);
for(fArmorStand packets : packList){
packets.setGravity(false);
packets.setInvisible(true);
packets.setBasePlate(false);
}
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
private boolean canDrop(ItemStack stack){
if(stack==null){return false;}
if(stack.getType().equals(Material.AIR)){return false;}
return true;
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
if(!isRunning()){
if(canDrop(packet1.getHelmet())){getWorld().dropItem(getLocation(), packet1.getHelmet());}
if(canDrop(packet1.getChestPlate())){getWorld().dropItem(getLocation(), packet1.getChestPlate());}
if(canDrop(packet1.getLeggings())){getWorld().dropItem(getLocation(), packet1.getLeggings());}
if(canDrop(packet1.getBoots())){getWorld().dropItem(getLocation(), packet1.getBoots());}
if(canDrop(packet1.getItemInHand())){getWorld().dropItem(getLocation(), packet1.getItemInHand());}
if(canDrop(packet2.getHelmet())){getWorld().dropItem(getLocation(), packet2.getHelmet());}
if(canDrop(packet2.getChestPlate())){getWorld().dropItem(getLocation(), packet2.getChestPlate());}
if(canDrop(packet2.getLeggings())){getWorld().dropItem(getLocation(), packet2.getLeggings());}
if(canDrop(packet2.getBoots())){getWorld().dropItem(getLocation(), packet2.getBoots());}
if(canDrop(packet3.getHelmet())){getWorld().dropItem(getLocation(), packet3.getHelmet());}
if(!packet1.getName().equalsIgnoreCase("#Executioner#")){
ItemStack is = new ItemStack(Material.NAME_TAG);
ItemMeta im = is.getItemMeta();
im.setDisplayName(packet1.getName());
getWorld().dropItem(getLocation(), is);
}
this.getObjID().remove(e.getPlayer());
getManager().remove(getObjID());
delete();
}
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
Player p = e.getPlayer();
if(!getLib().canBuild(e.getPlayer(), getObjID(), EventType.INTERACT)){return;}
if(p.isSneaking()){
if(isFinish){return;}
p.openInventory(invI);
for(int i = 0; i<9;i++){invI.setItem(i, pane);}
ItemStack is = new ItemStack(Material.SKULL_ITEM);
is.setDurability((short) 1);
ItemMeta im = is.getItemMeta();
im.setDisplayName("§2Executioner");
is.setItemMeta(im);
invI.setItem(2, is);
is = new ItemStack(Material.SKULL_ITEM);
is.setDurability((short) 3);
im = is.getItemMeta();
im.setDisplayName("§cOblation");
is.setItemMeta(im);
invI.setItem(6, is);
this.p = p;
}else{
if(isRunning()){return;}
if(canStart()&&!isFinish){
move();
}else if(canStart()&&isFinish){
setDefault();
}
}
}
@EventHandler
private void onClick(InventoryClickEvent e){
if(e.getClickedInventory()==null){return;}
if(e.getCurrentItem()==null){return;}
Player p = (Player) e.getWhoClicked();
if(this.p!=null&&this.p.equals(p)){if(!e.getClick().equals(ClickType.LEFT)&&!e.getClick().equals(ClickType.RIGHT)){e.setCancelled(true);}}
if(e.getClickedInventory().equals(invI)){
e.setCancelled(true);
if(e.getSlot() == 2){
p.closeInventory();
p.openInventory(invII);
openInv(1);
p.updateInventory();
}else if(e.getSlot() == 6){
p.closeInventory();
p.openInventory(invIII);
openInv(2);
p.updateInventory();
}
}else if(e.getClickedInventory().equals(invII)){
if(e.getCurrentItem().equals(pane)){e.setCancelled(true);}
Material m = e.getCursor().getType();
if(m==null||m.equals(Material.AIR)){return;}
switch (e.getSlot()) {
case 10:
if(!m.equals(Material.SKULL_ITEM)){e.setCancelled(true);}
break;
case 16:
if(!matList.contains(m)){e.setCancelled(true);}
break;
case 19:
if(!matListI.contains(m)){e.setCancelled(true);}
break;
case 28:
if(!matListII.contains(m)){e.setCancelled(true);}
break;
case 37:
if(!matListIII.contains(m)){e.setCancelled(true);}
break;
case 43:
if(!m.equals(Material.NAME_TAG)){e.setCancelled(true);}
break;
}
}else if(e.getClickedInventory().equals(invIII)){
if(e.getCurrentItem().equals(pane)){e.setCancelled(true);}
Material m = e.getCursor().getType();
if(m==null||m.equals(Material.AIR)){return;}
switch (e.getSlot()) {
case 10:
if(!m.equals(Material.SKULL_ITEM)){e.setCancelled(true);}
break;
case 19:
if(!matListI.contains(m)){e.setCancelled(true);}
break;
case 28:
if(!matListII.contains(m)){e.setCancelled(true);}
break;
case 37:
if(!matListIII.contains(m)){e.setCancelled(true);}
break;
}
}
}
private boolean isRunning(){
if(timer!=null){return true;}
return false;
}
private boolean canStart(){
if(isRunning()) return false;
boolean a = false,b = false,c = false;
a = !packet1.isVisible();
b = !packet2.isVisible();
if(packet1.getItemInHand()!=null&&!packet1.getItemInHand().equals(Material.AIR)){
c = true;
}
if(a&&b&&c){
return true;
}
return false;
}
private void move(){
if(isRunning()){return;}
timer = Bukkit.getScheduler().scheduleSyncRepeatingTask(getPlugin(), new Runnable() {
boolean b1 = false;
boolean b2 = false;
boolean b3 = false;
double d1 = .0;
double d2 = .7;
double d3 = -1.7;
double d4 = 0;
int i = 0;
int j = 0;
@Override
public void run() {
try{
EulerAngle angle = getLutil().Radtodegress(packet2.getHeadPose());
if(angle.getX()<90){
angle = angle.setX(angle.getX()+4);
}else{b1=true;}
if(angle.getY()>0){
angle = angle.setY(angle.getY()-6);
}else{b2=true;}
packet2.setHeadPose(getLutil().degresstoRad(angle));
update();
if(b1&&b2){
if(d1!=d2){
packet2.teleport(getLutil().getRelativ(packet2.getLocation(), getBlockFace(), .1, 0d));
update();
d1+=.1;
}else{
if(!b3){
packet1.setRightArmPose(getLutil().degresstoRad(new EulerAngle(0,0,15)));
packet1.setLeftArmPose(getLutil().degresstoRad(new EulerAngle(0,0,289)));
b3=true;
}else{
if(i!=10){
playSound();
i++;
}else{
if(d4>d3){
for(fArmorStand stand : armorStandList){
stand.teleport(stand.getLocation().add(0, -1.7, 0));
}
d4=-1.7;
update();
}else{
if(j==0){
packet3.getInventory().setHelmet(packet2.getInventory().getHelmet());
packet2.getInventory().setHelmet(new ItemStack(Material.AIR));
update();
}else if(j!=0&&j<3){
update();
}else if(j == 3){
getWorld().playEffect(getLutil().getRelativ(getLocation(), getBlockFace(), 0d, -.1d).add(0, 1.3, 0), Effect.STEP_SOUND, Material.REDSTONE_BLOCK);
stopTimer();
isFinish=true;
return;
}
j++;
}
}
}
}
}
}catch(Exception e){
stopTimer();
}
}
}, 0, 1);
}
private void stopTimer(){
if(isRunning()){
Bukkit.getScheduler().cancelTask(timer);
timer=null;
}
}
@EventHandler
private void onClose(InventoryCloseEvent e){
if(e.getInventory()==null){return;}
if(e.getInventory().equals(invII)){
boolean invisible = true;
//10,16,19,28,37,43
packet1.getInventory().setHelmet(invII.getItem(10));
packet1.getInventory().setChestPlate(invII.getItem(19));
packet1.getInventory().setLeggings(invII.getItem(28));
packet1.getInventory().setBoots(invII.getItem(37));
if(invII.getItem(10)!=null){invisible=false;}
if(invII.getItem(19)!=null){invisible=false;}
if(invII.getItem(28)!=null){invisible=false;}
if(invII.getItem(37)!=null){invisible=false;}
if(!invisible){
if(invII.getItem(43)!=null){
if(invII.getItem(43).hasItemMeta()&&invII.getItem(43).getItemMeta().hasDisplayName()){
packet1.setName(ChatColor.translateAlternateColorCodes('&', invII.getItem(43).getItemMeta().getDisplayName()));
packet1.setNameVasibility(true);
}else{
if(invII.getItem(43)!=null&&!invII.getItem(43).getType().equals(Material.AIR)){getWorld().dropItem(getLocation().clone().add(0, 1, 0), invII.getItem(43));}
packet1.setName("#Executioner#");
packet1.setNameVasibility(false);
packet1.setInvisible(false);
}
}else{
if(invII.getItem(43)!=null&&!invII.getItem(43).getType().equals(Material.AIR)){getWorld().dropItem(getLocation().clone().add(0, 1, 0), invII.getItem(43));}
packet1.setName("#Executioner#");
packet1.setNameVasibility(false);
}
if(invII.getItem(16)!=null){
packet1.getInventory().setItemInHand(invII.getItem(16));
}
}else{
if(invII.getItem(43)!=null&&!invII.getItem(43).getType().equals(Material.AIR)){getWorld().dropItem(getLocation().clone().add(0, 1, 0), invII.getItem(43));}
if(invII.getItem(16)!=null&&!invII.getItem(16).getType().equals(Material.AIR)){getWorld().dropItem(getLocation().clone().add(0, 1, 0), invII.getItem(16));}
packet1.getInventory().setItemInHand(new ItemStack(Material.AIR));
packet1.setName("#Executioner#");
packet1.setNameVasibility(!invisible);
}
packet1.setArms(true);
packet1.setBasePlate(false);
packet1.setInvisible(invisible);
update();
this.p = null;
}else if(e.getInventory().equals(invIII)){
boolean invisible = true;
packet2.getInventory().setHelmet(invIII.getItem(10));
packet2.getInventory().setChestPlate(invIII.getItem(19));
packet2.getInventory().setLeggings(invIII.getItem(28));
packet2.getInventory().setBoots(invIII.getItem(37));
if(invIII.getItem(10)!=null){invisible=false;}
if(invIII.getItem(19)!=null){invisible=false;}
if(invIII.getItem(28)!=null){invisible=false;}
if(invIII.getItem(37)!=null){invisible=false;}
packet2.setBasePlate(false);
packet2.setArms(true);
packet2.setInvisible(invisible);
update();
this.p = null;
}
}
private void playSound(){
if(!soundPlaying){
getWorld().playSound(getLocation(), Sound.GHAST_DEATH, 2, 1);
getWorld().playSound(getLocation(), Sound.GHAST_SCREAM, 1, 1);
getWorld().playSound(getLocation(), Sound.GHAST_MOAN, 1, 1);
soundPlaying= true;
}
}
private void openInv(int i){
if(i>2||i<1){return;}
fArmorStand packet;
Inventory inv;
if(i==1){
packet = packet1;
inv = invII;
}else{
packet = packet2;
inv = invIII;
}
for(int j = 0; j<inv.getSize();j++){
Material m = Material.AIR;
if(!packet.getName().equalsIgnoreCase("#Executioner#")){m = Material.NAME_TAG;}
ItemStack stack = new ItemStack(Material.AIR);
ItemMeta meta = stack.getItemMeta();
if(!m.equals(Material.AIR)){
if(packet.getName()!=null){
if(meta!=null){
meta.setDisplayName(packet.getName());
stack.setItemMeta(meta);
}
}
}
switch(j){
case 10:inv.setItem(j, packet.getHelmet());break;
case 19:inv.setItem(j, packet.getChestPlate());break;
case 28:inv.setItem(j, packet.getLeggings());break;
case 37:inv.setItem(j, packet.getBoots());break;
case 16:if(i==1){inv.setItem(j, packet.getItemInHand());break;}
case 43:if(i==1){inv.setItem(j, stack);break;}
default: inv.setItem(j, pane);break;
}
}
if(i==1){
invII = inv;
}else{
invIII = inv;
}
}
}

View File

@ -7,7 +7,6 @@ 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;
@ -19,33 +18,18 @@ 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;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
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,
@ -54,18 +38,9 @@ public class weaponStand extends Furniture {
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()){
public weaponStand(Plugin plugin, ObjectID id) {
super(plugin, id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
@ -77,36 +52,53 @@ public class weaponStand extends Furniture {
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) {
if(obj==null){return;}
if(!e.getID().equals(obj)){return;}
if(getObjID()==null){return;}
if(!e.getID().equals(getObjID())){return;}
if(e.isCancelled()){return;}
if(!e.canBuild()){return;}
if(p!=null){
p.closeInventory();
}
List<ArmorStandPacket> asList = manager.getArmorStandPacketByObjectID(obj);
for(ArmorStandPacket packet : asList){
List<fArmorStand> asList = getManager().getfArmorStandByObjectID(getObjID());
for(fArmorStand 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());
getWorld().dropItem(getLocation(), packet.getInventory().getItemInHand());
}
}
}
}
e.remove();
inv = null;
obj=null;
delete();
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e) {
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(p!=null){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
this.p = e.getPlayer();
ItemStack itemstack = p.getItemInHand();
if(itemstack!=null&&matList.contains(itemstack.getType())){
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getInventory().getHelmet()!=null){
if(packet.getInventory().getHelmet().getType().name().toLowerCase().endsWith("gate")){
ItemStack itemStack = new ItemStack(itemstack.getType(), 1, (short) 0);
packet.getInventory().setHelmet(itemStack);
}
}
}
getManager().updateFurniture(getObjID());
this.p = null;
return;
}
ItemStack is1 = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 15);
ItemStack is3 = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
@ -117,22 +109,8 @@ public class weaponStand extends Furniture {
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);
List<fArmorStand> asList = getManager().getfArmorStandByObjectID(getObjID());
int j = 1;
for(int i = 0; i<inv.getSize();i++){
@ -140,7 +118,7 @@ public class weaponStand extends Furniture {
if(slotList1.contains(i)){
inv.setItem(i, is3);
}else if(slotList2.contains(i)){
for(ArmorStandPacket packet : asList){
for(fArmorStand packet : asList){
if(packet.getName()!=null&&!packet.getName().equalsIgnoreCase("")){
if(packet.getName().equalsIgnoreCase("#SLOT"+j+"#")){
ItemStack is = new ItemStack(Material.AIR);
@ -159,8 +137,8 @@ public class weaponStand extends Furniture {
@EventHandler
private void onClick(InventoryClickEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(p==null){return;}
if(inv==null){return;}
if(e.getInventory()==null){return;}
@ -185,17 +163,17 @@ public class weaponStand extends Furniture {
@EventHandler
private void onClose(InventoryCloseEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(p==null){return;}
if(inv==null){return;}
if(!e.getInventory().getTitle().equalsIgnoreCase(inv.getTitle())){return;}
List<ArmorStandPacket> asList = manager.getArmorStandPacketByObjectID(obj);
List<fArmorStand> asList = getManager().getfArmorStandByObjectID(getObjID());
int j = 1;
for(int i = 0; i<inv.getSize();i++){
if(slotList2.contains(i)){
for(ArmorStandPacket packet : asList){
for(fArmorStand packet : asList){
if(packet.getName()!=null&&!packet.getName().equalsIgnoreCase("")){
if(packet.getName().equalsIgnoreCase("#SLOT"+j+"#")){
ItemStack is = inv.getItem(i);
@ -211,27 +189,27 @@ public class weaponStand extends Furniture {
if(e.getPlayer().equals(p)){
this.p = null;
this.inv = null;
manager.updateFurniture(obj);
getManager().updateFurniture(getObjID());
}
}
@Override
public void spawn(Location loc) {
List<ArmorStandPacket> packList = new ArrayList<ArmorStandPacket>();
Location center = lutil.getCenter(loc);
List<fArmorStand> packList = new ArrayList<fArmorStand>();
Location center = getLutil().getCenter(loc);
center = center.add(0, -2.2, 0);
Location center2 = center;
Location center3 = center.clone();
ArmorStandPacket as = manager.createArmorStand(obj, center2);
fArmorStand as = getManager().createArmorStand(getObjID(), center2);
as.getInventory().setHelmet(new ItemStack(Material.WOOD_PLATE, 1, (short) 0));
as.setPose(lutil.degresstoRad(new EulerAngle(0, 45, 0)), BodyPart.HEAD);
as.setPose(getLutil().degresstoRad(new EulerAngle(0, 45, 0)), BodyPart.HEAD);
packList.add(as);
as = manager.createArmorStand(obj, center3.add(0, .2, 0));
as = getManager().createArmorStand(getObjID(), 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);
as.setPose(getLutil().degresstoRad(new EulerAngle(0, 45, 0)), BodyPart.HEAD);
packList.add(as);
Location location = center;
@ -239,55 +217,53 @@ public class weaponStand extends Furniture {
float yaw = 0;
for(int i = 0; i<4;i++){
BlockFace face = lutil.yawToFace(yaw);
Location locat = lutil.getRelativ(location, face, .185D, .185D);
BlockFace face = getLutil().yawToFace(yaw);
Location locat = getLutil().getRelativ(location, face, .185D, .185D);
as = manager.createArmorStand(obj, locat);
as = getManager().createArmorStand(getObjID(), locat.clone());
as.getInventory().setHelmet(new ItemStack(Material.FENCE_GATE, 1, (short) 0));
as.setPose(lutil.degresstoRad(new EulerAngle(0, -45, 0)), BodyPart.HEAD);
as.setPose(getLutil().degresstoRad(new EulerAngle(0, -45, 0)), BodyPart.HEAD);
packList.add(as);
as = manager.createArmorStand(obj, locat.add(0, .37, 0).clone());
as = getManager().createArmorStand(getObjID(), 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);
as.setPose(getLutil().degresstoRad(new EulerAngle(0, -45, 0)), BodyPart.HEAD);
packList.add(as);
as = manager.createArmorStand(obj, locat.add(0, .37, 0).clone());
as = getManager().createArmorStand(getObjID(), 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);
as.setPose(getLutil().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 = getManager().createArmorStand(getObjID(), getLutil().getRelativ(location, getBlockFace(), .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.setPose(getLutil().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));
BlockFace face = getLutil().yawToFace(getLutil().FaceToYaw(getBlockFace()) + 90);
as = getManager().createArmorStand(getObjID(), getLutil().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.setPose(getLutil().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 = getManager().createArmorStand(getObjID(), getLutil().getRelativ(location, getBlockFace().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.setPose(getLutil().degresstoRad(new EulerAngle(-80, 30, 15)), BodyPart.RIGHT_ARM);
as.setMarker(false);
packList.add(as);
for(ArmorStandPacket asp : packList){
for(fArmorStand asp : packList){
asp.setGravity(false);
asp.setInvisible(true);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
}

View File

@ -0,0 +1,114 @@
package de.Ste3et_C0st.Furniture.Objects.School;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
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.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class BlackBoard extends Furniture implements Listener {
public BlackBoard(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
spawn(id.getStartLocation());
}
@Override
public void spawn(Location paramLocation) {
List<fArmorStand> aspList = new ArrayList<fArmorStand>();
double d = -.126;
for(int i = 0; i<4;i++){
Location loc1 = getRelative(getCenter(), getBlockFace(), -.27, d).add(0, -2.5, 0);
fArmorStand stand = spawnArmorStand(loc1.clone().add(0, .1, 0));
stand.setHelmet(new ItemStack(Material.BANNER));
stand.setHeadPose(new EulerAngle(0, 0, 0));
aspList.add(stand);
d+=.75;
}
d = -.235;
for(int i = 0; i<6;i++){
Location loc1 = getRelative(getCenter(), getBlockFace(), -.27, d).add(0, -2.5, 0);
fArmorStand stand = spawnArmorStand(loc1.clone().add(0, .4, 0));
stand.setHelmet(new ItemStack(Material.WOOD_PLATE));
stand.setHeadPose(new EulerAngle(0, 0, 0));
aspList.add(stand);
d+=.49;
}
Location loc = getRelative(getCenter(), getBlockFace(),.25d, 1.2d).add(0, -1.63, 0);
loc.setYaw(getYaw()+180);
fArmorStand stand = spawnArmorStand(loc);
//stand.setItemInHand(new ItemStack(Material.BONE));
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(-110, 0, 270)));
stand.setMarker(false);
stand.setName("#ITEM#");
aspList.add(stand);
for(fArmorStand as : aspList){
as.setInvisible(true);
as.setGravity(false);
}
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
delete();
e.remove();
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e){
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
Player p = e.getPlayer();
if(!e.canBuild()){return;}
e.setCancelled(true);
if(p.getItemInHand().getType().isBlock()&&!p.getItemInHand().getType().equals(Material.AIR)){return;}
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().equalsIgnoreCase("#ITEM#")){
ItemStack Itemstack = p.getItemInHand().clone();
Itemstack.setAmount(1);
if(packet.getInventory().getItemInHand()!=null&&!packet.getInventory().getItemInHand().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getItemInHand();
is.setAmount(1);
getWorld().dropItem(getLocation(), is);
}
packet.getInventory().setItemInHand(Itemstack);
if(p.getGameMode().equals(GameMode.CREATIVE) && getLib().useGamemode()) break;
Integer i = p.getInventory().getHeldItemSlot();
ItemStack is = p.getItemInHand();
is.setAmount(is.getAmount()-1);
p.getInventory().setItem(i, is);
p.updateInventory();
break;
}
}
update();
}
}

View File

@ -0,0 +1,116 @@
package de.Ste3et_C0st.Furniture.Objects.School;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
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.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class SchoolChair extends Furniture implements Listener {
public SchoolChair(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
spawn(id.getStartLocation());
}
@Override
public void spawn(Location paramLocation) {
List<fArmorStand> asList = new ArrayList<fArmorStand>();
Location loc1 = getRelative(getCenter(), getBlockFace(), .16, .67).subtract(0, 2.3, 0);
loc1.setYaw(getYaw()+90);
Location loc2 = getRelative(getCenter(), getBlockFace(), .16+.41, .67).subtract(0, 2.3, 0);
loc2.setYaw(getYaw()+90);
Location loc3 = getRelative(getCenter(), getBlockFace(), .16, .67-.36).subtract(0, 2.3, 0);
loc3.setYaw(getYaw()+90);
Location loc4 = getRelative(getCenter(), getBlockFace(), .16+.41, .67-.36).subtract(0, 2.3, 0);
loc4.setYaw(getYaw()+90);
fArmorStand stand = spawnArmorStand(loc1);
stand.setItemInHand(new ItemStack(Material.STICK));
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(-100, 0, 0)));
stand.setMarker(false);
asList.add(stand);
stand = spawnArmorStand(loc2);
stand.setItemInHand(new ItemStack(Material.STICK));
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(-100, 0, 0)));
stand.setMarker(false);
asList.add(stand);
stand = spawnArmorStand(loc3);
stand.setItemInHand(new ItemStack(Material.STICK));
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(-100, 0, 0)));
stand.setMarker(false);
asList.add(stand);
stand = spawnArmorStand(loc4);
stand.setItemInHand(new ItemStack(Material.STICK));
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(-100, 0, 0)));
stand.setMarker(false);
asList.add(stand);
stand = spawnArmorStand(getCenter().subtract(0, 1.6, 0));
stand.setHelmet(new ItemStack(Material.IRON_PLATE));
asList.add(stand);
stand = spawnArmorStand(getCenter().subtract(0, 1.5, 0));
stand.setName("#SITZ#");
asList.add(stand);
stand = spawnArmorStand(getCenter().subtract(0, 1, 0));
stand.setHelmet(new ItemStack(Material.IRON_PLATE));
stand.setHeadPose(getLutil().degresstoRad(new EulerAngle(-100, 0, 0)));
asList.add(stand);
for(fArmorStand as : asList){
as.setInvisible(true);
as.setGravity(false);
}
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
delete();
e.remove();
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().equalsIgnoreCase("#SITZ#")){
if(packet.getPassanger()==null){
packet.setPassanger(e.getPlayer());
}
}
}
}
}

View File

@ -0,0 +1,146 @@
package de.Ste3et_C0st.Furniture.Objects.School;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
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.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class SchoolTable extends Furniture implements Listener {
public SchoolTable(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
spawn(id.getStartLocation());
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().equalsIgnoreCase("#ITEM#")){
if(packet.getInventory().getItemInHand()!=null&&!packet.getInventory().getItemInHand().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getItemInHand();
getWorld().dropItem(getLocation(), is);
}
}
}
e.remove();
delete();
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e){
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
Player p = e.getPlayer();
if(!e.canBuild()){return;}
e.setCancelled(true);
if(p.getItemInHand().getType().isBlock()&&!p.getItemInHand().getType().equals(Material.AIR)){return;}
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().equalsIgnoreCase("#ITEM#")){
ItemStack Itemstack = p.getItemInHand().clone();
Itemstack.setAmount(1);
if(packet.getInventory().getItemInHand()!=null&&!packet.getInventory().getItemInHand().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getItemInHand();
is.setAmount(1);
getWorld().dropItem(getLocation(), is);
}
packet.getInventory().setItemInHand(Itemstack);
if(p.getGameMode().equals(GameMode.CREATIVE) && getLib().useGamemode()) break;
Integer i = p.getInventory().getHeldItemSlot();
ItemStack is = p.getItemInHand();
is.setAmount(is.getAmount()-1);
p.getInventory().setItem(i, is);
p.updateInventory();
break;
}
}
update();
}
@Override
public void spawn(Location arg0) {
List<fArmorStand> asList = new ArrayList<fArmorStand>();
Location loc1 = getRelative(getCenter(), getBlockFace(), .16, .67).subtract(0, 1.9, 0);
loc1.setYaw(getYaw()+90);
Location loc2 = getRelative(getCenter(), getBlockFace(), .16+.41, .67).subtract(0, 1.9, 0);
loc2.setYaw(getYaw()+90);
Location loc3 = getRelative(getCenter(), getBlockFace(), .16, .67-.36).subtract(0, 1.9, 0);
loc3.setYaw(getYaw()+90);
Location loc4 = getRelative(getCenter(), getBlockFace(), .16+.41, .67-.36).subtract(0, 1.9, 0);
loc4.setYaw(getYaw()+90);
Location loc5 = getRelative(getCenter(), getBlockFace(), .37, .33).subtract(0, .22, 0);
loc5.setYaw(getYaw()+90);
fArmorStand stand = spawnArmorStand(loc1);
stand.setItemInHand(new ItemStack(Material.STICK));
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(-100, 0, 0)));
stand.setMarker(false);
asList.add(stand);
stand = spawnArmorStand(loc2);
stand.setItemInHand(new ItemStack(Material.STICK));
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(-100, 0, 0)));
stand.setMarker(false);
asList.add(stand);
stand = spawnArmorStand(loc3);
stand.setItemInHand(new ItemStack(Material.STICK));
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(-100, 0, 0)));
stand.setMarker(false);
asList.add(stand);
stand = spawnArmorStand(loc4);
stand.setItemInHand(new ItemStack(Material.STICK));
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(-100, 0, 0)));
stand.setMarker(false);
asList.add(stand);
stand = spawnArmorStand(getCenter().subtract(0, 1.2, 0));
stand.setHelmet(new ItemStack(Material.WOOD_PLATE));
asList.add(stand);
stand = spawnArmorStand(loc5);
stand.setPose(new EulerAngle(0.0,0.0,0.0), BodyPart.RIGHT_ARM);
stand.setMarker(false);
stand.setName("#ITEM#");
asList.add(stand);
for(fArmorStand as : asList){
as.setInvisible(true);
as.setGravity(false);
}
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
}

View File

@ -0,0 +1,111 @@
package de.Ste3et_C0st.Furniture.Objects.School;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
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.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class TrashCan extends Furniture implements Listener {
public TrashCan(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
spawn(id.getStartLocation());
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()) return;
if(!e.getID().equals(getObjID())) return;
if(!e.canBuild()){return;}
e.remove();
delete();
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()) return;
if(!e.getID().equals(getObjID())) return;
if(!e.canBuild()){return;}
ItemStack is = e.getPlayer().getItemInHand();
fArmorStand stand = null;
for(fArmorStand s : getfAsList()){
if(s.getName().equalsIgnoreCase("#TRASH#")){
stand = s;break;
}
}
if(stand==null){return;}
if(is==null||is.getType()==null||is.getType().equals(Material.AIR)){
if(stand.getItemInHand()!=null&&!stand.getItemInHand().getType().equals(Material.AIR)){
getWorld().dropItem(getCenter(), stand.getItemInHand());
stand.setItemInHand(new ItemStack(Material.AIR));
update();
return;
}
}
stand.setItemInHand(is);
e.getPlayer().getInventory().clear(e.getPlayer().getInventory().getHeldItemSlot());
e.getPlayer().updateInventory();
update();
return;
}
@Override
public void spawn(Location loc) {
List<fArmorStand> asList = new ArrayList<fArmorStand>();
Location l = getLutil().getRelativ(getCenter(), getBlockFace(), -.29, .2).add(0, -1.1, 0);
l.setYaw(getYaw());
fArmorStand stand = spawnArmorStand(getCenter().add(0, -1.2, 0));
stand.setHelmet(new ItemStack(Material.CARPET, 1,(short) 15));
stand.setSmall(true);
asList.add(stand);
float yaw = 0;
for(int i = 0; i<4;i++){
Location location = getLutil().getRelativ(getCenter(), getLutil().yawToFace(yaw), .25, 0);
location.add(0,-1.88,0);
location.setYaw(yaw);
stand = spawnArmorStand(location);
stand.setHelmet(new ItemStack(Material.IRON_FENCE));
stand.setHeadPose(getLutil().degresstoRad(new EulerAngle(10, 0, 0)));
asList.add(stand);
yaw+=90;
}
stand = spawnArmorStand(l);
stand.setSmall(true);
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(-110,0,0)));
stand.setMarker(false);
stand.setName("#TRASH#");
asList.add(stand);
for(fArmorStand as : asList){
as.setInvisible(true);
as.setGravity(false);
}
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
}

View File

@ -6,8 +6,6 @@ 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.ItemFrame;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -15,44 +13,18 @@ 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;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class billboard extends Furniture implements Listener{
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Plugin plugin;
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
public billboard(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()){
public billboard(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
@ -60,42 +32,42 @@ public class billboard extends Furniture implements Listener{
}
public void spawn(Location location){
List<ArmorStandPacket> asList = new ArrayList<ArmorStandPacket>();
Location center = lutil.getCenter(location).add(0, -1.2, 0);
Location center2 = lutil.getRelativ(center, b, 0D, -4D);
Location center3 = lutil.getRelativ(center, b, 0D, -3.3D);
List<fArmorStand> asList = new ArrayList<fArmorStand>();
Location center = getLutil().getCenter(location).add(0, -1.2, 0);
Location center2 = getLutil().getRelativ(center, getBlockFace(), 0D, -4D);
Location center3 = getLutil().getRelativ(center, getBlockFace(), 0D, -3.3D);
for(int i = 0; i<=3;i++){
Location loc = lutil.getRelativ(center.clone(), b, -.1, -.5).add(0, .88*i, 0);
Location loc = getLutil().getRelativ(center.clone(), getBlockFace(), -.1, -.5).add(0, .88*i, 0);
loc.setYaw(loc.getYaw()+90);
ArmorStandPacket packet = manager.createArmorStand(obj, loc);
fArmorStand packet = getManager().createArmorStand(getObjID(), loc);
packet.getInventory().setItemInHand(new ItemStack(Material.STICK));
packet.setPose(new EulerAngle(1.39, 0, 0), BodyPart.RIGHT_ARM);
asList.add(packet);
}
for(int i = 0; i<=3;i++){
Location loc = lutil.getRelativ(center2.clone(), b, -.1, -.5).add(0, .88*i, 0);
Location loc = getLutil().getRelativ(center2.clone(), getBlockFace(), -.1, -.5).add(0, .88*i, 0);
loc.setYaw(loc.getYaw()+90);
ArmorStandPacket packet = manager.createArmorStand(obj, loc);
fArmorStand packet = getManager().createArmorStand(getObjID(), loc);
packet.getInventory().setItemInHand(new ItemStack(Material.STICK));
packet.setPose(new EulerAngle(1.39, 0, 0), BodyPart.RIGHT_ARM);
asList.add(packet);
}
for(int i = 0; i<=4;i++){
Location loc = lutil.getRelativ(center3.clone(), b, -.1, .88*i).add(0, .7D, 0);
Location loc = getLutil().getRelativ(center3.clone(), getBlockFace(), -.1, .88*i).add(0, .7D, 0);
loc.setYaw(loc.getYaw()+90);
ArmorStandPacket packet = manager.createArmorStand(obj, loc);
fArmorStand packet = getManager().createArmorStand(getObjID(), loc);
packet.getInventory().setItemInHand(new ItemStack(Material.STICK));
packet.setPose(new EulerAngle(-.17, 0, 0), BodyPart.RIGHT_ARM);
asList.add(packet);
}
for(int i = 0; i<=4;i++){
Location loc = lutil.getRelativ(center3.clone(), b, -.1, .88*i).add(0, 2.9D, 0);
Location loc = getLutil().getRelativ(center3.clone(), getBlockFace(), -.1, .88*i).add(0, 2.9D, 0);
loc.setYaw(loc.getYaw()+90);
ArmorStandPacket packet = manager.createArmorStand(obj, loc);
fArmorStand packet = getManager().createArmorStand(getObjID(), loc);
packet.getInventory().setItemInHand(new ItemStack(Material.STICK));
packet.setPose(new EulerAngle(-.17, 0, 0), BodyPart.RIGHT_ARM);
asList.add(packet);
@ -103,33 +75,32 @@ public class billboard extends Furniture implements Listener{
for(int x = 0; x<=1;x++){
for(int y = 0;y<=2;y++){
Location loc = lutil.getRelativ(location, b,0D,(double) -y-1).add(0, x+1, 0);
Location loc2 = lutil.getRelativ(location, b,-1D,(double) -y-1).add(0, x+1, 0);
Location loc = getLutil().getRelativ(location, getBlockFace(),0D,(double) -y-1).add(0, x+1, 0);
Location loc2 = getLutil().getRelativ(location, getBlockFace(),-1D,(double) -y-1).add(0, x+1, 0);
loc.getBlock().setType(Material.BARRIER);
ItemFrame frame = (ItemFrame) w.spawn(loc2, ItemFrame.class);
frame.setFacingDirection(b);
ItemFrame frame = (ItemFrame) getWorld().spawn(loc2, ItemFrame.class);
frame.setFacingDirection(getBlockFace());
}
}
for(ArmorStandPacket pack : asList){
for(fArmorStand pack : asList){
pack.setInvisible(true);
pack.setGravity(false);
pack.setBasePlate(false);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) {
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.canBuild()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!canBuild(e.getPlayer())){return;}
e.remove();
obj=null;
delete();
}
@EventHandler

View File

@ -7,7 +7,6 @@ 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;
@ -19,43 +18,18 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Camera.Utils.RenderClass;
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;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class camera extends Furniture implements Listener{
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Plugin plugin;
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
public camera(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()){
public camera(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
@ -63,103 +37,103 @@ public class camera extends Furniture implements Listener{
}
public void spawn(Location location){
List<ArmorStandPacket> aspList = new ArrayList<ArmorStandPacket>();
BlockFace b = lutil.yawToFace(location.getYaw()).getOppositeFace();
Location center = lutil.getCenter(location);
Location gehäuse = lutil.getRelativ(center, b, 0D, 0D).add(0,-1.0,0);
Location gehäuse2 = lutil.getRelativ(center, b, 0D, 0D).add(0,-0.4,0);
Location fokus = lutil.getRelativ(center, b, .15D, 0D).add(0,-.24,0);
Location search = lutil.getRelativ(center, b, .15D, 0D).add(0,-.7,0);
Location button = lutil.getRelativ(center, b, -.15D, -.15D).add(0,.08,0);
List<fArmorStand> aspList = new ArrayList<fArmorStand>();
BlockFace b = getLutil().yawToFace(location.getYaw()).getOppositeFace();
Location center = getLutil().getCenter(location);
Location gehäuse = getLutil().getRelativ(center, b, 0D, 0D).add(0,-1.0,0);
Location gehäuse2 = getLutil().getRelativ(center, b, 0D, 0D).add(0,-0.4,0);
Location fokus = getLutil().getRelativ(center, b, .15D, 0D).add(0,-.24,0);
Location search = getLutil().getRelativ(center, b, .15D, 0D).add(0,-.7,0);
Location button = getLutil().getRelativ(center, b, -.15D, -.15D).add(0,.08,0);
Location feet1 = lutil.getRelativ(center, b, .5D, .4D).add(0,-.9,0);
Location feet2 = lutil.getRelativ(center, b, -.2D, -.7D).add(0,-.9,0);
Location feet3 = lutil.getRelativ(center, b, -.7D, .2D).add(0,-.9,0);
Location feet1 = getLutil().getRelativ(center, b, .5D, .4D).add(0,-.9,0);
Location feet2 = getLutil().getRelativ(center, b, -.2D, -.7D).add(0,-.9,0);
Location feet3 = getLutil().getRelativ(center, b, -.7D, .2D).add(0,-.9,0);
gehäuse.setYaw(lutil.FaceToYaw(b));
fokus.setYaw(lutil.FaceToYaw(b));
search.setYaw(lutil.FaceToYaw(b));
button.setYaw(lutil.FaceToYaw(b));
feet1.setYaw(lutil.FaceToYaw(b));
feet2.setYaw(lutil.FaceToYaw(b) + 180 - 45);
feet3.setYaw(lutil.FaceToYaw(b) + 180 + 45);
gehäuse.setYaw(getLutil().FaceToYaw(b));
fokus.setYaw(getLutil().FaceToYaw(b));
search.setYaw(getLutil().FaceToYaw(b));
button.setYaw(getLutil().FaceToYaw(b));
feet1.setYaw(getLutil().FaceToYaw(b));
feet2.setYaw(getLutil().FaceToYaw(b) + 180 - 45);
feet3.setYaw(getLutil().FaceToYaw(b) + 180 + 45);
ArmorStandPacket as = manager.createArmorStand(obj, gehäuse);
fArmorStand as = getManager().createArmorStand(getObjID(), gehäuse);
as.getInventory().setHelmet(new ItemStack(Material.WOOL, 1, (short) 15));
aspList.add(as);
as = manager.createArmorStand(obj, gehäuse2);
as = getManager().createArmorStand(getObjID(), gehäuse2);
as.getInventory().setHelmet(new ItemStack(Material.WOOL, 1, (short) 15));
as.setSmall(true);
aspList.add(as);
as = manager.createArmorStand(obj, fokus);
as = getManager().createArmorStand(getObjID(), fokus);
as.getInventory().setHelmet(new ItemStack(Material.DISPENSER));
as.setSmall(true);
aspList.add(as);
as = manager.createArmorStand(obj, search);
as = getManager().createArmorStand(getObjID(), search);
as.getInventory().setHelmet(new ItemStack(Material.TRIPWIRE_HOOK));
aspList.add(as);
as = manager.createArmorStand(obj, button);
as = getManager().createArmorStand(getObjID(), button);
as.getInventory().setHelmet(new ItemStack(Material.WOOD_BUTTON));
as.setSmall(true);
aspList.add(as);
as = manager.createArmorStand(obj, feet1);
as = getManager().createArmorStand(getObjID(), feet1);
as.getInventory().setItemInHand(new ItemStack(Material.STICK));
as.setPose(new EulerAngle(1.2, 0, 0), BodyPart.RIGHT_ARM);
aspList.add(as);
as = manager.createArmorStand(obj, feet2);
as = getManager().createArmorStand(getObjID(), feet2);
as.getInventory().setItemInHand(new ItemStack(Material.STICK));
as.setPose(new EulerAngle(1.2, 0, 0), BodyPart.RIGHT_ARM);
aspList.add(as);
as = manager.createArmorStand(obj, feet3);
as = getManager().createArmorStand(getObjID(), feet3);
as.getInventory().setItemInHand(new ItemStack(Material.STICK));
as.setPose(new EulerAngle(1.2, 0, 0), BodyPart.RIGHT_ARM);
aspList.add(as);
for(ArmorStandPacket asp : aspList){
for(fArmorStand asp : aspList){
asp.setInvisible(true);
asp.setGravity(false);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) {
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.remove();
obj=null;
delete();
}
@SuppressWarnings("deprecation")
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e) {
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
Player p = e.getPlayer();
Location pLocation = lutil.getRelativ(p.getLocation().getBlock().getLocation(), b, -1D, 0D).clone();
Location pLocation = getLutil().getRelativ(p.getLocation().getBlock().getLocation(), getBlockFace(), -1D, 0D).clone();
Location locCopy = getLocation().getBlock().getLocation().clone();
pLocation.setYaw(locCopy.getYaw());
if(pLocation.equals(locCopy)){
if(lutil.yawToFace(p.getLocation().getYaw()).getOppositeFace().equals(b)){
if(getLutil().yawToFace(p.getLocation().getYaw()).getOppositeFace().equals(getBlockFace())){
if(!p.getInventory().getItemInHand().getType().equals(Material.MAP)){return;}
MapView view = Bukkit.getMap(p.getItemInHand().getDurability());
Location l = getLocation();
l.setYaw(lutil.FaceToYaw(b.getOppositeFace()));
Location l = getLocation().clone();
l.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()));
Iterator<MapRenderer> iter = view.getRenderers().iterator();
while(iter.hasNext()){
view.removeRenderer(iter.next());

View File

@ -6,65 +6,40 @@ import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBlockBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBlockClickEvent;
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.EventType;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class streetlamp extends Furniture implements Listener{
Location loc, light;
Location light;
Vector loc2, loc3;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Plugin plugin;
boolean redstone = false;
List<Location> blockLocation = new ArrayList<Location>();
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
public streetlamp(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());
public streetlamp(Plugin plugin, ObjectID id){
super(plugin, id);
setBlock();
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;
this.plugin = plugin;
this.light = lutil.getRelativ(loc, b, -1D, 0D);
this.obj = id;
setBlock();
if(id.isFinish()){
this.light = getLutil().getRelativ(getLocation(), getBlockFace(), -1D, 0D);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
@ -72,113 +47,114 @@ public class streetlamp extends Furniture implements Listener{
}
public void spawn(Location location){
List<ArmorStandPacket> asList = new ArrayList<ArmorStandPacket>();
Location center = lutil.getCenter(location).clone();
List<fArmorStand> asList = new ArrayList<fArmorStand>();
Location center = getLutil().getCenter(location).clone();
center.add(0, -1.1, 0);
Location aloc = center.clone();
aloc.add(0, -.2, 0);
for(int i = 0; i<=3;i++){
Location loc = aloc.clone().add(0, .215*i, 0);
ArmorStandPacket packet = manager.createArmorStand(obj, loc);
fArmorStand packet = getManager().createArmorStand(getObjID(), loc);
packet.getInventory().setHelmet(new ItemStack(Material.STEP));
packet.setSmall(true);
asList.add(packet);
}
for(int i = 0; i<=3;i++){
Location loc = lutil.getRelativ(center.clone(), b, .47, .38).add(0, .88*i, 0);
ArmorStandPacket packet = manager.createArmorStand(obj, loc);
Location loc = getLutil().getRelativ(center.clone(), getBlockFace(), .47, .38).add(0, .88*i, 0);
fArmorStand packet = getManager().createArmorStand(getObjID(), loc);
packet.getInventory().setItemInHand(new ItemStack(Material.STICK));
packet.setPose(new EulerAngle(1.39, 0, 0), BodyPart.RIGHT_ARM);
asList.add(packet);
}
ArmorStandPacket packet = manager.createArmorStand(obj, lutil.getRelativ(center, b, -.9, .38).add(0, 3.1, 0));
fArmorStand packet = getManager().createArmorStand(getObjID(), getLutil().getRelativ(center, getBlockFace(), -.9, .38).add(0, 3.1, 0));
packet.getInventory().setItemInHand(new ItemStack(Material.STICK));
packet.setPose(new EulerAngle(-.17, 0, 0), BodyPart.RIGHT_ARM);
asList.add(packet);
float yaw = lutil.FaceToYaw(b);
BlockFace face = lutil.yawToFace(yaw +90);
packet = manager.createArmorStand(obj, lutil.getRelativ(center, b, -.4, .38).add(0, 2.68, 0));
float yaw = getLutil().FaceToYaw(getBlockFace());
BlockFace face = getLutil().yawToFace(yaw +90);
packet = getManager().createArmorStand(getObjID(), getLutil().getRelativ(center, getBlockFace(), -.4, .38).add(0, 2.68, 0));
packet.getInventory().setItemInHand(new ItemStack(Material.STICK));
packet.setPose(new EulerAngle(1.39, 0, 0), BodyPart.RIGHT_ARM);
asList.add(packet);
packet = manager.createArmorStand(obj, lutil.getRelativ(center, face, 0.0, -0.9).add(0, 2.3, 0));
packet = getManager().createArmorStand(getObjID(), getLutil().getRelativ(center, face, 0.0, -0.9).add(0, 2.3, 0));
packet.getInventory().setHelmet(new ItemStack(Material.REDSTONE_LAMP_OFF));
packet.setName("#LAMP#");
packet.setSmall(true);
asList.add(packet);
packet = manager.createArmorStand(obj, lutil.getRelativ(center, face, 0.0, -0.9).add(0, 1.8, 0));
packet = getManager().createArmorStand(getObjID(), getLutil().getRelativ(center, face, 0.0, -0.9).add(0, 1.8, 0));
packet.getInventory().setHelmet(new ItemStack(Material.WOOD, 1,(short) 5));
asList.add(packet);
packet = manager.createArmorStand(obj, lutil.getRelativ(center, face, 0.0, -0.9).add(0, 2.3, 0));
packet = getManager().createArmorStand(getObjID(), getLutil().getRelativ(center, face, 0.0, -0.9).add(0, 2.3, 0));
packet.getInventory().setHelmet(new ItemStack(Material.GLASS));
packet.setSmall(true);
asList.add(packet);
for(ArmorStandPacket pack : asList){
for(fArmorStand pack : asList){
pack.setInvisible(true);
pack.setGravity(false);
pack.setBasePlate(false);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
getManager().send(getObjID());
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
private void setBlock(){
Location location = loc.getBlock().getLocation();
List<Block> blockLocation = new ArrayList<Block>();
Location location = getLocation().getBlock().getLocation();
location.setY(location.getY()-1);
for(int i = 0; i<=3;i++){
location.setY(location.getY()+1);
Block block = location.getBlock();
block.setType(Material.BARRIER);
blockLocation.add(block.getLocation());
blockLocation.add(block);
if(i==3){
Location loc =lutil.getRelativ(location, b, -1D, 0D);
Location loc =getLutil().getRelativ(location, getBlockFace(), -1D, 0D);
Block blocks = loc.getBlock();
blocks.setType(Material.BARRIER);
blockLocation.add(blocks.getLocation());
blockLocation.add(blocks);
}
}
getObjID().addBlock(blockLocation);
}
@EventHandler
private void onPlayerInteract(PlayerInteractEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
private void onBlockBreak(FurnitureBlockBreakEvent e){
if(e.isCancelled()){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)){
FurnitureLib.getInstance().getLightManager().removeLight(light);
obj.remove(e.getPlayer());
for(Location loc : blockLocation){
loc.getBlock().setType(Material.AIR);
}
obj=null;
}else if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
if(isOn()){
setLight(false);
}else{
setLight(true);
}
if(getObjID()==null){return;}
if(!e.getID().equals(getObjID())){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(!e.canBuild()){return;}
FurnitureLib.getInstance().getLightManager().removeLight(light);
e.remove();
delete();
}
@EventHandler
private void onBlockClick(FurnitureBlockClickEvent e){
if(e.isCancelled()){return;}
if(getObjID()==null){return;}
if(!e.getID().equals(getObjID())){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(!e.canBuild()){return;}
if(isOn()){
setLight(false);
}else{
setLight(true);
}
}
@EventHandler
private void onBlockPowered(BlockRedstoneEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.getBlock()==null){return;}
Vector loc = e.getBlock().getLocation().toVector();
if(loc2.distance(loc)<=1){
@ -205,24 +181,24 @@ public class streetlamp extends Furniture implements Listener{
private void setLight(Boolean b){
if(!b){
ArmorStandPacket packet = getPacket();
fArmorStand packet = getPacket();
if(packet==null) return;
packet.getInventory().setHelmet(new ItemStack(Material.REDSTONE_LAMP_OFF));
manager.updateFurniture(obj);
getManager().updateFurniture(getObjID());
FurnitureLib.getInstance().getLightManager().removeLight(light);
return;
}else{
ArmorStandPacket packet = getPacket();
fArmorStand packet = getPacket();
if(packet==null) return;
packet.getInventory().setHelmet(new ItemStack(Material.GLOWSTONE));
manager.updateFurniture(obj);
getManager().updateFurniture(getObjID());
FurnitureLib.getInstance().getLightManager().addLight(light, 15);
return;
}
}
private ArmorStandPacket getPacket(){
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
private fArmorStand getPacket(){
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().equalsIgnoreCase("#LAMP#")){
return packet;
}
@ -231,7 +207,7 @@ public class streetlamp extends Furniture implements Listener{
}
private boolean isOn(){
for(ArmorStandPacket as : manager.getArmorStandPacketByObjectID(obj)){
for(fArmorStand as : getManager().getfArmorStandByObjectID(getObjID())){
if(as.getName().equalsIgnoreCase("#LAMP#")){
switch (as.getInventory().getHelmet().getType()) {
case REDSTONE_LAMP_OFF: return false;
@ -246,29 +222,25 @@ public class streetlamp extends Furniture implements Listener{
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) {
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(!e.getID().equals(getObjID())){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(!e.canBuild()){return;}
FurnitureLib.getInstance().getLightManager().removeLight(light);
e.remove();
obj=null;
for(Location loc : blockLocation){
loc.getBlock().setType(Material.AIR);
}
blockLocation.clear();
delete();
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e) {
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
Boolean isOn = isOn();
ArmorStandPacket packet = getPacket();
fArmorStand packet = getPacket();
if(packet==null) return;
if(redstone) return;
if(isOn){

View File

@ -6,7 +6,6 @@ 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;
@ -14,44 +13,18 @@ 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;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class tv extends Furniture implements Listener{
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Plugin plugin;
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
public tv(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()){
public tv(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
@ -59,51 +32,48 @@ public class tv extends Furniture implements Listener{
}
public void spawn(Location location){
List<ArmorStandPacket> aspList = new ArrayList<ArmorStandPacket>();
if(b.equals(BlockFace.WEST)){location = lutil.getRelativ(location, b, .0, -1.02);}
if(b.equals(BlockFace.SOUTH)){location = lutil.getRelativ(location, b, -1.0, -1.02);}
if(b.equals(BlockFace.EAST)){location = lutil.getRelativ(location, b, -1.0, .0);}
BlockFace b = lutil.yawToFace(location.getYaw()).getOppositeFace();
Location center = lutil.getCenter(getLocation());
List<fArmorStand> aspList = new ArrayList<fArmorStand>();
BlockFace b = getLutil().yawToFace(location.getYaw()).getOppositeFace();
Location center = getLutil().getCenter(location);
center.add(0, -1.38, 0);
center.setYaw(lutil.FaceToYaw(b));
center.setYaw(getLutil().FaceToYaw(b));
Location iron = center.clone();
ArmorStandPacket as = manager.createArmorStand(obj, iron);
fArmorStand as = getManager().createArmorStand(getObjID(), iron);
as.getInventory().setHelmet(new ItemStack(Material.IRON_PLATE));
as.setSmall(true);
aspList.add(as);
center.add(0, -.45, 0);
center.setYaw(lutil.FaceToYaw(b));
center.setYaw(getLutil().FaceToYaw(b));
as = manager.createArmorStand(obj, center);
as = getManager().createArmorStand(getObjID(), center);
as.getInventory().setHelmet(new ItemStack(Material.LEVER));
aspList.add(as);
Location tv = lutil.getRelativ(location, getBlockFace(), .85, .7);
tv.add(0, -1.33, 0);
tv.setYaw(lutil.FaceToYaw(b));
Location tv = getLutil().getRelativ(center.clone(), b, -.38, -.2);
tv.add(0, -.1, 0);
tv.setYaw(getLutil().FaceToYaw(b));
Double l = .63;
for(int i = 0;i<=1;i++){
setRow(tv, .63, l, -.35,2,lutil.degresstoRad(new EulerAngle(90, 0, 0)), aspList);
setRow(tv, .63, l, -.35,2,getLutil().degresstoRad(new EulerAngle(90, 0, 0)), aspList);
l+=.63;
}
for(ArmorStandPacket asp : aspList){
for(fArmorStand asp : aspList){
asp.setGravity(false);
asp.setBasePlate(false);
asp.setInvisible(true);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
public void setRow(Location loc, double x,double y, double z, int replay, EulerAngle angle, List<ArmorStandPacket> list){
public void setRow(Location loc, double x,double y, double z, int replay, EulerAngle angle, List<fArmorStand> list){
Double d = .0;
for(int i = 0; i<=replay;i++){
Location loc1= lutil.getRelativ(loc, b, z, d-.825);
loc1.setYaw(lutil.FaceToYaw(b));
Location loc1= getLutil().getRelativ(loc, getBlockFace(), z, d-.825);
loc1.setYaw(getLutil().FaceToYaw(getBlockFace()));
loc1.add(0, y,0);
ArmorStandPacket packet = manager.createArmorStand(obj, loc1);
fArmorStand packet = getManager().createArmorStand(getObjID(), loc1);
packet.getInventory().setHelmet(new ItemStack(Material.CARPET, 1 , (short) 15));
packet.setPose(angle, BodyPart.HEAD);
list.add(packet);
@ -114,13 +84,13 @@ public class tv extends Furniture implements Listener{
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.remove();
obj=null;
delete();
}
@EventHandler

View File

@ -0,0 +1,89 @@
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.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.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class SleepingBag extends Furniture implements Listener {
public SleepingBag(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
spawn(id.getStartLocation());
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
delete();
e.remove();
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().equalsIgnoreCase("#SITZ#")){
if(packet.getPassanger()==null){
packet.setPassanger(e.getPlayer());
}
}
}
}
public void spawn(Location loc) {
List<fArmorStand> asList = new ArrayList<fArmorStand>();
double offset = .3;
fArmorStand stand = spawnArmorStand(getRelative(getCenter(), 0 - offset, 0).add(0, -2.15, 0));
asList.add(stand);
stand.setHelmet(new ItemStack(Material.IRON_TRAPDOOR));
stand.setHeadPose(getLutil().degresstoRad(new EulerAngle(90, 0, 0)));
stand = spawnArmorStand(getRelative(getCenter(), 2 - offset, 0).add(0, -1.7, 0));
asList.add(stand);
stand.setHelmet(new ItemStack(Material.BANNER, 1, (short) 3));
stand.setHeadPose(getLutil().degresstoRad(new EulerAngle(-90, 0, 0)));
stand = spawnArmorStand(getRelative(getCenter(), -.5 - offset, 0).add(0, -1.68, 0));
asList.add(stand);
stand.setHelmet(new ItemStack(Material.BANNER, 1, (short) 3));
stand.setHeadPose(getLutil().degresstoRad(new EulerAngle(-90, 180, 0)));
stand = spawnArmorStand(getRelative(getCenter(), .3 - offset, 0).add(0, -2.1, 0));
stand.setName("#SITZ#");
asList.add(stand);
for(fArmorStand as : asList){
as.setInvisible(true);
as.setGravity(false);
}
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
}

View File

@ -0,0 +1,142 @@
package de.Ste3et_C0st.Furniture.Objects.garden;
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.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.FlowerPot;
import org.bukkit.material.MaterialData;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBlockBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBlockClickEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class TFlowerPot extends Furniture implements Listener {
Block pot;
FlowerPot potMeta;
public TFlowerPot(Plugin plugin, ObjectID id){
super(plugin, id);
setPotState();
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
spawn(id.getStartLocation());
}
private void setPotState(){
pot=getLocation().getBlock();
if(pot.getType()==null||!pot.getType().equals(Material.FLOWER_POT)){pot.setType(Material.FLOWER_POT);}
potMeta = (FlowerPot) pot.getState().getData();
getObjID().addBlock(Arrays.asList(pot));
}
@Override
public void spawn(Location paramLocation) {
List<fArmorStand> packetList = new ArrayList<fArmorStand>();
float yaw = 90;
for(int i = 0; i<=3;i++){
Location location = getLutil().getRelativ(getCenter(), getLutil().yawToFace(yaw), .53, .08);
location.add(0,-1.7,0);
location.setYaw(90+yaw);
fArmorStand asp = getManager().createArmorStand(getObjID(), location);
asp.setRightArmPose(getLutil().degresstoRad(new EulerAngle(-115,45,0)));
asp.getInventory().setItemInHand(new ItemStack(Material.STICK));
packetList.add(asp);
yaw+=90;
}
for(fArmorStand asp : packetList){
asp.setGravity(false);
asp.setInvisible(true);
asp.setBasePlate(false);
asp.setMarker(false);
}
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
@Override
public void onFurnitureBreak(FurnitureBreakEvent paramFurnitureBreakEvent) {}
@Override
public void onFurnitureClick(FurnitureClickEvent paramFurnitureClickEvent) {}
@EventHandler
private void BlockBreak(FurnitureBlockBreakEvent e){
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if (pot==null) return;
if (e.getBlock() == null) return;
if (e.getBlock().getLocation() == null) return;
if(!e.getBlock().equals(pot)){return;}
e.setCancelled(true);
if(!canBuild(e.getPlayer())){return;}
if(potMeta!=null&&potMeta.getContents()!=null){
getWorld().dropItem(getLocation(), potMeta.getContents().toItemStack());
}
destroy(e.getPlayer());
pot.setType(Material.AIR);
pot=null;
potMeta=null;
return;
}
@EventHandler
private void onPhysiks(BlockPhysicsEvent e){
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if (pot==null) return;
if (e.getBlock() == null) return;
if (!e.getBlock().equals(pot)) return;
e.setCancelled(true);
}
private void resendFlowerPot(){
pot.getState().setData(new MaterialData(Material.AIR));
pot.getState().update();
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() {
@Override
public void run() {
pot.getState().setData(potMeta);
pot.getState().update();
}
}, 5);
}
@EventHandler(priority=EventPriority.HIGHEST)
private void onRightClick(FurnitureBlockClickEvent e){
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.getBlock()==null||pot==null){return;}
if(!e.getBlock().equals(pot)){return;}
if(!canInteract(e.getPlayer())){
e.setCancelled(true);
resendFlowerPot();
return;
}else{
potMeta = (FlowerPot) pot.getState().getData();
return;
}
}
}

View File

@ -0,0 +1,120 @@
package de.Ste3et_C0st.Furniture.Objects.garden;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
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.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class Trunk extends Furniture implements Listener {
public Trunk(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
spawn(id.getStartLocation());
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.remove();
delete();
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.getPlayer().getItemInHand().getType().isBlock()||
e.getPlayer().getItemInHand().getType().equals(Material.AIR)){setPassanger(e.getfArmorStand(), e.getPlayer());return;}
if(e.getPlayer().isSneaking()){setPassanger(e.getfArmorStand(), e.getPlayer());return;}
if(!e.canBuild()){return;}
ItemStack stack = e.getPlayer().getItemInHand();
stack.setAmount(1);
for(fArmorStand stand : getfAsList()){
if(stand.getName().startsWith("#TO")){
stand.setHelmet(stack);
}
}
update();
if(e.getPlayer().getGameMode().equals(GameMode.CREATIVE) && getLib().useGamemode()) return;
Integer i = e.getPlayer().getInventory().getHeldItemSlot();
ItemStack item = e.getPlayer().getItemInHand();
item.setAmount(item.getAmount()-1);
e.getPlayer().getInventory().setItem(i, item);
e.getPlayer().updateInventory();
}
private void setPassanger(fArmorStand stand, Player p){
int i = Integer.parseInt(stand.getName().split(":")[1]);
for(fArmorStand as : getfAsList()){
if(as.getName().equalsIgnoreCase("#Sitz:" + i)){
if(as.getPassanger()==null){
as.setPassanger(p);
return;
}
}
}
}
public void spawn(Location loc) {
List<fArmorStand> asList = new ArrayList<fArmorStand>();
for(int i = 1; i<=5;i++){
Location loc1 = getRelative(getCenter(), getLutil().yawToFace(getLutil().FaceToYaw(getBlockFace())), 0d,.1 -i*.62).add(0, -1.6, 0);
fArmorStand stand = spawnArmorStand(loc1);
stand.setHelmet(new ItemStack(Material.LOG));
stand.setHeadPose(getLutil().degresstoRad(new EulerAngle(0, 0, 90)));
if(i==1||i==2){
stand.setName("#TO:1");
}else if(i==4||i==5){
stand.setName("#TO:3");
}else{
stand.setName("#TO:2");
}
asList.add(stand);
}
for(int i = 1; i<=3;i++){
Location loc1 = getRelative(getCenter(), getLutil().yawToFace(getLutil().FaceToYaw(getBlockFace())), 0d,.3 -i*.9).add(0, -1.5, 0);
loc1.setYaw(getYaw()+180);
fArmorStand stand = spawnArmorStand(loc1);
asList.add(stand);
stand.setName("#SITZ:" + i);
}
for(fArmorStand stand : asList){
stand.setInvisible(true);
stand.setGravity(false);
}
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
}

View File

@ -0,0 +1,171 @@
package de.Ste3et_C0st.Furniture.Objects.garden;
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.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.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class WaterBottle extends Furniture implements Listener {
List<Material> matList = Arrays.asList(
Material.YELLOW_FLOWER,
Material.RED_ROSE,
Material.SAPLING,
Material.LONG_GRASS,
Material.DOUBLE_PLANT,
Material.BROWN_MUSHROOM,
Material.RED_MUSHROOM,
Material.DEAD_BUSH);
public WaterBottle(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
spawn(getLocation());
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()) return;
if(!e.getID().equals(getObjID())) return;
if(!e.canBuild()){return;}
e.remove();
delete();
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!canInteract(e.getPlayer())){return;}
Material data = e.getPlayer().getItemInHand().getType();
fArmorStand stand = removeItem();
if(matList.contains(data)){
ItemStack is = e.getPlayer().getItemInHand();
is.setAmount(1);
stand.setHelmet(is);
update();
}
}
private fArmorStand removeItem(){
fArmorStand fstand = null;
for(fArmorStand stand : getfAsList()){
if(stand.getName().equalsIgnoreCase("#ITEM#")){
fstand = stand;
if(stand.getItemInHand()!=null&&!stand.getItemInHand().equals(Material.AIR)){
ItemStack is = stand.getItemInHand();
is.setAmount(1);
getWorld().dropItem(getLocation(), is);
}
return stand;
}
}
return fstand;
}
private int getInt(Location loc){
for(int j = 0; j<10;j++){
Location newLocation = loc.clone().add(0, j, 0);
if(newLocation.getBlock().getType()!=null&&newLocation.getBlock().getType().equals(Material.AIR)){
return j;
}
}
return 0;
}
@Override
public void spawn(Location loc) {
double i = 0;
if(getLocation().getBlock().getRelative(BlockFace.UP).getType()!=null&&getLocation().getBlock().getType().equals(Material.STATIONARY_WATER)){
getObjID().setStartLocation(getLocation().add(0, getInt(getLocation()), 0));
i-=.54;
}
List<fArmorStand> stand = new ArrayList<fArmorStand>();
Location loc1 = getCenter().add(0, i-1.2, 0);
loc1.setYaw(45);
Location loc2 = getCenter().add(0, i-1.2, 0);
loc2.setYaw(loc1.getYaw()+90);
Location loc3 = getLutil().getRelativ(getCenter(), getBlockFace(), .15, 0).add(0, i-0.8, 0);
loc3.setYaw(getYaw()+180);
Location loc4 = getLutil().getRelativ(getCenter(), getBlockFace(), -.29, .2).add(0, i-0.88, 0);
loc4.setYaw(getYaw());
Location loc5 = getLutil().getRelativ(getCenter(), getBlockFace(), .13, .284).add(0, i-0.88, 0);
loc5.setYaw(getYaw()+90);
Location loc6 = getCenter().add(0, i-.7, 0);
loc6.setYaw(getYaw()+45+90);
fArmorStand as = spawnArmorStand(loc1);
as.setSmall(true);
as.setHelmet(new ItemStack(Material.WEB));
stand.add(as);
as = spawnArmorStand(loc2);
as.setSmall(true);
as.setHelmet(new ItemStack(Material.WEB));
stand.add(as);
as = spawnArmorStand(loc3);
as.setSmall(true);
as.setHelmet(new ItemStack(Material.WATER_LILY));
as.setHeadPose(getLutil().degresstoRad(new EulerAngle(90, 0, 0)));
stand.add(as);
as = spawnArmorStand(loc4);
as.setSmall(true);
as.setItemInHand(new ItemStack(Material.POTION));
as.setRightArmPose(getLutil().degresstoRad(new EulerAngle(-110,0,0)));
as.setMarker(false);
stand.add(as);
as = spawnArmorStand(loc5);
as.setSmall(true);
as.setItemInHand(new ItemStack(Material.POTION));
as.setRightArmPose(getLutil().degresstoRad(new EulerAngle(-110,0,0)));
as.setMarker(false);
stand.add(as);
as = spawnArmorStand(loc6);
as.setSmall(true);
//as.setItemInHand(new ItemStack(Material.RED_ROSE));
as.setName("#ITEM#");
as.setRightArmPose(getLutil().degresstoRad(new EulerAngle(-110,0,0)));
as.setMarker(false);
stand.add(as);
for(fArmorStand asp : stand){
asp.setGravity(false);
asp.setInvisible(true);
asp.setBasePlate(false);
}
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
}

View File

@ -6,54 +6,24 @@ 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;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
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()){
public campchair(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
@ -62,25 +32,25 @@ public class campchair extends Furniture implements Listener {
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) {
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
delete();
e.remove();
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e) {
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().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(!e.getID().equals(getObjID())){return;}
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().equalsIgnoreCase("#SITZ#")){
if(packet.getPessanger()==null){
packet.setPessanger(e.getPlayer());
if(packet.getPassanger()==null){
packet.setPassanger(e.getPlayer());
}
}
}
@ -88,43 +58,43 @@ public class campchair extends Furniture implements Listener {
@Override
public void spawn(Location location) {
List<ArmorStandPacket> aspList = new ArrayList<ArmorStandPacket>();
Location middle = lutil.getCenter(location);
List<fArmorStand> aspList = new ArrayList<fArmorStand>();
Location middle = getLutil().getCenter(location);
middle.add(0, -1.05, 0);
middle.setYaw(lutil.FaceToYaw(b));
middle.setYaw(getLutil().FaceToYaw(getBlockFace()));
Location l1 = lutil.getRelativ(middle, b, .25, .4);
ArmorStandPacket packet = manager.createArmorStand(obj, l1);
Location l1 = getLutil().getRelativ(middle, getBlockFace(), .25, .4);
fArmorStand packet = getManager().createArmorStand(getObjID(), l1);
packet.getInventory().setItemInHand(new ItemStack(Material.LADDER));
packet.setPose(lutil.degresstoRad(new EulerAngle(50, 0, 0)), BodyPart.RIGHT_ARM);
packet.setPose(getLutil().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);
l1 = getLutil().getRelativ(middle, getBlockFace().getOppositeFace(), .25, .4);
packet = getManager().createArmorStand(getObjID(), l1);
packet.getInventory().setItemInHand(new ItemStack(Material.LADDER));
packet.setPose(lutil.degresstoRad(new EulerAngle(50, 0, 0)), BodyPart.RIGHT_ARM);
packet.setPose(getLutil().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 = getManager().createArmorStand(getObjID(), 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);
middle.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()));
packet = getManager().createArmorStand(getObjID(), middle);
packet.setName("#SITZ#");
aspList.add(packet);
for(ArmorStandPacket as : aspList){
for(fArmorStand as : aspList){
as.setInvisible(true);
as.setBasePlate(false);
as.setGravity(false);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
}

View File

@ -7,45 +7,26 @@ import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBlockBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBlockClickEvent;
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.EventType;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class fance extends Furniture implements Listener{
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Plugin plugin;
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);}}
private void setTypes(ItemStack is){for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){packet.getInventory().setHelmet(is);}}
List<Material> matList = Arrays.asList(
Material.SPRUCE_FENCE,
Material.BIRCH_FENCE,
@ -57,18 +38,9 @@ public class fance extends Furniture implements Listener{
Block block;
Material m;
public fance(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()){
public fance(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
setBlock();
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
@ -79,13 +51,13 @@ public class fance extends Furniture implements Listener{
public void spawn(Location location){
this.m = Material.STONE;
Location locat = loc.clone();
locat=lutil.getCenter(locat);
Location locat = getLocation().clone();
locat=getLutil().getCenter(locat);
locat.add(0, -1.2, 0);
locat.setYaw(lutil.FaceToYaw(b.getOppositeFace()));
locat.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()));
for(int i = 0; i<=2;i++){
Location loc = locat.clone();
ArmorStandPacket packet = manager.createArmorStand(obj, loc);
fArmorStand packet = getManager().createArmorStand(getObjID(), loc);
packet.getInventory().setHelmet(new ItemStack(m,0,(short) 0));
packet.setGravity(false);
packet.setInvisible(true);
@ -93,52 +65,30 @@ public class fance extends Furniture implements Listener{
packet.setSmall(true);
locat.add(0, .44, 0);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
@EventHandler
private void onBlockBreak(BlockBreakEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(block==null){return;}
if(!e.getBlock().getLocation().equals(block.getLocation())){return;}
if(!lib.canBuild(e.getPlayer(), obj, EventType.BREAK)){return;}
this.block.setType(Material.AIR);
this.obj.remove(e.getPlayer());
block=null;
manager.remove(obj);
obj=null;
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
private void onBlockBreak(FurnitureBlockBreakEvent e){
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
if(this.block!=null) this.block.setType(Material.AIR);
e.remove();
obj=null;
block.setType(Material.AIR);
block=null;
delete();
}
@SuppressWarnings("deprecation")
@EventHandler
private void onInteract(PlayerInteractEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()) return;
if(this.block==null) return;
if(e.getAction()==null)return;
if(!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) return;
if(!e.getClickedBlock().getLocation().equals(this.block.getLocation())) return;
if(!lib.canBuild(e.getPlayer(), obj, EventType.INTERACT)){return;}
e.setCancelled(true);
private void onBlockBreak(FurnitureBlockClickEvent e){
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
Player p = e.getPlayer();
ItemStack is = p.getItemInHand();
if(is==null||!is.getType().isBlock()||is.getType().equals(Material.AIR)) return;
@ -151,11 +101,26 @@ public class fance extends Furniture implements Listener{
}else if(main.materialWhiteList.contains(itemStack.getType())){
setTypes(itemStack);
remove(p, is);
manager.updateFurniture(obj);
getManager().updateFurniture(getObjID());
return;
}
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){
if(getObjID()==null){return;}
if(e.getID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
e.remove();
delete();
}
private void remove(Player p, ItemStack is){
if(!p.getGameMode().equals(GameMode.CREATIVE)){
Integer i = p.getInventory().getHeldItemSlot();
@ -168,11 +133,11 @@ public class fance extends Furniture implements Listener{
@SuppressWarnings("deprecation")
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(this.block==null) return;
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
Player p = e.getPlayer();
@ -187,19 +152,20 @@ public class fance extends Furniture implements Listener{
}else if(main.materialWhiteList.contains(itemStack.getType())){
setTypes(itemStack);
remove(p, is);
manager.updateFurniture(obj);
getManager().updateFurniture(getObjID());
return;
}
}
private void setBlock(){
Location location = loc.clone();
Location location = getLocation().clone();
this.block = location.getBlock();
if(this.block.getType()==null||this.block.getType().equals(Material.AIR)||!this.block.getType().equals(Material.FENCE)){
if(!this.matList.contains(this.block.getType())){
this.block.setType(Material.FENCE);
}
}
getObjID().addBlock(Arrays.asList(this.block));
}

View File

@ -1,13 +1,13 @@
package de.Ste3et_C0st.Furniture.Objects.garden;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign;
@ -22,45 +22,18 @@ import org.bukkit.inventory.meta.BookMeta;
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;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class graveStone extends Furniture implements Listener{
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Plugin plugin;
public ObjectID getObjectID(){return this.obj;}
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
public graveStone(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()){
public graveStone(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
setBlock();
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
@ -74,57 +47,57 @@ public class graveStone extends Furniture implements Listener{
String[] lines = new String[4];
private void setBlock(){
Location location = loc.clone();
if(b.equals(BlockFace.WEST)){location = lutil.getRelativ(location, b, .0, -1.02);}
if(b.equals(BlockFace.SOUTH)){location = lutil.getRelativ(location, b, -1.0, -1.02);}
if(b.equals(BlockFace.EAST)){location = lutil.getRelativ(location, b, -1.0, .0);}
Location center = lutil.getRelativ(location, getBlockFace(), .18D, .955D);
center.setYaw(lutil.FaceToYaw(b.getOppositeFace()) + 90);
Location kreutz2 = lutil.getRelativ(center, getBlockFace(), -.23, -1.27);
Location sign = lutil.getRelativ(kreutz2.getBlock().getLocation(), b, 0D, 1D);
Location location = getLocation().clone();
if(getBlockFace().equals(BlockFace.WEST)){location = getLutil().getRelativ(location, getBlockFace(), .0, -1.02);}
if(getBlockFace().equals(BlockFace.SOUTH)){location = getLutil().getRelativ(location, getBlockFace(), -1.0, -1.02);}
if(getBlockFace().equals(BlockFace.EAST)){location = getLutil().getRelativ(location, getBlockFace(), -1.0, .0);}
Location center = getLutil().getRelativ(location, getBlockFace(), .18D, .955D);
center.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()) + 90);
Location kreutz2 = getLutil().getRelativ(center, getBlockFace(), -.23, -1.27);
Location sign = getLutil().getRelativ(kreutz2.getBlock().getLocation(), getBlockFace(), 0D, 1D);
this.signLoc = sign;
if(!sign.getBlock().getType().equals(Material.WALL_SIGN)){
this.sign = lutil.setSign(b, sign);
this.sign = getLutil().setSign(getBlockFace(), sign);
}else{
this.sign = sign.getBlock();
}
this.lines = getText();
getObjID().addBlock(Arrays.asList(this.sign));
}
public void spawn(Location location){
List<ArmorStandPacket> aspList = new ArrayList<ArmorStandPacket>();
if(b.equals(BlockFace.WEST)){location = lutil.getRelativ(location, b, .0, -1.02);}
if(b.equals(BlockFace.SOUTH)){location = lutil.getRelativ(location, b, -1.0, -1.02);}
if(b.equals(BlockFace.EAST)){location = lutil.getRelativ(location, b, -1.0, .0);}
Location center = lutil.getRelativ(location, getBlockFace(), .18D, .955D);
List<fArmorStand> aspList = new ArrayList<fArmorStand>();
if(getBlockFace().equals(BlockFace.WEST)){location = getLutil().getRelativ(location, getBlockFace(), .0, -1.02);}
if(getBlockFace().equals(BlockFace.SOUTH)){location = getLutil().getRelativ(location, getBlockFace(), -1.0, -1.02);}
if(getBlockFace().equals(BlockFace.EAST)){location = getLutil().getRelativ(location, getBlockFace(), -1.0, .0);}
Location center = getLutil().getRelativ(location, getBlockFace(), .18D, .955D);
center.add(0,-.8,0);
center.setYaw(lutil.FaceToYaw(b.getOppositeFace()) + 90);
Location kreutz1 = lutil.getRelativ(center, getBlockFace(), -.55, .0);
center.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()) + 90);
Location kreutz1 = getLutil().getRelativ(center, getBlockFace(), -.55, .0);
kreutz1.add(0, 1.5, 0);
kreutz1.setYaw(lutil.FaceToYaw(b.getOppositeFace()) + 90);
kreutz1.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()) + 90);
Location kreutz2 = lutil.getRelativ(center, getBlockFace(), -.23, -1.27);
Location kreutz2 = getLutil().getRelativ(center, getBlockFace(), -.23, -1.27);
kreutz2.add(0, 1.6, 0);
kreutz2.setYaw(lutil.FaceToYaw(b.getOppositeFace()));
kreutz2.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()));
Location loc = center;
for(int i = 0; i<=2;i++){
Location l = lutil.getRelativ(loc, b, .0, -.44*i);
Location l = getLutil().getRelativ(loc, getBlockFace(), .0, -.44*i);
l.setYaw(lutil.FaceToYaw(b.getOppositeFace()) + 90);
ArmorStandPacket as = manager.createArmorStand(obj, l);
l.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()) + 90);
fArmorStand as = getManager().createArmorStand(getObjID(), l);
as.getInventory().setHelmet(new ItemStack(Material.COBBLESTONE));
as.setSmall(true);
as.setPose(lutil.degresstoRad(new EulerAngle(0, 0, 90)), BodyPart.HEAD);
as.setPose(getLutil().degresstoRad(new EulerAngle(0, 0, 90)), BodyPart.HEAD);
aspList.add(as);
}
Double l = .3;
for(int i = 0;i<=2;i++){
setRow(center, .38, l, -.35,2,lutil.degresstoRad(new EulerAngle(90, 0, 0)), aspList);
setRow(center, .38, l, -.35,2,getLutil().degresstoRad(new EulerAngle(90, 0, 0)), aspList);
if(i!=1){
l+=.4;
}else{
@ -133,42 +106,42 @@ public class graveStone extends Furniture implements Listener{
}
ArmorStandPacket as = manager.createArmorStand(obj, kreutz1);
fArmorStand as = getManager().createArmorStand(getObjID(), kreutz1);
as.getInventory().setItemInHand(new ItemStack(Material.STICK));
as.setPose(new EulerAngle(1.38,.0,.0), BodyPart.RIGHT_ARM);
aspList.add(as);
as = manager.createArmorStand(obj, kreutz2);
as = getManager().createArmorStand(getObjID(), kreutz2);
as.getInventory().setItemInHand(new ItemStack(Material.STICK));
as.setPose(new EulerAngle(1.38,1.57,1.57), BodyPart.RIGHT_ARM);
aspList.add(as);
for(ArmorStandPacket asp : aspList){
for(fArmorStand asp : aspList){
asp.setGravity(false);
asp.setInvisible(true);
asp.setBasePlate(false);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()) return;
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.remove();
sign.setType(Material.AIR);
sign = null;
obj=null;
delete();
}
@EventHandler
private void onBlockRemove(BlockBreakEvent e)
{
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if (sign==null) return;
if (e.getBlock() == null) return;
if (e.getBlock().getLocation() == null) return;
@ -178,8 +151,8 @@ public class graveStone extends Furniture implements Listener{
@EventHandler
private void onBlockPlaceEvent(BlockPlaceEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if (sign==null) return;
if (e.getBlock() == null) return;
if (e.getBlock().getLocation() == null) return;
@ -189,8 +162,8 @@ public class graveStone extends Furniture implements Listener{
@EventHandler
private void onDrop(ItemSpawnEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if (sign==null) return;
if (e.getLocation() == null) return;
ItemStack is = e.getEntity().getItemStack();
@ -203,11 +176,11 @@ public class graveStone extends Furniture implements Listener{
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
Player p = e.getPlayer();
if(e.isCancelled()) return;
if(!e.getID().equals(obj)) return;
if(!e.getID().equals(getObjID())) return;
if(!e.canBuild()){return;}
ItemStack is = p.getItemInHand();
if (is == null) return;
@ -216,10 +189,10 @@ public class graveStone extends Furniture implements Listener{
}
public void resetSign(){
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() {
@Override
public void run() {
sign = lutil.setSign(b, signLoc);
sign = getLutil().setSign(getBlockFace(), signLoc);
placetext();
}
});
@ -229,8 +202,8 @@ public class graveStone extends Furniture implements Listener{
if(sign!=null){
sign.setType(Material.AIR);
sign = null;
manager.remove(obj);
obj=null;
getManager().remove(getObjID());
delete();
}
}
@ -289,13 +262,13 @@ public class graveStone extends Furniture implements Listener{
lines[line] = text;
}
public void setRow(Location loc, double x,double y, double z, int replay, EulerAngle angle, List<ArmorStandPacket> list){
public void setRow(Location loc, double x,double y, double z, int replay, EulerAngle angle, List<fArmorStand> list){
Double d = .0;
for(int i = 0; i<=replay;i++){
Location loc1= lutil.getRelativ(loc, b, z, d-.825);
loc1.setYaw(lutil.FaceToYaw(b));
Location loc1= getLutil().getRelativ(loc, getBlockFace(), z, d-.825);
loc1.setYaw(getLutil().FaceToYaw(getBlockFace()));
loc1.add(0, y,0);
ArmorStandPacket packet = manager.createArmorStand(obj, loc1);
fArmorStand packet = getManager().createArmorStand(getObjID(), loc1);
packet.getInventory().setHelmet(new ItemStack(Material.STONE_PLATE));
packet.setSmall(true);
packet.setPose(angle, BodyPart.HEAD);

View File

@ -0,0 +1,331 @@
package de.Ste3et_C0st.Furniture.Objects.garden;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
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.FurnitureLib.Events.FurnitureBlockBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBlockClickEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.ManageInv;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class log extends Furniture {
Block b;
int mode = 0;
Inventory inv = Bukkit.createInventory(null, 9, "§2Settings");
ItemStack pane = new ItemStack(Material.STAINED_GLASS_PANE);
ItemStack permissions = new ItemStack(Material.ARROW);
List<ItemStack> isList = new ArrayList<ItemStack>();
Player p;
public log(Plugin plugin, ObjectID id){
super(plugin, id);
b = getLocation().getBlock();
getObjID().addBlock(Arrays.asList(b));
ItemMeta meta = pane.getItemMeta();
meta.setDisplayName("§c");
pane.setItemMeta(meta);
pane.setDurability((short) 15);
pane.setItemMeta(meta);
setList();
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
spawn(id.getStartLocation());
}
private void setList(){
ItemStack stack = new ItemStack(Material.BANNER);
stack.setDurability((short) 1);
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName("§6Mode: §cTop");
stack.setItemMeta(meta);
isList.add(stack);
stack = new ItemStack(Material.BANNER);
stack.setDurability((short) 2);
meta = stack.getItemMeta();
meta.setDisplayName("§6Mode: §cFront I");
stack.setItemMeta(meta);
isList.add(stack);
stack = new ItemStack(Material.BANNER);
stack.setDurability((short) 11);
meta = stack.getItemMeta();
meta.setDisplayName("§6Mode: §cFront II");
stack.setItemMeta(meta);
isList.add(stack);
meta = permissions.getItemMeta();
meta.setDisplayName("§cChange Permissions (Owner Only)");
permissions.setItemMeta(meta);
}
@Override
public void spawn(Location loc) {
b.setType(Material.LOG);
List<fArmorStand> lStand = new ArrayList<fArmorStand>();
Location loc1 = getLutil().getRelativ(getCenter(), getBlockFace(), .5, .35);
loc1.setYaw(getYaw());
Location loc2 = getLutil().getRelativ(getCenter(), getBlockFace(), -.7, .35d);
loc2.setYaw(getYaw());
Location loc3 = getLutil().getRelativ(getCenter(), getBlockFace(), -1.3, .35d).subtract(0, 1.0, 0);
loc3.setYaw(getYaw());
fArmorStand stand = spawnArmorStand(loc1);
stand.setRightArmPose(new EulerAngle(1.35, 0, 0));
stand.setName("0");
lStand.add(stand);
stand = spawnArmorStand(loc2);
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(15, 0, 0)));
stand.setName("1");
lStand.add(stand);
stand = spawnArmorStand(loc3);
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(-30, 0, 0)));
stand.setName("2");
lStand.add(stand);
for(fArmorStand asp : lStand){
asp.setGravity(false);
asp.setInvisible(true);
asp.setBasePlate(false);
asp.setMarker(false);
}
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
private void openInventory(Player p){
if(this.p !=null) return;
this.p = p;
inv.clear();
int j = mode;
for(int i = 0; i<inv.getSize();i++){
if(i==2){
inv.addItem(isList.get(j));
continue;
}else if(i==6){
inv.addItem(permissions);
continue;
}
inv.setItem(i,pane);
}
p.openInventory(inv);
}
@EventHandler
private void onClick(InventoryClickEvent e){
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.getClickedInventory()==null||!e.getClickedInventory().equals(inv)){return;}
e.setCancelled(true);
if(e.getCurrentItem()==null){return;}
if(e.getCurrentItem().getType().equals(Material.BANNER)){
Integer i = isList.indexOf(e.getCurrentItem());
ItemStack is = null;
if(i>=2){i = -1;}
i++;
is = isList.get(i);
mode = i;
modeSwitch(e.getCurrentItem().getDurability());
inv.setItem(e.getSlot(), is);
p.updateInventory();
}else if(e.getCurrentItem().getType().equals(Material.ARROW)){
if(!getObjID().getUUID().equals(p.getUniqueId())){
if(!getLib().hasPerm(p, "furniture.admin") && !p.isOp() && !getLib().hasPerm(p, "furniture.manage.other")){
return;
}
}
p.closeInventory();
new ManageInv((Player) e.getWhoClicked(), getObjID());
}
}
public void modeSwitch(short dura){
int oldArmorStand = 0;
int currentArmorStand = 0;
switch (dura) {
case 1:
oldArmorStand = 0;
currentArmorStand = 1;
break;
case 2:
oldArmorStand = 1;
currentArmorStand = 2;
break;
case 11:
oldArmorStand = 2;
currentArmorStand = 0;
break;
}
fArmorStand standOld = null;
fArmorStand standCurrent = null;
for(fArmorStand s : getObjID().getPacketList()){
if(s.getName().equalsIgnoreCase(oldArmorStand+"")){
standOld=s;
}else if(s.getName().equalsIgnoreCase(currentArmorStand+"")){
standCurrent=s;
}
}
if(standOld!=null&&standCurrent!=null){
standCurrent.setItemInHand(standOld.getItemInHand());
standOld.setItemInHand(new ItemStack(Material.AIR));
update();
}
}
@EventHandler
public void onClose(InventoryCloseEvent e){
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.getInventory()==null){return;}
if(e.getInventory().equals(inv)){this.p = null;}
}
@SuppressWarnings("deprecation")
@EventHandler
public void onBlockClick(FurnitureBlockClickEvent e){
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
Player p = e.getPlayer();
if(p.isSneaking()){
if(p.getItemInHand().getType().isBlock()&&!p.getItemInHand().getType().equals(Material.AIR)){
e.setCancelled(false);
return;
}
openInventory(p);
}else{
if(p.getItemInHand().getType().isBlock() && !p.getItemInHand().getType().equals(Material.AIR)){
this.b.setType(p.getItemInHand().getType());
this.b.setData((byte) p.getItemInHand().getDurability());
removeItem(p);
return;
}else if(!p.getItemInHand().getType().isBlock() && !p.getItemInHand().getType().equals(Material.AIR)){
fArmorStand stand = null;
for(fArmorStand s : getObjID().getPacketList()){
if(s.getName().equalsIgnoreCase(mode+"")){
stand = s;
break;
}
}
if(stand==null){return;}
if(stand.getItemInHand()!=null&&!stand.getItemInHand().getType().equals(Material.AIR)){
ItemStack is = stand.getItemInHand();
is.setAmount(1);
getWorld().dropItem(getLocation(), is);
}
ItemStack is = p.getItemInHand().clone();
is.setAmount(1);
stand.setItemInHand(is);
update();
removeItem(p);
return;
}else{
fArmorStand stand = null;
for(fArmorStand s : getObjID().getPacketList()){
if(s.getName().equalsIgnoreCase(mode+"")){
stand = s;
break;
}
}
if(stand==null){return;}
if(stand.getItemInHand()!=null&&!stand.getItemInHand().getType().equals(Material.AIR)){
ItemStack is = stand.getItemInHand();
is.setAmount(1);
getWorld().dropItem(getLocation(), is);
}
stand.setItemInHand(new ItemStack(Material.AIR));
update();
return;
}
}
}
public void removeItem(Player p){
Boolean useGameMode = FurnitureLib.getInstance().useGamemode();
if(useGameMode&&p.getGameMode().equals(GameMode.CREATIVE)){return;}
Integer slot = p.getInventory().getHeldItemSlot();
ItemStack itemStack = p.getItemInHand().clone();
itemStack.setAmount(itemStack.getAmount()-1);
p.getInventory().setItem(slot, itemStack);
p.updateInventory();
}
@Override
public void onFurnitureBreak(FurnitureBreakEvent paramFurnitureBreakEvent) {}
@Override
public void onFurnitureClick(FurnitureClickEvent paramFurnitureClickEvent) {}
@EventHandler
public void onBlockBreak(FurnitureBlockBreakEvent e){
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
Player p = e.getPlayer();
fArmorStand stand = null;
for(fArmorStand s : getObjID().getPacketList()){
if(s.getName().equalsIgnoreCase(mode+"")){
stand = s;
break;
}
}
if(stand==null){p.sendMessage("test1");return;}
if(stand.getItemInHand()!=null&&!stand.getItemInHand().getType().equals(Material.AIR)){
ItemStack is = stand.getItemInHand();
is.setAmount(1);
getWorld().dropItem(getLocation(), is);
}
destroy(p);
b.setType(Material.AIR);
b=null;
}
}

View File

@ -7,7 +7,6 @@ import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.EventHandler;
@ -18,49 +17,22 @@ 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.EventType;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class mailBox extends Furniture implements Listener {
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Plugin plugin;
List<Block> blockList = new ArrayList<Block>();
public ObjectID getObjectID(){return this.obj;}
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
UUID uuid;
public mailBox(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()){
public mailBox(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
@ -68,42 +40,42 @@ public class mailBox extends Furniture implements Listener {
}
public void spawn(Location location){
List<ArmorStandPacket> aspList = new ArrayList<ArmorStandPacket>();
Location middle = lutil.getCenter(loc);
List<fArmorStand> aspList = new ArrayList<fArmorStand>();
Location middle = getLutil().getCenter(getLocation());
middle.add(0, -1.4, 0);
switch (b) {
case NORTH:middle = lutil.getRelativ(middle, b, 0D, 0.03D);break;
case EAST:middle = lutil.getRelativ(middle, b, 0D, 0.03D);break;
switch (getBlockFace()) {
case NORTH:middle = getLutil().getRelativ(middle, getBlockFace(), 0D, 0.03D);break;
case EAST:middle = getLutil().getRelativ(middle, getBlockFace(), 0D, 0.03D);break;
default:break;
}
ArmorStandPacket as = manager.createArmorStand(obj, middle);
fArmorStand as = getManager().createArmorStand(getObjID(), middle);
as.getInventory().setHelmet(new ItemStack(Material.STONE));
as.setSmall(true);
aspList.add(as);
for(int i = 0; i<=1;i++){
Location loc = lutil.getRelativ(middle.clone(), b, .47, .38).add(0, .88*i, 0);
ArmorStandPacket packet = manager.createArmorStand(obj, loc);
Location loc = getLutil().getRelativ(middle.clone(), getBlockFace(), .47, .38).add(0, .88*i, 0);
fArmorStand packet = getManager().createArmorStand(getObjID(), loc);
packet.getInventory().setItemInHand(new ItemStack(Material.STICK));
packet.setPose(new EulerAngle(1.39, 0, 0), BodyPart.RIGHT_ARM);
aspList.add(packet);
}
as = manager.createArmorStand(obj, lutil.getRelativ(middle.clone().add(0, 1.2, 0), b, -.21, 0D));
as = getManager().createArmorStand(getObjID(), getLutil().getRelativ(middle.clone().add(0, 1.2, 0), getBlockFace(), -.21, 0D));
as.getInventory().setHelmet(new ItemStack(Material.SMOOTH_BRICK, 1, (short) 0));
as.setSmall(true);
aspList.add(as);
as = manager.createArmorStand(obj, lutil.getRelativ(middle.clone().add(0, 1.2, 0), b, .21, 0D));
as = getManager().createArmorStand(getObjID(), getLutil().getRelativ(middle.clone().add(0, 1.2, 0), getBlockFace(), .21, 0D));
as.getInventory().setHelmet(new ItemStack(Material.SMOOTH_BRICK, 1, (short) 0));
as.setSmall(true);
aspList.add(as);
for(int i = 0; i<=4;i++){
Location loc = lutil.getRelativ(middle.clone().add(0, 1.898, 0), b, -.44+.165*i, .43D);
ArmorStandPacket packet = manager.createArmorStand(obj, loc);
Location loc = getLutil().getRelativ(middle.clone().add(0, 1.898, 0), getBlockFace(), -.44+.165*i, .43D);
fArmorStand packet = getManager().createArmorStand(getObjID(), loc);
packet.setSmall(true);
//x z y
//-.7 .73 -.3
@ -111,8 +83,8 @@ public class mailBox extends Furniture implements Listener {
packet.getInventory().setItemInHand(new ItemStack(Material.SMOOTH_STAIRS));
aspList.add(packet);
loc = lutil.getRelativ(middle.clone().add(0, 1.898, 0), b.getOppositeFace(), -.44+.165*i, .462D);
packet = manager.createArmorStand(obj, loc);
loc = getLutil().getRelativ(middle.clone().add(0, 1.898, 0), getBlockFace().getOppositeFace(), -.44+.165*i, .462D);
packet = getManager().createArmorStand(getObjID(), loc);
packet.setSmall(true);
//x z y
//-.7 .73 -.3
@ -121,8 +93,8 @@ public class mailBox extends Furniture implements Listener {
aspList.add(packet);
loc = lutil.getRelativ(middle.clone().add(0, 1.898, 0), b.getOppositeFace(), -.44+.165*i, .362D);
packet = manager.createArmorStand(obj, loc);
loc = getLutil().getRelativ(middle.clone().add(0, 1.898, 0), getBlockFace().getOppositeFace(), -.44+.165*i, .362D);
packet = getManager().createArmorStand(getObjID(), loc);
packet.setSmall(true);
//x z y
//-.7 .73 -.3
@ -131,47 +103,50 @@ public class mailBox extends Furniture implements Listener {
aspList.add(packet);
}
BlockFace face = b;
face = lutil.yawToFace(lutil.FaceToYaw(b) + 90);
as = manager.createArmorStand(obj, lutil.getRelativ(middle.clone().add(0, 1.5, 0), face, -.21, -.32D));
BlockFace face = getBlockFace();
face = getLutil().yawToFace(getLutil().FaceToYaw(getBlockFace()) + 90);
as = getManager().createArmorStand(getObjID(), getLutil().getRelativ(middle.clone().add(0, 1.5, 0), face, -.21, -.32D));
as.getInventory().setHelmet(new ItemStack(Material.REDSTONE_TORCH_ON, 1, (short) 0));
as.setPose(lutil.degresstoRad(new EulerAngle(0, 0, 90)), BodyPart.HEAD);
as.setPose(getLutil().degresstoRad(new EulerAngle(0, 0, 90)), BodyPart.HEAD);
as.setName("#ELEMENT#");
as.setSmall(true);
aspList.add(as);
as = manager.createArmorStand(obj, lutil.getRelativ(middle.clone().add(0, 1.10, 0), face.getOppositeFace(), -.0, .31D));
as = getManager().createArmorStand(getObjID(), getLutil().getRelativ(middle.clone().add(0, 1.10, 0), face.getOppositeFace(), -.0, .31D));
as.getInventory().setItemInHand(new ItemStack(Material.PAPER, 1, (short) 0));
as.setPose(lutil.degresstoRad(new EulerAngle(0, -120, -90)), BodyPart.RIGHT_ARM);
as.setPose(getLutil().degresstoRad(new EulerAngle(0, -120, -90)), BodyPart.RIGHT_ARM);
as.setSmall(true);
aspList.add(as);
as = manager.createArmorStand(obj, lutil.getRelativ(middle.clone().add(0, 1.40, 0), face.getOppositeFace(), -.1, .34D));
as = getManager().createArmorStand(getObjID(), getLutil().getRelativ(middle.clone().add(0, 1.40, 0), face.getOppositeFace(), -.1, .34D));
as.getInventory().setItemInHand(new ItemStack(Material.WOOD_BUTTON, 1, (short) 0));
as.setPose(lutil.degresstoRad(new EulerAngle(-15,-67, -90)), BodyPart.RIGHT_ARM);
as.setPose(getLutil().degresstoRad(new EulerAngle(-15,-67, -90)), BodyPart.RIGHT_ARM);
as.setSmall(true);
aspList.add(as);
as = manager.createArmorStand(obj, lutil.getRelativ(middle.clone().add(0, 1.2, 0), b, .2, .07D));
as = getManager().createArmorStand(getObjID(), getLutil().getRelativ(middle.clone().add(0, 1.2, 0), getBlockFace(), .2, .07D));
as.getInventory().setItemInHand(new ItemStack(Material.EMPTY_MAP, 1, (short) 0));
as.setPose(lutil.degresstoRad(new EulerAngle(0, -120, -90)), BodyPart.RIGHT_ARM);
as.setPose(getLutil().degresstoRad(new EulerAngle(0, -120, -90)), BodyPart.RIGHT_ARM);
as.setSmall(true);
aspList.add(as);
for(ArmorStandPacket asp : aspList){
for(fArmorStand asp : aspList){
asp.setGravity(false);
asp.setInvisible(true);
asp.setBasePlate(false);
}
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
public void setBlock(){
for(int i = 0; i<=1;i++){
Block b = location.clone().add(0, i, 0).getBlock();
Block b = getLocation().clone().add(0, i, 0).getBlock();
b.setType(Material.BARRIER);
blockList.add(b);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
getObjID().addBlock(blockList);
}
/*public void addMailbox(Player p){
@ -186,15 +161,15 @@ public class mailBox extends Furniture implements Listener {
}
public void setSendet(Boolean b){
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet!=null&&packet.getName().equalsIgnoreCase("#ELEMENT#")){
if(b){
packet.setPose(lutil.degresstoRad(new EulerAngle(0, 0, 0)), BodyPart.HEAD);
manager.updateFurniture(obj);
packet.setPose(getLutil().degresstoRad(new EulerAngle(0, 0, 0)), BodyPart.HEAD);
getManager().updateFurniture(getObjID());
return;
}
packet.setPose(lutil.degresstoRad(new EulerAngle(0, 0, 90)), BodyPart.HEAD);
manager.updateFurniture(obj);
packet.setPose(getLutil().degresstoRad(new EulerAngle(0, 0, 90)), BodyPart.HEAD);
getManager().updateFurniture(getObjID());
return;
}
}
@ -211,10 +186,10 @@ public class mailBox extends Furniture implements Listener {
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()) return;
if(!e.getID().equals(obj)) return;
if(!e.getID().equals(getObjID())) return;
if(!e.canBuild()){return;}
for(Block b : blockList){
@ -222,28 +197,28 @@ public class mailBox extends Furniture implements Listener {
}
blockList.clear();
e.remove();
obj=null;
delete();
}
public void onFurnitureClick(FurnitureClickEvent e){}
@EventHandler
private void onInteract(PlayerInteractEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){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(!getLib().canBuild(e.getPlayer(), getObjID(), EventType.INTERACT)){return;}
if(e.getAction().equals(Action.LEFT_CLICK_BLOCK)){
e.setCancelled(true);
for(Block b : blockList){
b.setType(Material.AIR);
}
blockList.clear();
this.obj.remove(e.getPlayer());
obj=null;
this.getObjID().remove(e.getPlayer());
delete();
}
}
}

View File

@ -9,49 +9,30 @@ import org.bukkit.DyeColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.banner.Pattern;
import org.bukkit.block.banner.PatternType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BannerMeta;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBlockBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBlockClickEvent;
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.EventType;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class sunshade extends Furniture implements Listener{
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Plugin plugin;
public ObjectID getObjectID(){return this.obj;}
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
List<Material> matList = Arrays.asList(
Material.SPRUCE_FENCE,
Material.BIRCH_FENCE,
@ -64,18 +45,9 @@ public class sunshade extends Furniture implements Listener{
Integer timer;
Block block;
public sunshade(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()){
public sunshade(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
setblock();
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
@ -85,27 +57,28 @@ public class sunshade extends Furniture implements Listener{
}
private void setblock(){
Location loc = this.loc.clone();
Location loc = getLocation().clone();
loc.add(0, 2, 0);
block = loc.getBlock();
block.setType(Material.BARRIER);
getObjID().addBlock(Arrays.asList(block));
}
public void spawn(Location location){
Location center = lutil.getCenter(location).clone();
List<ArmorStandPacket> asList = new ArrayList<ArmorStandPacket>();
Location center = getLutil().getCenter(location).clone();
List<fArmorStand> asList = new ArrayList<fArmorStand>();
center.add(0, -1.1, 0);
for(int i = 0; i<=2;i++){
Location loc = lutil.getRelativ(center.clone(), b, .47, .38).add(0, .88*i, 0);
ArmorStandPacket packet = manager.createArmorStand(obj, loc);
Location loc = getLutil().getRelativ(center.clone(), getBlockFace(), .47, .38).add(0, .88*i, 0);
fArmorStand packet = getManager().createArmorStand(getObjID(), loc);
packet.getInventory().setItemInHand(new ItemStack(Material.STICK));
packet.setPose(new EulerAngle(1.39, 0, 0), BodyPart.RIGHT_ARM);
asList.add(packet);
}
center.add(0, 1.758, 0);
ArmorStandPacket aspacket = manager.createArmorStand(obj, center);
fArmorStand aspacket = getManager().createArmorStand(getObjID(), center);
aspacket.getInventory().setHelmet(new ItemStack(Material.CARPET));
aspacket.setName("#TOP#");
asList.add(aspacket);
@ -121,63 +94,54 @@ public class sunshade extends Furniture implements Listener{
for(int i = 0; i<=17; i++){
loc.setYaw(i*21);
ArmorStandPacket packet = manager.createArmorStand(obj, loc.clone());
fArmorStand packet = getManager().createArmorStand(getObjID(), loc.clone());
packet.getInventory().setHelmet(is);
packet.setPose(new EulerAngle(-3.054, 0, 0), BodyPart.HEAD);
packet.setName("#ELEMENT#" + i);
asList.add(packet);
}
for(ArmorStandPacket packet : asList){
for(fArmorStand packet : asList){
packet.setInvisible(true);
packet.setGravity(false);
packet.setBasePlate(false);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
Player p = e.getPlayer();
ItemStack is = p.getItemInHand();
if(is==null||!is.getType().equals(Material.BANNER)){
if(!getLib().canBuild(e.getPlayer(), getObjID(), EventType.INTERACT)){return;}
if(is.getType().equals(Material.BANNER)){
e.setCancelled(true);
if(isRunning()){return;}
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getInventory().getHelmet()!=null&&packet.getInventory().getHelmet().getType().equals(Material.BANNER)){
packet.getInventory().setHelmet(is);
}else if(packet.getInventory().getHelmet()!=null&&packet.getInventory().getHelmet().getType().equals(Material.CARPET)){
ItemStack item = new ItemStack(Material.CARPET);
item.setDurability(getLutil().getFromDey((short) is.getDurability()));
packet.getInventory().setHelmet(item);
}
}
removeItem(p);
update();
}else{
if(isRunning()){return;}
if(!isOpen()){
open();
}else{
close();
}
}else{
if(isRunning()){return;}
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(itemstack);
}else if(packet.getName().equalsIgnoreCase("#TOP#")){
packet.getInventory().setHelmet(new ItemStack(Material.CARPET, 1, newS));
}
}
manager.updateFurniture(obj);
if(!p.getGameMode().equals(GameMode.CREATIVE)){
Integer i = p.getInventory().getHeldItemSlot();
is.setAmount(is.getAmount()-1);
p.getInventory().setItem(i, is);
p.updateInventory();
}
}
}
@ -187,107 +151,109 @@ public class sunshade extends Furniture implements Listener{
}
@EventHandler
private void onInteract(PlayerInteractEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
public void onBlockBreak(FurnitureBlockBreakEvent e){
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){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);
if(!lib.canBuild(e.getPlayer(), obj, EventType.BREAK)){return;}
stopTimer();
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
if(packet.getName().equalsIgnoreCase("#ITEM#")){
if(packet.getInventory().getItemInHand()!=null&&!packet.getInventory().getItemInHand().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getItemInHand();
w.dropItem(loc, is);
}
}
}
this.block.setType(Material.AIR);
this.block = null;
this.obj.remove(e.getPlayer());
obj=null;
}else if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
if(!lib.canBuild(e.getPlayer(), obj, EventType.INTERACT)){return;}
Player p = e.getPlayer();
ItemStack is = p.getItemInHand();
if(is==null||!is.getType().equals(Material.BANNER)){
if(isRunning()){return;}
if(!isOpen()){
open();
}else{
close();
}
}else{
e.setCancelled(true);
if(isRunning()){return;}
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(itemstack);
}else if(packet.getName().equalsIgnoreCase("#TOP#")){
packet.getInventory().setHelmet(new ItemStack(Material.CARPET, 1, newS));
}
}
manager.updateFurniture(obj);
if(!p.getGameMode().equals(GameMode.CREATIVE)){
Integer i = p.getInventory().getHeldItemSlot();
is.setAmount(is.getAmount()-1);
p.getInventory().setItem(i, is);
p.updateInventory();
}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
stopTimer();
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().equalsIgnoreCase("#ITEM#")){
if(packet.getInventory().getItemInHand()!=null&&!packet.getInventory().getItemInHand().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getItemInHand();
getWorld().dropItem(getLocation(), is);
}
}
}
getObjID().remove(e.getPlayer());
delete();
}
@EventHandler
public void onBlockBreak(FurnitureBlockClickEvent e){
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
Player p = e.getPlayer();
ItemStack is = p.getItemInHand();
if(is.getType().equals(Material.BANNER)){
e.setCancelled(true);
if(isRunning()){return;}
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getInventory().getHelmet()!=null&&packet.getInventory().getHelmet().getType().equals(Material.BANNER)){
packet.getInventory().setHelmet(is);
}else if(packet.getInventory().getHelmet()!=null&&packet.getInventory().getHelmet().getType().equals(Material.CARPET)){
ItemStack item = new ItemStack(Material.CARPET);
item.setDurability(getLutil().getFromDey((short) is.getDurability()));
packet.getInventory().setHelmet(item);
}
}
removeItem(p);
update();
}else{
if(isRunning()){return;}
if(!isOpen()){
open();
}else{
close();
}
}
}
public void removeItem(Player p){
Boolean useGameMode = FurnitureLib.getInstance().useGamemode();
if(useGameMode&&p.getGameMode().equals(GameMode.CREATIVE)){return;}
Integer slot = p.getInventory().getHeldItemSlot();
ItemStack itemStack = p.getItemInHand().clone();
itemStack.setAmount(itemStack.getAmount()-1);
p.getInventory().setItem(slot, itemStack);
p.updateInventory();
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
stopTimer();
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().equalsIgnoreCase("#ITEM#")){
if(packet.getInventory().getItemInHand()!=null&&!packet.getInventory().getItemInHand().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getItemInHand();
w.dropItem(loc, is);
getWorld().dropItem(getLocation(), is);
}
}
}
e.remove();
this.block.setType(Material.AIR);
this.block = null;
manager.remove(obj);
obj=null;
getManager().remove(getObjID());
delete();
}
private void close(){
timer = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
timer = Bukkit.getScheduler().scheduleSyncRepeatingTask(getPlugin(), new Runnable() {
@Override
public void run() {
try{
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().startsWith("#ELEMENT#")){
if(!isClose(packet)){
Double x = packet.getAngle(BodyPart.HEAD).getX();
Double x = packet.getPose(BodyPart.HEAD).getX();
packet.setPose(new EulerAngle(x-.32, 0, 0), BodyPart.HEAD);
}else{
stopTimer();
return;
}
manager.updateFurniture(obj);
getManager().updateFurniture(getObjID());
}
}
}catch(Exception e){
@ -300,20 +266,20 @@ public class sunshade extends Furniture implements Listener{
}
private void open(){
timer = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
timer = Bukkit.getScheduler().scheduleSyncRepeatingTask(getPlugin(), new Runnable() {
@Override
public void run() {
try{
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().startsWith("#ELEMENT#")){
if(!isOpen(packet)){
Double x = packet.getAngle(BodyPart.HEAD).getX();
Double x = packet.getPose(BodyPart.HEAD).getX();
packet.setPose(new EulerAngle(x+.32, 0, 0), BodyPart.HEAD);
}else{
stopTimer();
return;
}
manager.updateFurniture(obj);
getManager().updateFurniture(getObjID());
}
}
}catch(Exception e){
@ -326,30 +292,30 @@ public class sunshade extends Furniture implements Listener{
}
private void reset(){
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(!isOpen(packet)){
packet.setPose(new EulerAngle(-3.054, 0, 0), BodyPart.HEAD);
}
}
manager.updateFurniture(obj);
update();
}
private boolean isClose(ArmorStandPacket packet){
if(packet.getAngle(BodyPart.HEAD).getX()> -3.054){
private boolean isClose(fArmorStand packet){
if(packet.getPose(BodyPart.HEAD).getX()> -3.054){
return false;
}return true;
}
private boolean isOpen(ArmorStandPacket packet){
if(packet.getAngle(BodyPart.HEAD).getX()< -1.85){
private boolean isOpen(fArmorStand packet){
if(packet.getPose(BodyPart.HEAD).getX()< -1.85){
return false;
}return true;
}
private boolean isOpen(){
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().startsWith("#ELEMENT#")){
if(packet.getAngle(BodyPart.HEAD).getX()< -1.85){
if(packet.getPose(BodyPart.HEAD).getX()< -1.85){
return false;
}
}

View File

@ -6,7 +6,6 @@ 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;
@ -14,45 +13,19 @@ 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;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class chair extends Furniture implements Listener{
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Plugin plugin;
public ObjectID getObjectID(){return this.obj;}
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
public chair(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()){
public chair(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
@ -60,90 +33,90 @@ public class chair extends Furniture implements Listener{
}
public void spawn(Location loc){
List<ArmorStandPacket> aspList = new ArrayList<ArmorStandPacket>();
BlockFace b = lutil.yawToFace(loc.getYaw()).getOppositeFace();
Location center = lutil.getCenter(loc).add(0, -.05, 0);
List<fArmorStand> aspList = new ArrayList<fArmorStand>();
BlockFace b = getLutil().yawToFace(loc.getYaw()).getOppositeFace();
Location center = getLutil().getCenter(loc).add(0, -.05, 0);
Location sitz = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
Location feet1 = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
Location feet2 = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
Location feet3 = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
Location feet4 = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
Location lehne = lutil.getRelativ(center.add(0,-1.1,0), b, -.25, .0);
Location lehne = getLutil().getRelativ(center.add(0,-1.1,0), b, -.25, .0);
feet1.add(-.25,-1.8,-.25);
feet2.add(.25,-1.8,-.25);
feet3.add(.25,-1.8,.25);
feet4.add(-.25,-1.8,.25);
sitz.add(0,-1.45,0);
sitz.setYaw(lutil.FaceToYaw(b));
lehne.setYaw(lutil.FaceToYaw(b));
sitz.setYaw(getLutil().FaceToYaw(b));
lehne.setYaw(getLutil().FaceToYaw(b));
ArmorStandPacket as = manager.createArmorStand(obj, sitz.clone());
fArmorStand as = getManager().createArmorStand(getObjID(), sitz.clone());
as.getInventory().setHelmet(new ItemStack(Material.TRAP_DOOR));
aspList.add(as);
as = manager.createArmorStand(obj, lehne.clone());
as = getManager().createArmorStand(getObjID(), lehne.clone());
as.getInventory().setHelmet(new ItemStack(Material.TRAP_DOOR));
as.setPose(new EulerAngle(1.57, .0, .0), BodyPart.HEAD);
aspList.add(as);
as = manager.createArmorStand(obj, feet1.clone());
as = getManager().createArmorStand(getObjID(), feet1.clone());
as.getInventory().setHelmet(new ItemStack(Material.LEVER));
aspList.add(as);
as = manager.createArmorStand(obj, feet2.clone());
as = getManager().createArmorStand(getObjID(), feet2.clone());
as.getInventory().setHelmet(new ItemStack(Material.LEVER));
aspList.add(as);
as = manager.createArmorStand(obj, feet3.clone());
as = getManager().createArmorStand(getObjID(), feet3.clone());
as.getInventory().setHelmet(new ItemStack(Material.LEVER));
aspList.add(as);
as = manager.createArmorStand(obj, feet4.clone());
as = getManager().createArmorStand(getObjID(), feet4.clone());
as.getInventory().setHelmet(new ItemStack(Material.LEVER));
aspList.add(as);
Location sit = sitz.clone().add(0,-.2,0);
as = manager.createArmorStand(obj, sit.clone());
as = getManager().createArmorStand(getObjID(), sit.clone());
as.setName("#SITZ#");
aspList.add(as);
for(ArmorStandPacket asp : aspList){
for(fArmorStand asp : aspList){
asp.setGravity(false);
asp.setInvisible(true);
asp.setBasePlate(false);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.remove();
obj=null;
delete();
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
ArmorStandPacket packet = null;
for(ArmorStandPacket as : manager.getArmorStandPacketByObjectID(obj)){
if(!e.getID().equals(getObjID())){return;}
fArmorStand packet = null;
for(fArmorStand as : getManager().getfArmorStandByObjectID(getObjID())){
if(as.getName().equalsIgnoreCase("#SITZ#")){
packet=as;
break;
}
}
if(packet!=null){
if(packet.getPessanger()==null){
packet.setPessanger(e.getPlayer());
if(packet.getPassanger()==null){
packet.setPassanger(e.getPlayer());
packet.update();
}
}

View File

@ -1,14 +1,13 @@
package de.Ste3et_C0st.Furniture.Objects.indoor;
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.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -16,46 +15,18 @@ import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
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.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class lantern 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 lantern(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()){
public lantern(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
setBlock();
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
@ -66,15 +37,16 @@ public class lantern extends Furniture implements Listener{
Block block;
private void setBlock(){
Location center = lutil.getCenter(loc);
Location center = getLutil().getCenter(getLocation());
block = center.getWorld().getBlockAt(center);
if(!block.getType().equals(Material.AIR)){return;}
block.setType(Material.TORCH);
getObjID().addBlock(Arrays.asList(block));
}
public void spawn(Location loc){
List<ArmorStandPacket> aspList = new ArrayList<ArmorStandPacket>();
Location center = lutil.getCenter(loc);
List<fArmorStand> aspList = new ArrayList<fArmorStand>();
Location center = getLutil().getCenter(loc);
setBlock();
Location obsidian = center;
Location l = new Location(center.getWorld(), center.getX(), center.getY() -1.43, center.getZ());
@ -84,58 +56,58 @@ public class lantern extends Furniture implements Listener{
Location right_upper = new Location(obsidian.getWorld(), obsidian.getX()-.21, obsidian.getY()+.62, obsidian.getZ()-.21);
Location right_down = new Location(obsidian.getWorld(), obsidian.getX()+.21, obsidian.getY() + .62, obsidian.getZ() -.21);
ArmorStandPacket asp = manager.createArmorStand(obj, obsidian);
fArmorStand asp = getManager().createArmorStand(getObjID(), obsidian);
asp.getInventory().setHelmet(new ItemStack(Material.OBSIDIAN));
aspList.add(asp);
asp = manager.createArmorStand(obj, lutil.getRelativ(l.clone(), b, 0D, 0.01D));
asp = getManager().createArmorStand(getObjID(), getLutil().getRelativ(l.clone(), getBlockFace(), 0D, 0.01D));
asp.getInventory().setHelmet(new ItemStack(Material.WOOD_PLATE));
aspList.add(asp);
asp = manager.createArmorStand(obj, left_down);
asp = getManager().createArmorStand(getObjID(), left_down);
asp.getInventory().setHelmet(new ItemStack(Material.LEVER));
aspList.add(asp);
asp = manager.createArmorStand(obj, left_upper);
asp = getManager().createArmorStand(getObjID(), left_upper);
asp.getInventory().setHelmet(new ItemStack(Material.LEVER));
aspList.add(asp);
asp = manager.createArmorStand(obj, right_upper);
asp = getManager().createArmorStand(getObjID(), right_upper);
asp.getInventory().setHelmet(new ItemStack(Material.LEVER));
aspList.add(asp);
asp = manager.createArmorStand(obj, right_down);
asp = getManager().createArmorStand(getObjID(), right_down);
asp.getInventory().setHelmet(new ItemStack(Material.LEVER));
aspList.add(asp);
for(ArmorStandPacket packet : aspList){
for(fArmorStand packet : aspList){
packet.setBasePlate(false);
packet.setGravity(false);
packet.setInvisible(true);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
@EventHandler
public void onWaterFlow(BlockFromToEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
Location locTo = e.getToBlock().getLocation();
if(loc!=null && locTo.equals(loc.getBlock().getLocation())){
if(getLocation()!=null && locTo.equals(getLocation().getBlock().getLocation())){
e.setCancelled(true);
}
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()) return;
if(block==null) return;
if(!e.getID().equals(obj)) return;
if(!e.getID().equals(getObjID())) return;
if(!e.canBuild()){return;}
e.remove();
block.setType(Material.AIR);
@ -143,11 +115,11 @@ public class lantern extends Furniture implements Listener{
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()) return;
if(block==null) return;
if(!e.getID().equals(obj)) return;
if(!e.getID().equals(getObjID())) return;
if(!e.canBuild()){return;}
Player p = e.getPlayer();
ItemStack is = p.getItemInHand();

View File

@ -8,7 +8,6 @@ import org.bukkit.Bukkit;
import org.bukkit.GameMode;
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;
@ -17,50 +16,23 @@ 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.ColorType;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class largeTable 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 largeTable(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()){
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
public largeTable(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().startsWith("#TELLER")){
tellerIDs.add(packet.getEntityId());
tellerIDs.add(packet.getEntityID());
}
}
@ -72,60 +44,60 @@ public class largeTable extends Furniture implements Listener{
List<Integer> tellerIDs = new ArrayList<Integer>();
public void spawn(Location loc){
List<ArmorStandPacket> armorlist = new ArrayList<ArmorStandPacket>();
List<fArmorStand> armorlist = new ArrayList<fArmorStand>();
Location location = lutil.getCenter(loc.getBlock().getLocation());
float yaw = lutil.FaceToYaw(this.b);
location = lutil.getRelativ(location, this.b, 0.1, 0.28);
Location location = getLutil().getCenter(loc.getBlock().getLocation());
float yaw = getLutil().FaceToYaw(getBlockFace());
location = getLutil().getRelativ(location, getBlockFace(), 0.1, 0.28);
location.add(0,.2,0);
Double winkel = 1.57;
ItemStack iTemStack_1 = new ItemStack(Material.STAINED_GLASS_PANE);
for(int x=1; x<=3;x++){
Location l = lutil.getRelativ(location.clone(), this.b, 0.0, x*-.63);
Location l = getLutil().getRelativ(location.clone(), getBlockFace(), 0.0, x*-.63);
l.add(0,-1.2,0);
l.setYaw(yaw);
ArmorStandPacket as = manager.createArmorStand(obj, l.clone());
fArmorStand as = getManager().createArmorStand(getObjID(), l.clone());
as.setPose(new EulerAngle(winkel, 0, 0), BodyPart.HEAD);
as.getInventory().setHelmet(iTemStack_1);
armorlist.add(as);
}
for(int x=1; x<=3;x++){
Location l = lutil.getRelativ(location.clone(), this.b, 0.63, x*-.63);
Location l = getLutil().getRelativ(location.clone(), getBlockFace(), 0.63, x*-.63);
l.add(0,-1.2,0);
l.setYaw(yaw);
ArmorStandPacket as = manager.createArmorStand(obj, l.clone());
fArmorStand as = getManager().createArmorStand(getObjID(), l.clone());
as.setPose(new EulerAngle(winkel, 0, 0), BodyPart.HEAD);
as.getInventory().setHelmet(iTemStack_1);
armorlist.add(as);
}
for(int x=1; x<=3;x++){
Location l = lutil.getRelativ(location.clone(), this.b, 1.26, x*-.63);
Location l = getLutil().getRelativ(location.clone(), getBlockFace(), 1.26, x*-.63);
l.add(0,-1.2,0);
l.setYaw(yaw);
ArmorStandPacket as = manager.createArmorStand(obj, l.clone());
fArmorStand as = getManager().createArmorStand(getObjID(), l.clone());
as.setPose(new EulerAngle(winkel, 0, 0), BodyPart.HEAD);
as.getInventory().setHelmet(iTemStack_1);
armorlist.add(as);
}
Location middle = lutil.getCenter(armorlist.get(0).getLocation());
Location mitteTisch = lutil.getCenter(armorlist.get(4).getLocation().getBlock().getLocation());
Location middle = getLutil().getCenter(armorlist.get(0).getLocation());
Location mitteTisch = getLutil().getCenter(armorlist.get(4).getLocation().getBlock().getLocation());
middle.add(0, -.9, 0);
Location feet1 = lutil.getRelativ(middle, this.b, -.2, .1);
Location feet2 = lutil.getRelativ(middle, this.b, -.2, -1.3);
Location feet3 = lutil.getRelativ(middle, this.b, 1.1, .1);
Location feet4 = lutil.getRelativ(middle, this.b, 1.1, -1.3);
Location feet1 = getLutil().getRelativ(middle, getBlockFace(), -.2, .1);
Location feet2 = getLutil().getRelativ(middle, getBlockFace(), -.2, -1.3);
Location feet3 = getLutil().getRelativ(middle, getBlockFace(), 1.1, .1);
Location feet4 = getLutil().getRelativ(middle, getBlockFace(), 1.1, -1.3);
double hight = .67;
Location t1 = lutil.getRelativ(mitteTisch, this.b, -.95, .4).add(0,hight,0);
Location t2 = lutil.getRelativ(mitteTisch, this.b, -.4, -.92).add(0,hight,0);
Location t3 = lutil.getRelativ(mitteTisch, this.b, .92, -.36).add(0,hight,0);
Location t4 = lutil.getRelativ(mitteTisch, this.b, .4, .92).add(0,hight,0);
Location t1 = getLutil().getRelativ(mitteTisch, getBlockFace(), -.95, .4).add(0,hight,0);
Location t2 = getLutil().getRelativ(mitteTisch, getBlockFace(), -.4, -.92).add(0,hight,0);
Location t3 = getLutil().getRelativ(mitteTisch, getBlockFace(), .92, -.36).add(0,hight,0);
Location t4 = getLutil().getRelativ(mitteTisch, getBlockFace(), .4, .92).add(0,hight,0);
float yaw1 = yaw;
float yaw2 = yaw1-90;
@ -142,60 +114,60 @@ public class largeTable extends Furniture implements Listener{
feet3.setYaw(yaw);
feet4.setYaw(yaw);
ArmorStandPacket as = manager.createArmorStand(obj, feet1);
fArmorStand as = getManager().createArmorStand(getObjID(), feet1);
as.setPose(new EulerAngle(-1.75, 0, 0), BodyPart.RIGHT_ARM);
as.getInventory().setItemInHand(new ItemStack(Material.BONE));
armorlist.add(as);
as = manager.createArmorStand(obj, feet2);
as = getManager().createArmorStand(getObjID(), feet2);
as.setPose(new EulerAngle(-1.75, 0, 0), BodyPart.RIGHT_ARM);
as.getInventory().setItemInHand(new ItemStack(Material.BONE));
armorlist.add(as);
as = manager.createArmorStand(obj, feet3);
as = getManager().createArmorStand(getObjID(), feet3);
as.setPose(new EulerAngle(-1.75, 0, 0), BodyPart.RIGHT_ARM);
as.getInventory().setItemInHand(new ItemStack(Material.BONE));
armorlist.add(as);
as = manager.createArmorStand(obj, feet4);
as = getManager().createArmorStand(getObjID(), feet4);
as.setPose(new EulerAngle(-1.75, 0, 0), BodyPart.RIGHT_ARM);
as.getInventory().setItemInHand(new ItemStack(Material.BONE));
armorlist.add(as);
as = manager.createArmorStand(obj, t1);
as = getManager().createArmorStand(getObjID(), t1);
as.setName("#TELLER1#");
as.setPose(new EulerAngle(0, 0, 0), BodyPart.RIGHT_ARM);
armorlist.add(as);
tellerIDs.add(as.getEntityId());
as = manager.createArmorStand(obj, t2);
tellerIDs.add(as.getEntityID());
as = getManager().createArmorStand(getObjID(), t2);
as.setName("#TELLER2#");
as.setPose(new EulerAngle(0, 0, 0), BodyPart.RIGHT_ARM);
armorlist.add(as);
tellerIDs.add(as.getEntityId());
as = manager.createArmorStand(obj, t3);
tellerIDs.add(as.getEntityID());
as = getManager().createArmorStand(getObjID(), t3);
as.setName("#TELLER3#");
as.setPose(new EulerAngle(0, 0, 0), BodyPart.RIGHT_ARM);
armorlist.add(as);
tellerIDs.add(as.getEntityId());
as = manager.createArmorStand(obj, t4);
tellerIDs.add(as.getEntityID());
as = getManager().createArmorStand(getObjID(), t4);
as.setName("#TELLER4#");
as.setPose(new EulerAngle(0, 0, 0), BodyPart.RIGHT_ARM);
armorlist.add(as);
tellerIDs.add(as.getEntityId());
tellerIDs.add(as.getEntityID());
for(ArmorStandPacket packet : armorlist){
for(fArmorStand packet : armorlist){
packet.setInvisible(true);
packet.setGravity(false);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
public void setTeller(HashMap<Integer, ItemStack> itemList){
int i = 0;
for(Integer id : tellerIDs){
ArmorStandPacket as = manager.getArmorStandPacketByID(id);
fArmorStand as = getManager().getfArmorStandByID(id);
as.getInventory().setItemInHand(itemList.get(i));
i++;
}
@ -203,35 +175,35 @@ public class largeTable extends Furniture implements Listener{
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
for(Integer id : tellerIDs){
ArmorStandPacket asp = manager.getArmorStandPacketByID(id);
fArmorStand asp = getManager().getfArmorStandByID(id);
if(asp!=null&&asp.getInventory().getItemInHand()!=null){
if(asp.getName().startsWith("#TELLER")){
ArmorStandPacket packet = asp;
fArmorStand packet = asp;
e.getLocation().getWorld().dropItem(e.getLocation(), packet.getInventory().getItemInHand());
}
}
}
e.remove();
obj=null;
delete();
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
Player p = e.getPlayer();
if(p.getItemInHand().getType().equals(Material.INK_SACK)){
lib.getColorManager().color(p, e.canBuild(), Material.STAINED_GLASS_PANE, obj, ColorType.BLOCK, 3);
getLib().getColorManager().color(p, e.canBuild(), Material.STAINED_GLASS_PANE, getObjID(), ColorType.BLOCK, 3);
return;
}else{
setTeller(p, p.getInventory().getItemInHand());
@ -239,14 +211,14 @@ public class largeTable extends Furniture implements Listener{
}
public void setTeller(Player player, ItemStack is){
BlockFace b = lutil.yawToFace(player.getLocation().getYaw());
ArmorStandPacket as = null;
BlockFace b = getLutil().yawToFace(player.getLocation().getYaw());
fArmorStand as = null;
if(tellerIDs == null || tellerIDs.isEmpty()){return;}
for(Integer id : this.tellerIDs){
if(id!=null){
ArmorStandPacket armorStand = manager.getArmorStandPacketByID(id);
fArmorStand armorStand = getManager().getfArmorStandByID(id);
if(armorStand!=null){
BlockFace b2 = lutil.yawToFace(armorStand.getLocation().getYaw());
BlockFace b2 = getLutil().yawToFace(armorStand.getLocation().getYaw());
if(b2.equals(b)){
as = armorStand;
break;
@ -257,7 +229,7 @@ public class largeTable extends Furniture implements Listener{
if(as!=null&&as.getInventory().getItemInHand()!= null && as.getInventory().getItemInHand().equals(is)){return;}
if(as.getInventory().getItemInHand()!=null&&!as.getInventory().getItemInHand().getType().equals(Material.AIR)){
ArmorStandPacket asp = as;
fArmorStand asp = as;
ItemStack item = asp.getInventory().getItemInHand();
item.setAmount(1);
asp.getLocation().getWorld().dropItem(asp.getLocation(), item);
@ -267,9 +239,9 @@ public class largeTable extends Furniture implements Listener{
IS.setAmount(1);
as.getInventory().setItemInHand(IS);
manager.updateFurniture(obj);
update();
if(player.getGameMode().equals(GameMode.CREATIVE) && lib.useGamemode()) return;
if(player.getGameMode().equals(GameMode.CREATIVE) && getLib().useGamemode()) return;
Integer i = player.getInventory().getHeldItemSlot();
ItemStack itemstack = is.clone();
itemstack.setAmount(itemstack.getAmount()-1);
@ -281,7 +253,7 @@ public class largeTable extends Furniture implements Listener{
HashMap<Integer, ItemStack> teller = new HashMap<Integer, ItemStack>();
for(Integer id : tellerIDs){
try{
ArmorStandPacket as = manager.getArmorStandPacketByID(id);
fArmorStand as = getManager().getfArmorStandByID(id);
teller.put(teller.size(), as.getInventory().getItemInHand());
}catch(Exception e){
teller.put(teller.size(), new ItemStack(Material.AIR));

View File

@ -6,7 +6,6 @@ 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;
@ -15,48 +14,21 @@ 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.ColorType;
import de.Ste3et_C0st.FurnitureLib.main.Type.EventType;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class sofa 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 sofa(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()){
public sofa(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
@ -68,11 +40,11 @@ public class sofa extends Furniture implements Listener {
Double place;
public void spawn(Location loc){
List<ArmorStandPacket> aspList = new ArrayList<ArmorStandPacket>();
List<ArmorStandPacket> sitz = new ArrayList<ArmorStandPacket>();
List<fArmorStand> aspList = new ArrayList<fArmorStand>();
List<fArmorStand> sitz = new ArrayList<fArmorStand>();
Integer lengt = 3;
is = new ItemStack(Material.CARPET);
BlockFace b = lutil.yawToFace(loc.getYaw()).getOppositeFace();
BlockFace b = getLutil().yawToFace(loc.getYaw()).getOppositeFace();
Integer x = (int) loc.getX();
Integer y = (int) loc.getY();
@ -81,49 +53,53 @@ public class sofa extends Furniture implements Listener {
loc.setY(y);
loc.setZ(z);
if(b.equals(BlockFace.WEST)){loc = lutil.getRelativ(loc, b, .0, -1.0);}
if(b.equals(BlockFace.SOUTH)){loc = lutil.getRelativ(loc, b, -1.0, -1.0);}
if(b.equals(BlockFace.EAST)){loc = lutil.getRelativ(loc, b, -1.0, .0);}
if(b.equals(BlockFace.WEST)){loc = getLutil().getRelativ(loc, b, .0, -1.0);}
if(b.equals(BlockFace.SOUTH)){loc = getLutil().getRelativ(loc, b, -1.0, -1.0);}
if(b.equals(BlockFace.EAST)){loc = getLutil().getRelativ(loc, b, -1.0, .0);}
Location looking = new Location(loc.getWorld(), loc.getBlockX(), loc.getBlockY() -1.4 , loc.getBlockZ());
Location feet1 = lutil.getRelativ(looking, b, place, .2D);
Location feet2 = lutil.getRelativ(looking, b, place, lengt.doubleValue()-.2D);
Location feet3 = lutil.getRelativ(looking, b, place + .5, .2D);
Location feet4 = lutil.getRelativ(looking, b, place + .5, lengt.doubleValue()-.2D);
Location feet1 = getLutil().getRelativ(looking, b, place, .2D);
Location feet2 = getLutil().getRelativ(looking, b, place, lengt.doubleValue()-.2D);
Location feet3 = getLutil().getRelativ(looking, b, place + .5, .2D);
Location feet4 = getLutil().getRelativ(looking, b, place + .5, lengt.doubleValue()-.2D);
ArmorStandPacket asp = manager.createArmorStand(obj, feet1);
fArmorStand asp = getManager().createArmorStand(getObjID(), feet1);
asp.getInventory().setHelmet(new ItemStack(Material.LEVER));
asp.setMarker(false);
aspList.add(asp);
asp = manager.createArmorStand(obj, feet2);
asp = getManager().createArmorStand(getObjID(), feet2);
asp.getInventory().setHelmet(new ItemStack(Material.LEVER));
asp.setMarker(false);
aspList.add(asp);
asp = manager.createArmorStand(obj, feet3);
asp = getManager().createArmorStand(getObjID(), feet3);
asp.getInventory().setHelmet(new ItemStack(Material.LEVER));
asp.setMarker(false);
aspList.add(asp);
asp = manager.createArmorStand(obj, feet4);
asp = getManager().createArmorStand(getObjID(), feet4);
asp.getInventory().setHelmet(new ItemStack(Material.LEVER));
asp.setMarker(false);
aspList.add(asp);
Location carpetHight = new Location(looking.getWorld(), loc.getBlockX(), loc.getBlockY() -1 , loc.getBlockZ());
carpetHight.setYaw(lutil.FaceToYaw(b));
carpetHight = lutil.getRelativ(carpetHight, b, .25,.3);
carpetHight.setYaw(getLutil().FaceToYaw(b));
carpetHight = getLutil().getRelativ(carpetHight, b, .25,.3);
Double d = .02;
float facing = lutil.FaceToYaw(b);
float facing = getLutil().FaceToYaw(b);
Integer j = 0;
for(Double i = .0; i<=lengt; i+=0.65){
Location carpet = lutil.getRelativ(carpetHight, b, place,(double) d);
Location carpet = getLutil().getRelativ(carpetHight, b, place,(double) d);
carpet.setYaw(facing);
String s = "";
if(j==0||j==1){s="#SITZPOS:1#";}
if(j==2){s="#SITZPOS:2#";}
if(j==3||j==4){s="#SITZPOS:3#";}
asp = manager.createArmorStand(obj, carpet);
asp = getManager().createArmorStand(getObjID(), carpet);
asp.getInventory().setHelmet(is);
asp.setName(s);
aspList.add(asp);
sitz.add(asp);
Location location = lutil.getRelativ(carpetHight, b, place-.25,(double) d);
Location location = getLutil().getRelativ(carpetHight, b, place-.25,(double) d);
location.setYaw(facing);
asp = manager.createArmorStand(obj, location);
asp = getManager().createArmorStand(getObjID(), location);
asp.setPose(new EulerAngle(1.57, .0, .0), BodyPart.HEAD);
asp.getInventory().setHelmet(is);
asp.setName(s);
@ -135,55 +111,57 @@ public class sofa extends Furniture implements Listener {
Float yaw1= facing;
Float yaw2= facing;
Location last = lutil.getRelativ(sitz.get(sitz.size()-1).getLocation(), b, 0D, 0.26D);
Location last = getLutil().getRelativ(sitz.get(sitz.size()-1).getLocation(), b, 0D, 0.26D);
last.setYaw(yaw1+90);
Location first = lutil.getRelativ(new Location(loc.getWorld(), loc.getX(), last.getY(), loc.getZ()), b, place+.25, 0.07D);
Location first = getLutil().getRelativ(new Location(loc.getWorld(), loc.getX(), last.getY(), loc.getZ()), b, place+.25, 0.07D);
first.setYaw(yaw2-90);
asp = manager.createArmorStand(obj, first.add(0,-.05,0));
asp = getManager().createArmorStand(getObjID(), first.add(0,-.05,0));
asp.getInventory().setHelmet(is);
asp.setPose(new EulerAngle(1.57, .0, .0), BodyPart.HEAD);
asp.setMarker(false);
asp.setName("#SITZPOS:1#");
aspList.add(asp);
asp = manager.createArmorStand(obj, last.add(0,-.05,0));
asp = getManager().createArmorStand(getObjID(), last.add(0,-.05,0));
asp.getInventory().setHelmet(is);
asp.setPose(new EulerAngle(1.57, .0, .0), BodyPart.HEAD);
asp.setMarker(false);
asp.setName("#SITZPOS:3#");
aspList.add(asp);
Location start = lutil.getRelativ(looking, b, .45, .55);
Location start = getLutil().getRelativ(looking, b, .45, .55);
for(int i = 0; i<=2;i++){
Location location = lutil.getRelativ(start, b, place, i*.95D);
location.setYaw(lutil.FaceToYaw(b));
Location location = getLutil().getRelativ(start, b, place, i*.95D);
location.setYaw(getLutil().FaceToYaw(b));
location.add(0,.2,0);
asp = manager.createArmorStand(obj, location);
asp = getManager().createArmorStand(getObjID(), location);
asp.setName("#SITZ" + i + "#");
aspList.add(asp);
}
for(ArmorStandPacket asps : aspList){
for(fArmorStand asps : aspList){
asps.setInvisible(true);
asps.setGravity(false);
asps.setBasePlate(false);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
e.setCancelled(true);
final Player p = e.getPlayer();
if(p.getItemInHand().getType().equals(Material.INK_SACK)){
lib.getColorManager().color(p, e.canBuild(), Material.CARPET, obj, ColorType.BLOCK, 12);
getLib().getColorManager().color(p, e.canBuild(), Material.CARPET, getObjID(), ColorType.BLOCK, 12);
}else{
ArmorStandPacket packet = e.getArmorStandPacket();
fArmorStand packet = e.getfArmorStand();
switch (packet.getName()) {
case "#SITZPOS:1#": sit("#SITZ0#", p);break;
case "#SITZPOS:2#": sit("#SITZ1#", p);break;
@ -198,9 +176,9 @@ public class sofa extends Furniture implements Listener {
}
private void sit(String s, Player p){
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
if(packet.getName().equalsIgnoreCase(s) && packet.getPessanger() == null){
packet.setPessanger(p);
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().equalsIgnoreCase(s) && packet.getPassanger() == null){
packet.setPassanger(p);
packet.update();
return;
}
@ -209,18 +187,19 @@ public class sofa extends Furniture implements Listener {
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){
if(obj==null){return;}
if(getObjID()==null){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!lib.canBuild(e.getPlayer(), obj, EventType.BREAK)){return;}
if(e.getID()==null){return;}
if(!e.getID().equals(getObjID())){return;}
if(!getLib().canBuild(e.getPlayer(), getObjID(), EventType.BREAK)){return;}
e.setCancelled(true);
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
if(packet.getPessanger()!=null){
packet.unleash();
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getPassanger()!=null){
packet.eject();
packet.update();
}
}
e.remove();
obj=null;
delete();
}
}

View File

@ -7,8 +7,6 @@ import org.bukkit.Bukkit;
import org.bukkit.GameMode;
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.Listener;
@ -16,124 +14,97 @@ 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;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class table 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 table(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()){
public table(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
spawn(id.getStartLocation());
}
public void spawn(Location loc){
List<ArmorStandPacket> packetL = new ArrayList<ArmorStandPacket>();
Location middle1 = lutil.getCenter(loc);
Location middle2 = lutil.getCenter(loc);
List<fArmorStand> packetL = new ArrayList<fArmorStand>();
Location middle1 = getLutil().getCenter(loc);
Location middle2 = getLutil().getCenter(loc);
Location l = loc;
l.setYaw(0);
ArmorStandPacket asp = manager.createArmorStand(obj, middle1.add(0, -2.1, 0));
fArmorStand asp = getManager().createArmorStand(getObjID(), middle1.add(0, -2.1, 0));
asp.getInventory().setHelmet(new ItemStack(Material.WOOD_PLATE));
packetL.add(asp);
asp = manager.createArmorStand(obj, middle2.add(0,-1.05,0));
asp = getManager().createArmorStand(getObjID(), middle2.add(0,-1.05,0));
asp.getInventory().setHelmet(new ItemStack(Material.TRAP_DOOR));
packetL.add(asp);
Location locatio = l.clone().add(0.9,0.15,0.3);
asp = manager.createArmorStand(obj, locatio);
asp = getManager().createArmorStand(getObjID(), locatio);
asp.setName("#ITEM#");
asp.setPose(new EulerAngle(0.0,0.0,0.0), BodyPart.RIGHT_ARM);
packetL.add(asp);
locatio = locatio.clone().add(0,-0.65,0.68);
asp = manager.createArmorStand(obj, locatio);
asp = getManager().createArmorStand(getObjID(), locatio);
asp.getInventory().setItemInHand(new ItemStack(Material.STICK));
asp.setPose(new EulerAngle(1.38,.0,.0), BodyPart.RIGHT_ARM);
packetL.add(asp);
for(ArmorStandPacket packet : packetL){
for(fArmorStand packet : packetL){
packet.setInvisible(true);
packet.setGravity(false);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().equalsIgnoreCase("#ITEM#")){
if(packet.getInventory().getItemInHand()!=null&&!packet.getInventory().getItemInHand().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getItemInHand();
w.dropItem(loc, is);
getWorld().dropItem(getLocation(), is);
}
}
}
e.remove();
obj=null;
delete();
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
Player p = e.getPlayer();
if(!e.canBuild()){return;}
e.setCancelled(true);
if(p.getItemInHand().getType().isBlock()&&!p.getItemInHand().getType().equals(Material.AIR)){return;}
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().equalsIgnoreCase("#ITEM#")){
ItemStack Itemstack = p.getItemInHand().clone();
Itemstack.setAmount(1);
if(packet.getInventory().getItemInHand()!=null&&!packet.getInventory().getItemInHand().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getItemInHand();
is.setAmount(1);
w.dropItem(loc, is);
getWorld().dropItem(getLocation(), is);
}
packet.getInventory().setItemInHand(Itemstack);
if(p.getGameMode().equals(GameMode.CREATIVE) && lib.useGamemode()) break;
if(p.getGameMode().equals(GameMode.CREATIVE) && getLib().useGamemode()) break;
Integer i = p.getInventory().getHeldItemSlot();
ItemStack is = p.getItemInHand();
is.setAmount(is.getAmount()-1);
@ -142,6 +113,6 @@ public class table extends Furniture implements Listener {
break;
}
}
manager.updateFurniture(obj);
update();
}
}

View File

@ -0,0 +1,111 @@
package de.Ste3et_C0st.Furniture.Objects.outdoor;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
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.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class CactusPlant extends Furniture implements Listener {
public CactusPlant(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
spawn(id.getStartLocation());
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
delete();
e.remove();
}
@Override
public void onFurnitureClick(FurnitureClickEvent e) {}
public void spawn(Location location) {
List<fArmorStand> aspList = new ArrayList<fArmorStand>();
Location middle = getLutil().getCenter(location);
middle.add(0, -1.9, 0);
middle.setYaw(getLutil().FaceToYaw(getBlockFace()));
fArmorStand packet = getManager().createArmorStand(getObjID(), middle);
packet.getInventory().setHelmet(new ItemStack(Material.CACTUS));
aspList.add(packet);
packet = getManager().createArmorStand(getObjID(), middle.clone().add(0, .63, 0));
packet.getInventory().setHelmet(new ItemStack(Material.CACTUS));
aspList.add(packet);
packet = getManager().createArmorStand(getObjID(), middle.clone().add(0, 1.18, 0));
packet.getInventory().setHelmet(new ItemStack(Material.CACTUS));
packet.setPose(getLutil().degresstoRad(new EulerAngle(20, 0, 0)), BodyPart.HEAD);
aspList.add(packet);
Location l1 = getLutil().getRelativ(middle.clone().add(0, 1.665, 0), getBlockFace(), .16d, 0d);
l1.setYaw(getLutil().FaceToYaw(getBlockFace()));
packet = getManager().createArmorStand(getObjID(), l1);
packet.getInventory().setHelmet(new ItemStack(Material.CACTUS));
packet.setPose(getLutil().degresstoRad(new EulerAngle(5, 0, 0)), BodyPart.HEAD);
aspList.add(packet);
l1 = getLutil().getRelativ(middle.clone().add(0, 1.43, 0), getBlockFace(), .1d, 0d);
l1.setYaw(getLutil().FaceToYaw(getBlockFace()));
packet = getManager().createArmorStand(getObjID(), l1);
packet.getInventory().setHelmet(new ItemStack(Material.CACTUS));
packet.setSmall(true);
packet.setPose(getLutil().degresstoRad(new EulerAngle(60, 0, 0)), BodyPart.HEAD);
aspList.add(packet);
l1 = getLutil().getRelativ(middle.clone().add(0, 2.3, 0), getBlockFace(), -.07d, 0d);
l1.setYaw(getLutil().FaceToYaw(getBlockFace()));
packet = getManager().createArmorStand(getObjID(), l1);
packet.getInventory().setHelmet(new ItemStack(Material.CACTUS));
packet.setSmall(true);
packet.setPose(getLutil().degresstoRad(new EulerAngle(-45, 0, 0)), BodyPart.HEAD);
aspList.add(packet);
l1 = getLutil().getRelativ(middle.clone().add(0, 2.0, 0), getBlockFace(), .07d, .06d);
l1.setYaw(getLutil().FaceToYaw(getBlockFace()));
packet = getManager().createArmorStand(getObjID(), l1);
packet.getInventory().setHelmet(new ItemStack(Material.CACTUS));
packet.setSmall(true);
packet.setPose(getLutil().degresstoRad(new EulerAngle(0, 0, 45)), BodyPart.HEAD);
aspList.add(packet);
for(fArmorStand as : aspList){
as.setInvisible(true);
as.setGravity(false);
as.setBasePlate(false);
}
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
}

View File

@ -1,64 +1,36 @@
package de.Ste3et_C0st.Furniture.Objects.outdoor;
import java.util.Arrays;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBlockBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBlockClickEvent;
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.EventType;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class barrels extends Furniture implements Listener {
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Integer id;
Block block;
Plugin plugin;
public ObjectID getObjectID(){return this.obj;}
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
public barrels(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;
public barrels(Plugin plugin, ObjectID id){
super(plugin, id);
if(id.isFinish()){
this.block = loc.getBlock();
this.block = getLocation().getBlock();
this.block.setType(Material.CAULDRON);
getObjID().addBlock(Arrays.asList(block));
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
@ -68,34 +40,34 @@ public class barrels extends Furniture implements Listener {
public void spawn(Location loc){
this.block = loc.getBlock();
this.block.setType(Material.CAULDRON);
ArmorStandPacket packet = manager.createArmorStand(obj, lutil.getCenter(loc).add(0,-1.5,0));
getObjID().addBlock(Arrays.asList(block));
fArmorStand packet = getManager().createArmorStand(getObjID(), getLutil().getCenter(loc).add(0,-1.5,0));
packet.setInvisible(true);
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e){
if(obj==null){return;}
if(getObjID()==null){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
Player p = e.getPlayer();
if(!p.getItemInHand().getType().isBlock()&&!p.getItemInHand().getType().equals(Material.AIR)){return;}
ArmorStandPacket packet = manager.getArmorStandPacketByObjectID(obj).get(0);
fArmorStand packet = getManager().getfArmorStandByObjectID(getObjID()).get(0);
if(packet.getInventory().getHelmet()!=null&&!packet.getInventory().getHelmet().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getHelmet();
is.setAmount(1);
w.dropItem(loc, is);
getWorld().dropItem(getLocation(), is);
}
packet.getInventory().setHelmet(p.getItemInHand());
manager.updateFurniture(obj);
getManager().updateFurniture(getObjID());
if(p.getGameMode().equals(GameMode.CREATIVE) && lib.useGamemode()) return;
if(p.getGameMode().equals(GameMode.CREATIVE) && getLib().useGamemode()) return;
Integer i = e.getPlayer().getInventory().getHeldItemSlot();
ItemStack item = e.getPlayer().getItemInHand();
item.setAmount(item.getAmount()-1);
@ -104,31 +76,45 @@ public class barrels extends Furniture implements Listener {
}
@EventHandler
private void onInteract(PlayerInteractEvent e){
if(obj==null){return;}
if(block==null || obj==null){return;}
if(e.getClickedBlock()==null){return;}
if(!e.getClickedBlock().getLocation().equals(block.getLocation())){return;}
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)){return;}
private void onBlockBreak(FurnitureBlockBreakEvent e){
if(getObjID()==null){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
ItemStack Itemstack = p.getItemInHand().clone();
fArmorStand packet = getManager().getfArmorStandByObjectID(getObjID()).get(0);
if(packet.getInventory().getHelmet()!=null&&!packet.getInventory().getHelmet().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getHelmet();
is.setAmount(1);
getWorld().dropItem(getLocation(), is);
}
e.remove();
delete();
}
@EventHandler
private void onBlockClick(FurnitureBlockClickEvent e){
if(getObjID()==null){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
if(!e.getPlayer().getItemInHand().getType().isBlock()&&!e.getPlayer().getItemInHand().getType().equals(Material.AIR)){return;}
e.setCancelled(true);
ItemStack Itemstack = e.getPlayer().getItemInHand().clone();
Itemstack.setAmount(1);
ArmorStandPacket packet = manager.getArmorStandPacketByObjectID(obj).get(0);
fArmorStand packet = getManager().getfArmorStandByObjectID(getObjID()).get(0);
if(packet.getInventory().getHelmet()!=null&&!packet.getInventory().getHelmet().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getHelmet();
is.setAmount(1);
w.dropItem(loc, is);
getWorld().dropItem(getLocation(), is);
}
packet.getInventory().setHelmet(Itemstack);
manager.updateFurniture(obj);
getManager().updateFurniture(getObjID());
if(p.getGameMode().equals(GameMode.CREATIVE) && lib.useGamemode()) return;
if(e.getPlayer().getGameMode().equals(GameMode.CREATIVE) && getLib().useGamemode()) return;
Integer i = e.getPlayer().getInventory().getHeldItemSlot();
ItemStack item = e.getPlayer().getItemInHand();
item.setAmount(item.getAmount()-1);
@ -136,35 +122,20 @@ public class barrels extends Furniture implements Listener {
e.getPlayer().updateInventory();
}
@EventHandler
private void onBlockBreak(BlockBreakEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(block==null){return;}
if(!e.getBlock().getLocation().equals(block.getLocation())){return;}
if(!lib.canBuild(e.getPlayer(), obj, EventType.BREAK)){return;}
ArmorStandPacket packet = manager.getArmorStandPacketByObjectID(obj).get(0);
if(packet.getInventory().getHelmet()!=null&&!packet.getInventory().getHelmet().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getHelmet();
w.dropItem(loc, is);
}
this.block.setType(Material.AIR);
block=null;
this.obj.remove(e.getPlayer());
obj=null;
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){
if(obj==null){return;}
if(getObjID()==null){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
fArmorStand packet = getManager().getfArmorStandByObjectID(getObjID()).get(0);
if(packet.getInventory().getHelmet()!=null&&!packet.getInventory().getHelmet().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getHelmet();
is.setAmount(1);
getWorld().dropItem(getLocation(), is);
}
e.remove();
obj=null;
block.setType(Material.AIR);
block=null;
delete();
}
}

View File

@ -5,52 +5,23 @@ 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 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.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class campfire_1 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 campfire_1(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()){
public campfire_1(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
@ -59,61 +30,61 @@ public class campfire_1 extends Furniture implements Listener{
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
packet.setFire(false);
Location location = this.loc.clone();
Location location = getLocation().clone();
location.add(0, 1.2, 0);
lib.getLightManager().removeLight(location);
getLib().getLightManager().removeLight(location);
}
manager.updateFurniture(obj);
getManager().updateFurniture(getObjID());
e.remove();
obj=null;
delete();
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
List<ArmorStandPacket> aspList = manager.getArmorStandPacketByObjectID(obj);
List<fArmorStand> aspList = getManager().getfArmorStandByObjectID(getObjID());
ItemStack is = e.getPlayer().getItemInHand();
if(is.getType().equals(Material.WATER_BUCKET)){
for(ArmorStandPacket packet : aspList){
for(fArmorStand packet : aspList){
packet.setFire(false);
Location location = this.loc.clone();
Location location = getLocation().clone();
location.add(0, 1.2, 0);
lib.getLightManager().removeLight(location);
getLib().getLightManager().removeLight(location);
}
manager.updateFurniture(obj);
getManager().updateFurniture(getObjID());
}else if(is.getType().equals(Material.FLINT_AND_STEEL)){
for(ArmorStandPacket packet : aspList){
for(fArmorStand packet : aspList){
packet.setFire(true);
Location location = this.loc.clone();
Location location = getLocation().clone();
location.add(0, 1.2, 0);
lib.getLightManager().addLight(location,15);
getLib().getLightManager().addLight(location,15);
}
manager.updateFurniture(obj);
getManager().updateFurniture(getObjID());
}
}
public void spawn(Location loc){
for(int i = 0;i<=3;i++){
Location location = lutil.getCenter(loc);
Location location = getLutil().getCenter(loc);
location.add(0,-1.9,0);
location.setYaw(i*60);
ArmorStandPacket packet = manager.createArmorStand(obj, location);
fArmorStand packet = getManager().createArmorStand(getObjID(), location);
packet.setGravity(false);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
}

View File

@ -8,8 +8,6 @@ import org.bukkit.Bukkit;
import org.bukkit.GameMode;
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;
@ -19,14 +17,11 @@ 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;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class campfire_2 extends Furniture implements Listener{
List<Material> items = new ArrayList<Material>(
@ -60,43 +55,20 @@ public class campfire_2 extends Furniture implements Listener{
};
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Integer id;
Plugin plugin;
Location middle;
Location grill;
Integer timer;
ArmorStandPacket armorS;
fArmorStand armorS;
ItemStack is;
public ObjectID getObjectID(){return this.obj;}
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
public campfire_2(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;
middle = lutil.getCenter(loc);
middle = lutil.getRelativ(middle, b, .5D, -.5D);
public campfire_2(Plugin plugin, ObjectID id){
super(plugin, id);
middle = getLutil().getCenter(getLocation());
middle = getLutil().getRelativ(middle, getBlockFace(), .5D, -.5D);
middle.add(0,-1.2,0);
grill = lutil.getRelativ(middle,b, .0D, .5D);
grill.setYaw(lutil.FaceToYaw(b)+90);
this.obj = id;
grill = getLutil().getRelativ(middle,getBlockFace(), .0D, .5D);
grill.setYaw(getLutil().FaceToYaw(getBlockFace())+90);
if(id.isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
@ -105,30 +77,30 @@ public class campfire_2 extends Furniture implements Listener{
}
public void spawn(Location loc){
List<ArmorStandPacket> packetList = new ArrayList<ArmorStandPacket>();
Location stick1 = lutil.getRelativ(middle, b, .47D, -.05D);
Location stick2 = lutil.getRelativ(middle, b, .47D, .85D);
List<fArmorStand> packetList = new ArrayList<fArmorStand>();
Location stick1 = getLutil().getRelativ(middle, getBlockFace(), .47D, -.05D);
Location stick2 = getLutil().getRelativ(middle, getBlockFace(), .47D, .85D);
Location bone = lutil.getRelativ(middle, b, .5D, .82D);
stick2.setYaw(lutil.FaceToYaw(b));
Location bone = getLutil().getRelativ(middle, getBlockFace(), .5D, .82D);
stick2.setYaw(getLutil().FaceToYaw(getBlockFace()));
stick1.setYaw(lutil.FaceToYaw(b));
bone.setYaw(lutil.FaceToYaw(b));
stick1.setYaw(getLutil().FaceToYaw(getBlockFace()));
bone.setYaw(getLutil().FaceToYaw(getBlockFace()));
stick1.add(0,.3,0);
stick2.add(0,.3,0);
bone.add(0,.17,0);
Integer yaw = 90;
for(int i = 0; i<=7;i++){
Location location = null;
if(lutil.axisList.contains(lutil.yawToFaceRadial(yaw))){
location = lutil.getRelativ(middle, lutil.yawToFaceRadial(yaw), 0D, .5D);
if(getLutil().axisList.contains(getLutil().yawToFaceRadial(yaw))){
location = getLutil().getRelativ(middle, getLutil().yawToFaceRadial(yaw), 0D, .5D);
}else{
location = lutil.getRelativ(middle, lutil.yawToFaceRadial(yaw), 0D, .35D);
location = getLutil().getRelativ(middle, getLutil().yawToFaceRadial(yaw), 0D, .35D);
}
location.setYaw(90+yaw);
ArmorStandPacket asp = manager.createArmorStand(obj, location);
fArmorStand asp = getManager().createArmorStand(getObjID(), location);
asp.setPose(new EulerAngle(1.568, 0, 0), BodyPart.HEAD);
asp.setSmall(true);
asp.getInventory().setHelmet(new ItemStack(Material.STEP,1,(short)3));
@ -138,11 +110,11 @@ public class campfire_2 extends Furniture implements Listener{
yaw = 90;
for(int i = 0; i<=3;i++){
Location location = lutil.getRelativ(middle, lutil.yawToFace(yaw), .4, -.5D);
Location location = getLutil().getRelativ(middle, getLutil().yawToFace(yaw), .4, -.5D);
location.add(0,-.5,0);
location.setYaw(90+yaw);
ArmorStandPacket asp = manager.createArmorStand(obj, location);
fArmorStand asp = getManager().createArmorStand(getObjID(), location);
asp.setPose( new EulerAngle(2, 0, 0), BodyPart.RIGHT_ARM);
asp.getInventory().setItemInHand(new ItemStack(Material.STICK));
@ -150,50 +122,49 @@ public class campfire_2 extends Furniture implements Listener{
yaw+=90;
}
ArmorStandPacket asp = manager.createArmorStand(obj, stick1);
fArmorStand asp = getManager().createArmorStand(getObjID(), stick1);
asp.setPose(new EulerAngle(1.38,.0,.0), BodyPart.RIGHT_ARM);
asp.getInventory().setItemInHand(new ItemStack(Material.STICK));
packetList.add(asp);
asp = manager.createArmorStand(obj, stick2);
asp = getManager().createArmorStand(getObjID(), stick2);
asp.setPose(new EulerAngle(1.38,.0,.0), BodyPart.RIGHT_ARM);
asp.getInventory().setItemInHand(new ItemStack(Material.STICK));
packetList.add(asp);
asp = manager.createArmorStand(obj, bone);
asp = getManager().createArmorStand(getObjID(), bone);
asp.setPose(new EulerAngle(1.38,.0,1.57), BodyPart.RIGHT_ARM);
asp.getInventory().setItemInHand(new ItemStack(Material.BONE));
packetList.add(asp);
asp = manager.createArmorStand(obj, middle.add(0,-1.3,0));
asp = getManager().createArmorStand(getObjID(), middle.add(0,-1.3,0));
asp.setSmall(true);
packetList.add(asp);
for(ArmorStandPacket packet : packetList){
for(fArmorStand packet : packetList){
packet.setInvisible(true);
packet.setGravity(false);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
getManager().send(getObjID());
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
List<ArmorStandPacket> aspList = manager.getArmorStandPacketByObjectID(obj);
List<fArmorStand> aspList = getManager().getfArmorStandByObjectID(getObjID());
final ItemStack itemStack = e.getPlayer().getItemInHand();
ArmorStandPacket packet = null;
for(ArmorStandPacket pack : aspList){
if(pack.isMini() && pack.isInvisible()){
fArmorStand packet = null;
for(fArmorStand pack : aspList){
if(pack.isSmall() && pack.isVisible()){
packet = pack;
}
}
if(itemStack.getType().equals(Material.WATER_BUCKET) && packet.isFire()){
setfire(false);
}else if(itemStack.getType().equals(Material.FLINT_AND_STEEL) && !packet.isFire()){
@ -204,7 +175,7 @@ public class campfire_2 extends Furniture implements Listener{
setGrill();
if(e.getPlayer().getGameMode().equals(GameMode.CREATIVE) && lib.useGamemode()) return;
if(e.getPlayer().getGameMode().equals(GameMode.CREATIVE) && getLib().useGamemode()) return;
Integer i = e.getPlayer().getInventory().getHeldItemSlot();
ItemStack item = e.getPlayer().getItemInHand();
item.setAmount(item.getAmount()-1);
@ -215,16 +186,16 @@ public class campfire_2 extends Furniture implements Listener{
}
private void setfire(boolean b){
for(ArmorStandPacket pack : manager.getArmorStandPacketByObjectID(obj)){
if(pack.isMini() && pack.isInvisible()){
for(fArmorStand pack : getManager().getfArmorStandByObjectID(getObjID())){
if(pack.isSmall() && pack.isVisible()){
if((pack.getInventory().getHelmet() == null || pack.getInventory().getHelmet().getType().equals(Material.AIR)) &&
(pack.getInventory().getItemInHand() == null || pack.getInventory().getItemInHand().getType().equals(Material.AIR))){
pack.setFire(b);
Location loc = middle.clone();
loc.add(0, 1.3, 0);
if(b) lib.getLightManager().addLight(loc, 15);
if(!b) lib.getLightManager().removeLight(loc);
manager.updateFurniture(obj);
if(b) getLib().getLightManager().addLight(loc, 15);
if(!b) getLib().getLightManager().removeLight(loc);
getManager().updateFurniture(getObjID());
return;
}
@ -234,20 +205,20 @@ public class campfire_2 extends Furniture implements Listener{
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
if(isRunning()){
Bukkit.getScheduler().cancelTask(timer);
timer=null;
w.dropItem(middle.clone().add(0, .5, 0), is);
getWorld().dropItem(middle.clone().add(0, .5, 0), is);
}
setfire(false);
e.remove();
obj=null;
delete();
}
public void removeGrill(){
@ -255,15 +226,15 @@ public class campfire_2 extends Furniture implements Listener{
Bukkit.getScheduler().cancelTask(timer);
timer=null;
if(armorS!=null&&armorS.getInventory().getItemInHand()!=null&&getItem(armorS.getInventory().getItemInHand())!=null){
w.dropItem(middle.clone().add(0, .5, 0), getCooked(is));
armorS.destroy();
getWorld().dropItem(middle.clone().add(0, .5, 0), getCooked(is));
armorS.kill();
armorS.delete();
armorS=null;
}
}
if(armorS!=null){
if(armorS.getInventory().getItemInHand()!=null){w.dropItem(middle.clone().add(0, .5, 0), getCooked(is));}
armorS.destroy();
if(armorS.getInventory().getItemInHand()!=null){getWorld().dropItem(middle.clone().add(0, .5, 0), getCooked(is));}
armorS.kill();
armorS.delete();
armorS=null;
}
@ -293,12 +264,12 @@ public class campfire_2 extends Furniture implements Listener{
}
public void setGrill(){
this.armorS = manager.createArmorStand(obj, grill);
this.armorS = getManager().createArmorStand(getObjID(), grill);
this.armorS.setInvisible(true);
this.armorS.getInventory().setItemInHand(is);
manager.send(obj);
getManager().send(getObjID());
this.timer = main.getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(main.getInstance(), new Runnable() {
Integer rounds = lutil.randInt(15, 30);
Integer rounds = getLutil().randInt(15, 30);
Integer labs = 0;
Integer position = 0;
@Override

View File

@ -1,80 +1,51 @@
package de.Ste3et_C0st.Furniture.Objects.outdoor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
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.FurnitureBlockBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBlockClickEvent;
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.EventType;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class hammock extends Furniture{
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Integer id;
Block block;
Plugin plugin;
public class hammock extends Furniture implements Listener{
List<Block> blockList = new ArrayList<Block>();
public ObjectID getObjectID(){return this.obj;}
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
public hammock(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;
public hammock(Plugin plugin, ObjectID id) {
super(plugin, id);
setBlock();
if(id.isFinish()){
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
spawn(loc);
spawn(id.getStartLocation());
}
private void setBlock(){
BlockFace Right = lutil.yawToFace(lutil.FaceToYaw(b)+90);
Location center2 = lutil.getRelativ(loc, Right, 6D, 0D);
Block b1 = this.loc.getBlock();
Block b2 = this.loc.getBlock().getRelative(BlockFace.UP);
BlockFace Right = getLutil().yawToFace(getLutil().FaceToYaw(getBlockFace())+90);
Location center2 = getLutil().getRelativ(getLocation(), Right, 6D, 0D);
Block b1 = getLocation().getBlock();
Block b2 = getLocation().getBlock().getRelative(BlockFace.UP);
Block b3 = center2.getBlock();
Block b4 = center2.getBlock().getRelative(BlockFace.UP);
@ -82,11 +53,8 @@ public class hammock extends Furniture{
if(!isFence(b2.getType())) b2.setType(Material.FENCE);
if(!isFence(b3.getType())) b3.setType(Material.FENCE);
if(!isFence(b4.getType())) b4.setType(Material.FENCE);
blockList.add(b1);
blockList.add(b2);
blockList.add(b3);
blockList.add(b4);
getObjID().addBlock(Arrays.asList(b1,b2,b3,b4));
}
private boolean isFence(Material m){
@ -108,39 +76,46 @@ public class hammock extends Furniture{
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) {
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
for(Block b : blockList){
if(b!=null){
b.setType(Material.AIR);
}
}
e.remove();
blockList.clear();
delete();
}
@EventHandler
public void onFurnitureBreak(FurnitureBlockBreakEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.remove();
delete();
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e) {
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
List<ArmorStandPacket> aspList = manager.getArmorStandPacketByObjectID(obj);
if(!e.getID().equals(getObjID())){return;}
List<fArmorStand> aspList = getManager().getfArmorStandByObjectID(getObjID());
Player p = e.getPlayer();
ItemStack stack = p.getItemInHand();
if(stack!=null){
if(isMaterial(stack.getType())){
if(setColor(p,stack, e.canBuild(), aspList)){return;}
if(setColor(p,stack, getLib().canBuild(e.getPlayer(), getObjID(), EventType.INTERACT), aspList)){return;}
}
}
for(ArmorStandPacket packet : aspList){
for(fArmorStand packet : aspList){
if(packet.getName().equalsIgnoreCase("#SITZ#")){
if(packet.getPessanger()==null){
packet.setPessanger(e.getPlayer());
if(packet.getPassanger()==null){
packet.setPassanger(e.getPlayer());
return;
}
}
@ -158,80 +133,62 @@ public class hammock extends Furniture{
}
@EventHandler
private void onClick(PlayerInteractEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
public void onFurnitureClick(FurnitureBlockClickEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(e.getClickedBlock()==null){return;}
if(e.getAction() == null){return;}
if(e.getPlayer()==null){return;}
if(!blockList.contains(e.getClickedBlock())){return;}
if(e.getAction().equals(Action.LEFT_CLICK_BLOCK)){
e.setCancelled(true);
if(!lib.canBuild(e.getPlayer(), obj, EventType.BREAK)){return;}
for(Block b : blockList){
if(b!=null){
b.setType(Material.AIR);
}
if(!e.getID().equals(getObjID())){return;}
List<fArmorStand> aspList = getManager().getfArmorStandByObjectID(getObjID());
Player p = e.getPlayer();
ItemStack stack = p.getItemInHand();
if(stack!=null){
if(isMaterial(stack.getType())){
if(setColor(p,stack, e.canBuild(), aspList)){return;}
}
obj.remove(e.getPlayer());
blockList.clear();
return;
}else if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
e.setCancelled(true);
List<ArmorStandPacket> aspList = manager.getArmorStandPacketByObjectID(obj);
Player p = e.getPlayer();
ItemStack stack = p.getItemInHand();
if(stack!=null){
if(isMaterial(stack.getType())){
if(setColor(p,stack, lib.canBuild(e.getPlayer(), obj, EventType.INTERACT), aspList)){return;}
}
}
for(ArmorStandPacket packet : aspList){
if(packet.getName().equalsIgnoreCase("#SITZ#")){
if(packet.getPessanger()==null){
packet.setPessanger(e.getPlayer());
return;
}
}
for(fArmorStand packet : aspList){
if(packet.getName().equalsIgnoreCase("#SITZ#")){
if(packet.getPassanger()==null){
packet.setPassanger(e.getPlayer());
return;
}
}
}
}
private boolean setColor(Player p,ItemStack stack, Boolean canbuild, List<ArmorStandPacket> aspList){
private boolean setColor(Player p,ItemStack stack, Boolean canbuild, List<fArmorStand> aspList){
if(!canbuild){return true;}
if(stack!=null){
switch (stack.getType()) {
case BANNER:
for(ArmorStandPacket packet : aspList){
for(fArmorStand packet : aspList){
if(packet.getInventory().getHelmet()!=null&&packet.getInventory().getHelmet().getType().equals(Material.BANNER)){
packet.getInventory().setHelmet(stack);
}
}
removeItem(p);
manager.updateFurniture(obj);
getManager().updateFurniture(getObjID());
return true;
case LOG:
for(ArmorStandPacket packet : aspList){
for(fArmorStand packet : aspList){
if(packet.getName().equalsIgnoreCase("#PILLAR#")){
packet.getInventory().setHelmet(stack);
}
}
setPillar(stack.getDurability());
removeItem(p);
manager.updateFurniture(obj);
getManager().updateFurniture(getObjID());
return true;
case LOG_2:
for(ArmorStandPacket packet : aspList){
for(fArmorStand packet : aspList){
if(packet.getName().equalsIgnoreCase("#PILLAR#")){
packet.getInventory().setHelmet(stack);
}
}
setPillar(4 + stack.getDurability());
removeItem(p);
manager.updateFurniture(obj);
getManager().updateFurniture(getObjID());
return true;
default: break;
}
@ -250,100 +207,100 @@ public class hammock extends Furniture{
case 5: m = Material.DARK_OAK_FENCE;break;
}
if(m!=null){
for(Block b : blockList){
b.setType(m);
for(Location b : getObjID().getBlockList()){
getWorld().getBlockAt(b).setType(m);
}
}
}
public void spawn(Location location) {
Location center1 = lutil.getCenter(location);
Location center1 = getLutil().getCenter(location);
center1 = center1.add(0, -1.9, 0);
BlockFace Right = lutil.yawToFace(lutil.FaceToYaw(b)+90);
Location center2 = lutil.getRelativ(center1, Right, 6D, 0D);
List<ArmorStandPacket> aspList = new ArrayList<ArmorStandPacket>();
BlockFace Right = getLutil().yawToFace(getLutil().FaceToYaw(getBlockFace())+90);
Location center2 = getLutil().getRelativ(center1, Right, 6D, 0D);
List<fArmorStand> aspList = new ArrayList<fArmorStand>();
ArmorStandPacket packet = manager.createArmorStand(obj, center1);
fArmorStand packet = getManager().createArmorStand(getObjID(), center1);
packet.getInventory().setHelmet(new ItemStack(Material.LOG));
packet.setName("#PILLAR#");
aspList.add(packet);
packet = manager.createArmorStand(obj, center2);
packet = getManager().createArmorStand(getObjID(), center2);
packet.getInventory().setHelmet(new ItemStack(Material.LOG));
packet.setName("#PILLAR#");
aspList.add(packet);
Location middle = lutil.getRelativ(center1, Right, 2.85D, 0D);
Location middle = getLutil().getRelativ(center1, Right, 2.85D, 0D);
middle = middle.add(0, .75, 0);
packet = manager.createArmorStand(obj, middle);
packet = getManager().createArmorStand(getObjID(), middle);
packet.getInventory().setHelmet(new ItemStack(Material.BANNER, 1, (short) 0));
packet.setPose(lutil.degresstoRad(new EulerAngle(-69f,0f,0f)), BodyPart.HEAD);
packet.setPose(getLutil().degresstoRad(new EulerAngle(-69f,0f,0f)), BodyPart.HEAD);
aspList.add(packet);
Location middle2 = lutil.getRelativ(middle, Right, 1.5D, 0D);
Location middle2 = getLutil().getRelativ(middle, Right, 1.5D, 0D);
middle2 = middle2.add(0, .23, 0);
packet = manager.createArmorStand(obj, middle2);
packet = getManager().createArmorStand(getObjID(), middle2);
packet.getInventory().setHelmet(new ItemStack(Material.BANNER, 1, (short) 0));
packet.setPose(lutil.degresstoRad(new EulerAngle(-90f,0f,0f)), BodyPart.HEAD);
packet.setPose(getLutil().degresstoRad(new EulerAngle(-90f,0f,0f)), BodyPart.HEAD);
aspList.add(packet);
Location sitz = lutil.getRelativ(center1, Right, 3D, 0D).add(0, .6, 0);
sitz.setYaw(lutil.FaceToYaw(b.getOppositeFace()));
packet = manager.createArmorStand(obj, sitz);
Location sitz = getLutil().getRelativ(center1, Right, 3D, 0D).add(0, .6, 0);
sitz.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()));
packet = getManager().createArmorStand(getObjID(), sitz);
packet.setName("#SITZ#");
aspList.add(packet);
middle = lutil.getRelativ(middle, Right, .3D, 0D);
middle = getLutil().getRelativ(middle, Right, .3D, 0D);
middle.setYaw(middle.getYaw()+180);
packet = manager.createArmorStand(obj, middle);
packet = getManager().createArmorStand(getObjID(), middle);
packet.getInventory().setHelmet(new ItemStack(Material.BANNER, 1, (short) 0));
packet.setPose(lutil.degresstoRad(new EulerAngle(-69f,0f,0f)), BodyPart.HEAD);
packet.setPose(getLutil().degresstoRad(new EulerAngle(-69f,0f,0f)), BodyPart.HEAD);
aspList.add(packet);
Location stick = lutil.getRelativ(center1, Right, 4.6d, .5d);
Location stick = getLutil().getRelativ(center1, Right, 4.6d, .5d);
stick = stick.add(0, 1.7, 0);
stick.setYaw(lutil.FaceToYaw(b));
packet = manager.createArmorStand(obj, stick);
stick.setYaw(getLutil().FaceToYaw(getBlockFace()));
packet = getManager().createArmorStand(getObjID(), stick);
packet.getInventory().setItemInHand(new ItemStack(Material.STICK));
packet.setPose(lutil.degresstoRad(new EulerAngle(-40f,110f,0f)), BodyPart.RIGHT_ARM);
packet.setPose(getLutil().degresstoRad(new EulerAngle(-40f,110f,0f)), BodyPart.RIGHT_ARM);
aspList.add(packet);
stick = lutil.getRelativ(center1, Right, 4.6d, -.335d);
stick = getLutil().getRelativ(center1, Right, 4.6d, -.335d);
stick = stick.add(0, 1.7, 0);
stick.setYaw(lutil.FaceToYaw(b));
packet = manager.createArmorStand(obj, stick);
stick.setYaw(getLutil().FaceToYaw(getBlockFace()));
packet = getManager().createArmorStand(getObjID(), stick);
packet.getInventory().setItemInHand(new ItemStack(Material.STICK));
packet.setPose(lutil.degresstoRad(new EulerAngle(-40f,73f,0f)), BodyPart.RIGHT_ARM);
packet.setPose(getLutil().degresstoRad(new EulerAngle(-40f,73f,0f)), BodyPart.RIGHT_ARM);
packet.setArms(true);
aspList.add(packet);
stick = lutil.getRelativ(center1, Right.getOppositeFace(), -1.37d, -.335d);
stick = getLutil().getRelativ(center1, Right.getOppositeFace(), -1.37d, -.335d);
stick = stick.add(0, 1.7, 0);
stick.setYaw(lutil.FaceToYaw(b.getOppositeFace()));
packet = manager.createArmorStand(obj, stick);
stick.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()));
packet = getManager().createArmorStand(getObjID(), stick);
packet.getInventory().setItemInHand(new ItemStack(Material.STICK));
packet.setPose(lutil.degresstoRad(new EulerAngle(-40f,73f,0f)), BodyPart.RIGHT_ARM);
packet.setPose(getLutil().degresstoRad(new EulerAngle(-40f,73f,0f)), BodyPart.RIGHT_ARM);
packet.setArms(true);
aspList.add(packet);
stick = lutil.getRelativ(center1, Right.getOppositeFace(), -1.37d, .5d);
stick = getLutil().getRelativ(center1, Right.getOppositeFace(), -1.37d, .5d);
stick = stick.add(0, 1.7, 0);
stick.setYaw(lutil.FaceToYaw(b.getOppositeFace()));
packet = manager.createArmorStand(obj, stick);
stick.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()));
packet = getManager().createArmorStand(getObjID(), stick);
packet.getInventory().setItemInHand(new ItemStack(Material.STICK));
packet.setPose(lutil.degresstoRad(new EulerAngle(-40f,110f,0f)), BodyPart.RIGHT_ARM);
packet.setPose(getLutil().degresstoRad(new EulerAngle(-40f,110f,0f)), BodyPart.RIGHT_ARM);
packet.setArms(true);
aspList.add(packet);
for(ArmorStandPacket pack : aspList){
for(fArmorStand pack : aspList){
pack.setInvisible(true);
pack.setGravity(false);
pack.setBasePlate(false);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
}

View File

@ -1,12 +1,12 @@
package de.Ste3et_C0st.Furniture.Objects.outdoor;
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.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
@ -17,51 +17,25 @@ 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.ColorType;
import de.Ste3et_C0st.FurnitureLib.main.Type.EventType;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class tent_1 extends Furniture implements Listener{
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Integer id;
Block block;
Plugin plugin;
public ObjectID getObjectID(){return this.obj;}
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
public tent_1(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;
if(b.equals(BlockFace.WEST)){loc=lutil.getRelativ(loc, b, 1D, 0D);}
if(b.equals(BlockFace.NORTH)){loc=lutil.getRelativ(loc, b, 1D, 1D);}
if(b.equals(BlockFace.EAST)){loc=lutil.getRelativ(loc, b, 0D, 1D);}
this.obj = id;
public tent_1(Plugin plugin, ObjectID id){
super(plugin, id);
Location loc = id.getStartLocation();
if(getBlockFace().equals(BlockFace.WEST)){loc=getLutil().getRelativ(loc, getBlockFace(), 1D, 0D);}
if(getBlockFace().equals(BlockFace.NORTH)){loc=getLutil().getRelativ(loc, getBlockFace(), 1D, 1D);}
if(getBlockFace().equals(BlockFace.EAST)){loc=getLutil().getRelativ(loc, getBlockFace(), 0D, 1D);}
if(id.isFinish()){
setblock();
Bukkit.getPluginManager().registerEvents(this, plugin);
@ -71,78 +45,79 @@ public class tent_1 extends Furniture implements Listener{
}
public void setblock(){
Location blockLocation = new Location(loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
if(b.equals(BlockFace.SOUTH)){
this.block = blockLocation.getWorld().getBlockAt(lutil.getRelativ(blockLocation, b, 2D, -2D));
Location blockLocation = new Location(getWorld(), getLocation().getBlockX(), getLocation().getBlockY(), getLocation().getBlockZ());
if(getBlockFace().equals(BlockFace.SOUTH)){
this.block = blockLocation.getWorld().getBlockAt(getLutil().getRelativ(blockLocation, getBlockFace(), 2D, -2D));
this.block.setType(Material.WORKBENCH);
}else if(b.equals(BlockFace.WEST)){
this.block = blockLocation.getWorld().getBlockAt(lutil.getRelativ(blockLocation, b, 1D, -2D));
}else if(getBlockFace().equals(BlockFace.WEST)){
this.block = blockLocation.getWorld().getBlockAt(getLutil().getRelativ(blockLocation, getBlockFace(), 2D, -2D));
this.block.setType(Material.WORKBENCH);
}else if(b.equals(BlockFace.NORTH)){
this.block = blockLocation.getWorld().getBlockAt(lutil.getRelativ(blockLocation, b, 1D, -3D));
}else if(getBlockFace().equals(BlockFace.NORTH)){
this.block = blockLocation.getWorld().getBlockAt(getLutil().getRelativ(blockLocation, getBlockFace(), 2D, -2D));
this.block.setType(Material.WORKBENCH);
}else if(b.equals(BlockFace.EAST)){
this.block = blockLocation.getWorld().getBlockAt(lutil.getRelativ(blockLocation, b, 2D, -3D));
}else if(getBlockFace().equals(BlockFace.EAST)){
this.block = blockLocation.getWorld().getBlockAt(getLutil().getRelativ(blockLocation, getBlockFace(), 2D, -2D));
this.block.setType(Material.WORKBENCH);
}
getObjID().addBlock(Arrays.asList(block));
}
private Location getNew(Location loc, BlockFace b){
if(b.equals(BlockFace.WEST)){loc=lutil.getRelativ(loc, b, -1D, 0D);}
if(b.equals(BlockFace.NORTH)){loc=lutil.getRelativ(loc, b, -1D, -1D);}
if(b.equals(BlockFace.EAST)){loc=lutil.getRelativ(loc, b, 0D, -1D);}
if(b.equals(BlockFace.WEST)){loc=getLutil().getRelativ(loc, b, -1D, 0D);}
if(b.equals(BlockFace.NORTH)){loc=getLutil().getRelativ(loc, b, -1D, -1D);}
if(b.equals(BlockFace.EAST)){loc=getLutil().getRelativ(loc, b, 0D, -1D);}
return loc;
}
public void spawn(Location loc){
List<ArmorStandPacket> aspList = new ArrayList<ArmorStandPacket>();
List<fArmorStand> aspList = new ArrayList<fArmorStand>();
Location loc_1 = new Location(loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
Location loc_2 = new Location(loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
Location loc_3 = new Location(loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
Location karabine1 = getNew(lutil.getRelativ(loc, b, 0D, 0D), b);
Location karabine2 = getNew(lutil.getRelativ(loc, b, 3D, 0D), b);
Location karabine3 = getNew(lutil.getRelativ(loc, b, 3D, -4D), b);
Location karabine4 = getNew(lutil.getRelativ(loc, b, 0D, -4D), b);
Location karabine1 = getNew(getLutil().getRelativ(loc, getBlockFace(), 0D, 0D), getBlockFace());
Location karabine2 = getNew(getLutil().getRelativ(loc, getBlockFace(), 3D, 0D), getBlockFace());
Location karabine3 = getNew(getLutil().getRelativ(loc, getBlockFace(), 3D, -4D), getBlockFace());
Location karabine4 = getNew(getLutil().getRelativ(loc, getBlockFace(), 0D, -4D), getBlockFace());
karabine1 = lutil.getCenter(karabine1);
karabine2 = lutil.getCenter(karabine2);
karabine3 = lutil.getCenter(karabine3);
karabine4 = lutil.getCenter(karabine4);
karabine1.setYaw(lutil.FaceToYaw(b)+90);
karabine2.setYaw(lutil.FaceToYaw(b)+90);
karabine3.setYaw(lutil.FaceToYaw(b)+90);
karabine4.setYaw(lutil.FaceToYaw(b)+90);
karabine1 = getLutil().getCenter(karabine1);
karabine2 = getLutil().getCenter(karabine2);
karabine3 = getLutil().getCenter(karabine3);
karabine4 = getLutil().getCenter(karabine4);
karabine1.setYaw(getLutil().FaceToYaw(getBlockFace())+90);
karabine2.setYaw(getLutil().FaceToYaw(getBlockFace())+90);
karabine3.setYaw(getLutil().FaceToYaw(getBlockFace())+90);
karabine4.setYaw(getLutil().FaceToYaw(getBlockFace())+90);
Location saveLoc = lutil.getRelativ(loc_1, b, -.55D, -0.6);
Location saveLoc = getLutil().getRelativ(loc_1, getBlockFace(), -.55D, -0.6);
saveLoc.add(0,-1.25,0);
saveLoc.setYaw(lutil.FaceToYaw(b) -90);
saveLoc.setYaw(getLutil().FaceToYaw(getBlockFace()) -90);
Location saveLoc2 = lutil.getRelativ(loc_2, b, -4.27, -4.4);
Location saveLoc2 = getLutil().getRelativ(loc_2, getBlockFace(), -4.27, -4.4);
saveLoc2.add(0,-1.25,0);
saveLoc2.setYaw(lutil.FaceToYaw(b) -90);
saveLoc2.setYaw(getLutil().FaceToYaw(getBlockFace()) -90);
Location saveLoc3 = lutil.getRelativ(loc_3, b, -8D, -2.5D);
Location saveLoc3 = getLutil().getRelativ(loc_3, getBlockFace(), -8D, -2.5D);
saveLoc3.add(0,.64,0);
saveLoc3.setYaw(lutil.FaceToYaw(b) -90);
saveLoc3.setYaw(getLutil().FaceToYaw(getBlockFace()) -90);
Double d = .0;
setblock();
for(int i = 0; i<=5;i++){
Location loc1= lutil.getRelativ(saveLoc, b, d, 0D);
Location loc2= lutil.getRelativ(saveLoc, b, d, -.48).add(0,.3,0);
Location loc3= lutil.getRelativ(saveLoc, b, d, -.86).add(0,.81,0);
Location loc4= lutil.getRelativ(saveLoc, b, d, -1.08).add(0,1.33,0);
Location loc5= lutil.getRelativ(saveLoc, b, d, -1.38).add(0,1.86,0);
Location loc1= getLutil().getRelativ(saveLoc, getBlockFace(), d, 0D);
Location loc2= getLutil().getRelativ(saveLoc, getBlockFace(), d, -.48).add(0,.3,0);
Location loc3= getLutil().getRelativ(saveLoc, getBlockFace(), d, -.86).add(0,.81,0);
Location loc4= getLutil().getRelativ(saveLoc, getBlockFace(), d, -1.08).add(0,1.33,0);
Location loc5= getLutil().getRelativ(saveLoc, getBlockFace(), d, -1.38).add(0,1.86,0);
loc1.setYaw(lutil.FaceToYaw(b.getOppositeFace()));
loc2.setYaw(lutil.FaceToYaw(b.getOppositeFace()));
loc3.setYaw(lutil.FaceToYaw(b.getOppositeFace()));
loc4.setYaw(lutil.FaceToYaw(b.getOppositeFace()));
loc5.setYaw(lutil.FaceToYaw(b.getOppositeFace()));
loc1.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()));
loc2.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()));
loc3.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()));
loc4.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()));
loc5.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()));
loc.add(loc1);
loc.add(loc2);
@ -150,23 +125,23 @@ public class tent_1 extends Furniture implements Listener{
loc.add(loc4);
loc.add(loc5);
ArmorStandPacket asp = manager.createArmorStand(obj, loc1);
fArmorStand asp = getManager().createArmorStand(getObjID(), loc1);
asp.getInventory().setHelmet(new ItemStack(Material.CARPET));
asp.setPose(new EulerAngle(0, 0, -.2), BodyPart.HEAD);
aspList.add(asp);
asp = manager.createArmorStand(obj, loc2);
asp = getManager().createArmorStand(getObjID(), loc2);
asp.getInventory().setHelmet(new ItemStack(Material.CARPET));
asp.setPose(new EulerAngle(0, 0, -7.2), BodyPart.HEAD);
aspList.add(asp);
asp = manager.createArmorStand(obj, loc3);
asp = getManager().createArmorStand(getObjID(), loc3);
asp.getInventory().setHelmet(new ItemStack(Material.CARPET));
asp.setPose(new EulerAngle(0, 0, -7.2), BodyPart.HEAD);
aspList.add(asp);
asp = manager.createArmorStand(obj, loc4);
asp = getManager().createArmorStand(getObjID(), loc4);
asp.getInventory().setHelmet(new ItemStack(Material.CARPET));
asp.setPose(new EulerAngle(0, 0, -7.7), BodyPart.HEAD);
aspList.add(asp);
asp = manager.createArmorStand(obj, loc5);
asp = getManager().createArmorStand(getObjID(), loc5);
asp.getInventory().setHelmet(new ItemStack(Material.CARPET));
asp.setPose(new EulerAngle(0, 0, -.7), BodyPart.HEAD);
aspList.add(asp);
@ -174,17 +149,17 @@ public class tent_1 extends Furniture implements Listener{
}
for(int i = 0; i<=5;i++){
Location loc1= lutil.getRelativ(saveLoc2, b, d, .02D);
Location loc2= lutil.getRelativ(saveLoc2, b, d, .48).add(0,.3,0);
Location loc3= lutil.getRelativ(saveLoc2, b, d, .86).add(0,.81,0);
Location loc4= lutil.getRelativ(saveLoc2, b, d, 1.08).add(0,1.33,0);
Location loc5= lutil.getRelativ(saveLoc2, b, d, 1.38).add(0,1.86,0);
Location loc1= getLutil().getRelativ(saveLoc2, getBlockFace(), d, .02D);
Location loc2= getLutil().getRelativ(saveLoc2, getBlockFace(), d, .48).add(0,.3,0);
Location loc3= getLutil().getRelativ(saveLoc2, getBlockFace(), d, .86).add(0,.81,0);
Location loc4= getLutil().getRelativ(saveLoc2, getBlockFace(), d, 1.08).add(0,1.33,0);
Location loc5= getLutil().getRelativ(saveLoc2, getBlockFace(), d, 1.38).add(0,1.86,0);
loc1.setYaw(lutil.FaceToYaw(b));
loc2.setYaw(lutil.FaceToYaw(b));
loc3.setYaw(lutil.FaceToYaw(b));
loc4.setYaw(lutil.FaceToYaw(b));
loc5.setYaw(lutil.FaceToYaw(b));
loc1.setYaw(getLutil().FaceToYaw(getBlockFace()));
loc2.setYaw(getLutil().FaceToYaw(getBlockFace()));
loc3.setYaw(getLutil().FaceToYaw(getBlockFace()));
loc4.setYaw(getLutil().FaceToYaw(getBlockFace()));
loc5.setYaw(getLutil().FaceToYaw(getBlockFace()));
loc.add(loc1);
loc.add(loc2);
@ -192,23 +167,23 @@ public class tent_1 extends Furniture implements Listener{
loc.add(loc4);
loc.add(loc5);
ArmorStandPacket asp = manager.createArmorStand(obj, loc1);
fArmorStand asp = getManager().createArmorStand(getObjID(), loc1);
asp.getInventory().setHelmet(new ItemStack(Material.CARPET));
asp.setPose(new EulerAngle(0, 0, -.2), BodyPart.HEAD);
aspList.add(asp);
asp = manager.createArmorStand(obj, loc2);
asp = getManager().createArmorStand(getObjID(), loc2);
asp.getInventory().setHelmet(new ItemStack(Material.CARPET));
asp.setPose(new EulerAngle(0, 0, -7.2), BodyPart.HEAD);
aspList.add(asp);
asp = manager.createArmorStand(obj, loc3);
asp = getManager().createArmorStand(getObjID(), loc3);
asp.getInventory().setHelmet(new ItemStack(Material.CARPET));
asp.setPose(new EulerAngle(0, 0, -7.2), BodyPart.HEAD);
aspList.add(asp);
asp = manager.createArmorStand(obj, loc4);
asp = getManager().createArmorStand(getObjID(), loc4);
asp.getInventory().setHelmet(new ItemStack(Material.CARPET));
asp.setPose(new EulerAngle(0, 0, -7.7), BodyPart.HEAD);
aspList.add(asp);
asp = manager.createArmorStand(obj, loc5);
asp = getManager().createArmorStand(getObjID(), loc5);
asp.getInventory().setHelmet(new ItemStack(Material.CARPET));
asp.setPose(new EulerAngle(0, 0, -.7), BodyPart.HEAD);
aspList.add(asp);
@ -217,89 +192,89 @@ public class tent_1 extends Furniture implements Listener{
//middle
for(int i = 0; i<=5;i++){
Location loc1= lutil.getRelativ(saveLoc3, b, d, 0D);
loc1.setYaw(lutil.FaceToYaw(b.getOppositeFace()));
Location loc1= getLutil().getRelativ(saveLoc3, getBlockFace(), d, 0D);
loc1.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()));
loc.add(loc1);
ArmorStandPacket asp = manager.createArmorStand(obj, loc1);
fArmorStand asp = getManager().createArmorStand(getObjID(), loc1);
asp.getInventory().setHelmet( new ItemStack(Material.WOOD_STEP));
aspList.add(asp);
d+=.62;
}
ArmorStandPacket asp = manager.createArmorStand(obj, karabine1.add(0,-1.9,0));
fArmorStand asp = getManager().createArmorStand(getObjID(), karabine1.add(0,-1.9,0));
asp.getInventory().setHelmet(new ItemStack(Material.TRIPWIRE_HOOK));
aspList.add(asp);
asp = manager.createArmorStand(obj, karabine2.add(0,-1.9,0));
asp = getManager().createArmorStand(getObjID(), karabine2.add(0,-1.9,0));
asp.getInventory().setHelmet(new ItemStack(Material.TRIPWIRE_HOOK));
aspList.add(asp);
asp = manager.createArmorStand(obj, karabine3.add(0,-1.9,0));
asp = getManager().createArmorStand(getObjID(), karabine3.add(0,-1.9,0));
asp.getInventory().setHelmet(new ItemStack(Material.TRIPWIRE_HOOK));
aspList.add(asp);
asp = manager.createArmorStand(obj, karabine4.add(0,-1.9,0));
asp = getManager().createArmorStand(getObjID(), karabine4.add(0,-1.9,0));
asp.getInventory().setHelmet(new ItemStack(Material.TRIPWIRE_HOOK));
aspList.add(asp);
Location crafting = lutil.getCenter(block.getLocation());
crafting.setYaw(lutil.FaceToYaw(b)+90);
Location crafting = getLutil().getCenter(block.getLocation());
crafting.setYaw(getLutil().FaceToYaw(getBlockFace())+90);
asp = manager.createArmorStand(obj, crafting.add(0,-1,0).clone());
asp = getManager().createArmorStand(getObjID(), 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).clone());
asp = getManager().createArmorStand(getObjID(), crafting.add(0,.62,0).clone());
asp.getInventory().setHelmet(new ItemStack(Material.LADDER));
aspList.add(asp);
for(ArmorStandPacket packet : aspList){
for(fArmorStand packet : aspList){
packet.setInvisible(true);
packet.setGravity(false);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
block.setType(Material.AIR);
e.remove();
obj=null;
delete();
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
final Player p = e.getPlayer();
if(!p.getItemInHand().getType().equals(Material.INK_SACK)){
p.openWorkbench(this.block.getLocation(), true);
}else{
lib.getColorManager().color(p, e.canBuild(), Material.CARPET, obj, ColorType.BLOCK, 1);
getLib().getColorManager().color(p, e.canBuild(), Material.CARPET, getObjID(), ColorType.BLOCK, 1);
}
}
@EventHandler
private void onBlockBreak(BlockBreakEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(e.getBlock()==null){return;}
if(block==null){return;}
if(!e.getBlock().equals(block)){return;}
if(!lib.canBuild(e.getPlayer(), obj, EventType.BREAK)){e.getPlayer().sendMessage("ERROR1");return;}
if(!getLib().canBuild(e.getPlayer(), getObjID(), EventType.BREAK)){return;}
if(this.block!=null&&e.getBlock().equals(block)){this.block.setType(Material.AIR);this.block=null;}
this.obj.remove(e.getPlayer());
obj=null;
this.getObjID().remove(e.getPlayer());
delete();
}
}

View File

@ -1,12 +1,12 @@
package de.Ste3et_C0st.Furniture.Objects.outdoor;
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.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
@ -18,60 +18,33 @@ 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.ColorType;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class tent_2 extends Furniture implements Listener{
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Integer id;
List<Block> block = new ArrayList<Block>();
Plugin plugin;
Location bedLoc;
public ObjectID getObjectID(){return this.obj;}
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
public tent_2(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;
if(b.equals(BlockFace.WEST)){loc=lutil.getRelativ(loc, b, 1D, 0D);}
if(b.equals(BlockFace.NORTH)){loc=lutil.getRelativ(loc, b, 1D, 1D);}
if(b.equals(BlockFace.EAST)){loc=lutil.getRelativ(loc, b, 0D, 1D);}
this.obj = id;
public tent_2(Plugin plugin, ObjectID id){
super(plugin, id);
Location loc = getLocation();
if(getBlockFace().equals(BlockFace.WEST)){loc=getLutil().getRelativ(loc, getBlockFace(), 1D, 0D);}
if(getBlockFace().equals(BlockFace.NORTH)){loc=getLutil().getRelativ(loc, getBlockFace(), 1D, 1D);}
if(getBlockFace().equals(BlockFace.EAST)){loc=getLutil().getRelativ(loc, getBlockFace(), 0D, 1D);}
Location loca = loc.clone();
switch (b) {
case NORTH: loca=lutil.getRelativ(loca, b, -1D, -1D); break;
case EAST: loca=lutil.getRelativ(loca, b, 0D, -1D); break;
case WEST: loca=lutil.getRelativ(loca, b, -1D, 0D); break;
switch (getBlockFace()) {
case NORTH: loca=getLutil().getRelativ(loca, getBlockFace(), -1D, -1D); break;
case EAST: loca=getLutil().getRelativ(loca, getBlockFace(), 0D, -1D); break;
case WEST: loca=getLutil().getRelativ(loca, getBlockFace(), -1D, 0D); break;
default:break;
}
@ -86,37 +59,37 @@ public class tent_2 extends Furniture implements Listener{
public void spawn(Location loc){
List<ArmorStandPacket> aspl = new ArrayList<ArmorStandPacket>();
loc=lutil.getRelativ(loc, b, -.91D, -0.75D);
List<fArmorStand> aspl = new ArrayList<fArmorStand>();
loc=getLutil().getRelativ(loc, getBlockFace(), -.91D, -0.75D);
Location LeftLocation = loc;
LeftLocation.add(0,-.75,0);
Location RightLocation = lutil.getRelativ(LeftLocation, b, 0D, -4.55D);
Location MiddleLocation = lutil.getRelativ(LeftLocation, b, 0D, -2.27D).add(0,2.4,0);
Location LeftSart = lutil.getRelativ(LeftLocation, b, 3.87D, -.2D);
Location RightSart = lutil.getRelativ(RightLocation, b, 3.87D, .2D);
Location RightLocation = getLutil().getRelativ(LeftLocation, getBlockFace(), 0D, -4.55D);
Location MiddleLocation = getLutil().getRelativ(LeftLocation, getBlockFace(), 0D, -2.27D).add(0,2.4,0);
Location LeftSart = getLutil().getRelativ(LeftLocation, getBlockFace(), 3.87D, -.2D);
Location RightSart = getLutil().getRelativ(RightLocation, getBlockFace(), 3.87D, .2D);
Double d = .0;
for(int i = 0; i<=8;i++){
Location loc1= lutil.getRelativ(LeftLocation, b, d, 0D);
loc1.setYaw(lutil.FaceToYaw(b));
ArmorStandPacket as = manager.createArmorStand(obj, loc1);
Location loc1= getLutil().getRelativ(LeftLocation, getBlockFace(), d, 0D);
loc1.setYaw(getLutil().FaceToYaw(getBlockFace()));
fArmorStand as = getManager().createArmorStand(getObjID(), loc1);
as.getInventory().setHelmet(new ItemStack(Material.LOG));
as.setSmall(true);
as.setPose(new EulerAngle(1.568, 0, 0), BodyPart.HEAD);
aspl.add(as);
Location loc2= lutil.getRelativ(RightLocation, b, d, 0D);
loc2.setYaw(lutil.FaceToYaw(b));
as = manager.createArmorStand(obj, loc2);
Location loc2= getLutil().getRelativ(RightLocation, getBlockFace(), d, 0D);
loc2.setYaw(getLutil().FaceToYaw(getBlockFace()));
as = getManager().createArmorStand(getObjID(), loc2);
as.getInventory().setHelmet(new ItemStack(Material.LOG));
as.setSmall(true);
as.setPose(new EulerAngle(1.568, 0, 0), BodyPart.HEAD);
aspl.add(as);
Location loc3= lutil.getRelativ(MiddleLocation, b, d, 0D);
loc3.setYaw(lutil.FaceToYaw(b));
Location loc3= getLutil().getRelativ(MiddleLocation, getBlockFace(), d, 0D);
loc3.setYaw(getLutil().FaceToYaw(getBlockFace()));
as = manager.createArmorStand(obj, loc3);
as = getManager().createArmorStand(getObjID(), loc3);
as.getInventory().setHelmet(new ItemStack(Material.LOG));
as.setSmall(true);
as.setPose(new EulerAngle(1.568, 0, 0), BodyPart.HEAD);
@ -141,23 +114,28 @@ public class tent_2 extends Furniture implements Listener{
l+=.44;
}
for(ArmorStandPacket packet : aspl){
int i = 0;
for(fArmorStand packet : aspl){
packet.setInvisible(true);
packet.setGravity(false);
if(i>44&&i<57){
packet.setMarker(false);
}
i++;
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
@SuppressWarnings("deprecation")
public void setBlock(Location loc){
Location b1 = lutil.getRelativ(loc, b, 1D, -2D).add(0, 0, 0);
Location b2 = lutil.getRelativ(loc, b, 2D, -3D).add(0, 0, 0);
Location b1 = getLutil().getRelativ(loc, getBlockFace(), 1D, -2D).add(0, 0, 0);
Location b2 = getLutil().getRelativ(loc, getBlockFace(), 2D, -3D).add(0, 0, 0);
if(!b2.getBlock().getType().equals(Material.CHEST)){
b2.setYaw(lutil.FaceToYaw(b));
b2.setYaw(getLutil().FaceToYaw(getBlockFace()));
b2.getBlock().setType(Material.CHEST);
BlockState chest = b2.getBlock().getState();
switch (b){
switch (getBlockFace()){
case SOUTH:
chest.setRawData((byte) 0x3);break;
@ -178,19 +156,19 @@ public class tent_2 extends Furniture implements Listener{
bedLoc = lutil.setBed(this.b, b1);
bedLoc = getLutil().setBed(this.getBlockFace(), b1);
getObjID().addBlock(Arrays.asList(b1.getWorld().getBlockAt(b1)));
block.add(b1.getWorld().getBlockAt(b1));
block.add(b2.getWorld().getBlockAt(b2));
}
public void setRow(Location loc, double x,double y, double z, int replay, EulerAngle angle, List<ArmorStandPacket> list){
public void setRow(Location loc, double x,double y, double z, int replay, EulerAngle angle, List<fArmorStand> list){
Double d = .0;
for(int i = 0; i<=replay;i++){
Location loc1= lutil.getRelativ(loc, b, -3.55+d, z);
loc1.setYaw(lutil.FaceToYaw(b));
Location loc1= getLutil().getRelativ(loc, getBlockFace(), -3.55+d, z);
loc1.setYaw(getLutil().FaceToYaw(getBlockFace()));
loc1.add(0, y,0);
ArmorStandPacket packet = manager.createArmorStand(obj, loc1);
fArmorStand packet = getManager().createArmorStand(getObjID(), loc1);
packet.getInventory().setHelmet(new ItemStack(Material.CARPET));
packet.setPose(angle, BodyPart.HEAD);
list.add(packet);
@ -200,25 +178,25 @@ public class tent_2 extends Furniture implements Listener{
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
for(Block bl : block){
bl.setType(Material.AIR);
}
e.remove();
obj=null;
delete();
}
@EventHandler
public void onFurnitureClick(final FurnitureClickEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
e.setCancelled(true);
Player p = e.getPlayer();
if(!e.canBuild()){return;}
@ -231,7 +209,7 @@ public class tent_2 extends Furniture implements Listener{
}
}
}else{
lib.getColorManager().color(p, e.canBuild(), Material.CARPET, obj, ColorType.BLOCK, 1);
getLib().getColorManager().color(p, e.canBuild(), Material.CARPET, getObjID(), ColorType.BLOCK, 1);
}
}
}

View File

@ -1,13 +1,13 @@
package de.Ste3et_C0st.Furniture.Objects.outdoor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.banner.Pattern;
@ -20,54 +20,27 @@ import org.bukkit.inventory.meta.BannerMeta;
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.ColorType;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class tent_3 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 tent_3(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;
public tent_3(Plugin plugin, ObjectID id){
super(plugin, id);
setBlock();
if(id.isFinish()){
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
if(b.equals(BlockFace.WEST)){loc=lutil.getRelativ(loc, b, 1D, 0D);}
if(b.equals(BlockFace.NORTH)){loc=lutil.getRelativ(loc, b, 1D, 1D);}
if(b.equals(BlockFace.EAST)){loc=lutil.getRelativ(loc, b, 0D, 1D);}
Location loc = getLocation();
if(getBlockFace().equals(BlockFace.WEST)){loc=getLutil().getRelativ(loc, getBlockFace(), 1D, 0D);}
if(getBlockFace().equals(BlockFace.NORTH)){loc=getLutil().getRelativ(loc, getBlockFace(), 1D, 1D);}
if(getBlockFace().equals(BlockFace.EAST)){loc=getLutil().getRelativ(loc, getBlockFace(), 0D, 1D);}
spawn(loc);
}
@ -75,51 +48,55 @@ public class tent_3 extends Furniture implements Listener{
Block bed;
public void spawn(Location loc){
List<ArmorStandPacket> aspL = new ArrayList<ArmorStandPacket>();
List<fArmorStand> aspL = new ArrayList<fArmorStand>();
ItemStack banner = new ItemStack(Material.BANNER);
BannerMeta meta = (BannerMeta) banner.getItemMeta();
meta.setBaseColor(DyeColor.WHITE);
banner.setItemMeta(meta);
Location locstart = lutil.getRelativ(loc, b, .2D, -.17D);
Location locstart = getLutil().getRelativ(loc, getBlockFace(), .2D, -.17D);
locstart.add(0,.65,0);
Location locstart2 = lutil.getRelativ(loc, b, .2D, -.8D);
Location locstart2 = getLutil().getRelativ(loc, getBlockFace(), .2D, -.8D);
locstart2.add(0,.65,0);
for(int i = 0; i<=2;i++){
Location location = lutil.getRelativ(locstart, b, .74*i, 0D);
location.setYaw(lutil.FaceToYaw(b)+90);
ArmorStandPacket as = manager.createArmorStand(obj, location);
Location location = getLutil().getRelativ(locstart, getBlockFace(), .74*i, 0D);
location.setYaw(getLutil().FaceToYaw(getBlockFace())+90);
fArmorStand as = getManager().createArmorStand(getObjID(), location);
as.getInventory().setHelmet(banner);
as.setPose(new EulerAngle(3.5, 0, 0), BodyPart.HEAD);
if(i==2){as.setMarker(false);}
aspL.add(as);
location = lutil.getRelativ(locstart, b, .74*i, -.3D);
location = getLutil().getRelativ(locstart, getBlockFace(), .74*i, -.3D);
location.add(0,.9,0);
location.setYaw(lutil.FaceToYaw(b)+90);
location.setYaw(getLutil().FaceToYaw(getBlockFace())+90);
as = manager.createArmorStand(obj, location);
as = getManager().createArmorStand(getObjID(), location);
as.getInventory().setHelmet(banner);
as.setPose(new EulerAngle(3.5, 0, 0), BodyPart.HEAD);
if(i==2){as.setMarker(false);}
aspL.add(as);
}
for(int i = 0; i<=2;i++){
Location location = lutil.getRelativ(locstart2, b, .74*i, 0D);
location.setYaw(lutil.FaceToYaw(b)-90);
Location location = getLutil().getRelativ(locstart2, getBlockFace(), .74*i, 0D);
location.setYaw(getLutil().FaceToYaw(getBlockFace())-90);
ArmorStandPacket as = manager.createArmorStand(obj, location);
fArmorStand as = getManager().createArmorStand(getObjID(), location);
as.getInventory().setHelmet(banner);
as.setPose(new EulerAngle(3.5, 0, 0), BodyPart.HEAD);
if(i==2){as.setMarker(false);}
aspL.add(as);
location = lutil.getRelativ(locstart2, b, .74*i, .32D);
location = getLutil().getRelativ(locstart2, getBlockFace(), .74*i, .32D);
location.add(0,.9,0);
location.setYaw(lutil.FaceToYaw(b)-90);
as = manager.createArmorStand(obj, location);
location.setYaw(getLutil().FaceToYaw(getBlockFace())-90);
as = getManager().createArmorStand(getObjID(), location);
as.getInventory().setHelmet(banner);
as.setPose(new EulerAngle(3.5, 0, 0), BodyPart.HEAD);
if(i==2){as.setMarker(false);}
aspL.add(as);
}
@ -129,81 +106,82 @@ public class tent_3 extends Furniture implements Listener{
meta.addPattern(new Pattern(DyeColor.RED, PatternType.STRIPE_SMALL));
banner.setItemMeta(meta);
Location banner1 = lutil.getRelativ(loc, b, 1.7D, -.1D);
Location banner1 = getLutil().getRelativ(loc, getBlockFace(), 1.7D, -.1D);
banner1.add(0,-1.2,0);
Location banner2 = lutil.getRelativ(banner1, b, 0D, -.75);
banner1.setYaw(lutil.FaceToYaw(b));
banner2.setYaw(lutil.FaceToYaw(b));
Location banner2 = getLutil().getRelativ(banner1, getBlockFace(), 0D, -.75);
banner1.setYaw(getLutil().FaceToYaw(getBlockFace()));
banner2.setYaw(getLutil().FaceToYaw(getBlockFace()));
ArmorStandPacket as = manager.createArmorStand(obj, banner1);
fArmorStand as = getManager().createArmorStand(getObjID(), banner1);
as.getInventory().setHelmet(banner);
as.setPose(new EulerAngle(-1.568, 0, 0), BodyPart.HEAD);
as.setMarker(false);
aspL.add(as);
as = manager.createArmorStand(obj, banner2);
as = getManager().createArmorStand(getObjID(), banner2);
as.getInventory().setHelmet(banner);
as.setPose(new EulerAngle(-1.568, 0, 0), BodyPart.HEAD);
as.setMarker(false);
aspL.add(as);
Location sit = lutil.getCenter(loc);
Location sit = getLutil().getCenter(loc);
if(b.equals(BlockFace.WEST)){sit=lutil.getRelativ(sit, b, -1D, 0D);}
if(b.equals(BlockFace.NORTH)){sit=lutil.getRelativ(sit, b, -1D, -1D);}
if(b.equals(BlockFace.EAST)){sit=lutil.getRelativ(sit, b, 0D, -1D);}
if(getBlockFace().equals(BlockFace.WEST)){sit=getLutil().getRelativ(sit, getBlockFace(), -1D, 0D);}
if(getBlockFace().equals(BlockFace.NORTH)){sit=getLutil().getRelativ(sit, getBlockFace(), -1D, -1D);}
if(getBlockFace().equals(BlockFace.EAST)){sit=getLutil().getRelativ(sit, getBlockFace(), 0D, -1D);}
sit.setYaw(lutil.FaceToYaw(this.b.getOppositeFace()));
Location locationsit = lutil.getRelativ(sit, b, 1D, 0D);
locationsit.setYaw(lutil.FaceToYaw(this.b.getOppositeFace()));
sit.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()));
Location locationsit = getLutil().getRelativ(sit, getBlockFace(), 1D, 0D);
locationsit.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()));
as = manager.createArmorStand(obj, locationsit.add(0,-2,0));
as = getManager().createArmorStand(getObjID(), locationsit.add(0,-2,0));
as.setName("#SITZ#");
aspL.add(as);
for(ArmorStandPacket packet : aspL){
for(fArmorStand packet : aspL){
packet.setInvisible(true);
packet.setGravity(false);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
private void setBlock(){
Location sit = lutil.getCenter(loc);
sit.setYaw(lutil.FaceToYaw(this.b.getOppositeFace()));
bed = lutil.setHalfBed(b, lutil.getRelativ(sit.add(0,-2,0).getBlock().getLocation().add(0,2,0), b, 2D, 0D));
Location sit = getLutil().getCenter(getLocation());
sit.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()));
bed = getLutil().setHalfBed(getBlockFace(), getLutil().getRelativ(sit.add(0,-2,0).getBlock().getLocation().add(0,2,0), getBlockFace(), 2D, 0D));
getObjID().addBlock(Arrays.asList(bed));
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
bed.setType(Material.AIR);
e.remove();
obj=null;
delete();
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e){
if(obj==null){return;}
if(obj.getSQLAction().equals(SQLAction.REMOVE)){return;}
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
if(!e.getID().equals(getObjID())){return;}
e.setCancelled(true);
if(!e.canBuild()){return;}
Player p = e.getPlayer();
if(p.getItemInHand().getType().equals(Material.INK_SACK)){
lib.getColorManager().color(p, e.canBuild(), Material.BANNER, obj, ColorType.BANNER, 1);
getLib().getColorManager().color(p, e.canBuild(), Material.BANNER, getObjID(), ColorType.BANNER, 1);
}else{
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
for(fArmorStand packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().equalsIgnoreCase("#SITZ#")){
if(packet.getPessanger()==null){
packet.setPessanger(p);
packet.update();
}
packet.setPassanger(p);
packet.update();
}
}
}

View File

@ -0,0 +1,141 @@
package de.Ste3et_C0st.Furniture.Objects.trap;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
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.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
public class BearTrap extends Furniture implements Listener{
fArmorStand stand1, stand2;
boolean b;
public BearTrap(Plugin plugin, ObjectID id){
super(plugin, id);
if(isFinish()){
for(fArmorStand stand : getfAsList()){
if(stand.getName().equalsIgnoreCase("#IRON1#")){
stand1 = stand;
}else if(stand.getName().equalsIgnoreCase("#IRON2#")){
stand2 = stand;
}
}
setStatus(false);
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}
spawn(id.getStartLocation());
}
@Override
public void spawn(Location loc) {
List<fArmorStand> asList = new ArrayList<fArmorStand>();
fArmorStand stand = spawnArmorStand(getRelative(getCenter(), 0, 0).add(0, -1.9, 0));
stand.setHelmet(new ItemStack(Material.IRON_TRAPDOOR));
asList.add(stand);
Location location = getRelative(getCenter(), 0, .04).add(0, -1.8, 0);
location.setYaw(getYaw()+90);
stand = spawnArmorStand(location);
stand.setHeadPose(getLutil().degresstoRad(new EulerAngle(90, 0, 0)));
stand.setHelmet(new ItemStack(Material.IRON_FENCE));
stand.setName("#IRON1#");
stand1 = stand;
asList.add(stand);
location = getRelative(getCenter(), 0, -.04).add(0, -1.8, 0);
location.setYaw(getYaw()+90);
stand = spawnArmorStand(location);
stand.setHeadPose(getLutil().degresstoRad(new EulerAngle(-90, 0, 0)));
stand.setHelmet(new ItemStack(Material.IRON_FENCE));
stand.setName("#IRON2#");
stand2 = stand;
asList.add(stand);
for(fArmorStand packet : asList){
packet.setInvisible(true);
packet.setGravity(false);
}
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e){
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.remove();
delete();
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e) {
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
if(b){
setStatus(false);
getWorld().playSound(getLocation(), Sound.ANVIL_LAND, 10, 1);
}
}
private void setStatus(boolean b){
if(b){
stand1.setHeadPose(getLutil().degresstoRad(new EulerAngle(0, 0, 0)));
stand2.setHeadPose(getLutil().degresstoRad(new EulerAngle(0, 0, 0)));
getWorld().playSound(getLocation(), Sound.ITEM_BREAK, 5, 1);
}else{
stand1.setHeadPose(getLutil().degresstoRad(new EulerAngle(90, 0, 0)));
stand2.setHeadPose(getLutil().degresstoRad(new EulerAngle(-90, 0, 0)));
}
this.b = b;
update();
}
@EventHandler
public void onPlayerMove(PlayerMoveEvent e) {
if(b) return;
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if (e.getFrom().getWorld() == e.getTo().getWorld() &&
e.getFrom().getBlockX() == e.getTo().getBlockX() &&
e.getFrom().getBlockY() == e.getTo().getBlockY() &&
e.getFrom().getBlockZ() == e.getTo().getBlockZ())
return;
Player player = e.getPlayer();
if (player.getHealth() <= 0.0D) return;
Location loc = e.getTo().getBlock().getLocation();
Location loc2 = getLocation();
if(loc.toVector().distance(loc2.toVector())<1){
setStatus(true);
player.damage(main.damage);
}
}
}

View File

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