Defualt Furnitures By Ste3et_C0st

This commit is contained in:
BuildTools 2015-07-08 18:15:57 +02:00
parent 5403fe3b33
commit 981eefc68a
69 changed files with 2392 additions and 6459 deletions

View File

@ -2,19 +2,7 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="C:/Plugins/jars/Vault.jar"/>
<classpathentry kind="lib" path="C:/Plugins/jars/worldguard-6.0.0-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="C:/Plugins/jars/Landlord.jar"/>
<classpathentry kind="lib" path="C:/Plugins/jars/WorldEdit.jar"/>
<classpathentry kind="lib" path="C:/Plugins/jars/Factions.jar"/>
<classpathentry kind="lib" path="C:/Plugins/jars/spigot.jar"/>
<classpathentry kind="lib" path="C:/Plugins/jars/LightAPI.jar"/>
<classpathentry kind="lib" path="C:/Plugins/jars/PlotSquared.jar"/>
<classpathentry kind="lib" path="C:/Plugins/jars/PreciousStones.jar"/>
<classpathentry kind="lib" path="C:/Plugins/jars/Residence.jar"/>
<classpathentry kind="lib" path="C:/Plugins/jars/Towny.jar"/>
<classpathentry kind="lib" path="C:/Plugins/jars/PlotMe-Core.jar"/>
<classpathentry kind="lib" path="C:/Plugins/jars/GriefPrevention.jar"/>
<classpathentry kind="lib" path="C:/Plugins/jars/Plotz.jar"/>
<classpathentry kind="lib" path="C:/Plugins/jars/FurnitureLib.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Furniture</name>
<name>DefaultFurniture</name>
<comment></comment>
<projects>
</projects>

9
src/Crafting/Barrels.yml Normal file
View File

@ -0,0 +1,9 @@
Barrels:
name: '&cBarrels'
material: 383
crafting:
disable: false
recipe: X0X,X0X,XXX
index:
'0': 0
X: 280

11
src/Crafting/Camera.yml Normal file
View File

@ -0,0 +1,11 @@
Camera:
name: '&cCamera'
material: 383
crafting:
disable: false
recipe: DXD,AEA,EAE
index:
D: 331
E: 280
X: 35
A:

View File

@ -0,0 +1,10 @@
Campfire1:
name: '&cCampfire #1'
material: 383
crafting:
disable: false
recipe: 0X0,XEX,0X0
index:
'0': 0
E: 263
X: 280

View File

@ -0,0 +1,10 @@
Campfire2:
name: '&cCampfire #2'
material: 383
crafting:
disable: false
recipe: DXD,XEX,DXD
index:
D: 4
E: 263
X: 280

10
src/Crafting/Chair.yml Normal file
View File

@ -0,0 +1,10 @@
Chair:
name: '&cChair'
material: 383
crafting:
disable: false
recipe: 0+0,0+0,E0E
index:
'0': 0
+: 96
E: 280

View File

@ -0,0 +1,8 @@
GraveStone:
name: '&cGrave Stone'
material: 383
crafting:
disable: true
recipe: XXX,XXX,XXX
index:
X: 0

12
src/Crafting/Lantern.yml Normal file
View File

@ -0,0 +1,12 @@
Lantern:
name: '&cLantern'
material: 383
crafting:
disable: false
recipe: 0+0,XEX,0A0
index:
'0': 0
X: 280
E: 50
A: 49
+: 126

View File

@ -0,0 +1,10 @@
LargeTable:
name: '&cLarge Table'
material: 383
crafting:
disable: false
recipe: XXX,XXX,A0A
index:
'0': 0
X: 160
A: 352

10
src/Crafting/Sofa.yml Normal file
View File

@ -0,0 +1,10 @@
Sofa:
name: '&cSofa'
material: 383
crafting:
disable: false
recipe: +0+,+++,X0X
index:
'0': 0
+: 171
X: 69

11
src/Crafting/TV.yml Normal file
View File

@ -0,0 +1,11 @@
TV:
name: '&cTV'
material: 383
crafting:
disable: false
recipe: XXX,XEX,0A0
index:
X: 171
E: 69
A: 148
0: 0

11
src/Crafting/Table.yml Normal file
View File

@ -0,0 +1,11 @@
Table:
name: '&cTable'
material: 383
crafting:
disable: false
recipe: 0X0,0E0,0A0
index:
'0': 0
E: 280
A: 72
X: 96

11
src/Crafting/Tent1.yml Normal file
View File

@ -0,0 +1,11 @@
Tent1:
name: '&cTent #1'
material: 383
crafting:
disable: false
recipe: 0X0,XEX,EAE
index:
'0': 0
E: 35
A: 58
X: 280

12
src/Crafting/Tent2.yml Normal file
View File

@ -0,0 +1,12 @@
Tent2:
name: '&cTent #2'
material: 383
crafting:
disable: false
recipe: 0X0,XEX,OAO
index:
'0': 0
E: 58
A: 355
X: 35
O: 17

10
src/Crafting/Tent3.yml Normal file
View File

@ -0,0 +1,10 @@
Tent3:
name: '&cTent #3'
material: 383
crafting:
disable: false
recipe: 000,0E0,EAE
index:
'0': 0
E: 35
A: 355

View File

@ -3,6 +3,8 @@ config:
UseMetrics: true
CraftingPermissions: true
BreakPermissions: true
CreativeItems: true
CreativeStorage: true
Messages:
NoPermissions: "&cYou don't have permission to do that"
notFound: "&cFurniture not found"

View File

@ -1,126 +0,0 @@
Items:
chair:
name: '&cChair'
material: 383
crafting:
disable: false
recipe: 0+0,0+0,E0E
index:
'0': 0
+: 96
E: 280
sofa:
name: '&cSofa'
material: 383
crafting:
disable: false
recipe: +0+,+++,X0X
index:
'0': 0
+: 171
X: 69
lantern:
name: '&cLantern'
material: 383
crafting:
disable: false
recipe: 0+0,XEX,0A0
index:
'0': 0
X: 280
E: 50
A: 49
+: 126
largeTable:
name: '&cLarge Table'
material: 383
crafting:
disable: false
recipe: XXX,XXX,A0A
index:
'0': 0
X: 160
A: 352
table:
name: '&cTable'
material: 383
crafting:
disable: false
recipe: 0X0,0E0,0A0
index:
'0': 0
E: 280
A: 72
X: 96
tent1:
name: '&cTent #1'
material: 383
crafting:
disable: false
recipe: 0X0,XEX,EAE
index:
'0': 0
E: 35
A: 58
X: 280
tent2:
name: '&cTent #2'
material: 383
crafting:
disable: false
recipe: 0X0,XEX,OAO
index:
'0': 0
E: 58
A: 355
X: 35
O: 17
tent3:
name: '&cTent #3'
material: 383
crafting:
disable: false
recipe: 000,0E0,EAE
index:
'0': 0
E: 35
A: 355
barrels:
name: '&cBarrels'
material: 383
crafting:
disable: false
recipe: X0X,X0X,XXX
index:
'0': 0
X: 280
campfire1:
name: '&cCampfire #1'
material: 383
crafting:
disable: false
recipe: 0X0,XEX,0X0
index:
'0': 0
E: 263
X: 280
campfire2:
name: '&cCampfire #2'
material: 383
crafting:
disable: false
recipe: DXD,XEX,DXD
index:
D: 4
E: 263
X: 280
camera:
name: '&cCamera'
material: 383
crafting:
disable: false
recipe: DXD,AEA,EAE
index:
D: 331
E: 280
X: 35

View File

@ -7,16 +7,15 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main;
public class GetBlocks {
public HashMap<Integer, HashMap<Integer, Byte>> returnBlocks(Location location, int höhe, int links){
HashMap<Integer, HashMap<Integer, Byte>> blockList = new HashMap<Integer, HashMap<Integer, Byte>>();
BlockFace b = Utils.yawToFace(location.getYaw());
BlockFace b = main.getLocationUtil().yawToFace(location.getYaw());
höhe = höhe/2;
//links = links/2;
location = main.getNew(location, b, 0D,- (double) (links/2));
location = main.getLocationUtil().getRelativ(location, b, 0D,- (double) (links/2));
Integer tiefe = 24;
int layer = 0;
for(int x = 0;x<=tiefe;x++){
@ -24,7 +23,7 @@ public class GetBlocks {
Integer blockindex = 0;
for(int y = 0;y<=links;y++){
for(int z = 0;z<=höhe;z++){
Block b1 = main.getNew(location, b,(double) x, (double) y).add(0,z,0).getBlock();
Block b1 = main.getLocationUtil().getRelativ(location, b,(double) x, (double) y).add(0,z,0).getBlock();
byte byte1 = getByteFromBlock(b1);
layerlist.put(blockindex, byte1);
blockindex++;

View File

@ -1,23 +0,0 @@
package de.Ste3et_C0st.Furniture.Listener;
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPistonExtendEvent;
import de.Ste3et_C0st.Furniture.Main.main;
public class IPistonExtendEvent implements Listener {
@SuppressWarnings("static-access")
@EventHandler
public void onPistionExtend(BlockPistonExtendEvent e){
if(e.getBlock()==null){return;}
for(int i = 13;i>=0;i--){
Location l = main.getInstance().getNew(e.getBlock().getLocation(), e.getDirection(),(double)- i,(double) 0 );
if(main.getInstance().Fmgr.isAtLocation(l.toVector(), 1D)){e.setCancelled(true);}
if(main.getInstance().Fmgr.isAtLocation(l.getBlock().getRelative(BlockFace.UP).getLocation().toVector(), 1D)){e.setCancelled(true);}
}
}
}

View File

@ -1,274 +0,0 @@
package de.Ste3et_C0st.Furniture.Listener;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.bukkit.ChatColor;
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.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.ItemStack;
import de.Ste3et_C0st.Furniture.Main.Permissions;
import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.Furniture.Main.Manager.BlackList;
import de.Ste3et_C0st.Furniture.Main.Type.FurnitureType;
import de.Ste3et_C0st.Furniture.Objects.electric.camera;
import de.Ste3et_C0st.Furniture.Objects.indoor.chair;
import de.Ste3et_C0st.Furniture.Objects.indoor.largeTable;
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.barrels;
import de.Ste3et_C0st.Furniture.Objects.outdoor.campfire_1;
import de.Ste3et_C0st.Furniture.Objects.outdoor.campfire_2;
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_1;
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_2;
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_3;
public class OnInteract implements Listener {
@EventHandler(priority = EventPriority.LOW)
public void onCrafting(PrepareItemCraftEvent e){
Player p = (Player) e.getView().getPlayer();
CraftingInventory inv = e.getInventory();
if(!main.getInstance().isCrafting){return;}
if(main.getInstance().crafting.containsValue(e.getRecipe().getResult())){
if(getName(e.getRecipe().getResult()) != null){
if((!p.hasPermission("furniture.craft." + getName(e.getRecipe().getResult()))) && (!p.hasPermission("furniture.player")) ){
inv.setResult(null);
return;
}
}
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onDeath(EntityDeathEvent e){
if(e == null){return;}
if(e instanceof ArmorStand){
if(((ArmorStand) e).getName()==null){return;}
String name = ((ArmorStand) e).getName();
if(name != null && name.length()>=13){
String[] split = name.split("-");
if(split != null && split.length>=1){
ArmorStand as = (ArmorStand) e.getEntity();
ArmorStand armorStand = (ArmorStand) ((ArmorStand) e).getWorld().spawnEntity(as.getLocation(), EntityType.ARMOR_STAND);
if(as.getHelmet()!=null){armorStand.setHelmet(as.getHelmet());}
if(as.getItemInHand()!=null){armorStand.setItemInHand(as.getItemInHand());}
if(as.getRightArmPose()!=null){armorStand.setRightArmPose(as.getRightArmPose());}
if(as.getLeftArmPose()!=null){armorStand.setLeftArmPose(as.getLeftArmPose());}
if(as.getBodyPose()!=null){armorStand.setBodyPose(as.getBodyPose());}
if(as.getLeftLegPose()!=null){armorStand.setLeftLegPose(as.getLeftLegPose());}
if(as.getRightLegPose()!=null){armorStand.setRightArmPose(as.getRightArmPose());}
if(as.isSmall()){armorStand.setSmall(true);}
if(as.isVisible()){armorStand.setVisible(true);}
if(as.getVelocity()!=null){armorStand.setVelocity(as.getVelocity());}
}
}
}
}
public String getName(ItemStack is){
for(String s : main.getInstance().crafting.keySet()){
if(main.getInstance().crafting.get(s).equals(is)){
return s;
}
}
return null;
}
@EventHandler
public void onInterActEvent(PlayerInteractEvent e){
Player p = e.getPlayer();
if(e.getItem() == null){return;}
if(e.getClickedBlock() == null){return;}
if(e.getClickedBlock()==null){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 amount = is.getAmount();
Location location = new Location(p.getWorld(), e.getClickedBlock().getLocation().getBlockX(), e.getClickedBlock().getLocation().getBlockY(), e.getClickedBlock().getLocation().getBlockZ());
location.setYaw(p.getLocation().getYaw());
location.setY(location.getY() + 1);
ItemStack saveIS = getItemStackCopy(is);
String noPermissions = ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.NoPermissions"));
if(!main.getInstance().getCheckManager().canBuild(p, location)){return;}
if(location.getBlock().getRelative(BlockFace.DOWN).getType() != null && BlackList.materialBlackList.contains(location.getBlock().getRelative(BlockFace.DOWN).getType())){return;}
List<UUID> emptyList = new ArrayList<UUID>();
if(!main.getInstance().crafting.containsValue(saveIS)){return;}
if(saveIS.equals(main.getInstance().crafting.get("sofa"))){
if(!Permissions.check(p, FurnitureType.SOFA, null)){p.sendMessage(noPermissions);return;}
if(main.getInstance().canPlace(p, location, Utils.yawToFace(location.getYaw()).getOppositeFace(), 3)){
sofa s = new sofa(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
s.save();
}else{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
return;
}
}
if(saveIS.equals(main.getInstance().crafting.get("lantern"))){
if(!Permissions.check(p, FurnitureType.LANTERN, null)){p.sendMessage(noPermissions);return;}
if(main.getInstance().canPlace(p, location, null, null)){
new latern(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
p.playEffect(location, Effect.STEP_SOUND, Material.TORCH);
}else{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
return;
}
}
if(saveIS.equals(main.getInstance().crafting.get("chair"))){
if(!Permissions.check(p, FurnitureType.CHAIR, null)){p.sendMessage(noPermissions);return;}
if(main.getInstance().canPlace(p, location, null, null)){
chair c = new chair(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
p.playEffect(location, Effect.STEP_SOUND, Material.WOOD);
c.save();
}else{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
return;
}
}
if(saveIS.equals(main.getInstance().crafting.get("table"))){
if(!Permissions.check(p, FurnitureType.TABLE, null)){p.sendMessage(noPermissions);return;}
if(main.getInstance().canPlace(p, location, null, null)){
table t = new table(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
p.playEffect(location, Effect.STEP_SOUND, Material.WOOD);
t.save();
}else{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
return;
}
}
if(saveIS.equals(main.getInstance().crafting.get("largeTable"))){
if(!Permissions.check(p, FurnitureType.LARGE_TABLE, null)){p.sendMessage(noPermissions);return;}
if(main.getInstance().canPlaceLarge(p, location, Utils.yawToFace(location.getYaw()).getOppositeFace(), 3,3)){
largeTable l = new largeTable(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
p.playEffect(location, Effect.STEP_SOUND, Material.GLASS);
l.save();
}else{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
return;
}
}
if(saveIS.equals(main.getInstance().crafting.get("tent1"))){
if(!Permissions.check(p, FurnitureType.TENT_1, null)){p.sendMessage(noPermissions);return;}
if(main.getInstance().canPlaceTent(p, location, Utils.yawToFace(location.getYaw()).getOppositeFace(), 5,4, 3)){
tent_1 tent = new tent_1(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
tent.save();
p.playEffect(location, Effect.STEP_SOUND, Material.WOOL);
}else{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
return;
}
}
if(saveIS.equals(main.getInstance().crafting.get("tent2"))){
if(!Permissions.check(p, FurnitureType.TENT_2, null)){p.sendMessage(noPermissions);return;}
if(main.getInstance().canPlaceTent(p, location, Utils.yawToFace(location.getYaw()).getOppositeFace(), 6,4, 3)){
tent_2 tent = new tent_2(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
tent.save();
p.playEffect(location, Effect.STEP_SOUND, Material.WOOL);
}else{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
return;
}
}
if(saveIS.equals(main.getInstance().crafting.get("campfire1"))){
if(!Permissions.check(p, FurnitureType.CAMPFIRE_1, null)){p.sendMessage(noPermissions);return;}
if(main.getInstance().canPlace(p, location, null, null)){
campfire_1 tent = new campfire_1(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
tent.save();
p.playEffect(location, Effect.STEP_SOUND, Material.WOOD);
}else{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
return;
}
}
if(saveIS.equals(main.getInstance().crafting.get("tent3"))){
if(!Permissions.check(p, FurnitureType.TENT_3, null)){p.sendMessage(noPermissions);return;}
if(main.getInstance().canPlaceTent(p, location, Utils.yawToFace(location.getYaw()).getOppositeFace(), 3,4, 2)){
tent_3 tent = new tent_3(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
tent.save();
p.playEffect(location, Effect.STEP_SOUND, Material.WOOL);
}else{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
return;
}
}
if(saveIS.equals(main.getInstance().crafting.get("barrels"))){
if(!Permissions.check(p, FurnitureType.BARRELS, null)){p.sendMessage(noPermissions);return;}
if(main.getInstance().canPlace(p, location,null,null)){
barrels tent = new barrels(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
tent.save();
p.playEffect(location, Effect.STEP_SOUND, Material.CAULDRON);
}else{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
return;
}
}
if(saveIS.equals(main.getInstance().crafting.get("campfire2"))){
if(!Permissions.check(p, FurnitureType.CAMPFIRE_2, null)){p.sendMessage(noPermissions);return;}
if(main.getInstance().canPlaceLarge(p, location, Utils.yawToFace(location.getYaw()), 2,2)){
campfire_2 tent = new campfire_2(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
tent.save();
p.playEffect(location, Effect.STEP_SOUND, Material.WOOD);
}else{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
return;
}
}
if(saveIS.equals(main.getInstance().crafting.get("camera"))){
if(!Permissions.check(p, FurnitureType.CAMERA, null)){p.sendMessage(noPermissions);return;}
if(main.getInstance().canPlace(p, location, null, null)){
camera tent = new camera(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
tent.save();
p.playEffect(location, Effect.STEP_SOUND, Material.WOOD);
}else{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
return;
}
}
if(!p.getGameMode().equals(GameMode.CREATIVE)){
is.setAmount(amount-1);
p.getInventory().setItem(hand, is);
p.updateInventory();
}
return;
}
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,30 +0,0 @@
package de.Ste3et_C0st.Furniture.Main;
import org.bukkit.Location;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import de.Ste3et_C0st.Furniture.Main.Type.FurnitureType;
public final class FurnitureCreateEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private FurnitureType furnitureType;
private Location l;
private String id;
private boolean cancelled;
public FurnitureCreateEvent(FurnitureType ft, String s, Location l) {
this.id = s;
this.l = l;
this.furnitureType = ft;
}
public HandlerList getHandlers() {return handlers;}
public Location getLocation(){return l;}
public FurnitureType getType(){return furnitureType;}
public String getID(){return this.id;}
public static HandlerList getHandlerList() {return handlers;}
public boolean isCancelled() {return cancelled;}
public void setCancelled(boolean arg0) {cancelled = arg0;}
}

View File

@ -1,86 +0,0 @@
package de.Ste3et_C0st.Furniture.Main.Manager;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Material;
public class BlackList {
public static List<Material> materialBlackList = Arrays.asList(
Material.SAPLING,
Material.WEB,
Material.LONG_GRASS,
Material.DEAD_BUSH,
Material.YELLOW_FLOWER,
Material.RED_ROSE,
Material.BROWN_MUSHROOM,
Material.RED_MUSHROOM,
Material.TORCH,
Material.CHEST,
Material.LADDER,
Material.SNOW,
Material.CACTUS,
Material.IRON_PLATE,
Material.THIN_GLASS,
Material.VINE,
Material.WATER_LILY,
Material.ENCHANTMENT_TABLE,
Material.ENDER_CHEST,
Material.ANVIL,
Material.TRAPPED_CHEST,
Material.STAINED_GLASS_PANE,
Material.CARPET,
Material.DOUBLE_PLANT,
Material.PAINTING,
Material.SIGN,
Material.SIGN_POST,
Material.WALL_SIGN,
Material.BANNER,
Material.WALL_BANNER,
Material.BED_BLOCK,
Material.ITEM_FRAME,
Material.FLOWER_POT,
Material.SKULL,
Material.LEVER,
Material.STONE_PLATE,
Material.WOOD_PLATE,
Material.REDSTONE,
Material.REDSTONE_COMPARATOR,
Material.REDSTONE_TORCH_OFF,
Material.REDSTONE_TORCH_ON,
Material.REDSTONE_WIRE,
Material.STONE_BUTTON,
Material.WOOD_BUTTON,
Material.TRIPWIRE_HOOK,
Material.TRIPWIRE,
Material.FENCE_GATE,
Material.GOLD_PLATE,
Material.IRON_TRAPDOOR,
Material.TRAP_DOOR,
Material.IRON_BARDING,
Material.DAYLIGHT_DETECTOR,
Material.DAYLIGHT_DETECTOR_INVERTED,
Material.SPRUCE_FENCE_GATE,
Material.SPRUCE_DOOR,
Material.BIRCH_DOOR,
Material.DARK_OAK_DOOR,
Material.JUNGLE_DOOR,
Material.ACACIA_DOOR,
Material.WOOD_DOOR,
Material.IRON_DOOR_BLOCK,
Material.RAILS,
Material.POWERED_RAIL,
Material.ACTIVATOR_RAIL,
Material.DETECTOR_RAIL,
Material.BEACON,
Material.BREWING_STAND,
Material.CAULDRON,
Material.WOOD_STAIRS,
Material.NETHER_WARTS,
Material.NETHER_BRICK_STAIRS,
Material.ACACIA_STAIRS,
Material.BRICK_STAIRS
);
}

View File

@ -1,55 +0,0 @@
package de.Ste3et_C0st.Furniture.Main.Manager;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
public class CheckManager {
ILandLord landlord = null;
IPlotMeCheck plotme = null;
IPlotSquaredCheck plotsquared = null;
IPreciousStones stones = null;
IResidence residence = null;
ITowny towny = null;
IGriefPrevention grief = null;
IPlotz plotz = null;
ILightAPI lightAPI = null;
IWolrdGuardCheck world = null;
public CheckManager(PluginManager pm){
if(isEnable("Landlord", pm)){this.landlord = new ILandLord(pm);}
if(isEnable("PlotMe", pm)){this.plotme = new IPlotMeCheck(pm);}
if(isEnable("PlotSquared", pm)){this.plotsquared = new IPlotSquaredCheck(pm);}
if(isEnable("PreciousStones", pm)){this.stones = new IPreciousStones(pm);}
if(isEnable("Residence", pm)){this.residence = new IResidence(pm);}
if(isEnable("Towny", pm)){this.towny = new ITowny(pm);}
if(isEnable("LightAPI", pm)){this.lightAPI = new ILightAPI(pm);}
if(isEnable("Plotz", pm)){this.plotz = new IPlotz(pm);}
if(isEnable("GriefPrevention", pm)){this.grief = new IGriefPrevention(pm);}
if(isEnable("WorldGuard", pm)){this.world = new IWolrdGuardCheck(pm);}
}
public ILightAPI getLightAPI(){
return this.lightAPI;
}
public boolean canBuild(Player p, Location l){
if(p.isOp()){return true;}
if((landlord == null || landlord.check(p, l)) &&
(plotme == null || plotme.check(p, l)) &&
(plotsquared == null || plotsquared.check(p, l)) &&
(stones == null || stones.check(p, l)) &&
(residence == null || residence.check(p, l)) &&
(towny == null || towny.check(p, l)) &&
(plotz == null || plotz.check(p, l)) &&
(grief == null || grief.check(p, l)) &&
(world == null || world.check(p, l))){
return true;
}
return false;
}
public boolean isEnable(String plugin, PluginManager pm){
return pm.isPluginEnabled(plugin);
}
}

View File

@ -1,292 +0,0 @@
package de.Ste3et_C0st.Furniture.Main.Manager;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.util.Vector;
import de.Ste3et_C0st.Furniture.Main.Type.FurnitureType;
import de.Ste3et_C0st.Furniture.Objects.electric.camera;
import de.Ste3et_C0st.Furniture.Objects.indoor.chair;
import de.Ste3et_C0st.Furniture.Objects.indoor.largeTable;
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.barrels;
import de.Ste3et_C0st.Furniture.Objects.outdoor.campfire_1;
import de.Ste3et_C0st.Furniture.Objects.outdoor.campfire_2;
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_1;
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_2;
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_3;
public class FurnitureManager {
public List<sofa> sofaList = new ArrayList<sofa>();
public List<latern> lanternList = new ArrayList<latern>();
public List<chair> chairList = new ArrayList<chair>();
public List<table> tableList = new ArrayList<table>();
public List<largeTable> largeTableList = new ArrayList<largeTable>();
public List<tent_1> tent1List = new ArrayList<tent_1>();
public List<tent_2> tent2List = new ArrayList<tent_2>();
public List<tent_3> tent3List = new ArrayList<tent_3>();
public List<barrels> barrelList = new ArrayList<barrels>();
public List<campfire_1> campfire1List = new ArrayList<campfire_1>();
public List<campfire_2> campfire2List = new ArrayList<campfire_2>();
public List<camera> cameraList = new ArrayList<camera>();
@SuppressWarnings("unchecked")
public boolean RemoveType(FurnitureType f, boolean b){
switch (f) {
case CHAIR:
if(chairList.isEmpty()){break;}
List<chair> chairL = ((List<chair>) ((ArrayList<chair>) chairList).clone());
for(chair s : chairL){s.delete(b, false);return true;}
case LARGE_TABLE:
if(largeTableList.isEmpty()){break;}
List<largeTable> LLT = ((List<largeTable>) ((ArrayList<largeTable>) largeTableList).clone());
for(largeTable s : LLT){s.delete(b,false);return true;}
case LANTERN:
if(lanternList.isEmpty()){break;}
List<latern> latetnL = ((List<latern>) ((ArrayList<latern>) lanternList).clone());
for(latern s : latetnL){s.delete(b,false);return true;}
case SOFA:
if(sofaList.isEmpty()){break;}
List<sofa> sofaL = ((List<sofa>) ((ArrayList<sofa>) sofaList).clone());
for(sofa s : sofaL){s.delete(b,false);return true;}
case TABLE:
if(tableList.isEmpty()){break;}
List<table> tableL = ((List<table>) ((ArrayList<table>) tableList).clone());
for(table s : tableL){s.delete(b,false);return true;}
case BARRELS:
if(barrelList.isEmpty()){break;}
List<barrels> barrelL = ((List<barrels>) ((ArrayList<barrels>) barrelList).clone());
for(barrels s : barrelL){s.delete(b,false);return true;}
case CAMPFIRE_1:
if(campfire1List.isEmpty()){break;}
List<campfire_1> camp1L = ((List<campfire_1>) ((ArrayList<campfire_1>) campfire1List).clone());
for(campfire_1 s : camp1L){s.delete(b,false);return true;}
case CAMPFIRE_2:
if(campfire2List.isEmpty()){break;}
List<campfire_2> camp2L = ((List<campfire_2>) ((ArrayList<campfire_2>) campfire2List).clone());
for(campfire_2 s : camp2L){s.delete(b,false);return true;}
case TENT_1:
if(tent1List.isEmpty()){break;}
List<tent_1> tent1L = ((List<tent_1>) ((ArrayList<tent_1>) tent1List).clone());
for(tent_1 s : tent1L){s.delete(b,false);return true;}
case TENT_2:
if(tent2List.isEmpty()){break;}
List<tent_2> tent2L = ((List<tent_2>) ((ArrayList<tent_2>) tent2List).clone());
for(tent_2 s : tent2L){s.delete(b,false);return true;}
case TENT_3:
if(tent3List.isEmpty()){break;}
List<tent_3> tent3L = ((List<tent_3>) ((ArrayList<tent_3>) tent3List).clone());
for(tent_3 s : tent3L){s.delete(b,false);return true;}
case CAMERA:
if(cameraList.isEmpty()){break;}
List<camera> cameraL = ((List<camera>) ((ArrayList<camera>) cameraList).clone());
for(camera s : cameraL){s.delete(b,false);return true;}
default: return false;
}
return false;
}
@SuppressWarnings("unchecked")
public boolean RemoveFromID(String ID){
if(ID==null){return false;}
if(!sofaList.isEmpty()){
List<sofa> sofaL = ((List<sofa>) ((ArrayList<sofa>) sofaList).clone());
for(sofa s : sofaL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
if(!lanternList.isEmpty()){
List<latern> sofaL = ((List<latern>) ((ArrayList<latern>) lanternList).clone());
for(latern s : sofaL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
if(!chairList.isEmpty()){
List<chair> sofaL = ((List<chair>) ((ArrayList<chair>) chairList).clone());
for(chair s : sofaL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
if(!tableList.isEmpty()){
List<table> sofaL = ((List<table>) ((ArrayList<table>) tableList).clone());
for(table s : sofaL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
if(!largeTableList.isEmpty()){
List<largeTable> sofaL = ((List<largeTable>) ((ArrayList<largeTable>) largeTableList).clone());
for(largeTable s : sofaL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
if(!tent1List.isEmpty()){
List<tent_1> sofaL = ((List<tent_1>) ((ArrayList<tent_1>) tent1List).clone());
for(tent_1 s : sofaL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
if(!tent2List.isEmpty()){
List<tent_2> sofaL = ((List<tent_2>) ((ArrayList<tent_2>) tent2List).clone());
for(tent_2 s : sofaL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
if(!tent3List.isEmpty()){
List<tent_3> sofaL = ((List<tent_3>) ((ArrayList<tent_3>) tent3List).clone());
for(tent_3 s : sofaL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
if(!barrelList.isEmpty()){
List<barrels> sofaL = ((List<barrels>) ((ArrayList<barrels>) barrelList).clone());
for(barrels s : sofaL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
if(!campfire1List.isEmpty()){
List<campfire_1> sofaL = ((List<campfire_1>) ((ArrayList<campfire_1>) campfire1List).clone());
for(campfire_1 s : sofaL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
if(!campfire2List.isEmpty()){
List<campfire_2> sofaL = ((List<campfire_2>) ((ArrayList<campfire_2>) campfire2List).clone());
for(campfire_2 s : sofaL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
if(!cameraList.isEmpty()){
List<camera> cameraL = ((List<camera>) ((ArrayList<camera>) cameraList).clone());
for(camera s : cameraL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
return false;
}
@SuppressWarnings("unchecked")
public boolean isAtLocation(Vector v, Double distance){
if(v==null){return false;}
if(distance==null){return false;}
if(!sofaList.isEmpty()){
List<sofa> sofaL = ((List<sofa>) ((ArrayList<sofa>) sofaList).clone());
for(sofa s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
}
}
if(!lanternList.isEmpty()){
List<latern> sofaL = ((List<latern>) ((ArrayList<latern>) lanternList).clone());
for(latern s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
}
}
if(!chairList.isEmpty()){
List<chair> sofaL = ((List<chair>) ((ArrayList<chair>) chairList).clone());
for(chair s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
}
}
if(!tableList.isEmpty()){
List<table> sofaL = ((List<table>) ((ArrayList<table>) tableList).clone());
for(table s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
}
}
if(!largeTableList.isEmpty()){
List<largeTable> sofaL = ((List<largeTable>) ((ArrayList<largeTable>) largeTableList).clone());
for(largeTable s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
}
}
if(!tent1List.isEmpty()){
List<tent_1> sofaL = ((List<tent_1>) ((ArrayList<tent_1>) tent1List).clone());
for(tent_1 s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
}
}
if(!tent2List.isEmpty()){
List<tent_2> sofaL = ((List<tent_2>) ((ArrayList<tent_2>) tent2List).clone());
for(tent_2 s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
}
}
if(!tent3List.isEmpty()){
List<tent_3> sofaL = ((List<tent_3>) ((ArrayList<tent_3>) tent3List).clone());
for(tent_3 s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
}
}
if(!barrelList.isEmpty()){
List<barrels> sofaL = barrelList.subList(0, barrelList.size());
for(barrels s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
}
}
if(!campfire1List.isEmpty()){
List<campfire_1> sofaL = ((List<campfire_1>) ((ArrayList<campfire_1>) campfire1List).clone());
for(campfire_1 s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
}
}
if(!campfire2List.isEmpty()){
List<campfire_2> sofaL = ((List<campfire_2>) ((ArrayList<campfire_2>) campfire2List).clone());
for(campfire_2 s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
}
}
if(!cameraList.isEmpty()){
List<camera> sofaL = ((List<camera>) ((ArrayList<camera>) cameraList).clone());
for(camera s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
}
}
return false;
}
@SuppressWarnings("unchecked")
public Integer RemoveFromDistance(Vector v, Double distance){
if(v==null){return null;}
if(distance==null){return null;}
Integer i=0;
if(!sofaList.isEmpty()){
List<sofa> sofaL = ((List<sofa>) ((ArrayList<sofa>) sofaList).clone());
for(sofa s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true,false);i++;}
}
}
if(!lanternList.isEmpty()){
List<latern> sofaL = ((List<latern>) ((ArrayList<latern>) lanternList).clone());
for(latern s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true, false);i++;}
}
}
if(!chairList.isEmpty()){
List<chair> sofaL = ((List<chair>) ((ArrayList<chair>) chairList).clone());
for(chair s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true, false);i++;}
}
}
if(!tableList.isEmpty()){
List<table> sofaL = ((List<table>) ((ArrayList<table>) tableList).clone());
for(table s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true, false);i++;}
}
}
if(!largeTableList.isEmpty()){
List<largeTable> sofaL = ((List<largeTable>) ((ArrayList<largeTable>) largeTableList).clone());
for(largeTable s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true, false);i++;}
}
}
if(!tent1List.isEmpty()){
List<tent_1> sofaL = ((List<tent_1>) ((ArrayList<tent_1>) tent1List).clone());
for(tent_1 s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true, false);i++;}
}
}
if(!tent2List.isEmpty()){
List<tent_2> sofaL = ((List<tent_2>) ((ArrayList<tent_2>) tent2List).clone());
for(tent_2 s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true, false);i++;}
}
}
if(!tent3List.isEmpty()){
List<tent_3> sofaL = ((List<tent_3>) ((ArrayList<tent_3>) tent3List).clone());
for(tent_3 s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true, false);i++;}
}
}
if(!barrelList.isEmpty()){
List<barrels> sofaL = barrelList.subList(0, barrelList.size());
for(barrels s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true, false);i++;}
}
}
if(!campfire1List.isEmpty()){
List<campfire_1> sofaL = ((List<campfire_1>) ((ArrayList<campfire_1>) campfire1List).clone());
for(campfire_1 s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true, false);i++;}
}
}
if(!campfire2List.isEmpty()){
List<campfire_2> sofaL = ((List<campfire_2>) ((ArrayList<campfire_2>) campfire2List).clone());
for(campfire_2 s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true, false);i++;}
}
}
if(!cameraList.isEmpty()){
List<camera> sofaL = ((List<camera>) ((ArrayList<camera>) cameraList).clone());
for(camera s : sofaL){
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true, false);i++;}
}
}
return i;
}
}

View File

@ -1,37 +0,0 @@
package de.Ste3et_C0st.Furniture.Main.Manager;
import me.ryanhamshire.GriefPrevention.Claim;
import me.ryanhamshire.GriefPrevention.GriefPrevention;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import de.Ste3et_C0st.Furniture.Main.main;
public class IGriefPrevention {
Boolean enabled = false;
PluginManager pm = null;
GriefPrevention wg = null;
public IGriefPrevention(PluginManager pm){
if(!main.getInstance().getConfig().getBoolean("config.Protection.GriefPrevention.HookIFExist")){return;}
main.getInstance().getLogger().info("[Furniture] Hook into GriefPrevention");
this.pm = pm;
this.enabled = true;
wg = (GriefPrevention) pm.getPlugin("GriefPrevention");
}
public boolean check(Player p, Location l){
if(p.isOp()){return true;}
if(!this.enabled){return true;}
if(this.wg == null){return true;}
try{
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(l, false, null);
if(claim==null || claim.ownerID == null){return true;}
if(claim.ownerID.equals(p.getUniqueId())){return true;}
return false;
}catch(Exception e){
return true;
}
}
}

View File

@ -1,39 +0,0 @@
package de.Ste3et_C0st.Furniture.Main.Manager;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import com.jcdesimp.landlord.Landlord;
import com.jcdesimp.landlord.persistantData.Friend;
import com.jcdesimp.landlord.persistantData.OwnedLand;
import de.Ste3et_C0st.Furniture.Main.main;
public class ILandLord {
Boolean enabled = false;
PluginManager pm = null;
Landlord wg = null;
public ILandLord(PluginManager pm){
if(!main.getInstance().getConfig().getBoolean("config.Protection.LandLord.HookIFExist")){return;}
main.getInstance().getLogger().info("[Furniture] Hook into LandLord");
this.pm = pm;
this.enabled = true;
wg = (Landlord) pm.getPlugin("Landlord");
}
public boolean check(Player p, Location l){
if(p.isOp()){return true;}
if(!this.enabled){return true;}
if(this.wg == null){return true;}
try{
OwnedLand ow = OwnedLand.getApplicableLand(l);
if(ow==null){return true;}
if(ow.getOwnerUUID().equals(p.getUniqueId())){return true;}
if(ow.getFriends().contains(Friend.friendFromPlayer(p))){return true;}
return false;
}catch(Exception e){
return true;
}
}
}

View File

@ -1,19 +0,0 @@
package de.Ste3et_C0st.Furniture.Main.Manager;
import org.bukkit.plugin.PluginManager;
import de.Ste3et_C0st.Furniture.Main.main;
import ru.BeYkeRYkt.LightAPI.LightAPI;
public class ILightAPI {
LightAPI lightAPI = null;
public ILightAPI(PluginManager pm){
main.getInstance().getLogger().info("[Furniture] Hook into LightAPI");
this.lightAPI = (LightAPI) pm.getPlugin("LightAPI");
}
public LightAPI getLightAPI(){
return this.lightAPI;
}
}

View File

@ -1,45 +0,0 @@
package de.Ste3et_C0st.Furniture.Main.Manager;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import com.worldcretornica.plotme_core.Plot;
import com.worldcretornica.plotme_core.PlotMeCoreManager;
import com.worldcretornica.plotme_core.api.ILocation;
import com.worldcretornica.plotme_core.api.IWorld;
import com.worldcretornica.plotme_core.bukkit.api.BukkitLocation;
import com.worldcretornica.plotme_core.bukkit.api.BukkitWorld;
import de.Ste3et_C0st.Furniture.Main.main;
public class IPlotMeCheck {
Boolean enabled = false;
PluginManager pm = null;
PlotMeCoreManager wg = null;
public IPlotMeCheck(PluginManager pm){
if(!main.getInstance().getConfig().getBoolean("config.Protection.PlotME.HookIFExist")){return;}
main.getInstance().getLogger().info("[Furniture] Hook into PlotMe");
this.pm = pm;
this.enabled = true;
wg = PlotMeCoreManager.getInstance();
}
public boolean check(Player p, Location l){
if(p.isOp()){return true;}
if(!this.enabled){return true;}
if(this.wg == null){return true;}
try{
IWorld iworld = new BukkitWorld(p.getWorld());
if(!wg.isPlotWorld(iworld)){return true;}
ILocation plotLoc = new BukkitLocation(l);
String id = wg.getPlotId(plotLoc);
if (id.isEmpty()){return false;}
Plot plot = wg.getPlotById(id, iworld);
if(plot == null){return false;}
if(plot.isAllowed(p.getUniqueId())){return true;}else{return false;}
}catch(Exception e){
return true;
}
}
}

View File

@ -1,41 +0,0 @@
package de.Ste3et_C0st.Furniture.Main.Manager;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions;
import de.Ste3et_C0st.Furniture.Main.main;
public class IPlotSquaredCheck {
Boolean enabled = false;
PluginManager pm = null;
/*http://share.gifyoutube.com/y0VOzz.gif*/
Plugin wg = null;
public IPlotSquaredCheck(PluginManager pm){
if(!main.getInstance().getConfig().getBoolean("config.Protection.PlotSquared.HookIFExist")){return;}
main.getInstance().getLogger().info("[Furniture] Hook into PlotSquared");
this.pm = pm;
this.enabled = true;
wg = pm.getPlugin("PlotSquared");
}
public boolean check(Player p, Location l){
if(p.isOp()){return true;}
if(!this.enabled){return true;}
if(this.wg == null){return true;}
try{
Plot plot = BukkitPlayerFunctions.getCurrentPlot(p);
if(plot==null){return false;}
if(plot.isAdded(p.getUniqueId()) || plot.isOwner(p.getUniqueId())){
return true;
}
return false;
}catch(Exception e){
return true;
}
}
}

View File

@ -1,37 +0,0 @@
package de.Ste3et_C0st.Furniture.Main.Manager;
import me.kyle.plotz.api.Plotz;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import de.Ste3et_C0st.Furniture.Main.main;
public class IPlotz {
Boolean enabled = false;
PluginManager pm = null;
Plotz wg = null;
public IPlotz(PluginManager pm){
if(!main.getInstance().getConfig().getBoolean("config.Protection.Plotz.HookIFExist")){return;}
main.getInstance().getLogger().info("[Furniture] Hook into Plotz");
this.pm = pm;
this.enabled = true;
wg = (Plotz) pm.getPlugin("PLotz");
}
@SuppressWarnings("static-access")
public boolean check(Player p, Location l){
if(p.isOp()){return true;}
if(!this.enabled){return true;}
if(this.wg == null){return true;}
try{
if(wg.getPlotByLocation(l)==null){return false;}
if(wg.getPlotByLocation(l).isOwner(p)){return true;}
if(wg.getPlotByLocation(l).isAllowed(p)){return true;}
return false;
}catch(Exception e){
return true;
}
}
}

View File

@ -1,44 +0,0 @@
package de.Ste3et_C0st.Furniture.Main.Manager;
import java.util.List;
import net.sacredlabyrinth.Phaed.PreciousStones.FieldFlag;
import net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones;
import net.sacredlabyrinth.Phaed.PreciousStones.vectors.Field;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import de.Ste3et_C0st.Furniture.Main.main;
public class IPreciousStones {
Boolean enabled = false;
PluginManager pm = null;
PreciousStones wg = null;
public IPreciousStones(PluginManager pm){
if(!main.getInstance().getConfig().getBoolean("config.Protection.PreciousStones.HookIFExist")){return;}
main.getInstance().getLogger().info("[Furniture] Hook into PreciousStones");
this.pm = pm;
this.enabled = true;
wg = (PreciousStones) pm.getPlugin("PreciousStones");
}
public boolean check(Player p, Location l){
if(p.isOp()){return true;}
if(!this.enabled){return true;}
if(this.wg == null){return true;}
try{
List<Field> fields = PreciousStones.API().getFieldsProtectingArea(FieldFlag.ALL, l);
if ((fields == null) || (fields.size() == 0)){ return true; }else{
Field stones = (Field)fields.get(0);
if(stones.isBuyer(p)){
return true;
}
return false;
}
}catch(Exception e){
return true;
}
}
}

View File

@ -1,38 +0,0 @@
package de.Ste3et_C0st.Furniture.Main.Manager;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import com.bekvon.bukkit.residence.Residence;
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
import de.Ste3et_C0st.Furniture.Main.main;
public class IResidence {
Boolean enabled = false;
PluginManager pm = null;
Residence wg = null;
public IResidence(PluginManager pm){
if(!main.getInstance().getConfig().getBoolean("config.Protection.Residence.HookIFExist")){return;}
main.getInstance().getLogger().info("[Furniture] Hook into Residence");
this.pm = pm;
this.enabled = true;
wg = (Residence) pm.getPlugin("Residence");
}
public boolean check(Player p, Location l){
if(p.isOp()){return true;}
if(!this.enabled){return true;}
if(this.wg == null){return true;}
try{
ClaimedResidence residence = Residence.getResidenceManager().getByLoc(l);
if(residence==null||residence.getOwner().equalsIgnoreCase(p.getName())||residence.getOwner().equalsIgnoreCase(p.getUniqueId().toString())){
return true;
}
return false;
}catch(Exception e){
return true;
}
}
}

View File

@ -1,45 +0,0 @@
package de.Ste3et_C0st.Furniture.Main.Manager;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import com.palmergames.bukkit.towny.Towny;
import de.Ste3et_C0st.Furniture.Main.main;
public class ITowny {
Boolean enabled = false;
PluginManager pm = null;
Towny wg = null;
public ITowny(PluginManager pm){
if(!main.getInstance().getConfig().getBoolean("config.Protection.Towny.HookIFExist")){return;}
if(!pm.isPluginEnabled("Towny")){return;}
this.pm = pm;
this.enabled = true;
wg = (Towny) pm.getPlugin("Towny");
}
public boolean check(Player p, Location l){
if(p.isOp()){return true;}
if(!this.enabled){return true;}
if(this.wg == null){return true;}
try{
if (ITownyPermission.has(p, ITownyPermission.PROTECTION_BYPASS)) {
return true;
}
if(main.getInstance().getConfig().getBoolean("config.Towny.OnlyOwner")){
return TownyUtils.isPlotOwner(p, new Location[] { l });
}else{
if(TownyUtils.isPlotOwner(p, new Location[] { l }) ||
TownyUtils.isResident(p, new Location[] { l })){
return true;
}
}
return false;
}catch(Exception e){
return true;
}
}
}

View File

@ -1,36 +0,0 @@
package de.Ste3et_C0st.Furniture.Main.Manager;
import org.bukkit.entity.Player;
public enum ITownyPermission
{
PROTECTION_BYPASS("Furniture.towny.bypass");
private final String permission;
private ITownyPermission(String permission)
{
this.permission = permission;
}
public static boolean has(Player player, ITownyPermission permission)
{
return has(player, permission.permission);
}
public static boolean has(Player player, String node)
{
return (player.hasPermission(node)) || (player.hasPermission(node.toLowerCase()));
}
@SuppressWarnings("unused")
private static boolean hasPermissionSet(Player p, String perm)
{
return (p.isPermissionSet(perm)) && (p.hasPermission(perm));
}
public String toString()
{
return this.permission;
}
}

View File

@ -1,32 +0,0 @@
package de.Ste3et_C0st.Furniture.Main.Manager;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import de.Ste3et_C0st.Furniture.Main.main;
public class IWolrdGuardCheck {
Boolean enabled = false;
PluginManager pm = null;
WorldGuardPlugin wg = null;
public IWolrdGuardCheck(PluginManager pm){
if(!main.getInstance().getConfig().getBoolean("config.Protection.WorldGuard.HookIFExist")){return;}
this.pm = pm;
this.enabled = true;
wg = (WorldGuardPlugin) pm.getPlugin("WorldGuard");
}
public boolean check(Player p, Location l){
if(p.isOp()){return true;}
if(!this.enabled){return true;}
if(this.wg == null){return true;}
try{
return this.wg.canBuild(p, l);
}catch(Exception e){
return true;
}
}
}

View File

@ -1,498 +0,0 @@
package de.Ste3et_C0st.Furniture.Main.Manager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.config;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.Furniture.Main.option;
import de.Ste3et_C0st.Furniture.Objects.electric.camera;
import de.Ste3et_C0st.Furniture.Objects.indoor.chair;
import de.Ste3et_C0st.Furniture.Objects.indoor.largeTable;
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.barrels;
import de.Ste3et_C0st.Furniture.Objects.outdoor.campfire_1;
import de.Ste3et_C0st.Furniture.Objects.outdoor.campfire_2;
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_1;
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_2;
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_3;
public class Manager {
private static config cc;
private static FileConfiguration fc;
private String folder = "/objects/";
public void load(String s){
cc = new config();
option o = new option();
try{
if(cc.ExistConfig(folder, s+ ".yml")){
fc = cc.getConfig(s+".yml", folder);
if(fc.isSet("Furniture."+s)){
for(String str : fc.getConfigurationSection("Furniture." + s).getKeys(false)){
String path = "Furniture." + s;
path+= "." + str;
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);
List<UUID> uuidList = Utils.StringListToUUIDList(fc.getStringList(path+".UUUIDs"));
if(uuidList==null){
main.getInstance().getLogger().warning("Unknow data found pls remove ["+ s +".yml]");
main.getInstance().getLogger().warning("If you use a HealthBar plugin pls use the command");
main.getInstance().getLogger().warning("/kill @e[type=ArmorStand] {Invisible:1b,NoBasePlate:1b,NoGravity:1b}");
main.getInstance().getLogger().warning("Then you dont use a healthbar plugin run /furniture killall");
}else{
for(Entity e : w.getEntities()){
if(e!=null && e instanceof ArmorStand && uuidList.contains(e.getUniqueId())){
e.remove();
}
}
uuidList.clear();
}
float yaw = Utils.FaceToYaw(Utils.StringToFace(face));
l.setYaw(yaw);
if(s.equalsIgnoreCase("chair")){
new chair(l, main.getInstance(), str, uuidList);
}
if(s.equalsIgnoreCase("camera")){
l.setYaw(Utils.FaceToYaw(Utils.StringToFace(face).getOppositeFace()));
new camera(l, main.getInstance(), str, uuidList);
}
if(s.equalsIgnoreCase("largeTable")){
largeTable large = new largeTable(l, main.getInstance(), str, uuidList);
o.loadOptions(fc, large);
}
if(s.equalsIgnoreCase("lantern")){
latern later = new latern(l, main.getInstance(), str, uuidList);
o.loadOptions(fc, later);
}
if(s.equalsIgnoreCase("sofa")){
sofa sof = new sofa(l, main.getInstance(), str, uuidList);
o.loadOptions(fc, sof);
}
if(s.equalsIgnoreCase("table")){
table tabl = new table(l, main.getInstance(), str, uuidList);
o.loadOptions(fc, tabl);
}
if(s.equalsIgnoreCase("tent1")){
tent_1 tent = new tent_1(l, main.getInstance(), str, uuidList);
o.loadOptions(fc, tent);
}
if(s.equalsIgnoreCase("tent2")){
tent_2 tent = new tent_2(l, main.getInstance(), str, uuidList);
o.loadOptions(fc, tent);
}
if(s.equalsIgnoreCase("tent3")){
tent_3 tent = new tent_3(l, main.getInstance(), str, uuidList);
o.loadOptions(fc, tent);
}
if(s.equalsIgnoreCase("campfire1")){
campfire_1 fire = new campfire_1(l, main.getInstance(), str, uuidList);
o.loadOptions(fc, fire);
}
if(s.equalsIgnoreCase("campfire2")){
campfire_2 fire = new campfire_2(l, main.getInstance(), str, uuidList);
o.loadOptions(fc, fire);
}
if(s.equalsIgnoreCase("barrels")){
barrels fire = new barrels(l, main.getInstance(), str, uuidList);
o.loadOptions(fc, fire);
}
}
}
}
}catch(Exception e){
main.getInstance().shutdown("Config " + s);
}
}
public void saveStuhl(chair c){
cc = new config();
fc = cc.getConfig("chair",folder );
if(!main.getInstance().getManager().chairList.isEmpty()){
if(c==null){
for(chair s : main.getInstance().getManager().chairList){
save(s.getLocation(), "chair", s.getID(),s.getList());
}
}else{
save(c.getLocation(), "chair", c.getID(), c.getList());
}
}
cc.saveConfig("chair", fc, folder);
}
public void saveCamera(camera c) {
cc = new config();
fc = cc.getConfig("camera",folder );
if(!main.getInstance().getManager().cameraList.isEmpty()){
if(c==null){
for(camera s : main.getInstance().getManager().cameraList){
save(s.getLocation(), "camera", s.getID(),s.getList());
}
}else{
save(c.getLocation(), "camera", c.getID(), c.getList());
}
}
cc.saveConfig("camera", fc, folder);
}
public void saveLatern(latern l){
cc = new config();
fc = cc.getConfig("lantern",folder );
option o = new option();
if(!main.getInstance().getManager().lanternList.isEmpty()){
if(l==null){
for(latern s : main.getInstance().getManager().lanternList){
save(s.getLocation(), "lantern", s.getID(),s.getList());
o.saveOption(fc, s);
}
}else{
save(l.getLocation(), "lantern", l.getID(), l.getList());
o.saveOption(fc, l);
}
}
cc.saveConfig("lantern", fc, folder);
}
public void saveCampFire1(campfire_1 l){
cc = new config();
fc = cc.getConfig("campfire1",folder );
option o = new option();
if(!main.getInstance().getManager().campfire1List.isEmpty()){
if(l==null){
for(campfire_1 s : main.getInstance().getManager().campfire1List){
save(s.getLocation(), "campfire1", s.getID(),s.getList());
o.saveOption(fc, s);
}
}else{
save(l.getLocation(), "campfire1", l.getID(), l.getList());
o.saveOption(fc, l);
}
}
cc.saveConfig("campfire1", fc, folder);
}
public void saveCampFire2(campfire_2 l){
cc = new config();
fc = cc.getConfig("campfire2",folder );
option o = new option();
if(!main.getInstance().getManager().campfire2List.isEmpty()){
if(l==null){
for(campfire_2 s : main.getInstance().getManager().campfire2List){
save(s.getLocation(), "campfire2", s.getID(),s.getList());
o.saveOption(fc, s);
}
}else{
save(l.getLocation(), "campfire2", l.getID(), l.getList());
o.saveOption(fc, l);
}
}
cc.saveConfig("campfire2", fc, folder);
}
public void save(Location l, String file, String ID, List<String> list){
String path = "Furniture." + file;
path = "Furniture."+file+"."+ID;
fc.set(path+".Location.x",round(l.getX(), 2));
fc.set(path+".Location.y",round(l.getY(), 2));
fc.set(path+".Location.z",round(l.getZ(), 2));
fc.set(path+".Location.w", l.getWorld().getName());
fc.set(path+".Location.face", Utils.yawToFace(l.getYaw()).name());
fc.set(path+".UUUIDs", list);
}
public void saveSofa(sofa sof){
cc = new config();
fc = cc.getConfig("sofa",folder );
option o = new option();
if(!main.getInstance().getManager().sofaList.isEmpty()){
if(sof==null){
for(sofa s : main.getInstance().getManager().sofaList){
save(s.getLocation(), "sofa", s.getID(),s.getList());
o.saveOption(fc, s);
}
}else{
save(sof.getLocation(), "sofa", sof.getID(), sof.getList());
o.saveOption(fc, sof);
}
}
cc.saveConfig("sofa", fc, folder);
}
public void saveTable(table t){
cc = new config();
fc = cc.getConfig("table",folder );
option o = new option();
if(!main.getInstance().getManager().tableList.isEmpty()){
if(t==null){
for(table s : main.getInstance().getManager().tableList){
save(s.getLocation(), "table", s.getID(),s.getList());
o.saveOption(fc, s);
}
}else{
save(t.getLocation(), "table", t.getID(), t.getList());
o.saveOption(fc, t);
}
}
cc.saveConfig("table", fc, folder);
}
public void saveBarrel(barrels barrel) {
cc = new config();
fc = cc.getConfig("barrels",folder );
option o = new option();
if(!main.getInstance().getManager().barrelList.isEmpty()){
if(barrel==null){
for(barrels s : main.getInstance().getManager().barrelList){
save(s.getLocation(), "barrels", s.getID(),s.getList());
o.saveOption(fc, s);
}
}else{
save(barrel.getLocation(), "barrels", barrel.getID(), barrel.getList());
o.saveOption(fc, barrel);
}
}
cc.saveConfig("barrels", fc, folder);
}
public void saveTent1(tent_1 tent){
cc = new config();
fc = cc.getConfig("tent1",folder );
option o = new option();
if(!main.getInstance().getManager().tent1List.isEmpty()){
if(tent == null){
for(tent_1 s : main.getInstance().getManager().tent1List){
save(s.getLocation(), "tent1", s.getID(),s.getList());
o.saveOption(fc, s);
}
}else{
save(tent.getLocation(), "tent1", tent.getID(),tent.getList());
o.saveOption(fc, tent);
}
}
cc.saveConfig("tent1", fc, folder);
}
public void saveLargeTable(largeTable table){
cc = new config();
fc = cc.getConfig("largeTable",folder );
option o = new option();
if(!main.getInstance().getManager().largeTableList.isEmpty()){
if(table == null){
for(largeTable s : main.getInstance().getManager().largeTableList){
save(s.getLocation(), "largeTable", s.getID(),s.getList());
o.saveOption(fc, s);
}
}else{
save(table.getLocation(), "largeTable", table.getID(),table.getList());
o.saveOption(fc, table);
}
}
cc.saveConfig("largeTable", 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){
try{
if(!check(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));
}
}
Bukkit.getServer().addRecipe(recipe);
}
main.getInstance().crafting.put(s, returnResult(s));
}catch(Exception e){
main.getInstance().shutdown("Crafting");
}
}
public boolean check(String s){
cc = new config();
fc = cc.getConfig("crafting.yml", "");
String path = "Items." + s;
return fc.getBoolean(path + ".crafting.disable");
}
@SuppressWarnings("deprecation")
public ItemStack returnResult(String s){
cc = new config();
fc = cc.getConfig("crafting.yml", "");
String path = "Items." + s;
String MaterialSubID = path+".material";
short durability = 0;
if(MaterialSubID.contains(":")){
String[] split = MaterialSubID.split(":");
durability = (short) Integer.parseInt(split[1]);
}
Integer MaterialID = fc.getInt(path+".material");
ItemStack is = new ItemStack(Material.getMaterial(MaterialID));
ItemMeta im = is.getItemMeta();
im.setDisplayName(ChatColor.translateAlternateColorCodes('&', fc.getString(path+".name")));
is.setItemMeta(im);
is.setDurability(durability);
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;
}
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 saveTent2(tent_2 tent) {
cc = new config();
fc = cc.getConfig("tent2",folder );
option o = new option();
if(!main.getInstance().getManager().tent2List.isEmpty()){
if(tent == null){
for(tent_2 s : main.getInstance().getManager().tent2List){
save(s.getLocation(), "tent2", s.getID(),s.getList());
o.saveOption(fc, s);
}
}else{
save(tent.getLocation(), "tent2", tent.getID(),tent.getList());
o.saveOption(fc, tent);
}
}
cc.saveConfig("tent2", fc, folder);
}
public void saveTent3(tent_3 tent) {
cc = new config();
fc = cc.getConfig("tent3",folder );
option o = new option();
if(!main.getInstance().getManager().tent3List.isEmpty()){
if(tent == null){
for(tent_3 s : main.getInstance().getManager().tent3List){
save(s.getLocation(), "tent3", s.getID(),s.getList());
o.saveOption(fc, s);
}
}else{
save(tent.getLocation(), "tent3", tent.getID(),tent.getList());
o.saveOption(fc, tent);
}
}
cc.saveConfig("tent3", fc, folder);
}
}

View File

@ -1,66 +0,0 @@
package de.Ste3et_C0st.Furniture.Main.Manager;
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
import com.palmergames.bukkit.towny.object.TownBlockOwner;
import com.palmergames.bukkit.towny.object.TownyUniverse;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public class TownyUtils
{
public static boolean isResident(Player player, Location location)
{
try
{
return TownyUniverse.getTownBlock(location).getTown().hasResident(player.getName());
}
catch (NotRegisteredException ex) {}
return false;
}
public static boolean isResident(Player player, Location... locations)
{
for (Location location : locations) {
if (!isResident(player, location)) {
return false;
}
}
return true;
}
public static boolean isPlotOwner(Player player, Location location)
{
try
{
TownBlockOwner owner = TownyUniverse.getDataSource().getResident(player.getName());
return TownyUniverse.getTownBlock(location).isOwner(owner);
}
catch (NotRegisteredException ex) {}
return false;
}
public static boolean isPlotOwner(Player player, Location... locations)
{
for (Location location : locations) {
if (!isPlotOwner(player, location)) {
return false;
}
}
return true;
}
public static boolean isInWilderness(Location location)
{
return TownyUniverse.isWilderness(location.getBlock());
}
public static boolean isInWilderness(Location... locations)
{
for (Location location : locations) {
if ((location != null) && (!isInWilderness(location))) {
return false;
}
}
return true;
}
}

View File

@ -1,16 +0,0 @@
package de.Ste3et_C0st.Furniture.Main;
import org.bukkit.entity.Player;
import de.Ste3et_C0st.Furniture.Main.Type.FurnitureType;
public class Permissions {
public static boolean check(Player p, FurnitureType type, String s){
if(s == null){s="";}
String typ = type.name().toLowerCase();
typ = typ.replace("_", "");
if(!main.getInstance().isDestroyable && s.contains("destroy")){return true;}
if(p.hasPermission("furniture." + s + typ) || p.isOp() || p.hasPermission("furniture.player")){return true;}
return false;
}
}

View File

@ -1,14 +0,0 @@
package de.Ste3et_C0st.Furniture.Main;
public class Type {
public enum FurnitureType{
CHAIR, LARGE_TABLE, LANTERN, SOFA,
TABLE, BARRELS, CAMPFIRE_1, CAMPFIRE_2,
TENT_1, TENT_2, TENT_3, CAMERA
};
public enum HeadArmType{
HEAD, ARM
}
}

View File

@ -1,526 +0,0 @@
package de.Ste3et_C0st.Furniture.Main;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
import de.Ste3et_C0st.Furniture.Main.Type.HeadArmType;
public class Utils {
public static final BlockFace[] axis = { BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST };
public static List<BlockFace> axisList = Arrays.asList(BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST);
public static final BlockFace[] radial = { BlockFace.NORTH, BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST, BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST };
public static BlockFace yawToFaceRadial(float yaw) {
return radial[Math.round(yaw / 45f) & 0x7];
}
public static BlockFace yawToFace(float yaw) {
return axis[Math.round(yaw / 90f) & 0x3];
}
public static BlockFace yawToFace(float yaw, float pitch) {
if(pitch<-80){
return BlockFace.UP;
}else if(pitch>80){
return BlockFace.DOWN;
}
return axis[Math.round(yaw / 90f) & 0x3];
}
public static EulerAngle degresstoRad(EulerAngle degressAngle){
return new EulerAngle(degressAngle.getX() * Math.PI / 180, degressAngle.getY() * Math.PI / 180, degressAngle.getZ() * Math.PI / 180);
}
public static EulerAngle Radtodegress(EulerAngle degressAngle){
return new EulerAngle(degressAngle.getX() * 180 / Math.PI, degressAngle.getY() * 180 / Math.PI, degressAngle.getZ() * 180 / Math.PI);
}
public static int FaceToYaw(final BlockFace face) {
switch (face) {
case NORTH: return 0;
case NORTH_EAST: return 45;
case EAST: return 90;
case SOUTH_EAST: return 135;
case SOUTH: return 180;
case SOUTH_WEST: return 225;
case WEST: return 270;
case NORTH_WEST: return 315;
default: return 0;
}
}
public static List<String> UUIDListToStringList(List<UUID> list){
if(list==null){return null;}
List<String> stringList = new ArrayList<String>();
for(UUID uuid : list){
stringList.add(uuid.toString());
}
return stringList;
}
public static List<UUID> StringListToUUIDList(List<String> list){
if(list==null){return null;}
List<UUID> stringList = new ArrayList<UUID>();
for(String s : list){
stringList.add(UUID.fromString(s));
}
return stringList;
}
public static List<UUID> replace(Entity e, List<UUID> uuid){
if(e==null){return null;}
if(e.getName()==null){return null;}
if(e instanceof ArmorStand == false){return null;}
if(e.getName().length()>=13){
String[] split = e.getName().split("-");
if(split != null && split.length>=1){
if(!uuid.contains(e.getUniqueId())){
uuid.add(e.getUniqueId());
return uuid;
}
}
}
return uuid;
}
public static boolean day(World w) {
long time = w.getTime();
if(time > 0 && time < 12300) {
return true;
} else {
return false;
}
}
public static Vector getRelative(Vector v1, Vector v2){
return new Vector(v1.getX()-v2.getX(), v1.getY()-v2.getY(), v1.getZ()-v2.getZ());
}
public static Vector getRelativ(Vector v1, Double x, BlockFace bf){
// N
// W E
// S
switch(bf){
case NORTH: v1.add(new Vector(0, 0,x)); break;
/*case NORTH_EAST:
v1.add(new Vector(0, 0, x));
v1.add(new Vector(-x, 0, 0));
break;
case NORTH_NORTH_EAST:
v1.add(new Vector(0, 0, x));
v1.add(new Vector(0, 0, x));
v1.add(new Vector(-x, 0, 0));
break;
case NORTH_NORTH_WEST:
v1.add(new Vector(0, 0, x));
v1.add(new Vector(0, 0, x));
v1.add(new Vector(x, 0, 0));
break;
case NORTH_WEST:
v1.add(new Vector(0, 0, x));
v1.add(new Vector(x, 0, 0));
break;*/
case EAST: v1.add(new Vector(x, 0, 0)); break;
/*case EAST_NORTH_EAST:
v1.add(new Vector(-x, 0, 0));
v1.add(new Vector(0, 0, x));
v1.add(new Vector(-x, 0, 0));
break;
case EAST_SOUTH_EAST:
v1.add(new Vector(-x, 0, 0));
v1.add(new Vector(0, 0, -x));
v1.add(new Vector(-x, 0, 0));
break;*/
case SOUTH: v1.add(new Vector(0, 0,-x)); break;
/*case SOUTH_EAST:
v1.add(new Vector(0, 0, -x));
v1.add(new Vector(-x, 0, 0));
break;
case SOUTH_SOUTH_EAST:
v1.add(new Vector(0, 0, -x));
v1.add(new Vector(0, 0, -x));
v1.add(new Vector(-x, 0, 0));
break;
case SOUTH_SOUTH_WEST:
v1.add(new Vector(0, 0, -x));
v1.add(new Vector(0, 0, -x));
v1.add(new Vector(x, 0, 0));
break;
case SOUTH_WEST:
v1.add(new Vector(0, 0, -x));
v1.add(new Vector(x, 0, 0));
break;*/
case WEST: v1.add(new Vector(x, 0, 0)); break;
/*case WEST_NORTH_WEST:
v1.add(new Vector(x, 0, 0));
v1.add(new Vector(0, 0, x));
v1.add(new Vector(x, 0, 0));
break;
case WEST_SOUTH_WEST:
v1.add(new Vector(x, 0, 0));
v1.add(new Vector(0, 0, -x));
v1.add(new Vector(x, 0, 0));
break;*/
case DOWN:v1.add(new Vector(0, -x, 0));break;
case UP:v1.add(new Vector(0, x, 0));break;
default: v1.add(new Vector(x, 0, 0)); break;
}
return v1;
}
public static HeadArmType haTgetByString(String s){
if(s.equalsIgnoreCase("ARM")){return HeadArmType.ARM;}
if(s.equalsIgnoreCase("HEAD")){return HeadArmType.HEAD;}
return HeadArmType.HEAD;
}
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;
case "UP": return BlockFace.UP;
case "DOWN": return BlockFace.DOWN;
case "NORTH_NORTH_EAST": return BlockFace.NORTH_NORTH_EAST;
case "NORTH_NORTH_WEST": return BlockFace.NORTH_NORTH_WEST;
case "NORTH_WEST": return BlockFace.NORTH_WEST;
case "EAST_NORTH_EAST": return BlockFace.EAST_NORTH_EAST;
case "EAST_SOUTH_EAST": return BlockFace.EAST_SOUTH_EAST;
case "SOUTH_EAST": return BlockFace.SOUTH_EAST;
case "SOUTH_SOUTH_EAST": return BlockFace.SOUTH_SOUTH_EAST;
case "SOUTH_SOUTH_WEST": return BlockFace.SOUTH_SOUTH_WEST;
case "SOUTH_WEST": return BlockFace.SOUTH_WEST;
case "WEST_NORTH_WEST": return BlockFace.WEST_NORTH_WEST;
case "WEST_SOUTH_WEST": return BlockFace.WEST_SOUTH_WEST;
default: return BlockFace.NORTH;
}
}
@SuppressWarnings("deprecation")
public static void setBed(BlockFace face, Location l) {
if(face == BlockFace.NORTH){
l.getBlock().setType(Material.AIR);
l.getBlock().setType(Material.BED_BLOCK);
Block block = l.getBlock();
BlockState bedFoot = block.getState();
BlockState bedHead = bedFoot.getBlock().getRelative(BlockFace.SOUTH).getState();
bedFoot.setType(Material.BED_BLOCK);
bedHead.setType(Material.BED_BLOCK);
bedFoot.setRawData((byte) 0);
bedHead.setRawData((byte) 8);
bedFoot.update(true, false);
bedHead.update(true, true);
}else if(face == BlockFace.EAST){
l.getBlock().setType(Material.AIR);
l.getBlock().setType(Material.BED_BLOCK);
Block block = l.getBlock();
BlockState bedFoot = block.getState();
BlockState bedHead = bedFoot.getBlock().getRelative(BlockFace.WEST).getState();
bedFoot.setType(Material.BED_BLOCK);
bedHead.setType(Material.BED_BLOCK);
bedFoot.setRawData((byte) 1);
bedHead.setRawData((byte) 9);
bedFoot.update(true, false);
bedHead.update(true, true);
}else if(face == BlockFace.SOUTH){
l.getBlock().setType(Material.AIR);
l.getBlock().setType(Material.BED_BLOCK);
Block block = l.getBlock();
BlockState bedFoot = block.getState();
BlockState bedHead = bedFoot.getBlock().getRelative(BlockFace.NORTH).getState();
bedFoot.setType(Material.BED_BLOCK);
bedHead.setType(Material.BED_BLOCK);
bedFoot.setRawData((byte) 2);
bedHead.setRawData((byte) 10);
bedFoot.update(true, false);
bedHead.update(true, true);
}else if(face == BlockFace.WEST){
l.getBlock().setType(Material.AIR);
l.getBlock().setType(Material.BED_BLOCK);
Block block = l.getBlock();
BlockState bedFoot = block.getState();
BlockState bedHead = bedFoot.getBlock().getRelative(BlockFace.EAST).getState();
bedFoot.setType(Material.BED_BLOCK);
bedHead.setType(Material.BED_BLOCK);
bedFoot.setRawData((byte) 3);
bedHead.setRawData((byte) 11);
bedFoot.update(true, false);
bedHead.update(true, true);
}
}
@SuppressWarnings("deprecation")
public static Block setHalfBed(BlockFace face, Location l) {
if(face == BlockFace.NORTH){
Block block = l.getBlock();
BlockState bedHead = block.getState();
bedHead.setType(Material.BED_BLOCK);
bedHead.setRawData((byte) 9);
bedHead.update(true, false);
return block;
}else if(face == BlockFace.EAST){
Block block = l.getBlock();
BlockState bedHead = block.getState();
bedHead.setType(Material.BED_BLOCK);
bedHead.setRawData((byte) 10);
bedHead.update(true, false);
return block;
}else if(face == BlockFace.SOUTH){
Block block = l.getBlock();
BlockState bedHead = block.getState();
bedHead.setType(Material.BED_BLOCK);
bedHead.setRawData((byte) 11);
bedHead.update(true, false);
return block;
}else if(face == BlockFace.WEST){
Block block = l.getBlock();
BlockState bedHead = block.getState();
bedHead.setType(Material.BED_BLOCK);
bedHead.setRawData((byte) 8);
bedHead.update(true, false);
return block;
}
return null;
}
public static Location getRelativ(Location loc, BlockFace b, Double z, Double x){
Location l = new Location(loc.getWorld(), loc.getX(), loc.getY(), loc.getZ());
l.setYaw(Utils.FaceToYaw(b));
switch (b) {
case NORTH:
l.add(x,0,z);
break;
case SOUTH:
l.add(-x,0,-z);
break;
case WEST:
l.add(z,0,-x);
break;
case EAST:
l.add(-z,0,x);
break;
case NORTH_EAST:
l.add(x,0,z);
l.add(-z,0,x);
break;
case NORTH_NORTH_EAST:
l.add(x,0,z);
l.add(x,0,z);
l.add(-z,0,x);
break;
case NORTH_NORTH_WEST:
l.add(x,0,z);
l.add(x,0,z);
l.add(z,0,-x);
break;
case NORTH_WEST:
l.add(x,0,z);
l.add(z,0,-x);
break;
case EAST_NORTH_EAST:
l.add(-z,0,x);
l.add(x,0,z);
l.add(-z,0,x);
break;
case EAST_SOUTH_EAST:
l.add(-z,0,x);
l.add(-x,0,-z);
l.add(-z,0,x);
break;
case SOUTH_EAST:
l.add(-x,0,-z);
l.add(-z,0,x);
break;
case SOUTH_SOUTH_EAST:
l.add(-x,0,-z);
l.add(-x,0,-z);
l.add(-z,0,x);
break;
case SOUTH_SOUTH_WEST:
l.add(-x,0,-z);
l.add(-x,0,-z);
l.add(z,0,-x);
break;
case SOUTH_WEST:
l.add(-x,0,-z);
l.add(z,0,-x);
break;
case WEST_NORTH_WEST:
l.add(z,0,-x);
l.add(x,0,z);
l.add(z,0,-x);
break;
case WEST_SOUTH_WEST:
l.add(z,0,-x);
l.add(-x,0,-z);
l.add(z,0,-x);
break;
case DOWN:
l.add(0,-z,0);
break;
case UP:
l.add(0,z,0);
default:
l.add(x,0,z);
break;
}
return l;
}
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 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) {
return new EulerAngle(x,y,z);
}
public static Location getCenter(Location loc) {
return new Location(loc.getWorld(),
getRelativeCoord(loc.getBlockX()),
getRelativeCoord(loc.getBlockY()),
getRelativeCoord(loc.getBlockZ()));
}
public static Location getLocationCopy(Location l){
return new Location(l.getWorld(), l.getX(), l.getY(), l.getZ());
}
private static double getRelativeCoord(int i) {
double d = i;
if(d<0){d+=.5;}else{d+=.5;}
return d;
}
public static ArmorStand setArmorStand(Location location, EulerAngle angle, ItemStack is, Boolean Arm, Boolean mini, Boolean invisible, String ID, List<UUID> iDList){
ArmorStand as = (ArmorStand) location.getWorld().spawnEntity(location, EntityType.ARMOR_STAND);
if(Arm){
if(angle!=null){as.setRightArmPose(angle);}
if(is!=null){as.setItemInHand(is);}
}else{
if(angle!=null){as.setHeadPose(angle);}
if(is!=null){as.setHelmet(is);}
}
as.setSmall(mini);
as.setVisible(invisible);
as.setGravity(false);
as.setBasePlate(false);
iDList.add(as.getUniqueId());
return as;
}
public static ArmorStand check(Location location, EulerAngle angle, ItemStack is, Boolean arm, Boolean mini, Boolean invisible, List<UUID> iDList){
Boolean hand = true;
Boolean item = true;
Boolean min = true;
Boolean visible = true;
for(Entity e : location.getWorld().getEntities()){
if(e instanceof ArmorStand){
if(e!=null){
ArmorStand as = (ArmorStand) e;
if(arm){
if(angle != null && as.getRightArmPose()!=null && angle.equals(as.getRightArmPose())){hand = true;}else{hand=false;}
if(is != null && as.getItemInHand() != null && as.getItemInHand().equals(is)){item = true;}else{item = false;}
}else{
if(angle != null && as.getHeadPose()!=null && angle.equals(as.getHeadPose())){hand = true;}else{hand=false;}
if(is != null && as.getHelmet() != null && as.getHelmet().equals(is)){item = true;}else{item = false;}
}
if(as.isSmall() != mini){min = false;}
if(as.isVisible() != invisible){visible = false;}
if(hand&&item&&min&&visible){
if(!iDList.contains(e.getUniqueId())){iDList.add(e.getUniqueId());}
return as;
}else if(location.equals(as.getLocation())){as.remove();return null;}
}
}
}
return null;
}
public static Integer getRound(float f){
float circle = 360;
return (int) (circle/f);
}
public static ArmorStand getArmorStandAtID(World w, UUID ids){
for(Entity e : w.getEntities()){
if(e instanceof ArmorStand){
if(e!= null && e.getUniqueId().equals(ids)){
return (ArmorStand) e;
}
}
}
return null;
}
public static Boolean isDouble(String s){
try{
Double.parseDouble(s);
return true;
}catch(NumberFormatException e){
return false;
}
}
public static Boolean isBoolean(String s){
try {
s = s.toLowerCase();
Boolean.parseBoolean(s);
return true;
} catch (Exception e) {
return false;
}
}
public static Boolean isInt(String s){
try{
Integer.parseInt(s);
return true;
}catch(NumberFormatException e){
return false;
}
}
}

View File

@ -1,318 +0,0 @@
package de.Ste3et_C0st.Furniture.Main;
import java.io.File;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import de.Ste3et_C0st.Furniture.Main.Type.FurnitureType;
public class command implements CommandExecutor {
private static config cc;
@Override
public boolean onCommand(CommandSender sender, Command cmd, String arg2, String[] args) {
if(cmd.getName().equalsIgnoreCase("furniture")){
String noPermissions = ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.NoPermissions"));
String notFound = ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.notFound"));
String PlayerNotFound = ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.PlayerNotFound"));
String help = "§7================[§2Furniture§7]================\n";
help += "§2/furniture list | §8list all available furniture\n";
help += "§2/furniture give <PLAYER> <FURNITURE> | §8give one player one furniture\n";
help += "§2/furniture give <FURNITURE> | §8give you an furniture\n";
help += "§2/furniture killall | §8Killall Furnitures\n";
help += "§2/furniture remove radius <DISTANCE> | §8Remove furniture in radius\n";
help += "§2/furniture remove <type> | §8Remove all furnitures by type";
help += "§2/furniture remove <ID> | §8Remove a furniture by id";
help += "§2/furniture reload | §8Reload the plugin\n";
help += "§7=========================================";
if(sender instanceof Player){
if(args.length == 1){
if(args[0].equalsIgnoreCase("killall")){
if(sender.hasPermission("furniture.admin")){
main.getInstance().removeAll();
Integer i = 0;
for(World w : main.getInstance().getServer().getWorlds()){
for(Entity e : w.getEntities()){
if(e!=null && e instanceof ArmorStand){
String name = e.getName();
if(name != null && name.length()>=13){
String[] split = name.split("-");
if(split != null && split.length>=1){
i++;
e.remove();
}
}
}
}
}
cc = new config();
main.getInstance().removeAll();
String s = main.getInstance().getConfig().getString("config.Messages.ArmorStandsKills");
s = s.replace("@ARMORSTANDS", i.toString()).replace("@WOLRDS", main.getInstance().getServer().getWorlds().size() + "");
((Player) sender).sendMessage(ChatColor.translateAlternateColorCodes('&', s));
cc.deleteFolder(new File("plugins/Furniture/objects"));
return true;
}else{
((Player) sender).sendMessage(noPermissions);
return true;
}
}
}else if(args.length == 2){
if(args[0].equalsIgnoreCase("remove")){
if(!sender.hasPermission("furniture.admin")){sender.sendMessage(noPermissions);return true;}
if(getType(args[1])!=null){
Boolean b = main.getInstance().getManager().RemoveType(getType(args[1]), true);
String s = ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.ArmorStandsRemoveFromType"));
String[] split = s.split(" ");
Integer i = 0;
String string = "";
String stings = "";
for(String str : split){
if(str.startsWith("[") && str.endsWith("]")){
str = str.replace("[", "");
str = str.replace("]", "");
stings = str;
if(b){
String[] l = stings.split("#");
string = l[1];
}else{
String[] l = stings.split("#");
string = l[0];
}
}
i++;
}
sender.sendMessage(s.replace(stings, string).replace("[", "").replace("]", ""));
return true;
}else if(args[1] != null && args[1].length()>=13){
String[] split = args[1].split("-");
if(split != null && split.length>=1){
Boolean b = main.getInstance().getManager().RemoveFromID(args[1]);
String s = ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.ArmorStandsRemoveFromID"));
String[] splits = s.split(" ");
Integer i = 0;
String string = "";
String stings = "";
for(String str : splits){
if(str.startsWith("[") && str.endsWith("]")){
str = str.replace("[", "");
str = str.replace("]", "");
stings = str;
if(b){
String[] l = stings.split("#");
string = l[1];
}else{
String[] l = stings.split("#");
string = l[0];
}
}
i++;
}
sender.sendMessage(s.replace(stings, string).replace("[", "").replace("]", ""));
return true;
}
}else{
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.CommandBadArguments")));
return true;
}
}else 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 if(args.length == 3){
if(args[0].equalsIgnoreCase("remove")){
if(!sender.hasPermission("furniture.admin")){sender.sendMessage(noPermissions);return true;}
if(args[1].equalsIgnoreCase("radius")){
Double d = 0.0;
if(Utils.isInt(args[2])){
d = (double) Integer.parseInt(args[2]);
}
if(Utils.isDouble(args[2])){
d = Double.parseDouble(args[2]);
}
if(d!=0.0){
Integer i = main.getInstance().getManager().RemoveFromDistance(((Player) sender).getLocation().toVector(), d);
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.ArmorStandsRemoveFromDistance")).replace("@ARMORSTANDS", i.toString()));
return true;
}
}else{
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.CommandBadArguments")));
return true;
}
}
}
}
if(args.length == 1){
if(args[0].equalsIgnoreCase("list")){
if(sender.hasPermission("furniture.list")){
sender.sendMessage("§6=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
main.getInstance().getStringPage().returnStringPage(sender, main.getInstance().crafting, 0, 10);
sender.sendMessage("§6=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
sender.sendMessage("§2Type /furniture list <page>");
return true;
}else{
sender.sendMessage(noPermissions);
return true;
}
}else if(args[0].equalsIgnoreCase("reload")){
if(sender.hasPermission("furniture.admin")){
main.getInstance().reload();
sender.sendMessage("§bPlugin reloaded");
return true;
}else{
sender.sendMessage(noPermissions);
return true;
}
}else if(args[0].equalsIgnoreCase("fixall")){
}else{
sender.sendMessage(help);
return true;
}
}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 if(args.length == 2){
if(args[0].equalsIgnoreCase("remove")){
if(!sender.hasPermission("furniture.admin")){sender.sendMessage(noPermissions);return true;}
if(getType(args[1])!=null){
Boolean b = main.getInstance().getManager().RemoveType(getType(args[1]), true);
String s = ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.ArmorStandsRemoveFromType"));
String[] split = s.split(" ");
Integer i = 0;
String string = "";
String stings = "";
for(String str : split){
if(str.startsWith("[") && str.endsWith("]")){
stings = str;
if(b){
string = str.split("|")[1];
}
if(!b){
string = str.split("|")[0];
}
}
i++;
}
sender.sendMessage(s.replace(stings, string));
return true;
}else if(args[1] != null && args[1].length()>=13){
String[] split = args[1].split("-");
if(split != null && split.length>=1){
Boolean b = main.getInstance().getManager().RemoveFromID(args[1]);
String s = ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.ArmorStandsRemoveFromID"));
String[] splits = s.split(" ");
Integer i = 0;
String string = "";
String stings = "";
for(String str : splits){
if(str.startsWith("[") && str.endsWith("]")){
stings = str;
if(b){
string = str.split("|")[1];
}
if(!b){
string = str.split("|")[0];
}
}
i++;
}
sender.sendMessage(s.replace(stings, string));
return true;
}
}else{
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.CommandBadArguments")));
return true;
}
}else if(args[0].equalsIgnoreCase("list")){
if(sender.hasPermission("furniture.list")){
if(Utils.isInt(args[1])){
if(main.getInstance().getStringPage().check(sender, main.getInstance().crafting, Integer.parseInt(args[1]), 10)){
sender.sendMessage("§6=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
main.getInstance().getStringPage().returnStringPage(sender, main.getInstance().crafting, Integer.parseInt(args[1]), 10);
sender.sendMessage("§6=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
sender.sendMessage("§2Type /furniture list <page>");
return true;
}else{
sender.sendMessage("§cSide not found");
return true;
}
}else{
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.CommandBadArguments")));
}
return true;
}else{
sender.sendMessage(noPermissions);
return true;
}
}else{
sender.sendMessage(help);
return true;
}
}else{
sender.sendMessage(help);
return true;
}
}
return false;
}
public FurnitureType getType(String s){
if(s.equalsIgnoreCase("chair")){return FurnitureType.CHAIR;}
if(s.equalsIgnoreCase("largetable")){return FurnitureType.LARGE_TABLE;}
if(s.equalsIgnoreCase("lantern")){return FurnitureType.LANTERN;}
if(s.equalsIgnoreCase("sofa")){return FurnitureType.SOFA;}
if(s.equalsIgnoreCase("table")){return FurnitureType.TABLE;}
if(s.equalsIgnoreCase("barrels")){return FurnitureType.BARRELS;}
if(s.equalsIgnoreCase("campfire1")){return FurnitureType.CAMPFIRE_1;}
if(s.equalsIgnoreCase("campfire2")){return FurnitureType.CAMPFIRE_2;}
if(s.equalsIgnoreCase("tent1")){return FurnitureType.TENT_1;}
if(s.equalsIgnoreCase("tent2")){return FurnitureType.TENT_2;}
if(s.equalsIgnoreCase("tent3")){return FurnitureType.TENT_3;}
return null;
}
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

@ -1,415 +1,150 @@
package de.Ste3et_C0st.Furniture.Main;
import java.io.IOException;
import java.util.HashMap;
import java.util.Random;
import java.util.logging.Logger;
import net.milkbowl.vault.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
import de.Ste3et_C0st.Furniture.Main.Manager.CheckManager;
import de.Ste3et_C0st.Furniture.Main.Manager.FurnitureManager;
import de.Ste3et_C0st.Furniture.Main.Manager.Manager;
import de.Ste3et_C0st.Furniture.Main.Type.FurnitureType;
import de.Ste3et_C0st.Furniture.Model.ModelCommand;
import de.Ste3et_C0st.Furniture.Model.ModelListener;
import de.Ste3et_C0st.Furniture.Model.ModelManager;
import de.Ste3et_C0st.Furniture.Listener.IPistonExtendEvent;
import de.Ste3et_C0st.Furniture.Listener.OnInteract;
import de.Ste3et_C0st.Furniture.Objects.electric.camera;
import de.Ste3et_C0st.Furniture.Objects.electric.tv;
import de.Ste3et_C0st.Furniture.Objects.garden.graveStone;
import de.Ste3et_C0st.Furniture.Objects.indoor.chair;
import de.Ste3et_C0st.Furniture.Objects.indoor.largeTable;
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.barrels;
import de.Ste3et_C0st.Furniture.Objects.outdoor.campfire_1;
import de.Ste3et_C0st.Furniture.Objects.outdoor.campfire_2;
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_1;
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_2;
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_3;
import de.Ste3et_C0st.FurnitureLib.Crafting.CraftingFile;
import de.Ste3et_C0st.FurnitureLib.Crafting.Project;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureItemEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.LocationUtil;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureManager;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
public class main extends JavaPlugin {
private static main Main;
private Logger log = Logger.getLogger("Minecraft");
public HashMap<String, ItemStack> crafting = new HashMap<String, ItemStack>();
public Manager mgr;
public FurnitureManager Fmgr;
public Boolean isCrafting = true;
public Boolean isDestroyable = true;
public CheckManager check;
public StringPage sp;
//public Factions factionsAPI = null;
@SuppressWarnings({ "deprecation" })
@Override
public class main extends JavaPlugin implements Listener{
FurnitureLib lib;
FurnitureManager manager;
static main instance;
static LocationUtil util;
public void onEnable(){
Main = this;
new ModelManager();
getServer().getPluginManager().registerEvents(new OnInteract(), this);
getServer().getPluginManager().registerEvents(new IPistonExtendEvent(), this);
getServer().getPluginManager().registerEvents(new ModelListener(), this);
getCommand("furniture").setExecutor(new command());
getCommand("model").setExecutor(new ModelCommand());
try{
getConfig().addDefaults(YamlConfiguration.loadConfiguration(getResource("config.yml")));
getConfig().options().copyDefaults(true);
saveConfig();
}catch(Exception e){
shutdown("Config");
if(!Bukkit.getPluginManager().isPluginEnabled("FurnitureLib")){Bukkit.getPluginManager().disablePlugin(this);}
instance = this;
lib = (FurnitureLib) Bukkit.getPluginManager().getPlugin("FurnitureLib");
manager = lib.getFurnitureManager();
util = lib.getLocationUtil();
Bukkit.getPluginManager().registerEvents(this, this);
manager.addProject(new Project("Camera", new CraftingFile("Camera", getResource("Crafting/Camera.yml")),this));
manager.addProject(new Project("TV", new CraftingFile("TV", getResource("Crafting/Camera.yml")),this));
manager.addProject(new Project("GraveStone", new CraftingFile("GraveStone", getResource("Crafting/Camera.yml")),this));
manager.addProject(new Project("Chair", new CraftingFile("Chair", getResource("Crafting/Camera.yml")),this));
manager.addProject(new Project("LargeTable", new CraftingFile("LargeTable", getResource("Crafting/Camera.yml")),this));
manager.addProject(new Project("Lantern", new CraftingFile("Lantern", getResource("Crafting/Camera.yml")),this));
manager.addProject(new Project("Sofa", new CraftingFile("Sofa", getResource("Crafting/Camera.yml")),this));
manager.addProject(new Project("Table", new CraftingFile("Table", getResource("Crafting/Camera.yml")),this));
manager.addProject(new Project("Barrels", new CraftingFile("Barrels", getResource("Crafting/Camera.yml")),this));
manager.addProject(new Project("Campfire1", new CraftingFile("Campfire1", getResource("Crafting/Camera.yml")),this));
manager.addProject(new Project("Campfire2", new CraftingFile("Campfire2", getResource("Crafting/Camera.yml")),this));
manager.addProject(new Project("Tent1", new CraftingFile("Tent1", getResource("Crafting/Camera.yml")),this));
manager.addProject(new Project("Tent2", new CraftingFile("Tent2", getResource("Crafting/Camera.yml")),this));
manager.addProject(new Project("Tent3", new CraftingFile("Tent3", getResource("Crafting/Camera.yml")),this));
for(ObjectID obj : manager.getObjectList()){
if(obj.getPlugin().equalsIgnoreCase(this.getName())){
switch (obj.getProject()) {
case "Camera":
new camera(obj.getStartLocation(), lib, "Camera", this, obj);
break;
case "TV":
new tv(obj.getStartLocation(), lib, "TV", this, obj);
break;
case "GraveStone":
new graveStone(obj.getStartLocation(), lib, "GraveStone", this, obj);
break;
case "Chair":
new chair(obj.getStartLocation(), lib, "Chair", this, obj);
break;
case "LargeTable":
new largeTable(obj.getStartLocation(), lib, "LargeTable", this, obj);
break;
case "Lantern":
new latern(obj.getStartLocation(), lib, "Lantern", this, obj);
break;
case "Sofa":
new sofa(obj.getStartLocation(), lib, "Sofa", this, obj);
break;
case "Table":
new table(obj.getStartLocation(), lib, "Table", this, obj);
break;
case "Barrels":
new barrels(obj.getStartLocation(), lib, "Barrels", this, obj);
break;
case "Campfire1":
new campfire_1(obj.getStartLocation(), lib, "Campfire1", this, obj);
break;
case "Campfire2":
new campfire_2(obj.getStartLocation(), lib, "Campfire2", this, obj);
break;
case "Tent1":
new tent_1(obj.getStartLocation(), lib, "Tent1", this, obj);
break;
case "Tent2":
new tent_2(obj.getStartLocation(), lib, "Tent2", this, obj);
break;
case "Tent3":
new tent_3(obj.getStartLocation(), lib, "Tent3", this, obj);
break;
default:
break;
}
}
if(getServer().getPluginManager().isPluginEnabled("Vault") && getConfig().getBoolean("config.UseMetrics")){
try
{
Metrics metrics = new Metrics(this);
metrics.start();
}
catch (IOException localIOException) {}
}
this.check = new CheckManager(this.getServer().getPluginManager());
this.sp = new StringPage();
this.mgr = new Manager();
this.Fmgr = new FurnitureManager();
mgr.load("chair");
mgr.load("lantern");
mgr.load("table");
mgr.load("largeTable");
mgr.load("sofa");
mgr.load("tent1");
mgr.load("tent2");
mgr.load("tent3");
mgr.load("campfire1");
mgr.load("barrels");
mgr.load("campfire2");
mgr.load("camera");
mgr.defaultCrafting();
addCrafting();
isCrafting = getConfig().getBoolean("config.CraftingPermissions");
isDestroyable = getConfig().getBoolean("config.BreakPermissions");
check(Bukkit.getPluginManager());
}
public void check(PluginManager pm){
String plugins = "";
if(pm.isPluginEnabled("WorldGuard")){plugins +="Worldguard;";}
if(pm.isPluginEnabled("ClearLagg")){plugins +="ClearLagg;";}
if(pm.isPluginEnabled("NoLagg")){plugins +="NoLagg;";}
if(pm.isPluginEnabled("pTweaks")){plugins +="pTweaks;";}
if(plugins!=""){
getLogger().warning("[Furniture] your Plugins " + plugins);
getLogger().warning("[Furniture] have a stoplag features this can remove the Armor Stands");
}
}
public Double distance(Location loc1, Location loc2){
Vector v1 = loc1.toVector();
Vector v2 = loc1.toVector();
return v1.distance(v2);
}
public void removeAll(){
Fmgr.RemoveType(FurnitureType.CHAIR, false);
Fmgr.RemoveType(FurnitureType.LARGE_TABLE, false);
Fmgr.RemoveType(FurnitureType.LANTERN, false);
Fmgr.RemoveType(FurnitureType.SOFA, false);
Fmgr.RemoveType(FurnitureType.TABLE, false);
Fmgr.RemoveType(FurnitureType.BARRELS, false);
Fmgr.RemoveType(FurnitureType.CAMPFIRE_1, false);
Fmgr.RemoveType(FurnitureType.CAMPFIRE_2, false);
Fmgr.RemoveType(FurnitureType.TENT_1, false);
Fmgr.RemoveType(FurnitureType.TENT_2, false);
Fmgr.RemoveType(FurnitureType.TENT_3, false);
Fmgr.RemoveType(FurnitureType.CAMERA, false);
}
public void reload(){
//try{
mgr.saveLargeTable(null);
mgr.saveLatern(null);
mgr.saveSofa(null);
mgr.saveStuhl(null);
mgr.saveTable(null);
mgr.saveTent1(null);
mgr.saveTent2(null);
getServer().resetRecipes();
removeAll();
crafting.clear();
isCrafting=false;
mgr.load("chair");
mgr.load("lantern");
mgr.load("table");
mgr.load("largeTable");
mgr.load("sofa");
mgr.load("tent1");
mgr.load("tent2");
mgr.load("tent3");
mgr.load("campfire1");
mgr.load("barrels");
mgr.load("campfire2");
mgr.load("camera");
mgr.defaultCrafting();
addCrafting();
isCrafting = getConfig().getBoolean("config.CraftingPermissions");
//}catch (Exception e) {
// shutdown("Reload");
//}
}
public void shutdown(String s){
PluginDescriptionFile pdfFile = this.getDescription();
log.warning(pdfFile.getName() + s + " Exception");
}
@Override
public void onDisable(){
mgr.saveLargeTable(null);
mgr.saveLatern(null);
mgr.saveSofa(null);
mgr.saveStuhl(null);
mgr.saveTable(null);
mgr.saveTent1(null);
mgr.saveTent2(null);
mgr.saveCamera(null);
getServer().resetRecipes();
}
public void addCrafting(){
mgr.loadCrafting("largeTable");
mgr.loadCrafting("table");
mgr.loadCrafting("lantern");
mgr.loadCrafting("sofa");
mgr.loadCrafting("chair");
mgr.loadCrafting("tent1");
mgr.loadCrafting("tent2");
mgr.loadCrafting("tent3");
mgr.loadCrafting("barrels");
mgr.loadCrafting("campfire1");
mgr.loadCrafting("campfire2");
mgr.loadCrafting("camera");
}
public static String getCardinalDirection(Player player) {
double rotation = (player.getLocation().getYaw() - 90) % 360;
if (rotation < 0) {
rotation += 360.0;
}
if (0 <= rotation && rotation < 22.5) {
return "N";
} else if (67.5 <= rotation && rotation < 112.5) {
return "E";
} else if (157.5 <= rotation && rotation < 202.5) {
return "S";
} else if (247.5 <= rotation && rotation < 292.5) {
return "W";
} else if (337.5 <= rotation && rotation < 360.0) {
return "N";
} else {
return null;
}
}
public static Location getNew(Location loc, BlockFace b, Double z, Double x){
Location l = new Location(loc.getWorld(), loc.getX(), loc.getY(), loc.getZ());
if(b.equals(BlockFace.NORTH)){
l.add(x,0,z);
}
if(b.equals(BlockFace.SOUTH)){
l.add(-x,0,-z);
}
if(b.equals(BlockFace.EAST)){
l.add(-z,0,x);
}
if(b.equals(BlockFace.WEST)){
l.add(z,0,-x);
}
if(b.equals(BlockFace.NORTH_EAST)){
l.add(x,0,z);
l.add(-z,0,x);
}
if(b.equals(BlockFace.NORTH_WEST)){
l.add(x,0,z);
l.add(z,0,-x);
}
if(b.equals(BlockFace.SOUTH_EAST)){
l.add(-x,0,-z);
l.add(-z,0,x);
}
if(b.equals(BlockFace.SOUTH_WEST)){
l.add(-x,0,-z);
l.add(z,0,-x);
}
if(b.equals(BlockFace.UP)){
l.add(0,z+x,0);
}
if(b.equals(BlockFace.DOWN)){
l.add(0,-z-x,0);
}
return l;
}
public static EulerAngle getNewEuler(BlockFace b, Double z, Double x,Double y){
EulerAngle l = new EulerAngle(0, 0, 0);
if(b.equals(BlockFace.NORTH)){l = new EulerAngle(x,y,-z);
}else if(b.equals(BlockFace.SOUTH)){l = new EulerAngle(-x,y,z);
}else if(b.equals(BlockFace.EAST)){l = new EulerAngle(-z,y,x);
}else if(b.equals(BlockFace.WEST)){l = new EulerAngle(z,y,x);}
return l;
}
public static short getFromDey(short s){
if(s==15){return 0;}
if(s==14){return 1;}
if(s==13){return 2;}
if(s==12){return 3;}
if(s==11){return 4;}
if(s==10){return 5;}
if(s==9){return 6;}
if(s==8){return 7;}
if(s==7){return 8;}
if(s==6){return 9;}
if(s==5){return 10;}
if(s==4){return 11;}
if(s==3){return 12;}
if(s==2){return 13;}
if(s==1){return 14;}
if(s==0){return 15;}
return 0;
}
public static Color getDyeFromDurability(short s){
if(s==0){return Color.fromRGB(25, 25, 25);}
if(s==1){return Color.fromRGB(153, 51, 51);}
if(s==2){return Color.fromRGB(102, 127, 51);}
if(s==3){return Color.fromRGB(102, 76, 51);}
if(s==4){return Color.fromRGB(51, 76, 178);}
if(s==5){return Color.fromRGB(127, 63, 178);}
if(s==6){return Color.fromRGB(76, 127, 153);}
if(s==7){return Color.fromRGB(153, 153, 153);}
if(s==8){return Color.fromRGB(76, 76, 76);}
if(s==9){return Color.fromRGB(242, 127, 165);}
if(s==10){return Color.fromRGB(127, 204, 25);}
if(s==11){return Color.fromRGB(229, 229, 51);}
if(s==12){return Color.fromRGB(102, 153, 216);}
if(s==13){return Color.fromRGB(178, 76, 216);}
if(s==14){return Color.fromRGB(216, 127, 51);}
if(s==15){return Color.fromRGB(255, 255, 255);}
return Color.fromRGB(255, 255, 255);
}
public boolean canPlace(Player p, Location location, BlockFace b, Integer length){
try{
if(b==null&&length==null){
if(!location.getBlock().getType().equals(Material.AIR)){
return false;
}
}
if(b!=null&&length!=null){
for(int i = 0; i<= length-1; i++){
Block bl = getNew(location, b, 0D,(double) i).getBlock();
if(!(bl==null || bl.getType().equals(Material.AIR))){
return false;
}
}
}
return true;
}catch(Exception e){
return false;
@EventHandler
private void onClick(FurnitureItemEvent e){
if(e.isCancelled()){return;}
if(!e.canBuild(null)){return;}
if(!e.getProject().hasPermissions(e.getPlayer())){return;}
if(!e.getProject().getPlugin().getName().equalsIgnoreCase(this.getName())){return;}
Location loc = e.getLocation().getBlock().getLocation();
loc.setYaw(e.getPlayer().getLocation().getYaw());
loc.add(0, 1, 0);
switch(e.getProject().getName()){
case "Camera" : new camera(loc, lib, "Camera", instance, null); return;
case "TV" : new tv(loc, lib, "TV", instance, null); return;
case "GraveStone" : new graveStone(loc, lib, "GraveStone", instance, null); return;
case "Chair" : new chair(loc, lib, "Chair", instance, null); return;
case "LargeTable" : new largeTable(loc, lib, "LargeTable", instance, null); return;
case "Lantern" : new latern(loc, lib, "Lantern", instance, null); return;
case "Sofa" : new sofa(loc, lib, "Sofa", instance, null); return;
case "Table" : new table(loc, lib, "Table", instance, null); return;
case "Barrels" : new barrels(loc, lib, "Barrels", instance, null); return;
case "Campfire1" : new campfire_1(loc, lib, "Campfire1", instance, null); return;
case "Campfire2" : new campfire_2(loc, lib, "Campfire2", instance, null); return;
case "Tent1" : new tent_1(loc, lib, "Tent1", instance, null); return;
case "Tent2" : new tent_2(loc, lib, "Tent2", instance, null); return;
case "Tent3" : new tent_3(loc, lib, "Tent3", instance, null); return;
default: e.getPlayer().sendMessage("A error occorupted"); return;
}
}
public boolean canPlaceLarge(Player p, Location location, BlockFace b, Integer length, Integer width){
try{
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++){
Block bl = getNew(location, b,(double) l,(double) i).getBlock();
if(!(bl==null || bl.getType().equals(Material.AIR))){
return false;
}
}
}
}
return true;
}catch(Exception e){
return false;
}
}
public static LocationUtil getLocationUtil(){return util;}
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 Plugin getInstance() {
return instance;
}
public static main getInstance() {return Main;}
public boolean canPlaceTent(Player p, Location location, BlockFace b, Integer length, Integer width, Integer height){
try{
if(b==null&&length==null&&width==null){
if(!location.getBlock().getType().equals(Material.AIR)){
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("Config.Messages.Space")));
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)){
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("Config.Messages.Space")));
return false;
}
}
}
}
}
return true;
}catch(Exception e){
return false;
}
}
public FurnitureManager getManager() {return this.Fmgr;}
public CheckManager getCheckManager(){return this.check;}
public StringPage getStringPage(){return this.sp;}
}
}

View File

@ -1,220 +0,0 @@
package de.Ste3et_C0st.Furniture.Main;
import java.util.HashMap;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.inventory.ItemStack;
import de.Ste3et_C0st.Furniture.Objects.indoor.largeTable;
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.barrels;
import de.Ste3et_C0st.Furniture.Objects.outdoor.campfire_1;
import de.Ste3et_C0st.Furniture.Objects.outdoor.campfire_2;
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_1;
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_2;
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_3;
public class option {
public void saveOption(FileConfiguration fc, campfire_1 l) {
fc.set("Furniture.campfire1."+l.getID()+".settings", l.getFire());
}
public void saveOption(FileConfiguration fc, campfire_2 l) {
fc.set("Furniture.campfire2."+l.getID()+".settings", l.isFire());
}
public void saveOption(FileConfiguration fc, latern l)
{
fc.set("Furniture.lantern." + l.getID() + ".settings", Boolean.valueOf(l.getLight()));
}
public void saveOption(FileConfiguration fc, largeTable l){
for(Integer is : l.getTeller().keySet()){
saveItem(fc, "Furniture.largeTable."+l.getID()+".settings.items." + is, l.getTeller().get(is));
}
for(Integer is : l.getColor().keySet()){
saveColor(fc, "Furniture.largeTable."+l.getID()+".settings.colors."+is, l.getColor().get(is));
}
}
public void saveOption(FileConfiguration fc, tent_1 l){
for(Integer is : l.getColor().keySet()){
saveColor(fc, "Furniture.tent1."+l.getID()+".settings.colors."+is, l.getColor().get(is));
}
}
public void saveOption(FileConfiguration fc, tent_2 l){
for(Integer is : l.getColor().keySet()){
saveColor(fc, "Furniture.tent2."+l.getID()+".settings.colors."+is, l.getColor().get(is));
}
}
public void saveOption(FileConfiguration fc, tent_3 l) {
for(Integer is : l.getColor().keySet()){
saveColor(fc, "Furniture.tent3."+l.getID()+".settings.colors."+is, l.getColor().get(is));
}
}
public void saveOption(FileConfiguration fc, sofa l){
for(Integer is : l.getColor().keySet()){
saveColor(fc, "Furniture.sofa."+l.getID()+".settings.colors."+is, l.getColor().get(is));
}
}
public void saveOption(FileConfiguration fc, table l){
saveItem(fc, "Furniture.table."+l.getID()+".settings.item", l.getItemStack());
}
public void saveOption(FileConfiguration fc, barrels l){
saveItem(fc, "Furniture.barrels."+l.getID()+".settings.item", l.getItemStack());
}
public void loadOptions(FileConfiguration fc, tent_1 l){
if(fc.isSet("Furniture.tent1."+l.getID()+".settings")){
if(fc.isConfigurationSection("Furniture.tent1."+l.getID()+".settings.colors")){
Integer current = 0;
HashMap<Integer, Short> colors = new HashMap<Integer, Short>();
for(String str : fc.getConfigurationSection("Furniture.tent1."+l.getID()+".settings.colors").getKeys(false)){
Integer i = fc.getInt("Furniture.tent1."+l.getID()+".settings.colors."+str);
colors.put(current, i.shortValue());
current++;
}
l.setColor(colors);
}
}
}
public void loadOptions(FileConfiguration fc, tent_2 l){
if(fc.isSet("Furniture.tent2."+l.getID()+".settings")){
if(fc.isConfigurationSection("Furniture.tent2."+l.getID()+".settings.colors")){
Integer current = 0;
HashMap<Integer, Short> colors = new HashMap<Integer, Short>();
for(String str : fc.getConfigurationSection("Furniture.tent2."+l.getID()+".settings.colors").getKeys(false)){
Integer i = fc.getInt("Furniture.tent2."+l.getID()+".settings.colors."+str);
colors.put(current, i.shortValue());
current++;
}
l.setColor(colors);
}
}
}
public void loadOptions(FileConfiguration fc, tent_3 l){
if(fc.isSet("Furniture.tent3."+l.getID()+".settings")){
if(fc.isConfigurationSection("Furniture.tent3."+l.getID()+".settings.colors")){
Integer current = 0;
HashMap<Integer, Integer> colors = new HashMap<Integer, Integer>();
for(String str : fc.getConfigurationSection("Furniture.tent3."+l.getID()+".settings.colors").getKeys(false)){
Integer i = fc.getInt("Furniture.tent3."+l.getID()+".settings.colors."+str);
colors.put(current, i);
current++;
}
l.setColor(colors);
}
}
}
public void loadOptions(FileConfiguration fc, table l){
if(fc.isSet("Furniture.table."+l.getID()+".settings")){
if(fc.isConfigurationSection("Furniture.table."+l.getID()+".settings.item")){
ItemStack is = getItemStack(fc, "Furniture.table."+l.getID()+".settings.item");
l.setItem(is);
}
}
}
public void loadOptions(FileConfiguration fc, barrels l){
if(fc.isSet("Furniture.barrels."+l.getID()+".settings")){
if(fc.isConfigurationSection("Furniture.barrels."+l.getID()+".settings.item")){
ItemStack is = getItemStack(fc, "Furniture.barrels."+l.getID()+".settings.item");
l.setItemstack(is);
}
}
}
public void loadOptions(FileConfiguration fc, latern l){
if(fc.isSet("Furniture.lantern."+l.getID()+".settings")){
if(fc.isBoolean("Furniture.lantern."+l.getID()+".settings.state")){
l.setLight(fc.getBoolean("Furniture.lantern."+l.getID()+".settings.state"));
}
}
}
public void loadOptions(FileConfiguration fc, campfire_1 l) {
if(fc.isSet("Furniture.campfire1."+l.getID()+".settings")){
if(fc.isBoolean("Furniture.campfire1."+l.getID()+".settings.state")){
l.setLight(fc.getBoolean("Furniture.campfire1."+l.getID()+".settings.state"), false);
}
}
}
public void loadOptions(FileConfiguration fc, campfire_2 l) {
if(fc.isSet("Furniture.campfire2."+l.getID()+".settings")){
if(fc.isBoolean("Furniture.campfire2."+l.getID()+".settings.state")){
l.setLight(fc.getBoolean("Furniture.campfire2."+l.getID()+".settings.state"), false);
}
}
}
public void loadOptions(FileConfiguration fc, sofa l){
if(fc.isSet("Furniture.sofa."+l.getID()+".settings")){
if(fc.isConfigurationSection("Furniture.sofa."+l.getID()+".settings.colors")){
Integer current = 0;
HashMap<Integer, Short> colors = new HashMap<Integer, Short>();
for(String str : fc.getConfigurationSection("Furniture.sofa."+l.getID()+".settings.colors").getKeys(false)){
Integer i = fc.getInt("Furniture.sofa."+l.getID()+".settings.colors."+str);
colors.put(current, i.shortValue());
current++;
}
l.setColor(colors);
}
}
}
public void loadOptions(FileConfiguration fc, largeTable l){
if(fc.isSet("Furniture.largeTable."+l.getID()+".settings")){
HashMap<Integer, Short> colors = new HashMap<Integer, Short>();
HashMap<Integer, ItemStack> items = new HashMap<Integer, ItemStack>();
if(fc.isConfigurationSection("Furniture.largeTable."+l.getID()+".settings.colors")){
Integer current = 0;
for(String str : fc.getConfigurationSection("Furniture.largeTable."+l.getID()+".settings.colors").getKeys(false)){
Integer i = fc.getInt("Furniture.largeTable."+l.getID()+".settings.colors."+str);
colors.put(current, i.shortValue());
current++;
}
}
if(fc.isConfigurationSection("Furniture.largeTable."+l.getID()+".settings.items")){
for(String str : fc.getConfigurationSection("Furniture.largeTable."+l.getID()+".settings.items").getKeys(false)){
items.put(Integer.parseInt(str), getItemStack(fc, "Furniture.largeTable."+l.getID()+".settings.items."+str));
}
}
l.setColor(colors);
l.setTeller(items);
}
}
public void saveColor(FileConfiguration fc, String s, Short sh){
fc.set(s, sh);
}
public void saveColor(FileConfiguration fc, String s, Integer sh){
fc.set(s, sh);
}
public void saveItem(FileConfiguration fc, String s, ItemStack is){
fc.set(s, is);
}
public ItemStack getItemStack(FileConfiguration fc, String s){
return fc.getItemStack(s);
}
}

View File

@ -1,183 +0,0 @@
package de.Ste3et_C0st.Furniture.Model;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
import de.Ste3et_C0st.Furniture.Main.Type.HeadArmType;
import de.Ste3et_C0st.Furniture.Main.Utils;
public class ModelCommand implements CommandExecutor{
@Override
public boolean onCommand(CommandSender sender, Command cmd, String str1,String[] args) {
if(sender instanceof Player == false)return true;
if(!cmd.getName().equalsIgnoreCase("Model")) return false;
Player p = (Player) sender;
String help = "§3/model create <§6ID§3> §7| §9Create a new Model Object\n";
help+="§3/model add <§6ARM/HEAD§3> <§6MaterialID:subID/hand§3> <§6visible§3> <§6mini§3>\n";
help+="§3/model edit <§6INDEX§3> §7| §9go back to this ArmorStand edit mode\n";
help+="§3/model remove <§6INDEX§3> §7| §9you delete this armorstand\n";
help+="§3/model delete <§6ID§3> §7| §9delete the model with all armorstands\n";
help+="§3/model setvisible <§6INDEX§3> <§6true§3/§6false> | §9change the visible\n";
help+="§3/model setitem <§6INDEX§3> <§6MaterialID:subID/hand§3> | §9change Item\n";
help+="§3/model setype <§6INDEX§3> <§6ARM/HEAD§3> | §9change ArmorStand Type\n";
help+="§3/model save";
help+="§3/model killall <§6radius,ModelID§3>";
if(!p.hasPermission("furniture.admin") && !p.isOp()){return true;}
if(args.length==0){
p.sendMessage(help);
return true;
}else if(args.length==2){
if(args[0].equalsIgnoreCase("create")){
if(ModelManager.getModelCreator().isInManager(p)){p.sendMessage("You already in the ModelCreatorMode");return true;}
if(ModelManager.getModelCreator().getModelByName(args[1])!=null){p.sendMessage("Model Already exist");return true;}
ModelManager.getModelCreator().enterModelCreator(p, args[1]);
p.sendMessage("You enterd the Model Creator for model: " + args[1]);
return true;
}if(args[0].equalsIgnoreCase("edit")){
if(!ModelManager.getModelCreator().isInManager(p)){p.sendMessage("You are not in the edit Mode");return true;}
if(!Utils.isInt(args[1])){p.sendMessage(help);return true;}
ModelCreator modelC = ModelManager.getModelCreator().getModelCreator(p);
if(modelC.activeArmorStandID!=null){p.sendMessage("You have an unsaved armorstand");return true;}
Integer index = Integer.parseInt(args[1]);
if(modelC.getArmorStand(index)==null){p.sendMessage("ArmorStand does not exist"); return true;}
modelC.setActiveArmorStandIndex(index);
p.sendMessage("You can edit the ArmorStand #" + index);return true;
}else if(args[0].equalsIgnoreCase("remove")){
if(!ModelManager.getModelCreator().isInManager(p)){p.sendMessage("You are not in the edit Mode");return true;}
if(!Utils.isInt(args[1])){p.sendMessage(help);return true;}
ModelCreator modelC = ModelManager.getModelCreator().getModelCreator(p);
if(modelC.activeArmorStandID!=null){p.sendMessage("You have an unsaved armorstand");return true;}
Integer index = Integer.parseInt(args[1]);
if(modelC.getArmorStand(index)==null){p.sendMessage("ArmorStand does not exist"); return true;}
modelC.removeArmorStand(index);
p.sendMessage("You have remove the ArmorStand #" + index);return true;
}else{
p.sendMessage(help);return true;
}
}else if(args.length==5){
Vector v = new Vector(0, 0, 0);
if(args[0].equalsIgnoreCase("add")){
if(!ModelManager.getModelCreator().isInManager(p)){p.sendMessage("You are not in the edit Mode");return true;}
ModelCreator modelC = ModelManager.getModelCreator().getModelCreator(p);
if(modelC.activeArmorStandID!=null){p.sendMessage("You have an unsaved armorstand");return true;}
if(!(args[1].equalsIgnoreCase("ARM") || args[1].equalsIgnoreCase("HEAD"))){p.sendMessage(help);return true;}
HeadArmType ha = null;
ItemStack is = null;
Boolean visible;
Boolean mini;
if(args[1].equalsIgnoreCase("ARM")){ha = HeadArmType.ARM;}
if(args[1].equalsIgnoreCase("HEAD")){ha = HeadArmType.HEAD;}
if(args[2].equalsIgnoreCase("hand")){is=p.getItemInHand();}else{
if(getItemStackFromString(args[2]) == null){p.sendMessage("Not Valid Item format");return true;}
is = getItemStackFromString(args[2]);
}
if(!Utils.isBoolean(args[3])){p.sendMessage(help);return true;}
if(!Utils.isBoolean(args[4])){p.sendMessage(help);return true;}
visible = Boolean.parseBoolean(args[3]);
mini = Boolean.parseBoolean(args[4]);
v = Utils.getCenter(p.getLocation().getBlock().getLocation()).toVector();
Integer i = modelC.addArmorStand(v, ha, null, is, visible, mini, Utils.yawToFace(p.getLocation().getYaw()), Utils.yawToFace(p.getLocation().getYaw()));
modelC.setActiveArmorStandIndex(i);
}else{
p.sendMessage(help);
}
}else if(args.length==3){
if(!ModelManager.getModelCreator().isInManager(p)){p.sendMessage("You are not in the edit Mode");return true;}
if(!Utils.isInt(args[1])){p.sendMessage(help);return true;}
ModelCreator mc = ModelManager.getModelCreator().getModelCreator(p);
Integer index = Integer.parseInt(args[1]);
if(mc.getArmorStand(index)==null){p.sendMessage("ArmorStand does not exist"); return true;}
HeadArmType type = mc.getType(index);
EulerAngle angle = mc.getEuler(index, type);
ItemStack is = mc.getItemStack(index);
ArmorStand as = mc.getArmorStand(index);
Vector v = as.getLocation().toVector();
BlockFace face1 = Utils.yawToFaceRadial(as.getLocation().getYaw());
if(args[0].equalsIgnoreCase("setvisible")){
if(!Utils.isBoolean(args[2])){p.sendMessage(help);return true;}
mc.editArmorStand(v, type, angle, is, Boolean.parseBoolean(args[2]), as.isSmall(), index, face1, face1);
p.sendMessage("Change Armorstand Visible to:" + Boolean.parseBoolean(args[2]));
return true;
}else if(args[0].equalsIgnoreCase("setitem")){
if(args[2].equalsIgnoreCase("hand")){is=p.getItemInHand();}else{
if(getItemStackFromString(args[2]) == null){p.sendMessage("Not Valid Item format");return true;}
is = getItemStackFromString(args[2]);
}
mc.editArmorStand(v, type, angle, is, as.isVisible(), as.isSmall(), index, face1, face1);
p.sendMessage("Change Armorstand Item");
return true;
}else if(args[0].equalsIgnoreCase("setype")){
if(!(args[2].equalsIgnoreCase("ARM") || args[2].equalsIgnoreCase("HEAD"))){p.sendMessage(help);return true;}
if(args[2].equalsIgnoreCase("ARM")){type = HeadArmType.ARM;as.setHelmet(null);}
if(args[2].equalsIgnoreCase("HEAD")){type = HeadArmType.HEAD;as.setItemInHand(null);}
mc.editArmorStand(v, type, angle, is, as.isVisible(), as.isSmall(), index, face1, face1);
p.sendMessage("Change Armorstand Type to:" + type.name());
return true;
}else{
p.sendMessage(help);return true;
}
}else if(args.length == 1){
if(args[0].equalsIgnoreCase("save")){
if(!ModelManager.getModelCreator().isInManager(p)){p.sendMessage("You are not in the edit Mode");return true;}
ModelManager mc = ModelManager.getModelCreator();
ModelSave.save(mc.getModelCreator(p).ID, mc.getModelCreator(p).getModel());
mc.removeall(mc.getModelCreator(p).ID);
p.sendMessage("Model Saved");
}else if(args[0].equalsIgnoreCase("test")){
Vector pV = p.getLocation().getBlock().getLocation().toVector();
Vector pVNew = Utils.getRelativ(pV, 1D, Utils.yawToFace(p.getLocation().getYaw()));
Location l = pVNew.toLocation(p.getWorld());
l.getBlock().setType(Material.DIAMOND_BLOCK);
return true;
}
}else{
p.sendMessage(help);return true;
}
return false;
}
public ItemStack getItemStackFromString(String s){
String mat = s;
Material m = null;
short subID = 0;
if(mat.contains(":")){
String[] list = mat.split(":");
if(getMaterialFromString(list[0]) == null){return null;}
m = getMaterialFromString(list[0]);
if(Utils.isInt(list[1])) subID = (short) Integer.parseInt(list[1]);
}else{
if(getMaterialFromString(s) == null){return null;}
m = getMaterialFromString(s);
}
ItemStack is = new ItemStack(m);
is.setDurability(subID);
return is;
}
@SuppressWarnings("deprecation")
public Material getMaterialFromString(String s){
if(Utils.isInt(s)){
Integer i = Integer.parseInt(s);
if(Material.getMaterial(i)==null){return null;}
return Material.getMaterial(i);
}else if(Material.getMaterial(s.toUpperCase()) != null){
return Material.getMaterial(s.toUpperCase());
}
return null;
}
}

View File

@ -1,30 +0,0 @@
package de.Ste3et_C0st.Furniture.Model;
import org.bukkit.Location;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public final class ModelCreateEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private Modele model;
private Location l;
private boolean cancelled;
private boolean copy;
public ModelCreateEvent(Modele model, Location l) {
this.model = model;
this.l = l;
if(model.getID().contains("#")){
copy=true;
}
}
public HandlerList getHandlers() {return handlers;}
public Location getLocation(){return l;}
public Modele getModel(){return model;}
public static HandlerList getHandlerList() {return handlers;}
public boolean isCopy() {return copy;}
public boolean isCancelled() {return cancelled;}
public void setCancelled(boolean arg0) {cancelled = arg0;}
}

View File

@ -1,70 +0,0 @@
package de.Ste3et_C0st.Furniture.Model;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
import de.Ste3et_C0st.Furniture.Main.Type.HeadArmType;
import de.Ste3et_C0st.Furniture.Main.Utils;
public class ModelCreator {
String ID;
Integer activeArmorStandID;
Player p;
Modele m;
ModelInventory inv;
Material mat;
byte dru;
Location l;
//The Modele is the first model of the furniture
//The Spawner class can spawn 1-1 copy of the furniture
@SuppressWarnings("deprecation")
public ModelCreator(Player p, String ID) {
this.p = p;
this.ID = ID;
l = Utils.getCenter(p.getLocation().getBlock().getLocation().add(0, -.5, 0));
l.setYaw(p.getLocation().getYaw());
this.m = new Modele(ID, l);
this.inv = new ModelInventory(p);
this.inv.setInventory(ID);
this.mat = l.getBlock().getType();
this.dru = l.getBlock().getData();
l.getBlock().setType(Material.REDSTONE_BLOCK);
}
public Integer addArmorStand(Vector v1, HeadArmType type, EulerAngle eular, ItemStack is, Boolean show, Boolean mini, BlockFace b, BlockFace b2){
return m.addArmorStand(v1, type, eular, is, show, mini, b, b2);
}
public void removeArmorStand(Integer index){
m.removeArmorStand(index);
}
public void editArmorStand(Vector v1, HeadArmType type, EulerAngle eular, ItemStack is, boolean show, boolean mini, Integer index, BlockFace b, BlockFace b2){
m.editArmorStand(v1, type, eular, is, show, mini, index, b, b2);
}
public void setActiveArmorStandIndex(Integer i) {activeArmorStandID = i;}
public Integer getActive() {return this.activeArmorStandID;}
public ArmorStand getArmorStand(Integer index){return m.getArmorStand(index, p.getWorld());}
public HeadArmType getType(Integer index) {return m.getType(index);}
public EulerAngle getEuler(Integer index, HeadArmType type) {return m.getEuler(index, type);}
public ItemStack getItemStack(Integer index) {return m.getItemStack(index);}
public ModelInventory getModelInv(){return this.inv;}
public Modele getModel() {return this.m;}
public Location getStartLocation() {return l;}
public Material getMaterial(){return mat;}
@SuppressWarnings("deprecation")
public void removeall() {
m.removeall();
this.l.getBlock().setType(this.mat);
this.l.getBlock().setData(this.dru);
}
}

View File

@ -1,89 +0,0 @@
package de.Ste3et_C0st.Furniture.Model;
import java.util.HashMap;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
public class ModelInventory {
Player p;
Inventory inv;
HashMap<Integer, ItemStack> isList = new HashMap<Integer, ItemStack>();
public ModelInventory(Player p){
this.p = p;
this.inv = p.getInventory();
}
public void setInventory(String id){
this.p.getInventory().clear();
Inventory inv = this.p.getInventory();
ItemStack is = new ItemStack(Material.BEDROCK);
ItemMeta im = is.getItemMeta();
im.setDisplayName("§9" + id + " §6Editor");
is.setItemMeta(im);
inv.setItem(0, is);
isList.put(0, is);
is = new ItemStack(Material.BOOK);
im = is.getItemMeta();
im.setDisplayName("§cTutorial");
is.setItemMeta(im);
inv.setItem(2, is);
isList.put(1, is);
is = new ItemStack(Material.GOLD_AXE);
im = is.getItemMeta();
im.setDisplayName("§6DegressMode: §cRotate");
is.setItemMeta(im);
inv.setItem(4, is);
isList.put(2, is);
is = new ItemStack(Material.ARROW);
im = is.getItemMeta();
im.setDisplayName("§4exit editor");
is.setItemMeta(im);
inv.setItem(8, is);
isList.put(3, is);
this.p.updateInventory();
}
public void leaveEditor(){
this.p.getInventory().clear();
this.p.getInventory().setContents(this.inv.getContents());
this.p.updateInventory();
this.isList.clear();
this.inv = null;
}
public ItemStack getItem(){
return isList.get(2);
}
public void setItem(Integer i){
if(i>5){i = 0;}
Inventory inv = this.p.getInventory();
ItemStack is = new ItemStack(Material.GOLD_AXE);
ItemMeta im = is.getItemMeta();
if(i.equals(0)){
im.setDisplayName("§6DegressMode: §cRotate");
is.setItemMeta(im);
}else if(i.equals(1)){
im.setDisplayName("§6DegressMode: §cX");
is.setItemMeta(im);
}else if(i.equals(2)){
im.setDisplayName("§6DegressMode: §cY");
is.setItemMeta(im);
}else if(i.equals(3)){
im.setDisplayName("§6DegressMode: §cZ");
is.setItemMeta(im);
}
inv.setItem(4, is);
isList.put(2, is);
this.p.updateInventory();
}
}

View File

@ -1,209 +0,0 @@
package de.Ste3et_C0st.Furniture.Model;
import java.util.HashMap;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
import de.Ste3et_C0st.Furniture.Main.Type.HeadArmType;
import de.Ste3et_C0st.Furniture.Main.Utils;
public class ModelListener implements Listener {
private HashMap<Player, Integer> degressLevel = new HashMap<Player, Integer>();
private HashMap<Player, Double> scaleList = new HashMap<Player, Double>();
private HashMap<Player, ModelTimer> modelTimerList = new HashMap<Player, ModelTimer>();
@EventHandler
public void onMouseWeel(PlayerItemHeldEvent e){
Vector v1 = new Vector(0,0,0);
if(ModelManager.getModelCreator().isInManager(e.getPlayer())){
Integer index = ModelManager.getModelCreator().getModelCreator(e.getPlayer()).getActive();
ModelCreator mc = ModelManager.getModelCreator().getModelCreator(e.getPlayer());
Modele model = mc.getModel();
ArmorStand as = mc.getArmorStand(index);
if(as==null){return;}
Player p = e.getPlayer();
Double scale = 1D;
if(scaleList.containsKey(p)){scale = scaleList.get(p);}
if(!p.isSneaking()){
BlockFace face1 = Utils.yawToFace(p.getLocation().getYaw(), p.getLocation().getPitch());
BlockFace face2 = Utils.yawToFaceRadial(as.getLocation().getYaw());
HeadArmType type = mc.getType(index);
EulerAngle angle = mc.getEuler(index, type);
ItemStack is = mc.getItemStack(index);
if(((e.getPreviousSlot()-e.getNewSlot()>=0) || (e.getPreviousSlot()==0&&e.getNewSlot()==8)) && !(e.getPreviousSlot()==8&&e.getNewSlot()==0)){
v1 = Utils.getRelativ(as.getLocation().toVector(), -1D * scale, face1);
mc.editArmorStand(v1, type, angle, is, as.isVisible(), as.isSmall(), index, face1, face2);
}else{
v1 = Utils.getRelativ(as.getLocation().toVector(), 1D * scale, face1);
mc.editArmorStand(v1, type, angle, is, as.isVisible(), as.isSmall(), index, face1, face2);
}
}else{
HeadArmType type = mc.getType(index);
EulerAngle angle = mc.getEuler(index, type);
ItemStack is = mc.getItemStack(index);
BlockFace face1 = Utils.yawToFace(p.getLocation().getYaw());
BlockFace face3 = Utils.yawToFace(as.getLocation().getYaw());
EulerAngle oldEular = mc.getEuler(index, type);
if(!degressLevel.containsKey(p)){degressLevel.put(p, 0);}
if(Utils.yawToFace(p.getLocation().getYaw(), p.getLocation().getPitch()).equals(BlockFace.UP)){return;}
if(Utils.yawToFace(p.getLocation().getYaw(), p.getLocation().getPitch()).equals(BlockFace.DOWN)){return;}
v1=as.getLocation().toVector();
if(degressLevel.get(p).equals(0)){
if(((e.getPreviousSlot()-e.getNewSlot()>=0) || (e.getPreviousSlot()==0&&e.getNewSlot()==8)) && !(e.getPreviousSlot()==8&&e.getNewSlot()==0)){
BlockFace face2 = Utils.yawToFaceRadial(as.getLocation().getYaw() + 45);
mc.editArmorStand(v1, type, angle, is, as.isVisible(), as.isSmall(), index, face1, face2);
}else{
BlockFace face2 = Utils.yawToFaceRadial(as.getLocation().getYaw() - 45);
mc.editArmorStand(v1, type, angle, is, as.isVisible(), as.isSmall(), index, face1, face2);
}
}else if(degressLevel.get(p).equals(1)){
if(((e.getPreviousSlot()-e.getNewSlot()>=0) || (e.getPreviousSlot()==0&&e.getNewSlot()==8)) && !(e.getPreviousSlot()==8&&e.getNewSlot()==0)){
EulerAngle newEular = oldEular.add(.2*scale, 0, 0);
mc.editArmorStand(v1, type, newEular, is, as.isVisible(), as.isSmall(), index, face1, face3);
}else{
EulerAngle newEular = oldEular.add(-.2*scale, 0, 0);
mc.editArmorStand(v1, type, newEular, is, as.isVisible(), as.isSmall(), index, face1, face3);
}
}else if(degressLevel.get(p).equals(2)){
if(((e.getPreviousSlot()-e.getNewSlot()>=0) || (e.getPreviousSlot()==0&&e.getNewSlot()==8)) && !(e.getPreviousSlot()==8&&e.getNewSlot()==0)){
EulerAngle newEular = oldEular.add(0, .2*scale, 0);
mc.editArmorStand(v1, type, newEular, is, as.isVisible(), as.isSmall(), index, face1, face3);
}else{
EulerAngle newEular = oldEular.add(0, -.2*scale, 0);
mc.editArmorStand(v1, type, newEular, is, as.isVisible(), as.isSmall(), index, face1, face3);
}
}else if(degressLevel.get(p).equals(3)){
if(((e.getPreviousSlot()-e.getNewSlot()>=0) || (e.getPreviousSlot()==0&&e.getNewSlot()==8)) && !(e.getPreviousSlot()==8&&e.getNewSlot()==0)){
EulerAngle newEular = oldEular.add(0, 0, .2*scale);
mc.editArmorStand(v1, type, newEular, is, as.isVisible(), as.isSmall(), index, face1, face3);
}else{
EulerAngle newEular = oldEular.add(0, 0, -.2*scale);
mc.editArmorStand(v1, type, newEular, is, as.isVisible(), as.isSmall(), index, face1, face3);
}
}
}
check(p, index, model);
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void damage(EntityDamageByEntityEvent e){
if(e.isCancelled()){return;}
if(e.getDamager() instanceof Player == false){return;}
if(e.getEntity() instanceof ArmorStand == false){return;}
if(e.getEntity() == null){return;}
if(e.getEntity().getName() == null){return;}
Player p = (Player) e.getDamager();
String name = e.getEntity().getName();
if(ModelManager.getModelCreator().isInManager(p)){
e.setCancelled(true);
Integer index = ModelManager.getModelCreator().getModelCreator(p).getActive();
ModelCreator mc = ModelManager.getModelCreator().getModelCreator(p);
ArmorStand as = mc.getArmorStand(index);
if(e.getEntity().equals(as)){
if(modelTimerList.containsKey(p)){
e.setDamage(0);
e.setCancelled(true);
p.sendMessage("ArmorStand saved #" + index);
mc.setActiveArmorStandIndex(null);
modelTimerList.get(p).cancleTimer();
}
}
if(name != null && name.length()>=13){
String[] split = name.split("-");
if(split != null && split.length>=1){
e.setDamage(0);
e.setCancelled(true);
}
}
}
}
@EventHandler
public void onClickEvent(PlayerInteractEvent e){
if(ModelManager.getModelCreator().isInManager(e.getPlayer())){
if(e.getItem()==null){return;}
if(e.getAction()==null){return;}
e.setCancelled(true);
if(!degressLevel.containsKey(e.getPlayer())){degressLevel.put(e.getPlayer(), 0);}
ModelInventory mInv = ModelManager.getModelCreator().getModelCreator(e.getPlayer()).getModelInv();
ItemStack is1 = e.getItem();
ItemStack is2 = mInv.getItem();
Integer lastMode = degressLevel.get(e.getPlayer());
if(is1.equals(is2)){
if(e.getAction().equals(Action.LEFT_CLICK_AIR) || e.getAction().equals(Action.LEFT_CLICK_BLOCK)){
lastMode++;
if(lastMode>3){lastMode=0;}
mInv.setItem(lastMode);
}else if(e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
lastMode--;
if(lastMode<0){lastMode=3;}
mInv.setItem(lastMode);
}
}
degressLevel.put(e.getPlayer(), lastMode);
}
}
public void check(Player p, Integer index, Modele m){
ModelTimer model = null;
if(modelTimerList.containsKey(p)){
model = modelTimerList.get(p);
model.restartTimer();
modelTimerList.put(p, model);
}else{
model = new ModelTimer(p,index, m, this);
model.StartTimer();
}
modelTimerList.put(p, model);
}
@EventHandler
public void onDrop(PlayerDropItemEvent e){
if(ModelManager.getModelCreator().isInManager(e.getPlayer())){
e.setCancelled(true);
Double scale = 1D;
if(scaleList.containsKey(e.getPlayer())){scale = scaleList.get(e.getPlayer());}
if(e.getPlayer().isSneaking()){
if(scale>0.03125){
scale = scale/2;
}else{
scale = 0.03125;
}
}else{
if(scale<1){
scale = scale*2;
}else{
scale = 1.0;
}
}
if(scale<=0D){scale=0.03125;}
if(scale>=1D){scale=1D;}
e.getPlayer().sendMessage("Scalamode:" + scale);
scaleList.put(e.getPlayer(), scale);
}
}
public void remove(ModelTimer modelTimer, Player p) {
ModelManager.getModelCreator().getModelCreator(p).activeArmorStandID = null;
modelTimerList.remove(modelTimer);
}
}

View File

@ -1,42 +0,0 @@
package de.Ste3et_C0st.Furniture.Model;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Main.Type.HeadArmType;
import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.config;
public class ModelLoad {
private static config cc;
private static FileConfiguration fc;
private static String folder = "/models/";
public static void load(String ID){
cc = new config();
fc = cc.getConfig(ID, folder);
World w = Bukkit.getServer().getWorld(fc.getString("Model.Location.World"));
BlockFace b = Utils.StringToFace(fc.getString("Model.Location.BlockFace"));
for(String id : fc.getConfigurationSection("Model.ArmorStand").getKeys(false)){
String s = "Model.ArmorStand." + id + ".";
Double RelativeX = fc.getDouble(s+"x");
Double RelativeY = fc.getDouble(s+"y");
Double RelativeZ = fc.getDouble(s+"z");
BlockFace armorFace = Utils.StringToFace(fc.getString(s+"face"));
HeadArmType type = Utils.haTgetByString(fc.getString(s+"type"));
Boolean small = fc.getBoolean(fc.getString(s+"small"));
Boolean Visible = fc.getBoolean(s+"Visible");
Boolean colorable = fc.getBoolean(s+"colorable");
Boolean sitable = fc.getBoolean(s+"sitable");
Boolean fireable = fc.getBoolean(s+"fireable");
ItemStack is = fc.getItemStack(s+"Item");
EulerAngle ea = new EulerAngle(fc.getDouble(s+"Rad.X"), fc.getDouble(s+"Rad.Y"), fc.getDouble(s+"Rad.Z"));
}
}
}

View File

@ -1,97 +0,0 @@
package de.Ste3et_C0st.Furniture.Model;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
import de.Ste3et_C0st.Furniture.Main.Type.HeadArmType;
public class ModelManager {
private static ModelManager modelManager;
private HashMap<Player, ModelCreator> modelCreator = new HashMap<Player, ModelCreator>();
private List<Modele> modelListe = new ArrayList<Modele>();
public ModelManager(){
modelManager = this;
}
public static ModelManager getModelCreator(){
return modelManager;
}
public void enterModelCreator(Player p, String ID){
modelCreator.put(p, new ModelCreator(p, ID));
}
public void addModelListe(Modele m){
if(m==null){return;}
this.modelListe.add(m);
}
public void removeModelListe(Modele m){
if(m==null){return;}
if(modelListe.isEmpty()){return;}
this.modelListe.remove(m);
}
public List<Modele> getModel(){
return this.modelListe;
}
public Modele getModelByName(String name){
if(name==null){return null;}
if(modelListe.isEmpty()){return null;}
for(Modele m : modelListe){
if(m.getID().equals(name)){
return m;
}
}
return null;
}
public Integer getCopyIndex(String iD){
int i = 1;
if(!modelListe.isEmpty()){
for(Modele m : modelListe){
if(m.getID().startsWith(iD)){
i++;
}
}
}
return i;
}
public Modele spawnCopy(String iD, Location loc){
return new Modele(iD + "#" + getCopyIndex(iD), loc);
}
public void addArmorStand(Vector v, HeadArmType type, EulerAngle eular, ItemStack is, Boolean show, Boolean mini, Modele m, BlockFace b, BlockFace b2){
m.addArmorStand(v, type, eular, is, show, mini, b, b2);
}
public boolean isInManager(Player p) {
if(modelCreator.containsKey(p)){
return true;
}else{
return false;
}
}
public ModelCreator getModelCreator(Player p){
return modelCreator.get(p);
}
public void removeall(String iD) {
Modele m = getModelByName(iD);
m.removeall();
this.modelListe.remove(m);
}
}

View File

@ -1,53 +0,0 @@
package de.Ste3et_C0st.Furniture.Model;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.ArmorStand;
import de.Ste3et_C0st.Furniture.Main.Type.HeadArmType;
import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.config;
public class ModelSave {
private static config cc;
private static FileConfiguration fc;
private static String folder = "/models/";
public static void save(String ID, Modele m){
cc = new config();
fc = cc.getConfig(ID, folder);
World w = m.getLocation().getWorld();
fc.set("Model.Location.X", m.getLocation().getX());
fc.set("Model.Location.Y", m.getLocation().getY());
fc.set("Model.Location.Z", m.getLocation().getZ());
fc.set("Model.Location.World", m.getLocation().getWorld().getName());
fc.set("Model.Location.BlockFace", Utils.yawToFace(m.getLocation().getYaw()).name());
int i = 0;
for(String id : m.getList()){
Integer j = m.getIndex(id);
HeadArmType type = m.getType(j);
ArmorStand as = m.getArmorStand(j, w);
String s = "Model.ArmorStand." + i + ".";
fc.set(s+"face", m.getArmorStandFace(j).name());
fc.set(s+"type", type.name());
fc.set(s+"small", as.isSmall());
fc.set(s+"Visible", as.isVisible());
fc.set(s+"colorable", m.getColorable(j));
fc.set(s+"sitable", m.getSitable(j));
fc.set(s+"fireable", m.getFireable(j));
if(type.equals(HeadArmType.ARM)){
fc.set(s + "Item", as.getItemInHand());
fc.set(s+"Rad.X", as.getRightArmPose().getX());
fc.set(s+"Rad.Y", as.getRightArmPose().getX());
fc.set(s+"Rad.Z", as.getRightArmPose().getX());
}else{
fc.set(s + "Item", as.getHelmet());
fc.set(s+"Rad.X", as.getHeadPose().getX());
fc.set(s+"Rad.Y", as.getHeadPose().getX());
fc.set(s+"Rad.Z", as.getHeadPose().getX());
}
i++;
}
cc.saveConfig(ID, fc, folder);
}
}

View File

@ -1,49 +0,0 @@
package de.Ste3et_C0st.Furniture.Model;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
import de.Ste3et_C0st.Furniture.Main.main;
public class ModelTimer {
Integer index;
BukkitTask timer;
Modele m;
Player p;
ModelListener modelL;
public ModelTimer(Player p, Integer index, Modele m, ModelListener modelListener) {
this.index = index;
this.p = p;
this.m = m;
this.modelL = modelListener;
}
public void StartTimer(){
this.timer = Bukkit.getScheduler().runTaskLater(main.getInstance(), new Runnable() {
@Override
public void run() {
m.removeArmorStand(index);
cancleTimer();
}
}, 10*20);
}
public void restartTimer(){
if(this.timer != null){
this.timer.cancel();
}
StartTimer();
}
public void cancleTimer(){
modelL.remove(this, this.p);
this.index = null;
this.m = null;
this.p = null;
this.timer.cancel();
this.timer = null;
}
}

View File

@ -1,242 +0,0 @@
package de.Ste3et_C0st.Furniture.Model;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.Type.HeadArmType;
public class Modele {
private List<String> IDList = new ArrayList<String>();
private List<String> colorList = new ArrayList<String>();
private List<String> sitable = new ArrayList<String>();
private List<String> firelist = new ArrayList<String>();
private String iD;
private Location start;
private BlockFace b;
private World w;
private int copyID;
public List<String> getList(){return this.IDList;}
public String getID(){return this.iD;}
public World getWorld(){return this.w;}
public BlockFace getDirection(){return this.b;}
public Location getLocation(){return this.start;}
public Modele(String iD, Location loc) {
this.start = loc;
this.iD = iD;
this.w = loc.getWorld();
this.b = Utils.yawToFace(loc.getYaw());
ModelCreateEvent event = new ModelCreateEvent(this, start);
if(iD.contains("#")){
copyID = Integer.parseInt(iD.split("#")[1]);
}else{
copyID = 0;
}
if(!event.isCancelled()){
ModelManager.getModelCreator().addModelListe(this);
}
}
//Create create one Model
//When the Model is create you can Spawn a clone to the Location
//A model copy starts with the original ID like sofa#COPYID
//A ArmorStand has the the copy id 123456-123456-COPYID
public Integer addArmorStand(Vector v, HeadArmType type, EulerAngle eular, ItemStack is, boolean show, boolean mini, BlockFace bf, BlockFace bf2){
String id = Utils.createRandomRegistryId() + "-" + copyID;
Location l = v.toLocation(w);
if(bf2!=null){
l.setYaw(Utils.FaceToYaw(bf2));
}
ArmorStand armorstand = (ArmorStand) w.spawnEntity(l, EntityType.ARMOR_STAND);
armorstand.setCustomName(id);
switch (type) {
case HEAD:
armorstand.setArms(false);
if(is!=null&&!is.getType().equals(Material.AIR)){armorstand.setHelmet(is);}
if(eular!=null){armorstand.setHeadPose(eular);}
break;
case ARM:
armorstand.setArms(true);
if(is!=null&&!is.getType().equals(Material.AIR)){armorstand.setItemInHand(is);}
if(eular!=null){armorstand.setRightArmPose(eular);}
break;
}
armorstand.setVisible(show);
armorstand.setBasePlate(show);
armorstand.setSmall(mini);
armorstand.setGravity(false);
IDList.add(id);
return IDList.indexOf(id);
}
public void editArmorStand(Vector v, HeadArmType type, EulerAngle eular, ItemStack is, boolean show, boolean mini, Integer index, BlockFace bf, BlockFace bf2){
if(index==null){return;}
if(index>=IDList.size()){return;}
ArmorStand armorstand = getArmorStand(index, w);
if(armorstand == null){return;}
Location l = v.toLocation(w);
if(bf2!=null){
l.setYaw(Utils.FaceToYaw(bf2));
}
armorstand.teleport(l);
switch (type) {
case HEAD:
armorstand.setArms(false);
if(is!=null&&!is.getType().equals(Material.AIR)){armorstand.setHelmet(is);}
if(eular!=null){armorstand.setHeadPose(eular);}
break;
case ARM:
armorstand.setArms(true);
if(is!=null&&!is.getType().equals(Material.AIR)){armorstand.setItemInHand(is);}
if(eular!=null){armorstand.setRightArmPose(eular);}
break;
}
armorstand.setVisible(show);
armorstand.setBasePlate(show);
armorstand.setSmall(mini);
//Koordinaten hier rein X Y Z = Location
}
public void removeArmorStand(Integer index){
if(index ==null){return;}
if(getArmorStand(index, w)==null){return;}
getArmorStand(index, w).remove();
IDList.remove(index);
}
public BlockFace getArmorStandFace(Integer index){
if(index ==null){return null;}
if(getArmorStand(index, w)==null){return null;}
return Utils.yawToFace(getArmorStand(index, w).getLocation().getYaw());
}
public String getID(Integer index){
if(index==null){return null;}
if(index>=IDList.size()){return null;}
return IDList.get(index);
}
public Integer getIndex(String s){
if(s==null){return null;}
if(!IDList.contains(s)){return null;}
return IDList.indexOf(s);
}
public ArmorStand getArmorStand(Integer index, World w){
if(getID(index)==null){return null;}
String ID = getID(index);
for(Entity e : w.getEntities()){
if(e instanceof ArmorStand){
if(e!=null){
if(e.getName() != null){
if(e.getName().equals(ID)){
return (ArmorStand) e;
}
}
}
}
}
return null;
}
public HeadArmType getType(Integer index) {
if(getArmorStand(index, w) == null){return null;}
ArmorStand as = getArmorStand(index, w);
if(!as.hasArms()){
return HeadArmType.HEAD;
}else{
return HeadArmType.ARM;
}
}
public EulerAngle getEuler(Integer index, HeadArmType type) {
if(getArmorStand(index, w) == null){return null;}
ArmorStand as = getArmorStand(index, w);
if(type.equals(HeadArmType.ARM)){return as.getRightArmPose();}
return as.getHeadPose();
}
public ItemStack getItemStack(Integer index) {
if(getArmorStand(index, w) == null){return null;}
ArmorStand as = getArmorStand(index, w);
if(as.getItemInHand()!=null){
return as.getItemInHand();
}else{
return as.getHelmet();
}
}
public void removeall() {
for(String s : IDList){
Integer i = getIndex(s);
getArmorStand(i, w).remove();
}
IDList.clear();
}
public void setColorable(Integer j){
if(getID(j)==null){return;}
if(colorList.contains(getID(j))){return;}
colorList.add(getID(j));
}
public void removeColorable(Integer j){
if(getID(j)==null){return;}
if(!colorList.contains(getID(j))){return;}
colorList.remove(getID(j));
}
public void setSitable(Integer j){
if(getID(j)==null){return;}
if(sitable.contains(getID(j))){return;}
sitable.add(getID(j));
}
public void setFireable(Integer j){
if(getID(j)==null){return;}
if(firelist.contains(getID(j))){return;}
firelist.add(getID(j));
}
public void removeFireable(Integer j){
if(getID(j)==null){return;}
if(!firelist.contains(getID(j))){return;}
firelist.remove(getID(j));
}
public void removeSitable(Integer j){
if(getID(j)==null){return;}
if(!sitable.contains(getID(j))){return;}
sitable.remove(getID(j));
}
public Boolean getSitable(Integer j){
if(getID(j)==null){return false;}
if(sitable.contains(getID(j))){return true;}
return false;
}
public Boolean getColorable(Integer j) {
if(getID(j)==null){return false;}
if(colorList.contains(getID(j))){return true;}
return false;
}
public Boolean getFireable(Integer j) {
if(getID(j)==null){return false;}
if(firelist.contains(getID(j))){return true;}
return false;
}
}

View File

@ -3,23 +3,15 @@ package de.Ste3et_C0st.Furniture.Objects.electric;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
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.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
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.map.MapRenderer;
import org.bukkit.map.MapView;
@ -27,108 +19,135 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Camera.Utils.RenderClass;
import de.Ste3et_C0st.Furniture.Main.FurnitureCreateEvent;
import de.Ste3et_C0st.Furniture.Main.Permissions;
import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.Furniture.Main.Type.FurnitureType;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.LocationUtil;
import de.Ste3et_C0st.FurnitureLib.main.ArmorStandPacket;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureManager;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
public class camera implements Listener {
List<UUID> idList = new ArrayList<UUID>();
Location loc = null;
BlockFace b = null;
World w = null;
public class camera implements Listener{
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Plugin plugin;
private String id;
public String getID(){return this.id;}
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
public camera(Location location, Plugin plugin, String ID, List<UUID> uuids){
this.b = Utils.yawToFace(location.getYaw());
public camera(Location location, FurnitureLib lib, String name, Plugin plugin, ObjectID id){
this.lutil = main.getLocationUtil();
this.b = lutil.yawToFace(location.getYaw());
this.loc = location.getBlock().getLocation();
this.loc.setYaw(location.getYaw());
this.id = ID;
this.w = location.getWorld();
FurnitureCreateEvent event = new FurnitureCreateEvent(FurnitureType.CAMERA, this.id, location);
Bukkit.getPluginManager().callEvent(event);
if(!event.isCancelled()){
if(uuids==null){uuids = idList;}
spawn(uuids, location, plugin);
this.manager = lib.getFurnitureManager();
this.lib = lib;
this.plugin = plugin;
if(id!=null){
this.obj = id;
this.manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}else{
this.obj = new ObjectID(name, plugin.getName(), location);
}
spawn(location);
}
public void spawn(List<UUID> uuidList, Location location, Plugin plugin){
BlockFace b = Utils.yawToFace(location.getYaw()).getOppositeFace();
Location center = Utils.getCenter(location);
Location gehäuse = main.getNew(center, b, 0D, 0D).add(0,-1.0,0);
Location gehäuse2 = main.getNew(center, b, 0D, 0D).add(0,-0.4,0);
Location fokus = main.getNew(center, b, .15D, 0D).add(0,-.24,0);
Location search = main.getNew(center, b, .15D, 0D).add(0,-.7,0);
Location button = main.getNew(center, b, -.15D, -.15D).add(0,.08,0);
public void spawn(Location location){
List<ArmorStandPacket> aspList = new ArrayList<ArmorStandPacket>();
BlockFace b = lutil.yawToFace(location.getYaw()).getOppositeFace();
Location center = lutil.getCenter(location);
Location gehäuse = lutil.getRelativ(center, b, 0D, 0D).add(0,-1.0,0);
Location gehäuse2 = lutil.getRelativ(center, b, 0D, 0D).add(0,-0.4,0);
Location fokus = lutil.getRelativ(center, b, .15D, 0D).add(0,-.24,0);
Location search = lutil.getRelativ(center, b, .15D, 0D).add(0,-.7,0);
Location button = lutil.getRelativ(center, b, -.15D, -.15D).add(0,.08,0);
Location feet1 = main.getNew(center, b, .5D, .4D).add(0,-.9,0);
Location feet2 = main.getNew(center, b, -.2D, -.7D).add(0,-.9,0);
Location feet3 = main.getNew(center, b, -.7D, .2D).add(0,-.9,0);
Location feet1 = lutil.getRelativ(center, b, .5D, .4D).add(0,-.9,0);
Location feet2 = lutil.getRelativ(center, b, -.2D, -.7D).add(0,-.9,0);
Location feet3 = lutil.getRelativ(center, b, -.7D, .2D).add(0,-.9,0);
gehäuse.setYaw(Utils.FaceToYaw(b));
fokus.setYaw(Utils.FaceToYaw(b));
search.setYaw(Utils.FaceToYaw(b));
button.setYaw(Utils.FaceToYaw(b));
feet1.setYaw(Utils.FaceToYaw(b));
feet2.setYaw(Utils.FaceToYaw(b) + 180 - 45);
feet3.setYaw(Utils.FaceToYaw(b) + 180 + 45);
Utils.setArmorStand(gehäuse, null, new ItemStack(Material.WOOL, 1, (short) 15), false, false, false, getID(), idList);
Utils.setArmorStand(gehäuse2, null, new ItemStack(Material.WOOL, 1, (short) 15), false, true, false, getID(), idList);
Utils.setArmorStand(fokus, null, new ItemStack(Material.DISPENSER), false, true, false, getID(), idList);
Utils.setArmorStand(search, null, new ItemStack(Material.TRIPWIRE_HOOK, 1, (short) 15), false, false, false, getID(), idList);
Utils.setArmorStand(button, null, new ItemStack(Material.WOOD_BUTTON, 1, (short) 15), false, true, false, getID(), idList);
Utils.setArmorStand(feet1, new EulerAngle(1.2, 0, 0), new ItemStack(Material.STICK), true, false, false, getID(), idList);
Utils.setArmorStand(feet2, new EulerAngle(1.2, 0, 0), new ItemStack(Material.STICK), true, false, false, getID(), idList);
Utils.setArmorStand(feet3, new EulerAngle(1.2, 0, 0), new ItemStack(Material.STICK), true, false, false, getID(), idList);
main.getInstance().getManager().cameraList.add(this);
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
public List<String> getList(){
return Utils.UUIDListToStringList(idList);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void damage(EntityDamageByEntityEvent e){
if(e.isCancelled()){return;}
if(e.getDamager() instanceof Player == false){return;}
if(e.getEntity() instanceof ArmorStand == false){return;}
if(e.getEntity() == null){return;}
if(!idList.contains(e.getEntity().getUniqueId())){return;}
e.setCancelled(true);
if(!Permissions.check((Player) e.getDamager(), FurnitureType.CAMERA, "destroy.")){return;}
if(!main.getInstance().getCheckManager().canBuild((Player) e.getDamager(), getLocation())){return;}
if(((Player) e.getDamager()).getGameMode().equals(GameMode.CREATIVE)){delete(true, false);return;}
delete(true, true);
}
public void save(){
main.getInstance().mgr.saveCamera(this);
gehäuse.setYaw(lutil.FaceToYaw(b));
fokus.setYaw(lutil.FaceToYaw(b));
search.setYaw(lutil.FaceToYaw(b));
button.setYaw(lutil.FaceToYaw(b));
feet1.setYaw(lutil.FaceToYaw(b));
feet2.setYaw(lutil.FaceToYaw(b) + 180 - 45);
feet3.setYaw(lutil.FaceToYaw(b) + 180 + 45);
ArmorStandPacket as = manager.createArmorStand(obj, gehäuse);
as.getInventory().setHelmet(new ItemStack(Material.WOOL, 1, (short) 15));
aspList.add(as);
as = manager.createArmorStand(obj, gehäuse2);
as.getInventory().setHelmet(new ItemStack(Material.WOOL, 1, (short) 15));
as.setSmall(true);
aspList.add(as);
as = manager.createArmorStand(obj, fokus);
as.getInventory().setHelmet(new ItemStack(Material.DISPENSER));
as.setSmall(true);
aspList.add(as);
as = manager.createArmorStand(obj, search);
as.getInventory().setHelmet(new ItemStack(Material.TRIPWIRE_HOOK));
aspList.add(as);
as = manager.createArmorStand(obj, button);
as.getInventory().setHelmet(new ItemStack(Material.WOOD_BUTTON));
as.setSmall(true);
aspList.add(as);
as = manager.createArmorStand(obj, feet1);
as.getInventory().setItemInHand(new ItemStack(Material.STICK));
as.setPose(new EulerAngle(1.2, 0, 0), BodyPart.RIGHT_ARM);
aspList.add(as);
as = manager.createArmorStand(obj, feet2);
as.getInventory().setItemInHand(new ItemStack(Material.STICK));
as.setPose(new EulerAngle(1.2, 0, 0), BodyPart.RIGHT_ARM);
aspList.add(as);
as = manager.createArmorStand(obj, feet3);
as.getInventory().setItemInHand(new ItemStack(Material.STICK));
as.setPose(new EulerAngle(1.2, 0, 0), BodyPart.RIGHT_ARM);
aspList.add(as);
for(ArmorStandPacket asp : aspList){
asp.setInvisible(true);
asp.setGravity(false);
}
manager.send(obj);
//lib.saveObjToDB(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
}
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
private void onInteract(PlayerInteractAtEntityEvent e){
@EventHandler
private void onClick(FurnitureClickEvent e){
if(e.isCancelled()){return;}
Player player = e.getPlayer();
if(e.getRightClicked() == null){return;}
if(e.getRightClicked() instanceof ArmorStand == false){return;}
if(idList==null||idList.isEmpty()){return;}
if(!idList.contains(e.getRightClicked().getUniqueId())){return;}
e.setCancelled(true);
Location playerLocation = Utils.getLocationCopy(main.getNew(player.getLocation().getBlock().getLocation(), b, -1D, 0D));
Location location = Utils.getLocationCopy(getLocation());
if(playerLocation.equals(location) && Utils.yawToFace(player.getLocation().getYaw()).getOppositeFace().equals(b)){
if(!player.getInventory().getItemInHand().getType().equals(Material.MAP)){return;}
MapView view = Bukkit.getMap(player.getItemInHand().getDurability());
if(!e.getID().equals(obj)){return;}
Player p = e.getPlayer();
Location pLocation = lutil.getLocationCopy(lutil.getRelativ(p.getLocation().getBlock().getLocation(), b, -1D, 0D));
Location locCopy = lutil.getLocationCopy(getLocation());
if(pLocation.equals(locCopy) && lutil.yawToFace(p.getLocation().getYaw()).getOppositeFace().equals(b)){
if(!p.getInventory().getItemInHand().getType().equals(Material.MAP)){return;}
MapView view = Bukkit.getMap(p.getItemInHand().getDurability());
Location l = getLocation();
l.setYaw(Utils.FaceToYaw(b.getOppositeFace()));
Iterator<MapRenderer> iter = view.getRenderers().iterator();
l.setYaw(lutil.FaceToYaw(b.getOppositeFace()));
Iterator<MapRenderer> iter = view.getRenderers().iterator();
while(iter.hasNext()){
view.removeRenderer(iter.next());
}
@ -139,31 +158,13 @@ public class camera implements Listener {
}
}
public void delete(Boolean b, Boolean a){
if(b){
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("camera"));}
if(idList!=null&&!idList.isEmpty()){
for(UUID ids : idList){
if(ids==null){continue;}
ArmorStand as = Utils.getArmorStandAtID(w, ids);
if(as!=null){
if(a){getLocation().getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());}
as.remove();
main.getInstance().mgr.deleteFromConfig(getID(), "camera");
}
}
}
}
this.loc = null;
idList.clear();
main.getInstance().getManager().cameraList.remove(this);
@EventHandler
private void onBreak(FurnitureBreakEvent e){
if(e.isCancelled()){return;}
if(!e.canBuild(null)){return;}
if(!e.getID().equals(obj)){return;}
manager.remove(obj);
obj=null;
}
@EventHandler
public void onWaterFlow(BlockFromToEvent e){
Location locTo = e.getToBlock().getLocation();
if(loc!=null && locTo.equals(loc)){
e.setCancelled(true);
}
}
}

View File

@ -0,0 +1,127 @@
package de.Ste3et_C0st.Furniture.Objects.electric;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.LocationUtil;
import de.Ste3et_C0st.FurnitureLib.main.ArmorStandPacket;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureManager;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
public class tv implements Listener{
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Plugin plugin;
private String id;
public String getID(){return this.id;}
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
public tv(Location location, FurnitureLib lib, String name, Plugin plugin, ObjectID id){
this.lutil = main.getLocationUtil();
this.b = lutil.yawToFace(location.getYaw());
this.loc = location.getBlock().getLocation();
this.loc.setYaw(location.getYaw());
this.w = location.getWorld();
this.manager = lib.getFurnitureManager();
this.lib = lib;
this.plugin = plugin;
if(id!=null){
this.obj = id;
this.manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}else{
this.obj = new ObjectID(name, plugin.getName(), location);
}
spawn(location);
}
public void spawn(Location location){
List<ArmorStandPacket> aspList = new ArrayList<ArmorStandPacket>();
if(b.equals(BlockFace.WEST)){location = lutil.getRelativ(location, b, .0, -1.02);}
if(b.equals(BlockFace.SOUTH)){location = lutil.getRelativ(location, b, -1.0, -1.02);}
if(b.equals(BlockFace.EAST)){location = lutil.getRelativ(location, b, -1.0, .0);}
BlockFace b = lutil.yawToFace(location.getYaw()).getOppositeFace();
Location center = lutil.getCenter(getLocation());
center.add(0, -1.38, 0);
center.setYaw(lutil.FaceToYaw(b));
ArmorStandPacket as = manager.createArmorStand(obj, center);
as.getInventory().setHelmet(new ItemStack(Material.IRON_PLATE));
as.setSmall(true);
aspList.add(as);
// Loc ,angle, ITEMSTACK , Arm , Mini, invis, ID , List
center.add(0, -.45, 0);
center.setYaw(lutil.FaceToYaw(b));
as = manager.createArmorStand(obj, center);
as.getInventory().setHelmet(new ItemStack(Material.LEVER));
aspList.add(as);
Location tv = lutil.getRelativ(location, getBlockFace(), .85, .7);
tv.add(0, -1.33, 0);
tv.setYaw(lutil.FaceToYaw(b));
Double l = .63;
for(int i = 0;i<=1;i++){
setRow(tv, .63, l, -.35,2,lutil.degresstoRad(new EulerAngle(90, 0, 0)), aspList);
l+=.63;
}
for(ArmorStandPacket asp : aspList){
asp.setGravity(false);
asp.setBasePlate(false);
asp.setInvisible(true);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
}
public void setRow(Location loc, double x,double y, double z, int replay, EulerAngle angle, List<ArmorStandPacket> list){
Double d = .0;
for(int i = 0; i<=replay;i++){
Location loc1= lutil.getRelativ(loc, b, z, d-.825);
loc1.setYaw(lutil.FaceToYaw(b));
loc1.add(0, y,0);
ArmorStandPacket packet = manager.createArmorStand(obj, loc1);
packet.getInventory().setHelmet(new ItemStack(Material.CARPET, 1 , (short) 15));
packet.setPose(angle, BodyPart.HEAD);
list.add(packet);
d+=x;
}
}
@EventHandler
private void onBreak(FurnitureBreakEvent e){
if(e.isCancelled()){return;}
if(!e.canBuild(null)){return;}
if(!e.getID().equals(obj)){return;}
manager.remove(obj);
obj=null;
}
}

View File

@ -0,0 +1,284 @@
package de.Ste3et_C0st.Furniture.Objects.garden;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.LocationUtil;
import de.Ste3et_C0st.FurnitureLib.main.ArmorStandPacket;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureManager;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
public class graveStone implements Listener{
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Plugin plugin;
private String id;
public String getID(){return this.id;}
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
public graveStone(Location location, FurnitureLib lib, String name, Plugin plugin, ObjectID id){
this.lutil = main.getLocationUtil();
this.b = lutil.yawToFace(location.getYaw());
this.loc = location.getBlock().getLocation();
this.loc.setYaw(location.getYaw());
this.w = location.getWorld();
this.manager = lib.getFurnitureManager();
this.lib = lib;
this.plugin = plugin;
if(id!=null){
this.obj = id;
setBlock();
this.manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}else{
this.obj = new ObjectID(name, plugin.getName(), location);
}
spawn(location);
setBlock();
}
Location signLoc;
Block sign;
String[] lines = new String[4];
private void setBlock(){
Location location = loc.clone();
if(b.equals(BlockFace.WEST)){location = lutil.getRelativ(location, b, .0, -1.02);}
if(b.equals(BlockFace.SOUTH)){location = lutil.getRelativ(location, b, -1.0, -1.02);}
if(b.equals(BlockFace.EAST)){location = lutil.getRelativ(location, b, -1.0, .0);}
Location center = lutil.getRelativ(location, getBlockFace(), .18D, .955D);
center.setYaw(lutil.FaceToYaw(b.getOppositeFace()) + 90);
Location kreutz2 = lutil.getRelativ(center, getBlockFace(), -.23, -1.27);
Location sign = lutil.getRelativ(kreutz2.getBlock().getLocation(), b, 0D, 1D);
this.signLoc = sign;
this.sign = lutil.setSign(b, sign);
this.lines = getText();
}
public void spawn(Location location){
List<ArmorStandPacket> aspList = new ArrayList<ArmorStandPacket>();
if(b.equals(BlockFace.WEST)){location = lutil.getRelativ(location, b, .0, -1.02);}
if(b.equals(BlockFace.SOUTH)){location = lutil.getRelativ(location, b, -1.0, -1.02);}
if(b.equals(BlockFace.EAST)){location = lutil.getRelativ(location, b, -1.0, .0);}
Location center = lutil.getRelativ(location, getBlockFace(), .18D, .955D);
center.add(0,-.8,0);
center.setYaw(lutil.FaceToYaw(b.getOppositeFace()) + 90);
Location kreutz1 = lutil.getRelativ(center, getBlockFace(), -.55, .0);
kreutz1.add(0, 1.5, 0);
kreutz1.setYaw(lutil.FaceToYaw(b.getOppositeFace()) + 90);
Location kreutz2 = lutil.getRelativ(center, getBlockFace(), -.23, -1.27);
kreutz2.add(0, 1.6, 0);
kreutz2.setYaw(lutil.FaceToYaw(b.getOppositeFace()));
Location loc = center;
for(int i = 0; i<=2;i++){
Location l = lutil.getRelativ(loc, b, .0, -.44*i);
l.setYaw(lutil.FaceToYaw(b.getOppositeFace()) + 90);
ArmorStandPacket as = manager.createArmorStand(obj, l);
as.getInventory().setHelmet(new ItemStack(Material.COBBLESTONE));
as.setSmall(true);
as.setPose(lutil.degresstoRad(new EulerAngle(0, 0, 90)), BodyPart.HEAD);
aspList.add(as);
}
Double l = .3;
for(int i = 0;i<=2;i++){
setRow(center, .38, l, -.35,2,lutil.degresstoRad(new EulerAngle(90, 0, 0)), aspList);
if(i!=1){
l+=.4;
}else{
l+=.35;
}
}
ArmorStandPacket as = manager.createArmorStand(obj, kreutz1);
as.getInventory().setItemInHand(new ItemStack(Material.STICK));
as.setPose(new EulerAngle(1.38,.0,.0), BodyPart.RIGHT_ARM);
aspList.add(as);
as = manager.createArmorStand(obj, kreutz2);
as.getInventory().setItemInHand(new ItemStack(Material.STICK));
as.setPose(new EulerAngle(1.38,1.57,1.57), BodyPart.RIGHT_ARM);
aspList.add(as);
for(ArmorStandPacket asp : aspList){
asp.setGravity(false);
asp.setInvisible(true);
asp.setBasePlate(false);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
}
@EventHandler
private void onBreak(FurnitureBreakEvent e){
if(e.isCancelled()) return;
if(!e.canBuild(null)) return;
if(!e.getID().equals(obj)) return;
sign.setType(Material.AIR);
sign = null;
manager.remove(obj);
obj=null;
}
@EventHandler
private void onBlockRemove(BlockBreakEvent e)
{
if (sign==null) return;
if (e.getBlock() == null) return;
if (e.getBlock().getLocation() == null) return;
if (e.getBlock().getLocation().toVector().distance(signLoc.toVector())==0) return;
resetSign();
}
@EventHandler
private void onBlockPlaceEvent(BlockPlaceEvent e){
if (sign==null) return;
if (e.getBlock() == null) return;
if (e.getBlock().getLocation() == null) return;
if (e.getBlock().getLocation().toVector().distance(signLoc.toVector())!=1) return;
resetSign();
}
@EventHandler
private void onDrop(ItemSpawnEvent e){
if (sign==null) return;
if (e.getLocation() == null) return;
ItemStack is = e.getEntity().getItemStack();
if (is == null) return;
if (!is.getType().equals(Material.SIGN)) return;
if (e.getLocation().toVector().distance(signLoc.toVector())>=2) return;
e.getEntity().remove();
}
@EventHandler
private void onClick(FurnitureClickEvent e){
Player p = e.getPlayer();
if(e.isCancelled()) return;
if(!e.canBuild(null)) return;
if(!e.getID().equals(obj)) return;
ItemStack is = p.getItemInHand();
if (is == null) return;
if (!is.getType().equals(Material.WRITTEN_BOOK)) return;
readFromBook(is);
}
public void resetSign(){
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
sign = lutil.setSign(b, signLoc);
placetext();
}
});
}
public void readFromBook(ItemStack is){
BookMeta bm = (BookMeta) is.getItemMeta();
if(bm == null){return;}
String side = bm.getPage(1);
if(side==null){return;}
String lines[] = side.split("\\r?\\n");
Integer line = 0;
for(String s : lines){
if(s!=null && line<=3){
Integer i = 15;
if(s.length()>=15){i=15;}else{i=s.length();}
String a = s.substring(0, i);
if(a!=null){
a = ChatColor.translateAlternateColorCodes('&', a);
setText(line, a);
}
line++;
}
}
if(line!=3){
for(int i = line; i<=3; i++){
setText(i, "");
}
}
return;
}
public void placetext(){
Sign sign = (Sign) this.sign.getState();
Integer i = 0;
for(String s : lines){
if(i>3){break;}
sign.setLine(i, s);
i++;
}
sign.update(true, false);
}
public String[] getText(){
if(sign==null || !sign.getType().equals(Material.WALL_SIGN)){return null;}
Sign sign = (Sign) this.sign.getState();
return sign.getLines();
}
public void setText(Integer line, String text){
if(line==null || text == null){return;}
if(sign==null || !sign.getType().equals(Material.WALL_SIGN)){return;}
Sign sign = (Sign) this.sign.getState();
sign.setLine(line, text);
sign.update(true, false);
lines[line] = text;
}
public void setRow(Location loc, double x,double y, double z, int replay, EulerAngle angle, List<ArmorStandPacket> list){
Double d = .0;
for(int i = 0; i<=replay;i++){
Location loc1= lutil.getRelativ(loc, b, z, d-.825);
loc1.setYaw(lutil.FaceToYaw(b));
loc1.add(0, y,0);
ArmorStandPacket packet = manager.createArmorStand(obj, loc1);
packet.getInventory().setHelmet(new ItemStack(Material.STONE_PLATE));
packet.setSmall(true);
packet.setPose(angle, BodyPart.HEAD);
list.add(packet);
d+=x;
}
}
}

View File

@ -2,158 +2,135 @@ package de.Ste3et_C0st.Furniture.Objects.indoor;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
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.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
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.FurnitureCreateEvent;
import de.Ste3et_C0st.Furniture.Main.Permissions;
import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.Furniture.Main.Type.FurnitureType;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.LocationUtil;
import de.Ste3et_C0st.FurnitureLib.main.ArmorStandPacket;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureManager;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
public class chair implements Listener {
public class chair implements Listener{
List<UUID> idList = new ArrayList<UUID>();
Location loc = null;
BlockFace b = null;
World w = null;
private String id;
public String getID(){return this.id;}
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Integer id;
Plugin plugin;
public chair(Location location, Plugin plugin, String ID, List<UUID> uuids){
this.b = Utils.yawToFace(location.getYaw());
public chair(Location location, FurnitureLib lib, String name, Plugin plugin, ObjectID id){
this.lutil = main.getLocationUtil();
this.b = lutil.yawToFace(location.getYaw());
this.loc = location.getBlock().getLocation();
this.loc.setYaw(location.getYaw());
this.id = ID;
this.w = location.getWorld();
FurnitureCreateEvent event = new FurnitureCreateEvent(FurnitureType.CHAIR, this.id, location);
Bukkit.getPluginManager().callEvent(event);
if(!event.isCancelled()){
if(uuids==null){uuids = idList;}
spawn(uuids, location, plugin);
this.manager = lib.getFurnitureManager();
this.lib = lib;
this.plugin = plugin;
if(id!=null){
this.obj = id;
this.manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}else{
this.obj = new ObjectID(name, plugin.getName(), location);
}
spawn(location);
}
public void spawn(List<UUID> uuidList, Location location, Plugin plugin){
BlockFace b = Utils.yawToFace(loc.getYaw()).getOppositeFace();
Location center = Utils.getCenter(loc);
public void spawn(Location loc){
List<ArmorStandPacket> aspList = new ArrayList<ArmorStandPacket>();
BlockFace b = lutil.yawToFace(loc.getYaw()).getOppositeFace();
Location center = lutil.getCenter(loc);
Location sitz = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
Location feet1 = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
Location feet2 = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
Location feet3 = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
Location feet4 = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
Location lehne = main.getNew(center.add(0,-1.1,0), b, -.25, .0);
Location lehne = lutil.getRelativ(center.add(0,-1.1,0), b, -.25, .0);
feet1.add(-.25,-1.8,-.25);
feet2.add(.25,-1.8,-.25);
feet3.add(.25,-1.8,.25);
feet4.add(-.25,-1.8,.25);
sitz.add(0,-1.45,0);
sitz.setYaw(Utils.FaceToYaw(b));
lehne.setYaw(Utils.FaceToYaw(b));
sitz.setYaw(lutil.FaceToYaw(b));
lehne.setYaw(lutil.FaceToYaw(b));
Utils.setArmorStand(sitz, null, new ItemStack(Material.TRAP_DOOR), false,false,false,getID(),idList);
Utils.setArmorStand(lehne, new EulerAngle(1.57, .0, .0), new ItemStack(Material.TRAP_DOOR), false,false,false,getID(),idList);
Utils.setArmorStand(feet1, null, new ItemStack(Material.LEVER), false,false,false,getID(),idList);
Utils.setArmorStand(feet2, null, new ItemStack(Material.LEVER), false,false,false,getID(),idList);
Utils.setArmorStand(feet3, null, new ItemStack(Material.LEVER), false,false,false,getID(),idList);
Utils.setArmorStand(feet4, null, new ItemStack(Material.LEVER), false,false,false,getID(),idList);
Utils.setArmorStand(sitz.add(0,-.2,0), null, null, false,false,false,getID(),idList);
main.getInstance().getManager().chairList.add(this);
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
public void save(){
main.getInstance().mgr.saveStuhl(this);
}
public List<String> getList(){
return Utils.UUIDListToStringList(idList);
ArmorStandPacket as = manager.createArmorStand(obj, sitz);
as.getInventory().setHelmet(new ItemStack(Material.TRAP_DOOR));
aspList.add(as);
as = manager.createArmorStand(obj, lehne);
as.getInventory().setHelmet(new ItemStack(Material.TRAP_DOOR));
as.setPose(new EulerAngle(1.57, .0, .0), BodyPart.HEAD);
aspList.add(as);
as = manager.createArmorStand(obj, feet1);
as.getInventory().setHelmet(new ItemStack(Material.LEVER));
aspList.add(as);
as = manager.createArmorStand(obj, feet2);
as.getInventory().setHelmet(new ItemStack(Material.LEVER));
aspList.add(as);
as = manager.createArmorStand(obj, feet3);
as.getInventory().setHelmet(new ItemStack(Material.LEVER));
aspList.add(as);
as = manager.createArmorStand(obj, feet4);
as.getInventory().setHelmet(new ItemStack(Material.LEVER));
aspList.add(as);
as = manager.createArmorStand(obj, sitz.add(0,-.2,0));
id = as.getEntityId();
aspList.add(as);
for(ArmorStandPacket asp : aspList){
asp.setGravity(false);
asp.setInvisible(true);
asp.setBasePlate(false);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void onWaterFlow(BlockFromToEvent e){
Location locTo = e.getToBlock().getLocation();
if(loc!=null && locTo.equals(loc)){
e.setCancelled(true);
}
private void onBreak(FurnitureBreakEvent e){
if(e.isCancelled()){return;}
if(!e.canBuild(null)){return;}
if(!e.getID().equals(obj)){return;}
manager.remove(obj);
obj=null;
}
/*
@EventHandler
public void onHit(PlayerMoveEvent e){
Player p = e.getPlayer();
if(!p.isInsideVehicle() && loc!=null){
if(e.getTo().getBlock().getLocation().equals(loc.getBlock().getLocation())){
p.teleport(e.getFrom());
}
}
}
*/
public void delete(Boolean b, Boolean a){
if(b){
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("chair"));}
if(idList!=null&&!idList.isEmpty()){
for(UUID ids : idList){
if(ids==null){continue;}
ArmorStand as = Utils.getArmorStandAtID(w, ids);
if(as!=null){
if(a){getLocation().getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());}
as.remove();
main.getInstance().mgr.deleteFromConfig(getID(), "chair");
}
}
}
}
this.loc = null;
idList.clear();
main.getInstance().getManager().chairList.remove(this);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void damage(EntityDamageByEntityEvent e){
private void onClick(FurnitureClickEvent e){
if(e.isCancelled()){return;}
if(e.getDamager() instanceof Player == false){return;}
if(e.getEntity() instanceof ArmorStand == false){return;}
if(e.getEntity() == null){return;}
if(!idList.contains(e.getEntity().getUniqueId())){return;}
e.setCancelled(true);
if(!Permissions.check((Player) e.getDamager(), FurnitureType.TENT_2, "destroy.")){return;}
if(!main.getInstance().getCheckManager().canBuild((Player) e.getDamager(), getLocation())){return;}
if(((Player) e.getDamager()).getGameMode().equals(GameMode.CREATIVE)){delete(true, false);return;}
delete(true, true);
}
@EventHandler(priority = EventPriority.HIGHEST)
private void onInteract(PlayerInteractAtEntityEvent e){
if(e.isCancelled()){return;}
Player player = e.getPlayer();
if(e.getRightClicked() == null){return;}
if(e.getRightClicked() instanceof ArmorStand == false){return;}
if(idList==null||idList.isEmpty()){return;}
if(!idList.contains(e.getRightClicked().getUniqueId())){return;}
e.setCancelled(true);
Utils.getArmorStandAtID(w, idList.get(6)).setPassenger(player);
if(!e.getID().equals(obj)){return;}
ArmorStandPacket packet = manager.getArmorStandPacketByID(id);
if(packet.getPessanger()==null){
packet.setPessanger(e.getPlayer());
packet.update();
}
}
}

View File

@ -3,103 +3,120 @@ package de.Ste3et_C0st.Furniture.Objects.indoor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
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.FurnitureCreateEvent;
import de.Ste3et_C0st.Furniture.Main.Permissions;
import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.Furniture.Main.Type.FurnitureType;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.LocationUtil;
import de.Ste3et_C0st.FurnitureLib.main.ArmorStandPacket;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureManager;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
public class largeTable implements Listener {
public class largeTable implements Listener{
private List<UUID> idList = new ArrayList<UUID>();
private List<UUID> tellerIDS = new ArrayList<UUID>();
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;}
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Integer id;
Plugin plugin;
public largeTable(Location location, Plugin plugin, String ID, List<UUID> uuids){
this.loc = location;
this.b = Utils.yawToFace(location.getYaw());
this.id = ID;
public largeTable(Location location, FurnitureLib lib, String name, Plugin plugin, ObjectID id){
this.lutil = main.getLocationUtil();
this.b = lutil.yawToFace(location.getYaw());
this.loc = location.getBlock().getLocation();
this.loc.setYaw(location.getYaw());
this.w = location.getWorld();
FurnitureCreateEvent event = new FurnitureCreateEvent(FurnitureType.LARGE_TABLE, this.id, location);
Bukkit.getPluginManager().callEvent(event);
if(!event.isCancelled()){
if(uuids==null){uuids = idList;}
spawn(uuids, location, plugin);
this.manager = lib.getFurnitureManager();
this.lib = lib;
this.plugin = plugin;
if(id!=null){
this.obj = id;
this.manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}else{
this.obj = new ObjectID(name, plugin.getName(), location);
}
spawn(location);
}
public void spawn(List<UUID> uuidList, Location loc, Plugin plugin){
List<ArmorStand> armorlist = new ArrayList<ArmorStand>();
Location location = Utils.getCenter(loc.getBlock().getLocation());
float yaw = Utils.FaceToYaw(this.b);
location = main.getNew(location, this.b, 0.1, 0.28);
List<Integer> tellerIDs = new ArrayList<Integer>();
List<Integer> plattenIDs = new ArrayList<Integer>();
public void spawn(Location loc){
List<ArmorStandPacket> armorlist = new ArrayList<ArmorStandPacket>();
Location location = lutil.getCenter(loc.getBlock().getLocation());
float yaw = lutil.FaceToYaw(this.b);
location = lutil.getRelativ(location, this.b, 0.1, 0.28);
location.add(0,.2,0);
Double winkel = 1.57;
for(int x=1; x<=3;x++){
Location l = null;
l = main.getNew(location, this.b, 0.0, x*-.63);
l = lutil.getRelativ(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);
ArmorStand as = Utils.setArmorStand(l, new EulerAngle(winkel, 0, 0), iTemStack_1, false,false,false,getID(),idList);
ArmorStandPacket as = manager.createArmorStand(obj, l);
as.setPose(new EulerAngle(winkel, 0, 0), BodyPart.HEAD);
as.getInventory().setHelmet(iTemStack_1);
armorlist.add(as);
l = main.getNew(location, this.b, 0.63, x*-.63);
plattenIDs.add(as.getEntityId());
l = lutil.getRelativ(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,false,false,getID(),idList);
as = manager.createArmorStand(obj, l);
as.setPose(new EulerAngle(winkel, 0, 0), BodyPart.HEAD);
as.getInventory().setHelmet(iTemStack_1);
armorlist.add(as);
l = main.getNew(location, this.b, 1.26, x*-.63);
plattenIDs.add(as.getEntityId());
l = lutil.getRelativ(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,false,false,getID(),idList);
as = manager.createArmorStand(obj, l);
as.setPose(new EulerAngle(winkel, 0, 0), BodyPart.HEAD);
as.getInventory().setHelmet(iTemStack_1);
armorlist.add(as);
plattenIDs.add(as.getEntityId());
}
Location middle = Utils.getCenter(armorlist.get(0).getLocation());
Location mitteTisch = Utils.getCenter(armorlist.get(4).getLocation().getBlock().getLocation());
Location middle = lutil.getCenter(armorlist.get(0).getLocation());
Location mitteTisch = lutil.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);
Location feet1 = lutil.getRelativ(middle, this.b, -.2, .1);
Location feet2 = lutil.getRelativ(middle, this.b, -.2, -1.3);
Location feet3 = lutil.getRelativ(middle, this.b, 1.1, .1);
Location feet4 = lutil.getRelativ(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);
Location t1 = lutil.getRelativ(mitteTisch, this.b, -.95, .4).add(0,hight,0);
Location t2 = lutil.getRelativ(mitteTisch, this.b, -.4, -.92).add(0,hight,0);
Location t3 = lutil.getRelativ(mitteTisch, this.b, .92, -.36).add(0,hight,0);
Location t4 = lutil.getRelativ(mitteTisch, this.b, .4, .92).add(0,hight,0);
float yaw1 = yaw;
float yaw2 = yaw1-90;
@ -115,48 +132,77 @@ public class largeTable implements Listener {
feet2.setYaw(yaw);
feet3.setYaw(yaw);
feet4.setYaw(yaw);
Utils.setArmorStand(feet1, new EulerAngle(-1.75, 0, 0), new ItemStack(Material.BONE), true,false,false, getID(), idList);
Utils.setArmorStand(feet2, new EulerAngle(-1.75, 0, 0), new ItemStack(Material.BONE), true,false,false, getID(), idList);
Utils.setArmorStand(feet3, new EulerAngle(-1.75, 0, 0), new ItemStack(Material.BONE), true,false,false, getID(), idList);
Utils.setArmorStand(feet4, new EulerAngle(-1.75, 0, 0), new ItemStack(Material.BONE), true,false,false, getID(), idList);
ArmorStand as1 = Utils.setArmorStand(t1, new EulerAngle(0, 0, 0), null, true,false,false, getID(), idList);
ArmorStand as2 = Utils.setArmorStand(t2, new EulerAngle(0, 0, 0), null, true,false,false, getID(), idList);
ArmorStand as3 = Utils.setArmorStand(t3, new EulerAngle(0, 0, 0), null, true,false,false, getID(), idList);
ArmorStand as4 = Utils.setArmorStand(t4, new EulerAngle(0, 0, 0), null, true,false,false, getID(), idList);
tellerIDS.add(as1.getUniqueId());
tellerIDS.add(as2.getUniqueId());
tellerIDS.add(as3.getUniqueId());
tellerIDS.add(as4.getUniqueId());
ArmorStandPacket as = manager.createArmorStand(obj, feet1);
as.setPose(new EulerAngle(-1.75, 0, 0), BodyPart.RIGHT_ARM);
as.getInventory().setItemInHand(new ItemStack(Material.BONE));
armorlist.add(as);
plugin.getServer().getPluginManager().registerEvents(this, plugin);
main.getInstance().getManager().largeTableList.add(this);
}
public List<String> getList(){
return Utils.UUIDListToStringList(idList);
as = manager.createArmorStand(obj, feet2);
as.setPose(new EulerAngle(-1.75, 0, 0), BodyPart.RIGHT_ARM);
as.getInventory().setItemInHand(new ItemStack(Material.BONE));
armorlist.add(as);
as = manager.createArmorStand(obj, feet3);
as.setPose(new EulerAngle(-1.75, 0, 0), BodyPart.RIGHT_ARM);
as.getInventory().setItemInHand(new ItemStack(Material.BONE));
armorlist.add(as);
as = manager.createArmorStand(obj, feet4);
as.setPose(new EulerAngle(-1.75, 0, 0), BodyPart.RIGHT_ARM);
as.getInventory().setItemInHand(new ItemStack(Material.BONE));
armorlist.add(as);
as = manager.createArmorStand(obj, t1);
as.setName("#TELLER1#");
as.setPose(new EulerAngle(0, 0, 0), BodyPart.RIGHT_ARM);
armorlist.add(as);
tellerIDs.add(as.getEntityId());
as = manager.createArmorStand(obj, t2);
as.setName("#TELLER2#");
as.setPose(new EulerAngle(0, 0, 0), BodyPart.RIGHT_ARM);
armorlist.add(as);
tellerIDs.add(as.getEntityId());
as = manager.createArmorStand(obj, t3);
as.setName("#TELLER3#");
as.setPose(new EulerAngle(0, 0, 0), BodyPart.RIGHT_ARM);
armorlist.add(as);
tellerIDs.add(as.getEntityId());
as = manager.createArmorStand(obj, t4);
as.setName("#TELLER4#");
as.setPose(new EulerAngle(0, 0, 0), BodyPart.RIGHT_ARM);
armorlist.add(as);
tellerIDs.add(as.getEntityId());
for(ArmorStandPacket asp : armorlist){
asp.setGravity(false);
asp.setInvisible(true);
asp.setBasePlate(false);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
}
public void setTeller(HashMap<Integer, ItemStack> itemList){
int i = 0;
for(UUID id : tellerIDS){
ArmorStand as = Utils.getArmorStandAtID(w, id);
as.setItemInHand(itemList.get(i));
for(Integer id : tellerIDs){
ArmorStandPacket as = manager.getArmorStandPacketByID(id);
as.getInventory().setItemInHand(itemList.get(i));
i++;
}
}
public void setColor(HashMap<Integer, Short> durabilityList){
int i = 0;
for(UUID id: idList){
ArmorStand as = Utils.getArmorStandAtID(w, id);
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)&&as.getHelmet().getType().equals(Material.STAINED_GLASS_PANE)){
ItemStack is = as.getHelmet();
is.setDurability(durabilityList.get(i));
as.setHelmet(is);
i++;
}
for(Integer id : plattenIDs){
ArmorStandPacket as = manager.getArmorStandPacketByID(id);
ItemStack is = as.getInventory().getHelmet();
is.setDurability(durabilityList.get(i));
as.getInventory().setHelmet(is);
i++;
}
}
@ -164,138 +210,107 @@ public class largeTable implements Listener {
HashMap<Integer, Short> colorList = new HashMap<Integer, Short>();
Integer i = 0;
for(UUID id: idList){
for(Integer id : plattenIDs){
try{i=colorList.size();}catch(Exception e){return colorList;}
ArmorStand as = Utils.getArmorStandAtID(w, id);
if(as!=null){
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)&&as.getHelmet().getType().equals(Material.STAINED_GLASS_PANE)){
ItemStack is = as.getHelmet();
colorList.put(i, is.getDurability());
}
}
ArmorStandPacket as = manager.getArmorStandPacketByID(id);
colorList.put(i, as.getInventory().getHelmet().getDurability());
}
return colorList;
}
public void delete(boolean b, boolean a){
if(b){
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("largeTable"));}
for(UUID 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());
@EventHandler
private void onBreak(final FurnitureBreakEvent e){
if(e.isCancelled()){return;}
if(!e.canBuild(null)){return;}
if(!e.getID().equals(obj)){return;}
for(Integer id : tellerIDs){
ArmorStandPacket asp = manager.getArmorStandPacketByID(id);
if(asp!=null&&asp.getInventory().getItemInHand()!=null){
if(asp.getName().startsWith("#TELLER")){
ArmorStandPacket packet = asp;
e.getLocation().getWorld().dropItem(e.getLocation(), packet.getInventory().getItemInHand());
}
}
}
manager.remove(obj);
obj=null;
}
@EventHandler
private void onClick(FurnitureClickEvent e){
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
e.setCancelled(true);
final Player p = e.getPlayer();
if(p.getItemInHand().getType().equals(Material.INK_SACK)){
if(!e.canBuild(null)){return;}
ItemStack is = p.getItemInHand();
Integer Amount = is.getAmount();
List<ArmorStandPacket> asp = manager.getArmorStandPacketByObjectID(obj);
short color = lutil.getFromDey(is.getDurability());
for(ArmorStandPacket packet : asp){
if(packet.getInventory().getHelmet()!=null){
if(packet.getInventory().getHelmet().getType().equals(Material.STAINED_GLASS_PANE)){
if(Amount>0){
ItemStack is2 = packet.getInventory().getHelmet();
if(is2.getDurability()!=color){
if(p.getGameMode().equals(GameMode.SURVIVAL)){Amount=Amount-1;}
is2.setDurability(color);
packet.getInventory().setHelmet(is2);
}
}
}
}
}
for(UUID s : this.idList){
ArmorStand as = Utils.getArmorStandAtID(w, s);
if(as!=null && as.getHelmet()!= null && as.getHelmet().getType()!=null){
if(a){loc.getWorld().playEffect(loc, Effect.STEP_SOUND, as.getHelmet().getType());}
}
as.remove();
if(!p.getGameMode().equals(GameMode.CREATIVE)){
Integer o = Amount;
Integer i = p.getInventory().getHeldItemSlot();
ItemStack itemStack = p.getItemInHand();
itemStack.setAmount(o);
p.getInventory().setItem(i, itemStack);
p.updateInventory();
}
main.getInstance().mgr.deleteFromConfig(getID(), "largeTable");
manager.updateFurniture(obj);
return;
}else{
if(!e.canBuild(null)) return;
setTeller(e.getPlayer(), e.getPlayer().getInventory().getItemInHand());
}
this.tellerIDS.clear();
this.idList.clear();
main.getInstance().getManager().largeTableList.remove(this);
}
@EventHandler(priority = EventPriority.HIGHEST)
private void onInteract(PlayerInteractAtEntityEvent e){
if(e.isCancelled()){return;}
Player player = e.getPlayer();
if(e.getRightClicked() == null){return;}
if(e.getRightClicked() instanceof ArmorStand == false){return;}
if(idList==null||idList.isEmpty()){return;}
if(!this.idList.contains(e.getRightClicked().getUniqueId())){return;}
e.setCancelled(true);
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
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(UUID 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);
}
}
public void setTeller(Player player, ItemStack is){
BlockFace b = lutil.yawToFace(player.getLocation().getYaw());
ArmorStandPacket as = null;
if(tellerIDs == null || tellerIDs.isEmpty()){return;}
for(Integer id : this.tellerIDs){
if(id!=null){
ArmorStandPacket armorStand = manager.getArmorStandPacketByID(id);
if(armorStand!=null){
BlockFace b2 = lutil.yawToFace(armorStand.getLocation().getYaw());
if(b2.equals(b)){
as = armorStand;
break;
}
for(Entity entity : list){
if(list.indexOf(entity)>amount-1){break;}
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() || is.getType().equals(Material.AIR)){
BlockFace b = Utils.yawToFace(player.getLocation().getYaw());
ArmorStand as = null;
if(tellerIDS == null || tellerIDS.isEmpty()){return;}
for(UUID s : this.tellerIDS){
if(s!=null){
ArmorStand armorStand = Utils.getArmorStandAtID(w, s);
if(armorStand!=null){
BlockFace b2 = Utils.yawToFace(armorStand.getLocation().getYaw());
if(b2.equals(b)){
as = armorStand;
break;
}
}
}
}
if(as!=null&&as.getItemInHand()!= null && as.getItemInHand().equals(is)){return;}
if(as.getItemInHand()!=null&&!as.getItemInHand().getType().equals(Material.AIR)){as.getLocation().getWorld().dropItem(as.getLocation(), as.getItemInHand());}
as.setItemInHand(is);
if(!player.getGameMode().equals(GameMode.CREATIVE)){player.getInventory().remove(is);player.updateInventory();}
player.updateInventory();
}
main.getInstance().mgr.saveLargeTable(this);
}
}
public void save(){
main.getInstance().mgr.saveLargeTable(this);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void damage(EntityDamageByEntityEvent e){
if(e.isCancelled()){return;}
if(e.getDamager() instanceof Player == false){return;}
if(e.getEntity() instanceof ArmorStand == false){return;}
if(e.getEntity() == null){return;}
if(!idList.contains(e.getEntity().getUniqueId())){return;}
e.setCancelled(true);
if(!Permissions.check((Player) e.getDamager(), FurnitureType.LARGE_TABLE, "destroy.")){return;}
if(!main.getInstance().getCheckManager().canBuild((Player) e.getDamager(), getLocation())){return;}
if(((Player) e.getDamager()).getGameMode().equals(GameMode.CREATIVE)){delete(true, false);return;}
delete(true, true);
}
}
if(as!=null&&as.getInventory().getItemInHand()!= null && as.getInventory().getItemInHand().equals(is)){return;}
if(as.getInventory().getItemInHand()!=null&&!as.getInventory().getItemInHand().getType().equals(Material.AIR)){
ArmorStandPacket asp = as;
asp.getLocation().getWorld().dropItem(asp.getLocation(), asp.getInventory().getItemInHand());
}
as.getInventory().setItemInHand(is);
as.update();
}
public HashMap<Integer, ItemStack> getTeller(){
HashMap<Integer, ItemStack> teller = new HashMap<Integer, ItemStack>();
for(UUID s : tellerIDS){
for(Integer id : tellerIDs){
try{
ArmorStand as = Utils.getArmorStandAtID(w, s);
teller.put(teller.size(), as.getItemInHand());
ArmorStandPacket as = manager.getArmorStandPacketByID(id);
teller.put(teller.size(), as.getInventory().getItemInHand());
}catch(Exception e){
teller.put(teller.size(), new ItemStack(Material.AIR));
}

View File

@ -2,64 +2,75 @@ package de.Ste3et_C0st.Furniture.Objects.indoor;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
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 de.Ste3et_C0st.Furniture.Main.FurnitureCreateEvent;
import de.Ste3et_C0st.Furniture.Main.Permissions;
import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.Furniture.Main.Type.FurnitureType;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.LocationUtil;
import de.Ste3et_C0st.FurnitureLib.main.ArmorStandPacket;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureManager;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
public class latern implements Listener {
private List<UUID> idList = new ArrayList<UUID>();
private Block b;
private Location loc = null;
private BlockFace bFace = null;
private String id;
private World w;
public String getID(){return this.id;}
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.bFace;}
public class latern implements Listener{
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Integer id;
Plugin plugin;
public latern(Location location, Plugin plugin, String ID, List<UUID> uuids){
this.loc = location;
this.id = ID;
this.bFace = Utils.yawToFace(location.getYaw());
this.w = location.getWorld();
FurnitureCreateEvent event = new FurnitureCreateEvent(FurnitureType.LANTERN, this.id, location);
Bukkit.getPluginManager().callEvent(event);
if(!event.isCancelled()){
if(uuids==null){uuids = idList;}
spawn(uuids, location, plugin);
}
public latern(Location location, FurnitureLib lib, String name, Plugin plugin, ObjectID id){
this.lutil = main.getLocationUtil();
this.b = lutil.yawToFace(location.getYaw());
this.loc = location.getBlock().getLocation();
this.loc.setYaw(location.getYaw());
this.w = location.getWorld();
this.manager = lib.getFurnitureManager();
this.lib = lib;
this.plugin = plugin;
if(id!=null){
this.obj = id;
setBlock();
this.manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}else{
this.obj = new ObjectID(name, plugin.getName(), location);
}
spawn(location);
}
public void spawn(List<UUID> uuidList, Location location, Plugin plugin){
Location center = Utils.getCenter(getLocation());
b = center.getWorld().getBlockAt(center);
b.setType(Material.TORCH);
Block block;
private void setBlock(){
Location center = lutil.getCenter(loc);
block = center.getWorld().getBlockAt(center);
if(!block.getType().equals(Material.AIR)){return;}
block.setType(Material.TORCH);
}
public void spawn(Location loc){
List<ArmorStandPacket> aspList = new ArrayList<ArmorStandPacket>();
Location center = lutil.getCenter(loc);
setBlock();
Location obsidian = center;
Location l = new Location(center.getWorld(), center.getX(), center.getY() -1.43, center.getZ());
obsidian.add(0D, -2.2, 0D);
@ -68,20 +79,41 @@ public class latern implements Listener {
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);
Utils.setArmorStand(obsidian, null, new ItemStack(Material.OBSIDIAN), false,false,false,getID(),idList);
Utils.setArmorStand(l.add(0,0,0), null, new ItemStack(Material.WOOD_PLATE), false,false,false,getID(), idList);
ArmorStandPacket asp = manager.createArmorStand(obj, obsidian);
asp.getInventory().setHelmet(new ItemStack(Material.OBSIDIAN));
aspList.add(asp);
Utils.setArmorStand(left_down, null, new ItemStack(Material.LEVER), false,false,false,getID(), idList);
Utils.setArmorStand(left_upper, null, new ItemStack(Material.LEVER), false,false,false,getID(), idList);
Utils.setArmorStand(right_upper, null, new ItemStack(Material.LEVER), false,false,false,getID(), idList);
Utils.setArmorStand(right_down, null, new ItemStack(Material.LEVER), false,false,false,getID(), idList);
Bukkit.getServer().getPluginManager().registerEvents(this, plugin);
main.getInstance().getManager().lanternList.add(this);
asp = manager.createArmorStand(obj, l.add(0,0,0));
asp.getInventory().setHelmet(new ItemStack(Material.WOOD_PLATE));
aspList.add(asp);
asp = manager.createArmorStand(obj, left_down);
asp.getInventory().setHelmet(new ItemStack(Material.LEVER));
aspList.add(asp);
asp = manager.createArmorStand(obj, left_upper);
asp.getInventory().setHelmet(new ItemStack(Material.LEVER));
aspList.add(asp);
asp = manager.createArmorStand(obj, right_upper);
asp.getInventory().setHelmet(new ItemStack(Material.LEVER));
aspList.add(asp);
asp = manager.createArmorStand(obj, right_down);
asp.getInventory().setHelmet(new ItemStack(Material.LEVER));
aspList.add(asp);
for(ArmorStandPacket packet : aspList){
packet.setBasePlate(false);
packet.setGravity(false);
packet.setInvisible(true);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
}
public List<String> getList(){
return Utils.UUIDListToStringList(idList);
}
@EventHandler
public void onWaterFlow(BlockFromToEvent e){
@ -91,80 +123,40 @@ public class latern implements Listener {
}
}
public void delete(Boolean b, boolean a){
if(b){
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("lantern"));}
for(UUID s : idList){
ArmorStand as = Utils.getArmorStandAtID(w,s);
if(as!=null){
as.getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
as.remove();
}
}
main.getInstance().mgr.deleteFromConfig(getID(), "lantern");
}
if(this.b!=null&&!this.b.getType().equals(Material.AIR)){this.b.setType(Material.AIR);}
this.loc = null;
this.b = null;
this.idList.clear();
main.getInstance().getManager().lanternList.remove(this);
@EventHandler
private void onBreak(FurnitureBreakEvent e){
if(e.isCancelled()) return;
if(block==null) return;
if(!e.getID().equals(obj)) return;
if(!e.canBuild(null)) return;
block.setType(Material.AIR);
manager.remove(obj);
}
@EventHandler
public void onBlockBreak(BlockBreakEvent e){
if(e.getBlock()!=null&&b!=null&&e.getBlock().equals(b)){
e.setCancelled(true);
delete(true, true);
private void onInteract(FurnitureClickEvent e){
if(e.isCancelled()) return;
if(block==null) return;
if(!e.getID().equals(obj)) return;
if(!e.canBuild(null)) return;
Player p = e.getPlayer();
ItemStack is = p.getItemInHand();
if(is.getType().equals(Material.FLINT_AND_STEEL)){
setLight(true);
}else if(is.getType().equals(Material.WATER_BUCKET)){
setLight(false);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
private void onInteract(PlayerInteractAtEntityEvent e){
if(e.isCancelled()){return;}
Player player = e.getPlayer();
if(e.getRightClicked() == null){return;}
if(e.getRightClicked() instanceof ArmorStand == false){ return;}
if(idList==null||idList.isEmpty()){return;}
if(!this.idList.contains(e.getRightClicked().getUniqueId())){return;}
e.setCancelled(true);
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
ItemStack is = player.getItemInHand();
if(is!=null){
if(is.getType().equals(Material.FLINT_AND_STEEL)){
setLight(true);
}else if(is.getType().equals(Material.WATER_BUCKET)){
setLight(false);
}
main.getInstance().mgr.saveLatern(this);
}
}
public void save(){
main.getInstance().mgr.saveLatern(this);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void damage(EntityDamageByEntityEvent e){
if(e.isCancelled()){return;}
if(e.getDamager() instanceof Player == false){return;}
if(e.getEntity() instanceof ArmorStand == false){return;}
if(e.getEntity() == null){return;}
if(e.getEntity().getUniqueId() == null){return;}
if(!idList.contains(e.getEntity().getUniqueId())){return;}
e.setCancelled(true);
if(!Permissions.check((Player) e.getDamager(), FurnitureType.LANTERN, "destroy.")){return;}
if(!main.getInstance().getCheckManager().canBuild((Player) e.getDamager(), getLocation())){return;}
if(((Player) e.getDamager()).getGameMode().equals(GameMode.CREATIVE)){delete(true, false);return;}
delete(true, true);
}
public void setLight(boolean bool){
if(bool){b.setType(Material.TORCH);}
else{b.setType(Material.REDSTONE_TORCH_OFF);}
public void setLight(final boolean bool){
if(bool){block.setType(Material.TORCH);}
else{block.setType(Material.REDSTONE_TORCH_OFF);}
}
public boolean getLight(){
if(b==null||b.getType().equals(Material.AIR)||b.getType().equals(Material.TORCH)){
if(block==null||block.getType().equals(Material.AIR)||block.getType().equals(Material.TORCH)){
return true;
}
return false;

View File

@ -1,278 +1,226 @@
package de.Ste3et_C0st.Furniture.Objects.indoor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
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.FurnitureCreateEvent;
import de.Ste3et_C0st.Furniture.Main.Permissions;
import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.Furniture.Main.Type.FurnitureType;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.LocationUtil;
import de.Ste3et_C0st.FurnitureLib.main.ArmorStandPacket;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureManager;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
public class sofa implements Listener {
private List<UUID> idList = new ArrayList<UUID>();
private List<UUID> sitzList = new ArrayList<UUID>();
private ItemStack is;
private Double place;
private BlockFace b;
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 location, Plugin plugin, String ID, List<UUID> uuids){
this.w = location.getWorld();
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Integer id;
Plugin plugin;
public sofa(Location location, FurnitureLib lib, String name, Plugin plugin, ObjectID id){
this.lutil = main.getLocationUtil();
this.b = lutil.yawToFace(location.getYaw());
this.loc = location.getBlock().getLocation();
this.loc.setYaw(location.getYaw());
this.place = 0.2;
this.id = ID;
this.b = Utils.yawToFace(location.getYaw());
FurnitureCreateEvent event = new FurnitureCreateEvent(FurnitureType.SOFA, this.id, location);
Bukkit.getPluginManager().callEvent(event);
if(!event.isCancelled()){
if(uuids==null){uuids = idList;}
spawn(uuids, location, plugin);
}
this.w = location.getWorld();
this.manager = lib.getFurnitureManager();
this.lib = lib;
this.plugin = plugin;
if(id!=null){
this.obj = id;
this.manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}else{
this.obj = new ObjectID(name, plugin.getName(), location);
}
place = .3;
spawn(location);
}
public void spawn(List<UUID> uuidList, Location location, Plugin plugin){
List<Entity> sitz = new ArrayList<Entity>();
ItemStack is;
Double place;
public void spawn(Location loc){
List<ArmorStandPacket> aspList = new ArrayList<ArmorStandPacket>();
List<ArmorStandPacket> sitz = new ArrayList<ArmorStandPacket>();
Integer lengt = 3;
is = new ItemStack(Material.CARPET);
is.setDurability(color);
BlockFace b = Utils.yawToFace(location.getYaw()).getOppositeFace();
BlockFace b = lutil.yawToFace(loc.getYaw()).getOppositeFace();
Integer x = (int) location.getX();
Integer y = (int) location.getY();
Integer z = (int) location.getZ();
location.setX(x);
location.setY(y);
location.setZ(z);
Integer x = (int) loc.getX();
Integer y = (int) loc.getY();
Integer z = (int) loc.getZ();
loc.setX(x);
loc.setY(y);
loc.setZ(z);
if(b.equals(BlockFace.WEST)){location = main.getNew(location, b, .0, -1.0);}
if(b.equals(BlockFace.SOUTH)){location = main.getNew(location, b, -1.0, -1.0);}
if(b.equals(BlockFace.EAST)){location = main.getNew(location, b, -1.0, .0);}
Location looking = new Location(location.getWorld(), location.getBlockX(), location.getBlockY() -1.4 , location.getBlockZ());
Location feet1 = main.getNew(looking, b, place, .2D);
Location feet2 = main.getNew(looking, b, place, lengt.doubleValue()-.2D);
Location feet3 = main.getNew(looking, b, place + .5, .2D);
Location feet4 = main.getNew(looking, b, place + .5, lengt.doubleValue()-.2D);
if(b.equals(BlockFace.WEST)){loc = lutil.getRelativ(loc, b, .0, -1.0);}
if(b.equals(BlockFace.SOUTH)){loc = lutil.getRelativ(loc, b, -1.0, -1.0);}
if(b.equals(BlockFace.EAST)){loc = lutil.getRelativ(loc, b, -1.0, .0);}
Location looking = new Location(loc.getWorld(), loc.getBlockX(), loc.getBlockY() -1.4 , loc.getBlockZ());
Location feet1 = lutil.getRelativ(looking, b, place, .2D);
Location feet2 = lutil.getRelativ(looking, b, place, lengt.doubleValue()-.2D);
Location feet3 = lutil.getRelativ(looking, b, place + .5, .2D);
Location feet4 = lutil.getRelativ(looking, b, place + .5, lengt.doubleValue()-.2D);
Utils.setArmorStand(feet1, null, new ItemStack(Material.LEVER), false,false,false,getID(),idList);
Utils.setArmorStand(feet2, null, new ItemStack(Material.LEVER), false,false,false,getID(),idList);
Utils.setArmorStand(feet3, null, new ItemStack(Material.LEVER), false,false,false,getID(),idList);
Utils.setArmorStand(feet4, null, new ItemStack(Material.LEVER), false,false,false,getID(),idList);
Location carpetHight = new Location(looking.getWorld(), location.getBlockX(), location.getBlockY() -1 , location.getBlockZ());
carpetHight.setYaw(Utils.FaceToYaw(b));
carpetHight = main.getNew(carpetHight, b, .25,.3);
ArmorStandPacket asp = manager.createArmorStand(obj, feet1);
asp.getInventory().setHelmet(new ItemStack(Material.LEVER));
aspList.add(asp);
asp = manager.createArmorStand(obj, feet2);
asp.getInventory().setHelmet(new ItemStack(Material.LEVER));
aspList.add(asp);
asp = manager.createArmorStand(obj, feet3);
asp.getInventory().setHelmet(new ItemStack(Material.LEVER));
aspList.add(asp);
asp = manager.createArmorStand(obj, feet4);
asp.getInventory().setHelmet(new ItemStack(Material.LEVER));
aspList.add(asp);
Location carpetHight = new Location(looking.getWorld(), loc.getBlockX(), loc.getBlockY() -1 , loc.getBlockZ());
carpetHight.setYaw(lutil.FaceToYaw(b));
carpetHight = lutil.getRelativ(carpetHight, b, .25,.3);
Double d = .02;
float facing = Utils.FaceToYaw(b);
float facing = lutil.FaceToYaw(b);
for(Double i = .0; i<=lengt; i+=0.65){
Location carpet = main.getNew(carpetHight, b, place,(double) d);
Location carpet = lutil.getRelativ(carpetHight, b, place,(double) d);
carpet.setYaw(facing);
ArmorStand as = null;
as = Utils.setArmorStand(carpet, null, is, false,false,false,getID(),idList);
sitz.add(as);
//OBERER TEIL
Location loc = main.getNew(carpetHight, b, place-.25,(double) d);
loc.setYaw(facing);
Utils.setArmorStand(loc, new EulerAngle(1.57, .0, .0), is, false,false,false,getID(),idList);
asp = manager.createArmorStand(obj, carpet);
asp.getInventory().setHelmet(is);
aspList.add(asp);
sitz.add(asp);
Location location = lutil.getRelativ(carpetHight, b, place-.25,(double) d);
location.setYaw(facing);
asp = manager.createArmorStand(obj, location);
asp.setPose(new EulerAngle(1.57, .0, .0), BodyPart.HEAD);
asp.getInventory().setHelmet(is);
aspList.add(asp);
if(d<=0D){d = 0.00;}
d+=.58;
}
Float yaw1= facing;
Float yaw2= facing;
Location last = main.getNew(sitz.get(sitz.size()-1).getLocation(), b, 0D, 0.26D);
Location last = lutil.getRelativ(sitz.get(sitz.size()-1).getLocation(), b, 0D, 0.26D);
last.setYaw(yaw1+90);
Location first = main.getNew(new Location(location.getWorld(), location.getX(), last.getY(), location.getZ()), b, place+.25, 0.07D);
Location first = lutil.getRelativ(new Location(loc.getWorld(), loc.getX(), last.getY(), loc.getZ()), b, place+.25, 0.07D);
first.setYaw(yaw2-90);
Utils.setArmorStand(first.add(0,-.05,0), new EulerAngle(1.57, .0, .0), is, false,false,false,getID(),idList);
Utils.setArmorStand(last.add(0,-.05,0), new EulerAngle(1.57, .0, .0), is, false,false,false,getID(),idList);
asp = manager.createArmorStand(obj, first.add(0,-.05,0));
asp.getInventory().setHelmet(is);
asp.setPose(new EulerAngle(1.57, .0, .0), BodyPart.HEAD);
aspList.add(asp);
asp = manager.createArmorStand(obj, last.add(0,-.05,0));
asp.getInventory().setHelmet(is);
asp.setPose(new EulerAngle(1.57, .0, .0), BodyPart.HEAD);
aspList.add(asp);
Location start = lutil.getRelativ(looking, b, .45, .55);
Location start = main.getNew(looking, b, .45, .55);
for(int i = 0; i<=2;i++){
Location loc = main.getNew(start, b, 0D, i*.95D);
loc.setYaw(Utils.FaceToYaw(b));
loc.add(0,.2,0);
ArmorStand as = Utils.setArmorStand(loc, null, null, false, false, false, getID(), idList);
sitzList.add(as.getUniqueId());
Location location = lutil.getRelativ(start, b, place, i*.95D);
location.setYaw(lutil.FaceToYaw(b));
location.add(0,.2,0);
asp = manager.createArmorStand(obj, location);
asp.setName("#SITZ#");
aspList.add(asp);
}
plugin.getServer().getPluginManager().registerEvents(this, plugin);
main.getInstance().getManager().sofaList.add(this);
for(ArmorStandPacket asps : aspList){
asps.setInvisible(true);
asps.setGravity(false);
asps.setBasePlate(false);
}
}
public List<String> getList(){
return Utils.UUIDListToStringList(idList);
}
public void save(){
main.getInstance().mgr.saveSofa(this);
}
public void setColor(HashMap<Integer, Short> durabilityList){
int i = 0;
for(UUID id: idList){
ArmorStand as = Utils.getArmorStandAtID(w, id);
if(as!=null){
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)&&as.getHelmet().getType().equals(Material.CARPET)){
ItemStack is = as.getHelmet();
is.setDurability(durabilityList.get(i));
as.setHelmet(is);
i++;
}
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
}
}
public HashMap<Integer, Short> getColor(){
HashMap<Integer, Short> colorList = new HashMap<Integer, Short>();
Integer i = 0;
for(UUID id: idList){
try{i=colorList.size();}catch(Exception e){return colorList;}
ArmorStand as = Utils.getArmorStandAtID(w, id);
if(as!=null){
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)&&as.getHelmet().getType().equals(Material.CARPET)){
ItemStack is = as.getHelmet();
colorList.put(i, is.getDurability());
}
}
}
return colorList;
}
public void delete(Boolean b, boolean a){
if(b){
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("sofa"));}
for(UUID s : idList){
ArmorStand as = Utils.getArmorStandAtID(this.w, s);
if(as!=null){
if(a){as.getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());}
as.remove();
main.getInstance().mgr.deleteFromConfig(getID(), "sofa");
}
}
}
idList.clear();
main.getInstance().getManager().sofaList.remove(this);
}
@EventHandler(priority = EventPriority.HIGHEST)
private void onInteract(PlayerInteractAtEntityEvent e){
@EventHandler
private void onClick(FurnitureClickEvent e){
if(e.isCancelled()){return;}
Player player = e.getPlayer();
if(e.getRightClicked()==null){return;}
if(e.getRightClicked() instanceof ArmorStand == false){return;}
if(idList==null||idList.isEmpty()){return;}
if(!e.getID().equals(obj)){return;}
e.setCancelled(true);
ItemStack is = player.getItemInHand();
if(is!=null){
if(is.getType().equals(Material.INK_SACK)){
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
Short druability = is.getDurability();
Integer amount = is.getAmount();
if(amount>idList.size() || player.getGameMode().equals(GameMode.CREATIVE)){amount=idList.size();}
List<Entity> list = new ArrayList<Entity>();
for(UUID s : idList){
ArmorStand as = Utils.getArmorStandAtID(w, s);
if(as.getHelmet().getType().equals(Material.CARPET)){
ItemStack item = as.getHelmet();
if(item.getDurability() != main.getFromDey(druability)){
list.add(as);
}
}
}
for(Entity entity : list){
if(entity instanceof ArmorStand){
if(list.indexOf(entity)>amount-1){break;}
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();
}
main.getInstance().mgr.saveSofa(this);
return;
}
}
Integer intSitz = Utils.randInt(0, 2);
for(UUID s : sitzList){
if(s==null){return;}
ArmorStand as = Utils.getArmorStandAtID(w, s);
if(as==null){return;}
if(sitzList.indexOf(s) == intSitz){
if(as.getPassenger()==null){
as.setPassenger(player);
break;
final Player p = e.getPlayer();
if(p.getItemInHand().getType().equals(Material.INK_SACK)){
Boolean canBuild = lib.canBuild(p, e.getLocation(), Material.CARPET);
Material m = Material.CARPET;
color(p, canBuild, m);
}else{
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
if(packet.getName().equalsIgnoreCase("#SITZ#") && packet.getPessanger() == null){
packet.setPessanger(p);
packet.update();
return;
}
}
}
}
public boolean checkIfEmpty(){
for(UUID id : idList){
ArmorStand armorStand = Utils.getArmorStandAtID(w, id);
if(armorStand!=null){
if(armorStand.getHeadPose().equals(new EulerAngle(1.57, .0, .0)) && armorStand.getHelmet().getType().equals(Material.CARPET)){
if(armorStand.getPassenger() != null && !armorStand.getPassenger().isEmpty()){
return false;
private void color(Player p, boolean canBuild, Material m){
if(!canBuild){return;}
ItemStack is = p.getItemInHand();
Integer Amount = is.getAmount();
List<ArmorStandPacket> asp = manager.getArmorStandPacketByObjectID(obj);
short color = lutil.getFromDey(is.getDurability());
for(ArmorStandPacket packet : asp){
if(packet.getInventory().getHelmet()!=null&&packet.getInventory().getHelmet().getType().equals(m)){
if(Amount>0||p.getGameMode().equals(GameMode.CREATIVE)){
ItemStack is2 = packet.getInventory().getHelmet();
if(is2.getDurability() != color){
is2.setDurability(color);
packet.getInventory().setHelmet(is2);
if(!p.getGameMode().equals(GameMode.CREATIVE)){Amount--;}
}
}
}
}
return true;
if(!p.getGameMode().equals(GameMode.CREATIVE)){
Integer i = p.getInventory().getHeldItemSlot();
ItemStack item = p.getItemInHand();
item.setAmount(Amount);
p.getInventory().setItem(i, item);
p.updateInventory();
}
manager.updateFurniture(obj);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void damage(EntityDamageByEntityEvent e){
@EventHandler
private void onBreak(FurnitureBreakEvent e){
if(e.isCancelled()){return;}
if(e.getDamager() instanceof Player == false){return;}
if(e.getEntity() instanceof ArmorStand == false){return;}
if(e.getEntity() == null){return;}
if(e.getEntity().getUniqueId() == null){return;}
if(!idList.contains(e.getEntity().getUniqueId())){return;}
if(!e.canBuild(null)){return;}
if(!e.getID().equals(obj)){return;}
e.setCancelled(true);
if(!Permissions.check((Player) e.getDamager(), FurnitureType.TENT_2, "destroy.")){return;}
if(!main.getInstance().getCheckManager().canBuild((Player) e.getDamager(), getLocation())){return;}
if(((Player) e.getDamager()).getGameMode().equals(GameMode.CREATIVE)){delete(true, false);return;}
delete(true, true);
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
if(packet.getPessanger()!=null){
packet.unleash();
packet.update();
}
}
manager.remove(obj);
obj=null;
}
}

View File

@ -2,149 +2,143 @@ package de.Ste3et_C0st.Furniture.Objects.indoor;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
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.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.FurnitureCreateEvent;
import de.Ste3et_C0st.Furniture.Main.Permissions;
import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.Furniture.Main.Type.FurnitureType;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.LocationUtil;
import de.Ste3et_C0st.FurnitureLib.main.ArmorStandPacket;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureManager;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
public class table implements Listener {
private List<UUID> idList = new ArrayList<UUID>();
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 ItemStack getItemStack(){return this.is;}
public BlockFace getBlockFace(){return this.b;}
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Integer id;
Plugin plugin;
public table(Location location, Plugin plugin, String ID, List<UUID> uuids){
public table(Location location, FurnitureLib lib, String name, Plugin plugin, ObjectID id){
this.lutil = main.getLocationUtil();
this.b = lutil.yawToFace(location.getYaw());
this.loc = location.getBlock().getLocation();
this.loc.setYaw(location.getYaw());
this.id = ID;
this.b = Utils.yawToFace(location.getYaw());
this.w = location.getWorld();
FurnitureCreateEvent event = new FurnitureCreateEvent(FurnitureType.TABLE, this.id, location);
Bukkit.getPluginManager().callEvent(event);
if(!event.isCancelled()){
if(uuids==null){uuids = idList;}
spawn(uuids, location, plugin);
this.manager = lib.getFurnitureManager();
this.lib = lib;
this.plugin = plugin;
if(id!=null){
this.obj = id;
this.manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}else{
this.obj = new ObjectID(name, plugin.getName(), location);
}
spawn(location);
}
public void spawn(List<UUID> uuidList, Location location, Plugin plugin){
Location middle1 = Utils.getCenter(getLocation());
Location middle2 = Utils.getCenter(getLocation());
Utils.setArmorStand(middle1.add(0,-2.1,0),new EulerAngle(0, 0, 0) , new ItemStack(Material.WOOD_PLATE), false,false,false,getID(),idList);
Utils.setArmorStand(middle2.add(0,-1.05,0),new EulerAngle(0, 0, 0) , new ItemStack(Material.TRAP_DOOR), false,false,false,getID(),idList);
Location l = getLocation();
public void spawn(Location loc){
List<ArmorStandPacket> packetL = new ArrayList<ArmorStandPacket>();
Location middle1 = lutil.getCenter(loc);
Location middle2 = lutil.getCenter(loc);
Location l = loc;
l.setYaw(0);
ArmorStand as = Utils.setArmorStand(l.add(.9,0.15,0.3),new EulerAngle(0,.0,.0), is, true,false,false,getID(),idList);
Utils.setArmorStand(l.add(0,-.65,.68),new EulerAngle(1.38,.0,.0), new ItemStack(Material.STICK), true,false,false,getID(),idList);
this.armor = as;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
main.getInstance().getManager().tableList.add(this);
ArmorStandPacket asp = manager.createArmorStand(obj, middle1.add(0, -2.1, 0));
asp.getInventory().setHelmet(new ItemStack(Material.WOOD_PLATE));
packetL.add(asp);
asp = manager.createArmorStand(obj, middle2.add(0,-1.05,0));
asp.getInventory().setHelmet(new ItemStack(Material.TRAP_DOOR));
packetL.add(asp);
asp = manager.createArmorStand(obj, l.add(.9,0.15,0.3));
asp.setName("#ITEM#");
asp.setPose(new EulerAngle(.0,.0,.0), BodyPart.RIGHT_ARM);
packetL.add(asp);
asp = manager.createArmorStand(obj, l.add(0,-.65,.68));
asp.getInventory().setItemInHand(new ItemStack(Material.STICK));
asp.setPose(new EulerAngle(1.38,.0,.0), BodyPart.RIGHT_ARM);
packetL.add(asp);
for(ArmorStandPacket packet : packetL){
packet.setInvisible(true);
packet.setGravity(false);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
}
@EventHandler(priority = EventPriority.HIGHEST)
private void onInteract(PlayerInteractAtEntityEvent e){
@EventHandler
private void onBreak(FurnitureBreakEvent e){
if(e.isCancelled()){return;}
Player player = e.getPlayer();
if(e.getRightClicked() instanceof ArmorStand == false){return;}
if(idList==null||idList.isEmpty()){return;}
if(!idList.contains(e.getRightClicked().getUniqueId())){return;}
if(!e.canBuild(null)){return;}
if(!e.getID().equals(obj)){return;}
e.setCancelled(true);
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
ItemStack is = player.getItemInHand();
if(is!=null&&!is.getType().isBlock()||is.getType().equals(Material.AIR)){
if(armor!=null){
ArmorStand as = Utils.getArmorStandAtID(w,idList.get(2));
if(as!=null&&as.getItemInHand()!= null && as.getItemInHand().equals(is)){return;}
if(as!=null&&armor.getItemInHand()!=null&&!armor.getItemInHand().getType().equals(Material.AIR)){as.getLocation().getWorld().dropItem(as.getLocation(), as.getItemInHand());}
as.setItemInHand(is);
this.is = is;
if(!player.getGameMode().equals(GameMode.CREATIVE)){player.getInventory().remove(is);player.updateInventory();}
main.getInstance().mgr.saveTable(this);
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
if(packet.getName().equalsIgnoreCase("#ITEM#")){
if(packet.getInventory().getItemInHand()!=null&&!packet.getInventory().getItemInHand().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getItemInHand();
w.dropItem(loc, is);
}
}
}
manager.remove(obj);
obj=null;
}
public List<String> getList(){
return Utils.UUIDListToStringList(idList);
}
public void delete(Boolean b, boolean a){
if(b){
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("table"));}
if(is!=null && !is.getType().equals(Material.AIR)){
ArmorStand as = Utils.getArmorStandAtID(w,idList.get(2));
if(as!=null){
as.getLocation().getWorld().dropItem(as.getLocation(), as.getItemInHand());
this.is = null;
}
}
for(UUID s : idList){
ArmorStand as = Utils.getArmorStandAtID(w,s);
if(as!=null){
if(a){loc.getWorld().playEffect(loc, Effect.STEP_SOUND, as.getHelmet().getType());}
as.remove();
}
}
main.getInstance().mgr.deleteFromConfig(getID(), "table");
}
this.loc = null;
this.idList.clear();
main.getInstance().getManager().tableList.remove(this);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void damage(EntityDamageByEntityEvent e){
@EventHandler
private void onClick(FurnitureClickEvent e){
if(e.isCancelled()){return;}
if(e.getDamager() instanceof Player == false){return;}
if(e.getEntity() instanceof ArmorStand == false){return;}
if(e.getEntity() == null){return;}
if(!idList.contains(e.getEntity().getUniqueId())){return;}
if(!e.getID().equals(obj)){return;}
if(!e.canBuild(null)){return;}
e.setCancelled(true);
if(!Permissions.check((Player) e.getDamager(), FurnitureType.TABLE, "destroy.")){return;}
if(!main.getInstance().getCheckManager().canBuild((Player) e.getDamager(), getLocation())){return;}
if(((Player) e.getDamager()).getGameMode().equals(GameMode.CREATIVE)){delete(true, false);return;}
delete(true, true);
}
public void setItem(ItemStack itemS) {
is = itemS;
ArmorStand as = Utils.getArmorStandAtID(w,idList.get(2));
as.setItemInHand(itemS);
}
public void save() {
main.getInstance().mgr.saveTable(this);
Player p = e.getPlayer();
if(p.getItemInHand().getType().isBlock()&&!p.getItemInHand().getType().equals(Material.AIR)){return;}
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
if(packet.getName().equalsIgnoreCase("#ITEM#")){
ItemStack Itemstack = p.getItemInHand().clone();
Itemstack.setAmount(1);
if(packet.getInventory().getItemInHand()!=null&&!packet.getInventory().getItemInHand().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getItemInHand();
w.dropItem(loc, is);
}
if(!p.getGameMode().equals(GameMode.CREATIVE)){
Integer i = p.getInventory().getHeldItemSlot();
ItemStack is = p.getItemInHand();
is.setAmount(is.getAmount()-1);
p.getInventory().setItem(i, is);
p.updateInventory();
}
packet.getInventory().setItemInHand(Itemstack);
packet.update();
return;
}
}
}
}

View File

@ -1,191 +1,151 @@
package de.Ste3et_C0st.Furniture.Objects.outdoor;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import de.Ste3et_C0st.Furniture.Main.FurnitureCreateEvent;
import de.Ste3et_C0st.Furniture.Main.Permissions;
import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.Furniture.Main.Manager.ILightAPI;
import de.Ste3et_C0st.Furniture.Main.Type.FurnitureType;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.LocationUtil;
import de.Ste3et_C0st.FurnitureLib.main.ArmorStandPacket;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureManager;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
public class barrels implements Listener {
private Location loc;
private BlockFace b;
private ArmorStand as;
private Block block;
private String id;
private List<UUID> idList = new ArrayList<UUID>();
public String getID(){return this.id;}
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
public barrels(Location location, Plugin plugin, String ID, List<UUID> uuids){
this.id = ID;
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Integer id;
Block block;
Plugin plugin;
public barrels(Location location, FurnitureLib lib, String name, Plugin plugin, ObjectID id){
this.lutil = main.getLocationUtil();
this.b = lutil.yawToFace(location.getYaw());
this.loc = location.getBlock().getLocation();
this.loc.setYaw(location.getYaw());
this.b = Utils.yawToFace(location.getYaw());
FurnitureCreateEvent event = new FurnitureCreateEvent(FurnitureType.BARRELS, this.id, location);
Bukkit.getPluginManager().callEvent(event);
if(!event.isCancelled()){
if(uuids==null){uuids = idList;}
spawn(uuids, location, plugin);
this.w = location.getWorld();
this.manager = lib.getFurnitureManager();
this.lib = lib;
this.plugin = plugin;
if(id!=null){
this.obj = id;
this.block = loc.getBlock();
this.block.setType(Material.CAULDRON);
this.manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}else{
this.obj = new ObjectID(name, plugin.getName(), location);
}
spawn(location);
}
public void spawn(List<UUID> uuidList, Location location, Plugin plugin){
this.block = location.getBlock();
public void spawn(Location loc){
this.block = loc.getBlock();
this.block.setType(Material.CAULDRON);
this.as = Utils.setArmorStand(Utils.getCenter(loc).add(0,-1.5,0), null, null, false, false, false, this.id, idList);
main.getInstance().getManager().barrelList.add(this);
plugin.getServer().getPluginManager().registerEvents(this, plugin);
ArmorStandPacket packet = manager.createArmorStand(obj, lutil.getCenter(loc).add(0,-1.5,0));
packet.setInvisible(true);
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
}
public void save(){
main.getInstance().mgr.saveBarrel(this);
}
public ItemStack getItemStack() {
if(this.as != null && this.as.getHelmet()!=null){
return this.as.getHelmet();
}
return null;
}
public List<String> getList(){
return Utils.UUIDListToStringList(idList);
}
public void setItemstack(ItemStack is){
if(is==null){return;}
this.as.setHelmet(is);
}
public void delete(boolean b, boolean a){
if(b){
setLight(false);
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("barrels"));}
if(as!=null&&as.getHelmet()!=null &&!as.getHelmet().getType().equals(Material.AIR)){
as.getLocation().getWorld().dropItem(as.getLocation(), as.getHelmet());
}
if(this.block!=null&&!this.block.getType().equals(Material.AIR)){
this.block.setType(Material.AIR);
}
as.remove();
main.getInstance().mgr.deleteFromConfig(getID(), "barrels");
}
this.block = null;
this.loc = null;
this.idList.clear();
this.id = null;
this.as = null;
main.getInstance().getManager().barrelList.remove(this);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void damage(EntityDamageByEntityEvent e){
@EventHandler
private void onClick(FurnitureClickEvent e){
if(e.isCancelled()){return;}
if(e.getDamager() instanceof Player == false){return;}
if(e.getEntity() instanceof ArmorStand == false){return;}
if(e.getEntity() == null){return;}
if(!idList.contains(e.getEntity().getUniqueId())){return;}
if(!e.getID().equals(obj)){return;}
if(!e.canBuild(null)){return;}
e.setCancelled(true);
if(!Permissions.check((Player) e.getDamager(), FurnitureType.BARRELS, "destroy.")){return;}
if(!main.getInstance().getCheckManager().canBuild((Player) e.getDamager(), getLocation())){return;}
if(((Player) e.getDamager()).getGameMode().equals(GameMode.CREATIVE)){delete(true, false);return;}
delete(true, true);
}
@EventHandler(priority = EventPriority.HIGHEST)
private void onBreak(BlockBreakEvent e){
if(block!=null&&e.getBlock().equals(block)){
e.setCancelled(true);
if(((Player) e.getPlayer()).getGameMode().equals(GameMode.CREATIVE)){delete(true, false);return;}
if(!Permissions.check(e.getPlayer(), FurnitureType.BARRELS, "destroy.")){return;}
delete(true, true);
Player p = e.getPlayer();
if(!p.getItemInHand().getType().isBlock()&&!p.getItemInHand().getType().equals(Material.AIR)){return;}
ArmorStandPacket packet = manager.getArmorStandPacketByObjectID(obj).get(0);
if(packet.getInventory().getHelmet()!=null&&!packet.getInventory().getHelmet().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getHelmet();
w.dropItem(loc, is);
}
packet.getInventory().setHelmet(p.getItemInHand());
packet.update();
}
@SuppressWarnings("static-access")
public void setLight(Boolean b){
if(main.getInstance().getCheckManager().getLightAPI()!=null){
ILightAPI light = main.getInstance().getCheckManager().getLightAPI();
if(b){
light.getLightAPI().createLight(Utils.getCenter(getLocation()), 10);
}else{
light.getLightAPI().deleteLight(Utils.getCenter(getLocation()));
}
}
}
@EventHandler(priority = EventPriority.HIGHEST)
private void onInteract(PlayerInteractAtEntityEvent e){
if(e.isCancelled()){return;}
Player player = e.getPlayer();
if(e.getRightClicked()==null){return;}
if(e.getRightClicked() instanceof ArmorStand == false){return;}
if(idList==null||idList.isEmpty()){return;}
if(!idList.contains(e.getRightClicked().getUniqueId())){return;}
e.setCancelled(true);
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
ItemStack is = player.getItemInHand();
if(is!=null&&is.getType().isBlock()||is.getType().equals(Material.AIR)){
if(as!=null){
if(as.getHelmet()!=null&&as.getHelmet().equals(is)){return;}
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)){as.getLocation().getWorld().dropItem(as.getLocation(), as.getHelmet());}
setItemstack(is);
if(is.getType().equals(Material.GLOWSTONE) || is.getType().equals(Material.BEACON) || is.getType().equals(Material.SEA_LANTERN) ){setLight(true);}else{setLight(false);}
if(!player.getGameMode().equals(GameMode.CREATIVE)){player.getInventory().remove(is);player.updateInventory();}
main.getInstance().mgr.saveBarrel(this);
}
}
}
@EventHandler(priority = EventPriority.HIGHEST)
@EventHandler
private void onInteract(PlayerInteractEvent e){
if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
if(block!=null&&e.getClickedBlock()!=null&&e.getClickedBlock().equals(block)){
e.setCancelled(true);
Player player = e.getPlayer();
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
ItemStack is = player.getItemInHand();
if(is!=null&&is.getType().isBlock()||is.getType().equals(Material.AIR)){
if(as!=null){
if(as.getHelmet()!=null&&as.getHelmet().equals(is)){return;}
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)){as.getLocation().getWorld().dropItem(as.getLocation(), as.getHelmet());}
setItemstack(is);
if(is.getType().equals(Material.GLOWSTONE) || is.getType().equals(Material.BEACON) || is.getType().equals(Material.SEA_LANTERN) ){setLight(true);}else{setLight(false);}
if(!player.getGameMode().equals(GameMode.CREATIVE)){player.getInventory().remove(is);player.updateInventory();}
main.getInstance().mgr.saveBarrel(this);
}
}
}
if(block==null){return;}
if(!e.getClickedBlock().getLocation().equals(block.getLocation())){return;}
if(!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){return;}
if(!lib.canBuild(e.getPlayer(), e.getClickedBlock().getLocation(), Material.CAULDRON)){return;}
Player p = e.getPlayer();
if(!p.getItemInHand().getType().isBlock()&&!p.getItemInHand().getType().equals(Material.AIR)){e.getPlayer().sendMessage("03");return;}
e.setCancelled(true);
ItemStack Itemstack = p.getItemInHand().clone();
Itemstack.setAmount(1);
ArmorStandPacket packet = manager.getArmorStandPacketByObjectID(obj).get(0);
if(packet.getInventory().getHelmet()!=null&&!packet.getInventory().getHelmet().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getHelmet();
w.dropItem(loc, is);
}
if(!p.getGameMode().equals(GameMode.CREATIVE)){
Integer i = p.getInventory().getHeldItemSlot();
ItemStack is = p.getItemInHand();
is.setAmount(is.getAmount()-1);
p.getInventory().setItem(i, is);
p.updateInventory();
}
packet.getInventory().setHelmet(Itemstack);
packet.update();
}
@EventHandler
private void onBlockBreak(BlockBreakEvent e){
if(block==null){return;}
if(!e.getBlock().getLocation().equals(block.getLocation())){return;}
if(!lib.canBuild(e.getPlayer(), e.getBlock().getLocation(), Material.CAULDRON)){return;}
ArmorStandPacket packet = manager.getArmorStandPacketByObjectID(obj).get(0);
if(packet.getInventory().getHelmet()!=null&&!packet.getInventory().getHelmet().getType().equals(Material.AIR)){
ItemStack is = packet.getInventory().getHelmet();
w.dropItem(loc, is);
}
this.block.setType(Material.AIR);
block=null;
manager.remove(obj);
obj=null;
}
@EventHandler
private void onBreak(FurnitureBreakEvent e){
if(e.isCancelled()){return;}
if(!e.canBuild(null)){return;}
if(!e.getID().equals(obj)){return;}
e.setCancelled(true);
manager.remove(obj);
obj=null;
block.setType(Material.AIR);
block=null;
}
}

View File

@ -1,177 +1,104 @@
package de.Ste3et_C0st.Furniture.Objects.outdoor;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.ArmorStand;
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.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import de.Ste3et_C0st.Furniture.Main.FurnitureCreateEvent;
import de.Ste3et_C0st.Furniture.Main.Permissions;
import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.Furniture.Main.Type.FurnitureType;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.LocationUtil;
import de.Ste3et_C0st.FurnitureLib.main.ArmorStandPacket;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureManager;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
public class campfire_1 implements Listener {
public class campfire_1 implements Listener{
private Location loc;
private String ID;
private BlockFace b;
private List<UUID> idList = new ArrayList<UUID>();
private World w;
public String getID(){return this.ID;}
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Integer id;
Plugin plugin;
public campfire_1(Location location, Plugin plugin, String ID, List<UUID> uuids){
public campfire_1(Location location, FurnitureLib lib, String name, Plugin plugin, ObjectID id){
this.lutil = main.getLocationUtil();
this.b = lutil.yawToFace(location.getYaw());
this.loc = location.getBlock().getLocation();
this.loc.setYaw(location.getYaw());
this.ID = ID;
this.w = location.getWorld();
this.b = Utils.yawToFace(location.getYaw());
FurnitureCreateEvent event = new FurnitureCreateEvent(FurnitureType.CAMPFIRE_1, this.ID, location);
Bukkit.getPluginManager().callEvent(event);
if(!event.isCancelled()){
if(uuids==null){uuids = idList;}
spawn(uuids, location, plugin);
}
}
public void spawn(List<UUID> uuidList, Location location, Plugin plugin){
for(int i = 0;i<=3;i++){
Location loc = Utils.getCenter(getLocation());
loc.add(0,-1.9,0);
loc.setYaw(i*60);
Utils.setArmorStand(loc, null, null, false, false,true, getID(), idList);
}
plugin.getServer().getPluginManager().registerEvents(this, plugin);
main.getInstance().getManager().campfire1List.add(this);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void damage(EntityDamageByEntityEvent e){
if(e.isCancelled()){return;}
if(e.getDamager() instanceof Player == false){return;}
if(e.getEntity() instanceof ArmorStand == false){return;}
if(e.getEntity() == null){return;}
if(!idList.contains(e.getEntity().getUniqueId())){return;}
e.setCancelled(true);
if(!Permissions.check((Player) e.getDamager(), FurnitureType.CAMPFIRE_1, "destroy.")){return;}
if(!main.getInstance().getCheckManager().canBuild((Player) e.getDamager(), getLocation())){return;}
if(((Player) e.getDamager()).getGameMode().equals(GameMode.CREATIVE)){delete(true, false);return;}
delete(true, true);
}
public List<String> getList(){
return Utils.UUIDListToStringList(idList);
}
public void delete(boolean b, boolean a){
setLight(false, false);
if(b){
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("campfire1"));}
for(UUID s : idList){
ArmorStand as = Utils.getArmorStandAtID(w, s);
if(as!=null){
if(a){as.getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, Material.LOG);}
as.remove();
}
}
main.getInstance().mgr.deleteFromConfig(getID(), "campfire1");
}
idList.clear();
main.getInstance().getManager().campfire1List.remove(this);
}
public void save(){
main.getInstance().mgr.saveCampFire1(this);
}
@EventHandler(priority = EventPriority.HIGHEST)
private void onInteract(PlayerInteractAtEntityEvent e){
if(e.isCancelled()){return;}
Player player = e.getPlayer();
if(e.getRightClicked() instanceof ArmorStand){
if(this.idList.contains(e.getRightClicked().getUniqueId())){
e.setCancelled(true);
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
ItemStack is = player.getItemInHand();
if(is!=null){
if(is.getType().equals(Material.FLINT_AND_STEEL)){
setLight(true, true);
}else if(is.getType().equals(Material.WATER_BUCKET)){
setLight(false, true);
}
save();
}
}
this.manager = lib.getFurnitureManager();
this.lib = lib;
this.plugin = plugin;
if(id!=null){
this.obj = id;
this.manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}else{
this.obj = new ObjectID(name, plugin.getName(), location);
}
spawn(location);
}
@EventHandler
public void onBurn(EntityDamageEvent e){
if(e.getEntity() instanceof ArmorStand && (e.getCause().name().equalsIgnoreCase("FIRE") || e.getCause().name().equalsIgnoreCase("FIRE_TICK"))){
if(idList.contains(e.getEntity().getUniqueId())){
e.setCancelled(true);
}
}
private void onBreak(FurnitureBreakEvent e){
if(e.isCancelled()){return;}
if(!e.canBuild(null)){return;}
if(!e.getID().equals(obj)){return;}
manager.remove(obj);
obj=null;
}
@SuppressWarnings("static-access")
public void setLight(boolean boolean1, boolean a) {
Location light = new Location(w, getLocation().getX(), getLocation().getY(), getLocation().getZ());
for(UUID s : idList){
if(Utils.getArmorStandAtID(w, s) != null){
setFire(Utils.getArmorStandAtID(w, s), boolean1);
@EventHandler
private void onClick(FurnitureClickEvent e){
if(e.isCancelled()){return;}
if(!e.canBuild(null)){return;}
if(!e.getID().equals(obj)){return;}
e.setCancelled(true);
List<ArmorStandPacket> aspList = manager.getArmorStandPacketByObjectID(obj);
ItemStack is = e.getPlayer().getItemInHand();
if(is.getType().equals(Material.WATER_BUCKET)){
for(ArmorStandPacket packet : aspList){
packet.setFire(false);
Location location = this.loc;
location.add(0, 1.2, 0);
lib.getLightManager().removeLight(location);
}
}
if(boolean1){
if(main.getInstance().getCheckManager().getLightAPI()!=null){
main.getInstance().getCheckManager().getLightAPI().getLightAPI().createLight(light, 15);
manager.updateFurniture(obj);
}else if(is.getType().equals(Material.FLINT_AND_STEEL)){
for(ArmorStandPacket packet : aspList){
packet.setFire(true);
Location location = this.loc;
location.add(0, 1.2, 0);
lib.getLightManager().addLight(location,15);
}
light.getWorld().playSound(light, Sound.FIRE_IGNITE, 1, 1);
}else{
if(main.getInstance().getCheckManager().getLightAPI()!=null){
main.getInstance().getCheckManager().getLightAPI().getLightAPI().deleteLight(light);
}
if(a){light.getWorld().playSound(light, Sound.FIZZ, 1, 1);}
manager.updateFurniture(obj);
}
}
public boolean getFire(){
for(UUID s : idList){
if(Utils.getArmorStandAtID(w, s) != null){
if(Utils.getArmorStandAtID(w, s).getFireTicks()>=1){
return true;
}
}
}
return false;
}
public void setFire(ArmorStand as, boolean b){
if(as.getFireTicks() <= 0 && b){
as.setFireTicks(Integer.MAX_VALUE);
}else if(as.getFireTicks() >= 0 && !b){
as.setFireTicks(0);
public void spawn(Location loc){
for(int i = 0;i<=3;i++){
Location location = lutil.getCenter(loc);
location.add(0,-1.9,0);
location.setYaw(i*60);
ArmorStandPacket packet = manager.createArmorStand(obj, location);
packet.setGravity(false);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
}
}

View File

@ -3,43 +3,30 @@ package de.Ste3et_C0st.Furniture.Objects.outdoor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.ArmorStand;
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.entity.EntityDamageEvent;
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.FurnitureCreateEvent;
import de.Ste3et_C0st.Furniture.Main.Permissions;
import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.Furniture.Main.Type.FurnitureType;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.LocationUtil;
import de.Ste3et_C0st.FurnitureLib.main.ArmorStandPacket;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureManager;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
public class campfire_2 implements Listener {
private Location loc;
private Location l;
private String ID;
private BlockFace b;
private List<UUID> idList = new ArrayList<UUID>();
private List<UUID> fire = new ArrayList<UUID>();
private List<Material> items = new ArrayList<Material>(
public class campfire_2 implements Listener{
List<Material> items = new ArrayList<Material>(
Arrays.asList(
Material.RAW_BEEF,
Material.RAW_CHICKEN,
@ -50,7 +37,7 @@ public class campfire_2 implements Listener {
Material.MUTTON
)
);
private List<Material> items2 = new ArrayList<Material>(
List<Material> items2 = new ArrayList<Material>(
Arrays.asList(
Material.COOKED_BEEF,
Material.COOKED_CHICKEN,
@ -61,13 +48,8 @@ public class campfire_2 implements Listener {
Material.COOKED_MUTTON
)
);
private World w;
private Integer timer;
public String getID(){return this.ID;}
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
private ArmorStand armorS;
private EulerAngle[] angle = {
EulerAngle[] angle = {
new EulerAngle(-1.5, -.5, 0),
new EulerAngle(-1.9, -.3, .7),
new EulerAngle(-1.5, .3, 1.9),
@ -75,238 +57,191 @@ public class campfire_2 implements Listener {
};
public campfire_2(Location location, Plugin plugin, String ID, List<UUID> uuids) {
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Integer id;
Plugin plugin;
Location middle;
Location grill;
Integer timer;
ArmorStandPacket armorS;
ItemStack is;
public campfire_2(Location location, FurnitureLib lib, String name, Plugin plugin, ObjectID id){
this.lutil = main.getLocationUtil();
this.b = lutil.yawToFace(location.getYaw());
this.loc = location.getBlock().getLocation();
this.ID = ID;
this.b = Utils.yawToFace(location.getYaw());
this.w = location.getWorld();
this.loc.setYaw(location.getYaw());
FurnitureCreateEvent event = new FurnitureCreateEvent(FurnitureType.CAMPFIRE_2, this.ID, location);
Bukkit.getPluginManager().callEvent(event);
if(!event.isCancelled()){
if(uuids==null){uuids = idList;}
spawn(uuids, location, plugin);
}
}
public List<String> getList(){
return Utils.UUIDListToStringList(idList);
}
public void spawn(List<UUID> uuidList, Location location, Plugin plugin){
Location middle = Utils.getCenter(getLocation());
middle = main.getNew(middle, b, .5D, -.5D);
this.w = location.getWorld();
this.manager = lib.getFurnitureManager();
this.lib = lib;
this.plugin = plugin;
middle = lutil.getCenter(loc);
middle = lutil.getRelativ(middle, b, .5D, -.5D);
middle.add(0,-1.2,0);
Location stick1 = main.getNew(middle, getBlockFace(), .47D, -.05D);
Location stick2 = main.getNew(middle, getBlockFace(), .47D, .85D);
Location grill = main.getNew(middle,b, .0D, .5D);
Location bone = main.getNew(middle, getBlockFace(), .5D, .82D);
stick2.setYaw(Utils.FaceToYaw(b));
grill.setYaw(Utils.FaceToYaw(b)+90);
stick1.setYaw(Utils.FaceToYaw(b));
bone.setYaw(Utils.FaceToYaw(b));
grill = lutil.getRelativ(middle,b, .0D, .5D);
grill.setYaw(lutil.FaceToYaw(b)+90);
if(id!=null){
this.obj = id;
this.manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}else{
this.obj = new ObjectID(name, plugin.getName(), location);
}
spawn(location);
}
public void spawn(Location loc){
List<ArmorStandPacket> packetList = new ArrayList<ArmorStandPacket>();
Location stick1 = lutil.getRelativ(middle, b, .47D, -.05D);
Location stick2 = lutil.getRelativ(middle, b, .47D, .85D);
Location bone = lutil.getRelativ(middle, b, .5D, .82D);
stick2.setYaw(lutil.FaceToYaw(b));
stick1.setYaw(lutil.FaceToYaw(b));
bone.setYaw(lutil.FaceToYaw(b));
stick1.add(0,.3,0);
stick2.add(0,.3,0);
bone.add(0,.17,0);
Integer yaw = 90;
for(int i = 0; i<=7;i++){
Location loc = null;
if(Utils.axisList.contains(Utils.yawToFaceRadial(yaw))){
loc = main.getNew(middle, Utils.yawToFaceRadial(yaw), 0D, .5D);
Location location = null;
if(lutil.axisList.contains(lutil.yawToFaceRadial(yaw))){
location = lutil.getRelativ(middle, lutil.yawToFaceRadial(yaw), 0D, .5D);
}else{
loc = main.getNew(middle, Utils.yawToFaceRadial(yaw), 0D, .35D);
location = lutil.getRelativ(middle, lutil.yawToFaceRadial(yaw), 0D, .35D);
}
loc.setYaw(90+yaw);
Utils.setArmorStand(loc, new EulerAngle(1.568, 0, 0), new ItemStack(Material.STEP,1,(short)3), false, true, false, ID, idList);
location.setYaw(90+yaw);
ArmorStandPacket asp = manager.createArmorStand(obj, location);
asp.setPose(new EulerAngle(1.568, 0, 0), BodyPart.HEAD);
asp.setSmall(true);
asp.getInventory().setHelmet(new ItemStack(Material.STEP,1,(short)3));
packetList.add(asp);
yaw+=45;
}
yaw = 90;
for(int i = 0; i<=3;i++){
Location loc = main.getNew(middle, Utils.yawToFace(yaw), .4, -.5D);
loc.add(0,-.5,0);
loc.setYaw(90+yaw);
Utils.setArmorStand(loc, new EulerAngle(2, 0, 0), new ItemStack(Material.STICK), true, false, false, ID, idList);
Location location = lutil.getRelativ(middle, lutil.yawToFace(yaw), .4, -.5D);
location.add(0,-.5,0);
location.setYaw(90+yaw);
ArmorStandPacket asp = manager.createArmorStand(obj, location);
asp.setPose( new EulerAngle(2, 0, 0), BodyPart.RIGHT_ARM);
asp.getInventory().setItemInHand(new ItemStack(Material.STICK));
packetList.add(asp);
yaw+=90;
}
Utils.setArmorStand(stick1, new EulerAngle(1.38,.0,.0), new ItemStack(Material.STICK), true, false, false, ID, idList);
Utils.setArmorStand(stick2, new EulerAngle(1.38,.0,.0), new ItemStack(Material.STICK), true, false, false, ID, idList);
Utils.setArmorStand(bone, new EulerAngle(1.38,.0,1.57), new ItemStack(Material.BONE), true, false, false, ID, idList);
this.l = grill;
ArmorStandPacket asp = manager.createArmorStand(obj, stick1);
ArmorStand as = Utils.setArmorStand(middle.add(0,-1.3,0), null, null, false, true, false, ID, idList);
fire.add(as.getUniqueId());
asp.setPose(new EulerAngle(1.38,.0,.0), BodyPart.RIGHT_ARM);
asp.getInventory().setItemInHand(new ItemStack(Material.STICK));
packetList.add(asp);
asp = manager.createArmorStand(obj, stick2);
main.getInstance().getManager().campfire2List.add(this);
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onBurn(EntityDamageEvent e){
if(e.getEntity() instanceof ArmorStand && (e.getCause().name().equalsIgnoreCase("FIRE") || e.getCause().name().equalsIgnoreCase("FIRE_TICK"))){
if(fire!=null&&fire.contains(e.getEntity().getUniqueId())){
e.setCancelled(true);
}
asp.setPose(new EulerAngle(1.38,.0,.0), BodyPart.RIGHT_ARM);
asp.getInventory().setItemInHand(new ItemStack(Material.STICK));
packetList.add(asp);
asp = manager.createArmorStand(obj, bone);
asp.setPose(new EulerAngle(1.38,.0,1.57), BodyPart.RIGHT_ARM);
asp.getInventory().setItemInHand(new ItemStack(Material.BONE));
packetList.add(asp);
asp = manager.createArmorStand(obj, middle.add(0,-1.3,0));
asp.setSmall(true);
packetList.add(asp);
for(ArmorStandPacket packet : packetList){
packet.setInvisible(true);
packet.setGravity(false);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
}
public boolean isFire(){
if(fire==null){return false;}
for(UUID s : fire){
ArmorStand as = Utils.getArmorStandAtID(w, s);
if(as==null){return false;}
if(as.getFireTicks()>0){return true;}
}
return false;
}
@SuppressWarnings("static-access")
public void setLight(Boolean b, Boolean a){
if(b){
if(fire==null){return;}
for(UUID s : fire){
ArmorStand as = Utils.getArmorStandAtID(w, s);
if(as==null){return;}
as.setFireTicks(Integer.MAX_VALUE);
}
if(main.getInstance().getCheckManager().getLightAPI()!=null){
main.getInstance().getCheckManager().getLightAPI().getLightAPI().createLight(getLocation().toVector().toLocation(w), 15);
}
w.playSound(getLocation(), Sound.FIRE_IGNITE, 1, 1);
}else{
if(fire==null){return;}
for(UUID s : fire){
ArmorStand as = Utils.getArmorStandAtID(w, s);
if(as==null){return;}
as.setFireTicks(0);
}
if(main.getInstance().getCheckManager().getLightAPI()!=null){
main.getInstance().getCheckManager().getLightAPI().getLightAPI().deleteLight(getLocation().toVector().toLocation(w));
}
if(a){
w.playSound(getLocation(), Sound.FIZZ, 1, 1);
}
}
}
public void save(){
main.getInstance().mgr.saveCampFire2(this);
}
public void delete(Boolean b, Boolean a){
if(b){
setLight(false, false);
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("campfire2"));}
main.getInstance().mgr.deleteFromConfig(getID(), "campfire2");
for(UUID s : idList){
ArmorStand as = Utils.getArmorStandAtID(w, s);
if(as!=null){
if(a){as.getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, Material.LOG);}
as.remove();
}
}
}
removeGrill();
this.loc = null;
this.idList.clear();
this.ID = null;
main.getInstance().getManager().campfire2List.remove(this);
}
@EventHandler(priority = EventPriority.HIGHEST)
private void onInteract(PlayerInteractAtEntityEvent e){
@EventHandler
private void onClick(FurnitureClickEvent e){
if(e.isCancelled()){return;}
Player player = e.getPlayer();
if(e.getRightClicked() instanceof ArmorStand){
if(idList.contains(e.getRightClicked().getUniqueId())){
e.setCancelled(true);
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
ItemStack is = player.getItemInHand();
if(is!=null&&!is.getType().isBlock()||is.getType().equals(Material.AIR)){
if(is.getType().equals(Material.FLINT_AND_STEEL)){
setLight(true, true);
}
if(is.getType().equals(Material.WATER_BUCKET)){
setLight(false, true);
}
if(!isFire()){return;}
if(armorS==null&&getItem(is)!=null){
setGrill(is);
ItemStack item = is;
item.setAmount(is.getAmount()-1);
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), item);
player.updateInventory();
}
}
}
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void damage(EntityDamageByEntityEvent e){
if(e.isCancelled()){return;}
if(e.getDamager() instanceof Player == false){return;}
if(e.getEntity() instanceof ArmorStand == false){return;}
if(e.getEntity() == null){return;}
if(!idList.contains(e.getEntity().getUniqueId())){return;}
if(!e.canBuild(null)){return;}
if(!e.getID().equals(obj)){return;}
e.setCancelled(true);
if(!Permissions.check((Player) e.getDamager(), FurnitureType.CAMPFIRE_2, "destroy.")){return;}
if(!main.getInstance().getCheckManager().canBuild((Player) e.getDamager(), getLocation())){return;}
if(((Player) e.getDamager()).getGameMode().equals(GameMode.CREATIVE)){delete(true, false);return;}
delete(true, true);
}
public void setGrill(ItemStack is){
this.armorS = Utils.setArmorStand(l, null , is, true, false, false, ID, idList);
this.timer = main.getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(main.getInstance(), new Runnable() {
Integer rounds = Utils.randInt(15, 30);
Integer labs = 0;
Integer position = 0;
@Override
public void run() {
if(labs>=rounds){removeGrill();}
if(position>3){position=0;}
if(armorS!=null){
armorS.setRightArmPose(angle[position]);
}
position++;
labs++;
List<ArmorStandPacket> aspList = manager.getArmorStandPacketByObjectID(obj);
final ItemStack itemStack = e.getPlayer().getItemInHand();
ArmorStandPacket packet = null;
for(ArmorStandPacket pack : aspList){
if(pack.isMini() && pack.isInvisible()){
packet = pack;
}
}, 0, 4);
}
if(itemStack.getType().equals(Material.WATER_BUCKET) && packet.isFire()){
packet.setFire(false);
manager.updateFurniture(obj);
Location loc = middle.clone();
loc.add(0, 1.3, 0);
lib.getLightManager().removeLight(loc);
}else if(itemStack.getType().equals(Material.FLINT_AND_STEEL) && !packet.isFire()){
packet.setFire(true);
manager.updateFurniture(obj);
Location loc = middle.clone();
loc.add(0, 1.3, 0);
lib.getLightManager().addLight(loc, 15);
}else if(items.contains(itemStack.getType()) && packet.isFire() && armorS==null){
is = itemStack.clone();
is.setAmount(1);
setGrill();
}
}
public boolean check(){
if(armorS==null){return true;}
return false;
@EventHandler
private void onBreak(FurnitureBreakEvent e){
if(e.isCancelled()){return;}
if(!e.canBuild(null)){return;}
if(!e.getID().equals(obj)){return;}
e.setCancelled(true);
if(isRunning()){
Bukkit.getScheduler().cancelTask(timer);
timer=null;
w.dropItem(middle.clone().add(0, .5, 0), is);
}
manager.remove(obj);
obj=null;
}
public void removeGrill(){
if(isRunning()){
Bukkit.getScheduler().cancelTask(timer);
timer=null;
if(armorS!=null&&armorS.getItemInHand()!=null&&getItem(armorS.getItemInHand())!=null){
w.dropItem(getLocation(), getCooked(armorS.getItemInHand()));
armorS.remove();
if(armorS!=null&&armorS.getInventory().getItemInHand()!=null&&getItem(armorS.getInventory().getItemInHand())!=null){
w.dropItem(middle.clone().add(0, .5, 0), getCooked(is));
armorS.destroy();
armorS.delete();
armorS=null;
}
}
if(armorS!=null){
if(armorS.getItemInHand()!=null){w.dropItem(getLocation(), getCooked(armorS.getItemInHand()));}
armorS.remove();
if(armorS.getInventory().getItemInHand()!=null){w.dropItem(middle.clone().add(0, .5, 0), getCooked(is));}
armorS.destroy();
armorS.delete();
armorS=null;
}
}
public boolean isRunning(){
if(timer==null){return false;}
return true;
}
public ItemStack getItem(ItemStack is){
if(is==null){return null;}
if(is.getType()==null){return null;}
@ -324,4 +259,32 @@ public class campfire_2 implements Listener {
}
return is;
}
public boolean isRunning(){
if(timer==null){return false;}
return true;
}
public void setGrill(){
this.armorS = manager.createArmorStand(obj, grill);
this.armorS.setInvisible(true);
this.armorS.getInventory().setItemInHand(is);
manager.send(armorS);
this.timer = main.getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(main.getInstance(), new Runnable() {
Integer rounds = lutil.randInt(15, 30);
Integer labs = 0;
Integer position = 0;
@Override
public void run() {
if(labs>=rounds){removeGrill();return;}
if(position>3){position=0;}
if(armorS!=null){
armorS.setPose(angle[position], BodyPart.RIGHT_ARM);
armorS.update();
}
position++;
labs++;
}
}, 0, 4);
}
}

View File

@ -1,328 +1,322 @@
package de.Ste3et_C0st.Furniture.Objects.outdoor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
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.block.BlockBreakEvent;
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.FurnitureCreateEvent;
import de.Ste3et_C0st.Furniture.Main.Permissions;
import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.Furniture.Main.Type.FurnitureType;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.LocationUtil;
import de.Ste3et_C0st.FurnitureLib.main.ArmorStandPacket;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureManager;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
public class tent_1 implements Listener {
public class tent_1 implements Listener{
private Location loc;
private String ID;
private BlockFace b;
private Block block;
private List<UUID> idList = new ArrayList<UUID>();
private World w;
public String getID(){return this.ID;}
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Integer id;
Block block;
Plugin plugin;
public tent_1(Location location, Plugin plugin, String ID, List<UUID> uuids) {
this.loc = new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
public tent_1(Location location, FurnitureLib lib, String name, Plugin plugin, ObjectID id){
this.lutil = main.getLocationUtil();
this.b = lutil.yawToFace(location.getYaw());
this.loc = location.getBlock().getLocation();
this.loc.setYaw(location.getYaw());
this.w = location.getWorld();
BlockFace b = Utils.yawToFace(location.getYaw());
this.manager = lib.getFurnitureManager();
this.lib = lib;
this.plugin = plugin;
if(b.equals(BlockFace.WEST)){loc=lutil.getRelativ(loc, b, 1D, 0D);}
if(b.equals(BlockFace.NORTH)){loc=lutil.getRelativ(loc, b, 1D, 1D);}
if(b.equals(BlockFace.EAST)){loc=lutil.getRelativ(loc, b, 0D, 1D);}
if(b.equals(BlockFace.WEST)){location=main.getNew(location, b, 1D, 0D);}
if(b.equals(BlockFace.NORTH)){location=main.getNew(location, b, 1D, 1D);}
if(b.equals(BlockFace.EAST)){location=main.getNew(location, b, 0D, 1D);}
location.setYaw(Utils.FaceToYaw(b));
this.ID = ID;
this.b = b;
FurnitureCreateEvent event = new FurnitureCreateEvent(FurnitureType.TENT_1, this.ID, location);
Bukkit.getPluginManager().callEvent(event);
if(!event.isCancelled()){
if(uuids==null){uuids = idList;}
spawn(uuids, location, plugin);
if(id!=null){
this.obj = id;
setblock();
this.manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}else{
this.obj = new ObjectID(name, plugin.getName(), location);
}
spawn(loc);
}
public List<String> getList(){
return Utils.UUIDListToStringList(idList);
}
public void spawn(List<UUID> uuidList, Location location, Plugin plugin){
Location blockLocation = new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
Location loc_1 = new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
Location loc_2 = new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
Location loc_3 = new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
Location karabine1 = main.getNew(getLocation(), getBlockFace(), 0D, 0D);
Location karabine2 = main.getNew(getLocation(), getBlockFace(), 3D, 0D);
Location karabine3 = main.getNew(getLocation(), getBlockFace(), 3D, -4D);
Location karabine4 = main.getNew(getLocation(), getBlockFace(), 0D, -4D);
karabine1 = Utils.getCenter(karabine1);
karabine2 = Utils.getCenter(karabine2);
karabine3 = Utils.getCenter(karabine3);
karabine4 = Utils.getCenter(karabine4);
karabine1.setYaw(Utils.FaceToYaw(b)+90);
karabine2.setYaw(Utils.FaceToYaw(b)+90);
karabine3.setYaw(Utils.FaceToYaw(b)+90);
karabine4.setYaw(Utils.FaceToYaw(b)+90);
public void setblock(){
Location blockLocation = new Location(loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
if(b.equals(BlockFace.SOUTH)){
block = blockLocation.getWorld().getBlockAt(main.getNew(blockLocation, b, 2D, -2D));
block.setType(Material.WORKBENCH);
this.block = blockLocation.getWorld().getBlockAt(lutil.getRelativ(blockLocation, b, 2D, -2D));
this.block.setType(Material.WORKBENCH);
}else if(b.equals(BlockFace.WEST)){
block = blockLocation.getWorld().getBlockAt(main.getNew(blockLocation, b, 1D, -2D));
block.setType(Material.WORKBENCH);
this.block = blockLocation.getWorld().getBlockAt(lutil.getRelativ(blockLocation, b, 1D, -2D));
this.block.setType(Material.WORKBENCH);
}else if(b.equals(BlockFace.NORTH)){
block = blockLocation.getWorld().getBlockAt(main.getNew(blockLocation, b, 1D, -3D));
block.setType(Material.WORKBENCH);
this.block = blockLocation.getWorld().getBlockAt(lutil.getRelativ(blockLocation, b, 1D, -3D));
this.block.setType(Material.WORKBENCH);
}else if(b.equals(BlockFace.EAST)){
block = blockLocation.getWorld().getBlockAt(main.getNew(blockLocation, b, 2D, -3D));
block.setType(Material.WORKBENCH);
this.block = blockLocation.getWorld().getBlockAt(lutil.getRelativ(blockLocation, b, 2D, -3D));
this.block.setType(Material.WORKBENCH);
}
}
private Location getNew(Location loc, BlockFace b){
if(b.equals(BlockFace.WEST)){loc=lutil.getRelativ(loc, b, -1D, 0D);}
if(b.equals(BlockFace.NORTH)){loc=lutil.getRelativ(loc, b, -1D, -1D);}
if(b.equals(BlockFace.EAST)){loc=lutil.getRelativ(loc, b, 0D, -1D);}
return loc;
}
public void spawn(Location loc){
List<ArmorStandPacket> aspList = new ArrayList<ArmorStandPacket>();
Location loc_1 = new Location(loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
Location loc_2 = new Location(loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
Location loc_3 = new Location(loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
Location saveLoc = main.getNew(loc_1, b, -.55D, -0.6);
Location karabine1 = getNew(lutil.getRelativ(loc, b, 0D, 0D), b);
Location karabine2 = getNew(lutil.getRelativ(loc, b, 3D, 0D), b);
Location karabine3 = getNew(lutil.getRelativ(loc, b, 3D, -4D), b);
Location karabine4 = getNew(lutil.getRelativ(loc, b, 0D, -4D), b);
karabine1 = lutil.getCenter(karabine1);
karabine2 = lutil.getCenter(karabine2);
karabine3 = lutil.getCenter(karabine3);
karabine4 = lutil.getCenter(karabine4);
karabine1.setYaw(lutil.FaceToYaw(b)+90);
karabine2.setYaw(lutil.FaceToYaw(b)+90);
karabine3.setYaw(lutil.FaceToYaw(b)+90);
karabine4.setYaw(lutil.FaceToYaw(b)+90);
Location saveLoc = lutil.getRelativ(loc_1, b, -.55D, -0.6);
saveLoc.add(0,-1.25,0);
saveLoc.setYaw(Utils.FaceToYaw(b) -90);
saveLoc.setYaw(lutil.FaceToYaw(b) -90);
Location saveLoc2 = main.getNew(loc_2, b, -4.27, -4.4);
Location saveLoc2 = lutil.getRelativ(loc_2, b, -4.27, -4.4);
saveLoc2.add(0,-1.25,0);
saveLoc2.setYaw(Utils.FaceToYaw(b) -90);
saveLoc2.setYaw(lutil.FaceToYaw(b) -90);
Location saveLoc3 = main.getNew(loc_3, b, -8D, -2.5D);
Location saveLoc3 = lutil.getRelativ(loc_3, b, -8D, -2.5D);
saveLoc3.add(0,.64,0);
saveLoc3.setYaw(Utils.FaceToYaw(b) -90);
saveLoc3.setYaw(lutil.FaceToYaw(b) -90);
Double d = .0;
setblock();
for(int i = 0; i<=5;i++){
Location loc1= main.getNew(saveLoc, b, d, 0D);
Location loc2= main.getNew(saveLoc, b, d, -.48).add(0,.3,0);
Location loc3= main.getNew(saveLoc, b, d, -.86).add(0,.81,0);
Location loc4= main.getNew(saveLoc, b, d, -1.08).add(0,1.33,0);
Location loc5= main.getNew(saveLoc, b, d, -1.38).add(0,1.86,0);
Location loc1= lutil.getRelativ(saveLoc, b, d, 0D);
Location loc2= lutil.getRelativ(saveLoc, b, d, -.48).add(0,.3,0);
Location loc3= lutil.getRelativ(saveLoc, b, d, -.86).add(0,.81,0);
Location loc4= lutil.getRelativ(saveLoc, b, d, -1.08).add(0,1.33,0);
Location loc5= lutil.getRelativ(saveLoc, b, d, -1.38).add(0,1.86,0);
loc1.setYaw(Utils.FaceToYaw(b.getOppositeFace()));
loc2.setYaw(Utils.FaceToYaw(b.getOppositeFace()));
loc3.setYaw(Utils.FaceToYaw(b.getOppositeFace()));
loc4.setYaw(Utils.FaceToYaw(b.getOppositeFace()));
loc5.setYaw(Utils.FaceToYaw(b.getOppositeFace()));
loc1.setYaw(lutil.FaceToYaw(b.getOppositeFace()));
loc2.setYaw(lutil.FaceToYaw(b.getOppositeFace()));
loc3.setYaw(lutil.FaceToYaw(b.getOppositeFace()));
loc4.setYaw(lutil.FaceToYaw(b.getOppositeFace()));
loc5.setYaw(lutil.FaceToYaw(b.getOppositeFace()));
location.add(loc1);
location.add(loc2);
location.add(loc3);
location.add(loc4);
location.add(loc5);
loc.add(loc1);
loc.add(loc2);
loc.add(loc3);
loc.add(loc4);
loc.add(loc5);
Utils.setArmorStand(loc1, new EulerAngle(0, 0, -.2), new ItemStack(Material.CARPET), false,false,false, getID(),idList);
Utils.setArmorStand(loc2, new EulerAngle(0, 0, -7.2), new ItemStack(Material.CARPET), false,false,false,getID(),idList);
Utils.setArmorStand(loc3, new EulerAngle(0, 0, -7.2), new ItemStack(Material.CARPET), false,false,false,getID(),idList);
Utils.setArmorStand(loc4, new EulerAngle(0, 0, -7.7), new ItemStack(Material.CARPET), false,false,false,getID(),idList);
Utils.setArmorStand(loc5, new EulerAngle(0, 0, -.7), new ItemStack(Material.CARPET), false,false,false,getID(),idList);
ArmorStandPacket asp = manager.createArmorStand(obj, loc1);
asp.getInventory().setHelmet(new ItemStack(Material.CARPET));
asp.setPose(new EulerAngle(0, 0, -.2), BodyPart.HEAD);
aspList.add(asp);
asp = manager.createArmorStand(obj, loc2);
asp.getInventory().setHelmet(new ItemStack(Material.CARPET));
asp.setPose(new EulerAngle(0, 0, -7.2), BodyPart.HEAD);
aspList.add(asp);
asp = manager.createArmorStand(obj, loc3);
asp.getInventory().setHelmet(new ItemStack(Material.CARPET));
asp.setPose(new EulerAngle(0, 0, -7.2), BodyPart.HEAD);
aspList.add(asp);
asp = manager.createArmorStand(obj, loc4);
asp.getInventory().setHelmet(new ItemStack(Material.CARPET));
asp.setPose(new EulerAngle(0, 0, -7.7), BodyPart.HEAD);
aspList.add(asp);
asp = manager.createArmorStand(obj, loc5);
asp.getInventory().setHelmet(new ItemStack(Material.CARPET));
asp.setPose(new EulerAngle(0, 0, -.7), BodyPart.HEAD);
aspList.add(asp);
d+=.62;
}
for(int i = 0; i<=5;i++){
Location loc1= main.getNew(saveLoc2, b, d, .02D);
Location loc2= main.getNew(saveLoc2, b, d, .48).add(0,.3,0);
Location loc3= main.getNew(saveLoc2, b, d, .86).add(0,.81,0);
Location loc4= main.getNew(saveLoc2, b, d, 1.08).add(0,1.33,0);
Location loc5= main.getNew(saveLoc2, b, d, 1.38).add(0,1.86,0);
Location loc1= lutil.getRelativ(saveLoc2, b, d, .02D);
Location loc2= lutil.getRelativ(saveLoc2, b, d, .48).add(0,.3,0);
Location loc3= lutil.getRelativ(saveLoc2, b, d, .86).add(0,.81,0);
Location loc4= lutil.getRelativ(saveLoc2, b, d, 1.08).add(0,1.33,0);
Location loc5= lutil.getRelativ(saveLoc2, b, d, 1.38).add(0,1.86,0);
loc1.setYaw(Utils.FaceToYaw(b.getOppositeFace()));
loc2.setYaw(Utils.FaceToYaw(b.getOppositeFace()));
loc3.setYaw(Utils.FaceToYaw(b.getOppositeFace()));
loc4.setYaw(Utils.FaceToYaw(b.getOppositeFace()));
loc5.setYaw(Utils.FaceToYaw(b.getOppositeFace()));
loc1.setYaw(lutil.FaceToYaw(b));
loc2.setYaw(lutil.FaceToYaw(b));
loc3.setYaw(lutil.FaceToYaw(b));
loc4.setYaw(lutil.FaceToYaw(b));
loc5.setYaw(lutil.FaceToYaw(b));
location.add(loc1);
location.add(loc2);
location.add(loc3);
location.add(loc4);
location.add(loc5);
loc.add(loc1);
loc.add(loc2);
loc.add(loc3);
loc.add(loc4);
loc.add(loc5);
Utils.setArmorStand(loc1, new EulerAngle(0, 0, .2), new ItemStack(Material.CARPET), false,false,false,getID(),idList);
Utils.setArmorStand(loc2, new EulerAngle(0, 0, 7.2), new ItemStack(Material.CARPET), false,false,false,getID(),idList);
Utils.setArmorStand(loc3, new EulerAngle(0, 0, 7.2), new ItemStack(Material.CARPET), false,false,false,getID(),idList);
Utils.setArmorStand(loc4, new EulerAngle(0, 0, 7.7), new ItemStack(Material.CARPET), false,false,false,getID(),idList);
Utils.setArmorStand(loc5, new EulerAngle(0, 0, .7), new ItemStack(Material.CARPET), false,false,false,getID(),idList);
ArmorStandPacket asp = manager.createArmorStand(obj, loc1);
asp.getInventory().setHelmet(new ItemStack(Material.CARPET));
asp.setPose(new EulerAngle(0, 0, -.2), BodyPart.HEAD);
aspList.add(asp);
asp = manager.createArmorStand(obj, loc2);
asp.getInventory().setHelmet(new ItemStack(Material.CARPET));
asp.setPose(new EulerAngle(0, 0, -7.2), BodyPart.HEAD);
aspList.add(asp);
asp = manager.createArmorStand(obj, loc3);
asp.getInventory().setHelmet(new ItemStack(Material.CARPET));
asp.setPose(new EulerAngle(0, 0, -7.2), BodyPart.HEAD);
aspList.add(asp);
asp = manager.createArmorStand(obj, loc4);
asp.getInventory().setHelmet(new ItemStack(Material.CARPET));
asp.setPose(new EulerAngle(0, 0, -7.7), BodyPart.HEAD);
aspList.add(asp);
asp = manager.createArmorStand(obj, loc5);
asp.getInventory().setHelmet(new ItemStack(Material.CARPET));
asp.setPose(new EulerAngle(0, 0, -.7), BodyPart.HEAD);
aspList.add(asp);
d+=.62;
}
//middle
for(int i = 0; i<=5;i++){
Location loc1= main.getNew(saveLoc3, b, d, 0D);
loc1.setYaw(Utils.FaceToYaw(b.getOppositeFace()));
location.add(loc1);
Utils.setArmorStand(loc1, null, new ItemStack(Material.WOOD_STEP), false,false,false,getID(),idList);
Location loc1= lutil.getRelativ(saveLoc3, b, d, 0D);
loc1.setYaw(lutil.FaceToYaw(b.getOppositeFace()));
loc.add(loc1);
ArmorStandPacket asp = manager.createArmorStand(obj, loc1);
asp.getInventory().setHelmet( new ItemStack(Material.WOOD_STEP));
aspList.add(asp);
d+=.62;
}
Utils.setArmorStand(karabine1.add(0,-1.9,0), null, new ItemStack(Material.TRIPWIRE_HOOK), false, false,false, ID, idList);
Utils.setArmorStand(karabine2.add(0,-1.9,0), null, new ItemStack(Material.TRIPWIRE_HOOK), false, false,false, ID, idList);
Utils.setArmorStand(karabine3.add(0,-1.9,0), null, new ItemStack(Material.TRIPWIRE_HOOK), false, false,false, ID, idList);
Utils.setArmorStand(karabine4.add(0,-1.9,0), null, new ItemStack(Material.TRIPWIRE_HOOK), false, false,false, ID, idList);
ArmorStandPacket asp = manager.createArmorStand(obj, karabine1.add(0,-1.9,0));
asp.getInventory().setHelmet(new ItemStack(Material.TRIPWIRE_HOOK));
aspList.add(asp);
asp = manager.createArmorStand(obj, karabine2.add(0,-1.9,0));
asp.getInventory().setHelmet(new ItemStack(Material.TRIPWIRE_HOOK));
aspList.add(asp);
asp = manager.createArmorStand(obj, karabine3.add(0,-1.9,0));
asp.getInventory().setHelmet(new ItemStack(Material.TRIPWIRE_HOOK));
aspList.add(asp);
asp = manager.createArmorStand(obj, karabine4.add(0,-1.9,0));
asp.getInventory().setHelmet(new ItemStack(Material.TRIPWIRE_HOOK));
aspList.add(asp);
Location crafting = Utils.getCenter(block.getLocation());
crafting.setYaw(Utils.FaceToYaw(b)+90);
Utils.setArmorStand(crafting.add(0,-1,0), null, new ItemStack(Material.LADDER), false, false,false, ID, idList);
Utils.setArmorStand(crafting.add(0,.62,0), null, new ItemStack(Material.LADDER), false, false,false, ID, idList);
plugin.getServer().getPluginManager().registerEvents(this, plugin);
main.getInstance().getManager().tent1List.add(this);
Location crafting = lutil.getCenter(block.getLocation());
crafting.setYaw(lutil.FaceToYaw(b)+90);
asp = manager.createArmorStand(obj, crafting.add(0,-1,0));
asp.getInventory().setHelmet(new ItemStack(Material.LADDER));
aspList.add(asp);
asp = manager.createArmorStand(obj, crafting.add(0,.62,0));
asp.getInventory().setHelmet(new ItemStack(Material.LADDER));
aspList.add(asp);
for(ArmorStandPacket packet : aspList){
packet.setInvisible(true);
packet.setGravity(false);
}
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void onBlockBreak(BlockBreakEvent e){
if(e.getBlock()!=null&&block!=null&&e.getBlock().equals(block)){
e.setCancelled(true);
if(!Permissions.check(e.getPlayer(), FurnitureType.TENT_1, "destroy.")){return;}
delete(true, true);
}
}
public void save(){
main.getInstance().mgr.saveTent1(this);
}
public void delete(boolean b, boolean a){
if(b){
if(block!=null){block.setType(Material.AIR);}
if(a){
getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("tent1"));
}
for(UUID s : idList){
ArmorStand as = Utils.getArmorStandAtID(w, s);
if(as!=null){
if(a){
as.getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
}
as.remove();
}
}
main.getInstance().mgr.deleteFromConfig(getID(), "tent1");
}
idList.clear();
main.getInstance().getManager().tent1List.remove(this);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void damage(EntityDamageByEntityEvent e){
private void onBreak(FurnitureBreakEvent e){
if(e.isCancelled()){return;}
if(e.getDamager() instanceof Player == false){return;}
if(e.getEntity() instanceof ArmorStand == false){return;}
if(e.getEntity() == null){return;}
if(!idList.contains(e.getEntity().getUniqueId())){return;}
if(!e.canBuild(null)){return;}
if(!e.getID().equals(obj)){return;}
e.setCancelled(true);
if(!Permissions.check((Player) e.getDamager(), FurnitureType.TENT_1, "destroy.")){return;}
if(!main.getInstance().getCheckManager().canBuild((Player) e.getDamager(), getLocation())){return;}
if(((Player) e.getDamager()).getGameMode().equals(GameMode.CREATIVE)){delete(true, false);return;}
delete(true, true);
block.setType(Material.AIR);
manager.remove(obj);
obj=null;
}
@EventHandler(priority = EventPriority.HIGHEST)
private void onInteract(PlayerInteractAtEntityEvent e){
@EventHandler
private void onClick(FurnitureClickEvent e){
if(e.isCancelled()){return;}
Player player = e.getPlayer();
if(e.getRightClicked() instanceof ArmorStand == false){return;}
if(!idList.contains(e.getRightClicked().getUniqueId())){return;}
if(!e.getID().equals(obj)){return;}
e.setCancelled(true);
ItemStack is = player.getItemInHand();
if(is==null){return;}
if(is!=null){
if(is.getType().equals(Material.INK_SACK)){
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
Short druability = is.getDurability();
Integer amount = is.getAmount();
if(amount>idList.size() || player.getGameMode().equals(GameMode.CREATIVE)){amount=idList.size();}
List<Entity> list = new ArrayList<Entity>();
for(UUID s : this.idList){
ArmorStand as = Utils.getArmorStandAtID(w, s);
if(as!=null){
ItemStack item = as.getHelmet();
if(!as.getHelmet().getType().equals(Material.CARPET)){continue;}
if(item.getDurability() != main.getFromDey(druability)){list.add(as);}
}
}
int neAmound = amount;
for(Entity entity : list){
if(list.indexOf(entity)>amount-1){break;}
if(entity instanceof ArmorStand){
ArmorStand as = (ArmorStand) entity;
if(!as.getHelmet().getType().equals(Material.CARPET)){neAmound-=1;continue;}
ItemStack item = as.getHelmet();
item.setDurability(main.getFromDey(druability));
as.setHelmet(item);
}
final Player p = e.getPlayer();
if(!p.getItemInHand().getType().equals(Material.INK_SACK)){
p.openWorkbench(this.block.getLocation(), true);
}else{
Boolean canBuild = lib.canBuild(p, e.getLocation(), Material.CARPET);
Material m = Material.CARPET;
color(p, canBuild, m);
}
}
@EventHandler
private void onBlockBreak(BlockBreakEvent e){
if(e.isCancelled()){return;}
if(!lib.canBuild(e.getPlayer(), loc, null)){return;}
if(this.block!=null&&e.getBlock().equals(block)){this.block.setType(Material.AIR);this.block=null;}
manager.remove(obj);
obj=null;
}
private void color(Player p, boolean canBuild, Material m){
if(!canBuild){return;}
ItemStack is = p.getItemInHand();
Integer Amount = is.getAmount();
List<ArmorStandPacket> asp = manager.getArmorStandPacketByObjectID(obj);
short color = lutil.getFromDey(is.getDurability());
for(ArmorStandPacket packet : asp){
if(packet.getInventory().getHelmet()!=null&&packet.getInventory().getHelmet().getType().equals(m)){
if(Amount>0||p.getGameMode().equals(GameMode.CREATIVE)){
ItemStack is2 = packet.getInventory().getHelmet();
if(is2.getDurability() != color){
is2.setDurability(color);
packet.getInventory().setHelmet(is2);
if(!p.getGameMode().equals(GameMode.CREATIVE)){Amount--;}
}
if(!player.getGameMode().equals(GameMode.CREATIVE)){
is.setAmount(is.getAmount()-neAmound);
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), is);
player.updateInventory();
}
main.getInstance().mgr.saveTent1(this);
return;
}
}
if(block!=null){
player.openWorkbench(block.getLocation(), true);
}
}
public void setColor(HashMap<Integer, Short> durabilityList){
int i = 0;
for(UUID id: idList){
ArmorStand as = Utils.getArmorStandAtID(w, id);
if(as!=null){
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)&&as.getHelmet().getType().equals(Material.CARPET)){
ItemStack is = as.getHelmet();
is.setDurability(durabilityList.get(i));
as.setHelmet(is);
i++;
}
}
}
}
public HashMap<Integer, Short> getColor(){
HashMap<Integer, Short> colorList = new HashMap<Integer, Short>();
Integer i = 0;
for(UUID id: idList){
try{i=colorList.size();}catch(Exception e){return colorList;}
ArmorStand as = Utils.getArmorStandAtID(w, id);
if(as!=null){
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)&&as.getHelmet().getType().equals(Material.CARPET)){
ItemStack is = as.getHelmet();
colorList.put(i, is.getDurability());
}
}
if(!p.getGameMode().equals(GameMode.CREATIVE)){
Integer i = p.getInventory().getHeldItemSlot();
ItemStack item = p.getItemInHand();
item.setAmount(Amount);
p.getInventory().setItem(i, item);
p.updateInventory();
}
return colorList;
manager.updateFurniture(obj);
}
}

View File

@ -1,12 +1,9 @@
package de.Ste3et_C0st.Furniture.Objects.outdoor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
@ -15,88 +12,108 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.Chest;
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.block.BlockBreakEvent;
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.FurnitureCreateEvent;
import de.Ste3et_C0st.Furniture.Main.Permissions;
import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.Furniture.Main.Type.FurnitureType;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.LocationUtil;
import de.Ste3et_C0st.FurnitureLib.main.ArmorStandPacket;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureManager;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
public class tent_2 implements Listener {
public class tent_2 implements Listener{
private String ID;
private Location location;
private List<UUID> idList = new ArrayList<UUID>();
private BlockFace b;
public List<Block> block = new ArrayList<Block>();
public String getID(){return this.ID;}
public Location getLocation(){return this.location;}
public BlockFace getBlockFace(){return this.b;}
private World w;
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
public tent_2(Location location, Plugin plugin, String ID, List<UUID> uuids) {
this.b = Utils.yawToFace(location.getYaw());
this.location = location.getBlock().getLocation();
this.location.setYaw(location.getYaw());
this.ID = ID;
Integer id;
List<Block> block = new ArrayList<Block>();
Plugin plugin;
Location bedLoc;
public tent_2(Location location, FurnitureLib lib, String name, Plugin plugin, ObjectID id){
this.lutil = main.getLocationUtil();
this.b = lutil.yawToFace(location.getYaw());
this.loc = location.getBlock().getLocation();
this.loc.setYaw(location.getYaw());
this.w = location.getWorld();
if(b.equals(BlockFace.WEST)){location=main.getNew(location, b, 1D, 0D);}
if(b.equals(BlockFace.NORTH)){location=main.getNew(location, b, 1D, 1D);}
if(b.equals(BlockFace.EAST)){location=main.getNew(location, b, 0D, 1D);}
FurnitureCreateEvent event = new FurnitureCreateEvent(FurnitureType.TENT_2, this.ID, location);
Bukkit.getPluginManager().callEvent(event);
if(!event.isCancelled()){
if(uuids==null){uuids = idList;}
spawn(uuids, location, plugin);
this.manager = lib.getFurnitureManager();
this.lib = lib;
this.plugin = plugin;
if(b.equals(BlockFace.WEST)){location=lutil.getRelativ(location, b, 1D, 0D);}
if(b.equals(BlockFace.NORTH)){location=lutil.getRelativ(location, b, 1D, 1D);}
if(b.equals(BlockFace.EAST)){location=lutil.getRelativ(location, b, 0D, 1D);}
if(id!=null){
this.obj = id;
setBlock();
this.manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}else{
this.obj = new ObjectID(name, plugin.getName(), location);
}
spawn(location);
}
public List<String> getList(){
return Utils.UUIDListToStringList(idList);
}
@SuppressWarnings("deprecation")
public void spawn(List<UUID> uuidList, Location location, Plugin plugin){
location=main.getNew(location, b, -.91D, -0.75D);
Location LeftLocation = location;
public void spawn(Location loc){
List<ArmorStandPacket> aspl = new ArrayList<ArmorStandPacket>();
loc=lutil.getRelativ(loc, b, -.91D, -0.75D);
Location LeftLocation = loc;
LeftLocation.add(0,-.75,0);
Location RightLocation = main.getNew(LeftLocation, b, 0D, -4.55D);
Location MiddleLocation = main.getNew(LeftLocation, b, 0D, -2.27D).add(0,2.4,0);
Location LeftSart = main.getNew(LeftLocation, b, 3.87D, -.2D);
Location RightSart = main.getNew(RightLocation, b, 3.87D, .2D);
Location RightLocation = lutil.getRelativ(LeftLocation, b, 0D, -4.55D);
Location MiddleLocation = lutil.getRelativ(LeftLocation, b, 0D, -2.27D).add(0,2.4,0);
Location LeftSart = lutil.getRelativ(LeftLocation, b, 3.87D, -.2D);
Location RightSart = lutil.getRelativ(RightLocation, b, 3.87D, .2D);
Double d = .0;
for(int i = 0; i<=8;i++){
Location loc1= main.getNew(LeftLocation, b, d, 0D);
loc1.setYaw(Utils.FaceToYaw(b));
Utils.setArmorStand(loc1, new EulerAngle(1.568, 0, 0), new ItemStack(Material.LOG), false,true,false, ID, idList);
Location loc1= lutil.getRelativ(LeftLocation, b, d, 0D);
loc1.setYaw(lutil.FaceToYaw(b));
ArmorStandPacket as = manager.createArmorStand(obj, loc1);
as.getInventory().setHelmet(new ItemStack(Material.LOG));
as.setSmall(true);
as.setPose(new EulerAngle(1.568, 0, 0), BodyPart.HEAD);
aspl.add(as);
Location loc2= main.getNew(RightLocation, b, d, 0D);
loc2.setYaw(Utils.FaceToYaw(b));
Utils.setArmorStand(loc2, new EulerAngle(1.568, 0, 0), new ItemStack(Material.LOG), false,true,false, ID, idList);
Location loc2= lutil.getRelativ(RightLocation, b, d, 0D);
loc2.setYaw(lutil.FaceToYaw(b));
as = manager.createArmorStand(obj, loc2);
as.getInventory().setHelmet(new ItemStack(Material.LOG));
as.setSmall(true);
as.setPose(new EulerAngle(1.568, 0, 0), BodyPart.HEAD);
aspl.add(as);
Location loc3= main.getNew(MiddleLocation, b, d, 0D);
loc3.setYaw(Utils.FaceToYaw(b));
Utils.setArmorStand(loc3, new EulerAngle(1.568, 0, 0), new ItemStack(Material.LOG), false,true,false, ID, idList);
Location loc3= lutil.getRelativ(MiddleLocation, b, d, 0D);
loc3.setYaw(lutil.FaceToYaw(b));
as = manager.createArmorStand(obj, loc3);
as.getInventory().setHelmet(new ItemStack(Material.LOG));
as.setSmall(true);
as.setPose(new EulerAngle(1.568, 0, 0), BodyPart.HEAD);
aspl.add(as);
d+=.43;
}
d = .0;
Double l = -.25;
for(int i = 0;i<=4;i++){
setRow(LeftSart, .62, l, d, 5,new EulerAngle(0, 0, .79));
setRow(LeftSart, .62, l, d, 5,new EulerAngle(0, 0, .79), aspl);
d-=.435;
l+=.44;
}
@ -104,14 +121,26 @@ public class tent_2 implements Listener {
d = .0;
l = -.25;
for(int i = 0;i<=4;i++){
setRow(RightSart, .62, l, d, 5,new EulerAngle(0, 0, -.79));
setRow(RightSart, .62, l, d, 5,new EulerAngle(0, 0, -.79), aspl);
d+=.435;
l+=.44;
}
Location b1 = main.getNew(getLocation(), b, 1D, -2D);
Location b2 = main.getNew(getLocation(), b, 2D, -3D);
b2.setYaw(Utils.FaceToYaw(b));
for(ArmorStandPacket packet : aspl){
packet.setInvisible(true);
packet.setGravity(false);
}
setBlock();
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
}
@SuppressWarnings("deprecation")
public void setBlock(){
Location loc = this.loc.clone();
Location b1 = lutil.getRelativ(loc, b, 1D, -2D).add(0, 0, 0);
Location b2 = lutil.getRelativ(loc, b, 2D, -3D).add(0, 0, 0);
b2.setYaw(lutil.FaceToYaw(b));
b2.getBlock().setType(Material.CHEST);
BlockState chest = b2.getBlock().getState();
switch (b){
@ -131,164 +160,85 @@ public class tent_2 implements Listener {
}
chest.update(true, true);
Utils.setBed(this.b, b1);
bedLoc = lutil.setBed(this.b, b1);
block.add(b1.getWorld().getBlockAt(b1));
block.add(b2.getWorld().getBlockAt(b2));
plugin.getServer().getPluginManager().registerEvents(this, plugin);
main.getInstance().getManager().tent2List.add(this);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent e){
if(e.getBlock()!=null&&block!=null&&block.contains(e.getBlock())){
e.setCancelled(true);
if(!Permissions.check(e.getPlayer(), FurnitureType.TENT_2, "destroy.")){return;}
if(!main.getInstance().getCheckManager().canBuild(e.getPlayer(), getLocation())){return;}
delete(true, true);
}
}
public void delete(boolean b, boolean a){
if(b){
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("tent2"));}
for(UUID s : idList){
ArmorStand as = Utils.getArmorStandAtID(w, s);
if(as!=null){
if(a){as.getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());}
as.remove();
}
}
if(block!=null&&!block.isEmpty()){
for(Block bl : block){
if(bl!=null){
bl.setType(Material.AIR);
}
}
}
main.getInstance().mgr.deleteFromConfig(getID(), "tent2");
}
idList.clear();
block.clear();
main.getInstance().getManager().tent2List.remove(this);
}
public void save(){
main.getInstance().mgr.saveTent2(this);
}
public void setRow(Location loc, double x,double y, double z, int replay, EulerAngle angle){
public void setRow(Location loc, double x,double y, double z, int replay, EulerAngle angle, List<ArmorStandPacket> list){
Double d = .0;
for(int i = 0; i<=replay;i++){
Location loc1= main.getNew(loc, b, -3.55+d, z);
loc1.setYaw(Utils.FaceToYaw(b));
Location loc1= lutil.getRelativ(loc, b, -3.55+d, z);
loc1.setYaw(lutil.FaceToYaw(b));
loc1.add(0, y,0);
Utils.setArmorStand(loc1, angle, new ItemStack(Material.CARPET), false,false,false, ID, idList);
ArmorStandPacket packet = manager.createArmorStand(obj, loc1);
packet.getInventory().setHelmet(new ItemStack(Material.CARPET));
packet.setPose(angle, BodyPart.HEAD);
list.add(packet);
d+=x;
}
}
@EventHandler(priority = EventPriority.HIGHEST)
private void onInteract(PlayerInteractAtEntityEvent e){
@EventHandler
private void onBreak(FurnitureBreakEvent e){
if(e.isCancelled()){return;}
Player player = e.getPlayer();
if(e.getRightClicked() instanceof ArmorStand == false){return;}
if(!idList.contains(e.getRightClicked().getUniqueId())){return;}
if(!e.canBuild(null)){return;}
if(!e.getID().equals(obj)){return;}
e.setCancelled(true);
ItemStack is = player.getItemInHand();
if(is==null){return;}
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
if(is.getType().equals(Material.INK_SACK)){
Short druability = is.getDurability();
Integer amount = is.getAmount();
if(amount>idList.size() || player.getGameMode().equals(GameMode.CREATIVE)){amount=idList.size();}
List<Entity> list = new ArrayList<Entity>();
for(UUID s : this.idList){
ArmorStand as = Utils.getArmorStandAtID(w, s);
if(as!=null){
ItemStack item = as.getHelmet();
if(!as.getHelmet().getType().equals(Material.CARPET)){continue;}
if(item.getDurability() != main.getFromDey(druability)){list.add(as);
}
}
}
int neAmound = amount;
for(Entity entity : list){
if(list.indexOf(entity)>amount-1){break;}
if(entity instanceof ArmorStand){
ArmorStand as = (ArmorStand) entity;
if(!as.getHelmet().getType().equals(Material.CARPET)){neAmound-=1;continue;}
ItemStack item = as.getHelmet();
item.setDurability(main.getFromDey(druability));
as.setHelmet(item);
}
}
if(!player.getGameMode().equals(GameMode.CREATIVE)){
is.setAmount(is.getAmount()-neAmound);
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), is);
player.updateInventory();
}
main.getInstance().mgr.saveTent2(this);
return;
}
for(Block bl : block){
bl.setType(Material.AIR);
}
manager.remove(obj);
obj=null;
}
@EventHandler
private void onClick(final FurnitureClickEvent e){
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
e.setCancelled(true);
Player p = e.getPlayer();
if(!p.getItemInHand().getType().equals(Material.INK_SACK)){
if(block==null||block.isEmpty()){return;}
for(Block b : block){
if(b.getType().equals(Material.CHEST)){
Chest c = (Chest) b.getState();
player.openInventory(c.getBlockInventory());
}
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void damage(EntityDamageByEntityEvent e){
if(e.isCancelled()){return;}
if(e.getDamager() instanceof Player == false){return;}
if(e.getEntity() instanceof ArmorStand == false){return;}
if(e.getEntity() == null){return;}
if(!idList.contains(e.getEntity().getUniqueId())){return;}
e.setCancelled(true);
if(!Permissions.check((Player) e.getDamager(), FurnitureType.TENT_2, "destroy.")){return;}
if(!main.getInstance().getCheckManager().canBuild((Player) e.getDamager(), getLocation())){return;}
if(((Player) e.getDamager()).getGameMode().equals(GameMode.CREATIVE)){delete(true, false);return;}
delete(true, true);
}
public void setColor(HashMap<Integer, Short> durabilityList){
int i = 0;
for(UUID id: idList){
ArmorStand as = Utils.getArmorStandAtID(w, id);
if(as!=null){
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)&&as.getHelmet().getType().equals(Material.CARPET)){
ItemStack is = as.getHelmet();
is.setDurability(durabilityList.get(i));
as.setHelmet(is);
i++;
e.getPlayer().openInventory(c.getBlockInventory());
}
}
}else{
Boolean canBuild = lib.canBuild(p, e.getLocation(), Material.CARPET);
Material m = Material.CARPET;
color(p, canBuild, m);
}
}
public HashMap<Integer, Short> getColor(){
HashMap<Integer, Short> colorList = new HashMap<Integer, Short>();
Integer i = 0;
for(UUID id: idList){
try{i=colorList.size();}catch(Exception e){return colorList;}
ArmorStand as = Utils.getArmorStandAtID(w, id);
if(as!=null){
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)&&as.getHelmet().getType().equals(Material.CARPET)){
ItemStack is = as.getHelmet();
colorList.put(i, is.getDurability());
private void color(Player p, boolean canBuild, Material m){
if(!canBuild){return;}
ItemStack is = p.getItemInHand();
Integer Amount = is.getAmount();
List<ArmorStandPacket> asp = manager.getArmorStandPacketByObjectID(obj);
short color = lutil.getFromDey(is.getDurability());
for(ArmorStandPacket packet : asp){
if(packet.getInventory().getHelmet()!=null&&packet.getInventory().getHelmet().getType().equals(m)){
if(Amount>0||p.getGameMode().equals(GameMode.CREATIVE)){
ItemStack is2 = packet.getInventory().getHelmet();
if(is2.getDurability() != color){
is2.setDurability(color);
packet.getInventory().setHelmet(is2);
if(!p.getGameMode().equals(GameMode.CREATIVE)){Amount--;}
}
}
}
}
return colorList;
if(!p.getGameMode().equals(GameMode.CREATIVE)){
Integer i = p.getInventory().getHeldItemSlot();
ItemStack item = p.getItemInHand();
item.setAmount(Amount);
p.getInventory().setItem(i, item);
p.updateInventory();
}
manager.updateFurniture(obj);
}
}

View File

@ -1,14 +1,10 @@
package de.Ste3et_C0st.Furniture.Objects.outdoor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.DyeColor;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
@ -17,90 +13,109 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.banner.Pattern;
import org.bukkit.block.banner.PatternType;
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.inventory.meta.BannerMeta;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Main.FurnitureCreateEvent;
import de.Ste3et_C0st.Furniture.Main.Permissions;
import de.Ste3et_C0st.Furniture.Main.Utils;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.Furniture.Main.Type.FurnitureType;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.LocationUtil;
import de.Ste3et_C0st.FurnitureLib.main.ArmorStandPacket;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureManager;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;
public class tent_3 implements Listener {
public class tent_3 implements Listener{
private Location loc;
private String ID;
private BlockFace b;
private Block block;
private List<UUID> idList = new ArrayList<UUID>();
private World w;
public String getID(){return this.ID;}
public Location getLocation(){return this.loc;}
public BlockFace getBlockFace(){return this.b;}
public ArmorStand armorstand;
Location loc;
BlockFace b;
World w;
ObjectID obj;
FurnitureManager manager;
FurnitureLib lib;
LocationUtil lutil;
Integer id;
Plugin plugin;
public tent_3(Location location, Plugin plugin, String ID, List<UUID> uuids) {
this.b = Utils.yawToFace(location.getYaw());
public tent_3(Location location, FurnitureLib lib, String name, Plugin plugin, ObjectID id){
this.lutil = main.getLocationUtil();
this.b = lutil.yawToFace(location.getYaw());
this.loc = location.getBlock().getLocation();
this.ID = ID;
this.loc.setYaw(location.getYaw());
this.w = location.getWorld();
if(b.equals(BlockFace.WEST)){location=main.getNew(location, b, 1D, 0D);}
if(b.equals(BlockFace.NORTH)){location=main.getNew(location, b, 1D, 1D);}
if(b.equals(BlockFace.EAST)){location=main.getNew(location, b, 0D, 1D);}
FurnitureCreateEvent event = new FurnitureCreateEvent(FurnitureType.TENT_3, this.ID, location);
Bukkit.getPluginManager().callEvent(event);
if(!event.isCancelled()){
if(uuids==null){uuids = idList;}
spawn(uuids, location, plugin);
this.manager = lib.getFurnitureManager();
this.lib = lib;
this.plugin = plugin;
if(id!=null){
this.obj = id;
this.manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
return;
}else{
this.obj = new ObjectID(name, plugin.getName(), location);
}
if(b.equals(BlockFace.WEST)){location=lutil.getRelativ(location, b, 1D, 0D);}
if(b.equals(BlockFace.NORTH)){location=lutil.getRelativ(location, b, 1D, 1D);}
if(b.equals(BlockFace.EAST)){location=lutil.getRelativ(location, b, 0D, 1D);}
spawn(location);
}
public List<String> getList(){
return Utils.UUIDListToStringList(idList);
}
Block bed;
public void spawn(List<UUID> uuidList, Location location, Plugin plugin){
public void spawn(Location loc){
List<ArmorStandPacket> aspL = new ArrayList<ArmorStandPacket>();
ItemStack banner = new ItemStack(Material.BANNER);
BannerMeta meta = (BannerMeta) banner.getItemMeta();
meta.setBaseColor(DyeColor.WHITE);
banner.setItemMeta(meta);
Location locstart = main.getNew(location, b, .2D, -.17D);
Location locstart = lutil.getRelativ(loc, b, .2D, -.17D);
locstart.add(0,.65,0);
Location locstart2 = main.getNew(location, b, .2D, -.8D);
Location locstart2 = lutil.getRelativ(loc, b, .2D, -.8D);
locstart2.add(0,.65,0);
for(int i = 0; i<=2;i++){
Location loc = main.getNew(locstart, b, .74*i, 0D);
loc.setYaw(Utils.FaceToYaw(b)+90);
Utils.setArmorStand(loc, new EulerAngle(3.5, 0, 0), banner, false, false, false, getID(), idList);
Location location = lutil.getRelativ(locstart, b, .74*i, 0D);
location.setYaw(lutil.FaceToYaw(b)+90);
ArmorStandPacket as = manager.createArmorStand(obj, location);
as.getInventory().setHelmet(banner);
as.setPose(new EulerAngle(3.5, 0, 0), BodyPart.HEAD);
aspL.add(as);
location = lutil.getRelativ(locstart, b, .74*i, -.3D);
location.add(0,.9,0);
location.setYaw(lutil.FaceToYaw(b)+90);
loc = main.getNew(locstart, b, .74*i, -.3D);
loc.add(0,.9,0);
loc.setYaw(Utils.FaceToYaw(b)+90);
Utils.setArmorStand(loc, new EulerAngle(3.5, 0, 0), banner, false, false, false, getID(), idList);
as = manager.createArmorStand(obj, location);
as.getInventory().setHelmet(banner);
as.setPose(new EulerAngle(3.5, 0, 0), BodyPart.HEAD);
aspL.add(as);
}
for(int i = 0; i<=2;i++){
Location loc = main.getNew(locstart2, b, .74*i, 0D);
loc.setYaw(Utils.FaceToYaw(b)-90);
Utils.setArmorStand(loc, new EulerAngle(3.5, 0, 0), banner, false, false, false, getID(), idList);
Location location = lutil.getRelativ(locstart2, b, .74*i, 0D);
location.setYaw(lutil.FaceToYaw(b)-90);
loc = main.getNew(locstart2, b, .74*i, .32D);
loc.add(0,.9,0);
loc.setYaw(Utils.FaceToYaw(b)-90);
Utils.setArmorStand(loc, new EulerAngle(3.5, 0, 0), banner, false, false, false, getID(), idList);
ArmorStandPacket as = manager.createArmorStand(obj, location);
as.getInventory().setHelmet(banner);
as.setPose(new EulerAngle(3.5, 0, 0), BodyPart.HEAD);
aspL.add(as);
location = lutil.getRelativ(locstart2, b, .74*i, .32D);
location.add(0,.9,0);
location.setYaw(lutil.FaceToYaw(b)-90);
as = manager.createArmorStand(obj, location);
as.getInventory().setHelmet(banner);
as.setPose(new EulerAngle(3.5, 0, 0), BodyPart.HEAD);
aspL.add(as);
}
banner = new ItemStack(Material.BANNER);
@ -109,164 +124,109 @@ public class tent_3 implements Listener {
meta.addPattern(new Pattern(DyeColor.RED, PatternType.STRIPE_SMALL));
banner.setItemMeta(meta);
Location banner1 = main.getNew(location, b, 1.7D, -.1D);
Location banner1 = lutil.getRelativ(loc, b, 1.7D, -.1D);
banner1.add(0,-1.2,0);
Location banner2 = main.getNew(banner1, b, 0D, -.75);
banner1.setYaw(Utils.FaceToYaw(b));
banner2.setYaw(Utils.FaceToYaw(b));
Utils.setArmorStand(banner1, new EulerAngle(-1.568, 0, 0), banner, false, false, false, getID(), idList);
Utils.setArmorStand(banner2, new EulerAngle(-1.568, 0, 0), banner, false, false, false, getID(), idList);
Location banner2 = lutil.getRelativ(banner1, b, 0D, -.75);
banner1.setYaw(lutil.FaceToYaw(b));
banner2.setYaw(lutil.FaceToYaw(b));
Location sit = Utils.getCenter(location);
ArmorStandPacket as = manager.createArmorStand(obj, banner1);
as.getInventory().setHelmet(banner);
as.setPose(new EulerAngle(-1.568, 0, 0), BodyPart.HEAD);
aspL.add(as);
if(b.equals(BlockFace.WEST)){sit=main.getNew(sit, b, -1D, 0D);}
if(b.equals(BlockFace.NORTH)){sit=main.getNew(sit, b, -1D, -1D);}
if(b.equals(BlockFace.EAST)){sit=main.getNew(sit, b, 0D, -1D);}
as = manager.createArmorStand(obj, banner2);
as.getInventory().setHelmet(banner);
as.setPose(new EulerAngle(-1.568, 0, 0), BodyPart.HEAD);
aspL.add(as);
sit.setYaw(Utils.FaceToYaw(this.b.getOppositeFace()));
Location locationsit = main.getNew(sit, b, 1D, 0D);
locationsit.setYaw(Utils.FaceToYaw(this.b.getOppositeFace()));
armorstand = Utils.setArmorStand(locationsit.add(0,-2,0), null, null, false, false, false, getID(), idList);
Location sit = lutil.getCenter(loc);
block = Utils.setHalfBed(b, main.getNew(sit.add(0,-2,0).getBlock().getLocation().add(0,2,0), b, 2D, 0D));
if(b.equals(BlockFace.WEST)){sit=lutil.getRelativ(sit, b, -1D, 0D);}
if(b.equals(BlockFace.NORTH)){sit=lutil.getRelativ(sit, b, -1D, -1D);}
if(b.equals(BlockFace.EAST)){sit=lutil.getRelativ(sit, b, 0D, -1D);}
plugin.getServer().getPluginManager().registerEvents(this, plugin);
main.getInstance().getManager().tent3List.add(this);
this.loc.setYaw(Utils.FaceToYaw(b));
}
@EventHandler(priority = EventPriority.HIGHEST)
public void damage(EntityDamageByEntityEvent e){
if(e.isCancelled()){return;}
if(e.getDamager() instanceof Player == false){return;}
if(e.getEntity() instanceof ArmorStand == false){return;}
if(e.getEntity() == null){return;}
if(!idList.contains(e.getEntity().getUniqueId())){return;}
e.setCancelled(true);
if(!Permissions.check((Player) e.getDamager(), FurnitureType.TENT_3, null)){return;}
if(!main.getInstance().getCheckManager().canBuild((Player) e.getDamager(), getLocation())){return;}
if(((Player) e.getDamager()).getGameMode().equals(GameMode.CREATIVE)){delete(true, false);return;}
delete(true, true);
}
@EventHandler(priority = EventPriority.HIGHEST)
private void onInteract(PlayerInteractAtEntityEvent e){
if(e.isCancelled()){return;}
Player player = e.getPlayer();
if(e.getRightClicked() instanceof ArmorStand == false){return;}
if(!idList.contains(e.getRightClicked().getUniqueId())){return;}
e.setCancelled(true);
ItemStack is = player.getItemInHand();
if(is==null){return;}
if(is.getType().equals(Material.INK_SACK)){
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
Short druability = is.getDurability();
Integer amount = is.getAmount();
Integer neAmound = amount;
if(amount>idList.size() || player.getGameMode().equals(GameMode.CREATIVE)){amount=idList.size();}
List<Entity> list = new ArrayList<Entity>();
for(UUID s : this.idList){
ArmorStand as = Utils.getArmorStandAtID(w, s);
if(as!=null){
ItemStack item = as.getHelmet();
if(!as.getHelmet().getType().equals(Material.BANNER)){continue;}
BannerMeta im = (BannerMeta) item.getItemMeta();
if(im.getBaseColor().getColor() != main.getDyeFromDurability(druability)){list.add(as);}
}
}
for(Entity entity : list){
if(list.indexOf(entity)>amount-1){break;}
if(entity instanceof ArmorStand == false){break;}
ArmorStand as = (ArmorStand) entity;
if(as==null||as.getHelmet()==null){break;}
if(!as.getHelmet().getType().equals(Material.BANNER)){neAmound-=1;continue;}
ItemStack item = as.getHelmet();
BannerMeta banner = (BannerMeta) item.getItemMeta();
banner.setBaseColor(DyeColor.getByColor(main.getDyeFromDurability(druability)));
item.setItemMeta(banner);
as.setHelmet(item);
}
if(!player.getGameMode().equals(GameMode.CREATIVE)){
is.setAmount(is.getAmount()-neAmound);
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), is);
player.updateInventory();
sit.setYaw(lutil.FaceToYaw(this.b.getOppositeFace()));
Location locationsit = lutil.getRelativ(sit, b, 1D, 0D);
locationsit.setYaw(lutil.FaceToYaw(this.b.getOppositeFace()));
as = manager.createArmorStand(obj, locationsit.add(0,-2,0));
as.setName("#SITZ#");
aspL.add(as);
bed = lutil.setHalfBed(b, lutil.getRelativ(sit.add(0,-2,0).getBlock().getLocation().add(0,2,0), b, 2D, 0D));
for(ArmorStandPacket packet : aspL){
packet.setInvisible(true);
packet.setGravity(false);
}
main.getInstance().mgr.saveTent3(this);
return;
manager.send(obj);
Bukkit.getPluginManager().registerEvents(this, plugin);
}
@EventHandler
private void onBreak(FurnitureBreakEvent e){
if(e.isCancelled()){return;}
if(!e.canBuild(null)){return;}
if(!e.getID().equals(obj)){return;}
e.setCancelled(true);
bed.setType(Material.AIR);
manager.remove(obj);
obj=null;
}
@EventHandler
private void onClick(FurnitureClickEvent e){
if(e.isCancelled()){return;}
if(!e.getID().equals(obj)){return;}
e.setCancelled(true);
Player p = e.getPlayer();
if(p.getItemInHand().getType().equals(Material.INK_SACK)){
Boolean canBuild = lib.canBuild(p, e.getLocation(), Material.CARPET);
Material m = Material.BANNER;
color(p, canBuild, m);
}else{
if(checkIfSitting()){
armorstand.setPassenger(player);
}
}
}
public boolean checkIfSitting(){
if(armorstand != null){
if(armorstand.getPassenger()!= null){
return false;
}
}
return true;
}
public void delete(boolean b, boolean a){
if(b){
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("tent3"));}
for(UUID s : idList){
ArmorStand as = Utils.getArmorStandAtID(w, s);
if(as!=null){
if(a){as.getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, Material.LOG);}
as.remove();
}
}
if(this.block != null){
block.setType(Material.AIR);
}
main.getInstance().mgr.deleteFromConfig(getID(), "tent3");
}
block = null;
armorstand = null;
idList.clear();
main.getInstance().getManager().tent3List.remove(this);
}
public void save(){
main.getInstance().mgr.saveTent3(this);
}
public HashMap<Integer, Integer> getColor(){
HashMap<Integer, Integer> colorList = new HashMap<Integer, Integer>();
Integer i = 0;
for(UUID id: idList){
try{i=colorList.size();}catch(Exception e){return colorList;}
ArmorStand as = Utils.getArmorStandAtID(w, id);
if(as!=null){
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)&&as.getHelmet().getType().equals(Material.BANNER)){
ItemStack is = as.getHelmet();
BannerMeta im = (BannerMeta) is.getItemMeta();
colorList.put(i, im.getBaseColor().getColor().asRGB());
for(ArmorStandPacket packet : manager.getArmorStandPacketByObjectID(obj)){
if(packet.getName().equalsIgnoreCase("#SITZ#")){
if(packet.getPessanger()==null){
packet.setPessanger(p);
packet.update();
}
}
}
}
return colorList;
}
public void setColor(HashMap<Integer, Integer> durabilityList){
int i = 0;
for(UUID id: idList){
ArmorStand as = Utils.getArmorStandAtID(w, id);
if(as!=null){
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)&&as.getHelmet().getType().equals(Material.BANNER)){
ItemStack is = as.getHelmet();
BannerMeta im = (BannerMeta) is.getItemMeta();
im.setBaseColor(DyeColor.getByColor(Color.fromRGB(durabilityList.get(i))));
is.setItemMeta(im);
as.setHelmet(is);
i++;
private void color(Player p, boolean canBuild, Material m){
if(!canBuild){return;}
ItemStack is = p.getItemInHand();
Integer Amount = is.getAmount();
List<ArmorStandPacket> asp = manager.getArmorStandPacketByObjectID(obj);
p.sendMessage(asp.size() + ":" + Amount);
DyeColor change = DyeColor.getByColor(lutil.getDyeFromDurability(is.getDurability()));
for(ArmorStandPacket packet : asp){
if(packet.getInventory().getHelmet()!=null&&packet.getInventory().getHelmet().getType().equals(m)){
if(Amount>0||p.getGameMode().equals(GameMode.CREATIVE)){
ItemStack is2 = packet.getInventory().getHelmet();
BannerMeta banner = (BannerMeta) is2.getItemMeta();
DyeColor change2 = banner.getBaseColor();
if(change2 != change){
banner.setBaseColor(change);
is2.setItemMeta(banner);
packet.getInventory().setHelmet(is2);
if(!p.getGameMode().equals(GameMode.CREATIVE)){Amount--;}
}
}
}
}
if(!p.getGameMode().equals(GameMode.CREATIVE)){
Integer i = p.getInventory().getHeldItemSlot();
ItemStack item = p.getItemInHand();
item.setAmount(Amount);
p.getInventory().setItem(i, item);
p.updateInventory();
}
manager.updateFurniture(obj);
}
}

View File

@ -1,14 +1,7 @@
name: Furniture
version: 1.8.3
description: Add some Furniture to the Server
name: DefaultFurniture
version: 0.1
description: Furniture
author: Ste3et_C0st
website: http://dicecraft.de
softdepend: [Vault, WorldGuard, WorldEdit, Towny, Landlord, LightAPI, PlotSquared, PreciousStones, PlotMe, PlotMe, Plotz, GriefPrevention, Multiverse-Core, Multiworld]
main: de.Ste3et_C0st.Furniture.Main.main
commands:
furniture:
description: Dice Furniture Command
usage: /<command>
model:
description: Dice Furniture Command
usage: /<command>
depend: [FurnitureLib]
main: de.Ste3et_C0st.Furniture.Main.main