Dicecraft Furniture Plugin

This commit is contained in:
BuildTools 2015-04-16 17:46:14 +02:00
parent 61571cc8d7
commit 06d0a98c48
16 changed files with 1251 additions and 648 deletions

View File

@ -3,6 +3,6 @@
<classpathentry kind="src" path="src"/> <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="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="lib" path="C:/Plugins/jars/spigot.jar"/>
<classpathentry kind="src" path="/DiceEaster"/> <classpathentry kind="lib" path="C:/Plugins/jars/Vault.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

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

View File

@ -3,7 +3,6 @@ package de.Ste3et_C0st.Furniture.Listener;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
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;
@ -13,11 +12,12 @@ import org.bukkit.inventory.ItemStack;
import de.Ste3et_C0st.Furniture.Main.Utils; import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main; import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.Furniture.Objects.largeTable; import de.Ste3et_C0st.Furniture.Objects.indoor.chair;
import de.Ste3et_C0st.Furniture.Objects.laterne; import de.Ste3et_C0st.Furniture.Objects.indoor.largeTable;
import de.Ste3et_C0st.Furniture.Objects.sofa; import de.Ste3et_C0st.Furniture.Objects.indoor.latern;
import de.Ste3et_C0st.Furniture.Objects.stuhl; import de.Ste3et_C0st.Furniture.Objects.indoor.sofa;
import de.Ste3et_C0st.Furniture.Objects.tisch; import de.Ste3et_C0st.Furniture.Objects.indoor.table;
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_1;
public class OnInteract implements Listener { public class OnInteract implements Listener {
@ -26,55 +26,24 @@ public class OnInteract implements Listener {
Player p = e.getPlayer(); Player p = e.getPlayer();
if(e.getItem() == null){return;} if(e.getItem() == null){return;}
if(e.getClickedBlock() == 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.getClickedBlock()==null){return;}
if(!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){return;} if(!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){return;}
ItemStack is = e.getItem();
if(!(is!=null&&is.hasItemMeta()&&is.getItemMeta().hasDisplayName())){return;}
Integer hand = p.getInventory().getHeldItemSlot(); Integer hand = p.getInventory().getHeldItemSlot();
Integer amount = is.getAmount(); 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")){ ItemStack saveIS = getItemStackCopy(is);
String noPermissions = ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.NoPermissions"));
if(saveIS.equals(main.getInstance().crafting.get("sofa"))){
if(!p.hasPermission("furniture.sofa")){p.sendMessage(noPermissions);return;}
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(), null, main.createRandomRegistryId());
if(!p.getGameMode().equals(GameMode.CREATIVE)){ if(!p.getGameMode().equals(GameMode.CREATIVE)){
is.setAmount(amount); is.setAmount(amount-1);
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(), 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(), null);
if(!p.getGameMode().equals(GameMode.CREATIVE)){
is.setAmount(amount);
p.getInventory().setItem(hand, is); p.getInventory().setItem(hand, is);
p.updateInventory(); p.updateInventory();
} }
@ -82,11 +51,64 @@ public class OnInteract implements Listener {
} }
} }
if(ChatColor.stripColor(is.getItemMeta().getDisplayName()).equalsIgnoreCase("tisch2")){ if(saveIS.equals(main.getInstance().crafting.get("lantern"))){
if(!p.hasPermission("furniture.lantern")){p.sendMessage(noPermissions);return;}
if(main.getInstance().canPlace(p, location, null, null)){ if(main.getInstance().canPlace(p, location, null, null)){
new largeTable(location, main.getInstance(), null, null); new latern(location, main.getInstance(), true, main.createRandomRegistryId());
if(!p.getGameMode().equals(GameMode.CREATIVE)){ if(!p.getGameMode().equals(GameMode.CREATIVE)){
is.setAmount(amount); is.setAmount(amount-1);
p.getInventory().setItem(hand, is);
p.updateInventory();
}
return;
}
}
if(saveIS.equals(main.getInstance().crafting.get("chair"))){
if(!p.hasPermission("furniture.chair")){p.sendMessage(noPermissions);return;}
if(main.getInstance().canPlace(p, location, null, null)){
new chair(location, main.getInstance(), main.createRandomRegistryId());
if(!p.getGameMode().equals(GameMode.CREATIVE)){
is.setAmount(amount-1);
p.getInventory().setItem(hand, is);
p.updateInventory();
}
return;
}
}
if(saveIS.equals(main.getInstance().crafting.get("table"))){
if(!p.hasPermission("furniture.table")){p.sendMessage(noPermissions);return;}
if(main.getInstance().canPlace(p, location, null, null)){
new table(location, main.getInstance(), null, main.createRandomRegistryId());
if(!p.getGameMode().equals(GameMode.CREATIVE)){
is.setAmount(amount-1);
p.getInventory().setItem(hand, is);
p.updateInventory();
}
return;
}
}
if(saveIS.equals(main.getInstance().crafting.get("largeTable"))){
if(!p.hasPermission("furniture.largetable")){p.sendMessage(noPermissions);return;}
if(main.getInstance().canPlaceLarge(p, location, Utils.yawToFace(location.getYaw()).getOppositeFace(), 3,3)){
new largeTable(location, main.getInstance(), null, null, main.createRandomRegistryId());
if(!p.getGameMode().equals(GameMode.CREATIVE)){
is.setAmount(amount-1);
p.getInventory().setItem(hand, is);
p.updateInventory();
}
return;
}
}
if(saveIS.equals(main.getInstance().crafting.get("tent1"))){
if(!p.hasPermission("furniture.tent1")){p.sendMessage(noPermissions);return;}
if(main.getInstance().canPlaceTent(p, location, Utils.yawToFace(location.getYaw()).getOppositeFace(), 5,4, 3)){
new tent_1(location, main.getInstance(), main.createRandomRegistryId());
if(!p.getGameMode().equals(GameMode.CREATIVE)){
is.setAmount(amount-1);
p.getInventory().setItem(hand, is); p.getInventory().setItem(hand, is);
p.updateInventory(); p.updateInventory();
} }
@ -94,4 +116,12 @@ public class OnInteract implements Listener {
} }
} }
} }
public ItemStack getItemStackCopy(ItemStack is){
ItemStack copy = new ItemStack(is.getType());
copy.setAmount(1);
copy.setDurability(is.getDurability());
copy.setItemMeta(is.getItemMeta());
return copy;
}
} }

View File

@ -1,47 +0,0 @@
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

