Dicecraft Funitor mod

This commit is contained in:
BuildTools 2015-04-06 15:53:51 +02:00
commit 3682029652
15 changed files with 1289 additions and 0 deletions

8
.classpath Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="C:/Plugins/jars/spigot.jar"/>
<classpathentry kind="src" path="/DiceEaster"/>
<classpathentry kind="output" path="bin"/>
</classpath>

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/bin/

17
.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Furniture</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

View File

@ -0,0 +1,69 @@
package de.Ste3et_C0st.Furniture.Listener;
import org.bukkit.ChatColor;
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.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.Furniture.Objects.largeTable;
import de.Ste3et_C0st.Furniture.Objects.laterne;
import de.Ste3et_C0st.Furniture.Objects.sofa;
import de.Ste3et_C0st.Furniture.Objects.stuhl;
import de.Ste3et_C0st.Furniture.Objects.tisch;
public class OnInteract implements Listener {
@EventHandler
public void onInterActEvent(PlayerInteractEvent e){
Player p = e.getPlayer();
if(e.getItem() == null){return;}
if(e.getClickedBlock() == null){return;}
ItemStack is = e.getItem();
if(!is.hasItemMeta()){return;}
if(!is.getType().equals(Material.MONSTER_EGG)){return;}
if(!is.getItemMeta().hasDisplayName()){return;}
if(e.getClickedBlock()==null){return;}
if(!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){return;}
Location location = e.getClickedBlock().getLocation();
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());
return;
}
}
if(ChatColor.stripColor(is.getItemMeta().getDisplayName()).equalsIgnoreCase("laterne")){
if(main.getInstance().canPlace(p, location, null, null)){
new laterne(location, main.getInstance());
return;
}
}
if(ChatColor.stripColor(is.getItemMeta().getDisplayName()).equalsIgnoreCase("stuhl")){
if(main.getInstance().canPlace(p, location, null, null)){
new stuhl(location, main.getInstance());
return;
}
}
if(ChatColor.stripColor(is.getItemMeta().getDisplayName()).equalsIgnoreCase("tisch")){
if(main.getInstance().canPlace(p, location, null, null)){
new tisch(location, main.getInstance());
return;
}
}
if(ChatColor.stripColor(is.getItemMeta().getDisplayName()).equalsIgnoreCase("tisch2")){
if(main.getInstance().canPlace(p, location, null, null)){
new largeTable(location, main.getInstance());
return;
}
}
}
}

View File

@ -0,0 +1,47 @@
package de.Ste3et_C0st.Furniture.Main;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
public class ItemsEquipment {
public ItemStack Laterne = null;
public ItemStack Sofa = null;
public ItemStack stuhl = null;
public ItemStack tisch = null;
public ItemStack tisch2 = null;
public ItemsEquipment(){
ItemMeta im = null;
this.Sofa = new ItemStack(Material.MONSTER_EGG);
im = this.Sofa.getItemMeta();
im.addEnchant(Enchantment.ARROW_INFINITE, 1, true);
im.setDisplayName("§cSofa");
this.Sofa.setItemMeta(im);
this.Laterne = new ItemStack(Material.MONSTER_EGG);
im = this.Laterne.getItemMeta();
im.addEnchant(Enchantment.ARROW_INFINITE, 1, true);
im.setDisplayName("§cLaterne");
this.Laterne.setItemMeta(im);
this.stuhl = new ItemStack(Material.MONSTER_EGG);
im = this.stuhl.getItemMeta();
im.addEnchant(Enchantment.ARROW_INFINITE, 1, true);
im.setDisplayName("§cStuhl");
this.stuhl.setItemMeta(im);
this.tisch = new ItemStack(Material.MONSTER_EGG);
im = this.tisch.getItemMeta();
im.addEnchant(Enchantment.ARROW_INFINITE, 1, true);
im.setDisplayName("§cTisch");
this.tisch.setItemMeta(im);
this.tisch2 = new ItemStack(Material.MONSTER_EGG);
im = this.tisch2.getItemMeta();
im.addEnchant(Enchantment.ARROW_INFINITE, 1, true);
im.setDisplayName("§cTisch2");
this.tisch2.setItemMeta(im);
}
}

