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));
|
this.getCommand("username").setExecutor(new CommandUsername(this));
|
||||||
|
|
||||||
/* Block-related modules */
|
/* 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);*/
|
/*new TileEntityCheck(this).runTaskTimerAsynchronously(this, 0, 400);*/
|
||||||
this.getServer().getPluginManager().registerEvents(new BlockPhysics(this), this);
|
this.getServer().getPluginManager().registerEvents(new BlockPhysics(this), this);
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,11 @@ import org.bukkit.event.block.SignChangeEvent;
|
||||||
import org.bukkit.event.world.ChunkLoadEvent;
|
import org.bukkit.event.world.ChunkLoadEvent;
|
||||||
|
|
||||||
class BlockCheck implements Listener {
|
class BlockCheck implements Listener {
|
||||||
|
private Main main;
|
||||||
|
public BlockCheck(Main main) {
|
||||||
|
this.main = main;
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onBlockPlace(BlockPlaceEvent event) {
|
void onBlockPlace(BlockPlaceEvent event) {
|
||||||
if (event.getItemInHand().toString().length() > 3019) {
|
if (event.getItemInHand().toString().length() > 3019) {
|
||||||
|
@ -26,13 +31,21 @@ class BlockCheck implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onChunkLoad(ChunkLoadEvent event) {
|
void onChunkLoad(final ChunkLoadEvent event) {
|
||||||
if (!event.isNewChunk()) {
|
if (!event.isNewChunk()) {
|
||||||
|
try {
|
||||||
for (BlockState block : event.getChunk().getTileEntities()) {
|
for (BlockState block : event.getChunk().getTileEntities()) {
|
||||||
if (block instanceof CommandBlock) {
|
if (block instanceof CommandBlock) {
|
||||||
block.update();
|
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 ||
|
} else if (material == Material.WATER ||
|
||||||
material == Material.LAVA) {
|
material == Material.LAVA) {
|
||||||
final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
|
try {
|
||||||
final Levelled levelledBlock = (Levelled) block.getBlockData();
|
final Levelled levelledBlock = (Levelled) block.getBlockData();
|
||||||
|
} catch (Exception exception) {
|
||||||
|
}
|
||||||
|
|
||||||
if (levelledBlock.getLevel() <= 7) {
|
if (levelledBlock.getLevel() <= 7) {
|
||||||
if (block.getRelative(BlockFace.UP).getType() != material) {
|
if (block.getRelative(BlockFace.UP).getType() != material) {
|
||||||
|
@ -65,7 +68,8 @@ class BlockPhysics implements Listener {
|
||||||
|
|
||||||
for (BlockFace face : main.faces) {
|
for (BlockFace face : main.faces) {
|
||||||
if (block.getRelative(face).getType() == Material.AIR ||
|
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;
|
cancel = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +88,8 @@ class BlockPhysics implements Listener {
|
||||||
} else if (cancel) {
|
} else if (cancel) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
} else if (block.getRelative(BlockFace.DOWN).getType() == material) {
|
||||||
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (main.nonSolidWallMountedBlockList.contains(material)) {
|
} else if (main.nonSolidWallMountedBlockList.contains(material)) {
|
||||||
|
|
|
@ -40,9 +40,6 @@ class PlayerConnection implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onAsyncPlayerPreLogin(AsyncPlayerPreLoginEvent event) {
|
void onAsyncPlayerPreLogin(AsyncPlayerPreLoginEvent event) {
|
||||||
main.commandMillisList.put(event.getUniqueId(), System.currentTimeMillis());
|
|
||||||
main.interactMillisList.put(event.getUniqueId(), System.currentTimeMillis());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final URL skinUrl = new URL("https://api.ashcon.app/mojang/v2/user/" + event.getName());
|
final URL skinUrl = new URL("https://api.ashcon.app/mojang/v2/user/" + event.getName());
|
||||||
final HttpsURLConnection skinConnection = (HttpsURLConnection) skinUrl.openConnection();
|
final HttpsURLConnection skinConnection = (HttpsURLConnection) skinUrl.openConnection();
|
||||||
|
@ -66,20 +63,12 @@ class PlayerConnection implements Listener {
|
||||||
skinConnection.disconnect();
|
skinConnection.disconnect();
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
void onPlayerConnectionClose(final PlayerConnectionCloseEvent event) {
|
|
||||||
main.commandMillisList.remove(event.getPlayerUniqueId());
|
|
||||||
main.interactMillisList.remove(event.getPlayerUniqueId());
|
|
||||||
|
|
||||||
new BukkitRunnable() {
|
|
||||||
public void run() {
|
|
||||||
for (final World world : Bukkit.getWorlds()) {
|
for (final World world : Bukkit.getWorlds()) {
|
||||||
for (final Chunk chunk : world.getLoadedChunks()) {
|
for (final Chunk chunk : world.getLoadedChunks()) {
|
||||||
try {
|
try {
|
||||||
chunk.getTileEntities();
|
chunk.getTileEntities(false);
|
||||||
} catch (Exception e) {
|
} catch (Exception exception) {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
world.regenerateChunk(chunk.getX(), chunk.getZ());
|
world.regenerateChunk(chunk.getX(), chunk.getZ());
|
||||||
|
@ -89,7 +78,29 @@ class PlayerConnection implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskAsynchronously(main);
|
|
||||||
|
@EventHandler
|
||||||
|
void onPlayerConnectionClose(final PlayerConnectionCloseEvent event) {
|
||||||
|
main.commandMillisList.remove(event.getPlayerUniqueId());
|
||||||
|
main.interactMillisList.remove(event.getPlayerUniqueId());
|
||||||
|
|
||||||
|
/*new BukkitRunnable() {
|
||||||
|
public void run() {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskAsynchronously(main);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -131,6 +142,9 @@ class PlayerConnection implements Listener {
|
||||||
|
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
|
main.commandMillisList.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
|
main.interactMillisList.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
|
|
||||||
event.allow();
|
event.allow();
|
||||||
player.setOp(true);
|
player.setOp(true);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -10,8 +10,6 @@ import org.bukkit.event.Listener;
|
||||||
|
|
||||||
import org.bukkit.event.server.ServerCommandEvent;
|
import org.bukkit.event.server.ServerCommandEvent;
|
||||||
|
|
||||||
import org.bukkit.event.world.ChunkLoadEvent;
|
|
||||||
|
|
||||||
class ServerCommand implements Listener {
|
class ServerCommand implements Listener {
|
||||||
private Main main;
|
private Main main;
|
||||||
public ServerCommand(Main main) {
|
public ServerCommand(Main main) {
|
||||||
|
|
Loading…
Reference in a new issue