Update for new FurnitureLib pls use FunritureLib build #119

This commit is contained in:
Ste3et_C0st 2019-02-24 00:33:02 +01:00
parent 3742238bb6
commit 0e6a05cd41
29 changed files with 971 additions and 1059 deletions

View File

@ -204,19 +204,23 @@ public class main extends JavaPlugin implements Listener{
if(id.getProjectOBJ() == null) continue; if(id.getProjectOBJ() == null) continue;
if(id.getSQLAction().equals(SQLAction.REMOVE)) continue; if(id.getSQLAction().equals(SQLAction.REMOVE)) continue;
switch (id.getProjectOBJ().getName()) { switch (id.getProjectOBJ().getName()) {
case "Catapult":new Catapult(id);break; case "Catapult":id.setFunctionObject(new Catapult(id));break;
case "Barrels": new barrels(id);break; case "Barrels": id.setFunctionObject(new barrels(id));break;
case "WaxCandle": new WaxCandle(id);break; case "WaxCandle": id.setFunctionObject(new WaxCandle(id));break;
case "Lantern": new WaxCandle(id);break; case "Lantern": id.setFunctionObject(new WaxCandle(id));break;
case "Fence": new fance(id);break; case "Fence":{
case "Trunk": new Trunk(id);break; System.out.println("test");
case "Sunshade": new sunshade(id);break; id.setFunctionObject(new fance(id));break;
case "Hammock": new hammock(id);break;
case "Crossbow": new Crossbow(id);break; }
case "Tent1": new tent_1(id);break; case "Trunk": id.setFunctionObject(new Trunk(id));break;
case "GraveStone": new graveStone(id);break; case "Sunshade": id.setFunctionObject(new sunshade(id));break;
case "Camera": new camera(id);break; case "Hammock": id.setFunctionObject(new hammock(id));break;
case "Log": new log(id);break; case "Crossbow": id.setFunctionObject(new Crossbow(id));break;
case "Tent1": id.setFunctionObject(new tent_1(id));break;
case "GraveStone": id.setFunctionObject(new graveStone(id));break;
case "Camera": id.setFunctionObject(new camera(id));break;
case "Log": id.setFunctionObject(new log(id));break;
default:break; default:break;
} }
} }
@ -229,19 +233,19 @@ public class main extends JavaPlugin implements Listener{
if(event.getProject().getName()==null) return; if(event.getProject().getName()==null) return;
if(event.getID().getSQLAction().equals(SQLAction.REMOVE)) return; if(event.getID().getSQLAction().equals(SQLAction.REMOVE)) return;
switch (event.getProject().getName()) { switch (event.getProject().getName()) {
case "Catapult":new Catapult(event.getID());break; case "Catapult":event.getID().setFunctionObject(new Catapult(event.getID()));break;
case "Barrels": new barrels(event.getID());break; case "Barrels": event.getID().setFunctionObject(new barrels(event.getID()));break;
case "WaxCandle": new WaxCandle(event.getID());break; case "WaxCandle": event.getID().setFunctionObject(new WaxCandle(event.getID()));break;
case "Lantern": new WaxCandle(event.getID());break; case "Lantern": event.getID().setFunctionObject(new WaxCandle(event.getID()));break;
case "Fence": new fance(event.getID());break; case "Fence": event.getID().setFunctionObject(new fance(event.getID()));break;
case "Trunk": new Trunk(event.getID());break; case "Trunk": event.getID().setFunctionObject(new Trunk(event.getID()));break;
case "Sunshade": new sunshade(event.getID());break; case "Sunshade": event.getID().setFunctionObject(new sunshade(event.getID()));break;
case "Hammock": new hammock(event.getID());break; case "Hammock": event.getID().setFunctionObject(new hammock(event.getID()));break;
case "Crossbow": new Crossbow(event.getID());break; case "Crossbow": event.getID().setFunctionObject(new Crossbow(event.getID()));break;
case "Tent1": new tent_1(event.getID());break; case "Tent1": event.getID().setFunctionObject(new tent_1(event.getID()));break;
case "GraveStone": new graveStone(event.getID());break; case "GraveStone": event.getID().setFunctionObject(new graveStone(event.getID()));break;
case "Camera": new camera(event.getID());break; case "Camera": event.getID().setFunctionObject(new camera(event.getID()));break;
case "Log": new log(event.getID());break; case "Log": event.getID().setFunctionObject(new log(event.getID()));break;
default:break; default:break;
} }
} }

View File

@ -6,36 +6,26 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.EntityEffect; import org.bukkit.EntityEffect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.FallingBlock; import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.EulerAngle; import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import de.Ste3et_C0st.Furniture.Main.main; import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.NBT.CraftItemStack;
import de.Ste3et_C0st.FurnitureLib.NBT.NBTTagCompound;
import de.Ste3et_C0st.FurnitureLib.ShematicLoader.Events.ProjectClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper; import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib; import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
@ -99,25 +89,25 @@ public class Catapult extends FurnitureHelper implements Listener{
} }
} }
@EventHandler @Override
public void FurnitureClickEvent(ProjectClickEvent e){ public void onClick(Player player){
if(getObjID() == null) return; if(getObjID() == null) return;
if(e.getID()==null) return; if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())) return; if(player == null) return;
if(e.getID().getSQLAction().equals(SQLAction.REMOVE)) return; if(canBuild(player)) {
Location loc = getRelative(getCenter(), getBlockFace(), -.8, -1.03).add(0, -.2, 0); Location loc = getRelative(getCenter(), getBlockFace(), -.8, -1.03).add(0, -.2, 0);
loc.setYaw(getYaw()); loc.setYaw(getYaw());
ItemStack stack = e.getPlayer().getInventory().getItemInMainHand(); ItemStack stack = player.getInventory().getItemInMainHand();
if(stack.getType().equals(Material.TNT)){ if(stack.getType().equals(Material.TNT)){
TNTPrimed tnt = (TNTPrimed) e.getID().getWorld().spawnEntity(loc, EntityType.PRIMED_TNT); TNTPrimed tnt = (TNTPrimed) getWorld().spawnEntity(loc, EntityType.PRIMED_TNT);
if(tnt == null) return; if(tnt == null) return;
Vector v= getLaunchVector(getBlockFace()); Vector v= getLaunchVector(getBlockFace());
if(v == null) return; if(v == null) return;
tnt.playEffect(EntityEffect.WITCH_MAGIC); tnt.playEffect(EntityEffect.WITCH_MAGIC);
tnt.setVelocity(v.multiply(1)); tnt.setVelocity(v.multiply(1));
fallingSandList.put(tnt, e.getPlayer()); fallingSandList.put(tnt, player);
}else if(stack.getType().equals(Material.AIR)){ }else if(stack.getType().equals(Material.AIR)){
setRange(e.getPlayer()); setRange(player);
return; return;
}else{ }else{
// if(stack.getType().isBlock()){ // if(stack.getType().isBlock()){
@ -166,11 +156,22 @@ public class Catapult extends FurnitureHelper implements Listener{
// ex.printStackTrace(); // ex.printStackTrace();
// } // }
// }else{ // }else{
setRange(e.getPlayer()); setRange(player);
return; return;
// } // }
} }
consumeItem(e.getPlayer()); consumeItem(player);
}
}
@Override
public void onBreak(Player player) {
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
this.destroy(player);
}
} }
public void setRange(Player p){ public void setRange(Player p){

View File

@ -2,7 +2,6 @@ package de.Ste3et_C0st.Furniture.Objects.RPG;
import java.util.Random; import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -12,45 +11,41 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.SpectralArrow; import org.bukkit.entity.SpectralArrow;
import org.bukkit.entity.TippedArrow; import org.bukkit.entity.TippedArrow;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.ShematicLoader.Events.ProjectClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper; import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction; import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity; import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
public class Crossbow extends FurnitureHelper implements Listener { public class Crossbow extends FurnitureHelper {
public Crossbow(ObjectID id){ public Crossbow(ObjectID id){
super(id); super(id);
Bukkit.getPluginManager().registerEvents(this, main.instance);
} }
@EventHandler @Override
public void onFurnitureClick(ProjectClickEvent e) { public void onClick(Player player){
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())) return; if(player == null) return;
if(!e.canBuild()){return;} if(canBuild(player)) {
fEntity stand = getArmorStand(); fEntity stand = getArmorStand();
if(stand==null){return;} if(stand==null){return;}
ItemStack is = e.getPlayer().getInventory().getItemInMainHand(); ItemStack is = player.getInventory().getItemInMainHand();
if(is!=null&& (is.getType().equals(Material.ARROW) || is.getType().equals(Material.SPECTRAL_ARROW) || is.getType().equals(Material.TIPPED_ARROW)) ){ if(is!=null&& (is.getType().equals(Material.ARROW) || is.getType().equals(Material.SPECTRAL_ARROW) || is.getType().equals(Material.TIPPED_ARROW)) ){
if(!hasArrow()){ if(!hasArrow()){
fEntity entity = getArmorStand(); fEntity entity = getArmorStand();
entity.setItemInMainHand(is.clone()); entity.setItemInMainHand(is.clone());
update(); update();
consumeItem(e.getPlayer()); consumeItem(player);
return; return;
} }
} }
if(hasArrow()){ if(hasArrow()){
spawnArrow(getArrow().getType(), e.getPlayer()); spawnArrow(getArrow().getType(), player);
}
} }
} }
@ -132,4 +127,14 @@ public class Crossbow extends FurnitureHelper implements Listener {
} }
return false; return false;
} }
@Override
public void onBreak(Player player) {
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
this.destroy(player);
}
}
} }