@ -1,28 +1,35 @@
package de.Ste3et_C0st.Furniture.Main; package de.Ste3et_C0st.Furniture.Main;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.inventory.meta.LeatherArmorMeta;
import de.Ste3et_C0st.DiceEaster.config; import de.Ste3et_C0st.Furniture.Main.config;
import de.Ste3et_C0st.Furniture.Objects.laterne; import de.Ste3et_C0st.Furniture.Objects.indoor.chair;
import de.Ste3et_C0st.Furniture.Objects.stuhl; import de.Ste3et_C0st.Furniture.Objects.indoor.largeTable;
import de.Ste3et_C0st.Furniture.Objects.tisch; import de.Ste3et_C0st.Furniture.Objects.indoor.latern;
import de.Ste3et_C0st.Furniture.Objects.indoor.sofa;
import de.Ste3et_C0st.Furniture.Objects.indoor.table;
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_1;
public class Manager { public class Manager {
private static config cc; private static config cc;
private static FileConfiguration fc; private static FileConfiguration fc;
private String folder = "/furniture/"; private String folder = "/objects/";
public void loadStuhl(){ public void loadStuhl(){
cc = new config(); cc = new config();
@ -34,14 +41,15 @@ public class Manager {
path+= "." + s; path+= "." + s;
Double x = fc.getDouble(path+".Location.x"); Double x = fc.getDouble(path+".Location.x");
Double y = fc.getDouble(path+".Location.x"); Double y = fc.getDouble(path+".Location.y");
Double z = fc.getDouble(path+".Location.x"); Double z = fc.getDouble(path+".Location.z");
World w = Bukkit.getWorld(fc.getString(path+".Location.w")); World w = Bukkit.getWorld(fc.getString(path+".Location.w"));
Float yaw = (float) fc.getInt(fc.getString(path+".Location.Yaw")); String face = fc.getString(path+".Location.face");
float yaw = Utils.FaceToYaw(Utils.StringToFace(face));
Location l = new Location(w, x, y, z); Location l = new Location(w, x, y, z);
l.setYaw(yaw); l.setYaw(yaw);
new stuhl(l, main.getInstance()); new chair(l, main.getInstance(), s);
} }
} }
} }
@ -49,28 +57,28 @@ public class Manager {
public void loadLatern(){ public void loadLatern(){
cc = new config(); cc = new config();
if(cc.ExistConfig(folder, "latern.yml")){ if(cc.ExistConfig(folder, "lantern.yml")){
fc = cc.getConfig("latern.yml", folder); fc = cc.getConfig("lantern.yml", folder);
if(fc.isSet("Furniture.latern")){ if(fc.isSet("Furniture.lantern")){
for(String s : fc.getConfigurationSection("Furniture.latern").getKeys(false)){ for(String s : fc.getConfigurationSection("Furniture.lantern").getKeys(false)){
String path = "Furniture.latern"; String path = "Furniture.lantern";
path+= "." + s; path+= "." + s;
Double x = fc.getDouble(path+".Location.x"); Double x = fc.getDouble(path+".Location.x");
Double y = fc.getDouble(path+".Location.x"); Double y = fc.getDouble(path+".Location.y");
Double z = fc.getDouble(path+".Location.x"); Double z = fc.getDouble(path+".Location.z");
World w = Bukkit.getWorld(fc.getString(path+".Location.w")); World w = Bukkit.getWorld(fc.getString(path+".Location.w"));
Float yaw = (float) fc.getInt(fc.getString(path+".Location.Yaw")); String face = fc.getString(path+".Location.face");
Boolean b = fc.getBoolean(path+".settings.Light"); Boolean b = fc.getBoolean(path+".settings.Light");
Location l = new Location(w, x, y, z); Location l = new Location(w, x, y, z);
float yaw = Utils.FaceToYaw(Utils.StringToFace(face));
l.setYaw(yaw); l.setYaw(yaw);
new laterne(l, main.getInstance(), b); new latern(l, main.getInstance(), b, s);
} }
} }
} }
} }
@SuppressWarnings("deprecation")
public void loadTisch(){ public void loadTisch(){
cc = new config(); cc = new config();
if(cc.ExistConfig(folder, "table.yml")){ if(cc.ExistConfig(folder, "table.yml")){
@ -81,47 +89,404 @@ public class Manager {
path+= "." + s; path+= "." + s;
Double x = fc.getDouble(path+".Location.x"); Double x = fc.getDouble(path+".Location.x");
Double y = fc.getDouble(path+".Location.x"); Double y = fc.getDouble(path+".Location.y");
Double z = fc.getDouble(path+".Location.x"); Double z = fc.getDouble(path+".Location.z");
World w = Bukkit.getWorld(fc.getString(path+".Location.w")); World w = Bukkit.getWorld(fc.getString(path+".Location.w"));
Float yaw = (float) fc.getInt(fc.getString(path+".Location.Yaw")); String face = fc.getString(path+".Location.face");
Location l = new Location(w, x, y, z); Location l = new Location(w, x, y, z);
float yaw = Utils.FaceToYaw(Utils.StringToFace(face));
l.setYaw(yaw); l.setYaw(yaw);
ItemStack is = getItemStack(fc, path+".settings.ItemStack");
new table(l, main.getInstance(), is, s);
}
}
}
}
@SuppressWarnings("deprecation")
public ItemStack getItemStack(FileConfiguration fc, String s){
String path = s;
ItemStack is = null; ItemStack is = null;
if(fc.isSet(path+".settings.ItemStack")){ if(fc.isSet(path)){
Material m = Material.getMaterial(fc.getInt(path+".settings.ItemStack.Material")); Material m = Material.getMaterial(fc.getInt(path+".material"));
Short subID = (short) fc.getInt(path+".settings.ItemStack.Durability"); Short subID = (short) fc.getInt(path+".durability");
Integer amount = fc.getInt(path+".settings.ItemStack.Amount"); Integer amount = fc.getInt(path+".amount");
is = new ItemStack(m,amount,subID); is = new ItemStack(m,amount,subID);
ItemMeta im = is.getItemMeta(); ItemMeta im = is.getItemMeta();
List<String> lore = new ArrayList<String>(); List<String> lore = new ArrayList<String>();
if(fc.isSet(path+".settings.ItemStack.Lore")){ if(fc.isSet(path+".lore")){
lore = fc.getStringList(path+".settings.ItemStack.Lore"); lore = fc.getStringList(path+".lore");
im.setLore(lore); im.setLore(lore);
} }
if(fc.isSet(path+".settings.ItemStack.Enchantment")){ if(fc.isSet(path+".displayName")){
for(String enchant : fc.getConfigurationSection(path+".settings.ItemStack.Enchantment").getKeys(false)){ im.setDisplayName(fc.getString(path+".displayName"));
}
if(fc.isSet(path+".Enchantment")){
for(String enchant : fc.getConfigurationSection(path+".Enchantment").getKeys(false)){
Enchantment en = Enchantment.getByName(enchant); Enchantment en = Enchantment.getByName(enchant);
im.addEnchant(en, fc.getInt(path+".settings.ItemStack.Enchantment." + enchant + ".id"), true); im.addEnchant(en, fc.getInt(path+".Enchantment." + enchant + ".lvl"), true);
} }
} }
is.setItemMeta(im); is.setItemMeta(im);
if(is.getItemMeta() instanceof LeatherArmorMeta){ if(is.getItemMeta() instanceof LeatherArmorMeta){
LeatherArmorMeta lim = (LeatherArmorMeta) is.getItemMeta(); LeatherArmorMeta lim = (LeatherArmorMeta) is.getItemMeta();
if(fc.isSet(path+".settings.ItemStack.LeatherMeta")){ if(fc.isSet(path+".LeatherMeta")){
lim.setColor(Color.fromBGR( lim.setColor(Color.fromBGR(
fc.getInt(path+".settings.ItemStack.LeatherMeta.Color.blue"), fc.getInt(path+".LeatherMeta.Color.blue"),
fc.getInt(path+".settings.ItemStack.LeatherMeta.Color.green"), fc.getInt(path+".LeatherMeta.Color.green"),
fc.getInt(path+".settings.ItemStack.LeatherMeta.Color.red"))); fc.getInt(path+".LeatherMeta.Color.red")));
} }
is.setItemMeta(lim); is.setItemMeta(lim);
} }
} }
new tisch(l, main.getInstance(), is); return is;
}
public List<ItemStack> getList(FileConfiguration fc, String s){
List<ItemStack> itemlist = new ArrayList<ItemStack>();
if(fc.isSet(s)){
for(String string : fc.getConfigurationSection(s).getKeys(false)){
ItemStack is = new ItemStack(Material.getMaterial(fc.getString(s+"."+string+".material")));
ItemMeta im = is.getItemMeta();
im.setDisplayName(main.createRandomRegistryId());
is.setDurability((short) fc.getInt(s+"."+string+".durability"));
is.setItemMeta(im);
itemlist.add(is);
}
}
return itemlist;
}
public void loadLargeTisch(){
cc = new config();
if(cc.ExistConfig(folder, "largeTable.yml")){
fc = cc.getConfig("largeTable.yml", folder);
if(fc.isSet("Furniture.largeTable")){
for(String s : fc.getConfigurationSection("Furniture.largeTable").getKeys(false)){
String path = "Furniture.largeTable";
path+= "." + s;
Double x = fc.getDouble(path+".Location.x");
Double y = fc.getDouble(path+".Location.y");
Double z = fc.getDouble(path+".Location.z");
World w = Bukkit.getWorld(fc.getString(path+".Location.w"));
String face = fc.getString(path+".Location.face");
Location l = new Location(w, x, y, z);
float yaw = Utils.FaceToYaw(Utils.StringToFace(face));
l.setYaw(yaw);
HashMap<Integer, ItemStack> teller = new HashMap<Integer, ItemStack>();
teller.put(0, getItemStack(fc, path+".settings.ItemStack_place1"));
teller.put(1, getItemStack(fc, path+".settings.ItemStack_place2"));
teller.put(2, getItemStack(fc, path+".settings.ItemStack_place3"));
teller.put(3, getItemStack(fc, path+".settings.ItemStack_place4"));
new largeTable(l, main.getInstance(), getList(fc, path+".settings.ColorManager"), teller, s);
} }
} }
} }
} }
public void loadSofa(){
cc = new config();
if(cc.ExistConfig(folder, "sofa.yml")){
fc = cc.getConfig("sofa.yml", folder);
if(fc.isSet("Furniture.sofa")){
for(String s : fc.getConfigurationSection("Furniture.sofa").getKeys(false)){
String path = "Furniture.sofa";
path+= "." + s;
Double x = fc.getDouble(path+".Location.x");
Double y = fc.getDouble(path+".Location.y");
Double z = fc.getDouble(path+".Location.z");
World w = Bukkit.getWorld(fc.getString(path+".Location.w"));
String face = fc.getString(path+".Location.face");
Location l = new Location(w, x, y, z);
float yaw = Utils.FaceToYaw(Utils.StringToFace(face));
l.setYaw(yaw);
new sofa(l, 3, main.getInstance(), getList(fc, path+".settings.ColorManager"), s);
}
}
}
}
public void loadtent1(){
cc = new config();
if(cc.ExistConfig(folder, "tent1.yml")){
fc = cc.getConfig("tent1.yml", folder);
if(fc.isSet("Furniture.tent1")){
for(String s : fc.getConfigurationSection("Furniture.tent1").getKeys(false)){
String path = "Furniture.tent1";
path+= "." + s;
Double x = fc.getDouble(path+".Location.x");
Double y = fc.getDouble(path+".Location.y");
Double z = fc.getDouble(path+".Location.z");
World w = Bukkit.getWorld(fc.getString(path+".Location.w"));
String face = fc.getString(path+".Location.face");
Location l = new Location(w, x, y, z);
float yaw = Utils.FaceToYaw(Utils.StringToFace(face));
l.setYaw(yaw);
new tent_1(l, main.getInstance(), s);
}
}
}
}
public void saveStuhl(){
cc = new config();
fc = cc.getConfig("chair.yml",folder );
if(!main.getInstance().stuehle.isEmpty()){
String path = "Furniture.chair";
for(chair s : main.getInstance().stuehle){
path = "Furniture.chair."+s.getID();
fc.set(path+".Location.x",round(s.getLocation().getX(), 2));
fc.set(path+".Location.y",round(s.getLocation().getY(), 2));
fc.set(path+".Location.z",round(s.getLocation().getZ(), 2));
fc.set(path+".Location.w", s.getLocation().getWorld().getName());
fc.set(path+".Location.face", s.getBlockFace().name());
}
cc.saveConfig("chair.yml", fc, folder);
}
}
public void saveLatern(){
cc = new config();
fc = cc.getConfig("lantern.yml",folder );
if(!main.getInstance().laternen.isEmpty()){
String path = "Furniture.lantern";
for(latern s : main.getInstance().laternen){
path = "Furniture.lantern."+s.getID();
fc.set(path+".Location.x",round(s.getLocation().getX(), 2));
fc.set(path+".Location.y",round(s.getLocation().getY(), 2));
fc.set(path+".Location.z",round(s.getLocation().getZ(), 2));
fc.set(path+".Location.w", s.getLocation().getWorld().getName());
fc.set(path+".Location.face", s.getBlockFace().name());
fc.set(path+".settings.Light", s.getBlockState());
}
cc.saveConfig("lantern.yml", fc, folder);
}
}
public void saveSofa(){
cc = new config();
fc = cc.getConfig("sofa.yml",folder );
if(!main.getInstance().sofas.isEmpty()){
String path = "Furniture.sofa";
for(sofa s : main.getInstance().sofas){
path = "Furniture.sofa."+s.getID();
fc.set(path+".Location.x",round(s.getLocation().getX(), 2));
fc.set(path+".Location.y",round(s.getLocation().getY(), 2));
fc.set(path+".Location.z",round(s.getLocation().getZ(), 2));
fc.set(path+".Location.w", s.getLocation().getWorld().getName());
fc.set(path+".Location.face", s.getBlockFace().name());
if(!s.getItemListTisch().isEmpty()){
int l = 0;
for(ItemStack is : s.getItemListTisch()){
fc.set(path+".settings.ColorManager." + l + ".material", is.getType().name());
fc.set(path+".settings.ColorManager." + l + ".durability", is.getDurability());
l++;
}
}
}
cc.saveConfig("sofa.yml", fc, folder);
}
}
public void saveItem(FileConfiguration fc, String s, ItemStack is){
fc.set(s+".material", is.getType().name());
fc.set(s+".durability", is.getDurability());
fc.set(s+".amount", is.getAmount());
if(is.hasItemMeta()){
if(is.getItemMeta().hasDisplayName()){fc.set(s+".displayName", is.getType().name());}
if(is.getItemMeta().hasLore()){fc.set(s+".lore", is.getItemMeta().getLore());}
if(!is.getEnchantments().isEmpty()){
for(Enchantment e : is.getEnchantments().keySet()){
fc.set(s+".Enchantment." + e.getName() + ".lvl", e.getStartLevel());
}
}
if(is.getItemMeta() instanceof LeatherArmorMeta){
LeatherArmorMeta lm = (LeatherArmorMeta) is.getItemMeta();
fc.set(s+".LeatherMeta.Color.blue", lm.getColor().getBlue());
fc.set(s+".LeatherMeta.Color.green", lm.getColor().getGreen());
fc.set(s+".LeatherMeta.Color.red", lm.getColor().getRed());
}
}
}
public void saveTable(){
cc = new config();
fc = cc.getConfig("table.yml",folder );
if(!main.getInstance().tische.isEmpty()){
String path = "Furniture.table";
for(table s : main.getInstance().tische){
path = "Furniture.table."+s.getID();
fc.set(path+".Location.x",round(s.getLocation().getX(), 2));
fc.set(path+".Location.y",round(s.getLocation().getY(), 2));
fc.set(path+".Location.z",s.getLocation().getZ());
fc.set(path+".Location.w", s.getLocation().getWorld().getName());
fc.set(path+".Location.face", s.getBlockFace().name());
if(s.getItemStack()!=null){
saveItem(fc, path, s.getItemStack());
}
}
cc.saveConfig("table.yml", fc, folder);
}
}
public void saveTent1(){
cc = new config();
fc = cc.getConfig("tent1.yml",folder );
if(!main.getInstance().tents1.isEmpty()){
String path = "Furniture.tent1";
for(tent_1 s : main.getInstance().tents1){
path = "Furniture.tent1."+s.getID();
fc.set(path+".Location.x",round(s.getLocation().getX(), 2));
fc.set(path+".Location.y",round(s.getLocation().getY(), 2));
fc.set(path+".Location.z",round(s.getLocation().getZ(), 2));
fc.set(path+".Location.w", s.getLocation().getWorld().getName());
fc.set(path+".Location.face", s.getBlockFace().name());
}
cc.saveConfig("tent1.yml", fc, folder);
}
}
public void saveLargeTable(){
cc = new config();
fc = cc.getConfig("largeTable.yml",folder );
if(!main.getInstance().tische2.isEmpty()){
String path = "Furniture.largeTable";
for(largeTable s : main.getInstance().tische2){
path = "Furniture.largeTable."+s.getID();
fc.set(path+".Location.x",round(s.getLocation().getX(), 2));
fc.set(path+".Location.y",round(s.getLocation().getY(), 2));
fc.set(path+".Location.z",round(s.getLocation().getZ(), 2));
fc.set(path+".Location.w", s.getLocation().getWorld().getName());
fc.set(path+".Location.face", s.getBlockFace().name());
if(!s.getItemListTisch().isEmpty()){
int l = 0;
for(ItemStack is : s.getItemListTisch()){
fc.set(path+".settings.ColorManager." + l + ".material", is.getType().name());
fc.set(path+".settings.ColorManager." + l + ".durability", is.getDurability());
l++;
}
}
if(!s.getTeller().isEmpty()){
for(int l=0;l<=3;l++ ){
try{
ItemStack is = s.getTeller().get(l);
saveItem(fc, path, is);
}catch(Exception e){
ItemStack is = new ItemStack(Material.AIR);
saveItem(fc, path, is);
}
}
}
}
cc.saveConfig("largeTable.yml", fc, folder);
}
}
public void deleteFromConfig(String ID, String type){
cc = new config();
if(cc.ExistConfig(folder, type+".yml")){
fc = cc.getConfig(type, folder);
if(fc.isSet("Furniture." + type + "." + ID)){
fc.set("Furniture." + type + "." + ID, null);
}
cc.saveConfig(type, fc, folder);
}
}
public static double round(double value, int places) {
if (places < 0) throw new IllegalArgumentException();
long factor = (long) Math.pow(10, places);
value = value * factor;
long tmp = Math.round(value);
return (double) tmp / factor;
}
@SuppressWarnings("deprecation")
public void defaultCrafting(){
cc = new config();
fc = cc.getConfig("crafting.yml", "");
fc.addDefaults(YamlConfiguration.loadConfiguration(main.getInstance().getResource("crafting.yml")));
fc.options().copyDefaults(true);
cc.saveConfig("crafting.yml", fc, "");
}
public void loadCrafting(String s){
ShapedRecipe recipe = new ShapedRecipe(returnResult(s)).shape(returnFragment(s)[0], returnFragment(s)[1], returnFragment(s)[2]);
for(Character c : returnMaterial(s).keySet()){
if(!returnMaterial(s).get(c).equals(Material.AIR)){
recipe.setIngredient(c.charValue(), returnMaterial(s).get(c));
}
}
main.getInstance().getServer().addRecipe(recipe);
main.getInstance().crafting.put(s, returnResult(s));
}
@SuppressWarnings("deprecation")
public ItemStack returnResult(String s){
cc = new config();
fc = cc.getConfig("crafting.yml", "");
String path = "Items." + s;
Integer MaterialID = fc.getInt(path+".material");
Short shor = (short) fc.getInt(path+".durability");
ItemStack is = new ItemStack(Material.getMaterial(MaterialID));
ItemMeta im = is.getItemMeta();
im.setDisplayName(ChatColor.translateAlternateColorCodes('&', fc.getString(path+".name")));
is.setItemMeta(im);
is.setDurability(shor);
is.setAmount(1);
return is;
}
public String[] returnFragment(String s){
cc = new config();
fc = cc.getConfig("crafting.yml", "");
String path = "Items." + s;
String recipe = fc.getString(path+".crafting.recipe");
String[] fragments = recipe.split(",");
return fragments;
}
public List<String> returnCharacters(String s){
List<String> stringList = new ArrayList<String>();
for(String str: returnFragment(s)){
String[] sl = str.split("(?!^)");
for(String o : sl){
if(!stringList.contains(o)){
stringList.add(o);
}
}
}
return stringList;
}
@SuppressWarnings("deprecation")
public HashMap<Character,Material> returnMaterial(String s){
cc = new config();
fc = cc.getConfig("crafting.yml", "");
String path = "Items." + s;
List<String> stringList = returnCharacters(s);
HashMap<Character, Material> materialHash = new HashMap<Character, Material>();
for(String str : stringList){
Character chars = str.charAt(0);
Integer MaterialID = fc.getInt(path+".crafting.index." + str);
Material material = Material.getMaterial(MaterialID);
materialHash.put(chars, material);
}
return materialHash;
}
} }