View File

@ -0,0 +1,35 @@
package de.Ste3et_C0st.Furniture.Main;
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
public class Utils {
public static final BlockFace[] axis = { BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST };
public static BlockFace yawToFace(float yaw) {
return axis[Math.round(yaw / 90f) & 0x3];
}
public static Float FaceToYaw(BlockFace face) {
Float yaw = 0F;
if(face.equals(BlockFace.NORTH)){yaw = 0f;}
if(face.equals(BlockFace.WEST)){yaw = 270f;}
if(face.equals(BlockFace.SOUTH)){yaw = 180f;}
if(face.equals(BlockFace.EAST)){yaw = 90f;}
return yaw;
}
public static Location getCenter(Location loc) {
return new Location(loc.getWorld(),
getRelativeCoord(loc.getBlockX()),
getRelativeCoord(loc.getBlockY()),
getRelativeCoord(loc.getBlockZ()));
}
private static double getRelativeCoord(int i) {
double d = i;
d = d < 0 ? d - .5 : d + .5;
return d;
}
}

View File

@ -0,0 +1,25 @@
package de.Ste3et_C0st.Furniture.Main;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class command implements CommandExecutor {
@Override
public boolean onCommand(CommandSender arg0, Command arg1, String arg2,String[] arg3) {
if(arg0 instanceof Player == false){return true;}
Player p = (Player) arg0;
if(arg1.getName().equalsIgnoreCase("Furniture")){
p.getInventory().addItem(main.getInstance().itemse.Sofa);
p.getInventory().addItem(main.getInstance().itemse.Laterne);
p.getInventory().addItem(main.getInstance().itemse.stuhl);
p.getInventory().addItem(main.getInstance().itemse.tisch);
p.getInventory().addItem(main.getInstance().itemse.tisch2);
}
return false;
}
}

View File

