mirror of
https://github.com/Ste3et/furniture.git
synced 2024-11-14 14:45:46 +01:00
Furniture Plugin
This commit is contained in:
parent
7ad7ccf712
commit
16c6d4f7df
12
.classpath
12
.classpath
@ -2,7 +2,17 @@
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="lib" path="C:/Plugins/jars/spigot.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Plugins/jars/Vault.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Plugins/jars/worldguard-6.0.0-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Plugins/jars/Landlord.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Plugins/jars/WorldEdit.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Plugins/jars/Factions.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Plugins/jars/spigot.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Plugins/jars/LightAPI.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Plugins/jars/PlotSquared.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Plugins/jars/PreciousStones.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Plugins/jars/Residence.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Plugins/jars/Towny.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Plugins/jars/PlotMe-Core.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
@ -1,7 +1,14 @@
|
||||
config:
|
||||
# Needs Vualt (optional)
|
||||
UseMetrics: true
|
||||
CraftingPermissions: true
|
||||
Messages:
|
||||
NoPermissions: "&cYou don't have permission to do that"
|
||||
notFound: "&cFurniture not found"
|
||||
PlayerNotFound: "&cPlayer not found"
|
||||
PlayerNotFound: "&cPlayer not found"
|
||||
ArmorStandsKills: "&6@ARMORSTANDS ArmorStands removed from @WOLRDS worlds"
|
||||
ArmorStandsRemoveFromDistance: "@ARMORSTANDS &2Furniture removed"
|
||||
ArmorStandsRemoveFromID: "&9Furniture [&cnot#&2successful] &9removed"
|
||||
ArmorStandsRemoveFromType: "&9Furniture [&cnot#&2successful] &9removed"
|
||||
CommandBadArguments: "&cBadArguments"
|
||||
Space: "&aNot Enough Space"
|
@ -62,4 +62,55 @@ Items:
|
||||
'0': 0
|
||||
E: 35
|
||||
A: 58
|
||||
X: 280
|
||||
tent2:
|
||||
name: '&cTent #2'
|
||||
material: 383
|
||||
durability: 0
|
||||
crafting:
|
||||
recipe: 0X0,XEX,OAO
|
||||
index:
|
||||
'0': 0
|
||||
E: 58
|
||||
A: 355
|
||||
X: 35
|
||||
O: 17
|
||||
tent3:
|
||||
name: '&cTent #3'
|
||||
material: 383
|
||||
durability: 0
|
||||
crafting:
|
||||
recipe: 000,0E0,EAE
|
||||
index:
|
||||
'0': 0
|
||||
E: 35
|
||||
A: 355
|
||||
barrels:
|
||||
name: '&cBarrels #3'
|
||||
material: 383
|
||||
durability: 0
|
||||
crafting:
|
||||
recipe: X0X,X0X,XXX
|
||||
index:
|
||||
'0': 0
|
||||
X: 280
|
||||
campfire1:
|
||||
name: '&cCampfire #1'
|
||||
material: 383
|
||||
durability: 0
|
||||
crafting:
|
||||
recipe: 0X0,XEX,0X0
|
||||
index:
|
||||
'0': 0
|
||||
E: 263
|
||||
X: 280
|
||||
campfire2:
|
||||
name: '&cCampfire #2'
|
||||
material: 383
|
||||
durability: 0
|
||||
crafting:
|
||||
recipe: DXD,XEX,DXD
|
||||
index:
|
||||
D: 4
|
||||
E: 263
|
||||
X: 280
|
@ -0,0 +1,23 @@
|
||||
package de.Ste3et_C0st.Furniture.Listener;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
|
||||
import de.Ste3et_C0st.Furniture.Main.main;
|
||||
|
||||
public class IPistonExtendEvent implements Listener {
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
@EventHandler
|
||||
public void onPistionExtend(BlockPistonExtendEvent e){
|
||||
if(e.getBlock()==null){return;}
|
||||
for(int i = 13;i>=0;i--){
|
||||
Location l = main.getInstance().getNew(e.getBlock().getLocation(), e.getDirection(),(double)- i,(double) 0 );
|
||||
if(main.getInstance().Fmgr.isAtLocation(l.toVector(), 1D)){e.setCancelled(true);}
|
||||
if(main.getInstance().Fmgr.isAtLocation(l.getBlock().getRelative(BlockFace.UP).getLocation().toVector(), 1D)){e.setCancelled(true);}
|
||||
}
|
||||
}
|
||||
}
|
@ -3,24 +3,60 @@ package de.Ste3et_C0st.Furniture.Listener;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.BlockFace;
|
||||
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.inventory.PrepareItemCraftEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.CraftingInventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
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.Objects.indoor.chair;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.largeTable;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.latern;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.sofa;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.table;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.barrels;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.campfire_1;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.campfire_2;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_1;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_2;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_3;
|
||||
|
||||
public class OnInteract implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onCrafting(PrepareItemCraftEvent e){
|
||||
Player p = (Player) e.getView().getPlayer();
|
||||
CraftingInventory inv = e.getInventory();
|
||||
if(!main.getInstance().isCrafting){return;}
|
||||
if(main.getInstance().crafting.containsValue(e.getRecipe().getResult())){
|
||||
if(getName(e.getRecipe().getResult()) != null){
|
||||
|
||||
if(!p.hasPermission("furniture.craft." + getName(e.getRecipe().getResult()))){
|
||||
inv.setResult(null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getName(ItemStack is){
|
||||
for(String s : main.getInstance().crafting.keySet()){
|
||||
if(main.getInstance().crafting.get(s).equals(is)){
|
||||
return s;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInterActEvent(PlayerInteractEvent e){
|
||||
Player p = e.getPlayer();
|
||||
@ -38,81 +74,195 @@ public class OnInteract implements Listener {
|
||||
location.setY(location.getY() + 1);
|
||||
ItemStack saveIS = getItemStackCopy(is);
|
||||
String noPermissions = ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.NoPermissions"));
|
||||
if(!main.getInstance().check.canBuild(p, location)){return;}
|
||||
if(saveIS.equals(main.getInstance().crafting.get("sofa"))){
|
||||
if(!p.hasPermission("furniture.sofa")){p.sendMessage(noPermissions);return;}
|
||||
if(main.getInstance().canPlace(p, location, Utils.yawToFace(location.getYaw()).getOppositeFace(), 3)){
|
||||
new sofa(location, 3, main.getInstance(), null, main.createRandomRegistryId());
|
||||
sofa s = new sofa(location, main.getInstance(), main.createRandomRegistryId());
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if(!main.getInstance().getCheckManager().canBuild(p, location)){
|
||||
return;
|
||||
}
|
||||
|
||||
if(saveIS.equals(main.getInstance().crafting.get("lantern"))){
|
||||
if(location.getBlock().getRelative(BlockFace.DOWN).getType() != null && BlackList.materialBlackList.contains(location.getBlock().getRelative(BlockFace.DOWN).getType())){return;}
|
||||
if(!p.hasPermission("furniture.lantern")){p.sendMessage(noPermissions);return;}
|
||||
if(main.getInstance().canPlace(p, location, null, null)){
|
||||
new latern(location, main.getInstance(), true, main.createRandomRegistryId());
|
||||
new latern(location, main.getInstance(), main.createRandomRegistryId());
|
||||
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(saveIS.equals(main.getInstance().crafting.get("chair"))){
|
||||
if(!p.hasPermission("furniture.chair")){p.sendMessage(noPermissions);return;}
|
||||
if(main.getInstance().canPlace(p, location, null, null)){
|
||||
new chair(location, main.getInstance(), main.createRandomRegistryId());
|
||||
chair c = new chair(location, main.getInstance(), main.createRandomRegistryId());
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if(saveIS.equals(main.getInstance().crafting.get("table"))){
|
||||
if(!p.hasPermission("furniture.table")){p.sendMessage(noPermissions);return;}
|
||||
if(main.getInstance().canPlace(p, location, null, null)){
|
||||
new table(location, main.getInstance(), null, main.createRandomRegistryId());
|
||||
table t = new table(location, main.getInstance(), main.createRandomRegistryId());
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if(saveIS.equals(main.getInstance().crafting.get("largeTable"))){
|
||||
if(!p.hasPermission("furniture.largetable")){p.sendMessage(noPermissions);return;}
|
||||
if(main.getInstance().canPlaceLarge(p, location, Utils.yawToFace(location.getYaw()).getOppositeFace(), 3,3)){
|
||||
new largeTable(location, main.getInstance(), null, null, main.createRandomRegistryId());
|
||||
largeTable l = new largeTable(location, main.getInstance(), main.createRandomRegistryId());
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if(saveIS.equals(main.getInstance().crafting.get("tent1"))){
|
||||
if(!p.hasPermission("furniture.tent1")){p.sendMessage(noPermissions);return;}
|
||||
if(main.getInstance().canPlaceTent(p, location, Utils.yawToFace(location.getYaw()).getOppositeFace(), 5,4, 3)){
|
||||
new tent_1(location, main.getInstance(), main.createRandomRegistryId());
|
||||
tent_1 tent = new tent_1(location, main.getInstance(), main.createRandomRegistryId());
|
||||
tent.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;
|
||||
}
|
||||
}
|
||||
|
||||
if(saveIS.equals(main.getInstance().crafting.get("tent2"))){
|
||||
if(!p.hasPermission("furniture.tent2")){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.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;
|
||||
}
|
||||
}
|
||||
|
||||
if(saveIS.equals(main.getInstance().crafting.get("campfire1"))){
|
||||
if(!p.hasPermission("furniture.campfire1")){p.sendMessage(noPermissions);return;}
|
||||
if(main.getInstance().canPlace(p, location, null, null)){
|
||||
campfire_1 tent = new campfire_1(location, main.getInstance(), main.createRandomRegistryId());
|
||||
tent.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;
|
||||
}
|
||||
}
|
||||
|
||||
if(saveIS.equals(main.getInstance().crafting.get("tent3"))){
|
||||
if(!p.hasPermission("furniture.tent3")){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.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;
|
||||
}
|
||||
}
|
||||
|
||||
if(saveIS.equals(main.getInstance().crafting.get("barrels"))){
|
||||
if(!p.hasPermission("furniture.barrels")){p.sendMessage(noPermissions);return;}
|
||||
if(main.getInstance().canPlace(p, location,null,null)){
|
||||
barrels tent = new barrels(location, main.getInstance(), main.createRandomRegistryId());
|
||||
tent.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;
|
||||
}
|
||||
}
|
||||
|
||||
if(saveIS.equals(main.getInstance().crafting.get("campfire2"))){
|
||||
if(!p.hasPermission("furniture.campfire2")){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());
|
||||
tent.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,492 +0,0 @@
|
||||
package de.Ste3et_C0st.Furniture.Main;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
|
||||
import de.Ste3et_C0st.Furniture.Main.config;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.chair;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.largeTable;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.latern;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.sofa;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.table;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_1;
|
||||
|
||||
public class Manager {
|
||||
private static config cc;
|
||||
private static FileConfiguration fc;
|
||||
private String folder = "/objects/";
|
||||
|
||||
public void loadStuhl(){
|
||||
cc = new config();
|
||||
if(cc.ExistConfig(folder, "chair.yml")){
|
||||
fc = cc.getConfig("chair.yml", folder);
|
||||
if(fc.isSet("Furniture.chair")){
|
||||
for(String s : fc.getConfigurationSection("Furniture.chair").getKeys(false)){
|
||||
String path = "Furniture.chair";
|
||||
path+= "." + s;
|
||||
|
||||
Double x = fc.getDouble(path+".Location.x");
|
||||
Double y = fc.getDouble(path+".Location.y");
|
||||
Double z = fc.getDouble(path+".Location.z");
|
||||
World w = Bukkit.getWorld(fc.getString(path+".Location.w"));
|
||||
String face = fc.getString(path+".Location.face");
|
||||
float yaw = Utils.FaceToYaw(Utils.StringToFace(face));
|
||||
|
||||
Location l = new Location(w, x, y, z);
|
||||
l.setYaw(yaw);
|
||||
new chair(l, main.getInstance(), s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadLatern(){
|
||||
cc = new config();
|
||||
if(cc.ExistConfig(folder, "lantern.yml")){
|
||||
fc = cc.getConfig("lantern.yml", folder);
|
||||
if(fc.isSet("Furniture.lantern")){
|
||||
for(String s : fc.getConfigurationSection("Furniture.lantern").getKeys(false)){
|
||||
String path = "Furniture.lantern";
|
||||
path+= "." + s;
|
||||
|
||||
Double x = fc.getDouble(path+".Location.x");
|
||||
Double y = fc.getDouble(path+".Location.y");
|
||||
Double z = fc.getDouble(path+".Location.z");
|
||||
World w = Bukkit.getWorld(fc.getString(path+".Location.w"));
|
||||
String face = fc.getString(path+".Location.face");
|
||||
Boolean b = fc.getBoolean(path+".settings.Light");
|
||||
Location l = new Location(w, x, y, z);
|
||||
float yaw = Utils.FaceToYaw(Utils.StringToFace(face));
|
||||
l.setYaw(yaw);
|
||||
new latern(l, main.getInstance(), b, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadTisch(){
|
||||
cc = new config();
|
||||
if(cc.ExistConfig(folder, "table.yml")){
|
||||
fc = cc.getConfig("table.yml", folder);
|
||||
if(fc.isSet("Furniture.table")){
|
||||
for(String s : fc.getConfigurationSection("Furniture.table").getKeys(false)){
|
||||
String path = "Furniture.table";
|
||||
path+= "." + s;
|
||||
|
||||
Double x = fc.getDouble(path+".Location.x");
|
||||
Double y = fc.getDouble(path+".Location.y");
|
||||
Double z = fc.getDouble(path+".Location.z");
|
||||
World w = Bukkit.getWorld(fc.getString(path+".Location.w"));
|
||||
String face = fc.getString(path+".Location.face");
|
||||
Location l = new Location(w, x, y, z);
|
||||
float yaw = Utils.FaceToYaw(Utils.StringToFace(face));
|
||||
l.setYaw(yaw);
|
||||
ItemStack is = getItemStack(fc, path+".settings.ItemStack");
|
||||
new table(l, main.getInstance(), is, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ItemStack getItemStack(FileConfiguration fc, String s){
|
||||
String path = s;
|
||||
ItemStack is = null;
|
||||
if(fc.isSet(path)){
|
||||
Material m = Material.getMaterial(fc.getInt(path+".material"));
|
||||
Short subID = (short) fc.getInt(path+".durability");
|
||||
Integer amount = fc.getInt(path+".amount");
|
||||
is = new ItemStack(m,amount,subID);
|
||||
ItemMeta im = is.getItemMeta();
|
||||
|
||||
List<String> lore = new ArrayList<String>();
|
||||
if(fc.isSet(path+".lore")){
|
||||
lore = fc.getStringList(path+".lore");
|
||||
im.setLore(lore);
|
||||
}
|
||||
|
||||
if(fc.isSet(path+".displayName")){
|
||||
im.setDisplayName(fc.getString(path+".displayName"));
|
||||
}
|
||||
|
||||
if(fc.isSet(path+".Enchantment")){
|
||||
for(String enchant : fc.getConfigurationSection(path+".Enchantment").getKeys(false)){
|
||||
Enchantment en = Enchantment.getByName(enchant);
|
||||
im.addEnchant(en, fc.getInt(path+".Enchantment." + enchant + ".lvl"), true);
|
||||
}
|
||||
}
|
||||
is.setItemMeta(im);
|
||||
if(is.getItemMeta() instanceof LeatherArmorMeta){
|
||||
LeatherArmorMeta lim = (LeatherArmorMeta) is.getItemMeta();
|
||||
if(fc.isSet(path+".LeatherMeta")){
|
||||
lim.setColor(Color.fromBGR(
|
||||
fc.getInt(path+".LeatherMeta.Color.blue"),
|
||||
fc.getInt(path+".LeatherMeta.Color.green"),
|
||||
fc.getInt(path+".LeatherMeta.Color.red")));
|
||||
}
|
||||
is.setItemMeta(lim);
|
||||
}
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
public List<ItemStack> getList(FileConfiguration fc, String s){
|
||||
List<ItemStack> itemlist = new ArrayList<ItemStack>();
|
||||
if(fc.isSet(s)){
|
||||
for(String string : fc.getConfigurationSection(s).getKeys(false)){
|
||||
ItemStack is = new ItemStack(Material.getMaterial(fc.getString(s+"."+string+".material")));
|
||||
ItemMeta im = is.getItemMeta();
|
||||
im.setDisplayName(main.createRandomRegistryId());
|
||||
is.setDurability((short) fc.getInt(s+"."+string+".durability"));
|
||||
is.setItemMeta(im);
|
||||
itemlist.add(is);
|
||||
}
|
||||
}
|
||||
return itemlist;
|
||||
}
|
||||
|
||||
public void loadLargeTisch(){
|
||||
cc = new config();
|
||||
if(cc.ExistConfig(folder, "largeTable.yml")){
|
||||
fc = cc.getConfig("largeTable.yml", folder);
|
||||
if(fc.isSet("Furniture.largeTable")){
|
||||
for(String s : fc.getConfigurationSection("Furniture.largeTable").getKeys(false)){
|
||||
String path = "Furniture.largeTable";
|
||||
path+= "." + s;
|
||||
|
||||
Double x = fc.getDouble(path+".Location.x");
|
||||
Double y = fc.getDouble(path+".Location.y");
|
||||
Double z = fc.getDouble(path+".Location.z");
|
||||
World w = Bukkit.getWorld(fc.getString(path+".Location.w"));
|
||||
String face = fc.getString(path+".Location.face");
|
||||
Location l = new Location(w, x, y, z);
|
||||
float yaw = Utils.FaceToYaw(Utils.StringToFace(face));
|
||||
l.setYaw(yaw);
|
||||
|
||||
HashMap<Integer, ItemStack> teller = new HashMap<Integer, ItemStack>();
|
||||
teller.put(0, getItemStack(fc, path+".settings.ItemStack_place1"));
|
||||
teller.put(1, getItemStack(fc, path+".settings.ItemStack_place2"));
|
||||
teller.put(2, getItemStack(fc, path+".settings.ItemStack_place3"));
|
||||
teller.put(3, getItemStack(fc, path+".settings.ItemStack_place4"));
|
||||
|
||||
new largeTable(l, main.getInstance(), getList(fc, path+".settings.ColorManager"), teller, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadSofa(){
|
||||
cc = new config();
|
||||
if(cc.ExistConfig(folder, "sofa.yml")){
|
||||
fc = cc.getConfig("sofa.yml", folder);
|
||||
if(fc.isSet("Furniture.sofa")){
|
||||
for(String s : fc.getConfigurationSection("Furniture.sofa").getKeys(false)){
|
||||
String path = "Furniture.sofa";
|
||||
path+= "." + s;
|
||||
|
||||
Double x = fc.getDouble(path+".Location.x");
|
||||
Double y = fc.getDouble(path+".Location.y");
|
||||
Double z = fc.getDouble(path+".Location.z");
|
||||
World w = Bukkit.getWorld(fc.getString(path+".Location.w"));
|
||||
String face = fc.getString(path+".Location.face");
|
||||
Location l = new Location(w, x, y, z);
|
||||
float yaw = Utils.FaceToYaw(Utils.StringToFace(face));
|
||||
l.setYaw(yaw);
|
||||
|
||||
new sofa(l, 3, main.getInstance(), getList(fc, path+".settings.ColorManager"), s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadtent1(){
|
||||
cc = new config();
|
||||
if(cc.ExistConfig(folder, "tent1.yml")){
|
||||
fc = cc.getConfig("tent1.yml", folder);
|
||||
if(fc.isSet("Furniture.tent1")){
|
||||
for(String s : fc.getConfigurationSection("Furniture.tent1").getKeys(false)){
|
||||
String path = "Furniture.tent1";
|
||||
path+= "." + s;
|
||||
Double x = fc.getDouble(path+".Location.x");
|
||||
Double y = fc.getDouble(path+".Location.y");
|
||||
Double z = fc.getDouble(path+".Location.z");
|
||||
World w = Bukkit.getWorld(fc.getString(path+".Location.w"));
|
||||
String face = fc.getString(path+".Location.face");
|
||||
Location l = new Location(w, x, y, z);
|
||||
float yaw = Utils.FaceToYaw(Utils.StringToFace(face));
|
||||
l.setYaw(yaw);
|
||||
|
||||
new tent_1(l, main.getInstance(), s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void saveStuhl(){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("chair.yml",folder );
|
||||
if(!main.getInstance().stuehle.isEmpty()){
|
||||
String path = "Furniture.chair";
|
||||
for(chair s : main.getInstance().stuehle){
|
||||
path = "Furniture.chair."+s.getID();
|
||||
fc.set(path+".Location.x",round(s.getLocation().getX(), 2));
|
||||
fc.set(path+".Location.y",round(s.getLocation().getY(), 2));
|
||||
fc.set(path+".Location.z",round(s.getLocation().getZ(), 2));
|
||||
fc.set(path+".Location.w", s.getLocation().getWorld().getName());
|
||||
fc.set(path+".Location.face", s.getBlockFace().name());
|
||||
}
|
||||
cc.saveConfig("chair.yml", fc, folder);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveLatern(){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("lantern.yml",folder );
|
||||
if(!main.getInstance().laternen.isEmpty()){
|
||||
String path = "Furniture.lantern";
|
||||
for(latern s : main.getInstance().laternen){
|
||||
path = "Furniture.lantern."+s.getID();
|
||||
fc.set(path+".Location.x",round(s.getLocation().getX(), 2));
|
||||
fc.set(path+".Location.y",round(s.getLocation().getY(), 2));
|
||||
fc.set(path+".Location.z",round(s.getLocation().getZ(), 2));
|
||||
fc.set(path+".Location.w", s.getLocation().getWorld().getName());
|
||||
fc.set(path+".Location.face", s.getBlockFace().name());
|
||||
fc.set(path+".settings.Light", s.getBlockState());
|
||||
}
|
||||
cc.saveConfig("lantern.yml", fc, folder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void saveSofa(){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("sofa.yml",folder );
|
||||
if(!main.getInstance().sofas.isEmpty()){
|
||||
String path = "Furniture.sofa";
|
||||
for(sofa s : main.getInstance().sofas){
|
||||
path = "Furniture.sofa."+s.getID();
|
||||
fc.set(path+".Location.x",round(s.getLocation().getX(), 2));
|
||||
fc.set(path+".Location.y",round(s.getLocation().getY(), 2));
|
||||
fc.set(path+".Location.z",round(s.getLocation().getZ(), 2));
|
||||
fc.set(path+".Location.w", s.getLocation().getWorld().getName());
|
||||
fc.set(path+".Location.face", s.getBlockFace().name());
|
||||
if(!s.getItemListTisch().isEmpty()){
|
||||
int l = 0;
|
||||
for(ItemStack is : s.getItemListTisch()){
|
||||
fc.set(path+".settings.ColorManager." + l + ".material", is.getType().name());
|
||||
fc.set(path+".settings.ColorManager." + l + ".durability", is.getDurability());
|
||||
l++;
|
||||
}
|
||||
}
|
||||
}
|
||||
cc.saveConfig("sofa.yml", fc, folder);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveItem(FileConfiguration fc, String s, ItemStack is){
|
||||
fc.set(s+".material", is.getType().name());
|
||||
fc.set(s+".durability", is.getDurability());
|
||||
fc.set(s+".amount", is.getAmount());
|
||||
|
||||
if(is.hasItemMeta()){
|
||||
if(is.getItemMeta().hasDisplayName()){fc.set(s+".displayName", is.getType().name());}
|
||||
if(is.getItemMeta().hasLore()){fc.set(s+".lore", is.getItemMeta().getLore());}
|
||||
|
||||
if(!is.getEnchantments().isEmpty()){
|
||||
for(Enchantment e : is.getEnchantments().keySet()){
|
||||
fc.set(s+".Enchantment." + e.getName() + ".lvl", e.getStartLevel());
|
||||
}
|
||||
}
|
||||
|
||||
if(is.getItemMeta() instanceof LeatherArmorMeta){
|
||||
LeatherArmorMeta lm = (LeatherArmorMeta) is.getItemMeta();
|
||||
fc.set(s+".LeatherMeta.Color.blue", lm.getColor().getBlue());
|
||||
fc.set(s+".LeatherMeta.Color.green", lm.getColor().getGreen());
|
||||
fc.set(s+".LeatherMeta.Color.red", lm.getColor().getRed());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void saveTable(){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("table.yml",folder );
|
||||
if(!main.getInstance().tische.isEmpty()){
|
||||
String path = "Furniture.table";
|
||||
for(table s : main.getInstance().tische){
|
||||
path = "Furniture.table."+s.getID();
|
||||
fc.set(path+".Location.x",round(s.getLocation().getX(), 2));
|
||||
fc.set(path+".Location.y",round(s.getLocation().getY(), 2));
|
||||
fc.set(path+".Location.z",s.getLocation().getZ());
|
||||
fc.set(path+".Location.w", s.getLocation().getWorld().getName());
|
||||
fc.set(path+".Location.face", s.getBlockFace().name());
|
||||
if(s.getItemStack()!=null){
|
||||
saveItem(fc, path, s.getItemStack());
|
||||
}
|
||||
}
|
||||
cc.saveConfig("table.yml", fc, folder);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveTent1(){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("tent1.yml",folder );
|
||||
if(!main.getInstance().tents1.isEmpty()){
|
||||
String path = "Furniture.tent1";
|
||||
for(tent_1 s : main.getInstance().tents1){
|
||||
path = "Furniture.tent1."+s.getID();
|
||||
fc.set(path+".Location.x",round(s.getLocation().getX(), 2));
|
||||
fc.set(path+".Location.y",round(s.getLocation().getY(), 2));
|
||||
fc.set(path+".Location.z",round(s.getLocation().getZ(), 2));
|
||||
fc.set(path+".Location.w", s.getLocation().getWorld().getName());
|
||||
fc.set(path+".Location.face", s.getBlockFace().name());
|
||||
}
|
||||
cc.saveConfig("tent1.yml", fc, folder);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveLargeTable(){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("largeTable.yml",folder );
|
||||
if(!main.getInstance().tische2.isEmpty()){
|
||||
String path = "Furniture.largeTable";
|
||||
for(largeTable s : main.getInstance().tische2){
|
||||
path = "Furniture.largeTable."+s.getID();
|
||||
fc.set(path+".Location.x",round(s.getLocation().getX(), 2));
|
||||
fc.set(path+".Location.y",round(s.getLocation().getY(), 2));
|
||||
fc.set(path+".Location.z",round(s.getLocation().getZ(), 2));
|
||||
fc.set(path+".Location.w", s.getLocation().getWorld().getName());
|
||||
fc.set(path+".Location.face", s.getBlockFace().name());
|
||||
if(!s.getItemListTisch().isEmpty()){
|
||||
int l = 0;
|
||||
for(ItemStack is : s.getItemListTisch()){
|
||||
fc.set(path+".settings.ColorManager." + l + ".material", is.getType().name());
|
||||
fc.set(path+".settings.ColorManager." + l + ".durability", is.getDurability());
|
||||
l++;
|
||||
}
|
||||
}
|
||||
|
||||
if(!s.getTeller().isEmpty()){
|
||||
for(int l=0;l<=3;l++ ){
|
||||
try{
|
||||
ItemStack is = s.getTeller().get(l);
|
||||
saveItem(fc, path, is);
|
||||
}catch(Exception e){
|
||||
ItemStack is = new ItemStack(Material.AIR);
|
||||
saveItem(fc, path, is);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cc.saveConfig("largeTable.yml", fc, folder);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteFromConfig(String ID, String type){
|
||||
cc = new config();
|
||||
if(cc.ExistConfig(folder, type+".yml")){
|
||||
fc = cc.getConfig(type, folder);
|
||||
if(fc.isSet("Furniture." + type + "." + ID)){
|
||||
fc.set("Furniture." + type + "." + ID, null);
|
||||
}
|
||||
cc.saveConfig(type, fc, folder);
|
||||
}
|
||||
}
|
||||
|
||||
public static double round(double value, int places) {
|
||||
if (places < 0) throw new IllegalArgumentException();
|
||||
|
||||
long factor = (long) Math.pow(10, places);
|
||||
value = value * factor;
|
||||
long tmp = Math.round(value);
|
||||
return (double) tmp / factor;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void defaultCrafting(){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("crafting.yml", "");
|
||||
fc.addDefaults(YamlConfiguration.loadConfiguration(main.getInstance().getResource("crafting.yml")));
|
||||
fc.options().copyDefaults(true);
|
||||
cc.saveConfig("crafting.yml", fc, "");
|
||||
}
|
||||
|
||||
public void loadCrafting(String s){
|
||||
ShapedRecipe recipe = new ShapedRecipe(returnResult(s)).shape(returnFragment(s)[0], returnFragment(s)[1], returnFragment(s)[2]);
|
||||
for(Character c : returnMaterial(s).keySet()){
|
||||
if(!returnMaterial(s).get(c).equals(Material.AIR)){
|
||||
recipe.setIngredient(c.charValue(), returnMaterial(s).get(c));
|
||||
}
|
||||
}
|
||||
main.getInstance().getServer().addRecipe(recipe);
|
||||
main.getInstance().crafting.put(s, returnResult(s));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ItemStack returnResult(String s){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("crafting.yml", "");
|
||||
String path = "Items." + s;
|
||||
Integer MaterialID = fc.getInt(path+".material");
|
||||
Short shor = (short) fc.getInt(path+".durability");
|
||||
ItemStack is = new ItemStack(Material.getMaterial(MaterialID));
|
||||
ItemMeta im = is.getItemMeta();
|
||||
im.setDisplayName(ChatColor.translateAlternateColorCodes('&', fc.getString(path+".name")));
|
||||
is.setItemMeta(im);
|
||||
is.setDurability(shor);
|
||||
is.setAmount(1);
|
||||
return is;
|
||||
}
|
||||
|
||||
public String[] returnFragment(String s){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("crafting.yml", "");
|
||||
String path = "Items." + s;
|
||||
String recipe = fc.getString(path+".crafting.recipe");
|
||||
String[] fragments = recipe.split(",");
|
||||
return fragments;
|
||||
}
|
||||
|
||||
public List<String> returnCharacters(String s){
|
||||
List<String> stringList = new ArrayList<String>();
|
||||
for(String str: returnFragment(s)){
|
||||
String[] sl = str.split("(?!^)");
|
||||
for(String o : sl){
|
||||
if(!stringList.contains(o)){
|
||||
stringList.add(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
return stringList;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public HashMap<Character,Material> returnMaterial(String s){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("crafting.yml", "");
|
||||
String path = "Items." + s;
|
||||
List<String> stringList = returnCharacters(s);
|
||||
HashMap<Character, Material> materialHash = new HashMap<Character, Material>();
|
||||
for(String str : stringList){
|
||||
Character chars = str.charAt(0);
|
||||
Integer MaterialID = fc.getInt(path+".crafting.index." + str);
|
||||
Material material = Material.getMaterial(MaterialID);
|
||||
materialHash.put(chars, material);
|
||||
}
|
||||
return materialHash;
|
||||
}
|
||||
}
|
86
src/de/Ste3et_C0st/Furniture/Main/Manager/BlackList.java
Normal file
86
src/de/Ste3et_C0st/Furniture/Main/Manager/BlackList.java
Normal file
@ -0,0 +1,86 @@
|
||||
package de.Ste3et_C0st.Furniture.Main.Manager;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class BlackList {
|
||||
|
||||
public static List<Material> materialBlackList = Arrays.asList(
|
||||
Material.SAPLING,
|
||||
Material.WEB,
|
||||
Material.LONG_GRASS,
|
||||
Material.DEAD_BUSH,
|
||||
Material.YELLOW_FLOWER,
|
||||
Material.RED_ROSE,
|
||||
Material.BROWN_MUSHROOM,
|
||||
Material.RED_MUSHROOM,
|
||||
Material.TORCH,
|
||||
Material.CHEST,
|
||||
Material.LADDER,
|
||||
Material.SNOW,
|
||||
Material.CACTUS,
|
||||
Material.IRON_PLATE,
|
||||
Material.THIN_GLASS,
|
||||
Material.VINE,
|
||||
Material.WATER_LILY,
|
||||
Material.ENCHANTMENT_TABLE,
|
||||
Material.ENDER_CHEST,
|
||||
Material.ANVIL,
|
||||
Material.TRAPPED_CHEST,
|
||||
Material.STAINED_GLASS_PANE,
|
||||
Material.CARPET,
|
||||
Material.DOUBLE_PLANT,
|
||||
Material.PAINTING,
|
||||
Material.SIGN,
|
||||
Material.SIGN_POST,
|
||||
Material.WALL_SIGN,
|
||||
Material.BANNER,
|
||||
Material.WALL_BANNER,
|
||||
Material.BED_BLOCK,
|
||||
Material.ITEM_FRAME,
|
||||
Material.FLOWER_POT,
|
||||
Material.SKULL,
|
||||
Material.LEVER,
|
||||
Material.STONE_PLATE,
|
||||
Material.WOOD_PLATE,
|
||||
Material.REDSTONE,
|
||||
Material.REDSTONE_COMPARATOR,
|
||||
Material.REDSTONE_TORCH_OFF,
|
||||
Material.REDSTONE_TORCH_ON,
|
||||
Material.REDSTONE_WIRE,
|
||||
Material.STONE_BUTTON,
|
||||
Material.WOOD_BUTTON,
|
||||
Material.TRIPWIRE_HOOK,
|
||||
Material.TRIPWIRE,
|
||||
Material.FENCE_GATE,
|
||||
Material.GOLD_PLATE,
|
||||
Material.IRON_TRAPDOOR,
|
||||
Material.TRAP_DOOR,
|
||||
Material.IRON_BARDING,
|
||||
Material.DAYLIGHT_DETECTOR,
|
||||
Material.DAYLIGHT_DETECTOR_INVERTED,
|
||||
Material.SPRUCE_FENCE_GATE,
|
||||
Material.SPRUCE_DOOR,
|
||||
Material.BIRCH_DOOR,
|
||||
Material.DARK_OAK_DOOR,
|
||||
Material.JUNGLE_DOOR,
|
||||
Material.ACACIA_DOOR,
|
||||
Material.WOOD_DOOR,
|
||||
Material.IRON_DOOR_BLOCK,
|
||||
Material.RAILS,
|
||||
Material.POWERED_RAIL,
|
||||
Material.ACTIVATOR_RAIL,
|
||||
Material.DETECTOR_RAIL,
|
||||
Material.BEACON,
|
||||
Material.BREWING_STAND,
|
||||
Material.CAULDRON,
|
||||
Material.WOOD_STAIRS,
|
||||
Material.NETHER_WARTS,
|
||||
Material.NETHER_BRICK_STAIRS,
|
||||
Material.ACACIA_STAIRS,
|
||||
Material.BRICK_STAIRS
|
||||
);
|
||||
|
||||
}
|
37
src/de/Ste3et_C0st/Furniture/Main/Manager/CheckManager.java
Normal file
37
src/de/Ste3et_C0st/Furniture/Main/Manager/CheckManager.java
Normal file
@ -0,0 +1,37 @@
|
||||
package de.Ste3et_C0st.Furniture.Main.Manager;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
public class CheckManager {
|
||||
|
||||
ILandLord landlord = null;
|
||||
IPlotMeCheck plotme = null;
|
||||
IPlotSquaredCheck plotsquared = null;
|
||||
IPreciousStones stones = null;
|
||||
IResidence residence = null;
|
||||
ITowny towny = null;
|
||||
|
||||
public CheckManager(PluginManager pm) throws ClassNotFoundException{
|
||||
try {this.landlord = new ILandLord(pm);} catch (Exception e) {}
|
||||
this.plotme = new IPlotMeCheck(pm);
|
||||
try {this.stones = new IPreciousStones(pm);} catch (Exception e) {}
|
||||
try {this.stones = new IPreciousStones(pm);} catch (Exception e) {}
|
||||
try {this.residence = new IResidence(pm);} catch (Exception e) {}
|
||||
try {this.towny = new ITowny(pm);} catch (Exception e) {}
|
||||
}
|
||||
|
||||
public boolean canBuild(Player p, Location l){
|
||||
if(p.isOp()){return true;}
|
||||
if((landlord == null || landlord.check(p, l)) &&
|
||||
(plotme == null || plotme.check(p, l)) &&
|
||||
(plotsquared == null || plotsquared.check(p, l)) &&
|
||||
(stones == null || stones.check(p, l)) &&
|
||||
(residence == null || residence.check(p, l)) &&
|
||||
(towny == null || towny.check(p, l))){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
272
src/de/Ste3et_C0st/Furniture/Main/Manager/FurnitureManager.java
Normal file
272
src/de/Ste3et_C0st/Furniture/Main/Manager/FurnitureManager.java
Normal file
@ -0,0 +1,272 @@
|
||||
package de.Ste3et_C0st.Furniture.Main.Manager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import de.Ste3et_C0st.Furniture.Main.Type;
|
||||
import de.Ste3et_C0st.Furniture.Main.Type.FurnitureType;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.chair;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.largeTable;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.latern;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.sofa;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.table;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.barrels;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.campfire_1;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.campfire_2;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_1;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_2;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_3;
|
||||
|
||||
public class FurnitureManager {
|
||||
public List<sofa> sofaList = new ArrayList<sofa>();
|
||||
public List<latern> lanternList = new ArrayList<latern>();
|
||||
public List<chair> chairList = new ArrayList<chair>();
|
||||
public List<table> tableList = new ArrayList<table>();
|
||||
public List<largeTable> largeTableList = new ArrayList<largeTable>();
|
||||
public List<tent_1> tent1List = new ArrayList<tent_1>();
|
||||
public List<tent_2> tent2List = new ArrayList<tent_2>();
|
||||
public List<tent_3> tent3List = new ArrayList<tent_3>();
|
||||
public List<barrels> barrelList = new ArrayList<barrels>();
|
||||
public List<campfire_1> campfire1List = new ArrayList<campfire_1>();
|
||||
public List<campfire_2> campfire2List = new ArrayList<campfire_2>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean RemoveType(FurnitureType f, boolean b){
|
||||
switch (f) {
|
||||
case CHAIR:
|
||||
if(chairList.isEmpty()){break;}
|
||||
List<chair> chairL = ((List<chair>) ((ArrayList<chair>) chairList).clone());
|
||||
for(chair s : chairL){s.delete(b, false);return true;}
|
||||
case LARGE_TABLE:
|
||||
if(largeTableList.isEmpty()){break;}
|
||||
List<largeTable> LLT = ((List<largeTable>) ((ArrayList<largeTable>) largeTableList).clone());
|
||||
for(largeTable s : LLT){s.delete(b,false);return true;}
|
||||
case LATERN:
|
||||
if(lanternList.isEmpty()){break;}
|
||||
List<latern> latetnL = ((List<latern>) ((ArrayList<latern>) lanternList).clone());
|
||||
for(latern s : latetnL){s.delete(b,false);return true;}
|
||||
case SOFA:
|
||||
if(sofaList.isEmpty()){break;}
|
||||
List<sofa> sofaL = ((List<sofa>) ((ArrayList<sofa>) sofaList).clone());
|
||||
for(sofa s : sofaL){s.delete(b,false);return true;}
|
||||
case TABLE:
|
||||
if(tableList.isEmpty()){break;}
|
||||
List<table> tableL = ((List<table>) ((ArrayList<table>) tableList).clone());
|
||||
for(table s : tableL){s.delete(b,false);return true;}
|
||||
case BARRELS:
|
||||
if(barrelList.isEmpty()){break;}
|
||||
List<barrels> barrelL = ((List<barrels>) ((ArrayList<barrels>) barrelList).clone());
|
||||
for(barrels s : barrelL){s.delete(b,false);return true;}
|
||||
case CAMPFIRE_1:
|
||||
if(campfire1List.isEmpty()){break;}
|
||||
List<campfire_1> camp1L = ((List<campfire_1>) ((ArrayList<campfire_1>) campfire1List).clone());
|
||||
for(campfire_1 s : camp1L){s.delete(b,false);return true;}
|
||||
case CAMPFIRE_2:
|
||||
if(campfire2List.isEmpty()){break;}
|
||||
List<campfire_2> camp2L = ((List<campfire_2>) ((ArrayList<campfire_2>) campfire2List).clone());
|
||||
for(campfire_2 s : camp2L){s.delete(b,false);return true;}
|
||||
case TENT_1:
|
||||
if(tent1List.isEmpty()){break;}
|
||||
List<tent_1> tent1L = ((List<tent_1>) ((ArrayList<tent_1>) tent1List).clone());
|
||||
for(tent_1 s : tent1L){s.delete(b,false);return true;}
|
||||
case TENT_2:
|
||||
if(tent2List.isEmpty()){break;}
|
||||
List<tent_2> tent2L = ((List<tent_2>) ((ArrayList<tent_2>) tent2List).clone());
|
||||
for(tent_2 s : tent2L){s.delete(b,false);return true;}
|
||||
case TENT_3:
|
||||
if(tent3List.isEmpty()){break;}
|
||||
List<tent_3> tent3L = ((List<tent_3>) ((ArrayList<tent_3>) tent3List).clone());
|
||||
for(tent_3 s : tent3L){s.delete(b,false);return true;}
|
||||
default: return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean RemoveFromID(String ID){
|
||||
if(ID==null){return false;}
|
||||
if(!sofaList.isEmpty()){
|
||||
List<sofa> sofaL = ((List<sofa>) ((ArrayList<sofa>) sofaList).clone());
|
||||
for(sofa s : sofaL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
|
||||
if(!lanternList.isEmpty()){
|
||||
List<latern> sofaL = ((List<latern>) ((ArrayList<latern>) lanternList).clone());
|
||||
for(latern s : sofaL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
|
||||
if(!chairList.isEmpty()){
|
||||
List<chair> sofaL = ((List<chair>) ((ArrayList<chair>) chairList).clone());
|
||||
for(chair s : sofaL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
|
||||
if(!tableList.isEmpty()){
|
||||
List<table> sofaL = ((List<table>) ((ArrayList<table>) tableList).clone());
|
||||
for(table s : sofaL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
|
||||
if(!largeTableList.isEmpty()){
|
||||
List<largeTable> sofaL = ((List<largeTable>) ((ArrayList<largeTable>) largeTableList).clone());
|
||||
for(largeTable s : sofaL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
|
||||
if(!tent1List.isEmpty()){
|
||||
List<tent_1> sofaL = ((List<tent_1>) ((ArrayList<tent_1>) tent1List).clone());
|
||||
for(tent_1 s : sofaL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
|
||||
if(!tent2List.isEmpty()){
|
||||
List<tent_2> sofaL = ((List<tent_2>) ((ArrayList<tent_2>) tent2List).clone());
|
||||
for(tent_2 s : sofaL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
|
||||
if(!tent3List.isEmpty()){
|
||||
List<tent_3> sofaL = ((List<tent_3>) ((ArrayList<tent_3>) tent3List).clone());
|
||||
for(tent_3 s : sofaL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
|
||||
if(!barrelList.isEmpty()){
|
||||
List<barrels> sofaL = ((List<barrels>) ((ArrayList<barrels>) barrelList).clone());
|
||||
for(barrels s : sofaL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
|
||||
if(!campfire1List.isEmpty()){
|
||||
List<campfire_1> sofaL = ((List<campfire_1>) ((ArrayList<campfire_1>) campfire1List).clone());
|
||||
for(campfire_1 s : sofaL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
|
||||
if(!campfire2List.isEmpty()){
|
||||
List<campfire_2> sofaL = ((List<campfire_2>) ((ArrayList<campfire_2>) campfire2List).clone());
|
||||
for(campfire_2 s : sofaL){if(s!=null){if(s.getID().equalsIgnoreCase(ID))s.delete(true,false);return true;}}}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean isAtLocation(Vector v, Double distance){
|
||||
if(v==null){return false;}
|
||||
if(distance==null){return false;}
|
||||
if(!sofaList.isEmpty()){
|
||||
List<sofa> sofaL = ((List<sofa>) ((ArrayList<sofa>) sofaList).clone());
|
||||
for(sofa s : sofaL){
|
||||
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
|
||||
}
|
||||
}
|
||||
if(!lanternList.isEmpty()){
|
||||
List<latern> sofaL = ((List<latern>) ((ArrayList<latern>) lanternList).clone());
|
||||
for(latern s : sofaL){
|
||||
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
|
||||
}
|
||||
}
|
||||
if(!chairList.isEmpty()){
|
||||
List<chair> sofaL = ((List<chair>) ((ArrayList<chair>) chairList).clone());
|
||||
for(chair s : sofaL){
|
||||
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
|
||||
}
|
||||
}
|
||||
if(!tableList.isEmpty()){
|
||||
List<table> sofaL = ((List<table>) ((ArrayList<table>) tableList).clone());
|
||||
for(table s : sofaL){
|
||||
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
|
||||
}
|
||||
}
|
||||
if(!largeTableList.isEmpty()){
|
||||
List<largeTable> sofaL = ((List<largeTable>) ((ArrayList<largeTable>) largeTableList).clone());
|
||||
for(largeTable s : sofaL){
|
||||
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
|
||||
}
|
||||
}
|
||||
if(!tent1List.isEmpty()){
|
||||
List<tent_1> sofaL = ((List<tent_1>) ((ArrayList<tent_1>) tent1List).clone());
|
||||
for(tent_1 s : sofaL){
|
||||
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
|
||||
}
|
||||
}
|
||||
if(!tent2List.isEmpty()){
|
||||
List<tent_2> sofaL = ((List<tent_2>) ((ArrayList<tent_2>) tent2List).clone());
|
||||
for(tent_2 s : sofaL){
|
||||
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
|
||||
}
|
||||
}
|
||||
if(!tent3List.isEmpty()){
|
||||
List<tent_3> sofaL = ((List<tent_3>) ((ArrayList<tent_3>) tent3List).clone());
|
||||
for(tent_3 s : sofaL){
|
||||
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
|
||||
}
|
||||
}
|
||||
if(!barrelList.isEmpty()){
|
||||
List<barrels> sofaL = barrelList.subList(0, barrelList.size());
|
||||
for(barrels s : sofaL){
|
||||
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
|
||||
}
|
||||
}
|
||||
if(!campfire1List.isEmpty()){
|
||||
List<campfire_1> sofaL = ((List<campfire_1>) ((ArrayList<campfire_1>) campfire1List).clone());
|
||||
for(campfire_1 s : sofaL){
|
||||
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
|
||||
}
|
||||
}
|
||||
if(!campfire2List.isEmpty()){
|
||||
List<campfire_2> sofaL = ((List<campfire_2>) ((ArrayList<campfire_2>) campfire2List).clone());
|
||||
for(campfire_2 s : sofaL){
|
||||
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)return true;}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Integer RemoveFromDistance(Vector v, Double distance){
|
||||
if(v==null){return null;}
|
||||
if(distance==null){return null;}
|
||||
Integer i=0;
|
||||
if(!sofaList.isEmpty()){
|
||||
List<sofa> sofaL = ((List<sofa>) ((ArrayList<sofa>) sofaList).clone());
|
||||
for(sofa s : sofaL){
|
||||
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true,false);i++;}
|
||||
}
|
||||
}
|
||||
if(!lanternList.isEmpty()){
|
||||
List<latern> sofaL = ((List<latern>) ((ArrayList<latern>) lanternList).clone());
|
||||
for(latern s : sofaL){
|
||||
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true, false);i++;}
|
||||
}
|
||||
}
|
||||
if(!chairList.isEmpty()){
|
||||
List<chair> sofaL = ((List<chair>) ((ArrayList<chair>) chairList).clone());
|
||||
for(chair s : sofaL){
|
||||
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true, false);i++;}
|
||||
}
|
||||
}
|
||||
if(!tableList.isEmpty()){
|
||||
List<table> sofaL = ((List<table>) ((ArrayList<table>) tableList).clone());
|
||||
for(table s : sofaL){
|
||||
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true, false);i++;}
|
||||
}
|
||||
}
|
||||
if(!largeTableList.isEmpty()){
|
||||
List<largeTable> sofaL = ((List<largeTable>) ((ArrayList<largeTable>) largeTableList).clone());
|
||||
for(largeTable s : sofaL){
|
||||
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true, false);i++;}
|
||||
}
|
||||
}
|
||||
if(!tent1List.isEmpty()){
|
||||
List<tent_1> sofaL = ((List<tent_1>) ((ArrayList<tent_1>) tent1List).clone());
|
||||
for(tent_1 s : sofaL){
|
||||
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true, false);i++;}
|
||||
}
|
||||
}
|
||||
if(!tent2List.isEmpty()){
|
||||
List<tent_2> sofaL = ((List<tent_2>) ((ArrayList<tent_2>) tent2List).clone());
|
||||
for(tent_2 s : sofaL){
|
||||
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true, false);i++;}
|
||||
}
|
||||
}
|
||||
if(!tent3List.isEmpty()){
|
||||
List<tent_3> sofaL = ((List<tent_3>) ((ArrayList<tent_3>) tent3List).clone());
|
||||
for(tent_3 s : sofaL){
|
||||
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true, false);i++;}
|
||||
}
|
||||
}
|
||||
if(!barrelList.isEmpty()){
|
||||
List<barrels> sofaL = barrelList.subList(0, barrelList.size());
|
||||
for(barrels s : sofaL){
|
||||
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true, false);i++;}
|
||||
}
|
||||
}
|
||||
if(!campfire1List.isEmpty()){
|
||||
List<campfire_1> sofaL = ((List<campfire_1>) ((ArrayList<campfire_1>) campfire1List).clone());
|
||||
for(campfire_1 s : sofaL){
|
||||
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true, false);i++;}
|
||||
}
|
||||
}
|
||||
if(!campfire2List.isEmpty()){
|
||||
List<campfire_2> sofaL = ((List<campfire_2>) ((ArrayList<campfire_2>) campfire2List).clone());
|
||||
for(campfire_2 s : sofaL){
|
||||
if(s!=null){if(s.getLocation().toVector().distance(v)<=distance)s.delete(true, false);i++;}
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
36
src/de/Ste3et_C0st/Furniture/Main/Manager/ILandLord.java
Normal file
36
src/de/Ste3et_C0st/Furniture/Main/Manager/ILandLord.java
Normal file
@ -0,0 +1,36 @@
|
||||
package de.Ste3et_C0st.Furniture.Main.Manager;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import com.jcdesimp.landlord.Landlord;
|
||||
import com.jcdesimp.landlord.persistantData.Friend;
|
||||
import com.jcdesimp.landlord.persistantData.OwnedLand;
|
||||
|
||||
public class ILandLord {
|
||||
Boolean enabled = false;
|
||||
PluginManager pm = null;
|
||||
Landlord wg = null;
|
||||
public ILandLord(PluginManager pm){
|
||||
if(!pm.isPluginEnabled("Landlord")){return;}
|
||||
this.pm = pm;
|
||||
this.enabled = true;
|
||||
wg = (Landlord) pm.getPlugin("Landlord");
|
||||
}
|
||||
|
||||
public boolean check(Player p, Location l){
|
||||
if(p.isOp()){return true;}
|
||||
if(!this.enabled){return true;}
|
||||
if(this.wg == null){return true;}
|
||||
try{
|
||||
OwnedLand ow = OwnedLand.getApplicableLand(l);
|
||||
if(ow==null){return true;}
|
||||
if(ow.getOwnerUUID().equals(p.getUniqueId())){return true;}
|
||||
if(ow.getFriends().contains(Friend.friendFromPlayer(p))){return true;}
|
||||
return false;
|
||||
}catch(Exception e){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
41
src/de/Ste3et_C0st/Furniture/Main/Manager/IPlotMeCheck.java
Normal file
41
src/de/Ste3et_C0st/Furniture/Main/Manager/IPlotMeCheck.java
Normal file
@ -0,0 +1,41 @@
|
||||
package de.Ste3et_C0st.Furniture.Main.Manager;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import com.worldcretornica.plotme_core.Plot;
|
||||
import com.worldcretornica.plotme_core.PlotMeCoreManager;
|
||||
import com.worldcretornica.plotme_core.api.ILocation;
|
||||
import com.worldcretornica.plotme_core.api.IWorld;
|
||||
import com.worldcretornica.plotme_core.bukkit.api.BukkitLocation;
|
||||
import com.worldcretornica.plotme_core.bukkit.api.BukkitWorld;
|
||||
|
||||
public class IPlotMeCheck {
|
||||
Boolean enabled = false;
|
||||
PluginManager pm = null;
|
||||
PlotMeCoreManager wg = null;
|
||||
public IPlotMeCheck(PluginManager pm){
|
||||
if(!pm.isPluginEnabled("PlotMe")){return;}
|
||||
this.pm = pm;
|
||||
this.enabled = true;
|
||||
wg = (PlotMeCoreManager) pm.getPlugin("PlotMe");
|
||||
}
|
||||
|
||||
public boolean check(Player p, Location l){
|
||||
if(p.isOp()){return true;}
|
||||
if(!this.enabled){return true;}
|
||||
if(this.wg == null){return true;}
|
||||
try{
|
||||
IWorld iworld = new BukkitWorld(p.getWorld());
|
||||
if(!wg.isPlotWorld(iworld)){return true;}
|
||||
ILocation plotLoc = new BukkitLocation(p.getLocation());
|
||||
String id = wg.getPlotId(plotLoc);
|
||||
if (id.isEmpty()){return true;}
|
||||
Plot plot = wg.getPlotById(id, iworld);
|
||||
if(plot.isAllowed(p.getUniqueId())){return true;}else{return false;}
|
||||
}catch(Exception e){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package de.Ste3et_C0st.Furniture.Main.Manager;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions;
|
||||
|
||||
public class IPlotSquaredCheck {
|
||||
Boolean enabled = false;
|
||||
PluginManager pm = null;
|
||||
PlotSquared wg = null;
|
||||
public IPlotSquaredCheck(PluginManager pm){
|
||||
if(!pm.isPluginEnabled("PlotSquared")){return;}
|
||||
this.pm = pm;
|
||||
this.enabled = true;
|
||||
wg = (PlotSquared) pm.getPlugin("PlotSquared");
|
||||
}
|
||||
|
||||
public boolean check(Player p, Location l){
|
||||
if(p.isOp()){return true;}
|
||||
if(!this.enabled){return true;}
|
||||
if(this.wg == null){return true;}
|
||||
try{
|
||||
Plot plot = BukkitPlayerFunctions.getCurrentPlot(p);
|
||||
if(plot.isAdded(p.getUniqueId()) || plot.isOwner(p.getUniqueId())){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}catch(Exception e){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package de.Ste3et_C0st.Furniture.Main.Manager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sacredlabyrinth.Phaed.PreciousStones.FieldFlag;
|
||||
import net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones;
|
||||
import net.sacredlabyrinth.Phaed.PreciousStones.vectors.Field;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
public class IPreciousStones {
|
||||
Boolean enabled = false;
|
||||
PluginManager pm = null;
|
||||
PreciousStones wg = null;
|
||||
public IPreciousStones(PluginManager pm){
|
||||
if(!pm.isPluginEnabled("PreciousStones")){return;}
|
||||
this.pm = pm;
|
||||
this.enabled = true;
|
||||
wg = (PreciousStones) pm.getPlugin("PreciousStones");
|
||||
}
|
||||
|
||||
public boolean check(Player p, Location l){
|
||||
if(p.isOp()){return true;}
|
||||
if(!this.enabled){return true;}
|
||||
if(this.wg == null){return true;}
|
||||
try{
|
||||
List<Field> fields = PreciousStones.API().getFieldsProtectingArea(FieldFlag.ALL, l);
|
||||
if ((fields == null) || (fields.size() == 0)){ return true; }else{
|
||||
Field stones = (Field)fields.get(0);
|
||||
if(stones.isBuyer(p)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}catch(Exception e){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
35
src/de/Ste3et_C0st/Furniture/Main/Manager/IResidence.java
Normal file
35
src/de/Ste3et_C0st/Furniture/Main/Manager/IResidence.java
Normal file
@ -0,0 +1,35 @@
|
||||
package de.Ste3et_C0st.Furniture.Main.Manager;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import com.bekvon.bukkit.residence.Residence;
|
||||
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
|
||||
public class IResidence {
|
||||
Boolean enabled = false;
|
||||
PluginManager pm = null;
|
||||
Residence wg = null;
|
||||
public IResidence(PluginManager pm){
|
||||
if(!pm.isPluginEnabled("Residence")){return;}
|
||||
this.pm = pm;
|
||||
this.enabled = true;
|
||||
wg = (Residence) pm.getPlugin("Residence");
|
||||
}
|
||||
|
||||
public boolean check(Player p, Location l){
|
||||
if(p.isOp()){return true;}
|
||||
if(!this.enabled){return true;}
|
||||
if(this.wg == null){return true;}
|
||||
try{
|
||||
ClaimedResidence residence = Residence.getResidenceManager().getByLoc(l);
|
||||
if(residence==null||residence.getOwner().equalsIgnoreCase(p.getName())||residence.getOwner().equalsIgnoreCase(p.getUniqueId().toString())){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}catch(Exception e){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
36
src/de/Ste3et_C0st/Furniture/Main/Manager/ITowny.java
Normal file
36
src/de/Ste3et_C0st/Furniture/Main/Manager/ITowny.java
Normal file
@ -0,0 +1,36 @@
|
||||
package de.Ste3et_C0st.Furniture.Main.Manager;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import com.bekvon.bukkit.residence.Residence;
|
||||
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
import com.palmergames.bukkit.towny.Towny;
|
||||
|
||||
public class ITowny {
|
||||
Boolean enabled = false;
|
||||
PluginManager pm = null;
|
||||
Towny wg = null;
|
||||
public ITowny(PluginManager pm){
|
||||
if(!pm.isPluginEnabled("Towny")){return;}
|
||||
this.pm = pm;
|
||||
this.enabled = true;
|
||||
wg = (Towny) pm.getPlugin("Towny");
|
||||
}
|
||||
|
||||
public boolean check(Player p, Location l){
|
||||
if(p.isOp()){return true;}
|
||||
if(!this.enabled){return true;}
|
||||
if(this.wg == null){return true;}
|
||||
try{
|
||||
ClaimedResidence residence = Residence.getResidenceManager().getByLoc(l);
|
||||
if(residence==null||residence.getOwner().equalsIgnoreCase(p.getName())||residence.getOwner().equalsIgnoreCase(p.getUniqueId().toString())){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}catch(Exception e){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package de.Ste3et_C0st.Furniture.Main.Manager;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
|
||||
public class IWolrdGuardCheck {
|
||||
Boolean enabled = false;
|
||||
PluginManager pm = null;
|
||||
WorldGuardPlugin wg = null;
|
||||
public IWolrdGuardCheck(PluginManager pm){
|
||||
if(!pm.isPluginEnabled("WorldGuard")){return;}
|
||||
this.pm = pm;
|
||||
this.enabled = true;
|
||||
wg = (WorldGuardPlugin) pm.getPlugin("WorldGuard");
|
||||
}
|
||||
|
||||
public boolean check(Player p, Location l){
|
||||
if(p.isOp()){return true;}
|
||||
if(!this.enabled){return true;}
|
||||
if(this.wg == null){return true;}
|
||||
try{
|
||||
return this.wg.canBuild(p, l);
|
||||
}catch(Exception e){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
454
src/de/Ste3et_C0st/Furniture/Main/Manager/Manager.java
Normal file
454
src/de/Ste3et_C0st/Furniture/Main/Manager/Manager.java
Normal file
@ -0,0 +1,454 @@
|
||||
package de.Ste3et_C0st.Furniture.Main.Manager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import de.Ste3et_C0st.Furniture.Main.Utils;
|
||||
import de.Ste3et_C0st.Furniture.Main.config;
|
||||
import de.Ste3et_C0st.Furniture.Main.main;
|
||||
import de.Ste3et_C0st.Furniture.Main.option;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.chair;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.largeTable;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.latern;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.sofa;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.table;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.barrels;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.campfire_1;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.campfire_2;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_1;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_2;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_3;
|
||||
|
||||
public class Manager {
|
||||
private static config cc;
|
||||
private static FileConfiguration fc;
|
||||
private String folder = "/objects/";
|
||||
|
||||
public void load(String s){
|
||||
cc = new config();
|
||||
option o = new option();
|
||||
try{
|
||||
if(cc.ExistConfig(folder, s+ ".yml")){
|
||||
fc = cc.getConfig(s+".yml", folder);
|
||||
if(fc.isSet("Furniture."+s)){
|
||||
for(String str : fc.getConfigurationSection("Furniture." + s).getKeys(false)){
|
||||
String path = "Furniture." + s;
|
||||
path+= "." + str;
|
||||
Double x = fc.getDouble(path+".Location.x");
|
||||
Double y = fc.getDouble(path+".Location.y");
|
||||
Double z = fc.getDouble(path+".Location.z");
|
||||
World w = Bukkit.getWorld(fc.getString(path+".Location.w"));
|
||||
String face = fc.getString(path+".Location.face");
|
||||
Location l = new Location(w, x, y, z);
|
||||
float yaw = Utils.FaceToYaw(Utils.StringToFace(face));
|
||||
l.setYaw(yaw);
|
||||
|
||||
if(s.equalsIgnoreCase("chair")){
|
||||
new chair(l, main.getInstance(), str);
|
||||
}
|
||||
|
||||
if(s.equalsIgnoreCase("largeTable")){
|
||||
largeTable large = new largeTable(l, main.getInstance(), str);
|
||||
o.loadOptions(fc, large);
|
||||
}
|
||||
|
||||
if(s.equalsIgnoreCase("lantern")){
|
||||
latern later = new latern(l, main.getInstance(), str);
|
||||
o.loadOptions(fc, later);
|
||||
}
|
||||
|
||||
if(s.equalsIgnoreCase("sofa")){
|
||||
sofa sof = new sofa(l, main.getInstance(), str);
|
||||
o.loadOptions(fc, sof);
|
||||
}
|
||||
|
||||
|
||||
if(s.equalsIgnoreCase("table")){
|
||||
table tabl = new table(l, main.getInstance(), str);
|
||||
o.loadOptions(fc, tabl);
|
||||
}
|
||||
|
||||
if(s.equalsIgnoreCase("tent1")){
|
||||
tent_1 tent = new tent_1(l, main.getInstance(), str);
|
||||
o.loadOptions(fc, tent);
|
||||
}
|
||||
|
||||
if(s.equalsIgnoreCase("tent2")){
|
||||
tent_2 tent = new tent_2(l, main.getInstance(), str);
|
||||
o.loadOptions(fc, tent);
|
||||
}
|
||||
|
||||
if(s.equalsIgnoreCase("tent3")){
|
||||
tent_3 tent = new tent_3(l, main.getInstance(), str);
|
||||
o.loadOptions(fc, tent);
|
||||
}
|
||||
|
||||
if(s.equalsIgnoreCase("campfire1")){
|
||||
campfire_1 fire = new campfire_1(l, main.getInstance(), str);
|
||||
o.loadOptions(fc, fire);
|
||||
}
|
||||
|
||||
if(s.equalsIgnoreCase("campfire2")){
|
||||
campfire_2 fire = new campfire_2(l, main.getInstance(), str);
|
||||
o.loadOptions(fc, fire);
|
||||
}
|
||||
|
||||
if(s.equalsIgnoreCase("barrels")){
|
||||
barrels fire = new barrels(l, main.getInstance(), str);
|
||||
o.loadOptions(fc, fire);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch(Exception e){
|
||||
main.getInstance().shutdown("Config" + s);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveStuhl(chair c){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("chair",folder );
|
||||
if(!main.getInstance().getManager().chairList.isEmpty()){
|
||||
if(c==null){
|
||||
for(chair s : main.getInstance().getManager().chairList){
|
||||
save(s.getLocation(), "chair", s.getID());
|
||||
}
|
||||
}else{
|
||||
save(c.getLocation(), "chair", c.getID());
|
||||
}
|
||||
}
|
||||
cc.saveConfig("chair", fc, folder);
|
||||
}
|
||||
|
||||
public void saveLatern(latern l){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("lantern",folder );
|
||||
option o = new option();
|
||||
if(!main.getInstance().getManager().lanternList.isEmpty()){
|
||||
if(l==null){
|
||||
for(latern s : main.getInstance().getManager().lanternList){
|
||||
save(s.getLocation(), "lantern", s.getID());
|
||||
o.saveOption(fc, s);
|
||||
}
|
||||
}else{
|
||||
save(l.getLocation(), "lantern", l.getID());
|
||||
o.saveOption(fc, l);
|
||||
}
|
||||
}
|
||||
cc.saveConfig("lantern", fc, folder);
|
||||
}
|
||||
|
||||
public void saveCampFire1(campfire_1 l){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("campfire1",folder );
|
||||
option o = new option();
|
||||
if(!main.getInstance().getManager().campfire1List.isEmpty()){
|
||||
if(l==null){
|
||||
for(campfire_1 s : main.getInstance().getManager().campfire1List){
|
||||
save(s.getLocation(), "campfire1", s.getID());
|
||||
o.saveOption(fc, s);
|
||||
}
|
||||
}else{
|
||||
save(l.getLocation(), "campfire1", l.getID());
|
||||
o.saveOption(fc, l);
|
||||
}
|
||||
}
|
||||
cc.saveConfig("campfire1", fc, folder);
|
||||
}
|
||||
|
||||
public void saveCampFire2(campfire_2 l){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("campfire2",folder );
|
||||
option o = new option();
|
||||
if(!main.getInstance().getManager().campfire2List.isEmpty()){
|
||||
if(l==null){
|
||||
for(campfire_2 s : main.getInstance().getManager().campfire2List){
|
||||
save(s.getLocation(), "campfire2", s.getID());
|
||||
o.saveOption(fc, s);
|
||||
}
|
||||
}else{
|
||||
save(l.getLocation(), "campfire2", l.getID());
|
||||
o.saveOption(fc, l);
|
||||
}
|
||||
}
|
||||
cc.saveConfig("campfire2", fc, folder);
|
||||
}
|
||||
|
||||
public void save(Location l, String file, String ID){
|
||||
String path = "Furniture." + file;
|
||||
path = "Furniture."+file+"."+ID;
|
||||
fc.set(path+".Location.x",round(l.getX(), 2));
|
||||
fc.set(path+".Location.y",round(l.getY(), 2));
|
||||
fc.set(path+".Location.z",round(l.getZ(), 2));
|
||||
fc.set(path+".Location.w", l.getWorld().getName());
|
||||
fc.set(path+".Location.face", Utils.yawToFace(l.getYaw()).name());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void saveSofa(sofa sof){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("sofa",folder );
|
||||
option o = new option();
|
||||
if(!main.getInstance().getManager().sofaList.isEmpty()){
|
||||
if(sof==null){
|
||||
for(sofa s : main.getInstance().getManager().sofaList){
|
||||
save(s.getLocation(), "sofa", s.getID());
|
||||
o.saveOption(fc, s);
|
||||
}
|
||||
}else{
|
||||
save(sof.getLocation(), "sofa", sof.getID());
|
||||
o.saveOption(fc, sof);
|
||||
}
|
||||
}
|
||||
cc.saveConfig("sofa", fc, folder);
|
||||
}
|
||||
|
||||
public void saveTable(table t){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("table",folder );
|
||||
option o = new option();
|
||||
if(!main.getInstance().getManager().tableList.isEmpty()){
|
||||
if(t==null){
|
||||
for(table s : main.getInstance().getManager().tableList){
|
||||
save(s.getLocation(), "table", s.getID());
|
||||
o.saveOption(fc, s);
|
||||
}
|
||||
}else{
|
||||
save(t.getLocation(), "table", t.getID());
|
||||
o.saveOption(fc, t);
|
||||
}
|
||||
}
|
||||
cc.saveConfig("table", fc, folder);
|
||||
}
|
||||
|
||||
public void saveBarrel(barrels barrel) {
|
||||
cc = new config();
|
||||
fc = cc.getConfig("barrels",folder );
|
||||
option o = new option();
|
||||
if(!main.getInstance().getManager().barrelList.isEmpty()){
|
||||
if(barrel==null){
|
||||
for(barrels s : main.getInstance().getManager().barrelList){
|
||||
save(s.getLocation(), "barrels", s.getID());
|
||||
o.saveOption(fc, s);
|
||||
}
|
||||
}else{
|
||||
save(barrel.getLocation(), "barrels", barrel.getID());
|
||||
o.saveOption(fc, barrel);
|
||||
}
|
||||
}
|
||||
cc.saveConfig("barrels", fc, folder);
|
||||
}
|
||||
|
||||
public void saveTent1(tent_1 tent){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("tent1",folder );
|
||||
option o = new option();
|
||||
if(!main.getInstance().getManager().tent1List.isEmpty()){
|
||||
if(tent == null){
|
||||
for(tent_1 s : main.getInstance().getManager().tent1List){
|
||||
save(s.getLocation(), "tent1", s.getID());
|
||||
o.saveOption(fc, s);
|
||||
}
|
||||
}else{
|
||||
save(tent.getLocation(), "tent1", tent.getID());
|
||||
o.saveOption(fc, tent);
|
||||
}
|
||||
|
||||
}
|
||||
cc.saveConfig("tent1", fc, folder);
|
||||
}
|
||||
|
||||
public void saveLargeTable(largeTable table){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("largeTable",folder );
|
||||
option o = new option();
|
||||
if(!main.getInstance().getManager().largeTableList.isEmpty()){
|
||||
if(table == null){
|
||||
for(largeTable s : main.getInstance().getManager().largeTableList){
|
||||
save(s.getLocation(), "largeTable", s.getID());
|
||||
o.saveOption(fc, s);
|
||||
}
|
||||
}else{
|
||||
save(table.getLocation(), "largeTable", table.getID());
|
||||
o.saveOption(fc, table);
|
||||
}
|
||||
}
|
||||
cc.saveConfig("largeTable", fc, folder);
|
||||
}
|
||||
|
||||
public void deleteFromConfig(String ID, String type){
|
||||
cc = new config();
|
||||
if(cc.ExistConfig(folder, type+".yml")){
|
||||
fc = cc.getConfig(type, folder);
|
||||
if(fc.isSet("Furniture." + type + "." + ID)){
|
||||
fc.set("Furniture." + type + "." + ID, null);
|
||||
}
|
||||
cc.saveConfig(type, fc, folder);
|
||||
}
|
||||
}
|
||||
|
||||
public static double round(double value, int places) {
|
||||
if (places < 0) throw new IllegalArgumentException();
|
||||
|
||||
long factor = (long) Math.pow(10, places);
|
||||
value = value * factor;
|
||||
long tmp = Math.round(value);
|
||||
return (double) tmp / factor;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void defaultCrafting(){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("crafting.yml", "");
|
||||
fc.addDefaults(YamlConfiguration.loadConfiguration(main.getInstance().getResource("crafting.yml")));
|
||||
fc.options().copyDefaults(true);
|
||||
cc.saveConfig("crafting.yml", fc, "");
|
||||
}
|
||||
|
||||
public void loadCrafting(String s){
|
||||
try{
|
||||
ShapedRecipe recipe = new ShapedRecipe(returnResult(s)).shape(returnFragment(s)[0], returnFragment(s)[1], returnFragment(s)[2]);
|
||||
for(Character c : returnMaterial(s).keySet()){
|
||||
if(!returnMaterial(s).get(c).equals(Material.AIR)){
|
||||
recipe.setIngredient(c.charValue(), returnMaterial(s).get(c));
|
||||
}
|
||||
}
|
||||
Bukkit.getServer().addRecipe(recipe);
|
||||
main.getInstance().crafting.put(s, recipe.getResult());
|
||||
}catch(Exception e){
|
||||
main.getInstance().shutdown("Crafting");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean check(String s){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("crafting.yml", "");
|
||||
String path = "Items." + s;
|
||||
if(fc.getString(path + ".crafting") == null){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ItemStack returnResult(String s){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("crafting.yml", "");
|
||||
String path = "Items." + s;
|
||||
Integer MaterialID = fc.getInt(path+".material");
|
||||
Short shor = (short) fc.getInt(path+".durability");
|
||||
ItemStack is = new ItemStack(Material.getMaterial(MaterialID));
|
||||
ItemMeta im = is.getItemMeta();
|
||||
im.setDisplayName(ChatColor.translateAlternateColorCodes('&', fc.getString(path+".name")));
|
||||
is.setItemMeta(im);
|
||||
is.setDurability(shor);
|
||||
is.setAmount(1);
|
||||
return is;
|
||||
}
|
||||
|
||||
public String[] returnFragment(String s){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("crafting.yml", "");
|
||||
String path = "Items." + s;
|
||||
String recipe = fc.getString(path+".crafting.recipe");
|
||||
String[] fragments = recipe.split(",");
|
||||
return fragments;
|
||||
}
|
||||
|
||||
public List<String> returnCharacters(String s){
|
||||
List<String> stringList = new ArrayList<String>();
|
||||
for(String str: returnFragment(s)){
|
||||
String[] sl = str.split("(?!^)");
|
||||
for(String o : sl){
|
||||
if(!stringList.contains(o)){
|
||||
stringList.add(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
return stringList;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public HashMap<Character,Material> returnMaterial(String s){
|
||||
cc = new config();
|
||||
fc = cc.getConfig("crafting.yml", "");
|
||||
String path = "Items." + s;
|
||||
List<String> stringList = returnCharacters(s);
|
||||
HashMap<Character, Material> materialHash = new HashMap<Character, Material>();
|
||||
for(String str : stringList){
|
||||
Character chars = str.charAt(0);
|
||||
Integer MaterialID = fc.getInt(path+".crafting.index." + str);
|
||||
Material material = Material.getMaterial(MaterialID);
|
||||
materialHash.put(chars, material);
|
||||
}
|
||||
return materialHash;
|
||||
}
|
||||
|
||||
public List<ItemStack> getList(FileConfiguration fc, String s){
|
||||
List<ItemStack> itemlist = new ArrayList<ItemStack>();
|
||||
if(fc.isSet(s)){
|
||||
for(String string : fc.getConfigurationSection(s).getKeys(false)){
|
||||
ItemStack is = new ItemStack(Material.getMaterial(fc.getString(s+"."+string+".material")));
|
||||
ItemMeta im = is.getItemMeta();
|
||||
im.setDisplayName(main.createRandomRegistryId());
|
||||
is.setDurability((short) fc.getInt(s+"."+string+".durability"));
|
||||
is.setItemMeta(im);
|
||||
itemlist.add(is);
|
||||
}
|
||||
}
|
||||
return itemlist;
|
||||
}
|
||||
|
||||
public void saveTent2(tent_2 tent) {
|
||||
cc = new config();
|
||||
fc = cc.getConfig("tent2",folder );
|
||||
option o = new option();
|
||||
if(!main.getInstance().getManager().tent2List.isEmpty()){
|
||||
if(tent == null){
|
||||
for(tent_2 s : main.getInstance().getManager().tent2List){
|
||||
save(s.getLocation(), "tent2", s.getID());
|
||||
o.saveOption(fc, s);
|
||||
}
|
||||
}else{
|
||||
save(tent.getLocation(), "tent2", tent.getID());
|
||||
o.saveOption(fc, tent);
|
||||
}
|
||||
|
||||
}
|
||||
cc.saveConfig("tent2", fc, folder);
|
||||
}
|
||||
|
||||
public void saveTent3(tent_3 tent) {
|
||||
cc = new config();
|
||||
fc = cc.getConfig("tent3",folder );
|
||||
option o = new option();
|
||||
if(!main.getInstance().getManager().tent3List.isEmpty()){
|
||||
if(tent == null){
|
||||
for(tent_3 s : main.getInstance().getManager().tent3List){
|
||||
save(s.getLocation(), "tent3", s.getID());
|
||||
o.saveOption(fc, s);
|
||||
}
|
||||
}else{
|
||||
save(tent.getLocation(), "tent3", tent.getID());
|
||||
o.saveOption(fc, tent);
|
||||
}
|
||||
|
||||
}
|
||||
cc.saveConfig("tent3", fc, folder);
|
||||
}
|
||||
}
|
60
src/de/Ste3et_C0st/Furniture/Main/StringPage.java
Normal file
60
src/de/Ste3et_C0st/Furniture/Main/StringPage.java
Normal file
@ -0,0 +1,60 @@
|
||||
package de.Ste3et_C0st.Furniture.Main;
|
||||
|
||||
import static org.bukkit.util.NumberConversions.ceil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class StringPage {
|
||||
|
||||
public void returnStringPage(CommandSender sender, HashMap<String, ItemStack> map, Integer page, Integer perside){
|
||||
if(sender==null){return;}
|
||||
if(map==null||map.isEmpty()){return;}
|
||||
if(page==null||page==0){page=1;}
|
||||
|
||||
List<String> strings = getList(map);
|
||||
List<String> stringL = new ArrayList<String>();
|
||||
Collections.sort(strings);
|
||||
Integer max = page*perside;
|
||||
Integer min = page*perside-perside;
|
||||
|
||||
Integer l = 0;
|
||||
for(String s : strings){
|
||||
if(l>=min&&l<max){
|
||||
stringL.add(s);
|
||||
}
|
||||
l++;
|
||||
}
|
||||
|
||||
if(!stringL.isEmpty()){
|
||||
for(String s : stringL){
|
||||
sender.sendMessage(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getList(HashMap<String, ItemStack> map){
|
||||
if(map==null||map.isEmpty()){return null;}
|
||||
List<String> stringlist = new ArrayList<String>();
|
||||
for(String s : map.keySet()){
|
||||
stringlist.add(s);
|
||||
}
|
||||
return stringlist;
|
||||
}
|
||||
|
||||
public boolean check(CommandSender sender, HashMap<String, ItemStack> stringList, Integer page, Integer perside){
|
||||
if(sender==null){return false;}
|
||||
if(stringList==null||stringList.isEmpty()){return false;}
|
||||
if(page==null||page==0){page=1;}
|
||||
int numPages = ceil((double)stringList.size()/(double)perside);
|
||||
if(page > numPages){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
10
src/de/Ste3et_C0st/Furniture/Main/Type.java
Normal file
10
src/de/Ste3et_C0st/Furniture/Main/Type.java
Normal file
@ -0,0 +1,10 @@
|
||||
package de.Ste3et_C0st.Furniture.Main;
|
||||
|
||||
public class Type {
|
||||
|
||||
public enum FurnitureType{
|
||||
CHAIR, LARGE_TABLE, LATERN, SOFA,
|
||||
TABLE, BARRELS, CAMPFIRE_1, CAMPFIRE_2,
|
||||
TENT_1, TENT_2, TENT_3
|
||||
};
|
||||
}
|
@ -1,11 +1,15 @@
|
||||
package de.Ste3et_C0st.Furniture.Main;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@ -15,7 +19,13 @@ import org.bukkit.util.EulerAngle;
|
||||
public class Utils {
|
||||
|
||||
public static final BlockFace[] axis = { BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST };
|
||||
|
||||
public static List<BlockFace> axisList = Arrays.asList(BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST);
|
||||
public static final BlockFace[] radial = { BlockFace.NORTH, BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST, BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST };
|
||||
|
||||
public static BlockFace yawToFaceRadial(float yaw) {
|
||||
return radial[Math.round(yaw / 45f) & 0x7];
|
||||
}
|
||||
|
||||
public static BlockFace yawToFace(float yaw) {
|
||||
return axis[Math.round(yaw / 90f) & 0x3];
|
||||
}
|
||||
@ -30,6 +40,16 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean day(World w) {
|
||||
long time = w.getTime();
|
||||
|
||||
if(time > 0 && time < 12300) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static BlockFace StringToFace(final String face) {
|
||||
switch (face) {
|
||||
case "NORTH": return BlockFace.NORTH;
|
||||
@ -40,6 +60,93 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void setBed(BlockFace face, Location l) {
|
||||
if(face == BlockFace.NORTH){
|
||||
l.getBlock().setType(Material.AIR);
|
||||
l.getBlock().setType(Material.BED_BLOCK);
|
||||
Block block = l.getBlock();
|
||||
BlockState bedFoot = block.getState();
|
||||
BlockState bedHead = bedFoot.getBlock().getRelative(BlockFace.SOUTH).getState();
|
||||
bedFoot.setType(Material.BED_BLOCK);
|
||||
bedHead.setType(Material.BED_BLOCK);
|
||||
bedFoot.setRawData((byte) 0);
|
||||
bedHead.setRawData((byte) 8);
|
||||
bedFoot.update(true, false);
|
||||
bedHead.update(true, true);
|
||||
}else if(face == BlockFace.EAST){
|
||||
l.getBlock().setType(Material.AIR);
|
||||
l.getBlock().setType(Material.BED_BLOCK);
|
||||
Block block = l.getBlock();
|
||||
BlockState bedFoot = block.getState();
|
||||
BlockState bedHead = bedFoot.getBlock().getRelative(BlockFace.WEST).getState();
|
||||
bedFoot.setType(Material.BED_BLOCK);
|
||||
bedHead.setType(Material.BED_BLOCK);
|
||||
bedFoot.setRawData((byte) 1);
|
||||
bedHead.setRawData((byte) 9);
|
||||
bedFoot.update(true, false);
|
||||
bedHead.update(true, true);
|
||||
}else if(face == BlockFace.SOUTH){
|
||||
l.getBlock().setType(Material.AIR);
|
||||
l.getBlock().setType(Material.BED_BLOCK);
|
||||
Block block = l.getBlock();
|
||||
BlockState bedFoot = block.getState();
|
||||
BlockState bedHead = bedFoot.getBlock().getRelative(BlockFace.NORTH).getState();
|
||||
bedFoot.setType(Material.BED_BLOCK);
|
||||
bedHead.setType(Material.BED_BLOCK);
|
||||
bedFoot.setRawData((byte) 2);
|
||||
bedHead.setRawData((byte) 10);
|
||||
bedFoot.update(true, false);
|
||||
bedHead.update(true, true);
|
||||
}else if(face == BlockFace.WEST){
|
||||
l.getBlock().setType(Material.AIR);
|
||||
l.getBlock().setType(Material.BED_BLOCK);
|
||||
Block block = l.getBlock();
|
||||
BlockState bedFoot = block.getState();
|
||||
BlockState bedHead = bedFoot.getBlock().getRelative(BlockFace.EAST).getState();
|
||||
bedFoot.setType(Material.BED_BLOCK);
|
||||
bedHead.setType(Material.BED_BLOCK);
|
||||
bedFoot.setRawData((byte) 3);
|
||||
bedHead.setRawData((byte) 11);
|
||||
bedFoot.update(true, false);
|
||||
bedHead.update(true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Block setHalfBed(BlockFace face, Location l) {
|
||||
if(face == BlockFace.NORTH){
|
||||
Block block = l.getBlock();
|
||||
BlockState bedHead = block.getState();
|
||||
bedHead.setType(Material.BED_BLOCK);
|
||||
bedHead.setRawData((byte) 9);
|
||||
bedHead.update(true, false);
|
||||
return block;
|
||||
}else if(face == BlockFace.EAST){
|
||||
Block block = l.getBlock();
|
||||
BlockState bedHead = block.getState();
|
||||
bedHead.setType(Material.BED_BLOCK);
|
||||
bedHead.setRawData((byte) 10);
|
||||
bedHead.update(true, false);
|
||||
return block;
|
||||
}else if(face == BlockFace.SOUTH){
|
||||
Block block = l.getBlock();
|
||||
BlockState bedHead = block.getState();
|
||||
bedHead.setType(Material.BED_BLOCK);
|
||||
bedHead.setRawData((byte) 11);
|
||||
bedHead.update(true, false);
|
||||
return block;
|
||||
}else if(face == BlockFace.WEST){
|
||||
Block block = l.getBlock();
|
||||
BlockState bedHead = block.getState();
|
||||
bedHead.setType(Material.BED_BLOCK);
|
||||
bedHead.setRawData((byte) 8);
|
||||
bedHead.update(true, false);
|
||||
return block;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int randInt(int min, int max) {
|
||||
Random rand = new Random();
|
||||
int randomNum = rand.nextInt((max - min) + 1) + min;
|
||||
@ -63,12 +170,12 @@ public class Utils {
|
||||
return d;
|
||||
}
|
||||
|
||||
public static ArmorStand setArmorStand(Location location, EulerAngle angle, ItemStack is, Boolean Arm, String ID, List<String> idList){
|
||||
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().equals(id)){
|
||||
if(entity.getCustomName()!=null&&entity.getCustomName().equals(id)){
|
||||
idList.add(id);
|
||||
return (ArmorStand) entity;
|
||||
}
|
||||
@ -83,22 +190,46 @@ public class Utils {
|
||||
if(angle!=null){as.setHeadPose(angle);}
|
||||
if(is!=null){as.setHelmet(is);}
|
||||
}
|
||||
as.setVisible(false);
|
||||
as.setSmall(mini);
|
||||
as.setVisible(invisible);
|
||||
as.setGravity(false);
|
||||
as.setBasePlate(false);
|
||||
as.setCustomName(id);
|
||||
idList.add(id);
|
||||
return as;
|
||||
}
|
||||
|
||||
public static Integer getRound(float f){
|
||||
float circle = 360;
|
||||
return (int) (circle/f);
|
||||
}
|
||||
|
||||
public static ArmorStand getArmorStandAtID(World w, String string){
|
||||
for(Entity e : w.getEntities()){
|
||||
if(e instanceof ArmorStand){
|
||||
if(e.getCustomName().equalsIgnoreCase(string)){
|
||||
if(e!= null && e.getCustomName()!=null && e.getCustomName().equalsIgnoreCase(string)){
|
||||
return (ArmorStand) e;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Boolean isDouble(String s){
|
||||
try{
|
||||
Double.parseDouble(s);
|
||||
return true;
|
||||
}catch(NumberFormatException e){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Boolean isInt(String s){
|
||||
try{
|
||||
Integer.parseInt(s);
|
||||
return true;
|
||||
}catch(NumberFormatException e){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,22 @@
|
||||
package de.Ste3et_C0st.Furniture.Main;
|
||||
|
||||
import java.io.File;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class command implements CommandExecutor {
|
||||
import de.Ste3et_C0st.Furniture.Main.Type.FurnitureType;
|
||||
|
||||
public class command implements CommandExecutor {
|
||||
private static config cc;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String arg2, String[] args) {
|
||||
if(cmd.getName().equalsIgnoreCase("furniture")){
|
||||
@ -19,11 +26,105 @@ public class command implements CommandExecutor {
|
||||
String help = "§7================[§2Furniture§7]================\n";
|
||||
help += "§2/furniture list | §8list all available furniture\n";
|
||||
help += "§2/furniture give <PLAYER> <FURNITURE> | §8give one player one furniture\n";
|
||||
|
||||
help += "§2/furniture give <FURNITURE> | §8give you an furniture\n";
|
||||
help += "§2/furniture killall | §8Killall Furnitures\n";
|
||||
help += "§2/furniture remove radius <DISTANCE> | §8Remove furniture in radius\n";
|
||||
help += "§2/furniture remove <type> | §8Remove all furnitures by type";
|
||||
help += "§2/furniture remove <ID> | §8Remove a furniture by id";
|
||||
help += "§2/furniture reload | §8Reload the plugin\n";
|
||||
help += "§7=========================================";
|
||||
if(sender instanceof Player){
|
||||
help += "§2/furniture give <FURNITURE> | §8give you an furniture\n";
|
||||
if(args.length == 2){
|
||||
if(args[0].equalsIgnoreCase("give")){
|
||||
if(args.length == 1){
|
||||
if(args[0].equalsIgnoreCase("killall")){
|
||||
if(sender.hasPermission("furniture.admin")){
|
||||
main.getInstance().removeAll();
|
||||
Integer i = 0;
|
||||
for(World w : main.getInstance().getServer().getWorlds()){
|
||||
for(Entity e : w.getEntities()){
|
||||
if(e!=null && e instanceof ArmorStand){
|
||||
String name = e.getName();
|
||||
if(name != null && name.length()>=13){
|
||||
String[] split = name.split("-");
|
||||
if(split != null && split.length>=1){
|
||||
i++;
|
||||
e.remove();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
cc = new config();
|
||||
main.getInstance().removeAll();
|
||||
String s = main.getInstance().getConfig().getString("config.Messages.ArmorStandsKills");
|
||||
s = s.replace("@ARMORSTANDS", i.toString()).replace("@WOLRDS", main.getInstance().getServer().getWorlds().size() + "");
|
||||
((Player) sender).sendMessage(ChatColor.translateAlternateColorCodes('&', s));
|
||||
cc.deleteFolder(new File("plugins/Furniture/objects"));
|
||||
return true;
|
||||
}else{
|
||||
((Player) sender).sendMessage(noPermissions);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}else if(args.length == 2){
|
||||
if(args[0].equalsIgnoreCase("remove")){
|
||||
if(!sender.hasPermission("furniture.admin")){sender.sendMessage(noPermissions);return true;}
|
||||
if(getType(args[1])!=null){
|
||||
Boolean b = main.getInstance().getManager().RemoveType(getType(args[1]), true);
|
||||
String s = ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.ArmorStandsRemoveFromType"));
|
||||
String[] split = s.split(" ");
|
||||
Integer i = 0;
|
||||
String string = "";
|
||||
String stings = "";
|
||||
for(String str : split){
|
||||
if(str.startsWith("[") && str.endsWith("]")){
|
||||
str = str.replace("[", "");
|
||||
str = str.replace("]", "");
|
||||
stings = str;
|
||||
if(b){
|
||||
String[] l = stings.split("#");
|
||||
string = l[1];
|
||||
}else{
|
||||
String[] l = stings.split("#");
|
||||
string = l[0];
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
sender.sendMessage(s.replace(stings, string).replace("[", "").replace("]", ""));
|
||||
return true;
|
||||
}else if(args[1] != null && args[1].length()>=13){
|
||||
String[] split = args[1].split("-");
|
||||
if(split != null && split.length>=1){
|
||||
Boolean b = main.getInstance().getManager().RemoveFromID(args[1]);
|
||||
String s = ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.ArmorStandsRemoveFromID"));
|
||||
String[] splits = s.split(" ");
|
||||
Integer i = 0;
|
||||
String string = "";
|
||||
String stings = "";
|
||||
for(String str : splits){
|
||||
if(str.startsWith("[") && str.endsWith("]")){
|
||||
str = str.replace("[", "");
|
||||
str = str.replace("]", "");
|
||||
stings = str;
|
||||
if(b){
|
||||
String[] l = stings.split("#");
|
||||
string = l[1];
|
||||
}else{
|
||||
String[] l = stings.split("#");
|
||||
string = l[0];
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
sender.sendMessage(s.replace(stings, string).replace("[", "").replace("]", ""));
|
||||
return true;
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.CommandBadArguments")));
|
||||
return true;
|
||||
}
|
||||
}else if(args[0].equalsIgnoreCase("give")){
|
||||
if(!sender.hasPermission("furniture.give")){sender.sendMessage(noPermissions);return true;}
|
||||
if(isExist(args[1])){
|
||||
if(!sender.hasPermission("furniture.give." + args[1].toLowerCase())){sender.sendMessage(noPermissions);return true;}
|
||||
@ -33,21 +134,47 @@ public class command implements CommandExecutor {
|
||||
sender.sendMessage(notFound);
|
||||
return true;
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage(help);
|
||||
return true;
|
||||
}
|
||||
}else if(args.length == 3){
|
||||
if(args[0].equalsIgnoreCase("remove")){
|
||||
if(!sender.hasPermission("furniture.admin")){sender.sendMessage(noPermissions);return true;}
|
||||
if(args[1].equalsIgnoreCase("radius")){
|
||||
Double d = 0.0;
|
||||
if(Utils.isInt(args[2])){
|
||||
d = (double) Integer.parseInt(args[2]);
|
||||
}
|
||||
if(Utils.isDouble(args[2])){
|
||||
d = Double.parseDouble(args[2]);
|
||||
}
|
||||
if(d!=0.0){
|
||||
Integer i = main.getInstance().getManager().RemoveFromDistance(((Player) sender).getLocation().toVector(), d);
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.ArmorStandsRemoveFromDistance")).replace("@ARMORSTANDS", i.toString()));
|
||||
return true;
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.CommandBadArguments")));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
help += "§7=========================================";
|
||||
|
||||
if(args.length == 1){
|
||||
if(args[0].equalsIgnoreCase("list")){
|
||||
if(sender.hasPermission("furniture.list")){
|
||||
sender.sendMessage("§7Furniture: ");
|
||||
for(String a : main.getInstance().crafting.keySet()){
|
||||
sender.sendMessage("§6- " + a);
|
||||
}
|
||||
sender.sendMessage("§6=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
|
||||
main.getInstance().getStringPage().returnStringPage(sender, main.getInstance().crafting, 0, 10);
|
||||
sender.sendMessage("§6=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
|
||||
sender.sendMessage("§2Type /furniture list <page>");
|
||||
return true;
|
||||
}else{
|
||||
sender.sendMessage(noPermissions);
|
||||
return true;
|
||||
}
|
||||
}else if(args[0].equalsIgnoreCase("reload")){
|
||||
if(sender.hasPermission("furniture.admin")){
|
||||
main.getInstance().reload();
|
||||
sender.sendMessage("§bPlugin reloaded");
|
||||
return true;
|
||||
}else{
|
||||
sender.sendMessage(noPermissions);
|
||||
@ -55,6 +182,7 @@ public class command implements CommandExecutor {
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage(help);
|
||||
return true;
|
||||
}
|
||||
}else if(args.length == 3){
|
||||
if(args[0].equalsIgnoreCase("give")){
|
||||
@ -68,6 +196,83 @@ public class command implements CommandExecutor {
|
||||
sender.sendMessage(help);
|
||||
return true;
|
||||
}
|
||||
}else if(args.length == 2){
|
||||
if(args[0].equalsIgnoreCase("remove")){
|
||||
if(!sender.hasPermission("furniture.admin")){sender.sendMessage(noPermissions);return true;}
|
||||
if(getType(args[1])!=null){
|
||||
Boolean b = main.getInstance().getManager().RemoveType(getType(args[1]), true);
|
||||
String s = ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.ArmorStandsRemoveFromType"));
|
||||
String[] split = s.split(" ");
|
||||
Integer i = 0;
|
||||
String string = "";
|
||||
String stings = "";
|
||||
for(String str : split){
|
||||
if(str.startsWith("[") && str.endsWith("]")){
|
||||
stings = str;
|
||||
if(b){
|
||||
string = str.split("|")[1];
|
||||
}
|
||||
if(!b){
|
||||
string = str.split("|")[0];
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
sender.sendMessage(s.replace(stings, string));
|
||||
return true;
|
||||
}else if(args[1] != null && args[1].length()>=13){
|
||||
String[] split = args[1].split("-");
|
||||
if(split != null && split.length>=1){
|
||||
Boolean b = main.getInstance().getManager().RemoveFromID(args[1]);
|
||||
String s = ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.ArmorStandsRemoveFromID"));
|
||||
String[] splits = s.split(" ");
|
||||
Integer i = 0;
|
||||
String string = "";
|
||||
String stings = "";
|
||||
for(String str : splits){
|
||||
if(str.startsWith("[") && str.endsWith("]")){
|
||||
stings = str;
|
||||
if(b){
|
||||
string = str.split("|")[1];
|
||||
}
|
||||
if(!b){
|
||||
string = str.split("|")[0];
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
sender.sendMessage(s.replace(stings, string));
|
||||
return true;
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.CommandBadArguments")));
|
||||
return true;
|
||||
}
|
||||
}else if(args[0].equalsIgnoreCase("list")){
|
||||
if(sender.hasPermission("furniture.list")){
|
||||
if(Utils.isInt(args[1])){
|
||||
if(main.getInstance().getStringPage().check(sender, main.getInstance().crafting, Integer.parseInt(args[1]), 10)){
|
||||
sender.sendMessage("§6=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
|
||||
main.getInstance().getStringPage().returnStringPage(sender, main.getInstance().crafting, Integer.parseInt(args[1]), 10);
|
||||
sender.sendMessage("§6=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
|
||||
sender.sendMessage("§2Type /furniture list <page>");
|
||||
return true;
|
||||
}else{
|
||||
sender.sendMessage("§cSide not found");
|
||||
return true;
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("config.Messages.CommandBadArguments")));
|
||||
}
|
||||
return true;
|
||||
}else{
|
||||
sender.sendMessage(noPermissions);
|
||||
return true;
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage(help);
|
||||
return true;
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage(help);
|
||||
return true;
|
||||
@ -76,6 +281,21 @@ public class command implements CommandExecutor {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public FurnitureType getType(String s){
|
||||
if(s.equalsIgnoreCase("chair")){return FurnitureType.CHAIR;}
|
||||
if(s.equalsIgnoreCase("largetable")){return FurnitureType.LARGE_TABLE;}
|
||||
if(s.equalsIgnoreCase("lantern")){return FurnitureType.LATERN;}
|
||||
if(s.equalsIgnoreCase("sofa")){return FurnitureType.SOFA;}
|
||||
if(s.equalsIgnoreCase("table")){return FurnitureType.TABLE;}
|
||||
if(s.equalsIgnoreCase("barrels")){return FurnitureType.BARRELS;}
|
||||
if(s.equalsIgnoreCase("campfire1")){return FurnitureType.CAMPFIRE_1;}
|
||||
if(s.equalsIgnoreCase("campfire2")){return FurnitureType.CAMPFIRE_2;}
|
||||
if(s.equalsIgnoreCase("tent1")){return FurnitureType.TENT_1;}
|
||||
if(s.equalsIgnoreCase("tent2")){return FurnitureType.TENT_2;}
|
||||
if(s.equalsIgnoreCase("tent3")){return FurnitureType.TENT_3;}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isExist(String s){
|
||||
for(String a : main.getInstance().crafting.keySet()){
|
||||
|
@ -1,79 +1,173 @@
|
||||
package de.Ste3et_C0st.Furniture.Main;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.Metrics;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import de.Ste3et_C0st.Furniture.Main.Manager;
|
||||
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.Listener.IPistonExtendEvent;
|
||||
import de.Ste3et_C0st.Furniture.Listener.OnInteract;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.chair;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.largeTable;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.latern;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.sofa;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.table;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_1;
|
||||
|
||||
public class main extends JavaPlugin {
|
||||
private static main Main;
|
||||
public List<sofa> sofas = new ArrayList<sofa>();
|
||||
public List<latern> laternen = new ArrayList<latern>();
|
||||
public List<chair> stuehle = new ArrayList<chair>();
|
||||
public List<table> tische = new ArrayList<table>();
|
||||
public List<largeTable> tische2 = new ArrayList<largeTable>();
|
||||
private Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
public HashMap<String, ItemStack> crafting = new HashMap<String, ItemStack>();
|
||||
public Manager mgr;
|
||||
public List<tent_1> tents1 = new ArrayList<tent_1>();
|
||||
@SuppressWarnings("deprecation")
|
||||
public FurnitureManager Fmgr;
|
||||
public Boolean isCrafting = true;
|
||||
public CheckManager check;
|
||||
public StringPage sp;
|
||||
//public Factions factionsAPI = null;
|
||||
public Boolean light = false;
|
||||
@SuppressWarnings({ "deprecation" })
|
||||
@Override
|
||||
public void onEnable(){
|
||||
Main = this;
|
||||
getServer().getPluginManager().registerEvents(new OnInteract(), this);
|
||||
getCommand("furniture").setExecutor(new command());
|
||||
getConfig().addDefaults(YamlConfiguration.loadConfiguration(getResource("config.yml")));
|
||||
getConfig().options().copyDefaults(true);
|
||||
saveConfig();
|
||||
|
||||
if(getServer().getPluginManager().isPluginEnabled("Vault") && getConfig().getBoolean("config.UseMetrics")){
|
||||
try
|
||||
{
|
||||
Metrics metrics = new Metrics(this);
|
||||
metrics.start();
|
||||
}
|
||||
catch (IOException localIOException) {}
|
||||
}
|
||||
|
||||
this.mgr = new Manager();
|
||||
mgr.loadLargeTisch();
|
||||
mgr.loadLatern();
|
||||
mgr.loadSofa();
|
||||
mgr.loadStuhl();
|
||||
mgr.loadTisch();
|
||||
mgr.loadtent1();
|
||||
mgr.defaultCrafting();
|
||||
addCrafting();
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
log.info(pdfFile.getName() + " Version: " + pdfFile.getVersion() + " is now enabled!");
|
||||
Main = this;
|
||||
getServer().getPluginManager().registerEvents(new OnInteract(), this);
|
||||
getServer().getPluginManager().registerEvents(new IPistonExtendEvent(), this);
|
||||
getCommand("furniture").setExecutor(new command());
|
||||
|
||||
try{
|
||||
getConfig().addDefaults(YamlConfiguration.loadConfiguration(getResource("config.yml")));
|
||||
getConfig().options().copyDefaults(true);
|
||||
saveConfig();
|
||||
}catch(Exception e){
|
||||
shutdown("Config");
|
||||
}
|
||||
|
||||
if(getServer().getPluginManager().isPluginEnabled("Vault") && getConfig().getBoolean("config.UseMetrics")){
|
||||
try
|
||||
{
|
||||
Metrics metrics = new Metrics(this);
|
||||
metrics.start();
|
||||
}
|
||||
catch (IOException localIOException) {}
|
||||
}
|
||||
|
||||
if(main.getInstance().getServer().getPluginManager().isPluginEnabled("LightAPI")){
|
||||
this.light = true;
|
||||
}
|
||||
|
||||
this.sp = new StringPage();
|
||||
this.mgr = new Manager();
|
||||
this.Fmgr = new FurnitureManager();
|
||||
mgr.load("chair");
|
||||
mgr.load("lantern");
|
||||
mgr.load("table");
|
||||
mgr.load("largeTable");
|
||||
mgr.load("sofa");
|
||||
mgr.load("tent1");
|
||||
mgr.load("tent2");
|
||||
mgr.load("tent3");
|
||||
mgr.load("campfire1");
|
||||
mgr.load("barrels");
|
||||
mgr.load("campfire2");
|
||||
mgr.defaultCrafting();
|
||||
addCrafting();
|
||||
|
||||
isCrafting = getConfig().getBoolean("config.CraftingPermissions");
|
||||
|
||||
try {
|
||||
this.check = new CheckManager(this.getServer().getPluginManager());
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Double distance(Location loc1, Location loc2){
|
||||
Vector v1 = loc1.toVector();
|
||||
Vector v2 = loc1.toVector();
|
||||
return v1.distance(v2);
|
||||
}
|
||||
|
||||
public void removeAll(){
|
||||
Fmgr.RemoveType(FurnitureType.CHAIR, false);
|
||||
Fmgr.RemoveType(FurnitureType.LARGE_TABLE, false);
|
||||
Fmgr.RemoveType(FurnitureType.LATERN, false);
|
||||
Fmgr.RemoveType(FurnitureType.SOFA, false);
|
||||
Fmgr.RemoveType(FurnitureType.TABLE, false);
|
||||
Fmgr.RemoveType(FurnitureType.BARRELS, false);
|
||||
Fmgr.RemoveType(FurnitureType.CAMPFIRE_1, false);
|
||||
Fmgr.RemoveType(FurnitureType.CAMPFIRE_2, false);
|
||||
Fmgr.RemoveType(FurnitureType.TENT_1, false);
|
||||
Fmgr.RemoveType(FurnitureType.TENT_2, false);
|
||||
Fmgr.RemoveType(FurnitureType.TENT_3, false);
|
||||
}
|
||||
|
||||
public void reload(){
|
||||
//try{
|
||||
mgr.saveLargeTable(null);
|
||||
mgr.saveLatern(null);
|
||||
mgr.saveSofa(null);
|
||||
mgr.saveStuhl(null);
|
||||
mgr.saveTable(null);
|
||||
mgr.saveTent1(null);
|
||||
mgr.saveTent2(null);
|
||||
getServer().resetRecipes();
|
||||
removeAll();
|
||||
crafting.clear();
|
||||
isCrafting=false;
|
||||
|
||||
mgr.load("chair");
|
||||
mgr.load("lantern");
|
||||
mgr.load("table");
|
||||
mgr.load("largeTable");
|
||||
mgr.load("sofa");
|
||||
mgr.load("tent1");
|
||||
mgr.load("tent2");
|
||||
mgr.load("tent3");
|
||||
mgr.load("campfire1");
|
||||
mgr.load("barrels");
|
||||
mgr.load("campfire2");
|
||||
mgr.defaultCrafting();
|
||||
addCrafting();
|
||||
isCrafting = getConfig().getBoolean("config.CraftingPermissions");
|
||||
//}catch (Exception e) {
|
||||
// shutdown("Reload");
|
||||
//}
|
||||
}
|
||||
|
||||
public void shutdown(String s){
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
log.warning(pdfFile.getName() + " shutdown reason: " + s + "Exception");
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable(){
|
||||
mgr.saveLargeTable();
|
||||
mgr.saveLatern();
|
||||
mgr.saveSofa();
|
||||
mgr.saveStuhl();
|
||||
mgr.saveTable();
|
||||
mgr.saveTent1();
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
log.info(pdfFile.getName() + " Version: " + pdfFile.getVersion() + " is now disabled!");
|
||||
mgr.saveLargeTable(null);
|
||||
mgr.saveLatern(null);
|
||||
mgr.saveSofa(null);
|
||||
mgr.saveStuhl(null);
|
||||
mgr.saveTable(null);
|
||||
mgr.saveTent1(null);
|
||||
mgr.saveTent2(null);
|
||||
getServer().resetRecipes();
|
||||
}
|
||||
|
||||
@ -84,6 +178,11 @@ public class main extends JavaPlugin {
|
||||
mgr.loadCrafting("sofa");
|
||||
mgr.loadCrafting("chair");
|
||||
mgr.loadCrafting("tent1");
|
||||
mgr.loadCrafting("tent2");
|
||||
mgr.loadCrafting("tent3");
|
||||
mgr.loadCrafting("barrels");
|
||||
mgr.loadCrafting("campfire1");
|
||||
mgr.loadCrafting("campfire2");
|
||||
}
|
||||
|
||||
public static String getCardinalDirection(Player player) {
|
||||
@ -121,6 +220,35 @@ public class main extends JavaPlugin {
|
||||
if(b.equals(BlockFace.WEST)){
|
||||
l.add(z,0,-x);
|
||||
}
|
||||
|
||||
if(b.equals(BlockFace.NORTH_EAST)){
|
||||
l.add(x,0,z);
|
||||
l.add(-z,0,x);
|
||||
}
|
||||
|
||||
if(b.equals(BlockFace.NORTH_WEST)){
|
||||
l.add(x,0,z);
|
||||
l.add(z,0,-x);
|
||||
}
|
||||
|
||||
if(b.equals(BlockFace.SOUTH_EAST)){
|
||||
l.add(-x,0,-z);
|
||||
l.add(-z,0,x);
|
||||
}
|
||||
|
||||
if(b.equals(BlockFace.SOUTH_WEST)){
|
||||
l.add(-x,0,-z);
|
||||
l.add(z,0,-x);
|
||||
}
|
||||
|
||||
if(b.equals(BlockFace.UP)){
|
||||
l.add(0,z+x,0);
|
||||
}
|
||||
|
||||
if(b.equals(BlockFace.DOWN)){
|
||||
l.add(0,-z-x,0);
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
@ -154,69 +282,69 @@ public class main extends JavaPlugin {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static Color getDyeFromDurability(short s){
|
||||
if(s==0){return Color.fromRGB(25, 25, 25);}
|
||||
if(s==1){return Color.fromRGB(153, 51, 51);}
|
||||
if(s==2){return Color.fromRGB(102, 127, 51);}
|
||||
if(s==3){return Color.fromRGB(102, 76, 51);}
|
||||
if(s==4){return Color.fromRGB(51, 76, 178);}
|
||||
if(s==5){return Color.fromRGB(127, 63, 178);}
|
||||
if(s==6){return Color.fromRGB(76, 127, 153);}
|
||||
if(s==7){return Color.fromRGB(153, 153, 153);}
|
||||
if(s==8){return Color.fromRGB(76, 76, 76);}
|
||||
if(s==9){return Color.fromRGB(242, 127, 165);}
|
||||
if(s==10){return Color.fromRGB(127, 204, 25);}
|
||||
if(s==11){return Color.fromRGB(229, 229, 51);}
|
||||
if(s==12){return Color.fromRGB(102, 153, 216);}
|
||||
if(s==13){return Color.fromRGB(178, 76, 216);}
|
||||
if(s==14){return Color.fromRGB(216, 127, 51);}
|
||||
if(s==15){return Color.fromRGB(255, 255, 255);}
|
||||
return Color.fromRGB(255, 255, 255);
|
||||
}
|
||||
|
||||
public boolean canPlace(Player p, Location location, BlockFace b, Integer length){
|
||||
if(b==null&&length==null){
|
||||
if(!location.getBlock().getType().equals(Material.AIR)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(b!=null&&length!=null){
|
||||
for(int i = 0; i<= length-1; i++){
|
||||
if(!getNew(location, b, 0D,(double) i).getBlock().getType().equals(Material.AIR)){
|
||||
try{
|
||||
if(b==null&&length==null){
|
||||
if(!location.getBlock().getType().equals(Material.AIR)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canPlaceLarge(Player p, Location location, BlockFace b, Integer length, Integer width){
|
||||
if(b==null&&length==null&&width==null){
|
||||
if(!location.getBlock().getType().equals(Material.AIR)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
location = main.getNew(location, b.getOppositeFace(), 2D, 0D);
|
||||
if(b!=null&&length!=null&&width!=null){
|
||||
for(int i = 0; i<= length-1; i++){
|
||||
for(int l = 0; l<= width-1; l++){
|
||||
if(!getNew(location, b,(double) l,(double) i).getBlock().getType().equals(Material.AIR)){
|
||||
if(b!=null&&length!=null){
|
||||
for(int i = 0; i<= length-1; i++){
|
||||
Block bl = getNew(location, b, 0D,(double) i).getBlock();
|
||||
if(!(bl==null || bl.getType().equals(Material.AIR))){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}catch(Exception e){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<Location> getFunList(){
|
||||
List<Location> loc = new ArrayList<Location>();
|
||||
if(!this.stuehle.isEmpty()){
|
||||
for(chair s : stuehle){
|
||||
loc.add(s.getLocation());
|
||||
public boolean canPlaceLarge(Player p, Location location, BlockFace b, Integer length, Integer width){
|
||||
try{
|
||||
if(b==null&&length==null&&width==null){
|
||||
if(!location.getBlock().getType().equals(Material.AIR)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!this.laternen.isEmpty()){
|
||||
for(latern l : laternen){
|
||||
loc.add(l.getLocation());
|
||||
location = main.getNew(location, b.getOppositeFace(), 2D, 0D);
|
||||
if(b!=null&&length!=null&&width!=null){
|
||||
for(int i = 0; i<= length-1; i++){
|
||||
for(int l = 0; l<= width-1; l++){
|
||||
Block bl = getNew(location, b,(double) l,(double) i).getBlock();
|
||||
if(!(bl==null || bl.getType().equals(Material.AIR))){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}catch(Exception e){
|
||||
return false;
|
||||
}
|
||||
if(!this.tische2.isEmpty()){
|
||||
for(largeTable l : tische2){
|
||||
loc.add(l.getLocation());
|
||||
}
|
||||
}
|
||||
if(!this.sofas.isEmpty()){
|
||||
for(sofa s : sofas){
|
||||
loc.add(s.getLocation());
|
||||
}
|
||||
}
|
||||
if(!this.tische.isEmpty()){
|
||||
for(table t : tische){
|
||||
loc.add(t.getLocation());
|
||||
}
|
||||
}
|
||||
return loc;
|
||||
}
|
||||
|
||||
public static String createRandomRegistryId()
|
||||
@ -241,27 +369,37 @@ public class main extends JavaPlugin {
|
||||
return val;
|
||||
}
|
||||
|
||||
public static main getInstance() {return Main;}
|
||||
|
||||
public static main getInstance() {return Main;}
|
||||
|
||||
public boolean canPlaceTent(Player p, Location location, BlockFace b, Integer length, Integer width, Integer height){
|
||||
if(b==null&&length==null&&width==null){
|
||||
if(!location.getBlock().getType().equals(Material.AIR)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
location = main.getNew(location, b.getOppositeFace(), 3D, 0D);
|
||||
if(b!=null&&length!=null&&width!=null){
|
||||
for(int i = 0; i<= length-1; i++){
|
||||
for(int l = 0; l<= width-1; l++){
|
||||
for(int y=0;y<=height-1;y++){
|
||||
if(!getNew(location, b,(double) l,(double) i).add(0,y,0).getBlock().getType().equals(Material.AIR)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
try{
|
||||
if(b==null&&length==null&&width==null){
|
||||
if(!location.getBlock().getType().equals(Material.AIR)){
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("Config.Messages.Space")));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
location = main.getNew(location, b.getOppositeFace(), 3D, 0D);
|
||||
if(b!=null&&length!=null&&width!=null){
|
||||
for(int i = 0; i<= length-1; i++){
|
||||
for(int l = 0; l<= width-1; l++){
|
||||
for(int y=0;y<=height-1;y++){
|
||||
if(!getNew(location, b,(double) l,(double) i).add(0,y,0).getBlock().getType().equals(Material.AIR)){
|
||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', main.getInstance().getConfig().getString("Config.Messages.Space")));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}catch(Exception e){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public FurnitureManager getManager() {return this.Fmgr;}
|
||||
public CheckManager getCheckManager(){return this.check;}
|
||||
public StringPage getStringPage(){return this.sp;}
|
||||
}
|
||||
|
220
src/de/Ste3et_C0st/Furniture/Main/option.java
Normal file
220
src/de/Ste3et_C0st/Furniture/Main/option.java
Normal file
@ -0,0 +1,220 @@
|
||||
package de.Ste3et_C0st.Furniture.Main;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.largeTable;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.latern;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.sofa;
|
||||
import de.Ste3et_C0st.Furniture.Objects.indoor.table;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.barrels;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.campfire_1;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.campfire_2;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_1;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_2;
|
||||
import de.Ste3et_C0st.Furniture.Objects.outdoor.tent_3;
|
||||
|
||||
public class option {
|
||||
|
||||
|
||||
public void saveOption(FileConfiguration fc, campfire_1 l) {
|
||||
fc.set("Furniture.campfire1."+l.getID()+".settings", l.getFire());
|
||||
}
|
||||
|
||||
public void saveOption(FileConfiguration fc, campfire_2 l) {
|
||||
fc.set("Furniture.campfire2."+l.getID()+".settings", l.isFire());
|
||||
}
|
||||
|
||||
public void saveOption(FileConfiguration fc, latern l)
|
||||
{
|
||||
fc.set("Furniture.lantern." + l.getID() + ".settings", Boolean.valueOf(l.getLight()));
|
||||
}
|
||||
|
||||
public void saveOption(FileConfiguration fc, largeTable l){
|
||||
for(Integer is : l.getTeller().keySet()){
|
||||
saveItem(fc, "Furniture.largeTable."+l.getID()+".settings.items." + is, l.getTeller().get(is));
|
||||
}
|
||||
for(Integer is : l.getColor().keySet()){
|
||||
saveColor(fc, "Furniture.largeTable."+l.getID()+".settings.colors."+is, l.getColor().get(is));
|
||||
}
|
||||
}
|
||||
|
||||
public void saveOption(FileConfiguration fc, tent_1 l){
|
||||
for(Integer is : l.getColor().keySet()){
|
||||
saveColor(fc, "Furniture.tent1."+l.getID()+".settings.colors."+is, l.getColor().get(is));
|
||||
}
|
||||
}
|
||||
|
||||
public void saveOption(FileConfiguration fc, tent_2 l){
|
||||
for(Integer is : l.getColor().keySet()){
|
||||
saveColor(fc, "Furniture.tent2."+l.getID()+".settings.colors."+is, l.getColor().get(is));
|
||||
}
|
||||
}
|
||||
|
||||
public void saveOption(FileConfiguration fc, tent_3 l) {
|
||||
for(Integer is : l.getColor().keySet()){
|
||||
saveColor(fc, "Furniture.tent3."+l.getID()+".settings.colors."+is, l.getColor().get(is));
|
||||
}
|
||||
}
|
||||
|
||||
public void saveOption(FileConfiguration fc, sofa l){
|
||||
for(Integer is : l.getColor().keySet()){
|
||||
saveColor(fc, "Furniture.sofa."+l.getID()+".settings.colors."+is, l.getColor().get(is));
|
||||
}
|
||||
}
|
||||
|
||||
public void saveOption(FileConfiguration fc, table l){
|
||||
saveItem(fc, "Furniture.table."+l.getID()+".settings.item", l.getItemStack());
|
||||
}
|
||||
|
||||
public void saveOption(FileConfiguration fc, barrels l){
|
||||
saveItem(fc, "Furniture.barrels."+l.getID()+".settings.item", l.getItemStack());
|
||||
}
|
||||
|
||||
public void loadOptions(FileConfiguration fc, tent_1 l){
|
||||
if(fc.isSet("Furniture.tent1."+l.getID()+".settings")){
|
||||
if(fc.isConfigurationSection("Furniture.tent1."+l.getID()+".settings.colors")){
|
||||
Integer current = 0;
|
||||
HashMap<Integer, Short> colors = new HashMap<Integer, Short>();
|
||||
for(String str : fc.getConfigurationSection("Furniture.tent1."+l.getID()+".settings.colors").getKeys(false)){
|
||||
Integer i = fc.getInt("Furniture.tent1."+l.getID()+".settings.colors."+str);
|
||||
colors.put(current, i.shortValue());
|
||||
current++;
|
||||
}
|
||||
l.setColor(colors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadOptions(FileConfiguration fc, tent_2 l){
|
||||
if(fc.isSet("Furniture.tent2."+l.getID()+".settings")){
|
||||
if(fc.isConfigurationSection("Furniture.tent2."+l.getID()+".settings.colors")){
|
||||
Integer current = 0;
|
||||
HashMap<Integer, Short> colors = new HashMap<Integer, Short>();
|
||||
for(String str : fc.getConfigurationSection("Furniture.tent2."+l.getID()+".settings.colors").getKeys(false)){
|
||||
Integer i = fc.getInt("Furniture.tent2."+l.getID()+".settings.colors."+str);
|
||||
colors.put(current, i.shortValue());
|
||||
current++;
|
||||
}
|
||||
l.setColor(colors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadOptions(FileConfiguration fc, tent_3 l){
|
||||
if(fc.isSet("Furniture.tent3."+l.getID()+".settings")){
|
||||
if(fc.isConfigurationSection("Furniture.tent3."+l.getID()+".settings.colors")){
|
||||
Integer current = 0;
|
||||
HashMap<Integer, Integer> colors = new HashMap<Integer, Integer>();
|
||||
for(String str : fc.getConfigurationSection("Furniture.tent3."+l.getID()+".settings.colors").getKeys(false)){
|
||||
Integer i = fc.getInt("Furniture.tent3."+l.getID()+".settings.colors."+str);
|
||||
colors.put(current, i);
|
||||
current++;
|
||||
}
|
||||
l.setColor(colors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadOptions(FileConfiguration fc, table l){
|
||||
if(fc.isSet("Furniture.table."+l.getID()+".settings")){
|
||||
if(fc.isConfigurationSection("Furniture.table."+l.getID()+".settings.item")){
|
||||
ItemStack is = getItemStack(fc, "Furniture.table."+l.getID()+".settings.item");
|
||||
l.setItem(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadOptions(FileConfiguration fc, barrels l){
|
||||
if(fc.isSet("Furniture.barrels."+l.getID()+".settings")){
|
||||
if(fc.isConfigurationSection("Furniture.barrels."+l.getID()+".settings.item")){
|
||||
ItemStack is = getItemStack(fc, "Furniture.barrels."+l.getID()+".settings.item");
|
||||
l.setItemstack(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void loadOptions(FileConfiguration fc, latern l){
|
||||
if(fc.isSet("Furniture.lantern."+l.getID()+".settings")){
|
||||
if(fc.isBoolean("Furniture.lantern."+l.getID()+".settings.state")){
|
||||
l.setLight(fc.getBoolean("Furniture.lantern."+l.getID()+".settings.state"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadOptions(FileConfiguration fc, campfire_1 l) {
|
||||
if(fc.isSet("Furniture.campfire1."+l.getID()+".settings")){
|
||||
if(fc.isBoolean("Furniture.campfire1."+l.getID()+".settings.state")){
|
||||
l.setLight(fc.getBoolean("Furniture.campfire1."+l.getID()+".settings.state"), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void loadOptions(FileConfiguration fc, campfire_2 l) {
|
||||
if(fc.isSet("Furniture.campfire2."+l.getID()+".settings")){
|
||||
if(fc.isBoolean("Furniture.campfire2."+l.getID()+".settings.state")){
|
||||
l.setLight(fc.getBoolean("Furniture.campfire2."+l.getID()+".settings.state"), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadOptions(FileConfiguration fc, sofa l){
|
||||
if(fc.isSet("Furniture.sofa."+l.getID()+".settings")){
|
||||
if(fc.isConfigurationSection("Furniture.sofa."+l.getID()+".settings.colors")){
|
||||
Integer current = 0;
|
||||
HashMap<Integer, Short> colors = new HashMap<Integer, Short>();
|
||||
for(String str : fc.getConfigurationSection("Furniture.sofa."+l.getID()+".settings.colors").getKeys(false)){
|
||||
Integer i = fc.getInt("Furniture.sofa."+l.getID()+".settings.colors."+str);
|
||||
colors.put(current, i.shortValue());
|
||||
current++;
|
||||
}
|
||||
l.setColor(colors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadOptions(FileConfiguration fc, largeTable l){
|
||||
if(fc.isSet("Furniture.largeTable."+l.getID()+".settings")){
|
||||
HashMap<Integer, Short> colors = new HashMap<Integer, Short>();
|
||||
HashMap<Integer, ItemStack> items = new HashMap<Integer, ItemStack>();
|
||||
if(fc.isConfigurationSection("Furniture.largeTable."+l.getID()+".settings.colors")){
|
||||
Integer current = 0;
|
||||
for(String str : fc.getConfigurationSection("Furniture.largeTable."+l.getID()+".settings.colors").getKeys(false)){
|
||||
Integer i = fc.getInt("Furniture.largeTable."+l.getID()+".settings.colors."+str);
|
||||
colors.put(current, i.shortValue());
|
||||
current++;
|
||||
}
|
||||
}
|
||||
if(fc.isConfigurationSection("Furniture.largeTable."+l.getID()+".settings.items")){
|
||||
for(String str : fc.getConfigurationSection("Furniture.largeTable."+l.getID()+".settings.items").getKeys(false)){
|
||||
items.put(Integer.parseInt(str), getItemStack(fc, "Furniture.largeTable."+l.getID()+".settings.items."+str));
|
||||
}
|
||||
}
|
||||
l.setColor(colors);
|
||||
l.setTeller(items);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void saveColor(FileConfiguration fc, String s, Short sh){
|
||||
fc.set(s, sh);
|
||||
}
|
||||
|
||||
public void saveColor(FileConfiguration fc, String s, Integer sh){
|
||||
fc.set(s, sh);
|
||||
}
|
||||
|
||||
|
||||
public void saveItem(FileConfiguration fc, String s, ItemStack is){
|
||||
fc.set(s, is);
|
||||
}
|
||||
|
||||
public ItemStack getItemStack(FileConfiguration fc, String s){
|
||||
return fc.getItemStack(s);
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -35,9 +36,10 @@ public class chair implements Listener {
|
||||
public BlockFace getBlockFace(){return this.b;}
|
||||
|
||||
public chair(Location loc, Plugin plugin, String id){
|
||||
this.loc = loc.getBlock().getLocation();
|
||||
this.id = 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);
|
||||
@ -56,16 +58,21 @@ 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,getID(),IDList);
|
||||
Utils.setArmorStand(lehne, new EulerAngle(1.57, .0, .0), new ItemStack(Material.TRAP_DOOR), false,getID(),IDList);
|
||||
Utils.setArmorStand(feet1, null, new ItemStack(Material.LEVER), false,getID(),IDList);
|
||||
Utils.setArmorStand(feet2, null, new ItemStack(Material.LEVER), false,getID(),IDList);
|
||||
Utils.setArmorStand(feet3, null, new ItemStack(Material.LEVER), false,getID(),IDList);
|
||||
Utils.setArmorStand(feet4, null, new ItemStack(Material.LEVER), false,getID(),IDList);
|
||||
main.getInstance().stuehle.add(this);
|
||||
Utils.setArmorStand(sitz, null, new ItemStack(Material.TRAP_DOOR), false,false,false,getID(),IDList);
|
||||
Utils.setArmorStand(lehne, new EulerAngle(1.57, .0, .0), new ItemStack(Material.TRAP_DOOR), false,false,false,getID(),IDList);
|
||||
Utils.setArmorStand(feet1, null, new ItemStack(Material.LEVER), false,false,false,getID(),IDList);
|
||||
Utils.setArmorStand(feet2, null, new ItemStack(Material.LEVER), false,false,false,getID(),IDList);
|
||||
Utils.setArmorStand(feet3, null, new ItemStack(Material.LEVER), false,false,false,getID(),IDList);
|
||||
Utils.setArmorStand(feet4, null, new ItemStack(Material.LEVER), false,false,false,getID(),IDList);
|
||||
Utils.setArmorStand(sitz.add(0,-.2,0), null, null, false,false,false,getID(),IDList);
|
||||
main.getInstance().getManager().chairList.add(this);
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
public void save(){
|
||||
main.getInstance().mgr.saveStuhl(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWaterFlow(BlockFromToEvent e){
|
||||
Location locTo = e.getToBlock().getLocation();
|
||||
@ -85,43 +92,51 @@ public class chair implements Listener {
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
private void onInteract(PlayerInteractAtEntityEvent e){
|
||||
if(e.isCancelled()){return;}
|
||||
Player player = e.getPlayer();
|
||||
if(e.getRightClicked() instanceof ArmorStand){
|
||||
if(IDList.contains(e.getRightClicked().getCustomName())){
|
||||
e.setCancelled(true);
|
||||
Utils.getArmorStandAtID(w, IDList.get(0)).setPassenger(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void delete(Boolean b){
|
||||
public void delete(Boolean b, Boolean a){
|
||||
if(b){
|
||||
getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("chair"));
|
||||
for(String ids : IDList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, ids);
|
||||
getLocation().getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
|
||||
as.remove();
|
||||
main.getInstance().mgr.deleteFromConfig(getID(), "chair");
|
||||
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("chair"));}
|
||||
if(IDList!=null&&!IDList.isEmpty()){
|
||||
for(String ids : IDList){
|
||||
if(ids==null){continue;}
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, ids);
|
||||
if(as!=null){
|
||||
if(a){getLocation().getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());}
|
||||
as.remove();
|
||||
main.getInstance().mgr.deleteFromConfig(getID(), "chair");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.loc = null;
|
||||
IDList.clear();
|
||||
main.getInstance().stuehle.remove(this);
|
||||
main.getInstance().getManager().chairList.remove(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void damage(EntityDamageByEntityEvent e){
|
||||
if(e.isCancelled()){return;}
|
||||
if(e.getDamager() instanceof Player){
|
||||
if(e.getEntity() instanceof ArmorStand){
|
||||
if(IDList.contains(e.getEntity().getCustomName())){
|
||||
delete(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
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;}
|
||||
e.setCancelled(true);
|
||||
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)
|
||||
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(e.getRightClicked().getName() == null){return;}
|
||||
if(IDList==null||IDList.isEmpty()){return;}
|
||||
if(!IDList.contains(e.getRightClicked().getCustomName())){return;}
|
||||
e.setCancelled(true);
|
||||
Utils.getArmorStandAtID(w, IDList.get(6)).setPassenger(player);
|
||||
}
|
||||
}
|
||||
|
@ -37,30 +37,18 @@ public class largeTable implements Listener {
|
||||
public Location getLocation(){return this.loc;}
|
||||
public BlockFace getBlockFace(){return this.b;}
|
||||
|
||||
public largeTable(Location loc, Plugin plugin, List<ItemStack> iL, HashMap<Integer, ItemStack> tellerItems, String id){
|
||||
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();
|
||||
ItemStack IS1 =null;
|
||||
ItemStack IS2 =null;
|
||||
ItemStack IS3 =null;
|
||||
ItemStack IS4 =null;
|
||||
|
||||
if(tellerItems != null){
|
||||
if(tellerItems.containsKey(0)){IS1=tellerItems.get(0);}
|
||||
if(tellerItems.containsKey(1)){IS2=tellerItems.get(1);}
|
||||
if(tellerItems.containsKey(2)){IS3=tellerItems.get(2);}
|
||||
if(tellerItems.containsKey(3)){IS4=tellerItems.get(3);}
|
||||
}
|
||||
|
||||
Location location = Utils.getCenter(loc.getBlock().getLocation());
|
||||
float yaw = Utils.FaceToYaw(this.b);
|
||||
location = main.getNew(location, this.b, 0.1, 0.28);
|
||||
location.add(0,.2,0);
|
||||
Double winkel = 1.57;
|
||||
int iTems = 0;
|
||||
for(int x=1; x<=3;x++){
|
||||
Location l = null;
|
||||
l = main.getNew(location, this.b, 0.0, x*-.63);
|
||||
@ -69,32 +57,17 @@ public class largeTable implements Listener {
|
||||
ItemStack iTemStack_1 = new ItemStack(Material.STAINED_GLASS_PANE);
|
||||
ItemStack iTemStack_2 = new ItemStack(Material.STAINED_GLASS_PANE);
|
||||
ItemStack iTemStack_3 = new ItemStack(Material.STAINED_GLASS_PANE);
|
||||
if(iL!=null&&!iL.isEmpty()){
|
||||
if(iL.get(iTems)!=null){
|
||||
iTemStack_1=iL.get(iTems);
|
||||
iTems++;
|
||||
}
|
||||
if(iL.get(iTems)!=null){
|
||||
iTemStack_2=iL.get(iTems);
|
||||
iTems++;
|
||||
}
|
||||
if(iL.get(iTems)!=null){
|
||||
iTemStack_3=iL.get(iTems);
|
||||
iTems++;
|
||||
}
|
||||
}
|
||||
|
||||
ArmorStand as = Utils.setArmorStand(l, new EulerAngle(winkel, 0, 0), iTemStack_1, false,getID(),idList);
|
||||
ArmorStand as = Utils.setArmorStand(l, new EulerAngle(winkel, 0, 0), iTemStack_1, false,false,false,getID(),idList);
|
||||
armorlist.add(as);
|
||||
l = main.getNew(location, this.b, 0.63, x*-.63);
|
||||
l.add(0,-1.2,0);
|
||||
l.setYaw(yaw);
|
||||
as = Utils.setArmorStand(l, new EulerAngle(winkel, 0, 0), iTemStack_2, false,getID(),idList);
|
||||
as = Utils.setArmorStand(l, new EulerAngle(winkel, 0, 0), iTemStack_2, false,false,false,getID(),idList);
|
||||
armorlist.add(as);
|
||||
l = main.getNew(location, this.b, 1.26, x*-.63);
|
||||
l.add(0,-1.2,0);
|
||||
l.setYaw(yaw);
|
||||
as = Utils.setArmorStand(l, new EulerAngle(winkel, 0, 0), iTemStack_3, false,getID(),idList);
|
||||
as = Utils.setArmorStand(l, new EulerAngle(winkel, 0, 0), iTemStack_3, false,false,false,getID(),idList);
|
||||
armorlist.add(as);
|
||||
}
|
||||
|
||||
@ -129,14 +102,14 @@ public class largeTable implements Listener {
|
||||
feet3.setYaw(yaw);
|
||||
feet4.setYaw(yaw);
|
||||
|
||||
Utils.setArmorStand(feet1, new EulerAngle(-1.75, 0, 0), new ItemStack(Material.BONE), true, getID(), idList);
|
||||
Utils.setArmorStand(feet2, new EulerAngle(-1.75, 0, 0), new ItemStack(Material.BONE), true, getID(), idList);
|
||||
Utils.setArmorStand(feet3, new EulerAngle(-1.75, 0, 0), new ItemStack(Material.BONE), true, getID(), idList);
|
||||
Utils.setArmorStand(feet4, new EulerAngle(-1.75, 0, 0), new ItemStack(Material.BONE), true, getID(), idList);
|
||||
ArmorStand as1 = Utils.setArmorStand(t1, new EulerAngle(0, 0, 0), IS1, true, getID(), idList);
|
||||
ArmorStand as2 = Utils.setArmorStand(t2, new EulerAngle(0, 0, 0), IS2, true, getID(), idList);
|
||||
ArmorStand as3 = Utils.setArmorStand(t3, new EulerAngle(0, 0, 0), IS3, true, getID(), idList);
|
||||
ArmorStand as4 = Utils.setArmorStand(t4, new EulerAngle(0, 0, 0), IS4, true, getID(), idList);
|
||||
Utils.setArmorStand(feet1, new EulerAngle(-1.75, 0, 0), new ItemStack(Material.BONE), true,false,false, getID(), idList);
|
||||
Utils.setArmorStand(feet2, new EulerAngle(-1.75, 0, 0), new ItemStack(Material.BONE), true,false,false, getID(), idList);
|
||||
Utils.setArmorStand(feet3, new EulerAngle(-1.75, 0, 0), new ItemStack(Material.BONE), true,false,false, getID(), idList);
|
||||
Utils.setArmorStand(feet4, new EulerAngle(-1.75, 0, 0), new ItemStack(Material.BONE), true,false,false, getID(), idList);
|
||||
ArmorStand as1 = Utils.setArmorStand(t1, new EulerAngle(0, 0, 0), null, true,false,false, getID(), idList);
|
||||
ArmorStand as2 = Utils.setArmorStand(t2, new EulerAngle(0, 0, 0), null, true,false,false, getID(), idList);
|
||||
ArmorStand as3 = Utils.setArmorStand(t3, new EulerAngle(0, 0, 0), null, true,false,false, getID(), idList);
|
||||
ArmorStand as4 = Utils.setArmorStand(t4, new EulerAngle(0, 0, 0), null, true,false,false, getID(), idList);
|
||||
|
||||
tellerIDS.add(as1.getCustomName());
|
||||
tellerIDS.add(as2.getCustomName());
|
||||
@ -144,13 +117,51 @@ public class largeTable implements Listener {
|
||||
tellerIDS.add(as4.getCustomName());
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
main.getInstance().tische2.add(this);
|
||||
main.getInstance().getManager().largeTableList.add(this);
|
||||
}
|
||||
|
||||
public void delete(boolean b){
|
||||
public void setTeller(HashMap<Integer, ItemStack> itemList){
|
||||
int i = 0;
|
||||
for(String id : tellerIDS){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, id);
|
||||
as.setItemInHand(itemList.get(i));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public void setColor(HashMap<Integer, Short> durabilityList){
|
||||
int i = 0;
|
||||
for(String id: idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, id);
|
||||
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)&&as.getHelmet().getType().equals(Material.STAINED_GLASS_PANE)){
|
||||
ItemStack is = as.getHelmet();
|
||||
is.setDurability(durabilityList.get(i));
|
||||
as.setHelmet(is);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public HashMap<Integer, Short> getColor(){
|
||||
HashMap<Integer, Short> colorList = new HashMap<Integer, Short>();
|
||||
Integer i = 0;
|
||||
|
||||
for(String id: idList){
|
||||
try{i=colorList.size();}catch(Exception e){return colorList;}
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, id);
|
||||
if(as!=null){
|
||||
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)&&as.getHelmet().getType().equals(Material.STAINED_GLASS_PANE)){
|
||||
ItemStack is = as.getHelmet();
|
||||
colorList.put(i, is.getDurability());
|
||||
}
|
||||
}
|
||||
}
|
||||
return colorList;
|
||||
}
|
||||
|
||||
public void delete(boolean b, boolean a){
|
||||
if(b){
|
||||
getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("largeTable"));
|
||||
|
||||
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("largeTable"));}
|
||||
for(String s : tellerIDS){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as!=null){
|
||||
@ -163,7 +174,7 @@ public class largeTable implements Listener {
|
||||
for(String s : this.idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as!=null && as.getHelmet()!= null && as.getHelmet().getType()!=null){
|
||||
loc.getWorld().playEffect(loc, Effect.STEP_SOUND, as.getHelmet().getType());
|
||||
if(a){loc.getWorld().playEffect(loc, Effect.STEP_SOUND, as.getHelmet().getType());}
|
||||
}
|
||||
as.remove();
|
||||
}
|
||||
@ -172,45 +183,44 @@ public class largeTable implements Listener {
|
||||
|
||||
this.tellerIDS.clear();
|
||||
this.idList.clear();
|
||||
main.getInstance().tische2.remove(this);
|
||||
main.getInstance().getManager().largeTableList.remove(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
private void onInteract(PlayerInteractAtEntityEvent e){
|
||||
if(e.isCancelled()){return;}
|
||||
Player player = e.getPlayer();
|
||||
if(e.getRightClicked() instanceof ArmorStand){
|
||||
if(this.idList.contains(e.getRightClicked().getCustomName())){
|
||||
e.setCancelled(true);
|
||||
ItemStack is = player.getItemInHand();
|
||||
if(is!=null){
|
||||
if(is.getType().equals(Material.INK_SACK)){
|
||||
Short druability = is.getDurability();
|
||||
Integer amount = is.getAmount();
|
||||
if(amount>this.idList.size()-4 || player.getGameMode().equals(GameMode.CREATIVE)){amount=this.idList.size()-4;}
|
||||
List<Entity> list = new ArrayList<Entity>();
|
||||
|
||||
for(String s : this.idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as!=null){
|
||||
ItemStack item = as.getHelmet();
|
||||
if(item.getDurability() != main.getFromDey(druability)){
|
||||
list.add(as);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try{
|
||||
for(int i = 0; i<=amount-1;i++){
|
||||
Entity entity = list.get(i);
|
||||
if(entity instanceof ArmorStand){
|
||||
ArmorStand as = (ArmorStand) entity;
|
||||
ItemStack item = as.getHelmet();
|
||||
item.setDurability(main.getFromDey(druability));
|
||||
as.setHelmet(item);
|
||||
}
|
||||
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;}
|
||||
e.setCancelled(true);
|
||||
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
|
||||
ItemStack is = player.getItemInHand();
|
||||
if(is!=null){
|
||||
if(is.getType().equals(Material.INK_SACK)){
|
||||
Short druability = is.getDurability();
|
||||
Integer amount = is.getAmount();
|
||||
if(amount>this.idList.size()-4 || player.getGameMode().equals(GameMode.CREATIVE)){amount=this.idList.size()-4;}
|
||||
List<Entity> list = new ArrayList<Entity>();
|
||||
for(String s : this.idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as!=null){
|
||||
ItemStack item = as.getHelmet();
|
||||
if(item.getDurability() != main.getFromDey(druability)){
|
||||
list.add(as);
|
||||
}
|
||||
}catch(Exception ex){}
|
||||
}
|
||||
}
|
||||
for(Entity entity : list){
|
||||
if(list.indexOf(entity)>amount-1){break;}
|
||||
if(entity instanceof ArmorStand){
|
||||
ArmorStand as = (ArmorStand) entity;
|
||||
ItemStack item = as.getHelmet();
|
||||
item.setDurability(main.getFromDey(druability));
|
||||
as.setHelmet(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!player.getGameMode().equals(GameMode.CREATIVE)){
|
||||
@ -221,13 +231,17 @@ public class largeTable implements Listener {
|
||||
}else if(!is.getType().isBlock() || is.getType().equals(Material.AIR)){
|
||||
BlockFace b = Utils.yawToFace(player.getLocation().getYaw());
|
||||
ArmorStand as = null;
|
||||
|
||||
if(tellerIDS == null || tellerIDS.isEmpty()){return;}
|
||||
for(String s : this.tellerIDS){
|
||||
ArmorStand armorStand = Utils.getArmorStandAtID(w, s);
|
||||
BlockFace b2 = Utils.yawToFace(armorStand.getLocation().getYaw());
|
||||
if(b2.equals(b)){
|
||||
as = armorStand;
|
||||
break;
|
||||
if(s!=null){
|
||||
ArmorStand armorStand = Utils.getArmorStandAtID(w, s);
|
||||
if(armorStand!=null){
|
||||
BlockFace b2 = Utils.yawToFace(armorStand.getLocation().getYaw());
|
||||
if(b2.equals(b)){
|
||||
as = armorStand;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,29 +251,26 @@ public class largeTable implements Listener {
|
||||
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
||||
player.updateInventory();
|
||||
}
|
||||
main.getInstance().mgr.saveLargeTable(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void save(){
|
||||
main.getInstance().mgr.saveLargeTable(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void damage(EntityDamageByEntityEvent e){
|
||||
if(e.isCancelled()){return;}
|
||||
if(e.getDamager() instanceof Player){
|
||||
if(e.getEntity() instanceof ArmorStand){
|
||||
if(this.idList.contains(e.getEntity().getCustomName())){
|
||||
delete(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<ItemStack> getItemListTisch(){
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
for(int i = 0; i<=8;i++){
|
||||
items.add(Utils.getArmorStandAtID(w, idList.get(i)).getHelmet());
|
||||
}
|
||||
return items;
|
||||
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;}
|
||||
e.setCancelled(true);
|
||||
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 HashMap<Integer, ItemStack> getTeller(){
|
||||
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -29,28 +30,21 @@ public class latern implements Listener {
|
||||
private List<String> idList = new ArrayList<String>();
|
||||
private Block b;
|
||||
private Location loc = null;
|
||||
private Boolean bool = true;
|
||||
private BlockFace bFace = null;
|
||||
private String id;
|
||||
private World w;
|
||||
public String getID(){return this.id;}
|
||||
public Location getLocation(){return this.loc;}
|
||||
public BlockFace getBlockFace(){return this.bFace;}
|
||||
public Boolean getBlockState(){return this.bool;}
|
||||
|
||||
public latern(Location loc, Plugin plugin, Boolean bool, String id){
|
||||
public latern(Location loc, Plugin plugin, String id){
|
||||
this.loc = loc;
|
||||
this.bool = bool;
|
||||
this.id = id;
|
||||
this.bFace = Utils.yawToFace(loc.getYaw());
|
||||
this.w = loc.getWorld();
|
||||
Location center = Utils.getCenter(loc);
|
||||
b = center.getWorld().getBlockAt(center);
|
||||
if(bool){
|
||||
b.setType(Material.TORCH);
|
||||
}else{
|
||||
b.setType(Material.REDSTONE_TORCH_OFF);
|
||||
}
|
||||
b.setType(Material.TORCH);
|
||||
|
||||
Location obsidian = center;
|
||||
Location location = new Location(center.getWorld(), center.getX(), center.getY() -1.43, center.getZ());
|
||||
@ -60,22 +54,15 @@ public class latern implements Listener {
|
||||
Location right_upper = new Location(obsidian.getWorld(), obsidian.getX()-0.21, obsidian.getY()+.62, obsidian.getZ()-0.21);
|
||||
Location right_down = new Location(obsidian.getWorld(), obsidian.getX()+0.21, obsidian.getY() + .62, obsidian.getZ() -0.21);
|
||||
|
||||
Utils.setArmorStand(obsidian, null, new ItemStack(Material.OBSIDIAN), false,getID(),idList);
|
||||
Utils.setArmorStand(location.add(0,0,0), null, new ItemStack(Material.WOOD_PLATE), false,getID(), idList);
|
||||
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,getID(), idList);
|
||||
Utils.setArmorStand(left_upper, null, new ItemStack(Material.LEVER), false,getID(), idList);
|
||||
Utils.setArmorStand(right_upper, null, new ItemStack(Material.LEVER), false,getID(), idList);
|
||||
Utils.setArmorStand(right_down, null, new ItemStack(Material.LEVER), 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().laternen.add(this);
|
||||
}
|
||||
|
||||
public boolean check(Player player, Location loc){
|
||||
if(!loc.getBlock().equals(Material.AIR)){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
main.getInstance().getManager().lanternList.add(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -86,28 +73,30 @@ public class latern implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public void delete(Boolean b){
|
||||
|
||||
public void delete(Boolean b, boolean a){
|
||||
if(b){
|
||||
getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("lantern"));
|
||||
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("lantern"));}
|
||||
for(String s : idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w,s);
|
||||
as.getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
|
||||
as.remove();
|
||||
main.getInstance().mgr.deleteFromConfig(getID(), "lantern");
|
||||
if(as!=null){
|
||||
as.getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
|
||||
as.remove();
|
||||
}
|
||||
}
|
||||
main.getInstance().mgr.deleteFromConfig(getID(), "lantern");
|
||||
}
|
||||
if(this.b!=null&&!this.b.getType().equals(Material.AIR)){this.b.setType(Material.AIR);}
|
||||
this.bool = null;
|
||||
this.loc = null;
|
||||
this.b = null;
|
||||
this.idList.clear();
|
||||
main.getInstance().laternen.remove(this);
|
||||
main.getInstance().getManager().lanternList.remove(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent e){
|
||||
if(e.getBlock()!=null&&e.getBlock().equals(b)){
|
||||
delete(true);
|
||||
if(e.getBlock()!=null&&b!=null&&e.getBlock().equals(b)){
|
||||
e.setCancelled(true);
|
||||
delete(true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,32 +104,50 @@ public class latern implements Listener {
|
||||
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())){
|
||||
e.setCancelled(true);
|
||||
ItemStack is = player.getItemInHand();
|
||||
if(is!=null){
|
||||
if(is.getType().equals(Material.FLINT_AND_STEEL)){
|
||||
b.setType(Material.TORCH);
|
||||
bool = true;
|
||||
}else if(is.getType().equals(Material.WATER_BUCKET)){
|
||||
b.setType(Material.REDSTONE_TORCH_OFF);
|
||||
bool = false;
|
||||
}
|
||||
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;}
|
||||
e.setCancelled(true);
|
||||
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
|
||||
ItemStack is = player.getItemInHand();
|
||||
if(is!=null){
|
||||
if(is.getType().equals(Material.FLINT_AND_STEEL)){
|
||||
setLight(true);
|
||||
}else if(is.getType().equals(Material.WATER_BUCKET)){
|
||||
setLight(false);
|
||||
}
|
||||
main.getInstance().mgr.saveLatern(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void save(){
|
||||
main.getInstance().mgr.saveLatern(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void damage(EntityDamageByEntityEvent e){
|
||||
if(e.isCancelled()){return;}
|
||||
if(e.getDamager() instanceof Player){
|
||||
if(e.getEntity() instanceof ArmorStand){
|
||||
if(this.idList.contains(e.getEntity().getName())){
|
||||
delete(true);
|
||||
}
|
||||
}
|
||||
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;}
|
||||
e.setCancelled(true);
|
||||
if(!main.getInstance().getCheckManager().canBuild((Player) e.getDamager(), getLocation())){return;}
|
||||
if(((Player) e.getDamager()).getGameMode().equals(GameMode.CREATIVE)){delete(true, false);return;}
|
||||
delete(true, true);
|
||||
}
|
||||
|
||||
public void setLight(boolean bool){
|
||||
if(bool){b.setType(Material.TORCH);}
|
||||
else{b.setType(Material.REDSTONE_TORCH_OFF);}
|
||||
}
|
||||
|
||||
public boolean getLight(){
|
||||
if(b==null||b.getType().equals(Material.AIR)||b.getType().equals(Material.TORCH)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package de.Ste3et_C0st.Furniture.Objects.indoor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
@ -26,6 +27,7 @@ import de.Ste3et_C0st.Furniture.Main.main;
|
||||
|
||||
public class sofa implements Listener {
|
||||
private List<String> idList = new ArrayList<String>();
|
||||
private List<String> sitzList = new ArrayList<String>();
|
||||
private ItemStack is;
|
||||
private Double place;
|
||||
private BlockFace b;
|
||||
@ -37,19 +39,19 @@ public class sofa implements Listener {
|
||||
public Location getLocation(){return this.loc;}
|
||||
public BlockFace getBlockFace(){return this.b;}
|
||||
|
||||
public sofa(Location loc, Integer lengt, Plugin plugin, List<ItemStack> list, String id){
|
||||
public sofa(Location loc, Plugin plugin, String id){
|
||||
Integer lengt = 3;
|
||||
List<Entity> sitz = new ArrayList<Entity>();
|
||||
this.w = loc.getWorld();
|
||||
this.loc = loc;
|
||||
this.loc = loc.getBlock().getLocation();
|
||||
this.loc.setYaw(loc.getYaw());
|
||||
this.place = 0.2;
|
||||
this.id = id;
|
||||
this.b = Utils.yawToFace(loc.getYaw());
|
||||
is = new ItemStack(Material.CARPET);
|
||||
is.setDurability(color);
|
||||
BlockFace b = Utils.yawToFace(loc.getYaw()).getOppositeFace();
|
||||
|
||||
loc = loc.getBlock().getLocation();
|
||||
loc.setYaw(Utils.FaceToYaw(b));
|
||||
|
||||
Integer x = (int) loc.getX();
|
||||
Integer y = (int) loc.getY();
|
||||
Integer z = (int) loc.getZ();
|
||||
@ -66,39 +68,27 @@ public class sofa implements Listener {
|
||||
Location feet3 = main.getNew(looking, b, place + .5, .2D);
|
||||
Location feet4 = main.getNew(looking, b, place + .5, lengt.doubleValue()-.2D);
|
||||
|
||||
Utils.setArmorStand(feet1, null, new ItemStack(Material.LEVER), false,getID(),idList);
|
||||
Utils.setArmorStand(feet2, null, new ItemStack(Material.LEVER), false,getID(),idList);
|
||||
Utils.setArmorStand(feet3, null, new ItemStack(Material.LEVER), false,getID(),idList);
|
||||
Utils.setArmorStand(feet4, null, new ItemStack(Material.LEVER), 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);
|
||||
|
||||
Location carpetHight = new Location(looking.getWorld(), loc.getBlockX(), loc.getBlockY() -1 , loc.getBlockZ());
|
||||
carpetHight.setYaw(Utils.FaceToYaw(b));
|
||||
carpetHight = main.getNew(carpetHight, b, .25,.3);
|
||||
Double d = .02;
|
||||
float facing = Utils.FaceToYaw(b);
|
||||
int l = 0;
|
||||
for(Double i = .0; i<=lengt; i+=0.65){
|
||||
Location carpet = main.getNew(carpetHight, b, place,(double) d);
|
||||
carpet.setYaw(facing);
|
||||
ArmorStand as = null;
|
||||
if(list!=null&&!list.isEmpty() && list.get(l)!=null){
|
||||
as = Utils.setArmorStand(carpet, null, list.get(l), false,getID(),idList);
|
||||
}else{
|
||||
as = Utils.setArmorStand(carpet, null, is, false,getID(),idList);
|
||||
}
|
||||
as = Utils.setArmorStand(carpet, null, is, false,false,false,getID(),idList);
|
||||
sitz.add(as);
|
||||
l++;
|
||||
|
||||
//OBERER TEIL
|
||||
Location location = main.getNew(carpetHight, b, place-.25,(double) d);
|
||||
location.setYaw(facing);
|
||||
|
||||
if(list!=null&&!list.isEmpty() && list.get(l)!=null){
|
||||
Utils.setArmorStand(location, new EulerAngle(1.57, .0, .0), list.get(l), false,getID(),idList);
|
||||
}else{
|
||||
Utils.setArmorStand(location, new EulerAngle(1.57, .0, .0), is, false,getID(),idList);
|
||||
}
|
||||
l++;
|
||||
Utils.setArmorStand(location, new EulerAngle(1.57, .0, .0), is, false,false,false,getID(),idList);
|
||||
if(d<=0D){d = 0.00;}
|
||||
d+=.58;
|
||||
}
|
||||
@ -110,109 +100,160 @@ public class sofa implements Listener {
|
||||
Location first = main.getNew(new Location(loc.getWorld(), loc.getX(), last.getY(), loc.getZ()), b, place+.25, 0.07D);
|
||||
first.setYaw(yaw2-90);
|
||||
|
||||
Utils.setArmorStand(first.add(0,-.05,0), new EulerAngle(1.57, .0, .0), is, false,getID(),idList);
|
||||
Utils.setArmorStand(last.add(0,-.05,0), new EulerAngle(1.57, .0, .0), is, false,getID(),idList);
|
||||
Utils.setArmorStand(first.add(0,-.05,0), new EulerAngle(1.57, .0, .0), is, false,false,false,getID(),idList);
|
||||
Utils.setArmorStand(last.add(0,-.05,0), new EulerAngle(1.57, .0, .0), is, false,false,false,getID(),idList);
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
main.getInstance().sofas.add(this);
|
||||
main.getInstance().getManager().sofaList.add(this);
|
||||
}
|
||||
|
||||
/*@EventHandler
|
||||
private void onWaterFlow(BlockFromToEvent e){
|
||||
Location locTo = e.getToBlock().getLocation();
|
||||
if(location!=null && !location.isEmpty()){
|
||||
if(location.contains(locTo) || location.contains(locTo.add(0,1,0))){
|
||||
e.setCancelled(true);
|
||||
public void save(){
|
||||
main.getInstance().mgr.saveSofa(this);
|
||||
}
|
||||
|
||||
public void setColor(HashMap<Integer, Short> durabilityList){
|
||||
int i = 0;
|
||||
for(String id: idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, id);
|
||||
if(as!=null){
|
||||
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)&&as.getHelmet().getType().equals(Material.CARPET)){
|
||||
ItemStack is = as.getHelmet();
|
||||
is.setDurability(durabilityList.get(i));
|
||||
as.setHelmet(is);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public void delete(Boolean b){
|
||||
public HashMap<Integer, Short> getColor(){
|
||||
HashMap<Integer, Short> colorList = new HashMap<Integer, Short>();
|
||||
Integer i = 0;
|
||||
|
||||
for(String id: idList){
|
||||
try{i=colorList.size();}catch(Exception e){return colorList;}
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, id);
|
||||
if(as!=null){
|
||||
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)&&as.getHelmet().getType().equals(Material.CARPET)){
|
||||
ItemStack is = as.getHelmet();
|
||||
colorList.put(i, is.getDurability());
|
||||
}
|
||||
}
|
||||
}
|
||||
return colorList;
|
||||
}
|
||||
|
||||
public void delete(Boolean b, boolean a){
|
||||
if(b){
|
||||
getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("sofa"));
|
||||
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("sofa"));}
|
||||
|
||||
for(String s : idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(this.w, s);
|
||||
as.getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
|
||||
as.remove();
|
||||
main.getInstance().mgr.deleteFromConfig(getID(), "sofa");
|
||||
if(as!=null){
|
||||
if(a){as.getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());}
|
||||
|
||||
as.remove();
|
||||
main.getInstance().mgr.deleteFromConfig(getID(), "sofa");
|
||||
}
|
||||
}
|
||||
}
|
||||
idList.clear();
|
||||
main.getInstance().sofas.remove(this);
|
||||
main.getInstance().getManager().sofaList.remove(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
private void onInteract(PlayerInteractAtEntityEvent e){
|
||||
if(e.isCancelled()){return;}
|
||||
Player player = e.getPlayer();
|
||||
if(e.getRightClicked() instanceof ArmorStand){
|
||||
if(idList.contains(e.getRightClicked().getCustomName())){
|
||||
e.setCancelled(true);
|
||||
ItemStack is = player.getItemInHand();
|
||||
ArmorStand armorStand = Utils.getArmorStandAtID(w, e.getRightClicked().getCustomName());
|
||||
if(is!=null){
|
||||
if(is.getType().equals(Material.INK_SACK)){
|
||||
e.getRightClicked().sendMessage("test#2");
|
||||
Short druability = is.getDurability();
|
||||
Integer amount = is.getAmount() + 4;
|
||||
if(amount>idList.size() || player.getGameMode().equals(GameMode.CREATIVE)){amount=idList.size();}
|
||||
List<Entity> list = new ArrayList<Entity>();
|
||||
for(String s : idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as.getHelmet().getType().equals(Material.CARPET)){
|
||||
ItemStack item = as.getHelmet();
|
||||
if(item.getDurability() != main.getFromDey(druability)){
|
||||
list.add(as);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try{
|
||||
for(int i = 0; i<=amount-1;i++){
|
||||
Entity entity = list.get(i);
|
||||
if(entity instanceof ArmorStand){
|
||||
ArmorStand as = (ArmorStand) entity;
|
||||
ItemStack item = as.getHelmet();
|
||||
item.setDurability(main.getFromDey(druability));
|
||||
as.setHelmet(item);
|
||||
}
|
||||
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){
|
||||
if(is.getType().equals(Material.INK_SACK)){
|
||||
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
|
||||
Short druability = is.getDurability();
|
||||
Integer amount = is.getAmount();
|
||||
if(amount>idList.size() || player.getGameMode().equals(GameMode.CREATIVE)){amount=idList.size();}
|
||||
List<Entity> list = new ArrayList<Entity>();
|
||||
for(String s : idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as.getHelmet().getType().equals(Material.CARPET)){
|
||||
ItemStack item = as.getHelmet();
|
||||
if(item.getDurability() != main.getFromDey(druability)){
|
||||
list.add(as);
|
||||
}
|
||||
}catch(IndexOutOfBoundsException ex){}
|
||||
|
||||
if(!player.getGameMode().equals(GameMode.CREATIVE)){
|
||||
is.setAmount(is.getAmount()+4-amount);
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), is);
|
||||
player.updateInventory();
|
||||
}
|
||||
}else if(!armorStand.getHeadPose().equals(new EulerAngle(1.57, .0, .0)) && armorStand.getHelmet().getType().equals(Material.CARPET)){
|
||||
e.getRightClicked().setPassenger(player);
|
||||
}
|
||||
for(Entity entity : list){
|
||||
if(entity instanceof ArmorStand){
|
||||
if(list.indexOf(entity)>amount-1){break;}
|
||||
ArmorStand as = (ArmorStand) entity;
|
||||
ItemStack item = as.getHelmet();
|
||||
item.setDurability(main.getFromDey(druability));
|
||||
as.setHelmet(item);
|
||||
}
|
||||
}else if(!armorStand.getHeadPose().equals(new EulerAngle(1.57, .0, .0)) && armorStand.getHelmet().getType().equals(Material.CARPET)){
|
||||
e.getRightClicked().setPassenger(player);
|
||||
}
|
||||
|
||||
if(!player.getGameMode().equals(GameMode.CREATIVE)){
|
||||
is.setAmount(is.getAmount()-amount);
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), is);
|
||||
player.updateInventory();
|
||||
}
|
||||
main.getInstance().mgr.saveSofa(this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Integer intSitz = Utils.randInt(0, 2);
|
||||
for(String s : sitzList){
|
||||
if(s==null){return;}
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as==null){return;}
|
||||
if(sitzList.indexOf(s) == intSitz){
|
||||
if(as.getPassenger()==null){
|
||||
as.setPassenger(player);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<ItemStack> getItemListTisch(){
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
for(String s : idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as.getHelmet()!=null&&as.getHelmet().getType().equals(is.getType())){
|
||||
items.add(as.getHelmet());
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void damage(EntityDamageByEntityEvent e){
|
||||
if(e.isCancelled()){return;}
|
||||
if(e.getDamager() instanceof Player){
|
||||
if(e.getEntity() instanceof ArmorStand){
|
||||
if(idList.contains(e.getEntity().getCustomName())){
|
||||
delete(true);
|
||||
public boolean checkIfEmpty(){
|
||||
for(String id : idList){
|
||||
ArmorStand armorStand = Utils.getArmorStandAtID(w, id);
|
||||
if(armorStand!=null){
|
||||
if(armorStand.getHeadPose().equals(new EulerAngle(1.57, .0, .0)) && armorStand.getHelmet().getType().equals(Material.CARPET)){
|
||||
if(armorStand.getPassenger() != null && !armorStand.getPassenger().isEmpty()){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@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;}
|
||||
if(!idList.contains(e.getEntity().getCustomName())){return;}
|
||||
e.setCancelled(true);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -37,75 +37,93 @@ public class table implements Listener {
|
||||
public ItemStack getItemStack(){return this.is;}
|
||||
public BlockFace getBlockFace(){return this.b;}
|
||||
|
||||
public table(Location loc, Plugin plugin, ItemStack is, String id){
|
||||
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);
|
||||
Utils.setArmorStand(middle1.add(0,-2.1,0),new EulerAngle(0, 0, 0) , new ItemStack(Material.WOOD_PLATE), false,getID(),idList);
|
||||
Utils.setArmorStand(middle2.add(0,-1.05,0),new EulerAngle(0, 0, 0) , new ItemStack(Material.TRAP_DOOR), false,getID(),idList);
|
||||
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,getID(),idList);
|
||||
Utils.setArmorStand(loc.add(0,-.65,.68),new EulerAngle(1.38,.0,.0), new ItemStack(Material.STICK), true,getID(),idList);
|
||||
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);
|
||||
this.armor = as;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
main.getInstance().tische.add(this);
|
||||
main.getInstance().getManager().tableList.add(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
private void onInteract(PlayerInteractAtEntityEvent e){
|
||||
if(e.isCancelled()){return;}
|
||||
Player player = e.getPlayer();
|
||||
if(e.getRightClicked() instanceof ArmorStand){
|
||||
if(idList.contains(e.getRightClicked().getCustomName())){
|
||||
e.setCancelled(true);
|
||||
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(armor.getItemInHand()!=null&&!armor.getItemInHand().getType().equals(Material.AIR)){as.getLocation().getWorld().dropItem(as.getLocation(), as.getItemInHand());}
|
||||
as.setItemInHand(is);
|
||||
this.is = is;
|
||||
|
||||
if(!player.getGameMode().equals(GameMode.CREATIVE)){player.getInventory().remove(is);player.updateInventory();}
|
||||
}
|
||||
}
|
||||
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;}
|
||||
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&&armor.getItemInHand()!=null&&!armor.getItemInHand().getType().equals(Material.AIR)){as.getLocation().getWorld().dropItem(as.getLocation(), as.getItemInHand());}
|
||||
as.setItemInHand(is);
|
||||
this.is = is;
|
||||
if(!player.getGameMode().equals(GameMode.CREATIVE)){player.getInventory().remove(is);player.updateInventory();}
|
||||
main.getInstance().mgr.saveTable(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void delete(Boolean b){
|
||||
public void delete(Boolean b, boolean a){
|
||||
if(b){
|
||||
getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("table"));
|
||||
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("table"));}
|
||||
if(is!=null && !is.getType().equals(Material.AIR)){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w,idList.get(2));
|
||||
as.getLocation().getWorld().dropItem(as.getLocation(), as.getItemInHand());
|
||||
this.is = null;
|
||||
if(as!=null){
|
||||
as.getLocation().getWorld().dropItem(as.getLocation(), as.getItemInHand());
|
||||
this.is = null;
|
||||
}
|
||||
|
||||
}
|
||||
for(String s : idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w,s);
|
||||
loc.getWorld().playEffect(loc, Effect.STEP_SOUND, as.getHelmet().getType());
|
||||
as.remove();
|
||||
if(as!=null){
|
||||
if(a){loc.getWorld().playEffect(loc, Effect.STEP_SOUND, as.getHelmet().getType());}
|
||||
as.remove();
|
||||
}
|
||||
|
||||
}
|
||||
main.getInstance().mgr.deleteFromConfig(getID(), "table");
|
||||
}
|
||||
|
||||
this.loc = null;
|
||||
this.idList.clear();
|
||||
main.getInstance().tische.remove(this);
|
||||
main.getInstance().getManager().tableList.remove(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void damage(EntityDamageByEntityEvent e){
|
||||
if(e.isCancelled()){return;}
|
||||
if(e.getDamager() instanceof Player){
|
||||
if(e.getEntity() instanceof ArmorStand){
|
||||
if(idList.contains(e.getEntity().getCustomName())){
|
||||
delete(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
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;}
|
||||
e.setCancelled(true);
|
||||
if(!main.getInstance().getCheckManager().canBuild((Player) e.getDamager(), getLocation())){return;}
|
||||
if(((Player) e.getDamager()).getGameMode().equals(GameMode.CREATIVE)){delete(true, false);return;}
|
||||
delete(true, true);
|
||||
}
|
||||
|
||||
public void setItem(ItemStack itemS) {
|
||||
is = itemS;
|
||||
ArmorStand as = Utils.getArmorStandAtID(w,idList.get(2));
|
||||
as.setItemInHand(itemS);
|
||||
}
|
||||
public void save() {
|
||||
main.getInstance().mgr.saveTable(this);
|
||||
}
|
||||
}
|
||||
|
167
src/de/Ste3et_C0st/Furniture/Objects/outdoor/barrels.java
Normal file
167
src/de/Ste3et_C0st/Furniture/Objects/outdoor/barrels.java
Normal file
@ -0,0 +1,167 @@
|
||||
package de.Ste3et_C0st.Furniture.Objects.outdoor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import ru.BeYkeRYkt.LightAPI.LightAPI;
|
||||
import de.Ste3et_C0st.Furniture.Main.Utils;
|
||||
import de.Ste3et_C0st.Furniture.Main.main;
|
||||
|
||||
public class barrels implements Listener {
|
||||
|
||||
private Location loc;
|
||||
private BlockFace b;
|
||||
private ArmorStand as;
|
||||
private Block block;
|
||||
private String id;
|
||||
private List<String> idList = new ArrayList<String>();
|
||||
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){
|
||||
this.id = ID;
|
||||
this.loc = loc.getBlock().getLocation();
|
||||
this.loc.setYaw(loc.getYaw());
|
||||
this.b = Utils.yawToFace(loc.getYaw());
|
||||
|
||||
this.block = loc.getBlock();
|
||||
this.block.setType(Material.CAULDRON);
|
||||
|
||||
this.as = Utils.setArmorStand(Utils.getCenter(loc).add(0,-1.5,0), null, null, false, false, false, ID, idList);
|
||||
|
||||
main.getInstance().getManager().barrelList.add(this);
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
|
||||
public void save(){
|
||||
main.getInstance().mgr.saveBarrel(this);
|
||||
}
|
||||
|
||||
public ItemStack getItemStack() {
|
||||
if(this.as != null && this.as.getHelmet()!=null){
|
||||
return this.as.getHelmet();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setItemstack(ItemStack is){
|
||||
if(is==null){return;}
|
||||
this.as.setHelmet(is);
|
||||
}
|
||||
|
||||
public void delete(boolean b, boolean a){
|
||||
if(b){
|
||||
setLight(false);
|
||||
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("barrels"));}
|
||||
if(as!=null&&as.getHelmet()!=null &&!as.getHelmet().getType().equals(Material.AIR)){
|
||||
as.getLocation().getWorld().dropItem(as.getLocation(), as.getHelmet());
|
||||
}
|
||||
if(this.block!=null&&!this.block.getType().equals(Material.AIR)){
|
||||
this.block.setType(Material.AIR);
|
||||
}
|
||||
as.remove();
|
||||
main.getInstance().mgr.deleteFromConfig(getID(), "barrels");
|
||||
}
|
||||
this.loc = null;
|
||||
this.idList.clear();
|
||||
this.id = null;
|
||||
this.as = null;
|
||||
main.getInstance().getManager().barrelList.remove(this);
|
||||
}
|
||||
|
||||
@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;}
|
||||
if(!idList.contains(e.getEntity().getCustomName())){return;}
|
||||
e.setCancelled(true);
|
||||
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)
|
||||
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;}
|
||||
delete(true, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLight(Boolean b){
|
||||
if(main.getInstance().light){
|
||||
if(b){
|
||||
LightAPI.createLight(Utils.getCenter(getLocation()), 10);
|
||||
}else{
|
||||
LightAPI.deleteLight(Utils.getCenter(getLocation()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
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;}
|
||||
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().getType().equals(Material.AIR)){as.getLocation().getWorld().dropItem(as.getLocation(), as.getHelmet());}
|
||||
setItemstack(is);
|
||||
if(is.getType().equals(Material.GLOWSTONE) || is.getType().equals(Material.BEACON) || is.getType().equals(Material.SEA_LANTERN) ){setLight(true);}else{setLight(false);}
|
||||
if(!player.getGameMode().equals(GameMode.CREATIVE)){player.getInventory().remove(is);player.updateInventory();}
|
||||
main.getInstance().mgr.saveBarrel(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
private void onInteract(PlayerInteractEvent e){
|
||||
if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
|
||||
if(block!=null&&e.getClickedBlock()!=null&&e.getClickedBlock().equals(block)){
|
||||
e.setCancelled(true);
|
||||
Player player = e.getPlayer();
|
||||
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
|
||||
ItemStack is = player.getItemInHand();
|
||||
if(is!=null&&is.getType().isBlock()||is.getType().equals(Material.AIR)){
|
||||
if(as!=null){
|
||||
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)){as.getLocation().getWorld().dropItem(as.getLocation(), as.getHelmet());}
|
||||
setItemstack(is);
|
||||
if(is.getType().equals(Material.GLOWSTONE) || is.getType().equals(Material.BEACON) || is.getType().equals(Material.SEA_LANTERN) ){setLight(true);}else{setLight(false);}
|
||||
if(!player.getGameMode().equals(GameMode.CREATIVE)){player.getInventory().remove(is);player.updateInventory();}
|
||||
main.getInstance().mgr.saveBarrel(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
155
src/de/Ste3et_C0st/Furniture/Objects/outdoor/campfire_1.java
Normal file
155
src/de/Ste3et_C0st/Furniture/Objects/outdoor/campfire_1.java
Normal file
@ -0,0 +1,155 @@
|
||||
package de.Ste3et_C0st.Furniture.Objects.outdoor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import ru.BeYkeRYkt.LightAPI.LightAPI;
|
||||
import de.Ste3et_C0st.Furniture.Main.Utils;
|
||||
import de.Ste3et_C0st.Furniture.Main.main;
|
||||
|
||||
public class campfire_1 implements Listener {
|
||||
|
||||
private Location loc;
|
||||
private String ID;
|
||||
private BlockFace b;
|
||||
private List<String> idList = new ArrayList<String>();
|
||||
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) {
|
||||
this.loc = location.getBlock().getLocation();
|
||||
this.loc.setYaw(location.getYaw());
|
||||
this.ID = ID;
|
||||
this.w = location.getWorld();
|
||||
this.b = Utils.yawToFace(location.getYaw());
|
||||
|
||||
for(int i = 0;i<=3;i++){
|
||||
Location loc = Utils.getCenter(getLocation());
|
||||
loc.add(0,-1.9,0);
|
||||
loc.setYaw(i*60);
|
||||
Utils.setArmorStand(loc, null, null, false, false,true, getID(), idList);
|
||||
}
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
main.getInstance().getManager().campfire1List.add(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.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;}
|
||||
if(!idList.contains(e.getEntity().getCustomName())){return;}
|
||||
e.setCancelled(true);
|
||||
if(!main.getInstance().getCheckManager().canBuild((Player) e.getDamager(), getLocation())){return;}
|
||||
if(((Player) e.getDamager()).getGameMode().equals(GameMode.CREATIVE)){delete(true, false);return;}
|
||||
delete(true, true);
|
||||
}
|
||||
|
||||
public void 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){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as!=null){
|
||||
if(a){as.getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, Material.LOG);}
|
||||
as.remove();
|
||||
}
|
||||
}
|
||||
main.getInstance().mgr.deleteFromConfig(getID(), "campfire1");
|
||||
}
|
||||
idList.clear();
|
||||
main.getInstance().getManager().campfire1List.remove(this);
|
||||
}
|
||||
|
||||
public void save(){
|
||||
main.getInstance().mgr.saveCampFire1(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
private void onInteract(PlayerInteractAtEntityEvent e){
|
||||
if(e.isCancelled()){return;}
|
||||
Player player = e.getPlayer();
|
||||
if(e.getRightClicked() instanceof ArmorStand){
|
||||
if(this.idList.contains(e.getRightClicked().getName())){
|
||||
e.setCancelled(true);
|
||||
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
|
||||
ItemStack is = player.getItemInHand();
|
||||
if(is!=null){
|
||||
if(is.getType().equals(Material.FLINT_AND_STEEL)){
|
||||
setLight(true, true);
|
||||
}else if(is.getType().equals(Material.WATER_BUCKET)){
|
||||
setLight(false, true);
|
||||
}
|
||||
save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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())){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setLight(boolean boolean1, boolean a) {
|
||||
Location light = new Location(getLocation().getWorld(), getLocation().getX(), getLocation().getY(), getLocation().getZ());
|
||||
for(String s : idList){
|
||||
if(Utils.getArmorStandAtID(w, s) != null){
|
||||
setFire(Utils.getArmorStandAtID(w, s), boolean1);
|
||||
}
|
||||
}
|
||||
|
||||
if(boolean1){
|
||||
if(main.getInstance().light){LightAPI.createLight(light, 15);}
|
||||
light.getWorld().playSound(light, Sound.FIRE_IGNITE, 1, 1);
|
||||
}else{
|
||||
if(main.getInstance().light){LightAPI.deleteLight(light);}
|
||||
if(a){light.getWorld().playSound(light, Sound.FIZZ, 1, 1);}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getFire(){
|
||||
for(String s : idList){
|
||||
if(Utils.getArmorStandAtID(w, s) != null){
|
||||
if(Utils.getArmorStandAtID(w, s).getFireTicks()>=1){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setFire(ArmorStand as, boolean b){
|
||||
if(as.getFireTicks() <= 0 && b){
|
||||
as.setFireTicks(Integer.MAX_VALUE);
|
||||
}else if(as.getFireTicks() >= 0 && !b){
|
||||
as.setFireTicks(0);
|
||||
}
|
||||
}
|
||||
}
|
305
src/de/Ste3et_C0st/Furniture/Objects/outdoor/campfire_2.java
Normal file
305
src/de/Ste3et_C0st/Furniture/Objects/outdoor/campfire_2.java
Normal file
@ -0,0 +1,305 @@
|
||||
package de.Ste3et_C0st.Furniture.Objects.outdoor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
|
||||
import ru.BeYkeRYkt.LightAPI.LightAPI;
|
||||
import de.Ste3et_C0st.Furniture.Main.Utils;
|
||||
import de.Ste3et_C0st.Furniture.Main.main;
|
||||
|
||||
public class campfire_2 implements Listener {
|
||||
|
||||
private Location loc;
|
||||
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<Material> items = new ArrayList<Material>(
|
||||
Arrays.asList(
|
||||
Material.RAW_BEEF,
|
||||
Material.RAW_CHICKEN,
|
||||
Material.RAW_FISH,
|
||||
Material.POTATO_ITEM,
|
||||
Material.PORK,
|
||||
Material.RABBIT,
|
||||
Material.MUTTON
|
||||
)
|
||||
);
|
||||
private List<Material> items2 = new ArrayList<Material>(
|
||||
Arrays.asList(
|
||||
Material.COOKED_BEEF,
|
||||
Material.COOKED_CHICKEN,
|
||||
Material.COOKED_FISH,
|
||||
Material.BAKED_POTATO,
|
||||
Material.GRILLED_PORK,
|
||||
Material.COOKED_RABBIT,
|
||||
Material.COOKED_MUTTON
|
||||
)
|
||||
);
|
||||
private World w;
|
||||
private Integer timer;
|
||||
public String getID(){return this.ID;}
|
||||
public Location getLocation(){return this.loc;}
|
||||
public BlockFace getBlockFace(){return this.b;}
|
||||
private ArmorStand armorS;
|
||||
private EulerAngle[] angle = {
|
||||
new EulerAngle(-1.5, -.5, 0),
|
||||
new EulerAngle(-1.9, -.3, .7),
|
||||
new EulerAngle(-1.5, .3, 1.9),
|
||||
new EulerAngle(-0.7, -.5, -1.2)
|
||||
|
||||
};
|
||||
|
||||
public campfire_2(Location location, Plugin plugin, String ID) {
|
||||
this.loc = location.getBlock().getLocation();
|
||||
this.ID = ID;
|
||||
this.b = Utils.yawToFace(location.getYaw());
|
||||
this.w = loc.getWorld();
|
||||
this.loc.setYaw(location.getYaw());
|
||||
|
||||
Location middle = Utils.getCenter(getLocation());
|
||||
middle = main.getNew(middle, b, .5D, -.5D);
|
||||
middle.add(0,-1.2,0);
|
||||
Location stick1 = main.getNew(middle, getBlockFace(), .47D, -.05D);
|
||||
Location stick2 = main.getNew(middle, getBlockFace(), .47D, .85D);
|
||||
Location grill = main.getNew(middle,b, .0D, .5D);
|
||||
Location bone = main.getNew(middle, getBlockFace(), .5D, .82D);
|
||||
stick2.setYaw(Utils.FaceToYaw(b));
|
||||
grill.setYaw(Utils.FaceToYaw(b)+90);
|
||||
stick1.setYaw(Utils.FaceToYaw(b));
|
||||
bone.setYaw(Utils.FaceToYaw(b));
|
||||
stick1.add(0,.3,0);
|
||||
stick2.add(0,.3,0);
|
||||
bone.add(0,.17,0);
|
||||
Integer yaw = 90;
|
||||
for(int i = 0; i<=7;i++){
|
||||
Location loc = null;
|
||||
if(Utils.axisList.contains(Utils.yawToFaceRadial(yaw))){
|
||||
loc = main.getNew(middle, Utils.yawToFaceRadial(yaw), 0D, .5D);
|
||||
}else{
|
||||
loc = main.getNew(middle, Utils.yawToFaceRadial(yaw), 0D, .35D);
|
||||
}
|
||||
|
||||
loc.setYaw(90+yaw);
|
||||
Utils.setArmorStand(loc, new EulerAngle(1.568, 0, 0), new ItemStack(Material.STEP,1,(short)3), false, true, false, ID, idList);
|
||||
yaw+=45;
|
||||
}
|
||||
|
||||
yaw = 90;
|
||||
for(int i = 0; i<=3;i++){
|
||||
Location loc = main.getNew(middle, Utils.yawToFace(yaw), .4, -.5D);
|
||||
loc.add(0,-.5,0);
|
||||
loc.setYaw(90+yaw);
|
||||
Utils.setArmorStand(loc, new EulerAngle(2, 0, 0), new ItemStack(Material.STICK), true, false, false, ID, idList);
|
||||
yaw+=90;
|
||||
}
|
||||
|
||||
Utils.setArmorStand(stick1, new EulerAngle(1.38,.0,.0), new ItemStack(Material.STICK), true, false, false, ID, idList);
|
||||
Utils.setArmorStand(stick2, new EulerAngle(1.38,.0,.0), new ItemStack(Material.STICK), true, false, false, ID, idList);
|
||||
Utils.setArmorStand(bone, new EulerAngle(1.38,.0,1.57), new ItemStack(Material.BONE), true, false, false, ID, idList);
|
||||
this.l = grill;
|
||||
|
||||
ArmorStand as = Utils.setArmorStand(middle.add(0,-1.3,0), null, null, false, true, false, ID, idList);
|
||||
fire.add(as.getName());
|
||||
|
||||
main.getInstance().getManager().campfire2List.add(this);
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
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())){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFire(){
|
||||
if(fire==null){return false;}
|
||||
for(String s : fire){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as==null){return false;}
|
||||
if(as.getFireTicks()>0){return true;}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setLight(Boolean b, Boolean a){
|
||||
if(b){
|
||||
if(fire==null){return;}
|
||||
for(String s : fire){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as==null){return;}
|
||||
as.setFireTicks(Integer.MAX_VALUE);
|
||||
}
|
||||
if(main.getInstance().light){LightAPI.createLight(getLocation(), 15);}
|
||||
w.playSound(getLocation(), Sound.FIRE_IGNITE, 1, 1);
|
||||
}else{
|
||||
if(fire==null){return;}
|
||||
for(String s : fire){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as==null){return;}
|
||||
as.setFireTicks(0);
|
||||
}
|
||||
if(main.getInstance().light){LightAPI.deleteLight(getLocation());}
|
||||
if(a){
|
||||
w.playSound(getLocation(), Sound.FIZZ, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void save(){
|
||||
main.getInstance().mgr.saveCampFire2(this);
|
||||
}
|
||||
|
||||
public void delete(Boolean b, Boolean a){
|
||||
if(b){
|
||||
setLight(false, false);
|
||||
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("campfire2"));}
|
||||
|
||||
main.getInstance().mgr.deleteFromConfig(getID(), "campfire2");
|
||||
for(String s : idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as!=null){
|
||||
if(a){as.getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, Material.LOG);}
|
||||
as.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
removeGrill();
|
||||
this.loc = null;
|
||||
this.idList.clear();
|
||||
this.ID = null;
|
||||
main.getInstance().getManager().campfire2List.remove(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
private void onInteract(PlayerInteractAtEntityEvent e){
|
||||
if(e.isCancelled()){return;}
|
||||
Player player = e.getPlayer();
|
||||
if(e.getRightClicked() instanceof ArmorStand){
|
||||
if(idList.contains(e.getRightClicked().getCustomName())){
|
||||
e.setCancelled(true);
|
||||
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
|
||||
ItemStack is = player.getItemInHand();
|
||||
if(is!=null&&!is.getType().isBlock()||is.getType().equals(Material.AIR)){
|
||||
if(is.getType().equals(Material.FLINT_AND_STEEL)){
|
||||
setLight(true, true);
|
||||
}
|
||||
if(is.getType().equals(Material.WATER_BUCKET)){
|
||||
setLight(false, true);
|
||||
}
|
||||
if(!isFire()){return;}
|
||||
if(armorS==null&&getItem(is)!=null){
|
||||
setGrill(is);
|
||||
ItemStack item = is;
|
||||
item.setAmount(is.getAmount()-1);
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), item);
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.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;}
|
||||
if(!idList.contains(e.getEntity().getCustomName())){return;}
|
||||
e.setCancelled(true);
|
||||
if(!main.getInstance().getCheckManager().canBuild((Player) e.getDamager(), getLocation())){return;}
|
||||
if(((Player) e.getDamager()).getGameMode().equals(GameMode.CREATIVE)){delete(true, false);return;}
|
||||
delete(true, true);
|
||||
}
|
||||
|
||||
public void setGrill(ItemStack is){
|
||||
this.armorS = Utils.setArmorStand(l, null , is, true, false, false, ID, idList);
|
||||
this.timer = main.getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(main.getInstance(), new Runnable() {
|
||||
Integer rounds = Utils.randInt(15, 30);
|
||||
Integer labs = 0;
|
||||
Integer position = 0;
|
||||
@Override
|
||||
public void run() {
|
||||
if(labs>=rounds){removeGrill();}
|
||||
if(position>3){position=0;}
|
||||
if(armorS!=null){
|
||||
armorS.setRightArmPose(angle[position]);
|
||||
}
|
||||
position++;
|
||||
labs++;
|
||||
}
|
||||
}, 0, 4);
|
||||
}
|
||||
|
||||
public boolean check(){
|
||||
if(armorS==null){return true;}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void removeGrill(){
|
||||
if(isRunning()){
|
||||
Bukkit.getScheduler().cancelTask(timer);
|
||||
timer=null;
|
||||
if(armorS!=null&&armorS.getItemInHand()!=null&&getItem(armorS.getItemInHand())!=null){
|
||||
w.dropItem(getLocation(), getCooked(armorS.getItemInHand()));
|
||||
armorS.remove();
|
||||
armorS=null;
|
||||
}
|
||||
}
|
||||
if(armorS!=null){
|
||||
if(armorS.getItemInHand()!=null){w.dropItem(getLocation(), getCooked(armorS.getItemInHand()));}
|
||||
armorS.remove();
|
||||
armorS=null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isRunning(){
|
||||
if(timer==null){return false;}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ItemStack getItem(ItemStack is){
|
||||
if(is==null){return null;}
|
||||
if(is.getType()==null){return null;}
|
||||
if(items.contains(is.getType())){
|
||||
return is;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getCooked(ItemStack is){
|
||||
if(is==null){return null;}
|
||||
if(is.getType()==null){return null;}
|
||||
if(items.contains(is.getType())){
|
||||
return new ItemStack(items2.get(items.indexOf(is.getType())));
|
||||
}
|
||||
return is;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package de.Ste3et_C0st.Furniture.Objects.outdoor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
@ -16,13 +17,12 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import de.Ste3et_C0st.Furniture.Main.Utils;
|
||||
import de.Ste3et_C0st.Furniture.Main.main;
|
||||
|
||||
@ -56,6 +56,19 @@ public class tent_1 implements Listener {
|
||||
Location loc_1 = new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
Location loc_2 = new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
Location loc_3 = new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
Location karabine1 = main.getNew(getLocation(), getBlockFace(), 0D, 0D);
|
||||
Location karabine2 = main.getNew(getLocation(), getBlockFace(), 3D, 0D);
|
||||
Location karabine3 = main.getNew(getLocation(), getBlockFace(), 3D, -4D);
|
||||
Location karabine4 = main.getNew(getLocation(), getBlockFace(), 0D, -4D);
|
||||
karabine1 = Utils.getCenter(karabine1);
|
||||
karabine2 = Utils.getCenter(karabine2);
|
||||
karabine3 = Utils.getCenter(karabine3);
|
||||
karabine4 = Utils.getCenter(karabine4);
|
||||
karabine1.setYaw(Utils.FaceToYaw(b)+90);
|
||||
karabine2.setYaw(Utils.FaceToYaw(b)+90);
|
||||
karabine3.setYaw(Utils.FaceToYaw(b)+90);
|
||||
karabine4.setYaw(Utils.FaceToYaw(b)+90);
|
||||
|
||||
|
||||
if(b.equals(BlockFace.SOUTH)){
|
||||
block = blockLocation.getWorld().getBlockAt(main.getNew(blockLocation, b, 2D, -2D));
|
||||
@ -71,7 +84,6 @@ public class tent_1 implements Listener {
|
||||
block.setType(Material.WORKBENCH);
|
||||
}
|
||||
|
||||
|
||||
Location saveLoc = main.getNew(loc_1, b, -.55D, -0.6);
|
||||
saveLoc.add(0,-1.25,0);
|
||||
saveLoc.setYaw(Utils.FaceToYaw(b) -90);
|
||||
@ -104,11 +116,11 @@ public class tent_1 implements Listener {
|
||||
location.add(loc4);
|
||||
location.add(loc5);
|
||||
|
||||
Utils.setArmorStand(loc1, new EulerAngle(0, 0, -.2), new ItemStack(Material.CARPET), false, getID(),idList);
|
||||
Utils.setArmorStand(loc2, new EulerAngle(0, 0, -7.2), new ItemStack(Material.CARPET), false,getID(),idList);
|
||||
Utils.setArmorStand(loc3, new EulerAngle(0, 0, -7.2), new ItemStack(Material.CARPET), false,getID(),idList);
|
||||
Utils.setArmorStand(loc4, new EulerAngle(0, 0, -7.7), new ItemStack(Material.CARPET), false,getID(),idList);
|
||||
Utils.setArmorStand(loc5, new EulerAngle(0, 0, -.7), new ItemStack(Material.CARPET), false,getID(),idList);
|
||||
Utils.setArmorStand(loc1, new EulerAngle(0, 0, -.2), new ItemStack(Material.CARPET), false,false,false, getID(),idList);
|
||||
Utils.setArmorStand(loc2, new EulerAngle(0, 0, -7.2), new ItemStack(Material.CARPET), false,false,false,getID(),idList);
|
||||
Utils.setArmorStand(loc3, new EulerAngle(0, 0, -7.2), new ItemStack(Material.CARPET), false,false,false,getID(),idList);
|
||||
Utils.setArmorStand(loc4, new EulerAngle(0, 0, -7.7), new ItemStack(Material.CARPET), false,false,false,getID(),idList);
|
||||
Utils.setArmorStand(loc5, new EulerAngle(0, 0, -.7), new ItemStack(Material.CARPET), false,false,false,getID(),idList);
|
||||
d+=.62;
|
||||
}
|
||||
|
||||
@ -131,11 +143,11 @@ public class tent_1 implements Listener {
|
||||
location.add(loc4);
|
||||
location.add(loc5);
|
||||
|
||||
Utils.setArmorStand(loc1, new EulerAngle(0, 0, .2), new ItemStack(Material.CARPET), false,getID(),idList);
|
||||
Utils.setArmorStand(loc2, new EulerAngle(0, 0, 7.2), new ItemStack(Material.CARPET), false,getID(),idList);
|
||||
Utils.setArmorStand(loc3, new EulerAngle(0, 0, 7.2), new ItemStack(Material.CARPET), false,getID(),idList);
|
||||
Utils.setArmorStand(loc4, new EulerAngle(0, 0, 7.7), new ItemStack(Material.CARPET), false,getID(),idList);
|
||||
Utils.setArmorStand(loc5, new EulerAngle(0, 0, .7), new ItemStack(Material.CARPET), false,getID(),idList);
|
||||
Utils.setArmorStand(loc1, new EulerAngle(0, 0, .2), new ItemStack(Material.CARPET), false,false,false,getID(),idList);
|
||||
Utils.setArmorStand(loc2, new EulerAngle(0, 0, 7.2), new ItemStack(Material.CARPET), false,false,false,getID(),idList);
|
||||
Utils.setArmorStand(loc3, new EulerAngle(0, 0, 7.2), new ItemStack(Material.CARPET), false,false,false,getID(),idList);
|
||||
Utils.setArmorStand(loc4, new EulerAngle(0, 0, 7.7), new ItemStack(Material.CARPET), false,false,false,getID(),idList);
|
||||
Utils.setArmorStand(loc5, new EulerAngle(0, 0, .7), new ItemStack(Material.CARPET), false,false,false,getID(),idList);
|
||||
d+=.62;
|
||||
}
|
||||
|
||||
@ -144,93 +156,154 @@ public class tent_1 implements Listener {
|
||||
Location loc1= main.getNew(saveLoc3, b, d, 0D);
|
||||
loc1.setYaw(Utils.FaceToYaw(b.getOppositeFace()));
|
||||
location.add(loc1);
|
||||
Utils.setArmorStand(loc1, null, new ItemStack(Material.WOOD_STEP), false,getID(),idList);
|
||||
Utils.setArmorStand(loc1, null, new ItemStack(Material.WOOD_STEP), false,false,false,getID(),idList);
|
||||
|
||||
d+=.62;
|
||||
}
|
||||
|
||||
Utils.setArmorStand(karabine1.add(0,-1.9,0), null, new ItemStack(Material.TRIPWIRE_HOOK), false, false,false, ID, idList);
|
||||
Utils.setArmorStand(karabine2.add(0,-1.9,0), null, new ItemStack(Material.TRIPWIRE_HOOK), false, false,false, ID, idList);
|
||||
Utils.setArmorStand(karabine3.add(0,-1.9,0), null, new ItemStack(Material.TRIPWIRE_HOOK), false, false,false, ID, idList);
|
||||
Utils.setArmorStand(karabine4.add(0,-1.9,0), null, new ItemStack(Material.TRIPWIRE_HOOK), false, false,false, ID, idList);
|
||||
|
||||
Location crafting = Utils.getCenter(block.getLocation());
|
||||
crafting.setYaw(Utils.FaceToYaw(b)+90);
|
||||
Utils.setArmorStand(crafting.add(0,-1,0), null, new ItemStack(Material.LADDER), false, false,false, ID, idList);
|
||||
Utils.setArmorStand(crafting.add(0,.62,0), null, new ItemStack(Material.LADDER), false, false,false, ID, idList);
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
main.getInstance().tents1.add(this);
|
||||
main.getInstance().getManager().tent1List.add(this);
|
||||
}
|
||||
|
||||
public void delete(boolean b){
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent e){
|
||||
if(e.getBlock()!=null&&block!=null&&e.getBlock().equals(block)){
|
||||
e.setCancelled(true);
|
||||
delete(true, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void save(){
|
||||
main.getInstance().mgr.saveTent1(this);
|
||||
}
|
||||
|
||||
public void delete(boolean b, boolean a){
|
||||
if(b){
|
||||
getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("tent1"));
|
||||
if(block!=null){block.setType(Material.AIR);}
|
||||
if(a){
|
||||
getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("tent1"));
|
||||
}
|
||||
for(String s : idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
as.getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
|
||||
as.remove();
|
||||
if(as!=null){
|
||||
if(a){
|
||||
as.getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());
|
||||
}
|
||||
as.remove();
|
||||
}
|
||||
}
|
||||
main.getInstance().mgr.deleteFromConfig(getID(), "tent1");
|
||||
}
|
||||
idList.clear();
|
||||
main.getInstance().tents1.remove(this);
|
||||
main.getInstance().getManager().tent1List.remove(this);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void damage(EntityDamageByEntityEvent e){
|
||||
if(e.getDamager() instanceof Player){
|
||||
if(e.getEntity() instanceof ArmorStand){
|
||||
if(idList.contains(e.getEntity().getCustomName())){
|
||||
delete(true);
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
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;}
|
||||
e.setCancelled(true);
|
||||
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)
|
||||
private void onInteract(PlayerInteractAtEntityEvent e){
|
||||
if(e.isCancelled()){return;}
|
||||
Player player = e.getPlayer();
|
||||
if(e.getRightClicked() instanceof ArmorStand){
|
||||
if(idList.contains(e.getRightClicked().getCustomName())){
|
||||
e.setCancelled(true);
|
||||
ItemStack is = player.getItemInHand();
|
||||
if(is!=null){
|
||||
if(is.getType().equals(Material.INK_SACK)){
|
||||
Short druability = is.getDurability();
|
||||
Integer amount = is.getAmount();
|
||||
if(amount>idList.size() || player.getGameMode().equals(GameMode.CREATIVE)){amount=idList.size();}
|
||||
List<Entity> list = new ArrayList<Entity>();
|
||||
|
||||
|
||||
for(String s : this.idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
ItemStack item = as.getHelmet();
|
||||
if(!as.getHelmet().getType().equals(Material.CARPET)){continue;}
|
||||
if(item.getDurability() != main.getFromDey(druability)){
|
||||
list.add(as);
|
||||
}
|
||||
}
|
||||
|
||||
int neAmound = amount;
|
||||
try{
|
||||
for(int i = 0; i<=amount-1;i++){
|
||||
Entity entity = list.get(i);
|
||||
if(entity instanceof ArmorStand){
|
||||
ArmorStand as = (ArmorStand) entity;
|
||||
if(!as.getHelmet().getType().equals(Material.CARPET)){neAmound-=1;continue;}
|
||||
ItemStack item = as.getHelmet();
|
||||
item.setDurability(main.getFromDey(druability));
|
||||
as.setHelmet(item);
|
||||
}
|
||||
}
|
||||
}catch(Exception ex){}
|
||||
if(!player.getGameMode().equals(GameMode.CREATIVE)){
|
||||
is.setAmount(is.getAmount()-neAmound);
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), is);
|
||||
player.updateInventory();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(e.getRightClicked().getName()==null){return;}
|
||||
if(e.getRightClicked() instanceof ArmorStand == false){return;}
|
||||
if(!idList.contains(e.getRightClicked().getCustomName())){return;}
|
||||
e.setCancelled(true);
|
||||
ItemStack is = player.getItemInHand();
|
||||
if(is==null){return;}
|
||||
if(is!=null){
|
||||
if(is.getType().equals(Material.INK_SACK)){
|
||||
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
|
||||
Short druability = is.getDurability();
|
||||
Integer amount = is.getAmount();
|
||||
if(amount>idList.size() || player.getGameMode().equals(GameMode.CREATIVE)){amount=idList.size();}
|
||||
List<Entity> list = new ArrayList<Entity>();
|
||||
|
||||
|
||||
for(String s : this.idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as!=null){
|
||||
ItemStack item = as.getHelmet();
|
||||
if(!as.getHelmet().getType().equals(Material.CARPET)){continue;}
|
||||
if(item.getDurability() != main.getFromDey(druability)){list.add(as);}
|
||||
}
|
||||
}
|
||||
|
||||
int neAmound = amount;
|
||||
for(Entity entity : list){
|
||||
if(list.indexOf(entity)>amount-1){break;}
|
||||
if(entity instanceof ArmorStand){
|
||||
ArmorStand as = (ArmorStand) entity;
|
||||
if(!as.getHelmet().getType().equals(Material.CARPET)){neAmound-=1;continue;}
|
||||
ItemStack item = as.getHelmet();
|
||||
item.setDurability(main.getFromDey(druability));
|
||||
as.setHelmet(item);
|
||||
}
|
||||
}
|
||||
if(!player.getGameMode().equals(GameMode.CREATIVE)){
|
||||
is.setAmount(is.getAmount()-neAmound);
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), is);
|
||||
player.updateInventory();
|
||||
}
|
||||
main.getInstance().mgr.saveTent1(this);
|
||||
return;
|
||||
}
|
||||
Vector v1 = e.getRightClicked().getLocation().toVector();
|
||||
Vector v2 = block.getLocation().toVector();
|
||||
if(v1.distance(v2)<=2D){
|
||||
player.openWorkbench(block.getLocation(), true);
|
||||
}
|
||||
|
||||
if(block!=null){
|
||||
player.openWorkbench(block.getLocation(), true);
|
||||
}
|
||||
}
|
||||
|
||||
public void setColor(HashMap<Integer, Short> durabilityList){
|
||||
int i = 0;
|
||||
for(String id: idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, id);
|
||||
if(as!=null){
|
||||
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)&&as.getHelmet().getType().equals(Material.CARPET)){
|
||||
ItemStack is = as.getHelmet();
|
||||
is.setDurability(durabilityList.get(i));
|
||||
as.setHelmet(is);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public HashMap<Integer, Short> getColor(){
|
||||
HashMap<Integer, Short> colorList = new HashMap<Integer, Short>();
|
||||
Integer i = 0;
|
||||
|
||||
for(String id: idList){
|
||||
try{i=colorList.size();}catch(Exception e){return colorList;}
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, id);
|
||||
if(as!=null){
|
||||
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)&&as.getHelmet().getType().equals(Material.CARPET)){
|
||||
ItemStack is = as.getHelmet();
|
||||
colorList.put(i, is.getDurability());
|
||||
}
|
||||
}
|
||||
}
|
||||
return colorList;
|
||||
}
|
||||
}
|
||||
|
276
src/de/Ste3et_C0st/Furniture/Objects/outdoor/tent_2.java
Normal file
276
src/de/Ste3et_C0st/Furniture/Objects/outdoor/tent_2.java
Normal file
@ -0,0 +1,276 @@
|
||||
package de.Ste3et_C0st.Furniture.Objects.outdoor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
|
||||
import de.Ste3et_C0st.Furniture.Main.Utils;
|
||||
import de.Ste3et_C0st.Furniture.Main.main;
|
||||
|
||||
public class tent_2 implements Listener {
|
||||
|
||||
private String ID;
|
||||
private Location location;
|
||||
private List<String> idList = new ArrayList<String>();
|
||||
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) {
|
||||
this.b = Utils.yawToFace(location.getYaw());
|
||||
this.location = location.getBlock().getLocation();
|
||||
this.location.setYaw(location.getYaw());
|
||||
this.ID = ID;
|
||||
this.w = location.getWorld();
|
||||
if(b.equals(BlockFace.WEST)){location=main.getNew(location, b, 1D, 0D);}
|
||||
if(b.equals(BlockFace.NORTH)){location=main.getNew(location, b, 1D, 1D);}
|
||||
if(b.equals(BlockFace.EAST)){location=main.getNew(location, b, 0D, 1D);}
|
||||
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);
|
||||
Location MiddleLocation = main.getNew(LeftLocation, b, 0D, -2.27D).add(0,2.4,0);
|
||||
Location LeftSart = main.getNew(LeftLocation, b, 3.87D, -.2D);
|
||||
Location RightSart = main.getNew(RightLocation, b, 3.87D, .2D);
|
||||
Double d = .0;
|
||||
|
||||
for(int i = 0; i<=8;i++){
|
||||
Location loc1= main.getNew(LeftLocation, b, d, 0D);
|
||||
loc1.setYaw(Utils.FaceToYaw(b));
|
||||
Utils.setArmorStand(loc1, new EulerAngle(1.568, 0, 0), new ItemStack(Material.LOG), false,true,false, ID, idList);
|
||||
|
||||
Location loc2= main.getNew(RightLocation, b, d, 0D);
|
||||
loc2.setYaw(Utils.FaceToYaw(b));
|
||||
Utils.setArmorStand(loc2, new EulerAngle(1.568, 0, 0), new ItemStack(Material.LOG), false,true,false, ID, idList);
|
||||
|
||||
Location loc3= main.getNew(MiddleLocation, b, d, 0D);
|
||||
loc3.setYaw(Utils.FaceToYaw(b));
|
||||
Utils.setArmorStand(loc3, new EulerAngle(1.568, 0, 0), new ItemStack(Material.LOG), false,true,false, ID, idList);
|
||||
d+=.43;
|
||||
}
|
||||
|
||||
d = .0;
|
||||
Double l = -.25;
|
||||
for(int i = 0;i<=4;i++){
|
||||
setRow(LeftSart, .62, l, d, 5,new EulerAngle(0, 0, .79));
|
||||
d-=.435;
|
||||
l+=.44;
|
||||
}
|
||||
|
||||
d = .0;
|
||||
l = -.25;
|
||||
for(int i = 0;i<=4;i++){
|
||||
setRow(RightSart, .62, l, d, 5,new EulerAngle(0, 0, -.79));
|
||||
d+=.435;
|
||||
l+=.44;
|
||||
}
|
||||
|
||||
Location b1 = main.getNew(getLocation(), b, 1D, -2D);
|
||||
Location b2 = main.getNew(getLocation(), b, 2D, -3D);
|
||||
b2.setYaw(Utils.FaceToYaw(b));
|
||||
b2.getBlock().setType(Material.CHEST);
|
||||
BlockState chest = b2.getBlock().getState();
|
||||
switch (b){
|
||||
|
||||
case SOUTH:
|
||||
chest.setRawData((byte) 0x3);break;
|
||||
|
||||
case NORTH:
|
||||
chest.setRawData((byte) 0x2);break;
|
||||
|
||||
case EAST:
|
||||
chest.setRawData((byte) 0x5);break;
|
||||
|
||||
case WEST:
|
||||
chest.setRawData((byte) 0x4);break;
|
||||
default: chest.setRawData((byte) 0x3);break;
|
||||
|
||||
}
|
||||
chest.update(true, true);
|
||||
Utils.setBed(this.b, b1);
|
||||
|
||||
block.add(b1.getWorld().getBlockAt(b1));
|
||||
block.add(b2.getWorld().getBlockAt(b2));
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
main.getInstance().getManager().tent2List.add(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent e){
|
||||
if(e.getBlock()!=null&&block!=null&&block.contains(e.getBlock())){
|
||||
e.setCancelled(true);
|
||||
if(!main.getInstance().getCheckManager().canBuild(e.getPlayer(), getLocation())){return;}
|
||||
delete(true, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void delete(boolean b, boolean a){
|
||||
if(b){
|
||||
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("tent2"));}
|
||||
for(String s : idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as!=null){
|
||||
if(a){as.getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, as.getHelmet().getType());}
|
||||
as.remove();
|
||||
}
|
||||
}
|
||||
if(block!=null&&!block.isEmpty()){
|
||||
for(Block bl : block){
|
||||
if(bl!=null){
|
||||
bl.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main.getInstance().mgr.deleteFromConfig(getID(), "tent2");
|
||||
}
|
||||
idList.clear();
|
||||
block.clear();
|
||||
main.getInstance().getManager().tent2List.remove(this);
|
||||
}
|
||||
|
||||
public void save(){
|
||||
main.getInstance().mgr.saveTent2(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setRow(Location loc, double x,double y, double z, int replay, EulerAngle angle){
|
||||
Double d = .0;
|
||||
for(int i = 0; i<=replay;i++){
|
||||
Location loc1= main.getNew(loc, b, -3.55+d, z);
|
||||
loc1.setYaw(Utils.FaceToYaw(b));
|
||||
loc1.add(0, y,0);
|
||||
Utils.setArmorStand(loc1, angle, new ItemStack(Material.CARPET), false,false,false, ID, idList);
|
||||
d+=x;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
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;}
|
||||
e.setCancelled(true);
|
||||
ItemStack is = player.getItemInHand();
|
||||
if(is==null){return;}
|
||||
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
|
||||
|
||||
if(is.getType().equals(Material.INK_SACK)){
|
||||
Short druability = is.getDurability();
|
||||
Integer amount = is.getAmount();
|
||||
if(amount>idList.size() || player.getGameMode().equals(GameMode.CREATIVE)){amount=idList.size();}
|
||||
List<Entity> list = new ArrayList<Entity>();
|
||||
for(String s : this.idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as!=null){
|
||||
ItemStack item = as.getHelmet();
|
||||
if(!as.getHelmet().getType().equals(Material.CARPET)){continue;}
|
||||
if(item.getDurability() != main.getFromDey(druability)){list.add(as);
|
||||
}
|
||||
}
|
||||
}
|
||||
int neAmound = amount;
|
||||
for(Entity entity : list){
|
||||
if(list.indexOf(entity)>amount-1){break;}
|
||||
if(entity instanceof ArmorStand){
|
||||
ArmorStand as = (ArmorStand) entity;
|
||||
if(!as.getHelmet().getType().equals(Material.CARPET)){neAmound-=1;continue;}
|
||||
ItemStack item = as.getHelmet();
|
||||
item.setDurability(main.getFromDey(druability));
|
||||
as.setHelmet(item);
|
||||
}
|
||||
}
|
||||
if(!player.getGameMode().equals(GameMode.CREATIVE)){
|
||||
is.setAmount(is.getAmount()-neAmound);
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), is);
|
||||
player.updateInventory();
|
||||
}
|
||||
main.getInstance().mgr.saveTent2(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if(block==null||block.isEmpty()){return;}
|
||||
for(Block b : block){
|
||||
if(b.getType().equals(Material.CHEST)){
|
||||
Chest c = (Chest) b.getState();
|
||||
player.openInventory(c.getBlockInventory());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.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;}
|
||||
if(!idList.contains(e.getEntity().getCustomName())){return;}
|
||||
e.setCancelled(true);
|
||||
if(!main.getInstance().getCheckManager().canBuild((Player) e.getDamager(), getLocation())){return;}
|
||||
if(((Player) e.getDamager()).getGameMode().equals(GameMode.CREATIVE)){delete(true, false);return;}
|
||||
delete(true, true);
|
||||
}
|
||||
|
||||
public void setColor(HashMap<Integer, Short> durabilityList){
|
||||
int i = 0;
|
||||
for(String id: idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, id);
|
||||
if(as!=null){
|
||||
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)&&as.getHelmet().getType().equals(Material.CARPET)){
|
||||
ItemStack is = as.getHelmet();
|
||||
is.setDurability(durabilityList.get(i));
|
||||
as.setHelmet(is);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public HashMap<Integer, Short> getColor(){
|
||||
HashMap<Integer, Short> colorList = new HashMap<Integer, Short>();
|
||||
Integer i = 0;
|
||||
|
||||
for(String id: idList){
|
||||
try{i=colorList.size();}catch(Exception e){return colorList;}
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, id);
|
||||
if(as!=null){
|
||||
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)&&as.getHelmet().getType().equals(Material.CARPET)){
|
||||
ItemStack is = as.getHelmet();
|
||||
colorList.put(i, is.getDurability());
|
||||
}
|
||||
}
|
||||
}
|
||||
return colorList;
|
||||
}
|
||||
}
|
256
src/de/Ste3et_C0st/Furniture/Objects/outdoor/tent_3.java
Normal file
256
src/de/Ste3et_C0st/Furniture/Objects/outdoor/tent_3.java
Normal file
@ -0,0 +1,256 @@
|
||||
package de.Ste3et_C0st.Furniture.Objects.outdoor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.bukkit.block.banner.PatternType;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BannerMeta;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
|
||||
import de.Ste3et_C0st.Furniture.Main.Utils;
|
||||
import de.Ste3et_C0st.Furniture.Main.main;
|
||||
|
||||
public class tent_3 implements Listener {
|
||||
|
||||
private Location loc;
|
||||
private String ID;
|
||||
private BlockFace b;
|
||||
private Block block;
|
||||
private List<String> idList = new ArrayList<String>();
|
||||
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) {
|
||||
this.b = Utils.yawToFace(location.getYaw());
|
||||
this.loc = location.getBlock().getLocation();
|
||||
this.ID = ID;
|
||||
this.w = location.getWorld();
|
||||
if(b.equals(BlockFace.WEST)){location=main.getNew(location, b, 1D, 0D);}
|
||||
if(b.equals(BlockFace.NORTH)){location=main.getNew(location, b, 1D, 1D);}
|
||||
if(b.equals(BlockFace.EAST)){location=main.getNew(location, b, 0D, 1D);}
|
||||
|
||||
ItemStack banner = new ItemStack(Material.BANNER);
|
||||
BannerMeta meta = (BannerMeta) banner.getItemMeta();
|
||||
meta.setBaseColor(DyeColor.WHITE);
|
||||
banner.setItemMeta(meta);
|
||||
|
||||
Location locstart = main.getNew(location, b, .2D, -.17D);
|
||||
locstart.add(0,.65,0);
|
||||
|
||||
Location locstart2 = main.getNew(location, b, .2D, -.8D);
|
||||
locstart2.add(0,.65,0);
|
||||
|
||||
for(int i = 0; i<=2;i++){
|
||||
Location loc = main.getNew(locstart, b, .74*i, 0D);
|
||||
loc.setYaw(Utils.FaceToYaw(b)+90);
|
||||
Utils.setArmorStand(loc, new EulerAngle(3.5, 0, 0), banner, false, false, false, getID(), idList);
|
||||
|
||||
loc = main.getNew(locstart, b, .74*i, -.3D);
|
||||
loc.add(0,.9,0);
|
||||
loc.setYaw(Utils.FaceToYaw(b)+90);
|
||||
Utils.setArmorStand(loc, new EulerAngle(3.5, 0, 0), banner, false, false, false, getID(), idList);
|
||||
}
|
||||
|
||||
for(int i = 0; i<=2;i++){
|
||||
Location loc = main.getNew(locstart2, b, .74*i, 0D);
|
||||
loc.setYaw(Utils.FaceToYaw(b)-90);
|
||||
Utils.setArmorStand(loc, new EulerAngle(3.5, 0, 0), banner, false, false, false, getID(), idList);
|
||||
|
||||
loc = main.getNew(locstart2, b, .74*i, .32D);
|
||||
loc.add(0,.9,0);
|
||||
loc.setYaw(Utils.FaceToYaw(b)-90);
|
||||
Utils.setArmorStand(loc, new EulerAngle(3.5, 0, 0), banner, false, false, false, getID(), idList);
|
||||
}
|
||||
|
||||
banner = new ItemStack(Material.BANNER);
|
||||
meta = (BannerMeta) banner.getItemMeta();
|
||||
meta.setBaseColor(DyeColor.WHITE);
|
||||
meta.addPattern(new Pattern(DyeColor.RED, PatternType.STRIPE_SMALL));
|
||||
banner.setItemMeta(meta);
|
||||
|
||||
Location banner1 = main.getNew(location, b, 1.7D, -.1D);
|
||||
banner1.add(0,-1.2,0);
|
||||
Location banner2 = main.getNew(banner1, b, 0D, -.75);
|
||||
banner1.setYaw(Utils.FaceToYaw(b));
|
||||
banner2.setYaw(Utils.FaceToYaw(b));
|
||||
Utils.setArmorStand(banner1, new EulerAngle(-1.568, 0, 0), banner, false, false, false, getID(), idList);
|
||||
Utils.setArmorStand(banner2, new EulerAngle(-1.568, 0, 0), banner, false, false, false, getID(), idList);
|
||||
|
||||
Location sit = Utils.getCenter(location);
|
||||
|
||||
if(b.equals(BlockFace.WEST)){sit=main.getNew(sit, b, -1D, 0D);}
|
||||
if(b.equals(BlockFace.NORTH)){sit=main.getNew(sit, b, -1D, -1D);}
|
||||
if(b.equals(BlockFace.EAST)){sit=main.getNew(sit, b, 0D, -1D);}
|
||||
|
||||
sit.setYaw(Utils.FaceToYaw(this.b.getOppositeFace()));
|
||||
Location locationsit = main.getNew(sit, b, 1D, 0D);
|
||||
locationsit.setYaw(Utils.FaceToYaw(this.b.getOppositeFace()));
|
||||
armorstand = Utils.setArmorStand(locationsit.add(0,-2,0), null, null, false, false, false, getID(), idList);
|
||||
|
||||
block = Utils.setHalfBed(b, main.getNew(sit.add(0,-2,0).getBlock().getLocation().add(0,2,0), b, 2D, 0D));
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
main.getInstance().getManager().tent3List.add(this);
|
||||
this.loc.setYaw(Utils.FaceToYaw(b));
|
||||
}
|
||||
|
||||
|
||||
@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;}
|
||||
if(!idList.contains(e.getEntity().getCustomName())){return;}
|
||||
e.setCancelled(true);
|
||||
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)
|
||||
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;}
|
||||
e.setCancelled(true);
|
||||
ItemStack is = player.getItemInHand();
|
||||
if(is==null){return;}
|
||||
if(is.getType().equals(Material.INK_SACK)){
|
||||
if(!main.getInstance().getCheckManager().canBuild(player, getLocation())){return;}
|
||||
Short druability = is.getDurability();
|
||||
Integer amount = is.getAmount();
|
||||
Integer neAmound = amount;
|
||||
if(amount>idList.size() || player.getGameMode().equals(GameMode.CREATIVE)){amount=idList.size();}
|
||||
List<Entity> list = new ArrayList<Entity>();
|
||||
for(String s : this.idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as!=null){
|
||||
ItemStack item = as.getHelmet();
|
||||
if(!as.getHelmet().getType().equals(Material.BANNER)){continue;}
|
||||
BannerMeta im = (BannerMeta) item.getItemMeta();
|
||||
if(im.getBaseColor().getColor() != main.getDyeFromDurability(druability)){list.add(as);}
|
||||
}
|
||||
}
|
||||
for(Entity entity : list){
|
||||
if(list.indexOf(entity)>amount-1){break;}
|
||||
if(entity instanceof ArmorStand == false){break;}
|
||||
ArmorStand as = (ArmorStand) entity;
|
||||
if(as==null||as.getHelmet()==null){break;}
|
||||
if(!as.getHelmet().getType().equals(Material.BANNER)){neAmound-=1;continue;}
|
||||
ItemStack item = as.getHelmet();
|
||||
BannerMeta banner = (BannerMeta) item.getItemMeta();
|
||||
banner.setBaseColor(DyeColor.getByColor(main.getDyeFromDurability(druability)));
|
||||
item.setItemMeta(banner);
|
||||
as.setHelmet(item);
|
||||
}
|
||||
if(!player.getGameMode().equals(GameMode.CREATIVE)){
|
||||
is.setAmount(is.getAmount()-neAmound);
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), is);
|
||||
player.updateInventory();
|
||||
}
|
||||
main.getInstance().mgr.saveTent3(this);
|
||||
return;
|
||||
}else{
|
||||
if(checkIfSitting()){
|
||||
armorstand.setPassenger(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkIfSitting(){
|
||||
if(armorstand != null){
|
||||
if(armorstand.getPassenger()!= null){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void delete(boolean b, boolean a){
|
||||
if(b){
|
||||
if(a){getLocation().getWorld().dropItem(getLocation(), main.getInstance().crafting.get("tent3"));}
|
||||
for(String s : idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, s);
|
||||
if(as!=null){
|
||||
if(a){as.getWorld().playEffect(as.getLocation(), Effect.STEP_SOUND, Material.LOG);}
|
||||
as.remove();
|
||||
}
|
||||
}
|
||||
if(this.block != null){
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
main.getInstance().mgr.deleteFromConfig(getID(), "tent3");
|
||||
}
|
||||
block = null;
|
||||
armorstand = null;
|
||||
idList.clear();
|
||||
main.getInstance().getManager().tent3List.remove(this);
|
||||
}
|
||||
|
||||
public void save(){
|
||||
main.getInstance().mgr.saveTent3(this);
|
||||
}
|
||||
|
||||
public HashMap<Integer, Integer> getColor(){
|
||||
HashMap<Integer, Integer> colorList = new HashMap<Integer, Integer>();
|
||||
Integer i = 0;
|
||||
|
||||
for(String id: idList){
|
||||
try{i=colorList.size();}catch(Exception e){return colorList;}
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, id);
|
||||
if(as!=null){
|
||||
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)&&as.getHelmet().getType().equals(Material.BANNER)){
|
||||
ItemStack is = as.getHelmet();
|
||||
BannerMeta im = (BannerMeta) is.getItemMeta();
|
||||
colorList.put(i, im.getBaseColor().getColor().asRGB());
|
||||
}
|
||||
}
|
||||
}
|
||||
return colorList;
|
||||
}
|
||||
|
||||
public void setColor(HashMap<Integer, Integer> durabilityList){
|
||||
int i = 0;
|
||||
for(String id: idList){
|
||||
ArmorStand as = Utils.getArmorStandAtID(w, id);
|
||||
if(as!=null){
|
||||
if(as.getHelmet()!=null&&!as.getHelmet().getType().equals(Material.AIR)&&as.getHelmet().getType().equals(Material.BANNER)){
|
||||
ItemStack is = as.getHelmet();
|
||||
BannerMeta im = (BannerMeta) is.getItemMeta();
|
||||
im.setBaseColor(DyeColor.getByColor(Color.fromRGB(durabilityList.get(i))));
|
||||
is.setItemMeta(im);
|
||||
as.setHelmet(is);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +1,11 @@
|
||||
name: Furniture
|
||||
version: 1.5
|
||||
description: DiceEquipment
|
||||
version: 1.7.3
|
||||
description: Add some Furniture to the Server
|
||||
author: Ste3et_C0st
|
||||
website: http://dicecraft.de
|
||||
softdepend: [Vault]
|
||||
softdepend: [Vault, WorldGuard, WorldEdit, Towny, Landlord, LightAPI, PlotSquared, PreciousStones, PlotMe]
|
||||
main: de.Ste3et_C0st.Furniture.Main.main
|
||||
|
||||
commands:
|
||||
furniture:
|
||||
description: DiceEaster Egg Command
|
||||
description: Dice Furniture Command
|
||||
usage: /<command>
|
Loading…
Reference in New Issue
Block a user