Dicecraft Furniture Plugin

This commit is contained in:
BuildTools 2015-04-08 20:17:57 +02:00
parent e5b345124c
commit 056a0ca914
8 changed files with 307 additions and 374 deletions

View File

@ -1,6 +1,7 @@
package de.Ste3et_C0st.Furniture.Listener;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -31,37 +32,64 @@ public class OnInteract implements Listener {
if(!is.getItemMeta().hasDisplayName()){return;}
if(e.getClickedBlock()==null){return;}
if(!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){return;}
Integer hand = p.getInventory().getHeldItemSlot();
Integer amount = is.getAmount();
Location location = new Location(p.getWorld(), e.getClickedBlock().getLocation().getBlockX(), e.getClickedBlock().getLocation().getBlockY(), e.getClickedBlock().getLocation().getBlockZ());
location.setYaw(p.getLocation().getYaw());
location.setY(location.getY() + 1);
if(ChatColor.stripColor(is.getItemMeta().getDisplayName()).equalsIgnoreCase("sofa")){
if(main.getInstance().canPlace(p, location, Utils.yawToFace(location.getYaw()).getOppositeFace(), 3)){
new sofa(location, 3, main.getInstance());
if(!p.getGameMode().equals(GameMode.CREATIVE)){
is.setAmount(amount);
p.getInventory().setItem(hand, is);
p.updateInventory();
}
return;
}
}
if(ChatColor.stripColor(is.getItemMeta().getDisplayName()).equalsIgnoreCase("laterne")){
if(main.getInstance().canPlace(p, location, null, null)){
new laterne(location, main.getInstance());
new laterne(location, main.getInstance(), true);
if(!p.getGameMode().equals(GameMode.CREATIVE)){
is.setAmount(amount);
p.getInventory().setItem(hand, is);
p.updateInventory();
}
return;
}
}
if(ChatColor.stripColor(is.getItemMeta().getDisplayName()).equalsIgnoreCase("stuhl")){
if(main.getInstance().canPlace(p, location, null, null)){
new stuhl(location, main.getInstance());
if(!p.getGameMode().equals(GameMode.CREATIVE)){
is.setAmount(amount);
p.getInventory().setItem(hand, is);
p.updateInventory();
}
return;
}
}
if(ChatColor.stripColor(is.getItemMeta().getDisplayName()).equalsIgnoreCase("tisch")){
if(main.getInstance().canPlace(p, location, null, null)){
new tisch(location, main.getInstance());
new tisch(location, main.getInstance(), null);
if(!p.getGameMode().equals(GameMode.CREATIVE)){
is.setAmount(amount);
p.getInventory().setItem(hand, is);
p.updateInventory();
}
return;
}
}
if(ChatColor.stripColor(is.getItemMeta().getDisplayName()).equalsIgnoreCase("tisch2")){
if(main.getInstance().canPlace(p, location, null, null)){
new largeTable(location, main.getInstance());
new largeTable(location, main.getInstance(), null, null);
if(!p.getGameMode().equals(GameMode.CREATIVE)){
is.setAmount(amount);
p.getInventory().setItem(hand, is);
p.updateInventory();
}
return;
}
}

View File

@ -1,7 +1,14 @@
package de.Ste3et_C0st.Furniture.Main;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
public class Utils {
@ -39,4 +46,33 @@ public class Utils {
if(d<0){d+=.5;}else{d+=.5;}
return d;
}
public static ArmorStand setArmorStand(Location location, EulerAngle angle, ItemStack is, Boolean Arm, List<Entity> entityList, List<Location> locationList){
World w = location.getWorld();
for(Entity entity : w.getEntities()){
if(entity instanceof ArmorStand){
if(location.equals(entity.getLocation())){
entityList.add(entity);
if(locationList!=null){locationList.add(location);}
return (ArmorStand) entity;
}
}
}
ArmorStand as = (ArmorStand) location.getWorld().spawnEntity(location, EntityType.ARMOR_STAND);
if(Arm){
if(angle!=null){as.setRightArmPose(angle);}
if(is!=null){as.setItemInHand(is);}
}else{
if(angle!=null){as.setHeadPose(angle);}
if(is!=null){as.setHelmet(is);}
}
as.setVisible(false);
as.setGravity(false);
as.setBasePlate(false);
entityList.add(as);
if(locationList!=null){locationList.add(location);}
return as;
}
}

View File

@ -64,6 +64,10 @@ public class main extends JavaPlugin {
grinderRecipe = new ShapedRecipe(itemse.tisch).shape("0#0", "0E0", "0+0").setIngredient('#', Material.TRAP_DOOR).
setIngredient('E', Material.STICK).setIngredient('+', Material.WOOD_STEP);
getServer().addRecipe(grinderRecipe);
grinderRecipe = new ShapedRecipe(itemse.tisch2).shape("###", "###", "E0E").setIngredient('#', Material.STAINED_GLASS_PANE).
setIngredient('E', Material.BONE);
getServer().addRecipe(grinderRecipe);
}
public static String getCardinalDirection(Player player) {

View File

@ -1,6 +1,7 @@
package de.Ste3et_C0st.Furniture.Objects;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Effect;
@ -10,7 +11,6 @@ import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -28,71 +28,82 @@ public class largeTable implements Listener {
List<Entity> armorList = new ArrayList<Entity>();
List<Location> location = new ArrayList<Location>();
public largeTable(Location loc, Plugin plugin){
BlockFace b = Utils.yawToFace(loc.getYaw());
Location location = Utils.getCenter(loc.getBlock().getLocation());
float yaw = Utils.FaceToYaw(b);
location = main.getNew(location, b, 0.1, 0.28);
location.add(0,.2,0);
Double winkel = 1.57;
for(int x=1; x<=3;x++){
Location l = null;
l = main.getNew(location, b, 0.0, x*-.63);
l.add(0,-1.2,0);
l.setYaw(yaw);
ArmorStand as = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
as.setHelmet(new ItemStack(Material.STAINED_GLASS_PANE));
as.setHeadPose(new EulerAngle(winkel, 0, 0));
this.location.add(l.add(0,.5,0).getBlock().getLocation());
armorList.add(as);
l = main.getNew(location, b, 0.63, x*-.63);
l.add(0,-1.2,0);
l.setYaw(yaw);
as = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
as.setHelmet(new ItemStack(Material.STAINED_GLASS_PANE));
as.setHeadPose(new EulerAngle(winkel, 0, 0));
this.location.add(l.add(0,.5,0).getBlock().getLocation());
armorList.add(as);
l = main.getNew(location, b, 1.26, x*-.63);
l.add(0,-1.2,0);
l.setYaw(yaw);
as = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
as.setHelmet(new ItemStack(Material.STAINED_GLASS_PANE));
as.setHeadPose(new EulerAngle(winkel, 0, 0));
this.location.add(l.add(0,.5,0).getBlock().getLocation());
armorList.add(as);
Location loc = null;
BlockFace b = null;
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
public largeTable(Location loc, Plugin plugin, List<ItemStack> iL, HashMap<Integer, ItemStack> tellerItems){
this.loc = loc;
this.b = Utils.yawToFace(loc.getYaw());
ItemStack IS1 =null;
ItemStack IS2 =null;
ItemStack IS3 =null;
ItemStack IS4 =null;
if(tellerItems != null){
if(tellerItems.containsKey(0)){IS1=tellerItems.get(0);}
if(tellerItems.containsKey(1)){IS2=tellerItems.get(1);}
if(tellerItems.containsKey(2)){IS3=tellerItems.get(2);}
if(tellerItems.containsKey(3)){IS4=tellerItems.get(3);}
}
/*Teller {
###
###
###
Location location = Utils.getCenter(loc.getBlock().getLocation());
float yaw = Utils.FaceToYaw(this.b);
location = main.getNew(location, this.b, 0.1, 0.28);
location.add(0,.2,0);
Double winkel = 1.57;
int iTems = 0;
for(int x=1; x<=3;x++){
Location l = null;
l = main.getNew(location, this.b, 0.0, x*-.63);
l.add(0,-1.2,0);
l.setYaw(yaw);
ItemStack iTemStack_1 = new ItemStack(Material.STAINED_GLASS_PANE);
ItemStack iTemStack_2 = new ItemStack(Material.STAINED_GLASS_PANE);
ItemStack iTemStack_3 = new ItemStack(Material.STAINED_GLASS_PANE);
if(iL!=null&&!iL.isEmpty()){
if(iL.get(iTems)!=null){
iTemStack_1=iL.get(iTems);
iTems++;
}
if(iL.get(iTems)!=null){
iTemStack_2=iL.get(iTems);
iTems++;
}
if(iL.get(iTems)!=null){
iTemStack_3=iL.get(iTems);
iTems++;
}
}
3;7;5;1
}*/
Utils.setArmorStand(l, new EulerAngle(winkel, 0, 0), iTemStack_1, false, armorList,this.location);
l = main.getNew(location, this.b, 0.63, x*-.63);
l.add(0,-1.2,0);
l.setYaw(yaw);
Utils.setArmorStand(l, new EulerAngle(winkel, 0, 0), iTemStack_2, false, armorList,this.location);
l = main.getNew(location, this.b, 1.26, x*-.63);
l.add(0,-1.2,0);
l.setYaw(yaw);
Utils.setArmorStand(l, new EulerAngle(winkel, 0, 0), iTemStack_3, false, armorList,this.location);
}
Location middle = Utils.getCenter(armorList.get(0).getLocation());
Location mitteTisch = Utils.getCenter(armorList.get(4).getLocation().getBlock().getLocation());
middle.add(0, -.9, 0);
Location feet1 = main.getNew(middle, b, -.2, .1);
Location feet2 = main.getNew(middle, b, -.2, -1.3);
Location feet3 = main.getNew(middle, b, 1.1, .1);
Location feet4 = main.getNew(middle, b, 1.1, -1.3);
Location feet1 = main.getNew(middle, this.b, -.2, .1);
Location feet2 = main.getNew(middle, this.b, -.2, -1.3);
Location feet3 = main.getNew(middle, this.b, 1.1, .1);
Location feet4 = main.getNew(middle, this.b, 1.1, -1.3);
double hight = .68;
Location t1 = new Location(middle.getWorld(), this.location.get(3).getX(), this.location.get(3).getY()+hight, this.location.get(3).getZ());
Location t2 = new Location(middle.getWorld(), this.location.get(7).getX(), this.location.get(7).getY()+hight, this.location.get(7).getZ());
Location t3 = new Location(middle.getWorld(), this.location.get(5).getX(), this.location.get(5).getY()+hight, this.location.get(5).getZ());
Location t4 = new Location(middle.getWorld(), this.location.get(1).getX(), this.location.get(1).getY()+hight, this.location.get(1).getZ());
double hight = .67;
t1 =main.getNew(t1, b, -.05D, .37D);
t2 =main.getNew(t2, b, -.13D, -.32D);
t3 =main.getNew(t3, b, .55D, -.38D);
t4 =main.getNew(t4, b, .62D, .30D);
Location t1 = main.getNew(mitteTisch, this.b, -.95, .4).add(0,hight,0);
Location t2 = main.getNew(mitteTisch, this.b, -.4, -.92).add(0,hight,0);
Location t3 = main.getNew(mitteTisch, this.b, .92, -.36).add(0,hight,0);
Location t4 = main.getNew(mitteTisch, this.b, .4, .92).add(0,hight,0);
float yaw1 = yaw;
float yaw2 = yaw1-90;
@ -108,43 +119,15 @@ public class largeTable implements Listener {
feet2.setYaw(yaw);
feet3.setYaw(yaw);
feet4.setYaw(yaw);
ArmorStand as = (ArmorStand) feet1.getWorld().spawnEntity(feet1, EntityType.ARMOR_STAND);
as.setRightArmPose(new EulerAngle(-1.75, 0, 0));
as.setItemInHand(new ItemStack(Material.BONE));
this.armorList.add(as);
as = (ArmorStand) feet2.getWorld().spawnEntity(feet2, EntityType.ARMOR_STAND);
as.setRightArmPose(new EulerAngle(-1.75, 0, 0));
as.setItemInHand(new ItemStack(Material.BONE));
this.armorList.add(as);
as = (ArmorStand) feet3.getWorld().spawnEntity(feet3, EntityType.ARMOR_STAND);
as.setRightArmPose(new EulerAngle(-1.75, 0, 0));
as.setItemInHand(new ItemStack(Material.BONE));
this.armorList.add(as);
as = (ArmorStand) feet4.getWorld().spawnEntity(feet4, EntityType.ARMOR_STAND);
as.setRightArmPose(new EulerAngle(-1.75, 0, 0));
as.setItemInHand(new ItemStack(Material.BONE));
this.armorList.add(as);
as = (ArmorStand) t1.getWorld().spawnEntity(t1, EntityType.ARMOR_STAND);
as.setRightArmPose(new EulerAngle(0,.0,.0));
this.armorList.add(as);
as = (ArmorStand) t2.getWorld().spawnEntity(t2, EntityType.ARMOR_STAND);
as.setRightArmPose(new EulerAngle(0,.0,.0));
this.armorList.add(as);
as = (ArmorStand) t3.getWorld().spawnEntity(t3, EntityType.ARMOR_STAND);
as.setRightArmPose(new EulerAngle(0,.0,.0));
this.armorList.add(as);
as = (ArmorStand) t4.getWorld().spawnEntity(t4, EntityType.ARMOR_STAND);
as.setRightArmPose(new EulerAngle(0,.0,.0));
this.armorList.add(as);
Utils.setArmorStand(feet1, new EulerAngle(-1.75, 0, 0), new ItemStack(Material.BONE), true, armorList,null);
Utils.setArmorStand(feet2, new EulerAngle(-1.75, 0, 0), new ItemStack(Material.BONE), true, armorList,null);
Utils.setArmorStand(feet3, new EulerAngle(-1.75, 0, 0), new ItemStack(Material.BONE), true, armorList,null);
Utils.setArmorStand(feet4, new EulerAngle(-1.75, 0, 0), new ItemStack(Material.BONE), true, armorList,null);
Utils.setArmorStand(t1, new EulerAngle(0,0,0), IS1, true, armorList,null);
Utils.setArmorStand(t2, new EulerAngle(0,0,0), IS2, true, armorList,null);
Utils.setArmorStand(t3, new EulerAngle(0,0,0), IS3, true, armorList,null);
Utils.setArmorStand(t4, new EulerAngle(0,0,0), IS4, true, armorList,null);
for(Entity e : armorList){
ArmorStand armor = (ArmorStand) e;
@ -156,12 +139,14 @@ public class largeTable implements Listener {
main.getInstance().tische2.add(this);
}
public void delete(){
armorList.get(0).getLocation().getWorld().dropItem(armorList.get(0).getLocation().getBlock().getLocation().add(0, 1, 0), main.getInstance().itemse.tisch2);
for(Entity entity : armorList){
ArmorStand as = (ArmorStand) entity;
entity.getWorld().playEffect(entity.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
entity.remove();
public void delete(boolean b){
if(b){
armorList.get(0).getLocation().getWorld().dropItem(armorList.get(0).getLocation().getBlock().getLocation().add(0, 1, 0), main.getInstance().itemse.tisch2);
for(Entity entity : armorList){
ArmorStand as = (ArmorStand) entity;
entity.getWorld().playEffect(entity.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
entity.remove();
}
}
location.clear();
armorList.clear();
@ -205,7 +190,7 @@ public class largeTable implements Listener {
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), is);
player.updateInventory();
}
}else{
}else if(!is.getType().isBlock()){
Integer i = armorList.size();
if(armorList.get(3).equals(e.getRightClicked())){
i-=4;
@ -242,7 +227,7 @@ public class largeTable implements Listener {
if(e.getDamager() instanceof Player){
if(e.getEntity() instanceof ArmorStand){
if(armorList.contains(e.getEntity())){
delete();
delete(true);
}
}
}
@ -258,6 +243,26 @@ public class largeTable implements Listener {
}
}
public List<ItemStack> getItemListTisch(){
List<ItemStack> items = new ArrayList<ItemStack>();
for(int i = 0; i<=8;i++){
items.add((((ArmorStand)armorList.get(i)).getHelmet()));
}
return items;
}
public HashMap<Integer, ItemStack> getTeller(){
HashMap<Integer, ItemStack> teller = new HashMap<Integer, ItemStack>();
for(int i = 0;i<=3;i++){
try{
teller.put(i, ((ArmorStand) armorList.get(armorList.size()-1-i)).getItemInHand());
}catch(NullPointerException e){
teller.put(i, new ItemStack(Material.AIR));
}
}
return teller;
}
/*
@EventHandler
public void onHit(PlayerMoveEvent e){

View File

@ -8,9 +8,9 @@ import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -27,69 +27,40 @@ public class laterne implements Listener {
List<Entity> armorList = new ArrayList<Entity>();
Block b;
Location loc = null;
public laterne(Location loc, Plugin plugin){
Boolean bool = true;
BlockFace bFace = null;
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.bFace;}
public Boolean getBlockState(){return this.bool;}
public laterne(Location loc, Plugin plugin, Boolean bool){
this.loc = loc;
this.bool = bool;
Location center = Utils.getCenter(loc);
b = center.getWorld().getBlockAt(center);
b.setType(Material.TORCH);
if(bool){
b.setType(Material.TORCH);
}else{
b.setType(Material.REDSTONE_TORCH_OFF);
}
Location obsidian = center;
Bukkit.getServer().broadcastMessage(obsidian.getX() + ";" + obsidian.getY() + ";" + obsidian.getZ());
Location location = new Location(center.getWorld(), center.getX(), center.getY() -1.43, center.getZ());
obsidian.add(0D, -2.2, 0D);
ArmorStand as = (ArmorStand) loc.getWorld().spawnEntity(obsidian, EntityType.ARMOR_STAND);
as.setBasePlate(false);
as.setGravity(false);
as.setVisible(false);
as.setHelmet(new ItemStack(Material.OBSIDIAN));
Location left_down = new Location(obsidian.getWorld(), obsidian.getX()+0.22, obsidian.getY() + .62, obsidian.getZ()+0.22);
Location left_upper = new Location(obsidian.getWorld(), obsidian.getX() -0.21, obsidian.getY() + .62, obsidian.getZ() +0.22);
Location right_upper = new Location(obsidian.getWorld(), obsidian.getX()-0.21, obsidian.getY()+.62, obsidian.getZ()-0.21);
Location right_down = new Location(obsidian.getWorld(), obsidian.getX()+0.21, obsidian.getY() + .62, obsidian.getZ() -0.21);
armorList.add(as);
Utils.setArmorStand(obsidian, null, new ItemStack(Material.OBSIDIAN), false, armorList, null);
Utils.setArmorStand(location.add(0,0,0), null, new ItemStack(Material.WOOD_PLATE), false, armorList, null);
Location location = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
as = (ArmorStand) loc.getWorld().spawnEntity(location.add(0,.75,0), EntityType.ARMOR_STAND);
as.setBasePlate(false);
as.setGravity(false);
as.setVisible(false);
as.setHelmet(new ItemStack(Material.WOOD_PLATE));
armorList.add(as);
//Links u
location = new Location(obsidian.getWorld(), obsidian.getX(), obsidian.getY(), obsidian.getZ());
as = (ArmorStand) loc.getWorld().spawnEntity(location.add(0.22,.62,0.22), EntityType.ARMOR_STAND);
as.setBasePlate(false);
as.setGravity(false);
as.setVisible(false);
as.setHelmet(new ItemStack(Material.LEVER));
armorList.add(as);
//Rechts o
location = new Location(obsidian.getWorld(), obsidian.getX(), obsidian.getY(), obsidian.getZ());
as = (ArmorStand) loc.getWorld().spawnEntity(location.add(-0.21,.62,-0.21), EntityType.ARMOR_STAND);
as.setBasePlate(false);
as.setGravity(false);
as.setVisible(false);
as.setHelmet(new ItemStack(Material.LEVER));
armorList.add(as);
//Rechts U
location = new Location(obsidian.getWorld(), obsidian.getX(), obsidian.getY(), obsidian.getZ());
as = (ArmorStand) loc.getWorld().spawnEntity(location.add(0.21,.62,-0.21), EntityType.ARMOR_STAND);
as.setBasePlate(false);
as.setGravity(false);
as.setVisible(false);
as.setHelmet(new ItemStack(Material.LEVER));
armorList.add(as);
//Links O
location = new Location(obsidian.getWorld(), obsidian.getX(), obsidian.getY(), obsidian.getZ());
as = (ArmorStand) loc.getWorld().spawnEntity(location.add(-0.21,.62,0.22), EntityType.ARMOR_STAND);
as.setBasePlate(false);
as.setGravity(false);
as.setVisible(false);
as.setHelmet(new ItemStack(Material.LEVER));
armorList.add(as);
Utils.setArmorStand(left_down, null, new ItemStack(Material.LEVER), false, armorList, null);
Utils.setArmorStand(left_upper, null, new ItemStack(Material.LEVER), false, armorList, null);
Utils.setArmorStand(right_upper, null, new ItemStack(Material.LEVER), false, armorList, null);
Utils.setArmorStand(right_down, null, new ItemStack(Material.LEVER), false, armorList, null);
Bukkit.getServer().getPluginManager().registerEvents(this, plugin);
main.getInstance().laternen.add(this);
}
@ -122,14 +93,18 @@ public class laterne implements Listener {
}
*/
public void delete(){
armorList.get(0).getLocation().getWorld().dropItem(b.getLocation(), main.getInstance().itemse.Laterne);
for(Entity entity : armorList){
ArmorStand as = (ArmorStand) entity;
entity.getWorld().playEffect(entity.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
entity.remove();
public void delete(Boolean b){
if(b){
armorList.get(0).getLocation().getWorld().dropItem(this.b.getLocation(), main.getInstance().itemse.Laterne);
for(Entity entity : armorList){
ArmorStand as = (ArmorStand) entity;
entity.getWorld().playEffect(entity.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
entity.remove();
}
}
if(b!=null&&!b.getType().equals(Material.AIR)){b.setType(Material.AIR);}
if(this.b!=null&&!this.b.getType().equals(Material.AIR)){this.b.setType(Material.AIR);}
this.bool = null;
this.loc = null;
armorList.clear();
main.getInstance().laternen.remove(this);
@ -152,17 +127,13 @@ public class laterne implements Listener {
}
}
}
public Location getLocation(){
return this.loc;
}
@EventHandler
public void damage(EntityDamageByEntityEvent e){
if(e.getDamager() instanceof Player){
if(e.getEntity() instanceof ArmorStand){
if(armorList.contains(e.getEntity())){
delete();
delete(true);
}
}
}

View File

@ -7,11 +7,9 @@ import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -29,20 +27,19 @@ public class sofa implements Listener {
private List<Entity> armorList = new ArrayList<Entity>();
private List<Entity> sitz = new ArrayList<Entity>();
private List<Location> location = new ArrayList<Location>();
private ItemStack is;
private Double place;
private short color = 0;
public sofa(Location loc, Integer lengt, Plugin plugin){
this.place = 0.2;
is = new ItemStack(Material.CARPET);
is.setDurability(color);
BlockFace playerLookingDirection = Utils.yawToFace(loc.getYaw()).getOppositeFace();
create(loc, lengt, playerLookingDirection, loc.getYaw(), plugin);
}
public void create(Location loc, Integer lengt, BlockFace b, Float yaw, Plugin plugin){
BlockFace b = Utils.yawToFace(loc.getYaw()).getOppositeFace();
loc = loc.getBlock().getLocation();
loc.setYaw(yaw);
loc.setYaw(Utils.FaceToYaw(b));
Integer x = (int) loc.getX();
Integer y = (int) loc.getY();
Integer z = (int) loc.getZ();
@ -53,20 +50,17 @@ public class sofa implements Listener {
if(b.equals(BlockFace.WEST)){loc = main.getNew(loc, b, .0, -1.0);}
if(b.equals(BlockFace.SOUTH)){loc = main.getNew(loc, b, -1.0, -1.0);}
if(b.equals(BlockFace.EAST)){loc = main.getNew(loc, b, -1.0, .0);}
World w = loc.getWorld();
Location looking = new Location(loc.getWorld(), loc.getBlockX(), loc.getBlockY() -1.4 , loc.getBlockZ());
Location feet1 = main.getNew(looking, b, place, .2D);
Location feet2 = main.getNew(looking, b, place, lengt.doubleValue()-.2D);
Location feet3 = main.getNew(looking, b, place + .5, .2D);
Location feet4 = main.getNew(looking, b, place + .5, lengt.doubleValue()-.2D);
ArmorStand armor1 = (ArmorStand) w.spawnEntity(feet1, EntityType.ARMOR_STAND);
ArmorStand armor2 = (ArmorStand) w.spawnEntity(feet2, EntityType.ARMOR_STAND);
ArmorStand armor3 = (ArmorStand) w.spawnEntity(feet3, EntityType.ARMOR_STAND);
ArmorStand armor4 = (ArmorStand) w.spawnEntity(feet4, EntityType.ARMOR_STAND);
armor1.setHelmet(new ItemStack(Material.LEVER));
armor2.setHelmet(new ItemStack(Material.LEVER));
armor3.setHelmet(new ItemStack(Material.LEVER));
armor4.setHelmet(new ItemStack(Material.LEVER));
Utils.setArmorStand(feet1, null, new ItemStack(Material.LEVER), false, armorList, null);
Utils.setArmorStand(feet2, null, new ItemStack(Material.LEVER), false, armorList, null);
Utils.setArmorStand(feet3, null, new ItemStack(Material.LEVER), false, armorList, null);
Utils.setArmorStand(feet4, null, new ItemStack(Material.LEVER), false, armorList, null);
Location carpetHight = new Location(looking.getWorld(), loc.getBlockX(), loc.getBlockY() -1 , loc.getBlockZ());
carpetHight.setYaw(Utils.FaceToYaw(b));
//sitz
@ -75,29 +69,17 @@ public class sofa implements Listener {
float facing = Utils.FaceToYaw(b);
for(Double i = .0; i<=lengt; i+=0.65){
//SITZ
location.add(main.getNew(carpetHight, b, place,(double) d).getBlock().getLocation().add(0, 1, 0));
Location carpet = main.getNew(carpetHight, b, place,(double) d);
carpet.setYaw(facing);
ArmorStand armorcarpet = (ArmorStand) w.spawnEntity(carpet, EntityType.ARMOR_STAND);
armorcarpet.setHelmet(is);
armorList.add(armorcarpet);
sitz.add(armorcarpet);
ArmorStand as = Utils.setArmorStand(carpet, null, is, false, armorList, null);
sitz.add(as);
//OBERER TEIL
Location location = main.getNew(carpetHight, b, place-.25,(double) d);
location.setYaw(facing);
armorcarpet = (ArmorStand) w.spawnEntity(location, EntityType.ARMOR_STAND);
armorcarpet.setHeadPose(new EulerAngle(1.57, .0, .0));
armorcarpet.setHelmet(is);
armorList.add(armorcarpet);
Utils.setArmorStand(location, new EulerAngle(1.57, .0, .0), is, false, armorList, null);
if(d<=0D){d = 0.00;}
d+=.58;
}
Float yaw1= facing;
Float yaw2= facing;
@ -105,28 +87,11 @@ public class sofa implements Listener {
last.setYaw(yaw1+90);
Location first = main.getNew(new Location(loc.getWorld(), loc.getX(), last.getY(), loc.getZ()), b, place+.25, 0.07D);
first.setYaw(yaw2-90);
ArmorStand leftCarpet = (ArmorStand) w.spawnEntity(first.add(0,-.05,0), EntityType.ARMOR_STAND);
ArmorStand RightCarpet = (ArmorStand) w.spawnEntity(last.add(0,-.05,0), EntityType.ARMOR_STAND);
leftCarpet.setHelmet(is);
RightCarpet.setHelmet(is);
leftCarpet.setHeadPose(new EulerAngle(1.57, 0.0, 0.0));
RightCarpet.setHeadPose(new EulerAngle(1.57, 0.0, 0.0));
armorList.add(leftCarpet);
armorList.add(RightCarpet);
armorList.add(armor1);
armorList.add(armor2);
armorList.add(armor3);
armorList.add(armor4);
for(Entity as : armorList){
ArmorStand a = (ArmorStand) as;
a.setVisible(false);
a.setGravity(false);
a.setBasePlate(false);
}
Utils.setArmorStand(first.add(0,-.05,0), new EulerAngle(1.57, .0, .0), is, false, armorList, null);
Utils.setArmorStand(last.add(0,-.05,0), new EulerAngle(1.57, .0, .0), is, false, armorList, null);
plugin.getServer().getPluginManager().registerEvents(this, plugin);
main.getInstance().sofas.add(this);
}
@EventHandler
@ -150,12 +115,14 @@ public class sofa implements Listener {
}
}*/
public void delete(){
armorList.get(0).getLocation().getWorld().dropItem(armorList.get(0).getLocation().getBlock().getLocation().add(0, 1, 0), main.getInstance().itemse.Sofa);
for(Entity entity : armorList){
ArmorStand as = (ArmorStand) entity;
entity.getWorld().playEffect(entity.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
entity.remove();
public void delete(Boolean b){
if(b){
armorList.get(0).getLocation().getWorld().dropItem(armorList.get(0).getLocation().getBlock().getLocation().add(0, 1, 0), main.getInstance().itemse.Sofa);
for(Entity entity : armorList){
ArmorStand as = (ArmorStand) entity;
entity.getWorld().playEffect(entity.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
entity.remove();
}
}
location.clear();
armorList.clear();
@ -212,7 +179,7 @@ public class sofa implements Listener {
if(e.getDamager() instanceof Player){
if(e.getEntity() instanceof ArmorStand){
if(armorList.contains(e.getEntity())){
delete();
delete(true);
}
}
}

View File

@ -9,7 +9,6 @@ import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -27,87 +26,40 @@ public class stuhl implements Listener {
List<Entity> armorList = new ArrayList<Entity>();
Location loc = null;
BlockFace b = null;
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
public stuhl(Location loc, Plugin plugin){
this.loc = loc.getBlock().getLocation();
BlockFace b = Utils.yawToFace(loc.getYaw()).getOppositeFace();
Location center = Utils.getCenter(loc);
Location sitz = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
Location feet1 = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
Location feet2 = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
Location feet3 = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
Location feet4 = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
Location lehne = main.getNew(center.add(0,-1.1,0), b, -.25, .0);
feet1.add(-.25,-1.8,-.25);
feet2.add(.25,-1.8,-.25);
feet3.add(.25,-1.8,.25);
feet4.add(-.25,-1.8,.25);
sitz.add(0,-1.45,0);
sitz.setYaw(Utils.FaceToYaw(b));
ArmorStand as = (ArmorStand) loc.getWorld().spawnEntity(sitz, EntityType.ARMOR_STAND);
as.setBasePlate(false);
as.setGravity(false);
as.setVisible(false);
as.setHelmet(new ItemStack(Material.TRAP_DOOR));
lehne.setYaw(Utils.FaceToYaw(b));
armorList.add(as);
Location feet1 = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
feet1.add(-.25,-1.8,-.25);
as = (ArmorStand) loc.getWorld().spawnEntity(feet1, EntityType.ARMOR_STAND);
as.setBasePlate(false);
as.setGravity(false);
as.setVisible(false);
as.setHelmet(new ItemStack(Material.LEVER));
armorList.add(as);
feet1 = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
feet1.add(.25,-1.8,-.25);
as = (ArmorStand) loc.getWorld().spawnEntity(feet1, EntityType.ARMOR_STAND);
as.setBasePlate(false);
as.setGravity(false);
as.setVisible(false);
as.setHelmet(new ItemStack(Material.LEVER));
armorList.add(as);
feet1 = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
feet1.add(.25,-1.8,.25);
as = (ArmorStand) loc.getWorld().spawnEntity(feet1, EntityType.ARMOR_STAND);
as.setBasePlate(false);
as.setGravity(false);
as.setVisible(false);
as.setHelmet(new ItemStack(Material.LEVER));
armorList.add(as);
armorList.add(as);
feet1 = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
feet1.add(-.25,-1.8,.25);
as = (ArmorStand) loc.getWorld().spawnEntity(feet1, EntityType.ARMOR_STAND);
as.setBasePlate(false);
as.setGravity(false);
as.setVisible(false);
as.setHelmet(new ItemStack(Material.LEVER));
armorList.add(as);
feet1 = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
feet1.add(0,-1.1,0);
feet1 = main.getNew(feet1, b, -.25, .0);
feet1.setYaw(Utils.FaceToYaw(b));
as = (ArmorStand) loc.getWorld().spawnEntity(feet1, EntityType.ARMOR_STAND);
as.setBasePlate(false);
as.setGravity(false);
as.setVisible(false);
as.setHelmet(new ItemStack(Material.TRAP_DOOR));
as.setHeadPose(new EulerAngle(1.57, .0, .0));
armorList.add(as);
Utils.setArmorStand(sitz, null, new ItemStack(Material.TRAP_DOOR), false, armorList, null);
Utils.setArmorStand(lehne, new EulerAngle(1.57, .0, .0), new ItemStack(Material.TRAP_DOOR), false, armorList, null);
Utils.setArmorStand(feet1, null, new ItemStack(Material.LEVER), false, armorList, null);
Utils.setArmorStand(feet2, null, new ItemStack(Material.LEVER), false, armorList, null);
Utils.setArmorStand(feet3, null, new ItemStack(Material.LEVER), false, armorList, null);
Utils.setArmorStand(feet4, null, new ItemStack(Material.LEVER), false, armorList, null);
main.getInstance().stuehle.add(this);
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
public Location getLocation(){
return this.loc;
}
@EventHandler
public void onWaterFlow(BlockFromToEvent e){
Location locTo = e.getToBlock().getLocation();
@ -144,12 +96,14 @@ public class stuhl implements Listener {
}
}
public void delete(){
armorList.get(0).getLocation().getWorld().dropItem(armorList.get(0).getLocation().getBlock().getLocation().add(0, 1, 0), main.getInstance().itemse.stuhl);
for(Entity entity : armorList){
ArmorStand as = (ArmorStand) entity;
entity.getWorld().playEffect(entity.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
entity.remove();
public void delete(Boolean b){
if(b){
armorList.get(0).getLocation().getWorld().dropItem(armorList.get(0).getLocation().getBlock().getLocation().add(0, 1, 0), main.getInstance().itemse.stuhl);
for(Entity entity : armorList){
ArmorStand as = (ArmorStand) entity;
entity.getWorld().playEffect(entity.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
entity.remove();
}
}
this.loc = null;
armorList.clear();
@ -161,7 +115,7 @@ public class stuhl implements Listener {
if(e.getDamager() instanceof Player){
if(e.getEntity() instanceof ArmorStand){
if(armorList.contains(e.getEntity())){
delete();
delete(true);
}
}
}

View File

@ -4,17 +4,17 @@ import java.util.ArrayList;
import java.util.List;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.EulerAngle;
@ -26,62 +26,27 @@ public class tisch implements Listener {
List<Entity> armorList = new ArrayList<Entity>();
ArmorStand armor;
ItemStack is;
ItemStack is = null;
Location loc = null;
public tisch(Location loc, Plugin plugin){
BlockFace b = null;
public Location getLocation(){return this.loc;}
public ItemStack getItemStack(){return this.is;}
public BlockFace getBlockFace(){return this.b;}
public tisch(Location loc, Plugin plugin, ItemStack is){
this.loc = loc;
this.b = Utils.yawToFace(loc.getYaw());
Location middle1 = Utils.getCenter(loc);
Location middle2 = Utils.getCenter(loc);
ArmorStand as = (ArmorStand) loc.getWorld().spawnEntity(middle1.add(0,-2.1,0), EntityType.ARMOR_STAND);
as.setHelmet(new ItemStack(Material.WOOD_PLATE));
as.setVisible(false);
as.setGravity(false);
armorList.add(as);
as = (ArmorStand) loc.getWorld().spawnEntity(middle2.add(0,-1.05,0), EntityType.ARMOR_STAND);
as.setHelmet(new ItemStack(Material.TRAP_DOOR));
as.setVisible(false);
as.setGravity(false);
armorList.add(as);
loc.setYaw(0);
Location location = new Location(loc.getWorld(), loc.getX(), loc.getY(), loc.getZ());
as = (ArmorStand) loc.getWorld().spawnEntity(location.add(.9,0.15,0.3), EntityType.ARMOR_STAND);
as.setRightArmPose(new EulerAngle(0,.0,.0));
as.setVisible(false);
as.setGravity(false);
armor = as;
armorList.add(as);
loc.setYaw(0);
as = (ArmorStand) loc.getWorld().spawnEntity(loc.add(.9,-.5,1.02), EntityType.ARMOR_STAND);
as.setItemInHand(new ItemStack(Material.STICK));
as.setRightArmPose(new EulerAngle(1.38,.0,.0));
as.setVisible(false);
as.setGravity(false);
armorList.add(as);
plugin.getServer().getPluginManager().registerEvents(this, plugin);
main.getInstance().tische.add(this);
}
public Location getLocation(){
return this.loc;
}
/*
@EventHandler
public void onWaterFlow(BlockFromToEvent e){
Location locTo = e.getToBlock().getLocation();
if(loc!=null && locTo.equals(loc)){
e.setCancelled(true);
}
}*/
@EventHandler
public void onHit(PlayerMoveEvent e){
Player p = e.getPlayer();
if(!p.isInsideVehicle() && loc!=null){
if(e.getTo().getBlock().getLocation().equals(loc.getBlock().getLocation()) ||
e.getTo().getBlock().getLocation().equals(loc.getBlock().getLocation().add(0,1,0))){
p.teleport(e.getFrom());
}
}
Utils.setArmorStand(middle1.add(0,-2.1,0),new EulerAngle(0, 0, 0) , new ItemStack(Material.WOOD_PLATE), false, armorList, null);
Utils.setArmorStand(middle2.add(0,-1.05,0),new EulerAngle(0, 0, 0) , new ItemStack(Material.TRAP_DOOR), false, armorList, null);
loc.setYaw(0);
ArmorStand as = Utils.setArmorStand(loc.add(.9,0.15,0.3),new EulerAngle(0,.0,.0), is, true, armorList, null);
Utils.setArmorStand(loc.add(0,-.65,.68),new EulerAngle(1.38,.0,.0), new ItemStack(Material.STICK), true, armorList, null);
this.armor = as;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
main.getInstance().tische.add(this);
}
@EventHandler
@ -91,12 +56,14 @@ public class tisch implements Listener {
if(armorList.contains(e.getRightClicked())){
e.setCancelled(true);
ItemStack is = player.getItemInHand();
if(is!=null){
if(is!=null&&!is.getType().isBlock()){
if(armor!=null){
ArmorStand as = (ArmorStand) armorList.get(2);
if(armor.getItemInHand()!=null&&!armor.getItemInHand().getType().equals(Material.AIR)){as.getLocation().getWorld().dropItem(as.getLocation(), as.getItemInHand());}
as.setItemInHand(is);
this.is = is;
if(!player.getGameMode().equals(GameMode.CREATIVE)){player.getInventory().remove(is);player.updateInventory();}
}
}
}
@ -104,19 +71,20 @@ public class tisch implements Listener {
}
public void delete(Boolean b){
if(is!=null&&b){
if(!is.getType().equals(Material.AIR)){
if(b){
armorList.get(0).getLocation().getWorld().dropItem(armorList.get(0).getLocation().getBlock().getLocation().add(0, 2, 0), main.getInstance().itemse.tisch);
if(is!=null && !is.getType().equals(Material.AIR)){
ArmorStand as = (ArmorStand) armorList.get(2);
as.getLocation().getWorld().dropItem(as.getLocation(), as.getItemInHand());
this.is = null;
}
for(Entity entity : armorList){
ArmorStand as = (ArmorStand) entity;
entity.getWorld().playEffect(entity.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
entity.remove();
}
}
armorList.get(0).getLocation().getWorld().dropItem(armorList.get(0).getLocation().getBlock().getLocation().add(0, 2, 0), main.getInstance().itemse.tisch);
for(Entity entity : armorList){
ArmorStand as = (ArmorStand) entity;
entity.getWorld().playEffect(entity.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
entity.remove();
}
this.loc = null;
armorList.clear();
main.getInstance().tische.remove(this);