mirror of
https://github.com/Ste3et/furniture.git
synced 2025-02-16 20:31:26 +01:00
Furniture Plugin
This commit is contained in:
parent
65d0749a79
commit
5403fe3b33
@ -2,6 +2,7 @@ config:
|
||||
# Needs Vualt (optional)
|
||||
UseMetrics: true
|
||||
CraftingPermissions: true
|
||||
BreakPermissions: true
|
||||
Messages:
|
||||
NoPermissions: "&cYou don't have permission to do that"
|
||||
notFound: "&cFurniture not found"
|
||||
|
@ -1,24 +1,33 @@
|
||||
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;
|
||||
@ -41,8 +50,7 @@ public class OnInteract implements Listener {
|
||||
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()))){
|
||||
if((!p.hasPermission("furniture.craft." + getName(e.getRecipe().getResult()))) && (!p.hasPermission("furniture.player")) ){
|
||||
inv.setResult(null);
|
||||
return;
|
||||
}
|
||||
@ -50,6 +58,32 @@ public class OnInteract implements Listener {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@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()){
|
||||
@ -78,17 +112,13 @@ public class OnInteract implements Listener {
|
||||
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(!p.hasPermission("furniture.sofa")){p.sendMessage(noPermissions);return;}
|
||||
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());
|
||||
sofa s = new sofa(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
|
||||
s.save();
|
||||
if(!p.getGameMode().equals(GameMode.CREATIVE)){
|
||||
is.setAmount(amount-1);
|
||||
p.getInventory().setItem(hand, is);
|
||||
p.updateInventory();
|
||||
}
|
||||
return;
|
||||
}else{
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
|
||||
return;
|
||||
@ -96,16 +126,10 @@ public class OnInteract implements Listener {
|
||||
}
|
||||
|
||||
if(saveIS.equals(main.getInstance().crafting.get("lantern"))){
|
||||
if(!p.hasPermission("furniture.lantern")){p.sendMessage(noPermissions);return;}
|
||||
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());
|
||||
new latern(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
|
||||
p.playEffect(location, Effect.STEP_SOUND, Material.TORCH);
|
||||
if(!p.getGameMode().equals(GameMode.CREATIVE)){
|
||||
is.setAmount(amount-1);
|
||||
p.getInventory().setItem(hand, is);
|
||||
p.updateInventory();
|
||||
}
|
||||
return;
|
||||
}else{
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
|
||||
return;
|
||||
@ -113,17 +137,11 @@ public class OnInteract implements Listener {
|
||||
}
|
||||
|
||||
if(saveIS.equals(main.getInstance().crafting.get("chair"))){
|
||||
if(!p.hasPermission("furniture.chair")){p.sendMessage(noPermissions);return;}
|
||||
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());
|
||||
chair c = new chair(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
|
||||
p.playEffect(location, Effect.STEP_SOUND, Material.WOOD);
|
||||
c.save();
|
||||
if(!p.getGameMode().equals(GameMode.CREATIVE)){
|
||||
is.setAmount(amount-1);
|
||||
p.getInventory().setItem(hand, is);
|
||||
p.updateInventory();
|
||||
}
|
||||
return;
|
||||
}else{
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
|
||||
return;
|
||||
@ -131,17 +149,11 @@ public class OnInteract implements Listener {
|
||||
}
|
||||
|
||||
if(saveIS.equals(main.getInstance().crafting.get("table"))){
|
||||
if(!p.hasPermission("furniture.table")){p.sendMessage(noPermissions);return;}
|
||||
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());
|
||||
table t = new table(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
|
||||
p.playEffect(location, Effect.STEP_SOUND, Material.WOOD);
|
||||
t.save();
|
||||
if(!p.getGameMode().equals(GameMode.CREATIVE)){
|
||||
is.setAmount(amount-1);
|
||||
p.getInventory().setItem(hand, is);
|
||||
p.updateInventory();
|
||||
}
|
||||
return;
|
||||
}else{
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
|
||||
return;
|
||||
@ -149,17 +161,11 @@ public class OnInteract implements Listener {
|
||||
}
|
||||
|
||||
if(saveIS.equals(main.getInstance().crafting.get("largeTable"))){
|
||||
if(!p.hasPermission("furniture.largetable")){p.sendMessage(noPermissions);return;}
|
||||
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());
|
||||
largeTable l = new largeTable(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
|
||||
p.playEffect(location, Effect.STEP_SOUND, Material.GLASS);
|
||||
l.save();
|
||||
if(!p.getGameMode().equals(GameMode.CREATIVE)){
|
||||
is.setAmount(amount-1);
|
||||
p.getInventory().setItem(hand, is);
|
||||
p.updateInventory();
|
||||
}
|
||||
return;
|
||||
}else{
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
|
||||
return;
|
||||
@ -167,17 +173,11 @@ public class OnInteract implements Listener {
|
||||
}
|
||||
|
||||
if(saveIS.equals(main.getInstance().crafting.get("tent1"))){
|
||||
if(!p.hasPermission("furniture.tent1")){p.sendMessage(noPermissions);return;}
|
||||
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());
|
||||
tent_1 tent = new tent_1(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
|
||||
tent.save();
|
||||
p.playEffect(location, Effect.STEP_SOUND, Material.WOOL);
|
||||
if(!p.getGameMode().equals(GameMode.CREATIVE)){
|
||||
is.setAmount(amount-1);
|
||||
p.getInventory().setItem(hand, is);
|
||||
p.updateInventory();
|
||||
}
|
||||
return;
|
||||
}else{
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
|
||||
return;
|
||||
@ -185,17 +185,11 @@ public class OnInteract implements Listener {
|
||||
}
|
||||
|
||||
if(saveIS.equals(main.getInstance().crafting.get("tent2"))){
|
||||
if(!p.hasPermission("furniture.tent2")){p.sendMessage(noPermissions);return;}
|
||||
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());
|
||||
tent_2 tent = new tent_2(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
|
||||
tent.save();
|
||||
p.playEffect(location, Effect.STEP_SOUND, Material.WOOL);
|
||||
if(!p.getGameMode().equals(GameMode.CREATIVE)){
|
||||
is.setAmount(amount-1);
|
||||
p.getInventory().setItem(hand, is);
|
||||
p.updateInventory();
|
||||
}
|
||||
return;
|
||||
}else{
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
|
||||
return;
|
||||
@ -203,17 +197,11 @@ public class OnInteract implements Listener {
|
||||
}
|
||||
|
||||
if(saveIS.equals(main.getInstance().crafting.get("campfire1"))){
|
||||
if(!p.hasPermission("furniture.campfire1")){p.sendMessage(noPermissions);return;}
|
||||
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());
|
||||
campfire_1 tent = new campfire_1(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
|
||||
tent.save();
|
||||
p.playEffect(location, Effect.STEP_SOUND, Material.WOOD);
|
||||
if(!p.getGameMode().equals(GameMode.CREATIVE)){
|
||||
is.setAmount(amount-1);
|
||||
p.getInventory().setItem(hand, is);
|
||||
p.updateInventory();
|
||||
}
|
||||
return;
|
||||
}else{
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
|
||||
return;
|
||||
@ -221,17 +209,11 @@ public class OnInteract implements Listener {
|
||||
}
|
||||
|
||||
if(saveIS.equals(main.getInstance().crafting.get("tent3"))){
|
||||
if(!p.hasPermission("furniture.tent3")){p.sendMessage(noPermissions);return;}
|
||||
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());
|
||||
tent_3 tent = new tent_3(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
|
||||
tent.save();
|
||||
p.playEffect(location, Effect.STEP_SOUND, Material.WOOL);
|
||||
if(!p.getGameMode().equals(GameMode.CREATIVE)){
|
||||
is.setAmount(amount-1);
|
||||
p.getInventory().setItem(hand, is);
|
||||
p.updateInventory();
|
||||
}
|
||||
return;
|
||||
}else{
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
|
||||
return;
|
||||
@ -239,17 +221,11 @@ public class OnInteract implements Listener {
|
||||
}
|
||||
|
||||
if(saveIS.equals(main.getInstance().crafting.get("barrels"))){
|
||||
if(!p.hasPermission("furniture.barrels")){p.sendMessage(noPermissions);return;}
|
||||
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());
|
||||
barrels tent = new barrels(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
|
||||
tent.save();
|
||||
p.playEffect(location, Effect.STEP_SOUND, Material.CAULDRON);
|
||||
if(!p.getGameMode().equals(GameMode.CREATIVE)){
|
||||
is.setAmount(amount-1);
|
||||
p.getInventory().setItem(hand, is);
|
||||
p.updateInventory();
|
||||
}
|
||||
return;
|
||||
}else{
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
|
||||
return;
|
||||
@ -257,17 +233,11 @@ public class OnInteract implements Listener {
|
||||
}
|
||||
|
||||
if(saveIS.equals(main.getInstance().crafting.get("campfire2"))){
|
||||
if(!p.hasPermission("furniture.campfire2")){p.sendMessage(noPermissions);return;}
|
||||
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());
|
||||
campfire_2 tent = new campfire_2(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
|
||||
tent.save();
|
||||
p.playEffect(location, Effect.STEP_SOUND, Material.WOOD);
|
||||
if(!p.getGameMode().equals(GameMode.CREATIVE)){
|
||||
is.setAmount(amount-1);
|
||||
p.getInventory().setItem(hand, is);
|
||||
p.updateInventory();
|
||||
}
|
||||
return;
|
||||
}else{
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.Space")));
|
||||
return;
|
||||
@ -275,22 +245,23 @@ public class OnInteract implements Listener {
|
||||
}
|
||||
|
||||
if(saveIS.equals(main.getInstance().crafting.get("camera"))){
|
||||
if(!p.hasPermission("furniture.camera")){p.sendMessage(noPermissions);return;}
|
||||
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());
|
||||
camera tent = new camera(location, main.getInstance(), main.createRandomRegistryId(), emptyList);
|
||||
tent.save();
|
||||
p.playEffect(location, Effect.STEP_SOUND, Material.WOOD);
|
||||
if(!p.getGameMode().equals(GameMode.CREATIVE)){
|
||||
is.setAmount(amount-1);
|
||||
p.getInventory().setItem(hand, is);
|
||||
p.updateInventory();
|
||||
}
|
||||
return;
|
||||
}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){
|
||||
|
30
src/de/Ste3et_C0st/Furniture/Main/FurnitureCreateEvent.java
Normal file
30
src/de/Ste3et_C0st/Furniture/Main/FurnitureCreateEvent.java
Normal file
@ -0,0 +1,30 @@
|
||||
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;}
|
||||
}
|
@ -44,7 +44,7 @@ public class FurnitureManager {
|
||||
if(largeTableList.isEmpty()){break;}
|
||||
List<largeTable> LLT = ((List<largeTable>) ((ArrayList<largeTable>) largeTableList).clone());
|
||||
for(largeTable s : LLT){s.delete(b,false);return true;}
|
||||
case LATERN:
|
||||
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;}
|
||||
|
@ -3,6 +3,7 @@ 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;
|
||||
@ -11,6 +12,8 @@ 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;
|
||||
@ -53,66 +56,81 @@ public class Manager {
|
||||
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);
|
||||
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);
|
||||
new camera(l, main.getInstance(), str, uuidList);
|
||||
}
|
||||
|
||||
if(s.equalsIgnoreCase("largeTable")){
|
||||
largeTable large = new largeTable(l, main.getInstance(), str);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
barrels fire = new barrels(l, main.getInstance(), str, uuidList);
|
||||
o.loadOptions(fc, fire);
|
||||
}
|
||||
}
|
||||
@ -129,10 +147,10 @@ public class Manager {
|
||||
if(!main.getInstance().getManager().chairList.isEmpty()){
|
||||
if(c==null){
|
||||
for(chair s : main.getInstance().getManager().chairList){
|
||||
save(s.getLocation(), "chair", s.getID());
|
||||
save(s.getLocation(), "chair", s.getID(),s.getList());
|
||||
}
|
||||
}else{
|
||||
save(c.getLocation(), "chair", c.getID());
|
||||
save(c.getLocation(), "chair", c.getID(), c.getList());
|
||||
}
|
||||
}
|
||||
cc.saveConfig("chair", fc, folder);
|
||||
@ -144,10 +162,10 @@ public class Manager {
|
||||
if(!main.getInstance().getManager().cameraList.isEmpty()){
|
||||
if(c==null){
|
||||
for(camera s : main.getInstance().getManager().cameraList){
|
||||
save(s.getLocation(), "camera", s.getID());
|
||||
save(s.getLocation(), "camera", s.getID(),s.getList());
|
||||
}
|
||||
}else{
|
||||
save(c.getLocation(), "camera", c.getID());
|
||||
save(c.getLocation(), "camera", c.getID(), c.getList());
|
||||
}
|
||||
}
|
||||
cc.saveConfig("camera", fc, folder);
|
||||
@ -160,11 +178,11 @@ public class Manager {
|
||||
if(!main.getInstance().getManager().lanternList.isEmpty()){
|
||||
if(l==null){
|
||||
for(latern s : main.getInstance().getManager().lanternList){
|
||||
save(s.getLocation(), "lantern", s.getID());
|
||||
save(s.getLocation(), "lantern", s.getID(),s.getList());
|
||||
o.saveOption(fc, s);
|
||||
}
|
||||
}else{
|
||||
save(l.getLocation(), "lantern", l.getID());
|
||||
save(l.getLocation(), "lantern", l.getID(), l.getList());
|
||||
o.saveOption(fc, l);
|
||||
}
|
||||
}
|
||||
@ -178,11 +196,11 @@ public class Manager {
|
||||
if(!main.getInstance().getManager().campfire1List.isEmpty()){
|
||||
if(l==null){
|
||||
for(campfire_1 s : main.getInstance().getManager().campfire1List){
|
||||
save(s.getLocation(), "campfire1", s.getID());
|
||||
save(s.getLocation(), "campfire1", s.getID(),s.getList());
|
||||
o.saveOption(fc, s);
|
||||
}
|
||||
}else{
|
||||
save(l.getLocation(), "campfire1", l.getID());
|
||||
save(l.getLocation(), "campfire1", l.getID(), l.getList());
|
||||
o.saveOption(fc, l);
|
||||
}
|
||||
}
|
||||
@ -196,18 +214,18 @@ public class Manager {
|
||||
if(!main.getInstance().getManager().campfire2List.isEmpty()){
|
||||
if(l==null){
|
||||
for(campfire_2 s : main.getInstance().getManager().campfire2List){
|
||||
save(s.getLocation(), "campfire2", s.getID());
|
||||
save(s.getLocation(), "campfire2", s.getID(),s.getList());
|
||||
o.saveOption(fc, s);
|
||||
}
|
||||
}else{
|
||||
save(l.getLocation(), "campfire2", l.getID());
|
||||
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){
|
||||
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));
|
||||
@ -215,6 +233,7 @@ public class Manager {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@ -227,11 +246,11 @@ public class Manager {
|
||||
if(!main.getInstance().getManager().sofaList.isEmpty()){
|
||||
if(sof==null){
|
||||
for(sofa s : main.getInstance().getManager().sofaList){
|
||||
save(s.getLocation(), "sofa", s.getID());
|
||||
save(s.getLocation(), "sofa", s.getID(),s.getList());
|
||||
o.saveOption(fc, s);
|
||||
}
|
||||
}else{
|
||||
save(sof.getLocation(), "sofa", sof.getID());
|
||||
save(sof.getLocation(), "sofa", sof.getID(), sof.getList());
|
||||
o.saveOption(fc, sof);
|
||||
}
|
||||
}
|
||||
@ -245,11 +264,11 @@ public class Manager {
|
||||
if(!main.getInstance().getManager().tableList.isEmpty()){
|
||||
if(t==null){
|
||||
for(table s : main.getInstance().getManager().tableList){
|
||||
save(s.getLocation(), "table", s.getID());
|
||||
save(s.getLocation(), "table", s.getID(),s.getList());
|
||||
o.saveOption(fc, s);
|
||||
}
|
||||
}else{
|
||||
save(t.getLocation(), "table", t.getID());
|
||||
save(t.getLocation(), "table", t.getID(), t.getList());
|
||||
o.saveOption(fc, t);
|
||||
}
|
||||
}
|
||||
@ -263,11 +282,11 @@ public class Manager {
|
||||
if(!main.getInstance().getManager().barrelList.isEmpty()){
|
||||
if(barrel==null){
|
||||
for(barrels s : main.getInstance().getManager().barrelList){
|
||||
save(s.getLocation(), "barrels", s.getID());
|
||||
save(s.getLocation(), "barrels", s.getID(),s.getList());
|
||||
o.saveOption(fc, s);
|
||||
}
|
||||
}else{
|
||||
save(barrel.getLocation(), "barrels", barrel.getID());
|
||||
save(barrel.getLocation(), "barrels", barrel.getID(), barrel.getList());
|
||||
o.saveOption(fc, barrel);
|
||||
}
|
||||
}
|
||||
@ -281,11 +300,11 @@ public class Manager {
|
||||
if(!main.getInstance().getManager().tent1List.isEmpty()){
|
||||
if(tent == null){
|
||||
for(tent_1 s : main.getInstance().getManager().tent1List){
|
||||
save(s.getLocation(), "tent1", s.getID());
|
||||
save(s.getLocation(), "tent1", s.getID(),s.getList());
|
||||
o.saveOption(fc, s);
|
||||
}
|
||||
}else{
|
||||
save(tent.getLocation(), "tent1", tent.getID());
|
||||
save(tent.getLocation(), "tent1", tent.getID(),tent.getList());
|
||||
o.saveOption(fc, tent);
|
||||
}
|
||||
|
||||
@ -300,11 +319,11 @@ public class Manager {
|
||||
if(!main.getInstance().getManager().largeTableList.isEmpty()){
|
||||
if(table == null){
|
||||
for(largeTable s : main.getInstance().getManager().largeTableList){
|
||||
save(s.getLocation(), "largeTable", s.getID());
|
||||
save(s.getLocation(), "largeTable", s.getID(),s.getList());
|
||||
o.saveOption(fc, s);
|
||||
}
|
||||
}else{
|
||||
save(table.getLocation(), "largeTable", table.getID());
|
||||
save(table.getLocation(), "largeTable", table.getID(),table.getList());
|
||||
o.saveOption(fc, table);
|
||||
}
|
||||
}
|
||||
@ -446,11 +465,11 @@ public class Manager {
|
||||
if(!main.getInstance().getManager().tent2List.isEmpty()){
|
||||
if(tent == null){
|
||||
for(tent_2 s : main.getInstance().getManager().tent2List){
|
||||
save(s.getLocation(), "tent2", s.getID());
|
||||
save(s.getLocation(), "tent2", s.getID(),s.getList());
|
||||
o.saveOption(fc, s);
|
||||
}
|
||||
}else{
|
||||
save(tent.getLocation(), "tent2", tent.getID());
|
||||
save(tent.getLocation(), "tent2", tent.getID(),tent.getList());
|
||||
o.saveOption(fc, tent);
|
||||
}
|
||||
|
||||
@ -465,11 +484,11 @@ public class Manager {
|
||||
if(!main.getInstance().getManager().tent3List.isEmpty()){
|
||||
if(tent == null){
|
||||
for(tent_3 s : main.getInstance().getManager().tent3List){
|
||||
save(s.getLocation(), "tent3", s.getID());
|
||||
save(s.getLocation(), "tent3", s.getID(),s.getList());
|
||||
o.saveOption(fc, s);
|
||||
}
|
||||
}else{
|
||||
save(tent.getLocation(), "tent3", tent.getID());
|
||||
save(tent.getLocation(), "tent3", tent.getID(),tent.getList());
|
||||
o.saveOption(fc, tent);
|
||||
}
|
||||
|
||||
|
16
src/de/Ste3et_C0st/Furniture/Main/Permissions.java
Normal file
16
src/de/Ste3et_C0st/Furniture/Main/Permissions.java
Normal file
@ -0,0 +1,16 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -3,8 +3,12 @@ package de.Ste3et_C0st.Furniture.Main;
|
||||
public class Type {
|
||||
|
||||
public enum FurnitureType{
|
||||
CHAIR, LARGE_TABLE, LATERN, SOFA,
|
||||
CHAIR, LARGE_TABLE, LANTERN, SOFA,
|
||||
TABLE, BARRELS, CAMPFIRE_1, CAMPFIRE_2,
|
||||
TENT_1, TENT_2, TENT_3, CAMERA
|
||||
};
|
||||
|
||||
public enum HeadArmType{
|
||||
HEAD, ARM
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
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;
|
||||
@ -15,13 +17,15 @@ 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];
|
||||
}
|
||||
@ -30,16 +34,71 @@ public class Utils {
|
||||
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 WEST: return -90;
|
||||
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();
|
||||
|
||||
@ -50,12 +109,108 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -146,6 +301,112 @@ public class Utils {
|
||||
}
|
||||
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();
|
||||
@ -174,18 +435,7 @@ public class Utils {
|
||||
return d;
|
||||
}
|
||||
|
||||
public static ArmorStand setArmorStand(Location location, EulerAngle angle, ItemStack is, Boolean Arm, Boolean mini, Boolean invisible, String ID, List<String> idList){
|
||||
World w = location.getWorld();
|
||||
String id = ID+"-"+idList.size();
|
||||
for(Entity entity : w.getEntities()){
|
||||
if(entity instanceof ArmorStand){
|
||||
if(entity.getCustomName()!=null&&entity.getCustomName().equals(id)){
|
||||
idList.add(id);
|
||||
return (ArmorStand) entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);}
|
||||
@ -198,20 +448,47 @@ public class Utils {
|
||||
as.setVisible(invisible);
|
||||
as.setGravity(false);
|
||||
as.setBasePlate(false);
|
||||
as.setCustomName(id);
|
||||
idList.add(id);
|
||||
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, String string){
|
||||
public static ArmorStand getArmorStandAtID(World w, UUID ids){
|
||||
for(Entity e : w.getEntities()){
|
||||
if(e instanceof ArmorStand){
|
||||
if(e!= null && e.getCustomName()!=null && e.getCustomName().equalsIgnoreCase(string)){
|
||||
if(e!= null && e.getUniqueId().equals(ids)){
|
||||
return (ArmorStand) e;
|
||||
}
|
||||
}
|
||||
@ -228,6 +505,16 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -179,6 +179,8 @@ public class command implements CommandExecutor {
|
||||
sender.sendMessage(noPermissions);
|
||||
return true;
|
||||
}
|
||||
}else if(args[0].equalsIgnoreCase("fixall")){
|
||||
|
||||
}else{
|
||||
sender.sendMessage(help);
|
||||
return true;
|
||||
@ -284,7 +286,7 @@ public class command implements CommandExecutor {
|
||||
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.LATERN;}
|
||||
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;}
|
||||
|
@ -7,6 +7,7 @@ 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;
|
||||
@ -17,6 +18,7 @@ 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.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import org.bukkit.util.Vector;
|
||||
@ -25,17 +27,20 @@ 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;
|
||||
|
||||
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;
|
||||
@ -43,10 +48,12 @@ public class main extends JavaPlugin {
|
||||
@Override
|
||||
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);
|
||||
@ -82,7 +89,22 @@ public class main extends JavaPlugin {
|
||||
mgr.defaultCrafting();
|
||||
addCrafting();
|
||||
|
||||
isCrafting = getConfig().getBoolean("config.CraftingPermissions");
|
||||
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){
|
||||
@ -94,7 +116,7 @@ public class main extends JavaPlugin {
|
||||
public void removeAll(){
|
||||
Fmgr.RemoveType(FurnitureType.CHAIR, false);
|
||||
Fmgr.RemoveType(FurnitureType.LARGE_TABLE, false);
|
||||
Fmgr.RemoveType(FurnitureType.LATERN, false);
|
||||
Fmgr.RemoveType(FurnitureType.LANTERN, false);
|
||||
Fmgr.RemoveType(FurnitureType.SOFA, false);
|
||||
Fmgr.RemoveType(FurnitureType.TABLE, false);
|
||||
Fmgr.RemoveType(FurnitureType.BARRELS, false);
|
||||
|
183
src/de/Ste3et_C0st/Furniture/Model/ModelCommand.java
Normal file
183
src/de/Ste3et_C0st/Furniture/Model/ModelCommand.java
Normal file
@ -0,0 +1,183 @@
|
||||
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;
|
||||
}
|
||||
}
|
30
src/de/Ste3et_C0st/Furniture/Model/ModelCreateEvent.java
Normal file
30
src/de/Ste3et_C0st/Furniture/Model/ModelCreateEvent.java
Normal file
@ -0,0 +1,30 @@
|
||||
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;}
|
||||
}
|
70
src/de/Ste3et_C0st/Furniture/Model/ModelCreator.java
Normal file
70
src/de/Ste3et_C0st/Furniture/Model/ModelCreator.java
Normal file
@ -0,0 +1,70 @@
|
||||
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);
|
||||
}
|
||||
}
|
89
src/de/Ste3et_C0st/Furniture/Model/ModelInventory.java
Normal file
89
src/de/Ste3et_C0st/Furniture/Model/ModelInventory.java
Normal file
@ -0,0 +1,89 @@
|
||||
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();
|
||||
}
|
||||
}
|
209
src/de/Ste3et_C0st/Furniture/Model/ModelListener.java
Normal file
209
src/de/Ste3et_C0st/Furniture/Model/ModelListener.java
Normal file
@ -0,0 +1,209 @@
|
||||
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);
|
||||
}
|
||||
}
|
42
src/de/Ste3et_C0st/Furniture/Model/ModelLoad.java
Normal file
42
src/de/Ste3et_C0st/Furniture/Model/ModelLoad.java
Normal file
@ -0,0 +1,42 @@
|
||||
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"));
|
||||
}
|
||||
}
|
||||
}
|
97
src/de/Ste3et_C0st/Furniture/Model/ModelManager.java
Normal file
97
src/de/Ste3et_C0st/Furniture/Model/ModelManager.java
Normal file
@ -0,0 +1,97 @@
|
||||
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);
|
||||
}
|
||||
}
|
53
src/de/Ste3et_C0st/Furniture/Model/ModelSave.java
Normal file
53
src/de/Ste3et_C0st/Furniture/Model/ModelSave.java
Normal file
@ -0,0 +1,53 @@
|
||||
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);
|
||||
}
|
||||
}
|
49
src/de/Ste3et_C0st/Furniture/Model/ModelTimer.java
Normal file
49
src/de/Ste3et_C0st/Furniture/Model/ModelTimer.java
Normal file
@ -0,0 +1,49 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
242
src/de/Ste3et_C0st/Furniture/Model/Modele.java
Normal file
242
src/de/Ste3et_C0st/Furniture/Model/Modele.java
Normal file
@ -0,0 +1,242 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ 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;
|
||||
@ -26,11 +27,14 @@ 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;
|
||||
|
||||
public class camera implements Listener {
|
||||
List<String> IDList = new ArrayList<String>();
|
||||
List<UUID> idList = new ArrayList<UUID>();
|
||||
Location loc = null;
|
||||
BlockFace b = null;
|
||||
World w = null;
|
||||
@ -39,14 +43,23 @@ public class camera implements Listener {
|
||||
public Location getLocation(){return this.loc;}
|
||||
public BlockFace getBlockFace(){return this.b;}
|
||||
|
||||
public camera(Location loc, Plugin plugin, String id){
|
||||
this.b = Utils.yawToFace(loc.getYaw());
|
||||
this.loc = loc.getBlock().getLocation();
|
||||
this.loc.setYaw(loc.getYaw());
|
||||
this.id = id;
|
||||
this.w = this.loc.getWorld();
|
||||
BlockFace b = Utils.yawToFace(loc.getYaw()).getOppositeFace();
|
||||
Location center = Utils.getCenter(loc);
|
||||
public camera(Location location, Plugin plugin, String ID, List<UUID> uuids){
|
||||
this.b = Utils.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);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
@ -64,27 +77,31 @@ public class camera implements Listener {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
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(e.getEntity().getName() == null){return;}
|
||||
if(!IDList.contains(e.getEntity().getCustomName())){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);
|
||||
@ -101,9 +118,8 @@ public class camera implements Listener {
|
||||
Player player = e.getPlayer();
|
||||
if(e.getRightClicked() == null){return;}
|
||||
if(e.getRightClicked() instanceof ArmorStand == false){return;}
|
||||
if(e.getRightClicked().getName() == null){return;}
|
||||
if(IDList==null||IDList.isEmpty()){return;}
|
||||
if(!IDList.contains(e.getRightClicked().getCustomName())){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());
|
||||
@ -126,8 +142,8 @@ 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(String ids : IDList){
|
||||
if(idList!=null&&!idList.isEmpty()){
|
||||
for(UUID ids : idList){
|
||||
if(ids==null){continue;}
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, ids);
|
||||
if(as!=null){
|
||||
@ -139,7 +155,7 @@ public class camera implements Listener {
|
||||
}
|
||||
}
|
||||
this.loc = null;
|
||||
IDList.clear();
|
||||
idList.clear();
|
||||
main.getInstance().getManager().cameraList.remove(this);
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,9 @@ 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;
|
||||
@ -21,12 +23,15 @@ 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;
|
||||
|
||||
public class chair implements Listener {
|
||||
|
||||
List<String> IDList = new ArrayList<String>();
|
||||
List<UUID> idList = new ArrayList<UUID>();
|
||||
Location loc = null;
|
||||
BlockFace b = null;
|
||||
World w = null;
|
||||
@ -35,12 +40,21 @@ public class chair implements Listener {
|
||||
public Location getLocation(){return this.loc;}
|
||||
public BlockFace getBlockFace(){return this.b;}
|
||||
|
||||
public chair(Location loc, Plugin plugin, String id){
|
||||
this.b = Utils.yawToFace(loc.getYaw());
|
||||
this.loc = loc.getBlock().getLocation();
|
||||
this.loc.setYaw(loc.getYaw());
|
||||
this.id = id;
|
||||
this.w = this.loc.getWorld();
|
||||
public chair(Location location, Plugin plugin, String ID, List<UUID> uuids){
|
||||
this.b = Utils.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);
|
||||
}
|
||||
}
|
||||
|
||||
public void spawn(List<UUID> uuidList, Location location, Plugin plugin){
|
||||
BlockFace b = Utils.yawToFace(loc.getYaw()).getOppositeFace();
|
||||
Location center = Utils.getCenter(loc);
|
||||
Location sitz = new Location(center.getWorld(), center.getX(), center.getY(), center.getZ());
|
||||
@ -58,13 +72,13 @@ public class chair implements Listener {
|
||||
sitz.setYaw(Utils.FaceToYaw(b));
|
||||
lehne.setYaw(Utils.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);
|
||||
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);
|
||||
}
|
||||
@ -73,6 +87,10 @@ public class chair implements Listener {
|
||||
main.getInstance().mgr.saveStuhl(this);
|
||||
}
|
||||
|
||||
public List<String> getList(){
|
||||
return Utils.UUIDListToStringList(idList);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWaterFlow(BlockFromToEvent e){
|
||||
Location locTo = e.getToBlock().getLocation();
|
||||
@ -96,8 +114,8 @@ public class chair implements Listener {
|
||||
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(String ids : IDList){
|
||||
if(idList!=null&&!idList.isEmpty()){
|
||||
for(UUID ids : idList){
|
||||
if(ids==null){continue;}
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, ids);
|
||||
if(as!=null){
|
||||
@ -109,19 +127,19 @@ public class chair implements Listener {
|
||||
}
|
||||
}
|
||||
this.loc = null;
|
||||
IDList.clear();
|
||||
idList.clear();
|
||||
main.getInstance().getManager().chairList.remove(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@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().getName() == null){return;}
|
||||
if(!IDList.contains(e.getEntity().getCustomName())){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);
|
||||
@ -133,10 +151,9 @@ public class chair implements Listener {
|
||||
Player player = e.getPlayer();
|
||||
if(e.getRightClicked() == null){return;}
|
||||
if(e.getRightClicked() instanceof ArmorStand == false){return;}
|
||||
if(e.getRightClicked().getName() == null){return;}
|
||||
if(IDList==null||IDList.isEmpty()){return;}
|
||||
if(!IDList.contains(e.getRightClicked().getCustomName())){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);
|
||||
Utils.getArmorStandAtID(w, idList.get(6)).setPassenger(player);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,9 @@ 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;
|
||||
@ -22,13 +24,16 @@ 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;
|
||||
|
||||
public class largeTable implements Listener {
|
||||
|
||||
private List<String> idList = new ArrayList<String>();
|
||||
private List<String> tellerIDS = new ArrayList<String>();
|
||||
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;
|
||||
@ -37,13 +42,22 @@ public class largeTable implements Listener {
|
||||
public Location getLocation(){return this.loc;}
|
||||
public BlockFace getBlockFace(){return this.b;}
|
||||
|
||||
public largeTable(Location loc, Plugin plugin, String id){
|
||||
List<ArmorStand> armorlist = new ArrayList<ArmorStand>();
|
||||
this.loc = loc;
|
||||
this.b = Utils.yawToFace(loc.getYaw());
|
||||
this.id = id;
|
||||
this.w = loc.getWorld();
|
||||
public largeTable(Location location, Plugin plugin, String ID, List<UUID> uuids){
|
||||
this.loc = location;
|
||||
this.b = Utils.yawToFace(location.getYaw());
|
||||
this.id = ID;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
@ -111,18 +125,22 @@ public class largeTable implements Listener {
|
||||
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.getCustomName());
|
||||
tellerIDS.add(as2.getCustomName());
|
||||
tellerIDS.add(as3.getCustomName());
|
||||
tellerIDS.add(as4.getCustomName());
|
||||
tellerIDS.add(as1.getUniqueId());
|
||||
tellerIDS.add(as2.getUniqueId());
|
||||
tellerIDS.add(as3.getUniqueId());
|
||||
tellerIDS.add(as4.getUniqueId());
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
main.getInstance().getManager().largeTableList.add(this);
|
||||
}
|
||||
|
||||
public List<String> getList(){
|
||||
return Utils.UUIDListToStringList(idList);
|
||||
}
|
||||
|
||||
public void setTeller(HashMap<Integer, ItemStack> itemList){
|
||||
int i = 0;
|
||||
for(String id : tellerIDS){
|
||||
for(UUID id : tellerIDS){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, id);
|
||||
as.setItemInHand(itemList.get(i));
|
||||
i++;
|
||||
@ -131,7 +149,7 @@ public class largeTable implements Listener {
|
||||
|
||||
public void setColor(HashMap<Integer, Short> durabilityList){
|
||||
int i = 0;
|
||||
for(String id: idList){
|
||||
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();
|
||||
@ -146,7 +164,7 @@ public class largeTable implements Listener {
|
||||
HashMap<Integer, Short> colorList = new HashMap<Integer, Short>();
|
||||
Integer i = 0;
|
||||
|
||||
for(String id: idList){
|
||||
for(UUID id: idList){
|
||||
try{i=colorList.size();}catch(Exception e){return colorList;}
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, id);
|
||||
if(as!=null){
|
||||
@ -162,7 +180,7 @@ public class largeTable implements Listener {
|
||||
public void delete(boolean b, boolean a){
|
||||
if(b){
|
||||
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("largeTable"));}
|
||||
for(String s : tellerIDS){
|
||||
for(UUID s : tellerIDS){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as!=null){
|
||||
if(as.getItemInHand()!=null&&!as.getItemInHand().getType().equals(Material.AIR)){
|
||||
@ -171,7 +189,7 @@ public class largeTable implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
for(String s : this.idList){
|
||||
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());}
|
||||
@ -186,14 +204,14 @@ public class largeTable implements Listener {
|
||||
main.getInstance().getManager().largeTableList.remove(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@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().getCustomName())){return;}
|
||||
if(!this.idList.contains(e.getRightClicked().getUniqueId())){return;}
|
||||
e.setCancelled(true);
|
||||
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
|
||||
ItemStack is = player.getItemInHand();
|
||||
@ -203,7 +221,7 @@ public class largeTable implements Listener {
|
||||
Integer amount = is.getAmount();
|
||||
if(amount>this.idList.size()-4 || player.getGameMode().equals(GameMode.CREATIVE)){amount=this.idList.size()-4;}
|
||||
List<Entity> list = new ArrayList<Entity>();
|
||||
for(String s : this.idList){
|
||||
for(UUID s : this.idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as!=null){
|
||||
ItemStack item = as.getHelmet();
|
||||
@ -232,7 +250,7 @@ public class largeTable implements Listener {
|
||||
BlockFace b = Utils.yawToFace(player.getLocation().getYaw());
|
||||
ArmorStand as = null;
|
||||
if(tellerIDS == null || tellerIDS.isEmpty()){return;}
|
||||
for(String s : this.tellerIDS){
|
||||
for(UUID s : this.tellerIDS){
|
||||
if(s!=null){
|
||||
ArmorStand armorStand = Utils.getArmorStandAtID(w, s);
|
||||
if(armorStand!=null){
|
||||
@ -244,11 +262,10 @@ public class largeTable implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
||||
if(!player.getGameMode().equals(GameMode.CREATIVE)){player.getInventory().remove(is);player.updateInventory();}
|
||||
player.updateInventory();
|
||||
}
|
||||
main.getInstance().mgr.saveLargeTable(this);
|
||||
@ -259,15 +276,15 @@ public class largeTable implements Listener {
|
||||
main.getInstance().mgr.saveLargeTable(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@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().getName() == null){return;}
|
||||
if(!idList.contains(e.getEntity().getCustomName())){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);
|
||||
@ -275,7 +292,7 @@ public class largeTable implements Listener {
|
||||
|
||||
public HashMap<Integer, ItemStack> getTeller(){
|
||||
HashMap<Integer, ItemStack> teller = new HashMap<Integer, ItemStack>();
|
||||
for(String s : tellerIDS){
|
||||
for(UUID s : tellerIDS){
|
||||
try{
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
teller.put(teller.size(), as.getItemInHand());
|
||||
|
@ -2,6 +2,7 @@ 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;
|
||||
@ -23,11 +24,14 @@ 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;
|
||||
|
||||
public class latern implements Listener {
|
||||
private List<String> idList = new ArrayList<String>();
|
||||
private List<UUID> idList = new ArrayList<UUID>();
|
||||
private Block b;
|
||||
private Location loc = null;
|
||||
private BlockFace bFace = null;
|
||||
@ -37,32 +41,46 @@ public class latern implements Listener {
|
||||
public Location getLocation(){return this.loc;}
|
||||
public BlockFace getBlockFace(){return this.bFace;}
|
||||
|
||||
public latern(Location loc, Plugin plugin, String id){
|
||||
this.loc = loc;
|
||||
this.id = id;
|
||||
this.bFace = Utils.yawToFace(loc.getYaw());
|
||||
this.w = loc.getWorld();
|
||||
Location center = Utils.getCenter(loc);
|
||||
b = center.getWorld().getBlockAt(center);
|
||||
b.setType(Material.TORCH);
|
||||
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();
|
||||
|
||||
Location obsidian = center;
|
||||
Location location = new Location(center.getWorld(), center.getX(), center.getY() -1.43, center.getZ());
|
||||
obsidian.add(0D, -2.2, 0D);
|
||||
Location left_down = new Location(obsidian.getWorld(), obsidian.getX()+0.22, obsidian.getY() + .62, obsidian.getZ()+0.22);
|
||||
Location left_upper = new Location(obsidian.getWorld(), obsidian.getX() -0.21, obsidian.getY() + .62, obsidian.getZ() +0.22);
|
||||
Location right_upper = new Location(obsidian.getWorld(), obsidian.getX()-0.21, obsidian.getY()+.62, obsidian.getZ()-0.21);
|
||||
Location right_down = new Location(obsidian.getWorld(), obsidian.getX()+0.21, obsidian.getY() + .62, obsidian.getZ() -0.21);
|
||||
|
||||
Utils.setArmorStand(obsidian, null, new ItemStack(Material.OBSIDIAN), false,false,false,getID(),idList);
|
||||
Utils.setArmorStand(location.add(0,0,0), null, new ItemStack(Material.WOOD_PLATE), false,false,false,getID(), idList);
|
||||
|
||||
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);
|
||||
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 void spawn(List<UUID> uuidList, Location location, Plugin plugin){
|
||||
Location center = Utils.getCenter(getLocation());
|
||||
b = center.getWorld().getBlockAt(center);
|
||||
b.setType(Material.TORCH);
|
||||
|
||||
Location obsidian = center;
|
||||
Location l = new Location(center.getWorld(), center.getX(), center.getY() -1.43, center.getZ());
|
||||
obsidian.add(0D, -2.2, 0D);
|
||||
Location left_down = new Location(obsidian.getWorld(), obsidian.getX()+0.22, obsidian.getY() + .62, obsidian.getZ()+0.22);
|
||||
Location left_upper = new Location(obsidian.getWorld(), obsidian.getX() -0.21, obsidian.getY() + .62, obsidian.getZ() +0.22);
|
||||
Location right_upper = new Location(obsidian.getWorld(), obsidian.getX()-0.21, obsidian.getY()+.62, obsidian.getZ()-0.21);
|
||||
Location right_down = new Location(obsidian.getWorld(), obsidian.getX()+0.21, obsidian.getY() + .62, obsidian.getZ() -0.21);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public List<String> getList(){
|
||||
return Utils.UUIDListToStringList(idList);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -76,7 +94,7 @@ 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(String s : idList){
|
||||
for(UUID s : idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w,s);
|
||||
if(as!=null){
|
||||
as.getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
|
||||
@ -100,14 +118,14 @@ public class latern implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@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().getName())){return;}
|
||||
if(!this.idList.contains(e.getRightClicked().getUniqueId())){return;}
|
||||
e.setCancelled(true);
|
||||
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
|
||||
ItemStack is = player.getItemInHand();
|
||||
@ -125,15 +143,16 @@ public class latern implements Listener {
|
||||
main.getInstance().mgr.saveLatern(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@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().getName() == null){return;}
|
||||
if(!idList.contains(e.getEntity().getCustomName())){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);
|
||||
|
@ -3,7 +3,9 @@ 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;
|
||||
@ -22,12 +24,15 @@ 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;
|
||||
|
||||
public class sofa implements Listener {
|
||||
private List<String> idList = new ArrayList<String>();
|
||||
private List<String> sitzList = new ArrayList<String>();
|
||||
private List<UUID> idList = new ArrayList<UUID>();
|
||||
private List<UUID> sitzList = new ArrayList<UUID>();
|
||||
private ItemStack is;
|
||||
private Double place;
|
||||
private BlockFace b;
|
||||
@ -39,30 +44,39 @@ public class sofa implements Listener {
|
||||
public Location getLocation(){return this.loc;}
|
||||
public BlockFace getBlockFace(){return this.b;}
|
||||
|
||||
public sofa(Location loc, Plugin plugin, String id){
|
||||
Integer lengt = 3;
|
||||
List<Entity> sitz = new ArrayList<Entity>();
|
||||
this.w = loc.getWorld();
|
||||
this.loc = loc.getBlock().getLocation();
|
||||
this.loc.setYaw(loc.getYaw());
|
||||
public sofa(Location location, Plugin plugin, String ID, List<UUID> uuids){
|
||||
this.w = location.getWorld();
|
||||
this.loc = location.getBlock().getLocation();
|
||||
this.loc.setYaw(location.getYaw());
|
||||
this.place = 0.2;
|
||||
this.id = id;
|
||||
this.b = Utils.yawToFace(loc.getYaw());
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public void spawn(List<UUID> uuidList, Location location, Plugin plugin){
|
||||
List<Entity> sitz = new ArrayList<Entity>();
|
||||
Integer lengt = 3;
|
||||
is = new ItemStack(Material.CARPET);
|
||||
is.setDurability(color);
|
||||
BlockFace b = Utils.yawToFace(loc.getYaw()).getOppositeFace();
|
||||
BlockFace b = Utils.yawToFace(location.getYaw()).getOppositeFace();
|
||||
|
||||
Integer x = (int) loc.getX();
|
||||
Integer y = (int) loc.getY();
|
||||
Integer z = (int) loc.getZ();
|
||||
loc.setX(x);
|
||||
loc.setY(y);
|
||||
loc.setZ(z);
|
||||
Integer x = (int) location.getX();
|
||||
Integer y = (int) location.getY();
|
||||
Integer z = (int) location.getZ();
|
||||
location.setX(x);
|
||||
location.setY(y);
|
||||
location.setZ(z);
|
||||
|
||||
if(b.equals(BlockFace.WEST)){loc = main.getNew(loc, b, .0, -1.0);}
|
||||
if(b.equals(BlockFace.SOUTH)){loc = main.getNew(loc, b, -1.0, -1.0);}
|
||||
if(b.equals(BlockFace.EAST)){loc = main.getNew(loc, b, -1.0, .0);}
|
||||
Location looking = new Location(loc.getWorld(), loc.getBlockX(), loc.getBlockY() -1.4 , loc.getBlockZ());
|
||||
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);
|
||||
@ -73,7 +87,7 @@ public class sofa implements Listener {
|
||||
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(), loc.getBlockX(), loc.getBlockY() -1 , loc.getBlockZ());
|
||||
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);
|
||||
Double d = .02;
|
||||
@ -84,11 +98,10 @@ public class sofa implements Listener {
|
||||
ArmorStand as = null;
|
||||
as = Utils.setArmorStand(carpet, null, is, false,false,false,getID(),idList);
|
||||
sitz.add(as);
|
||||
|
||||
//OBERER TEIL
|
||||
Location location = main.getNew(carpetHight, b, place-.25,(double) d);
|
||||
location.setYaw(facing);
|
||||
Utils.setArmorStand(location, new EulerAngle(1.57, .0, .0), is, false,false,false,getID(),idList);
|
||||
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);
|
||||
if(d<=0D){d = 0.00;}
|
||||
d+=.58;
|
||||
}
|
||||
@ -97,7 +110,7 @@ public class sofa implements Listener {
|
||||
Float yaw2= facing;
|
||||
Location last = main.getNew(sitz.get(sitz.size()-1).getLocation(), b, 0D, 0.26D);
|
||||
last.setYaw(yaw1+90);
|
||||
Location first = main.getNew(new Location(loc.getWorld(), loc.getX(), last.getY(), loc.getZ()), b, place+.25, 0.07D);
|
||||
Location first = main.getNew(new Location(location.getWorld(), location.getX(), last.getY(), location.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);
|
||||
@ -105,23 +118,29 @@ public class sofa implements Listener {
|
||||
|
||||
Location start = main.getNew(looking, b, .45, .55);
|
||||
for(int i = 0; i<=2;i++){
|
||||
Location location = main.getNew(start, b, 0D, i*.95D);
|
||||
location.setYaw(Utils.FaceToYaw(b));
|
||||
location.add(0,.2,0);
|
||||
ArmorStand as = Utils.setArmorStand(location, null, null, false, false, false, getID(), idList);
|
||||
sitzList.add(as.getName());
|
||||
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());
|
||||
}
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
main.getInstance().getManager().sofaList.add(this);
|
||||
|
||||
}
|
||||
|
||||
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(String id: idList){
|
||||
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)){
|
||||
@ -138,7 +157,7 @@ public class sofa implements Listener {
|
||||
HashMap<Integer, Short> colorList = new HashMap<Integer, Short>();
|
||||
Integer i = 0;
|
||||
|
||||
for(String id: idList){
|
||||
for(UUID id: idList){
|
||||
try{i=colorList.size();}catch(Exception e){return colorList;}
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, id);
|
||||
if(as!=null){
|
||||
@ -155,7 +174,7 @@ public class sofa implements Listener {
|
||||
if(b){
|
||||
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("sofa"));}
|
||||
|
||||
for(String s : idList){
|
||||
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());}
|
||||
@ -176,7 +195,6 @@ public class sofa implements Listener {
|
||||
if(e.getRightClicked()==null){return;}
|
||||
if(e.getRightClicked() instanceof ArmorStand == false){return;}
|
||||
if(idList==null||idList.isEmpty()){return;}
|
||||
if(!idList.contains(e.getRightClicked().getCustomName())){return;}
|
||||
e.setCancelled(true);
|
||||
ItemStack is = player.getItemInHand();
|
||||
if(is!=null){
|
||||
@ -186,7 +204,7 @@ public class sofa implements Listener {
|
||||
Integer amount = is.getAmount();
|
||||
if(amount>idList.size() || player.getGameMode().equals(GameMode.CREATIVE)){amount=idList.size();}
|
||||
List<Entity> list = new ArrayList<Entity>();
|
||||
for(String s : idList){
|
||||
for(UUID s : idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as.getHelmet().getType().equals(Material.CARPET)){
|
||||
ItemStack item = as.getHelmet();
|
||||
@ -216,7 +234,7 @@ public class sofa implements Listener {
|
||||
}
|
||||
|
||||
Integer intSitz = Utils.randInt(0, 2);
|
||||
for(String s : sitzList){
|
||||
for(UUID s : sitzList){
|
||||
if(s==null){return;}
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as==null){return;}
|
||||
@ -230,7 +248,7 @@ public class sofa implements Listener {
|
||||
}
|
||||
|
||||
public boolean checkIfEmpty(){
|
||||
for(String id : idList){
|
||||
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)){
|
||||
@ -243,15 +261,16 @@ public class sofa implements Listener {
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@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().getName() == null){return;}
|
||||
if(!idList.contains(e.getEntity().getCustomName())){return;}
|
||||
if(e.getEntity().getUniqueId() == 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);
|
||||
|
@ -2,7 +2,9 @@ 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;
|
||||
@ -20,12 +22,15 @@ 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;
|
||||
|
||||
public class table implements Listener {
|
||||
|
||||
private List<String> idList = new ArrayList<String>();
|
||||
private List<UUID> idList = new ArrayList<UUID>();
|
||||
private ArmorStand armor;
|
||||
private ItemStack is = null;
|
||||
private Location loc = null;
|
||||
@ -37,37 +42,49 @@ public class table implements Listener {
|
||||
public ItemStack getItemStack(){return this.is;}
|
||||
public BlockFace getBlockFace(){return this.b;}
|
||||
|
||||
public table(Location loc, Plugin plugin, String id){
|
||||
this.loc = loc.getBlock().getLocation();
|
||||
this.id = id;
|
||||
this.b = Utils.yawToFace(loc.getYaw());
|
||||
this.w = loc.getWorld();
|
||||
Location middle1 = Utils.getCenter(loc);
|
||||
Location middle2 = Utils.getCenter(loc);
|
||||
public table(Location location, Plugin plugin, String ID, List<UUID> uuids){
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
loc.setYaw(0);
|
||||
ArmorStand as = Utils.setArmorStand(loc.add(.9,0.15,0.3),new EulerAngle(0,.0,.0), is, true,false,false,getID(),idList);
|
||||
Utils.setArmorStand(loc.add(0,-.65,.68),new EulerAngle(1.38,.0,.0), new ItemStack(Material.STICK), true,false,false,getID(),idList);
|
||||
Location l = getLocation();
|
||||
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);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
private void onInteract(PlayerInteractAtEntityEvent e){
|
||||
if(e.isCancelled()){return;}
|
||||
Player player = e.getPlayer();
|
||||
if(e.getRightClicked().getName()==null){return;}
|
||||
if(e.getRightClicked() instanceof ArmorStand == false){return;}
|
||||
if(idList==null||idList.isEmpty()){return;}
|
||||
if(!idList.contains(e.getRightClicked().getCustomName())){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(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;
|
||||
@ -77,6 +94,10 @@ public class table implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
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"));}
|
||||
@ -88,7 +109,7 @@ public class table implements Listener {
|
||||
}
|
||||
|
||||
}
|
||||
for(String s : idList){
|
||||
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());}
|
||||
@ -104,15 +125,15 @@ public class table implements Listener {
|
||||
main.getInstance().getManager().tableList.remove(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@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().getName() == null){return;}
|
||||
if(!idList.contains(e.getEntity().getCustomName())){return;}
|
||||
if(!idList.contains(e.getEntity().getUniqueId())){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);
|
||||
|
@ -2,7 +2,9 @@ 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;
|
||||
@ -21,9 +23,12 @@ 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;
|
||||
|
||||
public class barrels implements Listener {
|
||||
|
||||
@ -32,21 +37,30 @@ public class barrels implements Listener {
|
||||
private ArmorStand as;
|
||||
private Block block;
|
||||
private String id;
|
||||
private List<String> idList = new ArrayList<String>();
|
||||
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 loc, Plugin plugin, String ID){
|
||||
public barrels(Location location, Plugin plugin, String ID, List<UUID> uuids){
|
||||
this.id = ID;
|
||||
this.loc = loc.getBlock().getLocation();
|
||||
this.loc.setYaw(loc.getYaw());
|
||||
this.b = Utils.yawToFace(loc.getYaw());
|
||||
this.loc = location.getBlock().getLocation();
|
||||
this.loc.setYaw(location.getYaw());
|
||||
this.b = Utils.yawToFace(location.getYaw());
|
||||
|
||||
this.block = loc.getBlock();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public void spawn(List<UUID> uuidList, Location location, Plugin plugin){
|
||||
this.block = location.getBlock();
|
||||
this.block.setType(Material.CAULDRON);
|
||||
|
||||
this.as = Utils.setArmorStand(Utils.getCenter(loc).add(0,-1.5,0), null, null, false, false, false, ID, idList);
|
||||
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);
|
||||
@ -64,6 +78,10 @@ public class barrels implements Listener {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<String> getList(){
|
||||
return Utils.UUIDListToStringList(idList);
|
||||
}
|
||||
|
||||
public void setItemstack(ItemStack is){
|
||||
if(is==null){return;}
|
||||
this.as.setHelmet(is);
|
||||
@ -90,25 +108,26 @@ public class barrels implements Listener {
|
||||
main.getInstance().getManager().barrelList.remove(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@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().getName() == null){return;}
|
||||
if(!idList.contains(e.getEntity().getCustomName())){return;}
|
||||
if(!idList.contains(e.getEntity().getUniqueId())){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.NORMAL)
|
||||
@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);
|
||||
}
|
||||
}
|
||||
@ -125,19 +144,20 @@ public class barrels implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@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().getCustomName())){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);}
|
||||
@ -147,7 +167,7 @@ public class barrels implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
private void onInteract(PlayerInteractEvent e){
|
||||
if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
|
||||
if(block!=null&&e.getClickedBlock()!=null&&e.getClickedBlock().equals(block)){
|
||||
@ -157,6 +177,7 @@ public class barrels implements Listener {
|
||||
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);}
|
||||
|
@ -2,7 +2,9 @@ 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;
|
||||
@ -21,27 +23,39 @@ 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;
|
||||
|
||||
public class campfire_1 implements Listener {
|
||||
|
||||
private Location loc;
|
||||
private String ID;
|
||||
private BlockFace b;
|
||||
private List<String> idList = new ArrayList<String>();
|
||||
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 campfire_1(Location location, Plugin plugin, String ID) {
|
||||
public campfire_1(Location location, Plugin plugin, String ID, List<UUID> uuids){
|
||||
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);
|
||||
@ -52,25 +66,29 @@ public class campfire_1 implements Listener {
|
||||
main.getInstance().getManager().campfire1List.add(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@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().getName() == null){return;}
|
||||
if(!idList.contains(e.getEntity().getCustomName())){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(String s : idList){
|
||||
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);}
|
||||
@ -87,12 +105,12 @@ public class campfire_1 implements Listener {
|
||||
main.getInstance().mgr.saveCampFire1(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@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().getName())){
|
||||
if(this.idList.contains(e.getRightClicked().getUniqueId())){
|
||||
e.setCancelled(true);
|
||||
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
|
||||
ItemStack is = player.getItemInHand();
|
||||
@ -111,7 +129,7 @@ public class campfire_1 implements Listener {
|
||||
@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().getCustomName())){
|
||||
if(idList.contains(e.getEntity().getUniqueId())){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -119,7 +137,7 @@ public class campfire_1 implements Listener {
|
||||
@SuppressWarnings("static-access")
|
||||
public void setLight(boolean boolean1, boolean a) {
|
||||
Location light = new Location(w, getLocation().getX(), getLocation().getY(), getLocation().getZ());
|
||||
for(String s : idList){
|
||||
for(UUID s : idList){
|
||||
if(Utils.getArmorStandAtID(w, s) != null){
|
||||
setFire(Utils.getArmorStandAtID(w, s), boolean1);
|
||||
}
|
||||
@ -139,7 +157,7 @@ public class campfire_1 implements Listener {
|
||||
}
|
||||
|
||||
public boolean getFire(){
|
||||
for(String s : idList){
|
||||
for(UUID s : idList){
|
||||
if(Utils.getArmorStandAtID(w, s) != null){
|
||||
if(Utils.getArmorStandAtID(w, s).getFireTicks()>=1){
|
||||
return true;
|
||||
|
@ -3,6 +3,7 @@ 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;
|
||||
@ -24,8 +25,11 @@ 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;
|
||||
|
||||
public class campfire_2 implements Listener {
|
||||
|
||||
@ -33,8 +37,8 @@ public class campfire_2 implements Listener {
|
||||
private Location l;
|
||||
private String ID;
|
||||
private BlockFace b;
|
||||
private List<String> idList = new ArrayList<String>();
|
||||
private List<String> fire = new ArrayList<String>();
|
||||
private List<UUID> idList = new ArrayList<UUID>();
|
||||
private List<UUID> fire = new ArrayList<UUID>();
|
||||
private List<Material> items = new ArrayList<Material>(
|
||||
Arrays.asList(
|
||||
Material.RAW_BEEF,
|
||||
@ -71,13 +75,26 @@ public class campfire_2 implements Listener {
|
||||
|
||||
};
|
||||
|
||||
public campfire_2(Location location, Plugin plugin, String ID) {
|
||||
public campfire_2(Location location, Plugin plugin, String ID, List<UUID> uuids) {
|
||||
this.loc = location.getBlock().getLocation();
|
||||
this.ID = ID;
|
||||
this.b = Utils.yawToFace(location.getYaw());
|
||||
this.w = loc.getWorld();
|
||||
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);
|
||||
middle.add(0,-1.2,0);
|
||||
@ -121,16 +138,16 @@ public class campfire_2 implements Listener {
|
||||
this.l = grill;
|
||||
|
||||
ArmorStand as = Utils.setArmorStand(middle.add(0,-1.3,0), null, null, false, true, false, ID, idList);
|
||||
fire.add(as.getName());
|
||||
fire.add(as.getUniqueId());
|
||||
|
||||
main.getInstance().getManager().campfire2List.add(this);
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@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&&e.getEntity().getName()!=null&&fire.contains(e.getEntity().getName())){
|
||||
if(fire!=null&&fire.contains(e.getEntity().getUniqueId())){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -138,7 +155,7 @@ public class campfire_2 implements Listener {
|
||||
|
||||
public boolean isFire(){
|
||||
if(fire==null){return false;}
|
||||
for(String s : fire){
|
||||
for(UUID s : fire){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as==null){return false;}
|
||||
if(as.getFireTicks()>0){return true;}
|
||||
@ -150,7 +167,7 @@ public class campfire_2 implements Listener {
|
||||
public void setLight(Boolean b, Boolean a){
|
||||
if(b){
|
||||
if(fire==null){return;}
|
||||
for(String s : fire){
|
||||
for(UUID s : fire){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as==null){return;}
|
||||
as.setFireTicks(Integer.MAX_VALUE);
|
||||
@ -162,7 +179,7 @@ public class campfire_2 implements Listener {
|
||||
w.playSound(getLocation(), Sound.FIRE_IGNITE, 1, 1);
|
||||
}else{
|
||||
if(fire==null){return;}
|
||||
for(String s : fire){
|
||||
for(UUID s : fire){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as==null){return;}
|
||||
as.setFireTicks(0);
|
||||
@ -186,7 +203,7 @@ public class campfire_2 implements Listener {
|
||||
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("campfire2"));}
|
||||
|
||||
main.getInstance().mgr.deleteFromConfig(getID(), "campfire2");
|
||||
for(String s : idList){
|
||||
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);}
|
||||
@ -201,12 +218,12 @@ public class campfire_2 implements Listener {
|
||||
main.getInstance().getManager().campfire2List.remove(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
private void onInteract(PlayerInteractAtEntityEvent e){
|
||||
if(e.isCancelled()){return;}
|
||||
Player player = e.getPlayer();
|
||||
if(e.getRightClicked() instanceof ArmorStand){
|
||||
if(idList.contains(e.getRightClicked().getCustomName())){
|
||||
if(idList.contains(e.getRightClicked().getUniqueId())){
|
||||
e.setCancelled(true);
|
||||
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
|
||||
ItemStack is = player.getItemInHand();
|
||||
@ -230,15 +247,15 @@ public class campfire_2 implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@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().getName() == null){return;}
|
||||
if(!idList.contains(e.getEntity().getCustomName())){return;}
|
||||
if(!idList.contains(e.getEntity().getUniqueId())){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);
|
||||
|
@ -3,7 +3,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;
|
||||
@ -23,8 +25,12 @@ 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;
|
||||
|
||||
public class tent_1 implements Listener {
|
||||
|
||||
@ -32,16 +38,16 @@ public class tent_1 implements Listener {
|
||||
private String ID;
|
||||
private BlockFace b;
|
||||
private Block block;
|
||||
private List<String> idList = new ArrayList<String>();
|
||||
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 tent_1(Location location, Plugin plugin, String ID) {
|
||||
public tent_1(Location location, Plugin plugin, String ID, List<UUID> uuids) {
|
||||
this.loc = new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
this.loc.setYaw(location.getYaw());
|
||||
this.w = loc.getWorld();
|
||||
this.w = location.getWorld();
|
||||
BlockFace b = Utils.yawToFace(location.getYaw());
|
||||
|
||||
if(b.equals(BlockFace.WEST)){location=main.getNew(location, b, 1D, 0D);}
|
||||
@ -52,6 +58,19 @@ public class tent_1 implements Listener {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
@ -178,6 +197,7 @@ public class tent_1 implements Listener {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -192,7 +212,7 @@ public class tent_1 implements Listener {
|
||||
if(a){
|
||||
getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("tent1"));
|
||||
}
|
||||
for(String s : idList){
|
||||
for(UUID s : idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as!=null){
|
||||
if(a){
|
||||
@ -207,27 +227,26 @@ public class tent_1 implements Listener {
|
||||
main.getInstance().getManager().tent1List.remove(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@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().getName() == null){return;}
|
||||
if(!idList.contains(e.getEntity().getCustomName())){return;}
|
||||
if(!idList.contains(e.getEntity().getUniqueId())){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);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
private void onInteract(PlayerInteractAtEntityEvent e){
|
||||
if(e.isCancelled()){return;}
|
||||
Player player = e.getPlayer();
|
||||
if(e.getRightClicked().getName()==null){return;}
|
||||
if(e.getRightClicked() instanceof ArmorStand == false){return;}
|
||||
if(!idList.contains(e.getRightClicked().getCustomName())){return;}
|
||||
if(!idList.contains(e.getRightClicked().getUniqueId())){return;}
|
||||
e.setCancelled(true);
|
||||
ItemStack is = player.getItemInHand();
|
||||
if(is==null){return;}
|
||||
@ -240,7 +259,7 @@ public class tent_1 implements Listener {
|
||||
List<Entity> list = new ArrayList<Entity>();
|
||||
|
||||
|
||||
for(String s : this.idList){
|
||||
for(UUID s : this.idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as!=null){
|
||||
ItemStack item = as.getHelmet();
|
||||
@ -277,7 +296,7 @@ public class tent_1 implements Listener {
|
||||
|
||||
public void setColor(HashMap<Integer, Short> durabilityList){
|
||||
int i = 0;
|
||||
for(String id: idList){
|
||||
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)){
|
||||
@ -294,7 +313,7 @@ public class tent_1 implements Listener {
|
||||
HashMap<Integer, Short> colorList = new HashMap<Integer, Short>();
|
||||
Integer i = 0;
|
||||
|
||||
for(String id: idList){
|
||||
for(UUID id: idList){
|
||||
try{i=colorList.size();}catch(Exception e){return colorList;}
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, id);
|
||||
if(as!=null){
|
||||
|
@ -3,7 +3,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;
|
||||
@ -26,22 +28,25 @@ 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;
|
||||
|
||||
public class tent_2 implements Listener {
|
||||
|
||||
private String ID;
|
||||
private Location location;
|
||||
private List<String> idList = new ArrayList<String>();
|
||||
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;
|
||||
@SuppressWarnings("deprecation")
|
||||
public tent_2(Location location, Plugin plugin, String ID) {
|
||||
|
||||
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());
|
||||
@ -50,8 +55,21 @@ public class tent_2 implements Listener {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
LeftLocation.add(0,-.75,0);
|
||||
Location RightLocation = main.getNew(LeftLocation, b, 0D, -4.55D);
|
||||
@ -122,10 +140,11 @@ public class tent_2 implements Listener {
|
||||
main.getInstance().getManager().tent2List.add(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@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);
|
||||
}
|
||||
@ -134,7 +153,7 @@ public class tent_2 implements Listener {
|
||||
public void delete(boolean b, boolean a){
|
||||
if(b){
|
||||
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("tent2"));}
|
||||
for(String s : idList){
|
||||
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());}
|
||||
@ -173,13 +192,12 @@ public class tent_2 implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
private void onInteract(PlayerInteractAtEntityEvent e){
|
||||
if(e.isCancelled()){return;}
|
||||
Player player = e.getPlayer();
|
||||
if(e.getRightClicked().getName()==null){return;}
|
||||
if(e.getRightClicked() instanceof ArmorStand == false){return;}
|
||||
if(!idList.contains(e.getRightClicked().getCustomName())){return;}
|
||||
if(!idList.contains(e.getRightClicked().getUniqueId())){return;}
|
||||
e.setCancelled(true);
|
||||
ItemStack is = player.getItemInHand();
|
||||
if(is==null){return;}
|
||||
@ -190,7 +208,7 @@ public class tent_2 implements Listener {
|
||||
Integer amount = is.getAmount();
|
||||
if(amount>idList.size() || player.getGameMode().equals(GameMode.CREATIVE)){amount=idList.size();}
|
||||
List<Entity> list = new ArrayList<Entity>();
|
||||
for(String s : this.idList){
|
||||
for(UUID s : this.idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as!=null){
|
||||
ItemStack item = as.getHelmet();
|
||||
@ -228,15 +246,15 @@ public class tent_2 implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@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().getName() == null){return;}
|
||||
if(!idList.contains(e.getEntity().getCustomName())){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);
|
||||
@ -244,7 +262,7 @@ public class tent_2 implements Listener {
|
||||
|
||||
public void setColor(HashMap<Integer, Short> durabilityList){
|
||||
int i = 0;
|
||||
for(String id: idList){
|
||||
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)){
|
||||
@ -261,7 +279,7 @@ public class tent_2 implements Listener {
|
||||
HashMap<Integer, Short> colorList = new HashMap<Integer, Short>();
|
||||
Integer i = 0;
|
||||
|
||||
for(String id: idList){
|
||||
for(UUID id: idList){
|
||||
try{i=colorList.size();}catch(Exception e){return colorList;}
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, id);
|
||||
if(as!=null){
|
||||
|
@ -3,7 +3,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.Color;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Effect;
|
||||
@ -28,8 +30,11 @@ 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;
|
||||
|
||||
public class tent_3 implements Listener {
|
||||
|
||||
@ -37,14 +42,14 @@ public class tent_3 implements Listener {
|
||||
private String ID;
|
||||
private BlockFace b;
|
||||
private Block block;
|
||||
private List<String> idList = new ArrayList<String>();
|
||||
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;
|
||||
|
||||
public tent_3(Location location, Plugin plugin, String ID) {
|
||||
public tent_3(Location location, Plugin plugin, String ID, List<UUID> uuids) {
|
||||
this.b = Utils.yawToFace(location.getYaw());
|
||||
this.loc = location.getBlock().getLocation();
|
||||
this.ID = ID;
|
||||
@ -52,7 +57,19 @@ public class tent_3 implements Listener {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getList(){
|
||||
return Utils.UUIDListToStringList(idList);
|
||||
}
|
||||
|
||||
public void spawn(List<UUID> uuidList, Location location, Plugin plugin){
|
||||
ItemStack banner = new ItemStack(Material.BANNER);
|
||||
BannerMeta meta = (BannerMeta) banner.getItemMeta();
|
||||
meta.setBaseColor(DyeColor.WHITE);
|
||||
@ -119,27 +136,26 @@ public class tent_3 implements Listener {
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@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().getName() == null){return;}
|
||||
if(!idList.contains(e.getEntity().getCustomName())){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.NORMAL)
|
||||
@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(e.getRightClicked().getName()==null){return;}
|
||||
if(!idList.contains(e.getRightClicked().getCustomName())){return;}
|
||||
if(!idList.contains(e.getRightClicked().getUniqueId())){return;}
|
||||
e.setCancelled(true);
|
||||
ItemStack is = player.getItemInHand();
|
||||
if(is==null){return;}
|
||||
@ -150,7 +166,7 @@ public class tent_3 implements Listener {
|
||||
Integer neAmound = amount;
|
||||
if(amount>idList.size() || player.getGameMode().equals(GameMode.CREATIVE)){amount=idList.size();}
|
||||
List<Entity> list = new ArrayList<Entity>();
|
||||
for(String s : this.idList){
|
||||
for(UUID s : this.idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as!=null){
|
||||
ItemStack item = as.getHelmet();
|
||||
@ -197,7 +213,7 @@ public class tent_3 implements Listener {
|
||||
public void delete(boolean b, boolean a){
|
||||
if(b){
|
||||
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("tent3"));}
|
||||
for(String s : idList){
|
||||
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);}
|
||||
@ -223,7 +239,7 @@ public class tent_3 implements Listener {
|
||||
HashMap<Integer, Integer> colorList = new HashMap<Integer, Integer>();
|
||||
Integer i = 0;
|
||||
|
||||
for(String id: idList){
|
||||
for(UUID id: idList){
|
||||
try{i=colorList.size();}catch(Exception e){return colorList;}
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, id);
|
||||
if(as!=null){
|
||||
@ -239,7 +255,7 @@ public class tent_3 implements Listener {
|
||||
|
||||
public void setColor(HashMap<Integer, Integer> durabilityList){
|
||||
int i = 0;
|
||||
for(String id: idList){
|
||||
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)){
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: Furniture
|
||||
version: 1.8
|
||||
version: 1.8.3
|
||||
description: Add some Furniture to the Server
|
||||
author: Ste3et_C0st
|
||||
website: http://dicecraft.de
|
||||
@ -7,5 +7,8 @@ softdepend: [Vault, WorldGuard, WorldEdit, Towny, Landlord, LightAPI, PlotSquare
|
||||
main: de.Ste3et_C0st.Furniture.Main.main
|
||||
commands:
|
||||
furniture:
|
||||
description: Dice Furniture Command
|
||||
usage: /<command>
|
||||
model:
|
||||
description: Dice Furniture Command
|
||||
usage: /<command>
|
Loading…
Reference in New Issue
Block a user