@ -0,0 +1,163 @@
package de.Ste3et_C0st.Furniture.Main;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.DiceEaster.DiceEaster;
import de.Ste3et_C0st.Furniture.Listener.OnInteract;
import de.Ste3et_C0st.Furniture.Objects.largeTable;
import de.Ste3et_C0st.Furniture.Objects.laterne;
import de.Ste3et_C0st.Furniture.Objects.sofa;
import de.Ste3et_C0st.Furniture.Objects.stuhl;
import de.Ste3et_C0st.Furniture.Objects.tisch;
public class main extends JavaPlugin {
private static main Main;
public List<sofa> sofas = new ArrayList<sofa>();
public List<laterne> laternen = new ArrayList<laterne>();
public List<stuhl> stuehle = new ArrayList<stuhl>();
public List<tisch> tische = new ArrayList<tisch>();
public List<largeTable> tische2 = new ArrayList<largeTable>();
public ItemsEquipment itemse;
public DiceEaster dice;
@Override
public void onEnable(){
getCommand("equipment").setExecutor(new command());
Main = this;
this.itemse = new ItemsEquipment();
getServer().getPluginManager().registerEvents(new OnInteract(), this);
dice = (DiceEaster) getServer().getPluginManager().getPlugin("DiceEaster");
addCrafting();
}
@Override
public void onDisable(){
}
public void addCrafting(){
ShapedRecipe grinderRecipe = new ShapedRecipe(itemse.Sofa).shape("#0#", "###", "+0+").setIngredient('+', Material.FENCE).
setIngredient('#', Material.WOOL);
getServer().addRecipe(grinderRecipe);
grinderRecipe = new ShapedRecipe(itemse.Laterne).shape("0#0", "-+-", "0E0").setIngredient('+', Material.TORCH).
setIngredient('#', Material.WOOD_PLATE).setIngredient('-', Material.STICK).setIngredient('E', Material.OBSIDIAN);
getServer().addRecipe(grinderRecipe);
grinderRecipe = new ShapedRecipe(itemse.Laterne).shape("0#0", "-+-", "0E0").setIngredient('+', Material.TORCH).
setIngredient('#', Material.WOOD_PLATE).setIngredient('-', Material.STICK).setIngredient('E', Material.OBSIDIAN);
getServer().addRecipe(grinderRecipe);
grinderRecipe = new ShapedRecipe(itemse.stuhl).shape("0#0", "0#0", "E0E").setIngredient('#', Material.TRAP_DOOR).
setIngredient('E', Material.STICK);
getServer().addRecipe(grinderRecipe);
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);
}
public static String getCardinalDirection(Player player) {
double rotation = (player.getLocation().getYaw() - 90) % 360;
if (rotation < 0) {
rotation += 360.0;
}
if (0 <= rotation && rotation < 22.5) {
return "N";
} else if (67.5 <= rotation && rotation < 112.5) {
return "E";
} else if (157.5 <= rotation && rotation < 202.5) {
return "S";
} else if (247.5 <= rotation && rotation < 292.5) {
return "W";
} else if (337.5 <= rotation && rotation < 360.0) {
return "N";
} else {
return null;
}
}
//NORDEN IST KOMPLETT
public static Location getNew(Location loc, BlockFace b, Double z, Double x){
//WESTEN FALSCH HERUM
//NORDEN IST RICHTIG
//OSTEN FALSCH HERUM
//Süden Falschherum
Location l = new Location(loc.getWorld(), loc.getX(), loc.getY(), loc.getZ());
if(b.equals(BlockFace.NORTH)){
l.add(x,0,z);
}
if(b.equals(BlockFace.SOUTH)){
l.add(-x,0,-z);
}
if(b.equals(BlockFace.EAST)){
l.add(-z,0,x);
}
if(b.equals(BlockFace.WEST)){
l.add(z,0,-x);
}
return l;
}
public static EulerAngle getNewEuler(BlockFace b, Double z, Double x,Double y){
//!! SÜDEN GEHT !!
//!! NORDEN GEHT !!
//!! OSTEN GEHT !!
//!! Westen FALSCHHERUM !!
EulerAngle l = new EulerAngle(0, 0, 0);
if(b.equals(BlockFace.NORTH)){l = new EulerAngle(x,y,-z);
}else if(b.equals(BlockFace.SOUTH)){l = new EulerAngle(-x,y,z);
}else if(b.equals(BlockFace.EAST)){l = new EulerAngle(-z,y,x);
}else if(b.equals(BlockFace.WEST)){l = new EulerAngle(z,y,x);}
return l;
}
public static short getFromDey(short s){
if(s==15){return 0;}
if(s==14){return 1;}
if(s==13){return 2;}
if(s==12){return 3;}
if(s==11){return 4;}
if(s==10){return 5;}
if(s==9){return 6;}
if(s==8){return 7;}
if(s==7){return 8;}
if(s==6){return 9;}
if(s==5){return 10;}
if(s==4){return 11;}
if(s==3){return 12;}
if(s==2){return 13;}
if(s==1){return 14;}
if(s==0){return 15;}
return 0;
}
public boolean canPlace(Player p, Location location, BlockFace b, Integer length){
if(b==null&&length==null){
if(!location.getBlock().getType().equals(Material.AIR)){
return false;
}
}
if(b!=null&&length!=null){
for(int i = 0; i<= length-1; i++){
if(!getNew(location, b, 0D,(double) i).getBlock().getType().equals(Material.AIR)){
return false;
}
}
}
return true;
}
public static main getInstance() {return Main;}
}

View File

