mirror of
https://github.com/JamesPeters98/ChestsPlusPlus.git
synced 2025-01-10 10:27:44 +01:00
Bug Fixes
This commit is contained in:
parent
729bbad359
commit
1ce9b3f4b0
@ -4,6 +4,7 @@ import com.jamesdpeters.minecraft.chests.TileEntityOpener;
|
||||
import net.minecraft.server.v1_14_R1.Block;
|
||||
import net.minecraft.server.v1_14_R1.BlockChest;
|
||||
import net.minecraft.server.v1_14_R1.BlockPropertyChestType;
|
||||
import net.minecraft.server.v1_14_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_14_R1.EnumDirection;
|
||||
import net.minecraft.server.v1_14_R1.SoundCategory;
|
||||
import net.minecraft.server.v1_14_R1.SoundEffect;
|
||||
@ -71,4 +72,12 @@ public class CustomTileEntityChest extends TileEntityChest implements TileEntity
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void startOpen(EntityHuman entityhuman) {
|
||||
|
||||
}
|
||||
|
||||
public void closeContainer(EntityHuman entityhuman) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -71,4 +71,13 @@ public class CustomTileEntityChest extends TileEntityChest implements TileEntity
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void startOpen(EntityHuman entityhuman) {
|
||||
|
||||
}
|
||||
|
||||
public void closeContainer(EntityHuman entityhuman) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import net.minecraft.server.v1_16_R1.SoundCategory;
|
||||
import net.minecraft.server.v1_16_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_16_R1.SoundEffects;
|
||||
import net.minecraft.server.v1_16_R1.TileEntityChest;
|
||||
import net.minecraft.server.v1_16_R1.TileEntityChestTrapped;
|
||||
import net.minecraft.server.v1_16_R1.TileEntityTypes;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
|
||||
@ -74,5 +73,12 @@ public class CustomTileEntityChest extends TileEntityChest implements TileEntity
|
||||
|
||||
}
|
||||
|
||||
public void startOpen(EntityHuman entityhuman) {
|
||||
|
||||
}
|
||||
|
||||
public void closeContainer(EntityHuman entityhuman) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import com.jamesdpeters.minecraft.chests.commands.AutoCraftCommand;
|
||||
import com.jamesdpeters.minecraft.chests.commands.ChestLinkCommand;
|
||||
import com.jamesdpeters.minecraft.chests.commands.ChestsPlusPlusCommand;
|
||||
import com.jamesdpeters.minecraft.chests.crafting.Crafting;
|
||||
import com.jamesdpeters.minecraft.chests.lang.LangFile;
|
||||
import com.jamesdpeters.minecraft.chests.lang.Message;
|
||||
import com.jamesdpeters.minecraft.chests.listeners.StorageListener;
|
||||
import com.jamesdpeters.minecraft.chests.listeners.HopperListener;
|
||||
import com.jamesdpeters.minecraft.chests.listeners.InventoryListener;
|
||||
@ -38,6 +40,9 @@ import org.bukkit.plugin.java.annotation.plugin.Description;
|
||||
import org.bukkit.plugin.java.annotation.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.annotation.plugin.author.Author;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
@Plugin(name = "ChestsPlusPlus", version = BuildConstants.VERSION)
|
||||
@ApiVersion(ApiVersion.Target.v1_14)
|
||||
@Description(value = "Minecraft Spigot mod that enhances chests and hoppers, with ChestLinks and Hopper filters!")
|
||||
@ -81,8 +86,10 @@ public class ChestsPlusPlus extends JavaPlugin {
|
||||
Metrics metrics = new Metrics(this, pluginId);
|
||||
Stats.addCharts(metrics);
|
||||
|
||||
Settings.initConfig(this);
|
||||
PLUGIN = this;
|
||||
// LangFile.createTemplateLangFile();
|
||||
Settings.initConfig(this);
|
||||
// LangFile.loadLangFile(Settings.getLangFileName());
|
||||
|
||||
//API initialisation
|
||||
API.register(this);
|
||||
@ -93,12 +100,6 @@ public class ChestsPlusPlus extends JavaPlugin {
|
||||
new AutoCraftCommand().register(this);
|
||||
new ChestsPlusPlusCommand().register(this);
|
||||
|
||||
//Register event listeners
|
||||
getServer().getPluginManager().registerEvents(new StorageListener(),this);
|
||||
getServer().getPluginManager().registerEvents(new InventoryListener(),this);
|
||||
getServer().getPluginManager().registerEvents(new HopperListener(),this);
|
||||
getServer().getPluginManager().registerEvents(new WorldListener(),this);
|
||||
|
||||
//Load storage
|
||||
SpigotConfig.load(this);
|
||||
|
||||
@ -142,6 +143,12 @@ public class ChestsPlusPlus extends JavaPlugin {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () ->{
|
||||
Crafting.load();
|
||||
new Config();
|
||||
|
||||
//Register event listeners
|
||||
getServer().getPluginManager().registerEvents(new StorageListener(),this);
|
||||
getServer().getPluginManager().registerEvents(new InventoryListener(),this);
|
||||
getServer().getPluginManager().registerEvents(new HopperListener(),this);
|
||||
getServer().getPluginManager().registerEvents(new WorldListener(),this);
|
||||
getLogger().info("Chests++ Successfully Loaded Config and Recipes");
|
||||
},1);
|
||||
}
|
||||
|
@ -3,10 +3,6 @@ package com.jamesdpeters.minecraft.chests.listeners;
|
||||
import com.jamesdpeters.minecraft.chests.ChestsPlusPlus;
|
||||
import com.jamesdpeters.minecraft.chests.misc.Utils;
|
||||
import com.jamesdpeters.minecraft.chests.serialize.Config;
|
||||
import com.jamesdpeters.minecraft.chests.serialize.ConfigStorage;
|
||||
import com.jamesdpeters.minecraft.chests.serialize.LocationInfo;
|
||||
import com.jamesdpeters.minecraft.chests.storage.abstracts.AbstractStorage;
|
||||
import com.jamesdpeters.minecraft.chests.storage.abstracts.StorageType;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
@ -14,8 +10,6 @@ import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldSaveEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class WorldListener implements Listener {
|
||||
|
||||
private static boolean justSaved = false;
|
||||
@ -47,7 +41,7 @@ public class WorldListener implements Listener {
|
||||
storageType.getStorageMap().values().forEach(stringHashMap -> {
|
||||
stringHashMap.values().forEach(o -> {
|
||||
o.getLocations().forEach(locationInfo -> {
|
||||
if(locationInfo != null && locationInfo.getSignLocation() != null && locationInfo.getSignLocation().getChunk().equals(event.getChunk())){
|
||||
if(locationInfo != null && locationInfo.getSignLocation() != null && Utils.isLocationInChunk(locationInfo.getSignLocation(),event.getChunk())) {
|
||||
o.updateClient(locationInfo);
|
||||
}
|
||||
});
|
||||
|
@ -262,12 +262,20 @@ public class Utils {
|
||||
return location.getWorld() != null && location.getWorld().isChunkLoaded(chunkX, chunkZ);
|
||||
}
|
||||
|
||||
public static boolean isLocationInChunk(Location location, Chunk chunk){
|
||||
int chunkX = location.getBlockX() >> 4;
|
||||
int chunkZ = location.getBlockZ() >> 4;
|
||||
return (chunkX == chunk.getX()) && (chunkZ == chunk.getZ());
|
||||
}
|
||||
|
||||
public static Collection<Entity> getPlayersInViewDistance(Location location){
|
||||
if(location.getWorld() == null) return null;
|
||||
return location.getWorld().getNearbyEntities(location, Bukkit.getViewDistance()*16, 256, Bukkit.getViewDistance()*16, entity -> entity instanceof Player);
|
||||
}
|
||||
|
||||
public static boolean isLocationInViewDistance(Player player, Location location){
|
||||
if(location == null) return false;
|
||||
if(!player.getWorld().equals(location.getWorld())) return false;
|
||||
Location delta = player.getLocation().subtract(location);
|
||||
return (delta.getX() <= Bukkit.getViewDistance()*16) && (delta.getZ() <= Bukkit.getViewDistance()*16);
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
List<LocationInfo> locationInfos = locationInfoList.stream().filter(locationInfo -> locationInfo.isInWorld(player)).collect(Collectors.toList()); // Create a utility method for this
|
||||
locationInfos.forEach(locationInfo -> {
|
||||
if (Utils.isLocationInViewDistance(player, locationInfo.getSignLocation())) {
|
||||
if (Utils.isLocationInViewDistance(player, locationInfo.getSignLocation()) && Utils.isLocationChunkLoaded(locationInfo.getSignLocation())) {
|
||||
if(displayItem != null) player.sendBlockChange(locationInfo.getSignLocation(), air);
|
||||
}
|
||||
});
|
||||
@ -513,8 +513,6 @@ public abstract class AbstractStorage implements ConfigurationSerializable {
|
||||
EulerAngle angle = isTool ? TOOL_ITEM_POSE : (isBlock ? BLOCK_POSE : STANDARD_ITEM_POSE);
|
||||
stand.setRightArmPose(angle);
|
||||
|
||||
// stand.setArms(true);
|
||||
|
||||
//Store value of 1 in armour stand to indicate it belongs to this plugin.
|
||||
stand.getPersistentDataContainer().set(Values.PluginKey, PersistentDataType.INTEGER, 1);
|
||||
return stand;
|
||||
|
Loading…
Reference in New Issue
Block a user