View File

@ -3,8 +3,6 @@ package de.Ste3et_C0st.Furniture.Objects.RPG;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Effect; import org.bukkit.Effect;
@ -14,7 +12,6 @@ import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
@ -23,8 +20,6 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.util.EulerAngle; import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Main.main; 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.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart; import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
@ -61,9 +56,9 @@ public class Guillotine extends Furniture implements Listener{
public Guillotine(ObjectID id) { public Guillotine(ObjectID id) {
super(id); super(id);
if(isFinish()){ if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, main.getInstance());
setDefault(); setDefault();
initializeInventory(); initializeInventory();
Bukkit.getPluginManager().registerEvents(this, main.getInstance());
return; return;
} }
spawn(id.getStartLocation()); spawn(id.getStartLocation());
@ -299,13 +294,12 @@ public class Guillotine extends Furniture implements Listener{
return true; return true;
} }
@EventHandler @Override
public void onFurnitureBreak(FurnitureBreakEvent e) { public void onBreak(Player player) {
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())){return;} if(player == null) return;
if(!e.canBuild()){return;} if(canBuild(player)) {
if(!isRunning()){
if(canDrop(packet1.getHelmet())){getWorld().dropItem(getLocation(), packet1.getHelmet());} if(canDrop(packet1.getHelmet())){getWorld().dropItem(getLocation(), packet1.getHelmet());}
if(canDrop(packet1.getChestPlate())){getWorld().dropItem(getLocation(), packet1.getChestPlate());} if(canDrop(packet1.getChestPlate())){getWorld().dropItem(getLocation(), packet1.getChestPlate());}
if(canDrop(packet1.getLeggings())){getWorld().dropItem(getLocation(), packet1.getLeggings());} if(canDrop(packet1.getLeggings())){getWorld().dropItem(getLocation(), packet1.getLeggings());}
@ -322,24 +316,20 @@ public class Guillotine extends Furniture implements Listener{
im.setDisplayName(packet1.getName()); im.setDisplayName(packet1.getName());
getWorld().dropItem(getLocation(), is); getWorld().dropItem(getLocation(), is);
} }
this.destroy(player);
this.getObjID().remove(e.getPlayer());
getManager().remove(getObjID());
delete();
} }
} }
@EventHandler @Override
public void onFurnitureClick(FurnitureClickEvent e) { public void onClick(Player player){
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())){return;} if(player == null) return;
if(!e.canBuild()){return;} if(canBuild(player)) {
Player p = e.getPlayer(); if(!getLib().canBuild(player, getObjID(), EventType.INTERACT)){return;}
if(!getLib().canBuild(e.getPlayer(), getObjID(), EventType.INTERACT)){return;} if(player.isSneaking()){
if(p.isSneaking()){
if(isFinish){return;} if(isFinish){return;}
p.openInventory(invI); player.openInventory(invI);
for(int i = 0; i<9;i++){invI.setItem(i, pane);} for(int i = 0; i<9;i++){invI.setItem(i, pane);}
ItemStack is = new ItemStack(Material.ZOMBIE_HEAD); ItemStack is = new ItemStack(Material.ZOMBIE_HEAD);
@ -353,7 +343,7 @@ public class Guillotine extends Furniture implements Listener{
im.setDisplayName("§cOblation"); im.setDisplayName("§cOblation");
is.setItemMeta(im); is.setItemMeta(im);
invI.setItem(6, is); invI.setItem(6, is);
this.p = p; this.p = player;
}else{ }else{
if(isRunning()){return;} if(isRunning()){return;}
if(canStart()&&!isFinish){ if(canStart()&&!isFinish){
@ -363,6 +353,7 @@ public class Guillotine extends Furniture implements Listener{
} }
} }
} }
}
@EventHandler @EventHandler
private void onClick(InventoryClickEvent e){ private void onClick(InventoryClickEvent e){

View File

@ -9,16 +9,10 @@ import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.event.EventHandler; import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle; 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.main.Furniture; import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart; import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
@ -26,14 +20,13 @@ import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand; import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity; import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
public class flag extends Furniture implements Listener { public class flag extends Furniture {
public flag(ObjectID id){ public flag(ObjectID id){
super(id); super(id);
setBlock(); setBlock();
if(isFinish()){ if(isFinish()){
setState(3, getStand()); setState(3, getStand());
Bukkit.getPluginManager().registerEvents(this, main.getInstance());
return; return;
} }
spawn(id.getStartLocation()); spawn(id.getStartLocation());
@ -127,70 +120,31 @@ public class flag extends Furniture implements Listener {
update(); update();
} }
@EventHandler @Override
public void onFurnitureBreak(FurnitureBreakEvent e) { public void onBreak(Player player) {
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(e.getID() == null || getObjID() == null) return; if(player == null) return;
if(!e.getID().equals(getObjID())){return;} if(canBuild(player)) {
if(!e.canBuild()){return;} this.destroy(player);
delete(); }
e.remove();
} }
@EventHandler @Override
public void onFurnitureClick(FurnitureClickEvent e) { public void onClick(Player player){
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())){return;} if(player == null) return;
if(!e.canBuild()){return;} if(canBuild(player)) {
if(e.getPlayer().getInventory().getItemInMainHand()!=null&&e.getPlayer().getInventory().getItemInMainHand().getType()!=null){ if(player.getInventory().getItemInMainHand()!=null&&player.getInventory().getItemInMainHand().getType()!=null){
if(e.getPlayer().getInventory().getItemInMainHand().getType().name().contains("_BANNER")){ if(player.getInventory().getItemInMainHand().getType().name().contains("_BANNER")){
getStand().setHelmet(e.getPlayer().getInventory().getItemInMainHand());update(); getStand().setHelmet(player.getInventory().getItemInMainHand());update();
if(e.getPlayer().getGameMode().equals(GameMode.CREATIVE) && getLib().useGamemode()) return; if(player.getGameMode().equals(GameMode.CREATIVE) && getLib().useGamemode()) return;
Integer i = e.getPlayer().getInventory().getHeldItemSlot(); Integer i = player.getInventory().getHeldItemSlot();
ItemStack is = e.getPlayer().getInventory().getItemInMainHand(); ItemStack is = player.getInventory().getItemInMainHand();
is.setAmount(is.getAmount()-1); is.setAmount(is.getAmount()-1);
e.getPlayer().getInventory().setItem(i, is); player.getInventory().setItem(i, is);
e.getPlayer().updateInventory(); player.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(e.getID() == null || getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
delete();
e.remove();
}
@EventHandler
public void onFurnitureClick(FurnitureBlockClickEvent e) {
if(e.getID() == null || getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
if(e.getPlayer().getInventory().getItemInMainHand()!=null&&e.getPlayer().getInventory().getItemInMainHand().getType()!=null){
if(e.getPlayer().getInventory().getItemInMainHand().getType().name().contains("_BANNER")){
getStand().setHelmet(e.getPlayer().getInventory().getItemInMainHand());update();
if(e.getPlayer().getGameMode().equals(GameMode.CREATIVE) && getLib().useGamemode()) return;
Integer i = e.getPlayer().getInventory().getHeldItemSlot();
ItemStack is = e.getPlayer().getInventory().getItemInMainHand();
is.setAmount(is.getAmount()-1);
e.getPlayer().getInventory().setItem(i, is);
e.getPlayer().updateInventory();
return; return;
} }
} }
@ -204,3 +158,4 @@ public class flag extends Furniture implements Listener {
setState(state, getStand()); setState(state, getStand());
} }
} }
}

View File

@ -10,6 +10,7 @@ import org.bukkit.Material;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
@ -18,8 +19,6 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.util.EulerAngle; import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Main.main; 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.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart; import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
@ -27,7 +26,7 @@ import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand; import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity; import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
public class weaponStand extends Furniture { public class weaponStand extends Furniture implements Listener{
List<Integer> slotList1 = Arrays.asList(6,11,14,16,19,21,24,29,32,34,42); 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<Integer> slotList2 = Arrays.asList(20, 15, 33);
@ -51,13 +50,15 @@ public class weaponStand extends Furniture {
Player p = null; Player p = null;
Inventory inv = null; Inventory inv = null;
@EventHandler @Override
public void onFurnitureBreak(FurnitureBreakEvent e) { public void onBreak(Player player) {
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.canBuild()){return;} if(player == null) return;
if(canBuild(player)) {
if(p!=null){ if(p!=null){
p.closeInventory(); p.closeInventory();
inv = null;
} }
List<fEntity> asList = getManager().getfArmorStandByObjectID(getObjID()); List<fEntity> asList = getManager().getfArmorStandByObjectID(getObjID());
for(fEntity packet : asList){ for(fEntity packet : asList){
@ -69,26 +70,24 @@ public class weaponStand extends Furniture {
} }
} }
} }
e.remove(); this.destroy(player);
inv = null; }
delete();
} }
@EventHandler @Override
public void onFurnitureClick(FurnitureClickEvent e) { public void onClick(Player player){
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(p!=null){return;} if(player == null) return;
if(!e.getID().equals(getObjID())){return;} if(canBuild(player)) {
if(!e.canBuild()){return;} this.p = player;
this.p = e.getPlayer();
ItemStack itemstack = p.getInventory().getItemInMainHand(); ItemStack itemstack = p.getInventory().getItemInMainHand();
if(itemstack!=null&&matList.contains(itemstack.getType())){ if(itemstack!=null&&matList.contains(itemstack.getType())){
for(fEntity packet : getManager().getfArmorStandByObjectID(getObjID())){ for(fEntity packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getInventory().getHelmet()!=null){ if(packet.getInventory().getHelmet()!=null){
if(packet.getInventory().getHelmet().getType().name().toLowerCase().endsWith("gate")){ if(packet.getInventory().getHelmet().getType().name().toLowerCase().endsWith("gate")){
ItemStack itemStack = new ItemStack(itemstack.getType(), 1, (short) 0); ItemStack itemStack = new ItemStack(itemstack.getType(), 1);
packet.getInventory().setHelmet(itemStack); packet.getInventory().setHelmet(itemStack);
} }
} }
@ -133,6 +132,7 @@ public class weaponStand extends Furniture {
this.p.openInventory(inv); this.p.openInventory(inv);
this.p.updateInventory(); this.p.updateInventory();
} }
}
@EventHandler @EventHandler
private void onClick(InventoryClickEvent e){ private void onClick(InventoryClickEvent e){

View File

@ -6,21 +6,18 @@ import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.event.EventHandler; import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle; import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Main.main; 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.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction; import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand; import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity; import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
public class TrashCan extends Furniture implements Listener { public class TrashCan extends Furniture{
public TrashCan(ObjectID id){ public TrashCan(ObjectID id){
super(id); super(id);
@ -31,23 +28,23 @@ public class TrashCan extends Furniture implements Listener {
spawn(id.getStartLocation()); spawn(id.getStartLocation());
} }
@EventHandler @Override
public void onFurnitureBreak(FurnitureBreakEvent e) { public void onBreak(Player player) {
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())) return; if(player == null) return;
if(!e.canBuild()){return;} if(canBuild(player)) {
e.remove(); this.destroy(player);
delete(); }
} }
@EventHandler @Override
public void onFurnitureClick(FurnitureClickEvent e) { public void onClick(Player player){
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())) return; if(player == null) return;
if(!e.canBuild()){return;} if(canBuild(player)) {
ItemStack is = e.getPlayer().getInventory().getItemInMainHand(); ItemStack is = player.getInventory().getItemInMainHand();
fEntity stand = null; fEntity stand = null;
for(fEntity s : getfAsList()){ for(fEntity s : getfAsList()){
if(s.getName().equalsIgnoreCase("#TRASH#")){ if(s.getName().equalsIgnoreCase("#TRASH#")){
@ -64,11 +61,12 @@ public class TrashCan extends Furniture implements Listener {
} }
} }
stand.setItemInMainHand(is); stand.setItemInMainHand(is);
e.getPlayer().getInventory().clear(e.getPlayer().getInventory().getHeldItemSlot()); player.getInventory().clear(player.getInventory().getHeldItemSlot());
e.getPlayer().updateInventory(); player.updateInventory();
update(); update();
return; return;
} }
}
@Override @Override
public void spawn(Location loc) { public void spawn(Location loc) {

View File

@ -38,8 +38,6 @@ import org.bukkit.util.io.BukkitObjectOutputStream;
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
import de.Ste3et_C0st.Furniture.Objects.garden.config; import de.Ste3et_C0st.Furniture.Objects.garden.config;
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.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction; import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
@ -79,38 +77,38 @@ public class AdventCalender extends Furniture implements Listener {
spawn(id.getStartLocation()); spawn(id.getStartLocation());
} }
@EventHandler @Override
public void onFurnitureBreak(FurnitureBreakEvent e) { public void onBreak(Player player) {
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())){return;} if(player == null) return;
if(!canBuild(e.getPlayer())){return;} if(canBuild(player)) {
e.remove(true,false); this.destroy(player);
delete(); }
} }
@EventHandler @Override
public void onFurnitureClick(FurnitureClickEvent e) { public void onClick(Player player){
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())){return;} if(player == null) return;
ItemStack is = e.getPlayer().getInventory().getItemInMainHand(); ItemStack is = player.getInventory().getItemInMainHand();
if(is==null){open(e.getPlayer()); return;} if(is==null){open(player); return;}
if(is.getType()==null){open(e.getPlayer()); return;} if(is.getType()==null){open(player); return;}
if(is.getType().equals(Material.ARROW)){ if(is.getType().equals(Material.ARROW)){
if(p!=null){open(e.getPlayer());return;} if(p!=null){open(player);return;}
if(!getObjID().getUUID().equals(e.getPlayer().getUniqueId())){open(e.getPlayer());return;} if(!getObjID().getUUID().equals(player.getUniqueId())){open(player);return;}
if(!canBuild(e.getPlayer())){return;} if(!canBuild(player)){return;}
i = is.getAmount(); i = is.getAmount();
if(i>31 || i<1) return; if(i>31 || i<1) return;
this.p = e.getPlayer(); this.p = player;
if(isList.containsKey(i)){ if(isList.containsKey(i)){
openInventory(isList.get(i)); openInventory(isList.get(i));
}else{ }else{
openInventory(null); openInventory(null);
} }
}else{ }else{
open(e.getPlayer()); open(player);
} }
} }

View File

@ -7,20 +7,17 @@ import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.event.EventHandler; import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle; 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.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction; import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand; import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity; import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
public class AdventWreath extends Furniture implements Listener { public class AdventWreath extends Furniture {
double sub = .9; double sub = .9;
List<Location> locationList = Arrays.asList( List<Location> locationList = Arrays.asList(
@ -40,34 +37,36 @@ public class AdventWreath extends Furniture implements Listener {
spawn(id.getStartLocation()); spawn(id.getStartLocation());
} }
@EventHandler @Override
public void onFurnitureBreak(FurnitureBreakEvent e) { public void onBreak(Player player) {
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())){return;} if(player == null) return;
if(!canBuild(e.getPlayer())){return;} if(canBuild(player)) {
e.remove(true,false); this.destroy(player);
delete(); }
} }
@EventHandler @Override
public void onFurnitureClick(FurnitureClickEvent e) { public void onClick(Player player){
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.canBuild()){return;} if(player == null) return;
fArmorStand stand = (fArmorStand) e.getfEntity(); if(canBuild(player)) {
String str = stand.getName(); // fArmorStand stand = (fArmorStand) e.getfEntity();
if(str.startsWith("Fire") || str.startsWith("Torch")){ // String str = stand.getName();
int i = Integer.parseInt(str.split(":")[1]); // if(str.startsWith("Fire") || str.startsWith("Torch")){
for(fEntity fstand : getfAsList()){ // int i = Integer.parseInt(str.split(":")[1]);
if(fstand.getName().equalsIgnoreCase("Fire:" + i)){ // for(fEntity fstand : getfAsList()){
if(!fstand.getName().endsWith("Burn")){ // if(fstand.getName().equalsIgnoreCase("Fire:" + i)){
fstand.sendParticle(fstand.getLocation().clone().add(0, .93, 0), 26, true); // if(!fstand.getName().endsWith("Burn")){
fstand.setName("Fire:" + i + ":Burn"); // fstand.sendParticle(fstand.getLocation().clone().add(0, .93, 0), 26, true);
update(); // fstand.setName("Fire:" + i + ":Burn");
} // update();
} // }
} // }
// }
// }
} }
} }
@ -150,18 +149,18 @@ public class AdventWreath extends Furniture implements Listener {
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(-41,-37.5f,18))); stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(-41,-37.5f,18)));
stand.setSmall(true); stand.setSmall(true);
stand.setName("Torch:" + i); stand.setName("Torch:" + i);
stand.setHelmet(new ItemStack(Material.LEVER, 1, (short) 13)); stand.setHelmet(new ItemStack(Material.LEVER, 1));
asList.add(stand); asList.add(stand);
y=y+90; y=y+90;
} }
ItemStack is = new ItemStack(Material.POPPY, 1, (short) 8); ItemStack is = new ItemStack(Material.POPPY, 1);
spawnFlower(getRelative(getCenter().subtract(0, .7, 0), getLutil().yawToFace(0), .5, .5), is); spawnFlower(getRelative(getCenter().subtract(0, .7, 0), getLutil().yawToFace(0), .5, .5), is);
spawnFlower(getRelative(getCenter().subtract(0, .7, 0), getLutil().yawToFace(0), -.5, -.5), is); spawnFlower(getRelative(getCenter().subtract(0, .7, 0), getLutil().yawToFace(0), -.5, -.5), is);
spawnFlower(getRelative(getCenter().subtract(0, .7, 0), getLutil().yawToFace(0), -.5, .5), is); spawnFlower(getRelative(getCenter().subtract(0, .7, 0), getLutil().yawToFace(0), -.5, .5), is);
spawnFlower(getRelative(getCenter().subtract(0, .7, 0), getLutil().yawToFace(0), .5, -.5), is); spawnFlower(getRelative(getCenter().subtract(0, .7, 0), getLutil().yawToFace(0), .5, -.5), is);
is = new ItemStack(Material.POPPY, 1, (short) 4); is = new ItemStack(Material.POPPY, 1);
spawnFlower(getRelative(getCenter().subtract(0, .7, 0), getLutil().yawToFace(0), .25, .25), is); spawnFlower(getRelative(getCenter().subtract(0, .7, 0), getLutil().yawToFace(0), .25, .25), is);
spawnFlower(getRelative(getCenter().subtract(0, .7, 0), getLutil().yawToFace(0), -.25, -.25), is); spawnFlower(getRelative(getCenter().subtract(0, .7, 0), getLutil().yawToFace(0), -.25, -.25), is);
spawnFlower(getRelative(getCenter().subtract(0, .7, 0), getLutil().yawToFace(0), -.25, .25), is); spawnFlower(getRelative(getCenter().subtract(0, .7, 0), getLutil().yawToFace(0), -.25, .25), is);

View File

@ -11,14 +11,11 @@ import org.bukkit.Material;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework; import org.bukkit.entity.Firework;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta; import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.util.EulerAngle; 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.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction; import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
@ -36,12 +33,12 @@ public class FireworkLauncher extends Furniture implements Listener {
spawn(id.getStartLocation()); spawn(id.getStartLocation());
} }
@EventHandler @Override
public void onFurnitureBreak(FurnitureBreakEvent e) { public void onBreak(Player player) {
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())){return;} if(player == null) return;
if(!canBuild(e.getPlayer())){return;} if(canBuild(player)) {
for(fEntity packet : getManager().getfArmorStandByObjectID(getObjID())){ for(fEntity packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().equalsIgnoreCase("#FIREWORK#")){ if(packet.getName().equalsIgnoreCase("#FIREWORK#")){
if(packet.getInventory().getItemInMainHand()!=null&&!packet.getInventory().getItemInMainHand().getType().equals(Material.AIR)){ if(packet.getInventory().getItemInMainHand()!=null&&!packet.getInventory().getItemInMainHand().getType().equals(Material.AIR)){
@ -50,17 +47,16 @@ public class FireworkLauncher extends Furniture implements Listener {
} }
} }
} }
e.remove(true,true); this.destroy(player);
delete(); }
} }
@EventHandler @Override
public void onFurnitureClick(FurnitureClickEvent e) { public void onClick(Player player){
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())){return;} if(player == null) return;
if(!canBuild(e.getPlayer())){return;} if(canBuild(player)) {
Player p = e.getPlayer();
fEntity stand = null; fEntity stand = null;
for(fEntity st : getfAsList()){ for(fEntity st : getfAsList()){
if(st.getName().equalsIgnoreCase("#FIREWORK#")){ if(st.getName().equalsIgnoreCase("#FIREWORK#")){
@ -69,11 +65,11 @@ public class FireworkLauncher extends Furniture implements Listener {
} }
} }
if(stand == null) return; if(stand == null) return;
if(p.getInventory().getItemInMainHand()!=null){ if(player.getInventory().getItemInMainHand()!=null){
if(p.getInventory().getItemInMainHand().getType()!=null){ if(player.getInventory().getItemInMainHand().getType()!=null){
if(p.getInventory().getItemInMainHand().getType().equals(Material.FIREWORK_ROCKET)){ if(player.getInventory().getItemInMainHand().getType().equals(Material.FIREWORK_ROCKET)){
drop(stand); drop(stand);
setItem(stand, p.getInventory().getItemInMainHand()); setItem(stand, player.getInventory().getItemInMainHand());
Bukkit.getScheduler().runTaskLater(getPlugin(), new Runnable() { Bukkit.getScheduler().runTaskLater(getPlugin(), new Runnable() {
@ -84,12 +80,12 @@ public class FireworkLauncher extends Furniture implements Listener {
} }
}, 5); }, 5);
if(e.getPlayer().getGameMode().equals(GameMode.CREATIVE) && getLib().useGamemode()) return; if(player.getGameMode().equals(GameMode.CREATIVE) && getLib().useGamemode()) return;
Integer i = e.getPlayer().getInventory().getHeldItemSlot(); Integer i = player.getInventory().getHeldItemSlot();
ItemStack is = e.getPlayer().getInventory().getItemInMainHand(); ItemStack is = player.getInventory().getItemInMainHand();
is.setAmount(is.getAmount()-1); is.setAmount(is.getAmount()-1);
p.getInventory().setItem(i, is); player.getInventory().setItem(i, is);
p.updateInventory(); player.updateInventory();
return; return;
} }
} }
@ -102,6 +98,7 @@ public class FireworkLauncher extends Furniture implements Listener {
setItem(stand, new ItemStack(Material.AIR)); setItem(stand, new ItemStack(Material.AIR));
} }
} }
}
public double getRandom(double min, double max){ public double getRandom(double min, double max){
return ThreadLocalRandom.current().nextDouble(min, max); return ThreadLocalRandom.current().nextDouble(min, max);

View File

@ -8,14 +8,13 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.ItemFrame; import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle; import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Main.main; 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.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart; import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
@ -93,16 +92,16 @@ public class billboard extends Furniture implements Listener{
Bukkit.getPluginManager().registerEvents(this, getPlugin()); Bukkit.getPluginManager().registerEvents(this, getPlugin());
} }
@EventHandler @Override
public void onFurnitureBreak(FurnitureBreakEvent e) { public void onBreak(Player player) {
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())){return;} if(player == null) return;
if(!canBuild(e.getPlayer())){return;} if(canBuild(player)) {
e.remove(); this.destroy(player);
delete(); }
} }
@EventHandler @Override
public void onFurnitureClick(FurnitureClickEvent e) {} public void onClick(Player p) {}
} }