@ -0,0 +1,198 @@
package de.Ste3et_C0st.Furniture.Objects;
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.block.BlockFromToEvent;
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;
import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main;
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());
plugin.getServer().broadcastMessage(b.name());
//East WORK
//SOUT Z WORK
location = main.getNew(location, b, 0.0, 0.0);
Double d = .0;
//Glass Platte
for(int i = 0; i<=2;i++){
Double winkel = 1.57;
Location l = new Location(loc.getWorld(), location.getX()+d, location.getY()-1.0, location.getZ());
l.setYaw(0);
ArmorStand as = (ArmorStand) loc.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
as.setVisible(false);
as.setGravity(false);
as.setHelmet(new ItemStack(Material.STAINED_GLASS_PANE));
as.setHeadPose(new EulerAngle(winkel, 0, 0));
this.armorList.add(as);
this.location.add(as.getLocation());
l = main.getNew(l, b, 0.0, -0.62);
as = (ArmorStand) loc.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
as.setVisible(false);
as.setGravity(false);
as.setHelmet(new ItemStack(Material.STAINED_GLASS_PANE));
as.setHeadPose(new EulerAngle(winkel, 0, 0));
this.armorList.add(as);
this.location.add(as.getLocation());
l = main.getNew(l, b, 0.0, -0.62);
as = (ArmorStand) loc.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
as.setVisible(false);
as.setGravity(false);
as.setHelmet(new ItemStack(Material.STAINED_GLASS_PANE));
as.setHeadPose(new EulerAngle(winkel, 0, 0));
d+=.62;
this.armorList.add(as);
this.location.add(as.getLocation());
}
Location middle = Utils.getCenter(armorList.get(4).getLocation()).add(1, -.88, -1.0);
middle.setYaw(0);
ArmorStand as = (ArmorStand) middle.getWorld().spawnEntity(middle, EntityType.ARMOR_STAND);
as.setRightArmPose(new EulerAngle(-1.75, 0, 0));
as.setItemInHand(new ItemStack(Material.BONE));
as.setGravity(false);
as.setVisible(false);
this.armorList.add(as);
middle = Utils.getCenter(armorList.get(4).getLocation()).add(1.5, -.88, 1.45);
middle.setYaw(180);
as = (ArmorStand) middle.getWorld().spawnEntity(middle, EntityType.ARMOR_STAND);
as.setRightArmPose(new EulerAngle(-1.75, 0, 0));
as.setItemInHand(new ItemStack(Material.BONE));
as.setGravity(false);
as.setVisible(false);
this.armorList.add(as);
middle = Utils.getCenter(armorList.get(4).getLocation()).add(1.5, -.88, 0);
middle.setYaw(180);
as = (ArmorStand) middle.getWorld().spawnEntity(middle, EntityType.ARMOR_STAND);
as.setRightArmPose(new EulerAngle(-1.75, 0, 0));
as.setItemInHand(new ItemStack(Material.BONE));
as.setGravity(false);
as.setVisible(false);
this.armorList.add(as);
middle = Utils.getCenter(armorList.get(4).getLocation()).add(1, -.88, .45);
middle.setYaw(0);
as = (ArmorStand) middle.getWorld().spawnEntity(middle, EntityType.ARMOR_STAND);
as.setRightArmPose(new EulerAngle(-1.75, 0, 0));
as.setItemInHand(new ItemStack(Material.BONE));
as.setGravity(false);
as.setVisible(false);
this.armorList.add(as);
plugin.getServer().getPluginManager().registerEvents(this, plugin);
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();
}
location.clear();
armorList.clear();
main.getInstance().sofas.remove(this);
}
@EventHandler
public void onInteract(PlayerInteractAtEntityEvent e){
Player player = e.getPlayer();
if(e.getRightClicked() instanceof ArmorStand){
if(armorList.contains(e.getRightClicked())){
e.setCancelled(true);
ItemStack is = player.getItemInHand();
if(is!=null){
if(is.getType().equals(Material.INK_SACK)){
Short druability = is.getDurability();
Integer amount = is.getAmount();
if(amount>armorList.size() || player.getGameMode().equals(GameMode.CREATIVE)){amount=armorList.size();}
List<Entity> list = new ArrayList<Entity>();
for(Entity entity : armorList){
if(entity instanceof ArmorStand){
ArmorStand as = (ArmorStand) entity;
ItemStack item = as.getHelmet();
if(item.getDurability() != main.getFromDey(druability)){
list.add(entity);
}
}
}
for(int i = 0; i<=amount-1;i++){
Entity entity = list.get(i);
if(entity instanceof ArmorStand){
ArmorStand as = (ArmorStand) entity;
ItemStack item = as.getHelmet();
item.setDurability(main.getFromDey(druability));
as.setHelmet(item);
}
}
if(!player.getGameMode().equals(GameMode.CREATIVE)){
is.setAmount(is.getAmount()-amount);
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), is);
player.updateInventory();
}
}
}
}
}
}
@EventHandler
public void damage(EntityDamageByEntityEvent e){
if(e.getDamager() instanceof Player){
if(e.getEntity() instanceof ArmorStand){
if(armorList.contains(e.getEntity())){
delete();
}
}
}
}
@EventHandler
public void onWaterFlow(BlockFromToEvent e){
Location locTo = e.getToBlock().getLocation();
if(location!=null && !location.isEmpty()){
if(location.contains(locTo) || location.contains(locTo.add(0,1,0))){
e.setCancelled(true);
}
}
}
@EventHandler
public void onHit(PlayerMoveEvent e){
Player p = e.getPlayer();
if(!p.isInsideVehicle() && location!=null){
if(location.contains(e.getTo().getBlock().getLocation()) || location.contains(e.getTo().getBlock().getLocation().add(0,-1,0))){
p.teleport(e.getFrom());
}
}
}
}