View File

@ -1,6 +1,7 @@
package de.Ste3et_C0st.Furniture.Main; package de.Ste3et_C0st.Furniture.Main;
import java.util.List; import java.util.List;
import java.util.Random;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -29,7 +30,22 @@ public class Utils {
} }
} }
//NORDEN GEHT public static BlockFace StringToFace(final String face) {
switch (face) {
case "NORTH": return BlockFace.NORTH;
case "EAST": return BlockFace.EAST;
case "SOUTH": return BlockFace.SOUTH;
case "WEST": return BlockFace.WEST;
default: return BlockFace.NORTH;
}
}
public static int randInt(int min, int max) {
Random rand = new Random();
int randomNum = rand.nextInt((max - min) + 1) + min;
return randomNum;
}
public static EulerAngle FaceEuler(final BlockFace face, Double x, Double y, Double z) { public static EulerAngle FaceEuler(final BlockFace face, Double x, Double y, Double z) {
return new EulerAngle(x,y,z); return new EulerAngle(x,y,z);
} }
@ -47,14 +63,13 @@ public class Utils {
return d; return d;
} }
public static ArmorStand setArmorStand(Location location, EulerAngle angle, ItemStack is, Boolean Arm, List<Entity> entityList, List<Location> locationList){ public static ArmorStand setArmorStand(Location location, EulerAngle angle, ItemStack is, Boolean Arm, String ID, List<String> idList){
World w = location.getWorld(); World w = location.getWorld();
String id = ID+"-"+idList.size();
for(Entity entity : w.getEntities()){ for(Entity entity : w.getEntities()){
if(entity instanceof ArmorStand){ if(entity instanceof ArmorStand){
if(location.equals(entity.getLocation())){ if(entity.getCustomName().equals(id)){
entityList.add(entity); idList.add(id);
if(locationList!=null){locationList.add(location);}
return (ArmorStand) entity; return (ArmorStand) entity;
} }
} }
@ -71,8 +86,19 @@ public class Utils {
as.setVisible(false); as.setVisible(false);
as.setGravity(false); as.setGravity(false);
as.setBasePlate(false); as.setBasePlate(false);
entityList.add(as); as.setCustomName(id);
if(locationList!=null){locationList.add(location);} idList.add(id);
return as; return as;
} }
public static ArmorStand getArmorStandAtID(World w, String string){
for(Entity e : w.getEntities()){
if(e instanceof ArmorStand){
if(e.getCustomName().equalsIgnoreCase(string)){
return (ArmorStand) e;
}
}
}
return null;
}
} }

View File

@ -1,25 +1,97 @@
package de.Ste3et_C0st.Furniture.Main; package de.Ste3et_C0st.Furniture.Main;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class command implements CommandExecutor { public class command implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender arg0, Command arg1, String arg2,String[] arg3) { public boolean onCommand(CommandSender sender, Command cmd, String arg2, String[] args) {
if(arg0 instanceof Player == false){return true;} if(cmd.getName().equalsIgnoreCase("furniture")){
Player p = (Player) arg0; String noPermissions = ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.NoPermissions"));
if(arg1.getName().equalsIgnoreCase("Furniture")){ String notFound = ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.notFound"));
p.getInventory().addItem(main.getInstance().itemse.Sofa); String PlayerNotFound = ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.PlayerNotFound"));
p.getInventory().addItem(main.getInstance().itemse.Laterne); String help = "§7================[§2Furniture§7]================\n";
p.getInventory().addItem(main.getInstance().itemse.stuhl); help += "§2/furniture list | §8list all available furniture\n";
p.getInventory().addItem(main.getInstance().itemse.tisch); help += "§2/furniture give <PLAYER> <FURNITURE> | §8give one player one furniture\n";
p.getInventory().addItem(main.getInstance().itemse.tisch2);
if(sender instanceof Player){
help += "§2/furniture give <FURNITURE> | §8give you an furniture\n";
if(args.length == 2){
if(args[0].equalsIgnoreCase("give")){
if(!sender.hasPermission("furniture.give")){sender.sendMessage(noPermissions);return true;}
if(isExist(args[1])){
if(!sender.hasPermission("furniture.give." + args[1].toLowerCase())){sender.sendMessage(noPermissions);return true;}
((Player) sender).getInventory().addItem(getIS(args[1]));
return true;
}else{
sender.sendMessage(notFound);
return true;
}
}else{
sender.sendMessage(help);
return true;
}
}
}
help += "§7=========================================";
if(args.length == 1){
if(args[0].equalsIgnoreCase("list")){
if(sender.hasPermission("furniture.list")){
sender.sendMessage("§7Furniture: ");
for(String a : main.getInstance().crafting.keySet()){
sender.sendMessage("§6- " + a);
}
return true;
}else{
sender.sendMessage(noPermissions);
return true;
}
}else{
sender.sendMessage(help);
}
}else if(args.length == 3){
if(args[0].equalsIgnoreCase("give")){
if(!sender.hasPermission("furniture.give")){sender.sendMessage(noPermissions);return true;}
if(!isExist(args[2])){sender.sendMessage(notFound);return true;}
if(!Bukkit.getPlayer(args[1]).isOnline()){sender.sendMessage(PlayerNotFound);return true;}
Player player = Bukkit.getPlayer(args[1]);
player.getInventory().addItem(getIS(args[2]));
return true;
}else{
sender.sendMessage(help);
return true;
}
}else{
sender.sendMessage(help);
return true;
}
} }
return false; return false;
} }
public boolean isExist(String s){
for(String a : main.getInstance().crafting.keySet()){
if(a.equalsIgnoreCase(s)){
return true;
}
}
return false;
}
public ItemStack getIS(String s ){
for(String a : main.getInstance().crafting.keySet()){
if(a.equalsIgnoreCase(s)){
return main.getInstance().crafting.get(a);
}
}
return null;
}
} }

