Ste3et_C0st 2019-02-19 15:14:02 +01:00
parent 980c78afdf
commit 3742238bb6
8 changed files with 184 additions and 577 deletions

View File

@ -110,7 +110,7 @@
<dependency>
<groupId>de.Ste3et_C0st.furniture</groupId>
<artifactId>FurnitureLib</artifactId>
<version>2.0.5</version>
<version>2.0.6</version>
<scope>provided</scope>
</dependency>
</dependencies>

View File

@ -1,17 +1,17 @@
# ------------------------------------ #
# #
# never touch the system-ID ! #
# #
# ------------------------------------ #
Guillotine:
system-ID: Guillotine
displayName: '&cGuillotine'
itemGlowEffect: false
spawnMaterial: PIG_SPAWN_EGG
itemLore: []
crafting:
recipe: XXX,XXX,XXX
disable: true
index:
X: AIR
# ------------------------------------ #
# #
# never touch the system-ID ! #
# #
# ------------------------------------ #
Guillotine:
system-ID: Guillotine
displayName: '&cGuillotine'
itemGlowEffect: false
spawnMaterial: PIG_SPAWN_EGG
itemLore: []
crafting:
recipe: XXX,XXX,XXX
disable: true
index:
X: AIR

View File

@ -1,277 +0,0 @@
package de.Ste3et_C0st.Furniture.Main;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import de.Ste3et_C0st.FurnitureLib.Crafting.Project;
import de.Ste3et_C0st.FurnitureLib.ShematicLoader.Events.ProjectBreakEvent;
import de.Ste3et_C0st.FurnitureLib.ShematicLoader.Events.ProjectClickEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.HiddenStringUtils;
import de.Ste3et_C0st.FurnitureLib.Utilitis.ManageInv;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
public class Log extends FurnitureHelper implements Listener{
private int mode = 0;
private Inventory inv = Bukkit.createInventory(null, 9, "§2Settings");
private ItemStack pane = new ItemStack(Material.WHITE_STAINED_GLASS_PANE);
private ItemStack permissions = new ItemStack(Material.ARROW);
private Player p;
private List<ItemStack> isList = new ArrayList<ItemStack>();
public Log(ObjectID id) {
super(id);
Bukkit.getPluginManager().registerEvents(this, main.instance);
setList();
for(fEntity entity : getObjID().getPacketList()){
entity.setNameVasibility(false);
}
update();
}
@EventHandler
private void onBlockBreak(ProjectBreakEvent e){
if(e.getID() == null || getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
}
@SuppressWarnings("deprecation")
@EventHandler
private void onBlockBreak(ProjectClickEvent e){
if(e.getID() == null || getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
if(e.getPlayer().isSneaking()){
if(e.getPlayer().getInventory().getItemInMainHand().getType().isBlock()&&
!e.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.AIR)){
e.setCancelled(false);
return;
}
openInventory(e.getPlayer());
}else{
if(e.getPlayer().getInventory().getItemInMainHand().getType().isBlock() && !e.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.AIR)){
getCenter().getBlock().setType(e.getPlayer().getInventory().getItemInMainHand().getType());
removeItem(e.getPlayer());
return;
}else if(!e.getPlayer().getInventory().getItemInMainHand().getType().isBlock() && !e.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.AIR)){
fEntity stand = null;
if(getProjectByItem(e.getPlayer().getInventory().getItemInMainHand()) != null){return;}
for(fEntity s : getObjID().getPacketList()){
if(s.getName().equalsIgnoreCase(mode+"")){
stand = s;
break;
}
}
if(stand==null){return;}
if(stand.getInventory().getItemInMainHand()!=null&&!stand.getInventory().getItemInMainHand().getType().equals(Material.AIR)){
if(e.getPlayer().getInventory().getItemInMainHand()!=null){
if(e.getPlayer().getInventory().getItemInMainHand().equals(stand.getItemInMainHand())){
return;
}
}
ItemStack is = stand.getInventory().getItemInMainHand();
is.setAmount(1);
getWorld().dropItem(getLocation(), is);
}
ItemStack is = e.getPlayer().getInventory().getItemInMainHand().clone();
is.setAmount(1);
stand.setItemInMainHand(is);
update();
removeItem(e.getPlayer());
return;
}else{
fEntity stand = null;
for(fEntity s : getObjID().getPacketList()){
if(s.getName().equalsIgnoreCase(mode+"")){
stand = s;
break;
}
}
if(stand==null){return;}
if(stand.getInventory().getItemInMainHand()!=null&&!stand.getInventory().getItemInMainHand().getType().equals(Material.AIR)){
for(fEntity s : getObjID().getPacketList()){
if(s.getName().equalsIgnoreCase(mode+"")){
stand = s;
break;
}
}
ItemStack is = stand.getInventory().getItemInMainHand();
is.setAmount(1);
getWorld().dropItem(getLocation(), is);
}
stand.setItemInMainHand(new ItemStack(Material.AIR));
update();
return;
}
}
}
private void setList(){
ItemStack stack = new ItemStack(Material.WHITE_BANNER);
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName("§6Mode: §cTop");
stack.setItemMeta(meta);
isList.add(stack);
stack = new ItemStack(Material.ORANGE_BANNER);
meta = stack.getItemMeta();
meta.setDisplayName("§6Mode: §cFront I");
stack.setItemMeta(meta);
isList.add(stack);
stack = new ItemStack(Material.BLUE_BANNER);
meta = stack.getItemMeta();
meta.setDisplayName("§6Mode: §cFront II");
stack.setItemMeta(meta);
isList.add(stack);
meta = permissions.getItemMeta();
meta.setDisplayName("§cChange Permissions (Owner Only)");
permissions.setItemMeta(meta);
}
private Project getProjectByItem(ItemStack is){
ItemStack stack = is.clone();
if(stack==null) return null;
String systemID = "";
if(stack.hasItemMeta()){
if(stack.getItemMeta().hasLore()){
List<String> s = stack.getItemMeta().getLore();
if(HiddenStringUtils.hasHiddenString(s.get(0))) systemID = HiddenStringUtils.extractHiddenString(s.get(0));
}
}
for(Project pro : FurnitureLib.getInstance().getFurnitureManager().getProjects()){
if(pro==null) continue;
if(pro.getSystemID()==null) continue;
if(pro.getSystemID().equalsIgnoreCase(systemID)){
return pro;
}
}
return null;
}
public void removeItem(Player p){
Boolean useGameMode = FurnitureLib.getInstance().useGamemode();
if(useGameMode&&p.getGameMode().equals(GameMode.CREATIVE)){return;}
Integer slot = p.getInventory().getHeldItemSlot();
ItemStack itemStack = p.getInventory().getItemInMainHand().clone();
itemStack.setAmount(itemStack.getAmount()-1);
p.getInventory().setItem(slot, itemStack);
p.updateInventory();
}
private void openInventory(Player p){
if(this.p !=null) return;
this.p = p;
inv.clear();
int j = mode;
for(int i = 0; i<inv.getSize();i++){
if(i==2){
inv.addItem(isList.get(j));
continue;
}else if(i==6){
inv.addItem(permissions);
continue;
}
inv.setItem(i,pane);
}
p.openInventory(inv);
}
@EventHandler
private void onClick(InventoryClickEvent e){
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.getClickedInventory()==null||!e.getClickedInventory().equals(inv)){return;}
e.setCancelled(true);
if(e.getCurrentItem()==null){return;}
if(e.getCurrentItem().getType().name().contains("_BANNER")){
Integer i = isList.indexOf(e.getCurrentItem());
ItemStack is = null;
if(i>=2){i = -1;}
i++;
is = isList.get(i);
mode = i;
modeSwitch(e.getCurrentItem().getDurability());
inv.setItem(e.getSlot(), is);
p.updateInventory();
}else if(e.getCurrentItem().getType().equals(Material.ARROW)){
if(!getObjID().getUUID().equals(p.getUniqueId())){
if(!getLib().getPermission().hasPerm(p, "furniture.admin") && !p.isOp() && !getLib().getPermission().hasPerm(p, "furniture.manage.other")){
return;
}
}
p.closeInventory();
new ManageInv((Player) e.getWhoClicked(), getObjID());
}
}
public void modeSwitch(short dura){
int oldArmorStand = 0;
int currentArmorStand = 0;
switch (dura) {
case 1:
oldArmorStand = 0;
currentArmorStand = 1;
break;
case 2:
oldArmorStand = 1;
currentArmorStand = 2;
break;
case 11:
oldArmorStand = 2;
currentArmorStand = 0;
break;
}
fEntity standOld = null;
fEntity standCurrent = null;
for(fEntity s : getObjID().getPacketList()){
if(s.getName().equalsIgnoreCase(oldArmorStand+"")){
standOld=s;
}else if(s.getName().equalsIgnoreCase(currentArmorStand+"")){
standCurrent=s;
}
}
if(standOld!=null&&standCurrent!=null){
standCurrent.setItemInMainHand(standOld.getItemInMainHand());
standOld.setItemInMainHand(new ItemStack(Material.AIR));
update();
}
}
@EventHandler
public void onClose(InventoryCloseEvent e){
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.getInventory()==null){return;}
if(e.getInventory().equals(inv)){this.p = null;}
}
}