View File

@ -0,0 +1,169 @@
package de.Ste3et_C0st.Furniture.Objects;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
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.block.BlockFromToEvent;
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 de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main;
public class laterne implements Listener {
List<Entity> armorList = new ArrayList<Entity>();
Block b;
Location loc = null;
public laterne(Location loc, Plugin plugin){
this.loc = loc;
Location center = Utils.getCenter(loc);
center.add(1,0,0);
b = center.getWorld().getBlockAt(center);
b.setType(Material.TORCH);
Location obsidian = center;
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));
armorList.add(as);
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);
Bukkit.getServer().getPluginManager().registerEvents(this, plugin);
main.getInstance().laternen.add(this);
}
public boolean check(Player player, Location loc){
if(!loc.getBlock().equals(Material.AIR)){
return false;
}
return true;
}
@EventHandler
public void onWaterFlow(BlockFromToEvent e){
Location locTo = e.getToBlock().getLocation();
if(loc!=null && locTo.equals(loc.getBlock().getLocation())){
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());
}
}
}
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();
}
if(b!=null&&!b.getType().equals(Material.AIR)){b.setType(Material.AIR);}
this.loc = null;
armorList.clear();
main.getInstance().laternen.remove(this);
}
@EventHandler
public void onInteract(PlayerInteractAtEntityEvent e){
Player player = e.getPlayer();
if(e.getRightClicked() instanceof ArmorStand){
if(armorList.contains(e.getRightClicked())){
e.setCancelled(true);
ItemStack is = player.getItemInHand();
if(is!=null){
if(is.getType().equals(Material.FLINT_AND_STEEL)){
b.setType(Material.TORCH);
}else if(is.getType().equals(Material.WATER_BUCKET)){
b.setType(Material.REDSTONE_TORCH_OFF);
}
}
}
}
}
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();
}
}
}
}
}

View File