View File

@ -15,7 +15,7 @@ public class config
public config() public config()
{ {
this.path = "plugins/DiceEaster"; this.path = "plugins/Furniture/";
} }
public FileConfiguration createConfig(String name, String Folder) public FileConfiguration createConfig(String name, String Folder)
@ -75,7 +75,6 @@ public class config
} }
public boolean ExistConfig(String folder, String name){ public boolean ExistConfig(String folder, String name){
System.out.print(path + folder + "," + name);
if(new File(path + folder, name).exists()){ if(new File(path + folder, name).exists()){
return true; return true;
} }

View File

@ -1,73 +1,89 @@
package de.Ste3et_C0st.Furniture.Main; package de.Ste3et_C0st.Furniture.Main;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Random;
import net.milkbowl.vault.Metrics;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ShapedRecipe; import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.EulerAngle; import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.DiceEaster.DiceEaster; import de.Ste3et_C0st.Furniture.Main.Manager;
import de.Ste3et_C0st.Furniture.Listener.OnInteract; import de.Ste3et_C0st.Furniture.Listener.OnInteract;
import de.Ste3et_C0st.Furniture.Objects.largeTable; import de.Ste3et_C0st.Furniture.Objects.indoor.chair;
import de.Ste3et_C0st.Furniture.Objects.laterne; import de.Ste3et_C0st.Furniture.Objects.indoor.largeTable;
import de.Ste3et_C0st.Furniture.Objects.sofa; import de.Ste3et_C0st.Furniture.Objects.indoor.latern;
import de.Ste3et_C0st.Furniture.Objects.stuhl; import de.Ste3et_C0st.Furniture.Objects.indoor.sofa;
import de.Ste3et_C0st.Furniture.Objects.tisch; import de.Ste3et_C0st.Furniture.Objects.indoor.table;
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_1;
public class main extends JavaPlugin { public class main extends JavaPlugin {
private static main Main; private static main Main;
public List<sofa> sofas = new ArrayList<sofa>(); public List<sofa> sofas = new ArrayList<sofa>();
public List<laterne> laternen = new ArrayList<laterne>(); public List<latern> laternen = new ArrayList<latern>();
public List<stuhl> stuehle = new ArrayList<stuhl>(); public List<chair> stuehle = new ArrayList<chair>();
public List<tisch> tische = new ArrayList<tisch>(); public List<table> tische = new ArrayList<table>();
public List<largeTable> tische2 = new ArrayList<largeTable>(); public List<largeTable> tische2 = new ArrayList<largeTable>();
public ItemsEquipment itemse; public HashMap<String, ItemStack> crafting = new HashMap<String, ItemStack>();
public DiceEaster dice; public Manager mgr;
public List<tent_1> tents1 = new ArrayList<tent_1>();
@SuppressWarnings("deprecation")
@Override @Override
public void onEnable(){ public void onEnable(){
getCommand("Furniture").setExecutor(new command());
Main = this; Main = this;
this.itemse = new ItemsEquipment();
getServer().getPluginManager().registerEvents(new OnInteract(), this); getServer().getPluginManager().registerEvents(new OnInteract(), this);
dice = (DiceEaster) getServer().getPluginManager().getPlugin("DiceEaster"); getCommand("furniture").setExecutor(new command());
getConfig().addDefaults(YamlConfiguration.loadConfiguration(getResource("config.yml")));
getConfig().options().copyDefaults(true);
saveConfig();
if(getServer().getPluginManager().isPluginEnabled("Vault") && getConfig().getBoolean("config.UseMetrics")){
try
{
Metrics metrics = new Metrics(this);
metrics.start();
}
catch (IOException localIOException) {}
}
this.mgr = new Manager();
mgr.loadLargeTisch();
mgr.loadLatern();
mgr.loadSofa();
mgr.loadStuhl();
mgr.loadTisch();
mgr.loadtent1();
mgr.defaultCrafting();
addCrafting(); addCrafting();
} }
@Override @Override
public void onDisable(){ public void onDisable(){
mgr.saveLargeTable();
mgr.saveLatern();
mgr.saveSofa();
mgr.saveStuhl();
mgr.saveTable();
mgr.saveTent1();
getServer().resetRecipes();
} }
public void addCrafting(){ public void addCrafting(){
ShapedRecipe grinderRecipe = new ShapedRecipe(itemse.Sofa).shape("#0#", "###", "+0+").setIngredient('+', Material.FENCE). mgr.loadCrafting("largeTable");
setIngredient('#', Material.WOOL); mgr.loadCrafting("table");
getServer().addRecipe(grinderRecipe); mgr.loadCrafting("lantern");
mgr.loadCrafting("sofa");
grinderRecipe = new ShapedRecipe(itemse.Laterne).shape("0#0", "-+-", "0E0").setIngredient('+', Material.TORCH). mgr.loadCrafting("chair");
setIngredient('#', Material.WOOD_PLATE).setIngredient('-', Material.STICK).setIngredient('E', Material.OBSIDIAN); mgr.loadCrafting("tent1");
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);
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) {
@ -154,5 +170,98 @@ public class main extends JavaPlugin {
return true; return true;
} }
public static main getInstance() {return Main;} public boolean canPlaceLarge(Player p, Location location, BlockFace b, Integer length, Integer width){
if(b==null&&length==null&&width==null){
if(!location.getBlock().getType().equals(Material.AIR)){
return false;
}
}
location = main.getNew(location, b.getOppositeFace(), 2D, 0D);
if(b!=null&&length!=null&&width!=null){
for(int i = 0; i<= length-1; i++){
for(int l = 0; l<= width-1; l++){
if(!getNew(location, b,(double) l,(double) i).getBlock().getType().equals(Material.AIR)){
return false;
}
}
}
}
return true;
}
public List<Location> getFunList(){
List<Location> loc = new ArrayList<Location>();
if(!this.stuehle.isEmpty()){
for(chair s : stuehle){
loc.add(s.getLocation());
}
}
if(!this.laternen.isEmpty()){
for(latern l : laternen){
loc.add(l.getLocation());
}
}
if(!this.tische2.isEmpty()){
for(largeTable l : tische2){
loc.add(l.getLocation());
}
}
if(!this.sofas.isEmpty()){
for(sofa s : sofas){
loc.add(s.getLocation());
}
}
if(!this.tische.isEmpty()){
for(table t : tische){
loc.add(t.getLocation());
}
}
return loc;
}
public static String createRandomRegistryId()
{
String val = "";
int ranChar = 65 + (new Random()).nextInt(90-65);
char ch = (char)ranChar;
val += ch;
Random r = new Random();
int numbers = 100000 + (int)(r.nextFloat() * 899900);
val += String.valueOf(numbers);
val += "-";
for(int i = 0; i<6;){
int ranAny = 48 + (new Random()).nextInt(90-65);
if(!(57 < ranAny && ranAny<= 65)){
char c = (char)ranAny;
val += c;
i++;
}
}
return val;
}
public static main getInstance() {return Main;}
public boolean canPlaceTent(Player p, Location location, BlockFace b, Integer length, Integer width, Integer height){
if(b==null&&length==null&&width==null){
if(!location.getBlock().getType().equals(Material.AIR)){
return false;
}
}
location = main.getNew(location, b.getOppositeFace(), 3D, 0D);
if(b!=null&&length!=null&&width!=null){
for(int i = 0; i<= length-1; i++){
for(int l = 0; l<= width-1; l++){
for(int y=0;y<=height-1;y++){
if(!getNew(location, b,(double) l,(double) i).add(0,y,0).getBlock().getType().equals(Material.AIR)){
return false;
}
}
}
}
}
return true;
}
} }

View File

@ -1,4 +1,4 @@
package de.Ste3et_C0st.Furniture.Objects; package de.Ste3et_C0st.Furniture.Objects.indoor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -6,11 +6,12 @@ import java.util.List;
import org.bukkit.Effect; import org.bukkit.Effect;
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.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -22,17 +23,22 @@ import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Main.Utils; import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main; import de.Ste3et_C0st.Furniture.Main.main;
public class stuhl implements Listener { public class chair implements Listener {
List<Entity> armorList = new ArrayList<Entity>(); List<String> IDList = new ArrayList<String>();
Location loc = null; Location loc = null;
BlockFace b = null; BlockFace b = null;
World w = null;
private String id;
public String getID(){return this.id;}
public Location getLocation(){return this.loc;} public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;} public BlockFace getBlockFace(){return this.b;}
public stuhl(Location loc, Plugin plugin){ public chair(Location loc, Plugin plugin, String id){
this.loc = loc.getBlock().getLocation(); this.loc = loc.getBlock().getLocation();
this.id = id;
this.b = Utils.yawToFace(loc.getYaw());
this.w = this.loc.getWorld();
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());
@ -50,12 +56,12 @@ public class stuhl implements Listener {
sitz.setYaw(Utils.FaceToYaw(b)); sitz.setYaw(Utils.FaceToYaw(b));
lehne.setYaw(Utils.FaceToYaw(b)); lehne.setYaw(Utils.FaceToYaw(b));
Utils.setArmorStand(sitz, null, new ItemStack(Material.TRAP_DOOR), false, armorList, null); Utils.setArmorStand(sitz, null, new ItemStack(Material.TRAP_DOOR), false,getID(),IDList);
Utils.setArmorStand(lehne, new EulerAngle(1.57, .0, .0), new ItemStack(Material.TRAP_DOOR), false, armorList, null); Utils.setArmorStand(lehne, new EulerAngle(1.57, .0, .0), new ItemStack(Material.TRAP_DOOR), false,getID(),IDList);
Utils.setArmorStand(feet1, null, new ItemStack(Material.LEVER), false, armorList, null); Utils.setArmorStand(feet1, null, new ItemStack(Material.LEVER), false,getID(),IDList);
Utils.setArmorStand(feet2, null, new ItemStack(Material.LEVER), false, armorList, null); Utils.setArmorStand(feet2, null, new ItemStack(Material.LEVER), false,getID(),IDList);
Utils.setArmorStand(feet3, null, new ItemStack(Material.LEVER), false, armorList, null); Utils.setArmorStand(feet3, null, new ItemStack(Material.LEVER), false,getID(),IDList);
Utils.setArmorStand(feet4, null, new ItemStack(Material.LEVER), false, armorList, null); Utils.setArmorStand(feet4, null, new ItemStack(Material.LEVER), false,getID(),IDList);
main.getInstance().stuehle.add(this); main.getInstance().stuehle.add(this);
plugin.getServer().getPluginManager().registerEvents(this, plugin); plugin.getServer().getPluginManager().registerEvents(this, plugin);
} }
@ -80,41 +86,39 @@ public class stuhl implements Listener {
} }
*/ */
@EventHandler @EventHandler(priority = EventPriority.NORMAL)
public void onInteract(PlayerInteractAtEntityEvent e){ private void onInteract(PlayerInteractAtEntityEvent e){
if(e.isCancelled()){return;}
Player player = e.getPlayer(); Player player = e.getPlayer();
if(e.getRightClicked() instanceof ArmorStand){ if(e.getRightClicked() instanceof ArmorStand){
if(armorList.contains(e.getRightClicked())){ if(IDList.contains(e.getRightClicked().getCustomName())){
e.setCancelled(true); e.setCancelled(true);
ItemStack is = player.getItemInHand(); Utils.getArmorStandAtID(w, IDList.get(0)).setPassenger(player);
if(is!=null){
if(armorList.contains(e.getRightClicked())){
armorList.get(0).setPassenger(player);
}
}
} }
} }
} }
public void delete(Boolean b){ public void delete(Boolean b){
if(b){ if(b){
armorList.get(0).getLocation().getWorld().dropItem(armorList.get(0).getLocation().getBlock().getLocation().add(0, 1, 0), main.getInstance().itemse.stuhl); getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("chair"));
for(Entity entity : armorList){ for(String ids : IDList){
ArmorStand as = (ArmorStand) entity; ArmorStand as = Utils.getArmorStandAtID(w, ids);
entity.getWorld().playEffect(entity.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType()); getLocation().getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
entity.remove(); as.remove();
main.getInstance().mgr.deleteFromConfig(getID(), "chair");
} }
} }
this.loc = null; this.loc = null;
armorList.clear(); IDList.clear();
main.getInstance().stuehle.remove(this); main.getInstance().stuehle.remove(this);
} }
@EventHandler @EventHandler(priority = EventPriority.NORMAL)
public void damage(EntityDamageByEntityEvent e){ public void damage(EntityDamageByEntityEvent e){
if(e.isCancelled()){return;}
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(IDList.contains(e.getEntity().getCustomName())){
delete(true); delete(true);
} }
} }