View File

@ -4,17 +4,16 @@ import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.map.MapView; import org.bukkit.map.MapView;
import de.Ste3et_C0st.Furniture.Camera.Utils.RenderClass; import de.Ste3et_C0st.Furniture.Camera.Utils.RenderClass;
import de.Ste3et_C0st.Furniture.Camera.Utils.RenderClass.ScaleMode; import de.Ste3et_C0st.Furniture.Camera.Utils.RenderClass.ScaleMode;
import de.Ste3et_C0st.Furniture.Main.main; import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.ShematicLoader.Events.ProjectClickEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.Relative; import de.Ste3et_C0st.FurnitureLib.Utilitis.Relative;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper; import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity; import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
public class camera extends FurnitureHelper implements Listener{ public class camera extends FurnitureHelper implements Listener{
@ -66,19 +65,29 @@ public class camera extends FurnitureHelper implements Listener{
update(); update();
} }
@Override
public void onBreak(Player player) {
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
this.destroy(player);
}
}
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@EventHandler @Override
public void onFurnitureClick(ProjectClickEvent e) { public void onClick(Player player) {
if(!e.getID().equals(getObjID())){return;} if(getObjID() == null) return;
Player p = e.getPlayer(); if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
Location pLocation = getLutil().getRelativ(p.getLocation().getBlock().getLocation(), getBlockFace(), -1D, 0D).clone(); if(player == null) return;
Location pLocation = getLutil().getRelativ(player.getLocation().getBlock().getLocation(), getBlockFace(), -1D, 0D).clone();
Location locCopy = getLocation().getBlock().getLocation().clone(); Location locCopy = getLocation().getBlock().getLocation().clone();
pLocation.setYaw(locCopy.getYaw()); pLocation.setYaw(locCopy.getYaw());
if(pLocation.equals(locCopy)){ if(pLocation.equals(locCopy)){
if(getLutil().yawToFace(p.getLocation().getYaw()).getOppositeFace().equals(getBlockFace())){ if(getLutil().yawToFace(player.getLocation().getYaw()).getOppositeFace().equals(getBlockFace())){
if(e.canBuild()){ if(canBuild(player)){
if(!p.getInventory().getItemInMainHand().getType().equals(Material.FILLED_MAP)){ if(!player.getInventory().getItemInMainHand().getType().equals(Material.FILLED_MAP)){
if(entity == null || entity2 == null)return; if(entity == null || entity2 == null)return;
if(this.zoom.equalsIgnoreCase("#ZOOM0#")){ if(this.zoom.equalsIgnoreCase("#ZOOM0#")){
this.mode = ScaleMode.FAR; this.mode = ScaleMode.FAR;
@ -98,12 +107,10 @@ public class camera extends FurnitureHelper implements Listener{
update(); update();
return; return;
} }
}else{ }else if(!player.getInventory().getItemInMainHand().getType().equals(Material.MAP)){
if(!p.getInventory().getItemInMainHand().getType().equals(Material.MAP)){
return; return;
} }
} MapView view = Bukkit.getMap(player.getInventory().getItemInMainHand().getDurability());
MapView view = Bukkit.getMap(p.getInventory().getItemInMainHand().getDurability());
Location l = getLocation().clone(); Location l = getLocation().clone();
l.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace())); l.setYaw(getLutil().FaceToYaw(getBlockFace().getOppositeFace()));
view.getRenderers().clear(); view.getRenderers().clear();

View File

@ -8,6 +8,7 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockRedstoneEvent; import org.bukkit.event.block.BlockRedstoneEvent;
@ -16,10 +17,6 @@ import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import de.Ste3et_C0st.Furniture.Main.main; 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.main.Furniture; import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib; import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
@ -125,23 +122,23 @@ public class streetlamp extends Furniture implements Listener{
getObjID().addBlock(blockLocation); getObjID().addBlock(blockLocation);
} }
@EventHandler @Override
private void onBlockBreak(FurnitureBlockBreakEvent e){ public void onBreak(Player player) {
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(player == null) return;
if(!e.canBuild()){return;} if(canBuild(player)) {
FurnitureLib.getInstance().getLightManager().removeLight(light); FurnitureLib.getInstance().getLightManager().removeLight(light);
e.remove(); this.destroy(player);
delete(); }
} }
@EventHandler @Override
private void onBlockClick(FurnitureBlockClickEvent e){ public void onClick(Player player){
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(player == null) return;
if(!e.canBuild()){return;} if(!canBuild(player)) {return;}
if(isOn()){ if(isOn()){
setLight(false); setLight(false);
}else{ }else{
@ -216,32 +213,4 @@ public class streetlamp extends Furniture implements Listener{
} }
return false; return false;
} }
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) {
if(e.getID() == null || 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
public void onFurnitureClick(FurnitureClickEvent e) {
if(e.getID() == null || getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
Boolean isOn = isOn();
fEntity packet = getPacket();
if(packet==null) return;
if(redstone) return;
if(isOn){
setLight(false);
}else{
setLight(true);
}
}
} }

View File

@ -9,6 +9,7 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Tag; import org.bukkit.Tag;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.block.BlockPhysicsEvent;
@ -16,9 +17,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle; import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Main.main; import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBlockBreakEvent;
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.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction; import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
@ -70,24 +68,18 @@ public class TFlowerPot extends Furniture implements Listener {
} }
@Override @Override
public void onFurnitureBreak(FurnitureBreakEvent paramFurnitureBreakEvent) {} public void onClick(Player p) {}
@Override @Override
public void onFurnitureClick(FurnitureClickEvent paramFurnitureClickEvent) {} public void onBreak(Player player) {
if(getObjID() == null) return;
@EventHandler if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
private void BlockBreak(FurnitureBlockBreakEvent e){ if(player == null) return;
if(e.getID() == null || getObjID() == null) return; if(canBuild(player)) {
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;}
if(!canBuild(e.getPlayer())){return;}
destroy(e.getPlayer());
pot.setType(Material.AIR); pot.setType(Material.AIR);
pot=null; pot=null;
return; this.destroy(player);
}
} }
@EventHandler @EventHandler

View File

@ -1,46 +1,55 @@
package de.Ste3et_C0st.Furniture.Objects.garden; package de.Ste3et_C0st.Furniture.Objects.garden;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.event.EventHandler; import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import de.Ste3et_C0st.Furniture.Main.main; import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.ShematicLoader.Events.ProjectClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper; import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity; import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
public class Trunk extends FurnitureHelper implements Listener{ public class Trunk extends FurnitureHelper{
public Trunk(ObjectID id){ public Trunk(ObjectID id){
super(id); super(id);
Bukkit.getPluginManager().registerEvents(this, main.instance);
} }
@EventHandler @Override
public void onClick(ProjectClickEvent e){ public void onClick(Player player){
if(!e.getID().equals(getObjID())){return;} if(getObjID() == null) return;
ItemStack stack = e.getPlayer().getInventory().getItemInMainHand(); if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
ItemStack stack = player.getInventory().getItemInMainHand();
if(stack==null) return; if(stack==null) return;
if(main.materialWhiteList.contains(stack.getType())){ if(main.materialWhiteList.contains(stack.getType())){
if(stack.getType().equals(Material.AIR)) return; if(stack.getType().equals(Material.AIR)) return;
for(fEntity entity : e.getID().getPacketList()){ for(fEntity entity : getfAsList()){
if(entity.getName().startsWith("#TO")){ if(entity.getName().startsWith("#TO")){
entity.setHelmet(stack); entity.setHelmet(stack);
} }
} }
update(); update();
}else{ }else{
for(fEntity entity : e.getID().getPacketList()){ for(fEntity entity : getfAsList()){
if(entity.getName().startsWith("#SITZ:")){ if(entity.getName().startsWith("#SITZ:")){
if(entity.getPassanger()==null){ if(entity.getPassanger()==null||entity.getPassanger().isEmpty()){
entity.setPassanger(e.getPlayer()); entity.setPassanger(player);
return; return;
} }
} }
} }
} }
} }
@Override
public void onBreak(Player player) {
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
this.destroy(player);
}
}
} }

View File

@ -3,21 +3,19 @@ package de.Ste3et_C0st.Furniture.Objects.garden;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.event.EventHandler; import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import de.Ste3et_C0st.Furniture.Main.main; import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.ShematicLoader.Events.ProjectClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper; import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity; import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
public class fance extends FurnitureHelper implements Listener{ public class fance extends FurnitureHelper{
List<Material> matList = Arrays.asList( List<Material> matList = Arrays.asList(
Material.SPRUCE_FENCE, Material.SPRUCE_FENCE,
Material.BIRCH_FENCE, Material.BIRCH_FENCE,
@ -29,27 +27,40 @@ public class fance extends FurnitureHelper implements Listener{
public fance(ObjectID id){ public fance(ObjectID id){
super(id); super(id);
Bukkit.getPluginManager().registerEvents(this, main.instance);
} }
@EventHandler @Override
public void onClick(ProjectClickEvent e){ public void onClick(Player player){
if(!e.getID().equals(getObjID())){return;} if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
Block b = getWorld().getBlockAt(getObjID().getBlockList().toArray(new Location[getObjID().getBlockList().size()])[0]); Block b = getWorld().getBlockAt(getObjID().getBlockList().toArray(new Location[getObjID().getBlockList().size()])[0]);
ItemStack stack = e.getPlayer().getInventory().getItemInMainHand(); ItemStack stack = player.getInventory().getItemInMainHand();
if(stack==null) return; if(stack==null) return;
if(stack.getType().equals(Material.AIR)) return; if(stack.getType().equals(Material.AIR)) return;
if(matList.contains(stack.getType())){ if(matList.contains(stack.getType())){
b.setType(stack.getType()); b.setType(stack.getType());
consumeItem(e.getPlayer()); consumeItem(player);
return; return;
}else if(main.materialWhiteList.contains(stack.getType())){ }else if(main.materialWhiteList.contains(stack.getType())){
setTypes(stack); setTypes(stack);
consumeItem(e.getPlayer()); consumeItem(player);
update(); update();
return; return;
} }
} }
}
@Override
public void onBreak(Player player) {
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
this.destroy(player);
}
}
private void setTypes(ItemStack is){for(fEntity packet : getManager().getfArmorStandByObjectID(getObjID())){packet.getInventory().setHelmet(is);}} private void setTypes(ItemStack is){for(fEntity packet : getManager().getfArmorStandByObjectID(getObjID())){packet.getInventory().setHelmet(is);}}
} }

View File

@ -11,17 +11,15 @@ import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.BookMeta;
import de.Ste3et_C0st.Furniture.Main.main; import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.ShematicLoader.Events.ProjectBreakEvent;
import de.Ste3et_C0st.FurnitureLib.ShematicLoader.Events.ProjectClickEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.LocationUtil; import de.Ste3et_C0st.FurnitureLib.Utilitis.LocationUtil;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper; import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
public class graveStone extends FurnitureHelper implements Listener{ public class graveStone extends FurnitureHelper implements Listener{
@ -61,29 +59,31 @@ public class graveStone extends FurnitureHelper implements Listener{
getObjID().addBlock(Arrays.asList(this.sign)); getObjID().addBlock(Arrays.asList(this.sign));
} }
@EventHandler @Override
private void onBlockBreak(ProjectBreakEvent e){ public void onBreak(Player player) {
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.canBuild()){return;} if(player == null) return;
if(canBuild(player)) {
this.destroy(player);
if(sign!=null){ if(sign!=null){
sign.setType(Material.AIR); sign.setType(Material.AIR);
} }
} }
}
@EventHandler @Override
private void onBlockClick(ProjectClickEvent e){ public void onClick(Player player){
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.canBuild()){return;} if(player == null) return;
Player p = e.getPlayer(); if(canBuild(player)) {
if(!e.getID().equals(getObjID())) return; ItemStack is = player.getInventory().getItemInMainHand();
if(!e.canBuild()){return;}
ItemStack is = p.getInventory().getItemInMainHand();
if (is == null) return; if (is == null) return;
if (!is.getType().equals(Material.WRITTEN_BOOK)) return; if (!is.getType().equals(Material.WRITTEN_BOOK)) return;
readFromBook(is); readFromBook(is);
} }
}
public void resetSign(){ public void resetSign(){
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() { Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() {

View File

@ -18,8 +18,6 @@ import org.bukkit.inventory.meta.ItemMeta;
import de.Ste3et_C0st.Furniture.Main.main; import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.Crafting.Project; import de.Ste3et_C0st.FurnitureLib.Crafting.Project;
import de.Ste3et_C0st.FurnitureLib.ShematicLoader.Events.ProjectBreakEvent;
import de.Ste3et_C0st.FurnitureLib.ShematicLoader.Events.ProjectClickEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.HiddenStringUtils; import de.Ste3et_C0st.FurnitureLib.Utilitis.HiddenStringUtils;
import de.Ste3et_C0st.FurnitureLib.Utilitis.ManageInv; import de.Ste3et_C0st.FurnitureLib.Utilitis.ManageInv;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper; import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper;
@ -49,11 +47,14 @@ public class log extends FurnitureHelper implements Listener{
setList(); setList();
} }
@EventHandler @Override
private void onBlockBreak(ProjectBreakEvent e){ public void onBreak(Player player) {
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.canBuild()){return;} if(player == null) return;
if(canBuild(player)) {
this.destroy(player);
}
} }
private Project getProjectByItem(ItemStack is){ private Project getProjectByItem(ItemStack is){
@ -83,19 +84,20 @@ public class log extends FurnitureHelper implements Listener{
return copy; return copy;
} }
@EventHandler @Override
private void onBlockBreak(ProjectClickEvent e){ public void onClick(Player player){
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.canBuild()){return;} if(player == null) return;
if(e.getPlayer().isSneaking()){ if(canBuild(player)) {
if(e.getPlayer().getInventory().getItemInMainHand().getType().isBlock()&& if(player.isSneaking()){
!e.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.AIR)){ if(player.getInventory().getItemInMainHand().getType().isBlock()&&
!player.getInventory().getItemInMainHand().getType().equals(Material.AIR)){
return; return;
} }
openInventory(e.getPlayer()); openInventory(player);
}else{ }else{
ItemStack stack = e.getPlayer().getInventory().getItemInMainHand(); ItemStack stack = player.getInventory().getItemInMainHand();
if(stack == null || stack.getType().equals(Material.AIR)){ if(stack == null || stack.getType().equals(Material.AIR)){
//dropItem //dropItem
fEntity entity = entityByCustomName(this.mode + ""); fEntity entity = entityByCustomName(this.mode + "");
@ -126,13 +128,14 @@ public class log extends FurnitureHelper implements Listener{
ItemStack placeItem = stack.clone(); ItemStack placeItem = stack.clone();
placeItem.setAmount(1); placeItem.setAmount(1);
entity.getInventory().setItemInMainHand(placeItem); entity.getInventory().setItemInMainHand(placeItem);
consumeItem(e.getPlayer()); consumeItem(player);
update(); update();
} }
} }
} }
} }
} }
}
private void setList(){ private void setList(){
ItemStack stack = new ItemStack(Material.WHITE_BANNER); ItemStack stack = new ItemStack(Material.WHITE_BANNER);

View File

@ -3,17 +3,15 @@ package de.Ste3et_C0st.Furniture.Objects.garden;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle; import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Main.main; import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.ShematicLoader.Events.ProjectBreakEvent;
import de.Ste3et_C0st.FurnitureLib.ShematicLoader.Events.ProjectClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper; import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart; import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand; import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity; import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
@ -39,13 +37,13 @@ public class sunshade extends FurnitureHelper implements Listener{
}return true; }return true;
} }
@EventHandler @Override
public void onClick(ProjectClickEvent e){ public void onClick(Player player){
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.canBuild()){return;} if(player == null) return;
Player p = e.getPlayer(); if(canBuild(player)) {
ItemStack is = p.getInventory().getItemInMainHand(); ItemStack is = player.getInventory().getItemInMainHand();
if(is.getType().name().contains("BANNER")){ if(is.getType().name().contains("BANNER")){
for(fEntity packet : getfAsList()){ for(fEntity packet : getfAsList()){
if(packet.getInventory().getHelmet()!=null&&packet.getInventory().getHelmet().getType().name().contains("BANNER")){ if(packet.getInventory().getHelmet()!=null&&packet.getInventory().getHelmet().getType().name().contains("BANNER")){
@ -57,7 +55,7 @@ public class sunshade extends FurnitureHelper implements Listener{
} }
} }
update(); update();
consumeItem(p); consumeItem(player);
}else{ }else{
if(!isOpen()){ if(!isOpen()){
open(); open();
@ -65,16 +63,17 @@ public class sunshade extends FurnitureHelper implements Listener{
close(); close();
} }
} }
}
} }
@EventHandler @Override
public void onBreak(ProjectBreakEvent e){ public void onBreak(Player player) {
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.canBuild()){return;} if(player == null) return;
if(isRunning){ if(canBuild(player)) {
stopTimer(); this.destroy(player);
if(isRunning) stopTimer();
} }
} }

View File

@ -10,14 +10,9 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle; 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.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart; import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
@ -27,7 +22,7 @@ import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand; import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity; import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
public class largeTable extends Furniture implements Listener{ public class largeTable extends Furniture{
public largeTable(ObjectID id){ public largeTable(ObjectID id){
super(id); super(id);
@ -37,8 +32,6 @@ public class largeTable extends Furniture implements Listener{
tellerIDs.add(packet.getEntityID()); tellerIDs.add(packet.getEntityID());
} }
} }
Bukkit.getPluginManager().registerEvents(this, main.getInstance());
return; return;
} }
spawn(id.getStartLocation()); spawn(id.getStartLocation());
@ -176,40 +169,38 @@ public class largeTable extends Furniture implements Listener{
} }
} }
@EventHandler @Override
public void onFurnitureBreak(FurnitureBreakEvent e){ public void onBreak(Player player) {
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(e.getID()==null){return;} if(player == null) return;
if(!e.getID().equals(getObjID())){return;} if(canBuild(player)) {
if(!e.canBuild()){return;}
for(Integer id : tellerIDs){ for(Integer id : tellerIDs){
fEntity asp = getManager().getfArmorStandByID(id); fEntity asp = getManager().getfArmorStandByID(id);
if(asp!=null&&asp.getInventory().getItemInMainHand()!=null){ if(asp!=null&&asp.getInventory().getItemInMainHand()!=null){
if(asp.getName().startsWith("#TELLER")){ if(asp.getName().startsWith("#TELLER")){
fEntity packet = asp; fEntity packet = asp;
e.getLocation().getWorld().dropItem(e.getLocation(), packet.getInventory().getItemInMainHand()); getWorld().dropItem(getLocation(), packet.getInventory().getItemInMainHand());
} }
} }
} }
e.remove(); this.destroy(player);
delete(); }
} }
@EventHandler @Override
public void onFurnitureClick(FurnitureClickEvent e){ public void onClick(Player player){
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(e.getID()==null) return; if(player == null) return;
if(!e.getID().equals(getObjID())){return;} if(canBuild(player)) {
if(!e.canBuild()){return;} if(DyeColor.getDyeColor(player.getInventory().getItemInMainHand().getType()) != null){
Player p = e.getPlayer(); getLib().getColorManager().color(player, canBuild(player), "_STAINED_GLASS_PANE", getObjID(), ColorType.BLOCK, 3);
if(DyeColor.getDyeColor(p.getInventory().getItemInMainHand().getType()) != null){
getLib().getColorManager().color(p, e.canBuild(), "_STAINED_GLASS_PANE", getObjID(), ColorType.BLOCK, 3);
update(); update();
return; return;
}else{ }else{
setTeller(p, p.getInventory().getItemInMainHand()); setTeller(player, player.getInventory().getItemInMainHand());
}
} }
} }