@ -0,0 +1,229 @@
package de.Ste3et_C0st.Furniture.Objects;
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.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;
import org.bukkit.event.block.BlockFromToEvent;
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 de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main;
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){
loc = loc.getBlock().getLocation();
loc.setYaw(yaw);
Integer x = (int) loc.getX();
Integer y = (int) loc.getY();
Integer z = (int) loc.getZ();
loc.setX(x);
loc.setY(y);
loc.setZ(z);
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.setBasePlate(false);
armor2.setBasePlate(false);
armor3.setBasePlate(false);
armor4.setBasePlate(false);
armor1.setVisible(false);
armor2.setVisible(false);
armor3.setVisible(false);
armor4.setVisible(false);
armor1.setGravity(false);
armor2.setGravity(false);
armor3.setGravity(false);
armor4.setGravity(false);
armor1.setHelmet(new ItemStack(Material.LEVER));
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());
carpetHight.setYaw(Utils.FaceToYaw(b));
//sitz
carpetHight = main.getNew(carpetHight, b, .25,.3);
Double d = .02;
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);
ArmorStand armorcarpet = (ArmorStand) w.spawnEntity(carpet, EntityType.ARMOR_STAND);
armorcarpet.setVisible(false);
armorcarpet.setGravity(false);
armorcarpet.setHelmet(is);
armorList.add(armorcarpet);
sitz.add(armorcarpet);
//OBERER TEIL
armorcarpet = (ArmorStand) w.spawnEntity(main.getNew(carpetHight, b, place-.25,(double) d), EntityType.ARMOR_STAND);
armorcarpet.setHeadPose(main.getNewEuler(b, 0.0, 1.57, .0));
armorcarpet.setVisible(false);
armorcarpet.setGravity(false);
armorcarpet.setHelmet(is);
armorList.add(armorcarpet);
if(d<=0D){d = 0.00;}
d+=.58;
}
Location last = main.getNew(sitz.get(sitz.size()-1).getLocation(), b, 0D, 0.26D);
Location first = main.getNew(new Location(loc.getWorld(), loc.getX(), last.getY(), loc.getZ()), b, place+.25, 0.0D);
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.setBasePlate(false);
RightCarpet.setBasePlate(false);
leftCarpet.setVisible(false);
RightCarpet.setVisible(false);
leftCarpet.setGravity(false);
RightCarpet.setGravity(false);
leftCarpet.setHelmet(is);
RightCarpet.setHelmet(is);
leftCarpet.setHeadPose(main.getNewEuler(b, 1.57, 0.0, 0.0));
RightCarpet.setHeadPose(main.getNewEuler(b, 1.57, 0.0, 0.0));
armorList.add(leftCarpet);
armorList.add(RightCarpet);
armorList.add(armor1);
armorList.add(armor2);
armorList.add(armor3);
armorList.add(armor4);
plugin.getServer().getPluginManager().registerEvents(this, plugin);
main.getInstance().sofas.add(this);
}
@EventHandler
public void onWaterFlow(BlockFromToEvent e){
Location locTo = e.getToBlock().getLocation();
if(location!=null && !location.isEmpty()){
if(location.contains(locTo) || location.contains(locTo.add(0,1,0))){
e.setCancelled(true);
}
}
}
@EventHandler
public void onHit(PlayerMoveEvent e){
Player p = e.getPlayer();
if(!p.isInsideVehicle() && location!=null){
if(location.contains(e.getTo().getBlock().getLocation()) || location.contains(e.getTo().getBlock().getLocation().add(0,-1,0))){
p.teleport(e.getFrom());
}
}
}
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();
}
location.clear();
armorList.clear();
main.getInstance().sofas.remove(this);
}
@EventHandler
public void onInteract(PlayerInteractAtEntityEvent e){
Player player = e.getPlayer();
if(e.getRightClicked() instanceof ArmorStand){
if(armorList.contains(e.getRightClicked())){
e.setCancelled(true);
ItemStack is = player.getItemInHand();
if(is!=null){
if(is.getType().equals(Material.INK_SACK)){
Short druability = is.getDurability();
Integer amount = is.getAmount();
if(amount>armorList.size() || player.getGameMode().equals(GameMode.CREATIVE)){amount=armorList.size();}
List<Entity> list = new ArrayList<Entity>();
for(Entity entity : armorList){
if(entity instanceof ArmorStand){
ArmorStand as = (ArmorStand) entity;
ItemStack item = as.getHelmet();
if(item.getDurability() != main.getFromDey(druability)){
list.add(entity);
}
}
}
for(int i = 0; i<=amount-1;i++){
Entity entity = list.get(i);
if(entity instanceof ArmorStand){
ArmorStand as = (ArmorStand) entity;
ItemStack item = as.getHelmet();
item.setDurability(main.getFromDey(druability));
as.setHelmet(item);
}
}
if(!player.getGameMode().equals(GameMode.CREATIVE)){
is.setAmount(is.getAmount()-amount);
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), is);
player.updateInventory();
}
}else if(sitz.contains(e.getRightClicked())){
e.getRightClicked().setPassenger(player);
}
}
}
}
}
@EventHandler
public void damage(EntityDamageByEntityEvent e){
if(e.getDamager() instanceof Player){
if(e.getEntity() instanceof ArmorStand){
if(armorList.contains(e.getEntity())){
delete();
}
}
}
}
}