View File

@ -0,0 +1,277 @@
package de.Ste3et_C0st.Furniture.Objects.indoor;
import java.util.ArrayList;
import java.util.HashMap;
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.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
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 {
private List<String> idList = new ArrayList<String>();
private List<String> tellerIDS = new ArrayList<String>();
private Location loc = null;
private BlockFace b = null;
private String id;
private World w;
public String getID(){return this.id;}
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, String id){
List<ArmorStand> armorlist = new ArrayList<ArmorStand>();
this.loc = loc;
this.b = Utils.yawToFace(loc.getYaw());
this.id = id;
this.w = loc.getWorld();
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);}
}
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++;
}
}
ArmorStand as = Utils.setArmorStand(l, new EulerAngle(winkel, 0, 0), iTemStack_1, false,getID(),idList);
armorlist.add(as);
l = main.getNew(location, this.b, 0.63, x*-.63);
l.add(0,-1.2,0);
l.setYaw(yaw);
as = Utils.setArmorStand(l, new EulerAngle(winkel, 0, 0), iTemStack_2, false,getID(),idList);
armorlist.add(as);
l = main.getNew(location, this.b, 1.26, x*-.63);
l.add(0,-1.2,0);
l.setYaw(yaw);
as = Utils.setArmorStand(l, new EulerAngle(winkel, 0, 0), iTemStack_3, false,getID(),idList);
armorlist.add(as);
}
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, 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 = .67;
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;
float yaw3 = yaw2-90;
float yaw4 = yaw3-90;
t1.setYaw(yaw1);
t2.setYaw(yaw2);
t3.setYaw(yaw3);
t4.setYaw(yaw4);
feet1.setYaw(yaw);
feet2.setYaw(yaw);
feet3.setYaw(yaw);
feet4.setYaw(yaw);
Utils.setArmorStand(feet1, new EulerAngle(-1.75, 0, 0), new ItemStack(Material.BONE), true, getID(), idList);
Utils.setArmorStand(feet2, new EulerAngle(-1.75, 0, 0), new ItemStack(Material.BONE), true, getID(), idList);
Utils.setArmorStand(feet3, new EulerAngle(-1.75, 0, 0), new ItemStack(Material.BONE), true, getID(), idList);
Utils.setArmorStand(feet4, new EulerAngle(-1.75, 0, 0), new ItemStack(Material.BONE), true, getID(), idList);
ArmorStand as1 = Utils.setArmorStand(t1, new EulerAngle(0, 0, 0), IS1, true, getID(), idList);
ArmorStand as2 = Utils.setArmorStand(t2, new EulerAngle(0, 0, 0), IS2, true, getID(), idList);
ArmorStand as3 = Utils.setArmorStand(t3, new EulerAngle(0, 0, 0), IS3, true, getID(), idList);
ArmorStand as4 = Utils.setArmorStand(t4, new EulerAngle(0, 0, 0), IS4, true, getID(), idList);
tellerIDS.add(as1.getCustomName());
tellerIDS.add(as2.getCustomName());
tellerIDS.add(as3.getCustomName());
tellerIDS.add(as4.getCustomName());
plugin.getServer().getPluginManager().registerEvents(this, plugin);
main.getInstance().tische2.add(this);
}
public void delete(boolean b){
if(b){
getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("largeTable"));
for(String s : tellerIDS){
ArmorStand as = Utils.getArmorStandAtID(w, s);
if(as!=null){
if(as.getItemInHand()!=null&&!as.getItemInHand().getType().equals(Material.AIR)){
getLocation().getWorld().dropItem(getLocation(), as.getItemInHand());
}
}
}
for(String s : this.idList){
ArmorStand as = Utils.getArmorStandAtID(w, s);
if(as!=null && as.getHelmet()!= null && as.getHelmet().getType()!=null){
loc.getWorld().playEffect(loc, Effect.STEP_SOUND, as.getHelmet().getType());
}
as.remove();
}
main.getInstance().mgr.deleteFromConfig(getID(), "largeTable");
}
this.tellerIDS.clear();
this.idList.clear();
main.getInstance().tische2.remove(this);
}
@EventHandler(priority = EventPriority.NORMAL)
private void onInteract(PlayerInteractAtEntityEvent e){
if(e.isCancelled()){return;}
Player player = e.getPlayer();
if(e.getRightClicked() instanceof ArmorStand){
if(this.idList.contains(e.getRightClicked().getCustomName())){
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>this.idList.size()-4 || player.getGameMode().equals(GameMode.CREATIVE)){amount=this.idList.size()-4;}
List<Entity> list = new ArrayList<Entity>();
for(String s : this.idList){
ArmorStand as = Utils.getArmorStandAtID(w, s);
if(as!=null){
ItemStack item = as.getHelmet();
if(item.getDurability() != main.getFromDey(druability)){
list.add(as);
}
}
}
try{
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);
}
}
}catch(Exception ex){}
if(!player.getGameMode().equals(GameMode.CREATIVE)){
is.setAmount(is.getAmount()-amount);
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), is);
player.updateInventory();
}
}else if(!is.getType().isBlock() || is.getType().equals(Material.AIR)){
BlockFace b = Utils.yawToFace(player.getLocation().getYaw());
ArmorStand as = null;
for(String s : this.tellerIDS){
ArmorStand armorStand = Utils.getArmorStandAtID(w, s);
BlockFace b2 = Utils.yawToFace(armorStand.getLocation().getYaw());
if(b2.equals(b)){
as = armorStand;
break;
}
}
if(as.getItemInHand()!=null&&!as.getItemInHand().getType().equals(Material.AIR)){as.getLocation().getWorld().dropItem(as.getLocation(), as.getItemInHand());}
as.setItemInHand(is);
player.getInventory().clear(player.getInventory().getHeldItemSlot());
player.updateInventory();
}
}
}
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void damage(EntityDamageByEntityEvent e){
if(e.isCancelled()){return;}
if(e.getDamager() instanceof Player){
if(e.getEntity() instanceof ArmorStand){
if(this.idList.contains(e.getEntity().getCustomName())){
delete(true);
}
}
}
}
public List<ItemStack> getItemListTisch(){
List<ItemStack> items = new ArrayList<ItemStack>();
for(int i = 0; i<=8;i++){
items.add(Utils.getArmorStandAtID(w, idList.get(i)).getHelmet());
}
return items;
}
public HashMap<Integer, ItemStack> getTeller(){
HashMap<Integer, ItemStack> teller = new HashMap<Integer, ItemStack>();
for(String s : tellerIDS){
try{
ArmorStand as = Utils.getArmorStandAtID(w, s);
teller.put(teller.size(), as.getItemInHand());
}catch(Exception e){
teller.put(teller.size(), new ItemStack(Material.AIR));
}
}
return teller;
}
}