View File

@ -1,44 +1,29 @@
package de.Ste3et_C0st.Furniture.Objects.light; package de.Ste3et_C0st.Furniture.Objects.light;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.event.EventHandler; import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.ShematicLoader.Events.ProjectClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper; import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction; import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
public class WaxCandle extends FurnitureHelper implements Listener{ public class WaxCandle extends FurnitureHelper{
public WaxCandle(ObjectID id){ public WaxCandle(ObjectID id){
super(id); super(id);
Bukkit.getPluginManager().registerEvents(this, main.instance);
} }
@EventHandler @Override
public void onWaterFlow(BlockFromToEvent e){ public void onClick(Player player){
if(getObjID()==null){return;} if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
Location locTo = e.getToBlock().getLocation(); if(player == null) return;
if(getLocation()!=null && getLocation().getChunk().isLoaded()){ if(canBuild(player)) {
if(locTo.equals(getLocation().getBlock().getLocation())) {
e.setCancelled(true);
}
}
}
@EventHandler
public void onClick(ProjectClickEvent e){
if(!e.getID().equals(getObjID())){return;}
Block b = getWorld().getBlockAt(getObjID().getBlockList().toArray(new Location[getObjID().getBlockList().size()])[0]); Block b = getWorld().getBlockAt(getObjID().getBlockList().toArray(new Location[getObjID().getBlockList().size()])[0]);
ItemStack stack = e.getPlayer().getInventory().getItemInMainHand(); ItemStack stack = player.getInventory().getItemInMainHand();
if(stack==null) return; if(stack==null) return;
if(stack.getType().equals(Material.AIR)) return; if(stack.getType().equals(Material.AIR)) return;
if(b!=null){ if(b!=null){
@ -50,3 +35,14 @@ public class WaxCandle extends FurnitureHelper implements Listener{
} }
} }
} }
@Override
public void onBreak(Player player) {
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
this.destroy(player);
}
}
}

