mirror of
https://github.com/kaboomserver/extras.git
synced 2025-02-11 11:40:19 +00:00
Ugly hotfix for liquid freezes
This commit is contained in:
parent
3d67c5aa34
commit
192be7c779
5 changed files with 47 additions and 16 deletions
|
@ -596,7 +596,7 @@ public class Main extends JavaPlugin {
|
|||
this.getCommand("username").setExecutor(new CommandUsername(this));
|
||||
|
||||
/* Block-related modules */
|
||||
this.getServer().getPluginManager().registerEvents(new BlockCheck(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new BlockCheck(this), this);
|
||||
/*new TileEntityCheck(this).runTaskTimerAsynchronously(this, 0, 400);*/
|
||||
this.getServer().getPluginManager().registerEvents(new BlockPhysics(this), this);
|
||||
|
||||
|
|
|
@ -12,6 +12,11 @@ import org.bukkit.event.block.SignChangeEvent;
|
|||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
|
||||
class BlockCheck implements Listener {
|
||||
private Main main;
|
||||
public BlockCheck(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (event.getItemInHand().toString().length() > 3019) {
|
||||
|
@ -26,12 +31,20 @@ class BlockCheck implements Listener {
|
|||
}
|
||||
|
||||
@EventHandler
|
||||
void onChunkLoad(ChunkLoadEvent event) {
|
||||
void onChunkLoad(final ChunkLoadEvent event) {
|
||||
if (!event.isNewChunk()) {
|
||||
for (BlockState block : event.getChunk().getTileEntities()) {
|
||||
if (block instanceof CommandBlock) {
|
||||
block.update();
|
||||
try {
|
||||
for (BlockState block : event.getChunk().getTileEntities()) {
|
||||
if (block instanceof CommandBlock) {
|
||||
block.update();
|
||||
}
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
event.getChunk().getWorld().regenerateChunk(
|
||||
event.getChunk().getX(),
|
||||
event.getChunk().getZ()
|
||||
);
|
||||
System.out.println("REGEN");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,10 @@ class BlockPhysics implements Listener {
|
|||
} else if (material == Material.WATER ||
|
||||
material == Material.LAVA) {
|
||||
final Block block = event.getBlock();
|
||||
final Levelled levelledBlock = (Levelled) block.getBlockData();
|
||||
try {
|
||||
final Levelled levelledBlock = (Levelled) block.getBlockData();
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
|
||||
if (levelledBlock.getLevel() <= 7) {
|
||||
if (block.getRelative(BlockFace.UP).getType() != material) {
|
||||
|
@ -65,7 +68,8 @@ class BlockPhysics implements Listener {
|
|||
|
||||
for (BlockFace face : main.faces) {
|
||||
if (block.getRelative(face).getType() == Material.AIR ||
|
||||
block.getRelative(face).getType() == Material.CAVE_AIR) {
|
||||
block.getRelative(face).getType() == Material.CAVE_AIR ||
|
||||
block.getRelative(BlockFace.UP).getType() == Material.WATER) {
|
||||
cancel = false;
|
||||
}
|
||||
|
||||
|
@ -84,6 +88,8 @@ class BlockPhysics implements Listener {
|
|||
} else if (cancel) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (block.getRelative(BlockFace.DOWN).getType() == material) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} else if (main.nonSolidWallMountedBlockList.contains(material)) {
|
||||
|
|
|
@ -40,9 +40,6 @@ class PlayerConnection implements Listener {
|
|||
|
||||
@EventHandler
|
||||
void onAsyncPlayerPreLogin(AsyncPlayerPreLoginEvent event) {
|
||||
main.commandMillisList.put(event.getUniqueId(), System.currentTimeMillis());
|
||||
main.interactMillisList.put(event.getUniqueId(), System.currentTimeMillis());
|
||||
|
||||
try {
|
||||
final URL skinUrl = new URL("https://api.ashcon.app/mojang/v2/user/" + event.getName());
|
||||
final HttpsURLConnection skinConnection = (HttpsURLConnection) skinUrl.openConnection();
|
||||
|
@ -66,6 +63,20 @@ class PlayerConnection implements Listener {
|
|||
skinConnection.disconnect();
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
|
||||
for (final World world : Bukkit.getWorlds()) {
|
||||
for (final Chunk chunk : world.getLoadedChunks()) {
|
||||
try {
|
||||
chunk.getTileEntities(false);
|
||||
} catch (Exception exception) {
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
world.regenerateChunk(chunk.getX(), chunk.getZ());
|
||||
}
|
||||
}.runTask(main);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -73,13 +84,13 @@ class PlayerConnection implements Listener {
|
|||
main.commandMillisList.remove(event.getPlayerUniqueId());
|
||||
main.interactMillisList.remove(event.getPlayerUniqueId());
|
||||
|
||||
new BukkitRunnable() {
|
||||
/*new BukkitRunnable() {
|
||||
public void run() {
|
||||
for (final World world : Bukkit.getWorlds()) {
|
||||
for (final Chunk chunk : world.getLoadedChunks()) {
|
||||
try {
|
||||
chunk.getTileEntities();
|
||||
} catch (Exception e) {
|
||||
chunk.getTileEntities(false);
|
||||
} catch (Exception exception) {
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
world.regenerateChunk(chunk.getX(), chunk.getZ());
|
||||
|
@ -89,7 +100,7 @@ class PlayerConnection implements Listener {
|
|||
}
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(main);
|
||||
}.runTaskAsynchronously(main);*/
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -131,6 +142,9 @@ class PlayerConnection implements Listener {
|
|||
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
main.commandMillisList.put(player.getUniqueId(), System.currentTimeMillis());
|
||||
main.interactMillisList.put(player.getUniqueId(), System.currentTimeMillis());
|
||||
|
||||
event.allow();
|
||||
player.setOp(true);
|
||||
try {
|
||||
|
|
|
@ -10,8 +10,6 @@ import org.bukkit.event.Listener;
|
|||
|
||||
import org.bukkit.event.server.ServerCommandEvent;
|
||||
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
|
||||
class ServerCommand implements Listener {
|
||||
private Main main;
|
||||
public ServerCommand(Main main) {
|
||||
|
|
Loading…
Reference in a new issue