View File

@ -19,9 +19,9 @@ import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import de.Ste3et_C0st.Furniture.Objects.RPG.Crossbow;
import de.Ste3et_C0st.Furniture.Objects.RPG.Guillotine;
import de.Ste3et_C0st.Furniture.Objects.RPG.Catapult;
import de.Ste3et_C0st.Furniture.Objects.RPG.flag;
import de.Ste3et_C0st.Furniture.Objects.RPG.guillotine;
import de.Ste3et_C0st.Furniture.Objects.RPG.weaponStand;
import de.Ste3et_C0st.Furniture.Objects.School.TrashCan;
import de.Ste3et_C0st.Furniture.Objects.christmas.AdventCalender;
@ -34,6 +34,7 @@ import de.Ste3et_C0st.Furniture.Objects.garden.Trunk;
import de.Ste3et_C0st.Furniture.Objects.garden.config;
import de.Ste3et_C0st.Furniture.Objects.garden.fance;
import de.Ste3et_C0st.Furniture.Objects.garden.graveStone;
import de.Ste3et_C0st.Furniture.Objects.garden.log;
import de.Ste3et_C0st.Furniture.Objects.garden.sunshade;
import de.Ste3et_C0st.Furniture.Objects.indoor.largeTable;
import de.Ste3et_C0st.Furniture.Objects.light.WaxCandle;
@ -94,7 +95,7 @@ public class main extends JavaPlugin implements Listener{
new Project("Streetlamp", this, getResource("Crafting/Streetlamp.dModel"),PlaceableSide.TOP, streetlamp.class).setSize(2, 4, 1, CenterType.FRONT);
new Project("Billboard", this, getResource("Crafting/Billboard.dModel"),PlaceableSide.TOP, billboard.class).setSize(1, 3, 3, CenterType.RIGHT);
new Project("WeaponStand", this, getResource("Crafting/WeaponStand.dModel"),PlaceableSide.TOP, weaponStand.class).setSize(1, 1, 1, CenterType.RIGHT);
new Project("Guillotine", this, getResource("Crafting/Guillotine.dModel"),PlaceableSide.TOP, guillotine.class).setSize(1, 5, 2, CenterType.RIGHT);
new Project("Guillotine", this, getResource("Crafting/Guillotine.dModel"),PlaceableSide.TOP, Guillotine.class).setSize(1, 5, 2, CenterType.RIGHT);
new Project("FlowerPot", this, getResource("Crafting/FlowerPot.dModel"),PlaceableSide.BOTTOM, TFlowerPot.class).setSize(1, 1, 1, CenterType.RIGHT);
new Project("BearTrap", this, getResource("Crafting/BearTrap.dModel"), PlaceableSide.TOP, BearTrap.class).setSize(1, 1, 1, CenterType.RIGHT);
new Project("TrashCan", this, getResource("Crafting/TrashCan.dModel"), PlaceableSide.TOP, TrashCan.class).setSize(1, 1, 1, CenterType.RIGHT);
@ -135,7 +136,6 @@ public class main extends JavaPlugin implements Listener{
new Project("Camera", this, getResource("Models/Camera.dModel")).setSize(1, 1, 1, CenterType.RIGHT).setEditorProject(false);
new Project("Sofa", this, getResource("Models/Sofa.dModel")).setSize(1, 1, 3, CenterType.RIGHT).setEditorProject(false);
new Project("Log", this, getResource("Models/Log.dModel")).setSize(1, 1, 1, CenterType.CENTER).setEditorProject(false);
lib.registerPluginFurnitures(getInstance());
loadModels();
}else{
@ -216,7 +216,7 @@ public class main extends JavaPlugin implements Listener{
case "Tent1": new tent_1(id);break;
case "GraveStone": new graveStone(id);break;
case "Camera": new camera(id);break;
case "Log": new Log(id);break;
case "Log": new log(id);break;
default:break;
}
}
@ -241,7 +241,7 @@ public class main extends JavaPlugin implements Listener{
case "Tent1": new tent_1(event.getID());break;
case "GraveStone": new graveStone(event.getID());break;
case "Camera": new camera(event.getID());break;
case "Log": new Log(event.getID());break;
case "Log": new log(event.getID());break;
default:break;
}
}