View File

@ -1,4 +1,4 @@
package de.Ste3et_C0st.Furniture.Objects; package de.Ste3et_C0st.Furniture.Objects.indoor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -7,13 +7,15 @@ import org.bukkit.Bukkit;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
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.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent;
@ -23,21 +25,25 @@ import org.bukkit.plugin.Plugin;
import de.Ste3et_C0st.Furniture.Main.Utils; import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main; import de.Ste3et_C0st.Furniture.Main.main;
public class laterne implements Listener { public class latern implements Listener {
List<Entity> armorList = new ArrayList<Entity>(); private List<String> idList = new ArrayList<String>();
Block b; private Block b;
Location loc = null; private Location loc = null;
Boolean bool = true; private Boolean bool = true;
private BlockFace bFace = null;
BlockFace bFace = null; private String id;
private World w;
public String getID(){return this.id;}
public Location getLocation(){return this.loc;} public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.bFace;} public BlockFace getBlockFace(){return this.bFace;}
public Boolean getBlockState(){return this.bool;} public Boolean getBlockState(){return this.bool;}
public laterne(Location loc, Plugin plugin, Boolean bool){ public latern(Location loc, Plugin plugin, Boolean bool, String id){
this.loc = loc; this.loc = loc;
this.bool = bool; this.bool = bool;
this.id = id;
this.bFace = Utils.yawToFace(loc.getYaw());
this.w = loc.getWorld();
Location center = Utils.getCenter(loc); Location center = Utils.getCenter(loc);
b = center.getWorld().getBlockAt(center); b = center.getWorld().getBlockAt(center);
if(bool){ if(bool){
@ -54,13 +60,13 @@ public class laterne implements Listener {
Location right_upper = new Location(obsidian.getWorld(), obsidian.getX()-0.21, obsidian.getY()+.62, obsidian.getZ()-0.21); 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); Location right_down = new Location(obsidian.getWorld(), obsidian.getX()+0.21, obsidian.getY() + .62, obsidian.getZ() -0.21);
Utils.setArmorStand(obsidian, null, new ItemStack(Material.OBSIDIAN), false, armorList, null); Utils.setArmorStand(obsidian, null, new ItemStack(Material.OBSIDIAN), false,getID(),idList);
Utils.setArmorStand(location.add(0,0,0), null, new ItemStack(Material.WOOD_PLATE), false, armorList, null); Utils.setArmorStand(location.add(0,0,0), null, new ItemStack(Material.WOOD_PLATE), false,getID(), idList);
Utils.setArmorStand(left_down, null, new ItemStack(Material.LEVER), false, armorList, null); Utils.setArmorStand(left_down, null, new ItemStack(Material.LEVER), false,getID(), idList);
Utils.setArmorStand(left_upper, null, new ItemStack(Material.LEVER), false, armorList, null); Utils.setArmorStand(left_upper, null, new ItemStack(Material.LEVER), false,getID(), idList);
Utils.setArmorStand(right_upper, null, new ItemStack(Material.LEVER), false, armorList, null); Utils.setArmorStand(right_upper, null, new ItemStack(Material.LEVER), false,getID(), idList);
Utils.setArmorStand(right_down, null, new ItemStack(Material.LEVER), false, armorList, null); Utils.setArmorStand(right_down, null, new ItemStack(Material.LEVER), false,getID(), idList);
Bukkit.getServer().getPluginManager().registerEvents(this, plugin); Bukkit.getServer().getPluginManager().registerEvents(this, plugin);
main.getInstance().laternen.add(this); main.getInstance().laternen.add(this);
} }
@ -80,59 +86,58 @@ public class laterne implements Listener {
} }
} }
/*
@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(Boolean b){ public void delete(Boolean b){
if(b){ if(b){
armorList.get(0).getLocation().getWorld().dropItem(this.b.getLocation(), main.getInstance().itemse.Laterne); getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("lantern"));
for(Entity entity : armorList){ for(String s : idList){
ArmorStand as = (ArmorStand) entity; ArmorStand as = Utils.getArmorStandAtID(w,s);
entity.getWorld().playEffect(entity.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType()); as.getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
entity.remove(); as.remove();
main.getInstance().mgr.deleteFromConfig(getID(), "lantern");
} }
} }
if(this.b!=null&&!this.b.getType().equals(Material.AIR)){this.b.setType(Material.AIR);} if(this.b!=null&&!this.b.getType().equals(Material.AIR)){this.b.setType(Material.AIR);}
this.bool = null; this.bool = null;
this.loc = null; this.loc = null;
armorList.clear(); this.idList.clear();
main.getInstance().laternen.remove(this); main.getInstance().laternen.remove(this);
} }
@EventHandler @EventHandler
public void onInteract(PlayerInteractAtEntityEvent e){ public void onBlockBreak(BlockBreakEvent e){
if(e.getBlock()!=null&&e.getBlock().equals(b)){
delete(true);
}
}
@EventHandler(priority = EventPriority.NORMAL)
private void onInteract(PlayerInteractAtEntityEvent e){
if(e.isCancelled()){return;}
Player player = e.getPlayer(); Player player = e.getPlayer();
if(e.getRightClicked() instanceof ArmorStand){ if(e.getRightClicked() instanceof ArmorStand){
if(armorList.contains(e.getRightClicked())){ if(this.idList.contains(e.getRightClicked().getName())){
e.setCancelled(true); e.setCancelled(true);
ItemStack is = player.getItemInHand(); ItemStack is = player.getItemInHand();
if(is!=null){ if(is!=null){
if(is.getType().equals(Material.FLINT_AND_STEEL)){ if(is.getType().equals(Material.FLINT_AND_STEEL)){
b.setType(Material.TORCH); b.setType(Material.TORCH);
bool = true;
}else if(is.getType().equals(Material.WATER_BUCKET)){ }else if(is.getType().equals(Material.WATER_BUCKET)){
b.setType(Material.REDSTONE_TORCH_OFF); b.setType(Material.REDSTONE_TORCH_OFF);
bool = false;
} }
} }
} }
} }
} }
@EventHandler @EventHandler(priority = EventPriority.NORMAL)
public void damage(EntityDamageByEntityEvent e){ public void damage(EntityDamageByEntityEvent e){
if(e.isCancelled()){return;}
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(this.idList.contains(e.getEntity().getName())){
delete(true); delete(true);
} }
} }

View File

@ -1,4 +1,4 @@
package de.Ste3et_C0st.Furniture.Objects; package de.Ste3et_C0st.Furniture.Objects.indoor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -7,13 +7,14 @@ 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.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockFromToEvent;
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.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -24,16 +25,25 @@ import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main; import de.Ste3et_C0st.Furniture.Main.main;
public class sofa implements Listener { public class sofa implements Listener {
private List<Entity> armorList = new ArrayList<Entity>(); private List<String> idList = new ArrayList<String>();
private List<Entity> sitz = new ArrayList<Entity>();
private List<Location> location = new ArrayList<Location>();
private ItemStack is; private ItemStack is;
private Double place; private Double place;
private BlockFace b;
private short color = 0; private short color = 0;
private Location loc = null;
private String id;
private World w;
public String getID(){return this.id;}
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
public sofa(Location loc, Integer lengt, Plugin plugin){ public sofa(Location loc, Integer lengt, Plugin plugin, List<ItemStack> list, String id){
List<Entity> sitz = new ArrayList<Entity>();
this.w = loc.getWorld();
this.loc = loc;
this.place = 0.2; this.place = 0.2;
this.id = id;
this.b = Utils.yawToFace(loc.getYaw());
is = new ItemStack(Material.CARPET); is = new ItemStack(Material.CARPET);
is.setDurability(color); is.setDurability(color);
BlockFace b = Utils.yawToFace(loc.getYaw()).getOppositeFace(); BlockFace b = Utils.yawToFace(loc.getYaw()).getOppositeFace();
@ -56,31 +66,43 @@ public class sofa implements Listener {
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);
Utils.setArmorStand(feet1, null, new ItemStack(Material.LEVER), false, armorList, null); Utils.setArmorStand(feet1, null, new ItemStack(Material.LEVER), false,getID(),idList);
Utils.setArmorStand(feet2, null, new ItemStack(Material.LEVER), false, armorList, null); Utils.setArmorStand(feet2, null, new ItemStack(Material.LEVER), false,getID(),idList);
Utils.setArmorStand(feet3, null, new ItemStack(Material.LEVER), false, armorList, null); Utils.setArmorStand(feet3, null, new ItemStack(Material.LEVER), false,getID(),idList);
Utils.setArmorStand(feet4, null, new ItemStack(Material.LEVER), false, armorList, null); Utils.setArmorStand(feet4, null, new ItemStack(Material.LEVER), false,getID(),idList);
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
carpetHight = main.getNew(carpetHight, b, .25,.3); carpetHight = main.getNew(carpetHight, b, .25,.3);
Double d = .02; Double d = .02;
float facing = Utils.FaceToYaw(b); float facing = Utils.FaceToYaw(b);
int l = 0;
for(Double i = .0; i<=lengt; i+=0.65){ 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); Location carpet = main.getNew(carpetHight, b, place,(double) d);
carpet.setYaw(facing); carpet.setYaw(facing);
ArmorStand as = Utils.setArmorStand(carpet, null, is, false, armorList, null); ArmorStand as = null;
if(list!=null&&!list.isEmpty() && list.get(l)!=null){
as = Utils.setArmorStand(carpet, null, list.get(l), false,getID(),idList);
}else{
as = Utils.setArmorStand(carpet, null, is, false,getID(),idList);
}
sitz.add(as); sitz.add(as);
l++;
//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);
Utils.setArmorStand(location, new EulerAngle(1.57, .0, .0), is, false, armorList, null);
if(list!=null&&!list.isEmpty() && list.get(l)!=null){
Utils.setArmorStand(location, new EulerAngle(1.57, .0, .0), list.get(l), false,getID(),idList);
}else{
Utils.setArmorStand(location, new EulerAngle(1.57, .0, .0), is, false,getID(),idList);
}
l++;
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;
Location last = main.getNew(sitz.get(sitz.size()-1).getLocation(), b, 0D, 0.26D); Location last = main.getNew(sitz.get(sitz.size()-1).getLocation(), b, 0D, 0.26D);
@ -88,70 +110,63 @@ public class sofa implements Listener {
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);
Utils.setArmorStand(first.add(0,-.05,0), new EulerAngle(1.57, .0, .0), is, false, armorList, null); Utils.setArmorStand(first.add(0,-.05,0), new EulerAngle(1.57, .0, .0), is, false,getID(),idList);
Utils.setArmorStand(last.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,getID(),idList);
plugin.getServer().getPluginManager().registerEvents(this, plugin); plugin.getServer().getPluginManager().registerEvents(this, plugin);
main.getInstance().sofas.add(this); main.getInstance().sofas.add(this);
} }
@EventHandler /*@EventHandler
public void onWaterFlow(BlockFromToEvent e){ private void onWaterFlow(BlockFromToEvent e){
Location locTo = e.getToBlock().getLocation(); Location locTo = e.getToBlock().getLocation();
if(location!=null && !location.isEmpty()){ if(location!=null && !location.isEmpty()){
if(location.contains(locTo) || location.contains(locTo.add(0,1,0))){ if(location.contains(locTo) || location.contains(locTo.add(0,1,0))){
e.setCancelled(true); 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(Boolean b){ public void delete(Boolean b){
if(b){ if(b){
armorList.get(0).getLocation().getWorld().dropItem(armorList.get(0).getLocation().getBlock().getLocation().add(0, 1, 0), main.getInstance().itemse.Sofa); getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("sofa"));
for(Entity entity : armorList){ for(String s : idList){
ArmorStand as = (ArmorStand) entity; ArmorStand as = Utils.getArmorStandAtID(this.w, s);
entity.getWorld().playEffect(entity.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType()); as.getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
entity.remove(); as.remove();
main.getInstance().mgr.deleteFromConfig(getID(), "sofa");
} }
} }
location.clear(); idList.clear();
armorList.clear();
main.getInstance().sofas.remove(this); main.getInstance().sofas.remove(this);
} }
@EventHandler @EventHandler(priority = EventPriority.NORMAL)
public void onInteract(PlayerInteractAtEntityEvent e){ private void onInteract(PlayerInteractAtEntityEvent e){
if(e.isCancelled()){return;}
Player player = e.getPlayer(); Player player = e.getPlayer();
if(e.getRightClicked() instanceof ArmorStand){ if(e.getRightClicked() instanceof ArmorStand){
if(armorList.contains(e.getRightClicked())){ if(idList.contains(e.getRightClicked().getCustomName())){
e.setCancelled(true); e.setCancelled(true);
ItemStack is = player.getItemInHand(); ItemStack is = player.getItemInHand();
ArmorStand armorStand = Utils.getArmorStandAtID(w, e.getRightClicked().getCustomName());
if(is!=null){ if(is!=null){
if(is.getType().equals(Material.INK_SACK)){ if(is.getType().equals(Material.INK_SACK)){
e.getRightClicked().sendMessage("test#2");
Short druability = is.getDurability(); Short druability = is.getDurability();
Integer amount = is.getAmount(); Integer amount = is.getAmount() + 4;
if(amount>armorList.size() || player.getGameMode().equals(GameMode.CREATIVE)){amount=armorList.size();} if(amount>idList.size() || player.getGameMode().equals(GameMode.CREATIVE)){amount=idList.size();}
List<Entity> list = new ArrayList<Entity>(); List<Entity> list = new ArrayList<Entity>();
for(Entity entity : armorList){ for(String s : idList){
if(entity instanceof ArmorStand){ ArmorStand as = Utils.getArmorStandAtID(w, s);
ArmorStand as = (ArmorStand) entity; if(as.getHelmet().getType().equals(Material.CARPET)){
ItemStack item = as.getHelmet(); ItemStack item = as.getHelmet();
if(item.getDurability() != main.getFromDey(druability)){ if(item.getDurability() != main.getFromDey(druability)){
list.add(entity); list.add(as);
} }
} }
} }
try{
for(int i = 0; i<=amount-1;i++){ for(int i = 0; i<=amount-1;i++){
Entity entity = list.get(i); Entity entity = list.get(i);
if(entity instanceof ArmorStand){ if(entity instanceof ArmorStand){
@ -161,24 +176,40 @@ public class sofa implements Listener {
as.setHelmet(item); as.setHelmet(item);
} }
} }
}catch(IndexOutOfBoundsException ex){}
if(!player.getGameMode().equals(GameMode.CREATIVE)){ if(!player.getGameMode().equals(GameMode.CREATIVE)){
is.setAmount(is.getAmount()-amount); is.setAmount(is.getAmount()+4-amount);
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), is); player.getInventory().setItem(player.getInventory().getHeldItemSlot(), is);
player.updateInventory(); player.updateInventory();
} }
}else if(sitz.contains(e.getRightClicked())){ }else if(!armorStand.getHeadPose().equals(new EulerAngle(1.57, .0, .0)) && armorStand.getHelmet().getType().equals(Material.CARPET)){
e.getRightClicked().setPassenger(player);
}
}else if(!armorStand.getHeadPose().equals(new EulerAngle(1.57, .0, .0)) && armorStand.getHelmet().getType().equals(Material.CARPET)){
e.getRightClicked().setPassenger(player); e.getRightClicked().setPassenger(player);
} }
} }
} }
} }
public List<ItemStack> getItemListTisch(){
List<ItemStack> items = new ArrayList<ItemStack>();
for(String s : idList){
ArmorStand as = Utils.getArmorStandAtID(w, s);
if(as.getHelmet()!=null&&as.getHelmet().getType().equals(is.getType())){
items.add(as.getHelmet());
}
}
return items;
} }
@EventHandler @EventHandler(priority = EventPriority.NORMAL)
public void damage(EntityDamageByEntityEvent e){ public void damage(EntityDamageByEntityEvent e){
if(e.isCancelled()){return;}
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(idList.contains(e.getEntity().getCustomName())){
delete(true); delete(true);
} }
} }

View File

@ -1,4 +1,4 @@
package de.Ste3et_C0st.Furniture.Objects; package de.Ste3et_C0st.Furniture.Objects.indoor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -7,11 +7,12 @@ 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.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
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;
@ -22,43 +23,48 @@ import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Main.Utils; import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main; import de.Ste3et_C0st.Furniture.Main.main;
public class tisch implements Listener { public class table implements Listener {
List<Entity> armorList = new ArrayList<Entity>();
ArmorStand armor;
ItemStack is = null;
Location loc = null;
BlockFace b = null;
private List<String> idList = new ArrayList<String>();
private ArmorStand armor;
private ItemStack is = null;
private Location loc = null;
private BlockFace b = null;
private String id;
private World w;
public String getID(){return this.id;}
public Location getLocation(){return this.loc;} public Location getLocation(){return this.loc;}
public ItemStack getItemStack(){return this.is;} public ItemStack getItemStack(){return this.is;}
public BlockFace getBlockFace(){return this.b;} public BlockFace getBlockFace(){return this.b;}
public tisch(Location loc, Plugin plugin, ItemStack is){ public table(Location loc, Plugin plugin, ItemStack is, String id){
this.loc = loc; this.loc = loc.getBlock().getLocation();
this.id = id;
this.b = Utils.yawToFace(loc.getYaw()); this.b = Utils.yawToFace(loc.getYaw());
this.w = loc.getWorld();
Location middle1 = Utils.getCenter(loc); Location middle1 = Utils.getCenter(loc);
Location middle2 = Utils.getCenter(loc); Location middle2 = Utils.getCenter(loc);
Utils.setArmorStand(middle1.add(0,-2.1,0),new EulerAngle(0, 0, 0) , new ItemStack(Material.WOOD_PLATE), false, armorList, null); Utils.setArmorStand(middle1.add(0,-2.1,0),new EulerAngle(0, 0, 0) , new ItemStack(Material.WOOD_PLATE), false,getID(),idList);
Utils.setArmorStand(middle2.add(0,-1.05,0),new EulerAngle(0, 0, 0) , new ItemStack(Material.TRAP_DOOR), false, armorList, null); Utils.setArmorStand(middle2.add(0,-1.05,0),new EulerAngle(0, 0, 0) , new ItemStack(Material.TRAP_DOOR), false,getID(),idList);
loc.setYaw(0); loc.setYaw(0);
ArmorStand as = Utils.setArmorStand(loc.add(.9,0.15,0.3),new EulerAngle(0,.0,.0), is, true, armorList, null); ArmorStand as = Utils.setArmorStand(loc.add(.9,0.15,0.3),new EulerAngle(0,.0,.0), is, true,getID(),idList);
Utils.setArmorStand(loc.add(0,-.65,.68),new EulerAngle(1.38,.0,.0), new ItemStack(Material.STICK), true, armorList, null); Utils.setArmorStand(loc.add(0,-.65,.68),new EulerAngle(1.38,.0,.0), new ItemStack(Material.STICK), true,getID(),idList);
this.armor = as; this.armor = as;
plugin.getServer().getPluginManager().registerEvents(this, plugin); plugin.getServer().getPluginManager().registerEvents(this, plugin);
main.getInstance().tische.add(this); main.getInstance().tische.add(this);
} }
@EventHandler @EventHandler(priority = EventPriority.NORMAL)
public void onInteract(PlayerInteractAtEntityEvent e){ private void onInteract(PlayerInteractAtEntityEvent e){
if(e.isCancelled()){return;}
Player player = e.getPlayer(); Player player = e.getPlayer();
if(e.getRightClicked() instanceof ArmorStand){ if(e.getRightClicked() instanceof ArmorStand){
if(armorList.contains(e.getRightClicked())){ if(idList.contains(e.getRightClicked().getCustomName())){
e.setCancelled(true); e.setCancelled(true);
ItemStack is = player.getItemInHand(); ItemStack is = player.getItemInHand();
if(is!=null&&!is.getType().isBlock()){ if(is!=null&&!is.getType().isBlock()||is.getType().equals(Material.AIR)){
if(armor!=null){ if(armor!=null){
ArmorStand as = (ArmorStand) armorList.get(2); ArmorStand as = Utils.getArmorStandAtID(w,idList.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;
@ -72,29 +78,31 @@ public class tisch implements Listener {
public void delete(Boolean b){ public void delete(Boolean b){
if(b){ if(b){
armorList.get(0).getLocation().getWorld().dropItem(armorList.get(0).getLocation().getBlock().getLocation().add(0, 2, 0), main.getInstance().itemse.tisch); getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("table"));
if(is!=null && !is.getType().equals(Material.AIR)){ if(is!=null && !is.getType().equals(Material.AIR)){
ArmorStand as = (ArmorStand) armorList.get(2); ArmorStand as = Utils.getArmorStandAtID(w,idList.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){ for(String s : idList){
ArmorStand as = (ArmorStand) entity; ArmorStand as = Utils.getArmorStandAtID(w,s);
entity.getWorld().playEffect(entity.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType()); loc.getWorld().playEffect(loc, Effect.STEP_SOUND, as.getHelmet().getType());
entity.remove(); as.remove();
} }
main.getInstance().mgr.deleteFromConfig(getID(), "table");
} }
this.loc = null; this.loc = null;
armorList.clear(); this.idList.clear();
main.getInstance().tische.remove(this); main.getInstance().tische.remove(this);
} }
@EventHandler @EventHandler(priority = EventPriority.NORMAL)
public void damage(EntityDamageByEntityEvent e){ public void damage(EntityDamageByEntityEvent e){
if(e.isCancelled()){return;}
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(idList.contains(e.getEntity().getCustomName())){
delete(true); delete(true);
} }
} }

View File

@ -1,277 +0,0 @@
package de.Ste3et_C0st.Furniture.Objects;
import java.util.ArrayList;
import java.util.HashMap;
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.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.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>();
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);}
}
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++;
}
}
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, 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 = .67;
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;
float yaw3 = yaw2-90;
float yaw4 = yaw3-90;
t1.setYaw(yaw1);
t2.setYaw(yaw2);
t3.setYaw(yaw3);
t4.setYaw(yaw4);
feet1.setYaw(yaw);
feet2.setYaw(yaw);
feet3.setYaw(yaw);
feet4.setYaw(yaw);
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;
armor.setVisible(false);
armor.setGravity(false);
}
plugin.getServer().getPluginManager().registerEvents(this, plugin);
main.getInstance().tische2.add(this);
}
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();
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(!is.getType().isBlock()){
Integer i = armorList.size();
if(armorList.get(3).equals(e.getRightClicked())){
i-=4;
ArmorStand as = (ArmorStand) armorList.get(i);
if(as.getItemInHand()!=null&&!as.getItemInHand().getType().equals(Material.AIR)){as.getLocation().getWorld().dropItem(as.getLocation(), as.getItemInHand());}
as.setItemInHand(is);
}
if(armorList.get(7).equals(e.getRightClicked())){
i-=3;
ArmorStand as = (ArmorStand) armorList.get(i);
if(as.getItemInHand()!=null&&!as.getItemInHand().getType().equals(Material.AIR)){as.getLocation().getWorld().dropItem(as.getLocation(), as.getItemInHand());}
as.setItemInHand(is);
}
if(armorList.get(5).equals(e.getRightClicked())){
i-=2;
ArmorStand as = (ArmorStand) armorList.get(i);
if(as.getItemInHand()!=null&&!as.getItemInHand().getType().equals(Material.AIR)){as.getLocation().getWorld().dropItem(as.getLocation(), as.getItemInHand());}
as.setItemInHand(is);
}
if(armorList.get(1).equals(e.getRightClicked())){
i-=1;
ArmorStand as = (ArmorStand) armorList.get(i);
if(as.getItemInHand()!=null&&!as.getItemInHand().getType().equals(Material.AIR)){as.getLocation().getWorld().dropItem(as.getLocation(), as.getItemInHand());}
as.setItemInHand(is);
}
}
}
}
}
}
@EventHandler
public void damage(EntityDamageByEntityEvent e){
if(e.getDamager() instanceof Player){
if(e.getEntity() instanceof ArmorStand){
if(armorList.contains(e.getEntity())){
delete(true);
}
}
}
}
@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,-0.5,0))){
e.setCancelled(true);
}
}
}
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){
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

@ -1,12 +1,12 @@
name: Furniture name: Furniture
version: 0.1 version: 1.5
description: DiceEquipment description: DiceEquipment
author: Ste3et_C0st author: Ste3et_C0st
website: http://dicecraft.de website: http://dicecraft.de
softdepend: [Vault]
main: de.Ste3et_C0st.Furniture.Main.main main: de.Ste3et_C0st.Furniture.Main.main
commands: commands:
Furniture: furniture:
description: test description: DiceEaster Egg Command
usage: /<command> usage: /<command>