View File

@ -1,57 +1,55 @@
package de.Ste3et_C0st.Furniture.Objects.outdoor; package de.Ste3et_C0st.Furniture.Objects.outdoor;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.ShematicLoader.Events.ProjectBreakEvent;
import de.Ste3et_C0st.FurnitureLib.ShematicLoader.Events.ProjectClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper; import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity; import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
public class barrels extends FurnitureHelper implements Listener { public class barrels extends FurnitureHelper{
Integer id; Integer id;
Block block; Block block;
public barrels(ObjectID id){ public barrels(ObjectID id){
super(id); super(id);
Bukkit.getPluginManager().registerEvents(this, main.instance);
} }
@EventHandler @Override
public void onFurnitureClick(ProjectClickEvent e){ public void onClick(Player player){
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.canBuild()){return;} if(player == null) return;
Player p = e.getPlayer(); if(canBuild(player)) {
if(!p.getInventory().getItemInMainHand().getType().isBlock()&&!p.getInventory().getItemInMainHand().getType().equals(Material.AIR)){return;} if(!player.getInventory().getItemInMainHand().getType().isBlock()&&!player.getInventory().getItemInMainHand().getType().equals(Material.AIR)){return;}
fEntity packet = getManager().getfArmorStandByObjectID(getObjID()).get(0); fEntity packet = getManager().getfArmorStandByObjectID(getObjID()).get(0);
if(packet.getInventory().getHelmet()!=null&&!packet.getInventory().getHelmet().getType().equals(Material.AIR)){ if(packet.getInventory().getHelmet()!=null&&!packet.getInventory().getHelmet().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getHelmet(); ItemStack is = packet.getInventory().getHelmet();
is.setAmount(1); is.setAmount(1);
getWorld().dropItem(getLocation(), is); getWorld().dropItem(getLocation(), is);
} }
packet.getInventory().setHelmet(p.getInventory().getItemInMainHand()); packet.getInventory().setHelmet(player.getInventory().getItemInMainHand());
update(); update();
consumeItem(e.getPlayer()); consumeItem(player);
}
} }
@EventHandler @Override
private void onBlockBreak(ProjectBreakEvent e){ public void onBreak(Player player) {
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.canBuild()){return;} if(player == null) return;
if(canBuild(player)) {
fEntity packet = getManager().getfArmorStandByObjectID(getObjID()).get(0); fEntity packet = getManager().getfArmorStandByObjectID(getObjID()).get(0);
if(packet.getInventory().getHelmet()!=null&&!packet.getInventory().getHelmet().getType().equals(Material.AIR)){ if(packet.getInventory().getHelmet()!=null&&!packet.getInventory().getHelmet().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getHelmet(); ItemStack is = packet.getInventory().getHelmet();
is.setAmount(1); is.setAmount(1);
getWorld().dropItem(getLocation(), is); getWorld().dropItem(getLocation(), is);
} }
this.destroy(player);
}
} }
} }