View File

@ -3,6 +3,7 @@ package de.Ste3et_C0st.Furniture.Objects.RPG;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -32,7 +33,7 @@ import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
public class guillotine extends Furniture implements Listener{
public class Guillotine extends Furniture implements Listener{
Boolean soundPlaying = false, isFinish = false;
fArmorStand packet1, packet2, packet3;
@ -55,9 +56,9 @@ public class guillotine extends Furniture implements Listener{
List<Material> matListIII = Arrays.asList(
Material.LEATHER_BOOTS,Material.IRON_BOOTS,Material.GOLDEN_BOOTS,
Material.DIAMOND_BOOTS, Material.CHAINMAIL_BOOTS);
List<fArmorStand> armorStandList = new ArrayList<fArmorStand>();
List<fEntity> armorStandList = new ArrayList<fEntity>();
ItemStack pane = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
public guillotine(ObjectID id) {
public Guillotine(ObjectID id) {
super(id);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, main.getInstance());
@ -95,24 +96,15 @@ public class guillotine extends Furniture implements Listener{
private void setDefault(){
armorStandList.clear();
if(packet1==null){packet2 = getByName("#Oblation#");}
if(packet3==null){packet3 = getByName("#Head#");}
for(fEntity packets : getManager().getfArmorStandByObjectID(getObjID())){
if(packets instanceof fArmorStand){
fArmorStand stand = (fArmorStand) packets;
if(!packets.getName().equalsIgnoreCase("")){
if(!(packets.getName().startsWith("#Oblation#") && packets.getName().startsWith("#Head#"))){
if(packets.getName().startsWith("iron")){
armorStandList.add(stand);
Location loc = getStartLocation(packets.getName());
packets.teleport(loc);
}else{
packet1 = stand;
}
}
}
}
}
this.packet1 = (fArmorStand) entityByCustomName("#Executioner#");
this.packet3 = (fArmorStand) entityByCustomName("#Head#");
this.packet2 = (fArmorStand) getfAsList().stream().filter(entity -> entity.getCustomName().startsWith("#Oblation#")).findFirst().orElse(null);
getfAsList().stream().filter(entity -> entity.getCustomName().startsWith("iron")).forEach(entity -> {
armorStandList.add(entity);
entity.teleport(getStartLocation(entity.getCustomName()));
});
if(packet3!=null){
if(packet3.getHelmet()!=null){
@ -447,30 +439,22 @@ public class guillotine extends Furniture implements Listener{
boolean a = false,b = false,c = false;
a = !packet1.isInvisible();
b = !packet2.isInvisible();
if(packet1.getItemInMainHand() == null) {
return false;
}
if(packet1.getHelmet() == null) {
return false;
}
if(packet1.getItemInMainHand()!=null&&!packet1.getItemInMainHand().getType().equals(Material.AIR)){
c = true;
}else {
if(!packet1.getItemInMainHand().getType().equals(Material.AIR)) System.out.println("material");
System.out.println("false");
}
if(packet1.getItemInMainHand()!=null) {
System.out.println("mainHand");
if(!packet1.getItemInMainHand().getType().equals(Material.AIR)) {
System.out.println("material");
}else {
System.out.println("material==null");
}
}else {
System.out.println("mainHand == null");
}
if(a&&b&&c){
return true;
}
System.out.println("test");
return false;
}
@ -514,7 +498,7 @@ public class guillotine extends Furniture implements Listener{
i++;
}else{
if(d4>d3){
for(fArmorStand stand : armorStandList){
for(fEntity stand : armorStandList){
stand.teleport(stand.getLocation().add(0, -1.7, 0));
}
d4=-1.7;

View File

@ -1,77 +1,151 @@
package de.Ste3et_C0st.Furniture.Objects.garden;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.util.EulerAngle;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.Crafting.Project;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBlockBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBlockClickEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureBreakEvent;
import de.Ste3et_C0st.FurnitureLib.Events.FurnitureClickEvent;
import de.Ste3et_C0st.FurnitureLib.ShematicLoader.Events.ProjectBreakEvent;
import de.Ste3et_C0st.FurnitureLib.ShematicLoader.Events.ProjectClickEvent;
import de.Ste3et_C0st.FurnitureLib.Utilitis.HiddenStringUtils;
import de.Ste3et_C0st.FurnitureLib.Utilitis.ManageInv;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureHelper;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.SQLAction;
import de.Ste3et_C0st.FurnitureLib.main.entity.fArmorStand;
import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
public class log extends Furniture {
public class log extends FurnitureHelper implements Listener{
Block b;
int mode = 0;
Inventory inv = Bukkit.createInventory(null, 9, "§2Settings");
ItemStack pane = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
ItemStack permissions = new ItemStack(Material.ARROW);
List<ItemStack> isList = new ArrayList<ItemStack>();
Player p;
private int mode = 0;
private Inventory inv = Bukkit.createInventory(null, 9, "§2Settings");
private ItemStack pane = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
private ItemStack permissions = new ItemStack(Material.ARROW);
private Player p;
private List<ItemStack> isList = new ArrayList<ItemStack>();
public log(ObjectID id){
public log(ObjectID id) {
super(id);
b = getLocation().getBlock();
ItemMeta meta = pane.getItemMeta();
meta.setDisplayName("§c");
pane.setItemMeta(meta);
pane.setDurability((short) 15);
pane.setItemMeta(meta);
Bukkit.getPluginManager().registerEvents(this, main.instance);
getObjID().getPacketList().stream().forEach(entity -> {
entity.setNameVasibility(false);
((fArmorStand) entity).setMarker(false);
});
update();
setList();
getObjID().addBlock(Arrays.asList(b));
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, main.getInstance());
return;
}
@EventHandler
private void onBlockBreak(ProjectBreakEvent e){
if(e.getID() == null || getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
}
private Project getProjectByItem(ItemStack is){
ItemStack stack = getItemStackCopy(is);
if(stack==null) return null;
String systemID = "";
if(stack.hasItemMeta()){
if(stack.getItemMeta().hasLore()){
List<String> s = stack.getItemMeta().getLore();
if(HiddenStringUtils.hasHiddenString(s.get(0))) systemID = HiddenStringUtils.extractHiddenString(s.get(0));
}
}
spawn(id.getStartLocation());
for(Project pro : FurnitureLib.getInstance().getFurnitureManager().getProjects()){
if(pro==null) continue;
if(pro.getSystemID()==null) continue;
if(pro.getSystemID().equalsIgnoreCase(systemID)){
return pro;
}
}
return null;
}
private ItemStack getItemStackCopy(ItemStack is){
ItemStack copy = is.clone();
copy.setAmount(1);
return copy;
}
@EventHandler
private void onBlockBreak(ProjectClickEvent e){
if(e.getID() == null || getObjID() == null) return;
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
if(e.getPlayer().isSneaking()){
if(e.getPlayer().getInventory().getItemInMainHand().getType().isBlock()&&
!e.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.AIR)){
return;
}
openInventory(e.getPlayer());
}else{
ItemStack stack = e.getPlayer().getInventory().getItemInMainHand();
if(stack == null || stack.getType().equals(Material.AIR)){
//dropItem
fEntity entity = entityByCustomName(this.mode + "");
if(entity != null) {
if(entity.getItemInMainHand() != null) {
if(!entity.getItemInMainHand().getType().equals(Material.AIR)) {
if(entity.getItemInMainHand().equals(stack)) {return;}
getWorld().dropItem(getLocation(), entity.getItemInMainHand());
entity.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
update();
}
}
}
}else{
if(getProjectByItem(stack) != null) {return;}
if(stack.getType().isBlock()) {
Block b = getCenter().getBlock();
b.setType(stack.getType());
}else{
fEntity entity = entityByCustomName(this.mode + "");
if(entity != null) {
if(entity.getItemInMainHand() != null) {
if(!entity.getItemInMainHand().getType().equals(Material.AIR)) {
if(entity.getItemInMainHand().equals(stack)) {return;}
getWorld().dropItem(getLocation(), entity.getItemInMainHand());
}
}
ItemStack placeItem = stack.clone();
placeItem.setAmount(1);
entity.getInventory().setItemInMainHand(placeItem);
consumeItem(e.getPlayer());
update();
}
}
}
}
}
private void setList(){
ItemStack stack = new ItemStack(Material.ORANGE_WOOL);
ItemStack stack = new ItemStack(Material.WHITE_BANNER);
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName("§6Mode: §cTop");
stack.setItemMeta(meta);
isList.add(stack);
stack = new ItemStack(Material.MAGENTA_WOOL);
stack = new ItemStack(Material.ORANGE_BANNER);
meta = stack.getItemMeta();
meta.setDisplayName("§6Mode: §cFront I");
stack.setItemMeta(meta);
isList.add(stack);
stack = new ItemStack(Material.BLUE_WOOL);
stack = new ItemStack(Material.BLUE_BANNER);
meta = stack.getItemMeta();
meta.setDisplayName("§6Mode: §cFront II");
stack.setItemMeta(meta);
@ -82,43 +156,14 @@ public class log extends Furniture {
permissions.setItemMeta(meta);
}
@Override
public void spawn(Location loc) {
b.setType(Material.OAK_LOG);
List<fArmorStand> lStand = new ArrayList<fArmorStand>();
Location loc1 = getLutil().getRelativ(getCenter(), getBlockFace(), .5, .35);
loc1.setYaw(getYaw());
Location loc2 = getLutil().getRelativ(getCenter(), getBlockFace(), -.7, .35d);
loc2.setYaw(getYaw());
Location loc3 = getLutil().getRelativ(getCenter(), getBlockFace(), -1.3, .35d).subtract(0, 1.0, 0);
loc3.setYaw(getYaw());
fArmorStand stand = spawnArmorStand(loc1);
stand.setRightArmPose(new EulerAngle(1.35, 0, 0));
stand.setName("0");
lStand.add(stand);
stand = spawnArmorStand(loc2);
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(15, 0, 0)));
stand.setName("1");
lStand.add(stand);
stand = spawnArmorStand(loc3);
stand.setRightArmPose(getLutil().degresstoRad(new EulerAngle(-30, 0, 0)));
stand.setName("2");
lStand.add(stand);
for(fArmorStand asp : lStand){
asp.setInvisible(false);
asp.setBasePlate(false);
asp.setMarker(false);
}
send();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
public void removeItem(Player p){
Boolean useGameMode = FurnitureLib.getInstance().useGamemode();
if(useGameMode&&p.getGameMode().equals(GameMode.CREATIVE)){return;}
Integer slot = p.getInventory().getHeldItemSlot();
ItemStack itemStack = p.getInventory().getItemInMainHand().clone();
itemStack.setAmount(itemStack.getAmount()-1);
p.getInventory().setItem(slot, itemStack);
p.updateInventory();
}
private void openInventory(Player p){
@ -146,14 +191,14 @@ public class log extends Furniture {
if(e.getClickedInventory()==null||!e.getClickedInventory().equals(inv)){return;}
e.setCancelled(true);
if(e.getCurrentItem()==null){return;}
if(e.getCurrentItem().getType().equals(Material.WHITE_BANNER)){
if(e.getCurrentItem().getType().name().contains("_BANNER")){
Integer i = isList.indexOf(e.getCurrentItem());
ItemStack is = null;
if(i>=2){i = -1;}
i++;
is = isList.get(i);
mode = i;
modeSwitch(e.getCurrentItem().getDurability());
modeSwitch(e.getCurrentItem().getType());
inv.setItem(e.getSlot(), is);
p.updateInventory();
}else if(e.getCurrentItem().getType().equals(Material.ARROW)){
@ -167,23 +212,24 @@ public class log extends Furniture {
}
}
public void modeSwitch(short dura){
public void modeSwitch(Material type){
int oldArmorStand = 0;
int currentArmorStand = 0;
switch (dura) {
case 1:
switch (type) {
case WHITE_BANNER:
oldArmorStand = 0;
currentArmorStand = 1;
break;
case 2:
case ORANGE_BANNER:
oldArmorStand = 1;
currentArmorStand = 2;
break;
case 11:
case BLUE_BANNER:
oldArmorStand = 2;
currentArmorStand = 0;
break;
default: break;
}
fEntity standOld = null;
@ -211,156 +257,4 @@ public class log extends Furniture {
if(e.getInventory().equals(inv)){this.p = null;}
}
@SuppressWarnings("deprecation")
@EventHandler
public void onBlockClick(FurnitureBlockClickEvent e){
if(e.getID() == null || getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.isCancelled()){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
e.setCancelled(true);
Player p = e.getPlayer();
if(p.isSneaking()){
if(p.getInventory().getItemInMainHand().getType().isBlock()&&!p.getInventory().getItemInMainHand().getType().equals(Material.AIR)){
e.setCancelled(false);
return;
}
openInventory(p);
}else{
if(p.getInventory().getItemInMainHand().getType().isBlock() && !p.getInventory().getItemInMainHand().getType().equals(Material.AIR)){
this.b.setType(p.getInventory().getItemInMainHand().getType());
removeItem(p);
return;
}else if(!p.getInventory().getItemInMainHand().getType().isBlock() && !p.getInventory().getItemInMainHand().getType().equals(Material.AIR)){
fEntity stand = null;
if(getProjectByItem(p.getInventory().getItemInMainHand()) != null){return;}
for(fEntity s : getObjID().getPacketList()){
if(s.getName().equalsIgnoreCase(mode+"")){
stand = s;
break;
}
}
if(stand==null){return;}
if(stand.getInventory().getItemInMainHand()!=null&&!stand.getInventory().getItemInMainHand().getType().equals(Material.AIR)){
if(p.getInventory().getItemInMainHand()!=null){
if(p.getInventory().getItemInMainHand().equals(stand.getItemInMainHand())){
return;
}
}
ItemStack is = stand.getInventory().getItemInMainHand();
is.setAmount(1);
getWorld().dropItem(getLocation(), is);
}
ItemStack is = p.getInventory().getItemInMainHand().clone();
is.setAmount(1);
stand.setItemInMainHand(is);
update();
removeItem(p);
return;
}else{
fEntity stand = null;
for(fEntity s : getObjID().getPacketList()){
if(s.getName().equalsIgnoreCase(mode+"")){
stand = s;
break;
}
}
if(stand==null){return;}
if(stand.getInventory().getItemInMainHand()!=null&&!stand.getInventory().getItemInMainHand().getType().equals(Material.AIR)){
for(fEntity s : getObjID().getPacketList()){
if(s.getName().equalsIgnoreCase(mode+"")){
stand = s;
break;
}
}
ItemStack is = stand.getInventory().getItemInMainHand();
is.setAmount(1);
getWorld().dropItem(getLocation(), is);
}
stand.setItemInMainHand(new ItemStack(Material.AIR));
update();
return;
}
}
}
public void removeItem(Player p){
Boolean useGameMode = FurnitureLib.getInstance().useGamemode();
if(useGameMode&&p.getGameMode().equals(GameMode.CREATIVE)){return;}
Integer slot = p.getInventory().getHeldItemSlot();
ItemStack itemStack = p.getInventory().getItemInMainHand().clone();
itemStack.setAmount(itemStack.getAmount()-1);
p.getInventory().setItem(slot, itemStack);
p.updateInventory();
}
@Override
public void onFurnitureBreak(FurnitureBreakEvent paramFurnitureBreakEvent) {}
@Override
public void onFurnitureClick(FurnitureClickEvent paramFurnitureClickEvent) {}
@EventHandler
public void onBlockBreak(FurnitureBlockBreakEvent e){
if(e.getID() == null || getObjID() == null) return;
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(!e.getID().equals(getObjID())){return;}
if(!e.canBuild()){return;}
Player p = e.getPlayer();
fEntity stand = null;
for(fEntity s : getObjID().getPacketList()){
if(s.getName().equalsIgnoreCase(mode+"")){
stand = s;
break;
}
}
if(stand.getItemInMainHand()!=null&&!stand.getItemInMainHand().getType().equals(Material.AIR)){
ItemStack is = stand.getItemInMainHand();
is.setAmount(1);
getWorld().dropItem(getLocation(), is);
}
destroy(p);
b.setType(Material.AIR);
b=null;
}
private Project getProjectByItem(ItemStack is){
ItemStack stack = getItemStackCopy(is);
if(stack==null) return null;
String systemID = "";
if(stack.hasItemMeta()){
if(stack.getItemMeta().hasLore()){
List<String> s = stack.getItemMeta().getLore();
if(HiddenStringUtils.hasHiddenString(s.get(0))) systemID = HiddenStringUtils.extractHiddenString(s.get(0));
}
}
for(Project pro : FurnitureLib.getInstance().getFurnitureManager().getProjects()){
if(pro==null) continue;
if(pro.getSystemID()==null) continue;
if(pro.getSystemID().equalsIgnoreCase(systemID)){
return pro;
}
}
return null;
}
private ItemStack getItemStackCopy(ItemStack is){
ItemStack copy = new ItemStack(is.getType());
copy.setAmount(1);
copy.setDurability(is.getDurability());
copy.setItemMeta(is.getItemMeta());
return copy;
}
}
}

View File

@ -1,7 +0,0 @@
name: DiceFurniture
version: 3.2.1.4
description: Add some new Objects to the Server
author: Ste3et_C0st
website: http://dicecraft.de
depend: [FurnitureLib]
main: de.Ste3et_C0st.Furniture.Main.main

View File

@ -253,9 +253,22 @@ public class campfire_2 extends Furniture implements Listener{
if(is==null){return null;}
if(is.getType()==null){return null;}
if(items.contains(is.getType())){
String name = is.getType().name();
Material mat = EnumSet.allOf(Material.class).stream().filter(ma -> ma.name().startsWith(name) && !ma.equals(is.getType())).filter(ma -> ma.name().equalsIgnoreCase("COOKED") || ma.name().equalsIgnoreCase("BAKED")).findFirst().orElse(null);
if(mat == null) return null;
Material mat = null;
int rnd = (int)(Math.random()*100);
if(rnd < 5) {
mat = Material.COAL;
}else {
switch(is.getType()) {
case BEEF: mat = Material.COOKED_BEEF; break;
case CHICKEN: mat = Material.COOKED_CHICKEN; break;
case COD: mat = Material.COOKED_COD; break;
case POTATO: mat = Material.BAKED_POTATO; break;
case PORKCHOP: mat = Material.COOKED_PORKCHOP; break;
case RABBIT: mat = Material.RABBIT_STEW; break;
case MUTTON: mat = Material.COOKED_MUTTON; break;
default: mat = Material.COAL;break;
}
}
return new ItemStack(mat);
}
return is;