Fix Streetlamp "BlockRedstoneEvent"

This commit is contained in:
Ste3et_C0st 2020-01-06 13:21:07 +01:00
parent 5aaa09f392
commit 5dabe94b1d
4 changed files with 7 additions and 31 deletions

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.Ste3et_C0st.furniture</groupId>
<artifactId>DiceFurniture</artifactId>
<version>3.4</version>
<version>3.4.1</version>
<build>
<defaultGoal>clean package install</defaultGoal>
<sourceDirectory>src</sourceDirectory>

View File

@ -1,16 +1,12 @@
package de.Ste3et_C0st.Furniture.Main;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;

View File

@ -230,7 +230,7 @@ public class AdventCalender extends Furniture implements Listener{
conf = new config();
file = conf.getConfig(getObjID().getSerial() + "_Players", "plugin/AdventCalender/Data/");
if(file == null) return;
if(!file.isSet("Players")) return;
if(!file.contains("Players")) return;
for(String s : file.getConfigurationSection("Players").getKeys(false)){
UUID uuid = UUID.fromString(s);
int i = file.getInt("Players." + s);
@ -249,7 +249,7 @@ public class AdventCalender extends Furniture implements Listener{
if(uuid != null){
config conf = new config();
FileConfiguration file = conf.getConfig(getObjID().getSerial() + "_Players", "plugin/AdventCalender/Data/");
file.set("Players." + uuid.toString(), i);
file.set("Players." + uuid.toString(), getDay());
conf.saveConfig(getObjID().getSerial() + "_Players", file, "plugin/AdventCalender/Data/");
}
}

View File

@ -7,16 +7,12 @@ import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import de.Ste3et_C0st.Furniture.Main.FurnitureHook;
import de.Ste3et_C0st.Furniture.Main.main;
import de.Ste3et_C0st.FurnitureLib.main.Furniture;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
@ -25,20 +21,15 @@ import de.Ste3et_C0st.FurnitureLib.main.entity.fEntity;
public class streetlamp extends Furniture implements Listener{
Location light;
Vector loc2, loc3;
private Location light, redstoneBlock;
boolean redstone = false;
public streetlamp(ObjectID id){
super(id);
setBlock();
this.loc2 = id.getStartLocation().toVector();
this.loc3 = id.getStartLocation().getBlock().getRelative(BlockFace.DOWN).getLocation().toVector();
this.light = getLutil().getRelativ(getLocation(), getBlockFace(), -1D, 0D);
if(isFinish()){
Bukkit.getPluginManager().registerEvents(this, main.getInstance());
return;
}
this.redstoneBlock = getCenter().getBlock().getLocation();
spawn(id.getStartLocation());
}
@ -94,18 +85,7 @@ public class streetlamp extends Furniture implements Listener{
if(getObjID()==null){return;}
if(getObjID().getSQLAction().equals(SQLAction.REMOVE)){return;}
if(e.getBlock()==null){return;}
Vector loc = e.getBlock().getLocation().toVector();
if(loc2.distance(loc)<=1){
if(e.getNewCurrent()==0){
setLight(false);
redstone = false;
}else{
setLight(true);
redstone = true;
}
return;
}
if(loc3.distance(loc)<=1){
if(redstoneBlock.distance(e.getBlock().getLocation()) <= 1){
if(e.getNewCurrent()==0){
setLight(false);
redstone = false;