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

View File

@ -6,36 +6,26 @@ import java.util.List;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.EntityEffect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
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.EntityType;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
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.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
@ -99,78 +89,89 @@ public class Catapult extends FurnitureHelper implements Listener{
}
}
@EventHandler
public void FurnitureClickEvent(ProjectClickEvent e){
if(getObjID()==null) return;
if(e.getID()==null) return;
if(!e.getID().equals(getObjID())) return;
if(e.getID().getSQLAction().equals(SQLAction.REMOVE)) return;
Location loc = getRelative(getCenter(), getBlockFace(), -.8, -1.03).add(0, -.2, 0);
loc.setYaw(getYaw());
ItemStack stack = e.getPlayer().getInventory().getItemInMainHand();
if(stack.getType().equals(Material.TNT)){
TNTPrimed tnt = (TNTPrimed) e.getID().getWorld().spawnEntity(loc, EntityType.PRIMED_TNT);
if(tnt == null) return;
Vector v= getLaunchVector(getBlockFace());
if(v == null) return;
tnt.playEffect(EntityEffect.WITCH_MAGIC);
tnt.setVelocity(v.multiply(1));
fallingSandList.put(tnt, e.getPlayer());
}else if(stack.getType().equals(Material.AIR)){
setRange(e.getPlayer());
return;
}else{
// if(stack.getType().isBlock()){
// @SuppressWarnings("deprecation")
// FallingBlock block = getWorld().spawnFallingBlock(loc, stack.getType().getId(), (byte) stack.getDurability());
// if(block == null) return;
// Vector v= getLaunchVector(getBlockFace());
// if(v == null) return;
// block.setDropItem(false);
// block.setVelocity(v.multiply(1));
// fallingSandList.put(block, e.getPlayer());
// e.getPlayer().playSound(getLocation(), Sound.ENTITY_ARROW_SHOOT, 1, (float) getPitch());
// }else if(stack.getType().equals(Material.MONSTER_EGG)){
// try{
// NBTTagCompound nbtTag = new CraftItemStack().getNBTTag(stack);
// if(nbtTag.hasKey("tag")){
// NBTTagCompound tag = nbtTag.getCompound("tag");
// NBTTagCompound id = tag.getCompound("EntityTag");
// String str = id.getString("id").replace("minecraft:", "");
// @SuppressWarnings("deprecation")
// EntityType type = EntityType.fromName(str);
// if(!entityList.contains(type)){setRange(e.getPlayer());return;}
// Vector v= getLaunchVector(getBlockFace());
// Entity entity = getWorld().spawnEntity(loc, type);
// entity.setVelocity(v);
// LivingEntity entiLivingEntity = (LivingEntity) entity;
// entiLivingEntity.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 4), false);
// if(type.equals(EntityType.CREEPER)){
// if(randInt(0, 25)==7){
// Creeper creeper = (Creeper) entity;
// creeper.setPowered(true);
// }
// }else if(type.equals(EntityType.SHEEP)){
// Sheep mob = (Sheep) entity;
// int i = randInt(0, DyeColor.values().length);
// mob.setColor(DyeColor.values()[i]);
// if(randInt(0, 25)==7){
// mob.setCustomName("jeb_");
// mob.setCustomNameVisible(false);
// }
// }
// }
// e.getPlayer().playSound(getLocation(), Sound.ENTITY_ARROW_SHOOT, 1, (float) getPitch());
// return;
// }catch(Exception ex){
// ex.printStackTrace();
// }
// }else{
setRange(e.getPlayer());
@Override
public void onClick(Player player){
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
Location loc = getRelative(getCenter(), getBlockFace(), -.8, -1.03).add(0, -.2, 0);
loc.setYaw(getYaw());
ItemStack stack = player.getInventory().getItemInMainHand();
if(stack.getType().equals(Material.TNT)){
TNTPrimed tnt = (TNTPrimed) getWorld().spawnEntity(loc, EntityType.PRIMED_TNT);
if(tnt == null) return;
Vector v= getLaunchVector(getBlockFace());
if(v == null) return;
tnt.playEffect(EntityEffect.WITCH_MAGIC);
tnt.setVelocity(v.multiply(1));
fallingSandList.put(tnt, player);
}else if(stack.getType().equals(Material.AIR)){
setRange(player);
return;
// }
}else{
// if(stack.getType().isBlock()){
// @SuppressWarnings("deprecation")
// FallingBlock block = getWorld().spawnFallingBlock(loc, stack.getType().getId(), (byte) stack.getDurability());
// if(block == null) return;
// Vector v= getLaunchVector(getBlockFace());
// if(v == null) return;
// block.setDropItem(false);
// block.setVelocity(v.multiply(1));
// fallingSandList.put(block, e.getPlayer());
// e.getPlayer().playSound(getLocation(), Sound.ENTITY_ARROW_SHOOT, 1, (float) getPitch());
// }else if(stack.getType().equals(Material.MONSTER_EGG)){
// try{
// NBTTagCompound nbtTag = new CraftItemStack().getNBTTag(stack);
// if(nbtTag.hasKey("tag")){
// NBTTagCompound tag = nbtTag.getCompound("tag");
// NBTTagCompound id = tag.getCompound("EntityTag");
// String str = id.getString("id").replace("minecraft:", "");
// @SuppressWarnings("deprecation")
// EntityType type = EntityType.fromName(str);
// if(!entityList.contains(type)){setRange(e.getPlayer());return;}
// Vector v= getLaunchVector(getBlockFace());
// Entity entity = getWorld().spawnEntity(loc, type);
// entity.setVelocity(v);
// LivingEntity entiLivingEntity = (LivingEntity) entity;
// entiLivingEntity.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 4), false);
// if(type.equals(EntityType.CREEPER)){
// if(randInt(0, 25)==7){
// Creeper creeper = (Creeper) entity;
// creeper.setPowered(true);
// }
// }else if(type.equals(EntityType.SHEEP)){
// Sheep mob = (Sheep) entity;
// int i = randInt(0, DyeColor.values().length);
// mob.setColor(DyeColor.values()[i]);
// if(randInt(0, 25)==7){
// mob.setCustomName("jeb_");
// mob.setCustomNameVisible(false);
// }
// }
// }
// e.getPlayer().playSound(getLocation(), Sound.ENTITY_ARROW_SHOOT, 1, (float) getPitch());
// return;
// }catch(Exception ex){
// ex.printStackTrace();
// }
// }else{
setRange(player);
return;
// }
}
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);
}
consumeItem(e.getPlayer());
}
public void setRange(Player p){

View File

@ -2,7 +2,6 @@ package de.Ste3et_C0st.Furniture.Objects.RPG;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -12,45 +11,41 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.SpectralArrow;
import org.bukkit.entity.TippedArrow;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
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.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
public class Crossbow extends FurnitureHelper implements Listener {
public class Crossbow extends FurnitureHelper {
public Crossbow(ObjectID id){
super(id);
Bukkit.getPluginManager().registerEvents(this, main.instance);
}
@EventHandler
public void onFurnitureClick(ProjectClickEvent 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;}
fEntity stand = getArmorStand();
if(stand==null){return;}
ItemStack is = e.getPlayer().getInventory().getItemInMainHand();
if(is!=null&& (is.getType().equals(Material.ARROW) || is.getType().equals(Material.SPECTRAL_ARROW) || is.getType().equals(Material.TIPPED_ARROW)) ){
if(!hasArrow()){
fEntity entity = getArmorStand();
entity.setItemInMainHand(is.clone());
update();
consumeItem(e.getPlayer());
return;
@Override
public void onClick(Player player){
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
fEntity stand = getArmorStand();
if(stand==null){return;}
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(!hasArrow()){
fEntity entity = getArmorStand();
entity.setItemInMainHand(is.clone());
update();
consumeItem(player);
return;
}
}
if(hasArrow()){
spawnArrow(getArrow().getType(), player);
}
}
if(hasArrow()){
spawnArrow(getArrow().getType(), e.getPlayer());
}
}
@ -132,4 +127,14 @@ public class Crossbow extends FurnitureHelper implements Listener {
}
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.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
@ -14,7 +12,6 @@ import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
@ -23,8 +20,6 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
@ -61,9 +56,9 @@ public class Guillotine extends Furniture implements Listener{
public Guillotine(ObjectID id) {
super(id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, main.getInstance());
setDefault();
initializeInventory();
Bukkit.getPluginManager().registerEvents(this, main.getInstance());
return;
}
spawn(id.getStartLocation());
@ -298,14 +293,13 @@ public class Guillotine extends Furniture implements Listener{
if(stack.getType().equals(Material.AIR)){return false;}
return true;
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent 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(!isRunning()){
@Override
public void onBreak(Player player) {
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
if(canDrop(packet1.getHelmet())){getWorld().dropItem(getLocation(), packet1.getHelmet());}
if(canDrop(packet1.getChestPlate())){getWorld().dropItem(getLocation(), packet1.getChestPlate());}
if(canDrop(packet1.getLeggings())){getWorld().dropItem(getLocation(), packet1.getLeggings());}
@ -322,44 +316,41 @@ public class Guillotine extends Furniture implements Listener{
im.setDisplayName(packet1.getName());
getWorld().dropItem(getLocation(), is);
}
this.getObjID().remove(e.getPlayer());
getManager().remove(getObjID());
delete();
this.destroy(player);
}
}
@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;}
Player p = e.getPlayer();
if(!getLib().canBuild(e.getPlayer(), getObjID(), EventType.INTERACT)){return;}
if(p.isSneaking()){
if(isFinish){return;}
p.openInventory(invI);
for(int i = 0; i<9;i++){invI.setItem(i, pane);}
ItemStack is = new ItemStack(Material.ZOMBIE_HEAD);
ItemMeta im = is.getItemMeta();
im.setDisplayName("§2Executioner");
is.setItemMeta(im);
invI.setItem(2, is);
is = new ItemStack(Material.PLAYER_HEAD);
im = is.getItemMeta();
im.setDisplayName("§cOblation");
is.setItemMeta(im);
invI.setItem(6, is);
this.p = p;
}else{
if(isRunning()){return;}
if(canStart()&&!isFinish){
move();
}else if(canStart()&&isFinish){
setDefault();
@Override
public void onClick(Player player){
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
if(!getLib().canBuild(player, getObjID(), EventType.INTERACT)){return;}
if(player.isSneaking()){
if(isFinish){return;}
player.openInventory(invI);
for(int i = 0; i<9;i++){invI.setItem(i, pane);}
ItemStack is = new ItemStack(Material.ZOMBIE_HEAD);
ItemMeta im = is.getItemMeta();
im.setDisplayName("§2Executioner");
is.setItemMeta(im);
invI.setItem(2, is);
is = new ItemStack(Material.PLAYER_HEAD);
im = is.getItemMeta();
im.setDisplayName("§cOblation");
is.setItemMeta(im);
invI.setItem(6, is);
this.p = player;
}else{
if(isRunning()){return;}
if(canStart()&&!isFinish){
move();
}else if(canStart()&&isFinish){
setDefault();
}
}
}
}

View File

@ -9,16 +9,10 @@ import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
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.ObjectID;
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.fEntity;
public class flag extends Furniture implements Listener {
public class flag extends Furniture {
public flag(ObjectID id){
super(id);
setBlock();
if(isFinish()){
setState(3, getStand());
Bukkit.getPluginManager().registerEvents(this, main.getInstance());
return;
}
spawn(id.getStartLocation());
@ -127,80 +120,42 @@ public class flag extends Furniture implements Listener {
update();
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) {
if(e.getID() == null || getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.getID() == null || getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
delete();
e.remove();
@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);
}
}
@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;}
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;
@Override
public void onClick(Player player){
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
if(player.getInventory().getItemInMainHand()!=null&&player.getInventory().getItemInMainHand().getType()!=null){
if(player.getInventory().getItemInMainHand().getType().name().contains("_BANNER")){
getStand().setHelmet(player.getInventory().getItemInMainHand());update();
if(player.getGameMode().equals(GameMode.CREATIVE) && getLib().useGamemode()) return;
Integer i = player.getInventory().getHeldItemSlot();
ItemStack is = player.getInventory().getItemInMainHand();
is.setAmount(is.getAmount()-1);
player.getInventory().setItem(i, is);
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;
int state = getState();
switch (state) {
case 3:state=2;break;
case 2:state=1;break;
case 1:state=3;break;
}
setState(state, getStand());
}
int state = getState();
switch (state) {
case 3:state=2;break;
case 2:state=1;break;
case 1:state=3;break;
}
setState(state, getStand());
}
}

View File

@ -10,6 +10,7 @@ import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
@ -18,8 +19,6 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.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.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> slotList2 = Arrays.asList(20, 15, 33);
@ -51,87 +50,88 @@ public class weaponStand extends Furniture {
Player p = null;
Inventory inv = null;
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) {
if(e.getID() == null || getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
if(p!=null){
p.closeInventory();
}
List<fEntity> asList = getManager().getfArmorStandByObjectID(getObjID());
for(fEntity packet : asList){
if(packet.getName()!=null&&!packet.getName().equalsIgnoreCase("")){
if(packet.getInventory().getItemInMainHand()!=null){
if(!packet.getInventory().getItemInMainHand().getType().equals(Material.AIR)){
getWorld().dropItem(getLocation(), packet.getInventory().getItemInMainHand());
}
}
@Override
public void onBreak(Player player) {
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
if(p!=null){
p.closeInventory();
inv = null;
}
}
e.remove();
inv = null;
delete();
}
@EventHandler
public void onFurnitureClick(FurnitureClickEvent e) {
if(e.getID() == null || getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(p!=null){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
this.p = e.getPlayer();
ItemStack itemstack = p.getInventory().getItemInMainHand();
if(itemstack!=null&&matList.contains(itemstack.getType())){
for(fEntity packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getInventory().getHelmet()!=null){
if(packet.getInventory().getHelmet().getType().name().toLowerCase().endsWith("gate")){
ItemStack itemStack = new ItemStack(itemstack.getType(), 1, (short) 0);
packet.getInventory().setHelmet(itemStack);
}
}
}
getManager().updateFurniture(getObjID());
this.p = null;
return;
}
ItemStack is1 = new ItemStack(Material.BLACK_STAINED_GLASS_PANE, 1);
ItemStack is3 = new ItemStack(Material.RED_STAINED_GLASS_PANE, 1);
ItemMeta im1 = is1.getItemMeta();
ItemMeta im3 = is3.getItemMeta();
im1.setDisplayName("§c");
im3.setDisplayName("§c");
is1.setItemMeta(im1);
is3.setItemMeta(im3);
inv = Bukkit.createInventory(null, 45, "§cWeaponBox");
List<fEntity> asList = getManager().getfArmorStandByObjectID(getObjID());
int j = 1;
for(int i = 0; i<inv.getSize();i++){
inv.setItem(i, is1);
if(slotList1.contains(i)){
inv.setItem(i, is3);
}else if(slotList2.contains(i)){
for(fEntity packet : asList){
if(packet.getName()!=null&&!packet.getName().equalsIgnoreCase("")){
if(packet.getName().equalsIgnoreCase("#SLOT"+j+"#")){
ItemStack is = new ItemStack(Material.AIR);
if(packet.getInventory().getItemInMainHand()!=null){is = packet.getInventory().getItemInMainHand();}
inv.setItem(i, is);
List<fEntity> asList = getManager().getfArmorStandByObjectID(getObjID());
for(fEntity packet : asList){
if(packet.getName()!=null&&!packet.getName().equalsIgnoreCase("")){
if(packet.getInventory().getItemInMainHand()!=null){
if(!packet.getInventory().getItemInMainHand().getType().equals(Material.AIR)){
getWorld().dropItem(getLocation(), packet.getInventory().getItemInMainHand());
}
}
}
j++;
}
this.destroy(player);
}
}
@Override
public void onClick(Player player){
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
this.p = player;
ItemStack itemstack = p.getInventory().getItemInMainHand();
if(itemstack!=null&&matList.contains(itemstack.getType())){
for(fEntity packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getInventory().getHelmet()!=null){
if(packet.getInventory().getHelmet().getType().name().toLowerCase().endsWith("gate")){
ItemStack itemStack = new ItemStack(itemstack.getType(), 1);
packet.getInventory().setHelmet(itemStack);
}
}
}
getManager().updateFurniture(getObjID());
this.p = null;
return;
}
ItemStack is1 = new ItemStack(Material.BLACK_STAINED_GLASS_PANE, 1);
ItemStack is3 = new ItemStack(Material.RED_STAINED_GLASS_PANE, 1);
ItemMeta im1 = is1.getItemMeta();
ItemMeta im3 = is3.getItemMeta();
im1.setDisplayName("§c");
im3.setDisplayName("§c");
is1.setItemMeta(im1);
is3.setItemMeta(im3);
inv = Bukkit.createInventory(null, 45, "§cWeaponBox");
List<fEntity> asList = getManager().getfArmorStandByObjectID(getObjID());
int j = 1;
for(int i = 0; i<inv.getSize();i++){
inv.setItem(i, is1);
if(slotList1.contains(i)){
inv.setItem(i, is3);
}else if(slotList2.contains(i)){
for(fEntity packet : asList){
if(packet.getName()!=null&&!packet.getName().equalsIgnoreCase("")){
if(packet.getName().equalsIgnoreCase("#SLOT"+j+"#")){
ItemStack is = new ItemStack(Material.AIR);
if(packet.getInventory().getItemInMainHand()!=null){is = packet.getInventory().getItemInMainHand();}
inv.setItem(i, is);
}
}
}
j++;
}
}
this.p.openInventory(inv);
this.p.updateInventory();
}
this.p.openInventory(inv);
this.p.updateInventory();
}
@EventHandler

View File

@ -6,21 +6,18 @@ import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
public class TrashCan extends Furniture implements Listener {
public class TrashCan extends Furniture{
public TrashCan(ObjectID id){
super(id);
@ -30,44 +27,45 @@ public class TrashCan extends Furniture implements Listener {
}
spawn(id.getStartLocation());
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent 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;}
e.remove();
delete();
@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);
}
}
@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;}
ItemStack is = e.getPlayer().getInventory().getItemInMainHand();
fEntity stand = null;
for(fEntity s : getfAsList()){
if(s.getName().equalsIgnoreCase("#TRASH#")){
stand = s;break;
@Override
public void onClick(Player player){
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
ItemStack is = player.getInventory().getItemInMainHand();
fEntity stand = null;
for(fEntity s : getfAsList()){
if(s.getName().equalsIgnoreCase("#TRASH#")){
stand = s;break;
}
}
}
if(stand==null){return;}
if(is==null||is.getType()==null||is.getType().equals(Material.AIR)){
if(stand.getItemInMainHand()!=null&&!stand.getItemInMainHand().getType().equals(Material.AIR)){
getWorld().dropItem(getCenter(), stand.getItemInMainHand());
stand.setItemInMainHand(new ItemStack(Material.AIR));
update();
return;
if(stand==null){return;}
if(is==null||is.getType()==null||is.getType().equals(Material.AIR)){
if(stand.getItemInMainHand()!=null&&!stand.getItemInMainHand().getType().equals(Material.AIR)){
getWorld().dropItem(getCenter(), stand.getItemInMainHand());
stand.setItemInMainHand(new ItemStack(Material.AIR));
update();
return;
}
}
stand.setItemInMainHand(is);
player.getInventory().clear(player.getInventory().getHeldItemSlot());
player.updateInventory();
update();
return;
}
stand.setItemInMainHand(is);
e.getPlayer().getInventory().clear(e.getPlayer().getInventory().getHeldItemSlot());
e.getPlayer().updateInventory();
update();
return;
}
@Override

View File

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

View File

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

View File

@ -11,14 +11,11 @@ import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
@ -35,71 +32,71 @@ public class FireworkLauncher extends Furniture implements Listener {
}
spawn(id.getStartLocation());
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent e) {
if(e.getID() == null || getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!canBuild(e.getPlayer())){return;}
for(fEntity packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().equalsIgnoreCase("#FIREWORK#")){
if(packet.getInventory().getItemInMainHand()!=null&&!packet.getInventory().getItemInMainHand().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getItemInMainHand();
getWorld().dropItem(getLocation(), is);
@Override
public void onBreak(Player player) {
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
for(fEntity packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().equalsIgnoreCase("#FIREWORK#")){
if(packet.getInventory().getItemInMainHand()!=null&&!packet.getInventory().getItemInMainHand().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getItemInMainHand();
getWorld().dropItem(getLocation(), is);
}
}
}
this.destroy(player);
}
e.remove(true,true);
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(!canBuild(e.getPlayer())){return;}
Player p = e.getPlayer();
fEntity stand = null;
for(fEntity st : getfAsList()){
if(st.getName().equalsIgnoreCase("#FIREWORK#")){
stand = st;
break;
}
}
if(stand == null) return;
if(p.getInventory().getItemInMainHand()!=null){
if(p.getInventory().getItemInMainHand().getType()!=null){
if(p.getInventory().getItemInMainHand().getType().equals(Material.FIREWORK_ROCKET)){
drop(stand);
setItem(stand, p.getInventory().getItemInMainHand());
Bukkit.getScheduler().runTaskLater(getPlugin(), new Runnable() {
@Override
public void run() {
update();
}
}, 5);
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);
p.getInventory().setItem(i, is);
p.updateInventory();
return;
@Override
public void onClick(Player player){
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
fEntity stand = null;
for(fEntity st : getfAsList()){
if(st.getName().equalsIgnoreCase("#FIREWORK#")){
stand = st;
break;
}
}
}
if(canLaunch(stand)){
Firework fw = (Firework) getWorld().spawnEntity(getCenter(), EntityType.FIREWORK);
FireworkMeta meta = (FireworkMeta) stand.getItemInMainHand().getItemMeta();
fw.setFireworkMeta(meta);
setItem(stand, new ItemStack(Material.AIR));
if(stand == null) return;
if(player.getInventory().getItemInMainHand()!=null){
if(player.getInventory().getItemInMainHand().getType()!=null){
if(player.getInventory().getItemInMainHand().getType().equals(Material.FIREWORK_ROCKET)){
drop(stand);
setItem(stand, player.getInventory().getItemInMainHand());
Bukkit.getScheduler().runTaskLater(getPlugin(), new Runnable() {
@Override
public void run() {
update();
}
}, 5);
if(player.getGameMode().equals(GameMode.CREATIVE) && getLib().useGamemode()) return;
Integer i = player.getInventory().getHeldItemSlot();
ItemStack is = player.getInventory().getItemInMainHand();
is.setAmount(is.getAmount()-1);
player.getInventory().setItem(i, is);
player.updateInventory();
return;
}
}
}
if(canLaunch(stand)){
Firework fw = (Firework) getWorld().spawnEntity(getCenter(), EntityType.FIREWORK);
FireworkMeta meta = (FireworkMeta) stand.getItemInMainHand().getItemMeta();
fw.setFireworkMeta(meta);
setItem(stand, new ItemStack(Material.AIR));
}
}
}

View File

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

View File

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

View File

@ -8,6 +8,7 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockRedstoneEvent;
@ -16,10 +17,6 @@ import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBlockBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBlockClickEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
@ -125,23 +122,23 @@ public class streetlamp extends Furniture implements Listener{
getObjID().addBlock(blockLocation);
}
@EventHandler
private void onBlockBreak(FurnitureBlockBreakEvent 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();
@Override
public void onBreak(Player player) {
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
FurnitureLib.getInstance().getLightManager().removeLight(light);
this.destroy(player);
}
}
@EventHandler
private void onBlockClick(FurnitureBlockClickEvent 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;}
@Override
public void onClick(Player player){
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(!canBuild(player)) {return;}
if(isOn()){
setLight(false);
}else{
@ -216,32 +213,4 @@ public class streetlamp extends Furniture implements Listener{
}
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.Tag;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPhysicsEvent;
@ -16,9 +17,6 @@ import org.bukkit.inventory.ItemStack;
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.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
@ -68,26 +66,20 @@ public class TFlowerPot extends Furniture implements Listener {
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
@Override
public void onFurnitureBreak(FurnitureBreakEvent paramFurnitureBreakEvent) {}
@Override
public void onFurnitureClick(FurnitureClickEvent paramFurnitureClickEvent) {}
@EventHandler
private void BlockBreak(FurnitureBlockBreakEvent e){
if(e.getID() == null || getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if (pot==null) return;
if (e.getBlock() == null) return;
if (e.getBlock().getLocation() == null) return;
if(!e.getBlock().equals(pot)){return;}
if(!canBuild(e.getPlayer())){return;}
destroy(e.getPlayer());
pot.setType(Material.AIR);
pot=null;
return;
@Override
public void onClick(Player p) {}
@Override
public void onBreak(Player player) {
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
pot.setType(Material.AIR);
pot=null;
this.destroy(player);
}
}
@EventHandler

View File

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

View File

@ -3,21 +3,19 @@ package de.Ste3et_C0st.Furniture.Objects.garden;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.entity.Player;
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.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
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(
Material.SPRUCE_FENCE,
Material.BIRCH_FENCE,
@ -29,25 +27,38 @@ public class fance extends FurnitureHelper implements Listener{
public fance(ObjectID id){
super(id);
Bukkit.getPluginManager().registerEvents(this, main.instance);
}
@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]);
ItemStack stack = e.getPlayer().getInventory().getItemInMainHand();
if(stack==null) return;
if(stack.getType().equals(Material.AIR)) return;
if(matList.contains(stack.getType())){
b.setType(stack.getType());
consumeItem(e.getPlayer());
return;
}else if(main.materialWhiteList.contains(stack.getType())){
setTypes(stack);
consumeItem(e.getPlayer());
update();
return;
@Override
public void onClick(Player player){
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]);
ItemStack stack = player.getInventory().getItemInMainHand();
if(stack==null) return;
if(stack.getType().equals(Material.AIR)) return;
if(matList.contains(stack.getType())){
b.setType(stack.getType());
consumeItem(player);
return;
}else if(main.materialWhiteList.contains(stack.getType())){
setTypes(stack);
consumeItem(player);
update();
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

@ -11,17 +11,15 @@ import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
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.main.FurnitureHelper;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
public class graveStone extends FurnitureHelper implements Listener{
@ -61,28 +59,30 @@ public class graveStone extends FurnitureHelper implements Listener{
getObjID().addBlock(Arrays.asList(this.sign));
}
@EventHandler
private void onBlockBreak(ProjectBreakEvent e){
if(e.getID() == null || getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
if(sign!=null){
sign.setType(Material.AIR);
@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);
if(sign!=null){
sign.setType(Material.AIR);
}
}
}
@EventHandler
private void onBlockClick(ProjectClickEvent e){
if(e.getID() == null || getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
Player p = e.getPlayer();
if(!e.getID().equals(getObjID())) return;
if(!e.canBuild()){return;}
ItemStack is = p.getInventory().getItemInMainHand();
if (is == null) return;
if (!is.getType().equals(Material.WRITTEN_BOOK)) return;
readFromBook(is);
@Override
public void onClick(Player player){
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
ItemStack is = player.getInventory().getItemInMainHand();
if (is == null) return;
if (!is.getType().equals(Material.WRITTEN_BOOK)) return;
readFromBook(is);
}
}
public void resetSign(){

View File

@ -18,8 +18,6 @@ import org.bukkit.inventory.meta.ItemMeta;
import de.Ste3et_C0st.Furniture.Main.main;
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.ManageInv;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper;
@ -49,11 +47,14 @@ public class log extends FurnitureHelper implements Listener{
setList();
}
@EventHandler
private void onBlockBreak(ProjectBreakEvent e){
if(e.getID() == null || getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){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 Project getProjectByItem(ItemStack is){
@ -83,51 +84,53 @@ public class log extends FurnitureHelper implements Listener{
return copy;
}
@EventHandler
private void onBlockBreak(ProjectClickEvent e){
if(e.getID() == null || getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
if(e.getPlayer().isSneaking()){
if(e.getPlayer().getInventory().getItemInMainHand().getType().isBlock()&&
!e.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.AIR)){
return;
}
openInventory(e.getPlayer());
}else{
ItemStack stack = e.getPlayer().getInventory().getItemInMainHand();
if(stack == null || stack.getType().equals(Material.AIR)){
//dropItem
fEntity entity = entityByCustomName(this.mode + "");
if(entity != null) {
if(entity.getItemInMainHand() != null) {
if(!entity.getItemInMainHand().getType().equals(Material.AIR)) {
if(entity.getItemInMainHand().equals(stack)) {return;}
getWorld().dropItem(getLocation(), entity.getItemInMainHand());
entity.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
update();
}
}
}
@Override
public void onClick(Player player){
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
if(player.isSneaking()){
if(player.getInventory().getItemInMainHand().getType().isBlock()&&
!player.getInventory().getItemInMainHand().getType().equals(Material.AIR)){
return;
}
openInventory(player);
}else{
if(getProjectByItem(stack) != null) {return;}
if(stack.getType().isBlock()) {
Block b = getCenter().getBlock();
b.setType(stack.getType());
}else{
ItemStack stack = player.getInventory().getItemInMainHand();
if(stack == null || stack.getType().equals(Material.AIR)){
//dropItem
fEntity entity = entityByCustomName(this.mode + "");
if(entity != null) {
if(entity.getItemInMainHand() != null) {
if(!entity.getItemInMainHand().getType().equals(Material.AIR)) {
if(entity.getItemInMainHand().equals(stack)) {return;}
getWorld().dropItem(getLocation(), entity.getItemInMainHand());
entity.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
update();
}
}
}
ItemStack placeItem = stack.clone();
placeItem.setAmount(1);
entity.getInventory().setItemInMainHand(placeItem);
consumeItem(e.getPlayer());
update();
}else{
if(getProjectByItem(stack) != null) {return;}
if(stack.getType().isBlock()) {
Block b = getCenter().getBlock();
b.setType(stack.getType());
}else{
fEntity entity = entityByCustomName(this.mode + "");
if(entity != null) {
if(entity.getItemInMainHand() != null) {
if(!entity.getItemInMainHand().getType().equals(Material.AIR)) {
if(entity.getItemInMainHand().equals(stack)) {return;}
getWorld().dropItem(getLocation(), entity.getItemInMainHand());
}
}
ItemStack placeItem = stack.clone();
placeItem.setAmount(1);
entity.getInventory().setItemInMainHand(placeItem);
consumeItem(player);
update();
}
}
}
}

View File

@ -3,17 +3,15 @@ package de.Ste3et_C0st.Furniture.Objects.garden;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
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.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
@ -39,42 +37,43 @@ public class sunshade extends FurnitureHelper implements Listener{
}return true;
}
@EventHandler
public void onClick(ProjectClickEvent e){
if(e.getID() == null || getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
Player p = e.getPlayer();
ItemStack is = p.getInventory().getItemInMainHand();
if(is.getType().name().contains("BANNER")){
for(fEntity packet : getfAsList()){
if(packet.getInventory().getHelmet()!=null&&packet.getInventory().getHelmet().getType().name().contains("BANNER")){
packet.getInventory().setHelmet(is.clone());
}else if(packet.getInventory().getHelmet()!=null&&packet.getInventory().getHelmet().getType().name().contains("CARPET")){
ItemStack item = new ItemStack(Material.WHITE_CARPET);
item.setDurability(getLutil().getFromDey((short) is.getDurability()));
packet.getInventory().setHelmet(item);
@Override
public void onClick(Player player){
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
ItemStack is = player.getInventory().getItemInMainHand();
if(is.getType().name().contains("BANNER")){
for(fEntity packet : getfAsList()){
if(packet.getInventory().getHelmet()!=null&&packet.getInventory().getHelmet().getType().name().contains("BANNER")){
packet.getInventory().setHelmet(is.clone());
}else if(packet.getInventory().getHelmet()!=null&&packet.getInventory().getHelmet().getType().name().contains("CARPET")){
ItemStack item = new ItemStack(Material.WHITE_CARPET);
item.setDurability(getLutil().getFromDey((short) is.getDurability()));
packet.getInventory().setHelmet(item);
}
}
update();
consumeItem(player);
}else{
if(!isOpen()){
open();
}else{
close();
}
}
update();
consumeItem(p);
}else{
if(!isOpen()){
open();
}else{
close();
}
}
}
@EventHandler
public void onBreak(ProjectBreakEvent e){
if(e.getID() == null || getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
if(isRunning){
stopTimer();
@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);
if(isRunning) stopTimer();
}
}

View File

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

View File

@ -1,52 +1,48 @@
package de.Ste3et_C0st.Furniture.Objects.light;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.entity.Player;
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.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
public class WaxCandle extends FurnitureHelper implements Listener{
public class WaxCandle extends FurnitureHelper{
public WaxCandle(ObjectID id){
super(id);
Bukkit.getPluginManager().registerEvents(this, main.instance);
}
@EventHandler
public void onWaterFlow(BlockFromToEvent e){
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
Location locTo = e.getToBlock().getLocation();
if(getLocation()!=null && getLocation().getChunk().isLoaded()){
if(locTo.equals(getLocation().getBlock().getLocation())) {
e.setCancelled(true);
@Override
public void onClick(Player player){
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]);
ItemStack stack = player.getInventory().getItemInMainHand();
if(stack==null) return;
if(stack.getType().equals(Material.AIR)) return;
if(b!=null){
if(b.getType().equals(Material.TORCH) && stack.getType().equals(Material.WATER_BUCKET)){
b.setType(Material.REDSTONE_TORCH);
}else if(b.getType().equals(Material.REDSTONE_TORCH) && stack.getType().equals(Material.FLINT_AND_STEEL)){
b.setType(Material.TORCH);
}
}
}
}
@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]);
ItemStack stack = e.getPlayer().getInventory().getItemInMainHand();
if(stack==null) return;
if(stack.getType().equals(Material.AIR)) return;
if(b!=null){
if(b.getType().equals(Material.TORCH) && stack.getType().equals(Material.WATER_BUCKET)){
b.setType(Material.REDSTONE_TORCH);
}else if(b.getType().equals(Material.REDSTONE_TORCH) && stack.getType().equals(Material.FLINT_AND_STEEL)){
b.setType(Material.TORCH);
}
@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;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
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.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
public class barrels extends FurnitureHelper implements Listener {
public class barrels extends FurnitureHelper{
Integer id;
Block block;
public barrels(ObjectID id){
super(id);
Bukkit.getPluginManager().registerEvents(this, main.instance);
}
@EventHandler
public void onFurnitureClick(ProjectClickEvent e){
if(e.getID() == null || getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
Player p = e.getPlayer();
if(!p.getInventory().getItemInMainHand().getType().isBlock()&&!p.getInventory().getItemInMainHand().getType().equals(Material.AIR)){return;}
fEntity packet = getManager().getfArmorStandByObjectID(getObjID()).get(0);
if(packet.getInventory().getHelmet()!=null&&!packet.getInventory().getHelmet().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getHelmet();
is.setAmount(1);
getWorld().dropItem(getLocation(), is);
@Override
public void onClick(Player player){
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
if(!player.getInventory().getItemInMainHand().getType().isBlock()&&!player.getInventory().getItemInMainHand().getType().equals(Material.AIR)){return;}
fEntity packet = getManager().getfArmorStandByObjectID(getObjID()).get(0);
if(packet.getInventory().getHelmet()!=null&&!packet.getInventory().getHelmet().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getHelmet();
is.setAmount(1);
getWorld().dropItem(getLocation(), is);
}
packet.getInventory().setHelmet(player.getInventory().getItemInMainHand());
update();
consumeItem(player);
}
packet.getInventory().setHelmet(p.getInventory().getItemInMainHand());
update();
consumeItem(e.getPlayer());
}
@EventHandler
private void onBlockBreak(ProjectBreakEvent e){
if(e.getID() == null || getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
fEntity packet = getManager().getfArmorStandByObjectID(getObjID()).get(0);
if(packet.getInventory().getHelmet()!=null&&!packet.getInventory().getHelmet().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getHelmet();
is.setAmount(1);
getWorld().dropItem(getLocation(), is);
@Override
public void onBreak(Player player) {
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
fEntity packet = getManager().getfArmorStandByObjectID(getObjID()).get(0);
if(packet.getInventory().getHelmet()!=null&&!packet.getInventory().getHelmet().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getHelmet();
is.setAmount(1);
getWorld().dropItem(getLocation(), is);
}
this.destroy(player);
}
}
}

View File

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

View File

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

View File

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

View File

@ -1,36 +1,39 @@
package de.Ste3et_C0st.Furniture.Objects.outdoor;
import org.bukkit.Bukkit;
import org.bukkit.Material;
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.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.ColorType;
import de.Ste3et_C0st.FurnitureLib.main.Type.DyeColor;
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){
super(id);
Bukkit.getPluginManager().registerEvents(this, main.getInstance());
}
@EventHandler
public void onFurnitureClick(ProjectClickEvent 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;}
final Player p = e.getPlayer();
if(DyeColor.getDyeColor(p.getInventory().getItemInMainHand().getType()) == null){
p.openWorkbench(null, true);
}else{
getLib().getColorManager().color(p, e.canBuild(), "_CARPET", getObjID(), ColorType.BLOCK, 1);
@Override
public void onClick(Player player){
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
if(DyeColor.getDyeColor(player.getInventory().getItemInMainHand().getType()) == null){
player.openWorkbench(null, true);
}else{
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.Chest;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
@ -178,35 +175,35 @@ public class tent_2 extends Furniture implements Listener{
}
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent 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;}
for(Block bl : block){
bl.setType(Material.AIR);
@Override
public void onBreak(Player player) {
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
for(Block bl : block){
bl.setType(Material.AIR);
}
this.destroy(player);
}
e.remove();
delete();
}
@EventHandler
public void onFurnitureClick(final FurnitureClickEvent e){
if(e.getID() == null || getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(!e.getID().equals(getObjID())){return;}
Player p = e.getPlayer();
if(!e.canBuild()){return;}
if(DyeColor.getDyeColor(p.getInventory().getItemInMainHand().getType()) == null){
for(Block b : block){
if(b.getType().equals(Material.CHEST)){
Chest c = (Chest) b.getState();
e.getPlayer().openInventory(c.getBlockInventory());
@Override
public void onClick(Player player){
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
if(DyeColor.getDyeColor(player.getInventory().getItemInMainHand().getType()) == null){
for(Block b : block){
if(b.getType().equals(Material.CHEST)){
Chest c = (Chest) b.getState();
player.getPlayer().openInventory(c.getBlockInventory());
}
}
}else{
getLib().getColorManager().color(player, true, "_CARPET", getObjID(), ColorType.BLOCK, 1);
}
}else{
getLib().getColorManager().color(p, e.canBuild(), "_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.PatternType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BannerMeta;
import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.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.fEntity;
public class tent_3 extends Furniture implements Listener{
public class tent_3 extends Furniture{
public tent_3(ObjectID id){
super(id);
setBlock();
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, main.getInstance());
return;
}
Location loc = getLocation();
@ -150,32 +144,32 @@ public class tent_3 extends Furniture implements Listener{
bed = getLutil().setHalfBed(getLutil().yawToFace(sit.getYaw()).getOppositeFace(), getLutil().getRelativ(sit.add(0,-2,0).getBlock().getLocation().add(0,2,0), getBlockFace(), 2D, 0D), Material.RED_BED);
getObjID().addBlock(Arrays.asList(bed));
}
@EventHandler
public void onFurnitureBreak(FurnitureBreakEvent 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;}
bed.setType(Material.AIR);
e.remove();
delete();
@Override
public void onBreak(Player player) {
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
bed.setType(Material.AIR);
this.destroy(player);
}
}
@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;}
Player p = e.getPlayer();
if(DyeColor.getDyeColor(p.getInventory().getItemInMainHand().getType()) != null){
getLib().getColorManager().color(p, e.canBuild(), "_BANNER", getObjID(), ColorType.BANNER, 1);
}else{
for(fEntity packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().equalsIgnoreCase("#SITZ#")){
packet.setPassanger(p);
packet.update();
@Override
public void onClick(Player player){
if(getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)) return;
if(player == null) return;
if(canBuild(player)) {
if(DyeColor.getDyeColor(player.getInventory().getItemInMainHand().getType()) != null){
getLib().getColorManager().color(player, true, "_BANNER", getObjID(), ColorType.BANNER, 1);
}else{
for(fEntity packet : getManager().getfArmorStandByObjectID(getObjID())){
if(packet.getName().equalsIgnoreCase("#SITZ#")){
packet.setPassanger(player);
packet.update();
}
}
}
}

View File

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