View File

@ -0,0 +1,168 @@
package de.Ste3et_C0st.Furniture.Objects;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Effect;
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.block.BlockFromToEvent;
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 de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main;
public class stuhl implements Listener {
List<Entity> armorList = new ArrayList<Entity>();
Location loc = null;
public stuhl(Location loc, Plugin plugin){
this.loc = loc.getBlock().getLocation();
loc.add(1, 0, 0);
BlockFace b = Utils.yawToFace(loc.getYaw()).getOppositeFace();
Location center = Utils.getCenter(loc);
Location sitz = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
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));
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);
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(main.getNewEuler(b, .0, 1.55, .0));
armorList.add(as);
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();
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())){
p.teleport(e.getFrom());
}
}
}
@EventHandler
public void onInteract(PlayerInteractAtEntityEvent e){
Player player = e.getPlayer();
if(e.getRightClicked() instanceof ArmorStand){
if(armorList.contains(e.getRightClicked())){
e.setCancelled(true);
ItemStack is = player.getItemInHand();
if(is!=null){
if(armorList.contains(e.getRightClicked())){
armorList.get(0).setPassenger(player);
}
}
}
}
}
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();
}
this.loc = null;
armorList.clear();
main.getInstance().stuehle.remove(this);
}
@EventHandler
public void damage(EntityDamageByEntityEvent e){
if(e.getDamager() instanceof Player){
if(e.getEntity() instanceof ArmorStand){
if(armorList.contains(e.getEntity())){
delete();
}
}
}
}
}

View File

@ -0,0 +1,137 @@
package de.Ste3et_C0st.Furniture.Objects;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
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.block.BlockFromToEvent;
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;
import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main;
public class tisch implements Listener {
List<Entity> armorList = new ArrayList<Entity>();
ArmorStand armor;
ItemStack is;
Location loc = null;
public tisch(Location loc, Plugin plugin){
Location middle1 = Utils.getCenter(loc);
Location middle2 = Utils.getCenter(loc);
this.loc = middle1.getBlock().getLocation().add(1,0,0);
ArmorStand as = (ArmorStand) loc.getWorld().spawnEntity(middle1.add(1,-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(1,-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());
}
}
}
@EventHandler
public void onInteract(PlayerInteractAtEntityEvent e){
Player player = e.getPlayer();
if(e.getRightClicked() instanceof ArmorStand){
if(armorList.contains(e.getRightClicked())){
e.setCancelled(true);
ItemStack is = player.getItemInHand();
if(is!=null){
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;
}
}
}
}
}
public void delete(Boolean b){
if(is!=null&&b){
if(!is.getType().equals(Material.AIR)){
ArmorStand as = (ArmorStand) armorList.get(2);
as.getLocation().getWorld().dropItem(as.getLocation(), as.getItemInHand());
this.is = null;
}
}
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);
}
@EventHandler
public void damage(EntityDamageByEntityEvent e){
if(e.getDamager() instanceof Player){
if(e.getEntity() instanceof ArmorStand){
if(armorList.contains(e.getEntity())){
delete(true);
}
}
}
}
}

12
src/plugin.yml Normal file
View File

@ -0,0 +1,12 @@
name: Furniture
version: 0.1
description: DiceEquipment
author: Ste3et_C0st
website: http://dicecraft.de
main: de.Ste3et_C0st.Furniture.Main.main
commands:
Furniture:
description: test
usage: /<command>