View File

@ -5,55 +5,46 @@ import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.event.EventHandler; import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
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.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction; import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity; import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
public class campfire_1 extends Furniture implements Listener{ public class campfire_1 extends Furniture{
public campfire_1(ObjectID id){ public campfire_1(ObjectID id){
super(id); super(id);
if(isFinish()){ if(isFinish()){return;}
Bukkit.getPluginManager().registerEvents(this, main.getInstance());
return;
}
spawn(id.getStartLocation()); spawn(id.getStartLocation());
} }
@EventHandler @Override
public void onFurnitureBreak(FurnitureBreakEvent e){ public void onBreak(Player player) {
if(getObjID()==null||e.getID()==null){return;} if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(e.getID()==null) return; if(player == null) return;
if(!e.getID().equals(getObjID())){return;} if(canBuild(player)) {
if(!e.canBuild()){return;}
for(fEntity packet : getManager().getfArmorStandByObjectID(getObjID())){ for(fEntity packet : getManager().getfArmorStandByObjectID(getObjID())){
packet.setFire(false); packet.setFire(false);
Location location = getLocation().clone(); Location location = getLocation().clone();
location.add(0, 1.2, 0); location.add(0, 1.2, 0);
getLib().getLightManager().removeLight(location); getLib().getLightManager().removeLight(location);
} }
getManager().updateFurniture(getObjID()); this.destroy(player);
e.remove(); }
delete();
} }
@EventHandler @Override
public void onFurnitureClick(FurnitureClickEvent e){ public void onClick(Player player){
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())){return;} if(player == null) return;
if(!e.canBuild()){return;} if(canBuild(player)) {
List<fEntity> aspList = getManager().getfArmorStandByObjectID(getObjID()); List<fEntity> aspList = getManager().getfArmorStandByObjectID(getObjID());
ItemStack is = e.getPlayer().getInventory().getItemInMainHand(); ItemStack is = player.getInventory().getItemInMainHand();
if(is.getType().equals(Material.WATER_BUCKET)){ if(is.getType().equals(Material.WATER_BUCKET)){
for(fEntity packet : aspList){ for(fEntity packet : aspList){
packet.setFire(false); packet.setFire(false);
@ -72,6 +63,7 @@ public class campfire_1 extends Furniture implements Listener{
getManager().updateFurniture(getObjID()); getManager().updateFurniture(getObjID());
} }
} }
}
public void spawn(Location loc){ public void spawn(Location loc){

View File

@ -2,22 +2,18 @@ package de.Ste3et_C0st.Furniture.Objects.outdoor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.EnumSet;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.event.EventHandler; import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle; import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import de.Ste3et_C0st.Furniture.Main.main; 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.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart; import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
@ -25,7 +21,7 @@ import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand; import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity; import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
public class campfire_2 extends Furniture implements Listener{ public class campfire_2 extends Furniture{
List<Material> items = new ArrayList<Material>( List<Material> items = new ArrayList<Material>(
Arrays.asList( Arrays.asList(
Material.BEEF, Material.BEEF,
@ -61,7 +57,6 @@ public class campfire_2 extends Furniture implements Listener{
grill = getLutil().getRelativ(middle,getBlockFace(), .0D, .5D); grill = getLutil().getRelativ(middle,getBlockFace(), .0D, .5D);
grill.setYaw(getLutil().FaceToYaw(getBlockFace())+90); grill.setYaw(getLutil().FaceToYaw(getBlockFace())+90);
if(id.isFinish()){ if(id.isFinish()){
Bukkit.getPluginManager().registerEvents(this, main.getInstance());
return; return;
} }
spawn(id.getStartLocation()); spawn(id.getStartLocation());
@ -139,14 +134,14 @@ public class campfire_2 extends Furniture implements Listener{
Bukkit.getPluginManager().registerEvents(this, getPlugin()); Bukkit.getPluginManager().registerEvents(this, getPlugin());
} }
@EventHandler @Override
public void onFurnitureClick(FurnitureClickEvent e){ public void onClick(Player player){
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())){return;} if(player == null) return;
if(!e.canBuild()){return;} if(canBuild(player)) {
List<fEntity> aspList = getManager().getfArmorStandByObjectID(getObjID()); List<fEntity> aspList = getManager().getfArmorStandByObjectID(getObjID());
final ItemStack itemStack = e.getPlayer().getInventory().getItemInMainHand(); final ItemStack itemStack = player.getInventory().getItemInMainHand();
fArmorStand packet = null; fArmorStand packet = null;
for(fEntity pack : aspList){ for(fEntity pack : aspList){
if(pack instanceof fArmorStand){ if(pack instanceof fArmorStand){
@ -169,14 +164,14 @@ public class campfire_2 extends Furniture implements Listener{
setGrill(); setGrill();
if(e.getPlayer().getGameMode().equals(GameMode.CREATIVE) && getLib().useGamemode()) return; if(player.getGameMode().equals(GameMode.CREATIVE) && getLib().useGamemode()) return;
Integer i = e.getPlayer().getInventory().getHeldItemSlot(); Integer i = player.getInventory().getHeldItemSlot();
ItemStack item = e.getPlayer().getInventory().getItemInMainHand(); ItemStack item = player.getInventory().getItemInMainHand();
item.setAmount(item.getAmount()-1); item.setAmount(item.getAmount()-1);
e.getPlayer().getInventory().setItem(i, item); player.getInventory().setItem(i, item);
e.getPlayer().updateInventory(); player.updateInventory();
}
} }
} }
private void setfire(boolean b){ private void setfire(boolean b){
@ -202,20 +197,20 @@ public class campfire_2 extends Furniture implements Listener{
update(); update();
} }
@EventHandler @Override
public void onFurnitureBreak(FurnitureBreakEvent e){ public void onBreak(Player player) {
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())){return;} if(player == null) return;
if(!e.canBuild()){return;} if(canBuild(player)) {
if(isRunning()){ if(isRunning()){
Bukkit.getScheduler().cancelTask(timer); Bukkit.getScheduler().cancelTask(timer);
timer=null; timer=null;
getWorld().dropItemNaturally(middle.clone().add(0, 1, 0), is).setVelocity(new Vector().zero()); getWorld().dropItemNaturally(middle.clone().add(0, 1, 0), is).setVelocity(new Vector().zero());
} }
setfire(false); setfire(false);
e.remove(); this.destroy(player);
delete(); }
} }
public void removeGrill(){ public void removeGrill(){

View File

@ -1,34 +1,27 @@
package de.Ste3et_C0st.Furniture.Objects.outdoor; package de.Ste3et_C0st.Furniture.Objects.outdoor;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.ShematicLoader.Events.ProjectClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper; import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction; import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity; import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
public class hammock extends FurnitureHelper implements Listener{ public class hammock extends FurnitureHelper{
public hammock(ObjectID id) { public hammock(ObjectID id) {
super(id); super(id);
Bukkit.getPluginManager().registerEvents(this, main.getInstance());
} }
@EventHandler(priority = EventPriority.LOW) @Override
public void onClick(ProjectClickEvent e){ public void onClick(Player player){
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())){return;} if(player == null) return;
Player p = e.getPlayer(); if(canBuild(player)) {
ItemStack stack = p.getInventory().getItemInMainHand(); ItemStack stack = player.getInventory().getItemInMainHand();
if(stack!=null){ if(stack!=null){
if(isMaterial(stack.getType())){ if(isMaterial(stack.getType())){
if(stack.getType().name().contains("BANNER")){ if(stack.getType().name().contains("BANNER")){
@ -39,31 +32,49 @@ public class hammock extends FurnitureHelper implements Listener{
} }
} }
} }
e.setCancelled(true); consumeItem(player);
consumeItem(p);
update(); update();
}else{ }else{
for(fEntity entity : getfAsList()){ for(fEntity entity : getfAsList()){
if(entity.getHelmet()!=null){ if(entity.getHelmet()!=null){
if(entity.getHelmet().getType().toString().toLowerCase().startsWith("log")){ if(entity.getHelmet().getType().toString().toLowerCase().endsWith("log")){
entity.setHelmet(stack.clone()); entity.setHelmet(stack.clone());
} }
} }
} }
e.setCancelled(true); consumeItem(player);
consumeItem(p);
update(); update();
} }
}else {
for(fEntity entity : getfAsList()){
if(entity.getName().startsWith("#SITZ#")){
if(entity.getPassanger()==null||entity.getPassanger().isEmpty()){
entity.setPassanger(player);
} }
return;
}
}
}
}
}
}
@Override
public void onBreak(Player player) {
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
this.destroy(player);
} }
} }
private boolean isMaterial(Material m){ private boolean isMaterial(Material m){
if(m==null){return false;} if(m==null){return false;}
boolean b = false; boolean b = false;
if(m.toString().toLowerCase().startsWith("log")){ if(m.toString().toLowerCase().endsWith("log")){
b=true; b=true;
}else if(m.toString().toLowerCase().equalsIgnoreCase("banner")){ }else if(m.toString().toLowerCase().endsWith("banner")){
b=true; b=true;
} }

View File

@ -1,36 +1,39 @@
package de.Ste3et_C0st.Furniture.Objects.outdoor; package de.Ste3et_C0st.Furniture.Objects.outdoor;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.ShematicLoader.Events.ProjectClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper; import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.ColorType; import de.Ste3et_C0st.FurnitureLib.main.Type.ColorType;
import de.Ste3et_C0st.FurnitureLib.main.Type.DyeColor; import de.Ste3et_C0st.FurnitureLib.main.Type.DyeColor;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction; import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
public class tent_1 extends FurnitureHelper implements Listener{ public class tent_1 extends FurnitureHelper{
public tent_1(ObjectID id){ public tent_1(ObjectID id){
super(id); super(id);
Bukkit.getPluginManager().registerEvents(this, main.getInstance());
} }
@EventHandler @Override
public void onFurnitureClick(ProjectClickEvent e){ public void onClick(Player player){
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())){return;} if(player == null) return;
if(!e.canBuild()){return;} if(canBuild(player)) {
final Player p = e.getPlayer(); if(DyeColor.getDyeColor(player.getInventory().getItemInMainHand().getType()) == null){
if(DyeColor.getDyeColor(p.getInventory().getItemInMainHand().getType()) == null){ player.openWorkbench(null, true);
p.openWorkbench(null, true);
}else{ }else{
getLib().getColorManager().color(p, e.canBuild(), "_CARPET", getObjID(), ColorType.BLOCK, 1); getLib().getColorManager().color(player, true, "_CARPET", getObjID(), ColorType.BLOCK, 1);
}
}
}
@Override
public void onBreak(Player player) {
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
this.destroy(player);
} }
} }
} }

View File

@ -12,14 +12,11 @@ import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.Chest; import org.bukkit.block.Chest;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle; import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Main.main; 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.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart; import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
@ -178,35 +175,35 @@ public class tent_2 extends Furniture implements Listener{
} }
} }
@EventHandler @Override
public void onFurnitureBreak(FurnitureBreakEvent e){ public void onBreak(Player player) {
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())){return;} if(player == null) return;
if(!e.canBuild()){return;} if(canBuild(player)) {
for(Block bl : block){ for(Block bl : block){
bl.setType(Material.AIR); bl.setType(Material.AIR);
} }
e.remove(); this.destroy(player);
delete(); }
} }
@EventHandler @Override
public void onFurnitureClick(final FurnitureClickEvent e){ public void onClick(Player player){
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())){return;} if(player == null) return;
Player p = e.getPlayer(); if(canBuild(player)) {
if(!e.canBuild()){return;} if(DyeColor.getDyeColor(player.getInventory().getItemInMainHand().getType()) == null){
if(DyeColor.getDyeColor(p.getInventory().getItemInMainHand().getType()) == null){
for(Block b : block){ for(Block b : block){
if(b.getType().equals(Material.CHEST)){ if(b.getType().equals(Material.CHEST)){
Chest c = (Chest) b.getState(); Chest c = (Chest) b.getState();
e.getPlayer().openInventory(c.getBlockInventory()); player.getPlayer().openInventory(c.getBlockInventory());
} }
} }
}else{ }else{
getLib().getColorManager().color(p, e.canBuild(), "_CARPET", getObjID(), ColorType.BLOCK, 1); getLib().getColorManager().color(player, true, "_CARPET", getObjID(), ColorType.BLOCK, 1);
}
} }
} }
} }

