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

View File

@ -1,7 +1,14 @@
package de.Ste3et_C0st.Furniture.Main; package de.Ste3et_C0st.Furniture.Main;
import java.util.List;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.BlockFace; 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; import org.bukkit.util.EulerAngle;
public class Utils { public class Utils {
@ -39,4 +46,33 @@ public class Utils {
if(d<0){d+=.5;}else{d+=.5;} if(d<0){d+=.5;}else{d+=.5;}
return d; 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). grinderRecipe = new ShapedRecipe(itemse.tisch).shape("0#0", "0E0", "0+0").setIngredient('#', Material.TRAP_DOOR).
setIngredient('E', Material.STICK).setIngredient('+', Material.WOOD_STEP); setIngredient('E', Material.STICK).setIngredient('+', Material.WOOD_STEP);
getServer().addRecipe(grinderRecipe); 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) { public static String getCardinalDirection(Player player) {

View File

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

View File

@ -8,9 +8,9 @@ import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -27,69 +27,40 @@ public class laterne implements Listener {
List<Entity> armorList = new ArrayList<Entity>(); List<Entity> armorList = new ArrayList<Entity>();
Block b; Block b;
Location loc = null; 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.loc = loc;
this.bool = bool;
Location center = Utils.getCenter(loc); Location center = Utils.getCenter(loc);
b = center.getWorld().getBlockAt(center); 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; 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); obsidian.add(0D, -2.2, 0D);
ArmorStand as = (ArmorStand) loc.getWorld().spawnEntity(obsidian, EntityType.ARMOR_STAND); Location left_down = new Location(obsidian.getWorld(), obsidian.getX()+0.22, obsidian.getY() + .62, obsidian.getZ()+0.22);
as.setBasePlate(false); Location left_upper = new Location(obsidian.getWorld(), obsidian.getX() -0.21, obsidian.getY() + .62, obsidian.getZ() +0.22);
as.setGravity(false); Location right_upper = new Location(obsidian.getWorld(), obsidian.getX()-0.21, obsidian.getY()+.62, obsidian.getZ()-0.21);
as.setVisible(false); Location right_down = new Location(obsidian.getWorld(), obsidian.getX()+0.21, obsidian.getY() + .62, obsidian.getZ() -0.21);
as.setHelmet(new ItemStack(Material.OBSIDIAN));
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()); Utils.setArmorStand(left_down, null, new ItemStack(Material.LEVER), false, armorList, null);
as = (ArmorStand) loc.getWorld().spawnEntity(location.add(0,.75,0), EntityType.ARMOR_STAND); Utils.setArmorStand(left_upper, null, new ItemStack(Material.LEVER), false, armorList, null);
as.setBasePlate(false); Utils.setArmorStand(right_upper, null, new ItemStack(Material.LEVER), false, armorList, null);
as.setGravity(false); Utils.setArmorStand(right_down, null, new ItemStack(Material.LEVER), false, armorList, null);
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);
Bukkit.getServer().getPluginManager().registerEvents(this, plugin); Bukkit.getServer().getPluginManager().registerEvents(this, plugin);
main.getInstance().laternen.add(this); main.getInstance().laternen.add(this);
} }
@ -122,14 +93,18 @@ public class laterne implements Listener {
} }
*/ */
public void delete(){ public void delete(Boolean b){
armorList.get(0).getLocation().getWorld().dropItem(b.getLocation(), main.getInstance().itemse.Laterne);
for(Entity entity : armorList){ if(b){
ArmorStand as = (ArmorStand) entity; armorList.get(0).getLocation().getWorld().dropItem(this.b.getLocation(), main.getInstance().itemse.Laterne);
entity.getWorld().playEffect(entity.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType()); for(Entity entity : armorList){
entity.remove(); 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; this.loc = null;
armorList.clear(); armorList.clear();
main.getInstance().laternen.remove(this); main.getInstance().laternen.remove(this);
@ -152,17 +127,13 @@ public class laterne implements Listener {
} }
} }
} }
public Location getLocation(){
return this.loc;
}
@EventHandler @EventHandler
public void damage(EntityDamageByEntityEvent e){ public void damage(EntityDamageByEntityEvent e){
if(e.getDamager() instanceof Player){ if(e.getDamager() instanceof Player){
if(e.getEntity() instanceof ArmorStand){ if(e.getEntity() instanceof ArmorStand){
if(armorList.contains(e.getEntity())){ 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.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -29,20 +27,19 @@ public class sofa implements Listener {
private List<Entity> armorList = new ArrayList<Entity>(); private List<Entity> armorList = new ArrayList<Entity>();
private List<Entity> sitz = new ArrayList<Entity>(); private List<Entity> sitz = new ArrayList<Entity>();
private List<Location> location = new ArrayList<Location>(); private List<Location> location = new ArrayList<Location>();
private ItemStack is; private ItemStack is;
private Double place; private Double place;
private short color = 0; private short color = 0;
public sofa(Location loc, Integer lengt, Plugin plugin){ public sofa(Location loc, Integer lengt, Plugin plugin){
this.place = 0.2; this.place = 0.2;
is = new ItemStack(Material.CARPET); is = new ItemStack(Material.CARPET);
is.setDurability(color); is.setDurability(color);
BlockFace playerLookingDirection = Utils.yawToFace(loc.getYaw()).getOppositeFace(); BlockFace b = 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){
loc = loc.getBlock().getLocation(); loc = loc.getBlock().getLocation();
loc.setYaw(yaw); loc.setYaw(Utils.FaceToYaw(b));
Integer x = (int) loc.getX(); Integer x = (int) loc.getX();
Integer y = (int) loc.getY(); Integer y = (int) loc.getY();
Integer z = (int) loc.getZ(); 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.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.SOUTH)){loc = main.getNew(loc, b, -1.0, -1.0);}
if(b.equals(BlockFace.EAST)){loc = main.getNew(loc, b, -1.0, .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 looking = new Location(loc.getWorld(), loc.getBlockX(), loc.getBlockY() -1.4 , loc.getBlockZ());
Location feet1 = main.getNew(looking, b, place, .2D); Location feet1 = main.getNew(looking, b, place, .2D);
Location feet2 = main.getNew(looking, b, place, lengt.doubleValue()-.2D); Location feet2 = main.getNew(looking, b, place, lengt.doubleValue()-.2D);
Location feet3 = main.getNew(looking, b, place + .5, .2D); Location feet3 = main.getNew(looking, b, place + .5, .2D);
Location feet4 = main.getNew(looking, b, place + .5, lengt.doubleValue()-.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); Utils.setArmorStand(feet1, null, new ItemStack(Material.LEVER), false, armorList, null);
ArmorStand armor3 = (ArmorStand) w.spawnEntity(feet3, EntityType.ARMOR_STAND); Utils.setArmorStand(feet2, null, new ItemStack(Material.LEVER), false, armorList, null);
ArmorStand armor4 = (ArmorStand) w.spawnEntity(feet4, EntityType.ARMOR_STAND); Utils.setArmorStand(feet3, null, new ItemStack(Material.LEVER), false, armorList, null);
armor1.setHelmet(new ItemStack(Material.LEVER)); Utils.setArmorStand(feet4, null, new ItemStack(Material.LEVER), false, armorList, null);
armor2.setHelmet(new ItemStack(Material.LEVER));
armor3.setHelmet(new ItemStack(Material.LEVER));
armor4.setHelmet(new ItemStack(Material.LEVER));
Location carpetHight = new Location(looking.getWorld(), loc.getBlockX(), loc.getBlockY() -1 , loc.getBlockZ()); Location carpetHight = new Location(looking.getWorld(), loc.getBlockX(), loc.getBlockY() -1 , loc.getBlockZ());
carpetHight.setYaw(Utils.FaceToYaw(b)); carpetHight.setYaw(Utils.FaceToYaw(b));
//sitz //sitz
@ -75,29 +69,17 @@ public class sofa implements Listener {
float facing = Utils.FaceToYaw(b); float facing = Utils.FaceToYaw(b);
for(Double i = .0; i<=lengt; i+=0.65){ for(Double i = .0; i<=lengt; i+=0.65){
//SITZ //SITZ
location.add(main.getNew(carpetHight, b, place,(double) d).getBlock().getLocation().add(0, 1, 0)); location.add(main.getNew(carpetHight, b, place,(double) d).getBlock().getLocation().add(0, 1, 0));
Location carpet = main.getNew(carpetHight, b, place,(double) d); Location carpet = main.getNew(carpetHight, b, place,(double) d);
carpet.setYaw(facing); carpet.setYaw(facing);
ArmorStand armorcarpet = (ArmorStand) w.spawnEntity(carpet, EntityType.ARMOR_STAND); ArmorStand as = Utils.setArmorStand(carpet, null, is, false, armorList, null);
armorcarpet.setHelmet(is); sitz.add(as);
armorList.add(armorcarpet);
sitz.add(armorcarpet);
//OBERER TEIL //OBERER TEIL
Location location = main.getNew(carpetHight, b, place-.25,(double) d); Location location = main.getNew(carpetHight, b, place-.25,(double) d);
location.setYaw(facing); location.setYaw(facing);
armorcarpet = (ArmorStand) w.spawnEntity(location, EntityType.ARMOR_STAND); Utils.setArmorStand(location, new EulerAngle(1.57, .0, .0), is, false, armorList, null);
armorcarpet.setHeadPose(new EulerAngle(1.57, .0, .0));
armorcarpet.setHelmet(is);
armorList.add(armorcarpet);
if(d<=0D){d = 0.00;} if(d<=0D){d = 0.00;}
d+=.58; d+=.58;
} }
Float yaw1= facing; Float yaw1= facing;
Float yaw2= facing; Float yaw2= facing;
@ -105,28 +87,11 @@ public class sofa implements Listener {
last.setYaw(yaw1+90); last.setYaw(yaw1+90);
Location first = main.getNew(new Location(loc.getWorld(), loc.getX(), last.getY(), loc.getZ()), b, place+.25, 0.07D); Location first = main.getNew(new Location(loc.getWorld(), loc.getX(), last.getY(), loc.getZ()), b, place+.25, 0.07D);
first.setYaw(yaw2-90); 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); Utils.setArmorStand(first.add(0,-.05,0), new EulerAngle(1.57, .0, .0), is, false, armorList, null);
armorList.add(RightCarpet); Utils.setArmorStand(last.add(0,-.05,0), new EulerAngle(1.57, .0, .0), is, false, armorList, null);
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);
}
plugin.getServer().getPluginManager().registerEvents(this, plugin); plugin.getServer().getPluginManager().registerEvents(this, plugin);
main.getInstance().sofas.add(this); main.getInstance().sofas.add(this);
} }
@EventHandler @EventHandler
@ -150,12 +115,14 @@ public class sofa implements Listener {
} }
}*/ }*/
public void delete(){ public void delete(Boolean b){
armorList.get(0).getLocation().getWorld().dropItem(armorList.get(0).getLocation().getBlock().getLocation().add(0, 1, 0), main.getInstance().itemse.Sofa); if(b){
for(Entity entity : armorList){ armorList.get(0).getLocation().getWorld().dropItem(armorList.get(0).getLocation().getBlock().getLocation().add(0, 1, 0), main.getInstance().itemse.Sofa);
ArmorStand as = (ArmorStand) entity; for(Entity entity : armorList){
entity.getWorld().playEffect(entity.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType()); ArmorStand as = (ArmorStand) entity;
entity.remove(); entity.getWorld().playEffect(entity.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
entity.remove();
}
} }
location.clear(); location.clear();
armorList.clear(); armorList.clear();
@ -212,7 +179,7 @@ public class sofa implements Listener {
if(e.getDamager() instanceof Player){ if(e.getDamager() instanceof Player){
if(e.getEntity() instanceof ArmorStand){ if(e.getEntity() instanceof ArmorStand){
if(armorList.contains(e.getEntity())){ 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.block.BlockFace;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -27,87 +26,40 @@ public class stuhl implements Listener {
List<Entity> armorList = new ArrayList<Entity>(); List<Entity> armorList = new ArrayList<Entity>();
Location loc = null; Location loc = null;
BlockFace b = null;
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
public stuhl(Location loc, Plugin plugin){ public stuhl(Location loc, Plugin plugin){
this.loc = loc.getBlock().getLocation(); this.loc = loc.getBlock().getLocation();
BlockFace b = Utils.yawToFace(loc.getYaw()).getOppositeFace(); BlockFace b = Utils.yawToFace(loc.getYaw()).getOppositeFace();
Location center = Utils.getCenter(loc); Location center = Utils.getCenter(loc);
Location sitz = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ()); 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.add(0,-1.45,0);
sitz.setYaw(Utils.FaceToYaw(b)); sitz.setYaw(Utils.FaceToYaw(b));
ArmorStand as = (ArmorStand) loc.getWorld().spawnEntity(sitz, EntityType.ARMOR_STAND); lehne.setYaw(Utils.FaceToYaw(b));
as.setBasePlate(false);
as.setGravity(false);
as.setVisible(false);
as.setHelmet(new ItemStack(Material.TRAP_DOOR));
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);
Location feet1 = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ()); Utils.setArmorStand(feet1, null, new ItemStack(Material.LEVER), false, armorList, null);
feet1.add(-.25,-1.8,-.25); Utils.setArmorStand(feet2, null, new ItemStack(Material.LEVER), false, armorList, null);
Utils.setArmorStand(feet3, null, new ItemStack(Material.LEVER), false, armorList, null);
as = (ArmorStand) loc.getWorld().spawnEntity(feet1, EntityType.ARMOR_STAND); Utils.setArmorStand(feet4, null, new ItemStack(Material.LEVER), false, armorList, null);
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);
main.getInstance().stuehle.add(this); main.getInstance().stuehle.add(this);
plugin.getServer().getPluginManager().registerEvents(this, plugin); plugin.getServer().getPluginManager().registerEvents(this, plugin);
} }
public Location getLocation(){
return this.loc;
}
@EventHandler @EventHandler
public void onWaterFlow(BlockFromToEvent e){ public void onWaterFlow(BlockFromToEvent e){
Location locTo = e.getToBlock().getLocation(); Location locTo = e.getToBlock().getLocation();
@ -144,12 +96,14 @@ public class stuhl implements Listener {
} }
} }
public void delete(){ public void delete(Boolean b){
armorList.get(0).getLocation().getWorld().dropItem(armorList.get(0).getLocation().getBlock().getLocation().add(0, 1, 0), main.getInstance().itemse.stuhl); if(b){
for(Entity entity : armorList){ armorList.get(0).getLocation().getWorld().dropItem(armorList.get(0).getLocation().getBlock().getLocation().add(0, 1, 0), main.getInstance().itemse.stuhl);
ArmorStand as = (ArmorStand) entity; for(Entity entity : armorList){
entity.getWorld().playEffect(entity.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType()); ArmorStand as = (ArmorStand) entity;
entity.remove(); entity.getWorld().playEffect(entity.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
entity.remove();
}
} }
this.loc = null; this.loc = null;
armorList.clear(); armorList.clear();
@ -161,7 +115,7 @@ public class stuhl implements Listener {
if(e.getDamager() instanceof Player){ if(e.getDamager() instanceof Player){
if(e.getEntity() instanceof ArmorStand){ if(e.getEntity() instanceof ArmorStand){
if(armorList.contains(e.getEntity())){ if(armorList.contains(e.getEntity())){
delete(); delete(true);
} }
} }
} }

View File

@ -4,17 +4,17 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.util.EulerAngle; import org.bukkit.util.EulerAngle;
@ -26,62 +26,27 @@ public class tisch implements Listener {
List<Entity> armorList = new ArrayList<Entity>(); List<Entity> armorList = new ArrayList<Entity>();
ArmorStand armor; ArmorStand armor;
ItemStack is; ItemStack is = null;
Location loc = 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 middle1 = Utils.getCenter(loc);
Location middle2 = Utils.getCenter(loc); Location middle2 = Utils.getCenter(loc);
ArmorStand as = (ArmorStand) loc.getWorld().spawnEntity(middle1.add(0,-2.1,0), EntityType.ARMOR_STAND); Utils.setArmorStand(middle1.add(0,-2.1,0),new EulerAngle(0, 0, 0) , new ItemStack(Material.WOOD_PLATE), false, armorList, null);
as.setHelmet(new ItemStack(Material.WOOD_PLATE)); Utils.setArmorStand(middle2.add(0,-1.05,0),new EulerAngle(0, 0, 0) , new ItemStack(Material.TRAP_DOOR), false, armorList, null);
as.setVisible(false); loc.setYaw(0);
as.setGravity(false); ArmorStand as = Utils.setArmorStand(loc.add(.9,0.15,0.3),new EulerAngle(0,.0,.0), is, true, armorList, null);
armorList.add(as); Utils.setArmorStand(loc.add(0,-.65,.68),new EulerAngle(1.38,.0,.0), new ItemStack(Material.STICK), true, armorList, null);
as = (ArmorStand) loc.getWorld().spawnEntity(middle2.add(0,-1.05,0), EntityType.ARMOR_STAND); this.armor = as;
as.setHelmet(new ItemStack(Material.TRAP_DOOR)); plugin.getServer().getPluginManager().registerEvents(this, plugin);
as.setVisible(false); main.getInstance().tische.add(this);
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());
}
}
} }
@EventHandler @EventHandler
@ -91,12 +56,14 @@ public class tisch implements Listener {
if(armorList.contains(e.getRightClicked())){ if(armorList.contains(e.getRightClicked())){
e.setCancelled(true); e.setCancelled(true);
ItemStack is = player.getItemInHand(); ItemStack is = player.getItemInHand();
if(is!=null){ if(is!=null&&!is.getType().isBlock()){
if(armor!=null){ if(armor!=null){
ArmorStand as = (ArmorStand) armorList.get(2); ArmorStand as = (ArmorStand) armorList.get(2);
if(armor.getItemInHand()!=null&&!armor.getItemInHand().getType().equals(Material.AIR)){as.getLocation().getWorld().dropItem(as.getLocation(), as.getItemInHand());} if(armor.getItemInHand()!=null&&!armor.getItemInHand().getType().equals(Material.AIR)){as.getLocation().getWorld().dropItem(as.getLocation(), as.getItemInHand());}
as.setItemInHand(is); as.setItemInHand(is);
this.is = 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){ public void delete(Boolean b){
if(is!=null&&b){ if(b){
if(!is.getType().equals(Material.AIR)){ 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); ArmorStand as = (ArmorStand) armorList.get(2);
as.getLocation().getWorld().dropItem(as.getLocation(), as.getItemInHand()); as.getLocation().getWorld().dropItem(as.getLocation(), as.getItemInHand());
this.is = null; 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; this.loc = null;
armorList.clear(); armorList.clear();
main.getInstance().tische.remove(this); main.getInstance().tische.remove(this);