View File

@ -12,15 +12,10 @@ import org.bukkit.block.BlockFace;
import org.bukkit.block.banner.Pattern; import org.bukkit.block.banner.Pattern;
import org.bukkit.block.banner.PatternType; import org.bukkit.block.banner.PatternType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.BannerMeta;
import org.bukkit.util.EulerAngle; 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.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart; import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
@ -30,12 +25,11 @@ import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand; import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity; import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
public class tent_3 extends Furniture implements Listener{ public class tent_3 extends Furniture{
public tent_3(ObjectID id){ public tent_3(ObjectID id){
super(id); super(id);
setBlock(); setBlock();
if(isFinish()){ if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, main.getInstance());
return; return;
} }
Location loc = getLocation(); Location loc = getLocation();
@ -151,33 +145,33 @@ public class tent_3 extends Furniture implements Listener{
getObjID().addBlock(Arrays.asList(bed)); getObjID().addBlock(Arrays.asList(bed));
} }
@EventHandler @Override
public void onFurnitureBreak(FurnitureBreakEvent e){ public void onBreak(Player player) {
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())){return;} if(player == null) return;
if(!e.canBuild()){return;} if(canBuild(player)) {
bed.setType(Material.AIR); bed.setType(Material.AIR);
e.remove(); this.destroy(player);
delete(); }
} }
@EventHandler @Override
public void onFurnitureClick(FurnitureClickEvent e){ public void onClick(Player player){
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())){return;} if(player == null) return;
if(!e.canBuild()){return;} if(canBuild(player)) {
Player p = e.getPlayer(); if(DyeColor.getDyeColor(player.getInventory().getItemInMainHand().getType()) != null){
if(DyeColor.getDyeColor(p.getInventory().getItemInMainHand().getType()) != null){ getLib().getColorManager().color(player, true, "_BANNER", getObjID(), ColorType.BANNER, 1);
getLib().getColorManager().color(p, e.canBuild(), "_BANNER", getObjID(), ColorType.BANNER, 1);
}else{ }else{
for(fEntity packet : getManager().getfArmorStandByObjectID(getObjID())){ for(fEntity packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().equalsIgnoreCase("#SITZ#")){ if(packet.getName().equalsIgnoreCase("#SITZ#")){
packet.setPassanger(p); packet.setPassanger(player);
packet.update(); packet.update();
} }
} }
} }
} }
} }
}

View File

@ -15,8 +15,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle; import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Main.main; 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.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID; import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction; import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
@ -102,28 +100,28 @@ public class BearTrap extends Furniture implements Listener{
Bukkit.getPluginManager().registerEvents(this, getPlugin()); Bukkit.getPluginManager().registerEvents(this, getPlugin());
} }
@EventHandler @Override
public void onFurnitureBreak(FurnitureBreakEvent e){ public void onBreak(Player player) {
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(e.getID() == null || getObjID() == null) return; if(player == null) return;
if(!e.getID().equals(getObjID())){return;} if(canBuild(player)) {
if(!e.canBuild()){return;} this.destroy(player);
e.remove(); }
delete();
} }
@EventHandler @Override
public void onFurnitureClick(FurnitureClickEvent e) { public void onClick(Player player){
if(e.getID() == null || getObjID() == null) return; if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;} if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(!e.getID().equals(getObjID())){return;} if(player == null) return;
if(!e.canBuild()){return;} if(canBuild(player)) {
if(b){ if(b){
setStatus(false); setStatus(false);
getWorld().playSound(getLocation(), Sound.BLOCK_ANVIL_LAND, 10, 1); getWorld().playSound(getLocation(), Sound.BLOCK_ANVIL_LAND, 10, 1);
} }
} }
}
private void setStatus(boolean b){ private void setStatus(boolean b){
if(!b){ if(!b){