Skip to content

Commit

Permalink
Added debug to nether portals and fixed chunk loading for levels.
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Oct 1, 2017
1 parent 43c0702 commit 1722382
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
15 changes: 11 additions & 4 deletions src/com/wasteofplastic/askyblock/LevelCalcByChunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import org.apache.commons.lang.math.NumberUtils;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
Expand Down Expand Up @@ -125,11 +126,17 @@ public LevelCalcByChunk(final ASkyBlock plugin, final UUID targetPlayer, final C
Set<ChunkSnapshot> chunkSnapshot = new HashSet<ChunkSnapshot>();
for (int x = island.getMinProtectedX(); x < (island.getMinProtectedX() + island.getProtectionSize() + 16); x += 16) {
for (int z = island.getMinProtectedZ(); z < (island.getMinProtectedZ() + island.getProtectionSize() + 16); z += 16) {
if (!world.getBlockAt(x, 0, z).getChunk().isLoaded()) {
world.getBlockAt(x, 0, z).getChunk().load();
chunkSnapshot.add(world.getBlockAt(x, 0, z).getChunk().getChunkSnapshot());
world.getBlockAt(x, 0, z).getChunk().unload();
if (!world.isChunkLoaded((int)((double)x/16), (int)((double)z/16))) {
//plugin.getLogger().info("DEBUG: chunk is not loaded");
// If the chunk isn't already generated, don't try and generate it
if (world.loadChunk((int)((double)x/16), (int)((double)z/16), false)) {
//plugin.getLogger().info("DEBUG: chunk loaded");
Chunk chunk = world.getChunkAt((int)((double)x/16), (int)((double)z/16));
chunkSnapshot.add(chunk.getChunkSnapshot());
//plugin.getLogger().info("DEBUG: unload = " + chunk.unload(false));
}
} else {
//plugin.getLogger().info("DEBUG: chunk is loaded");
chunkSnapshot.add(world.getBlockAt(x, 0, z).getChunk().getChunkSnapshot());
}
//plugin.getLogger().info("DEBUG: getting chunk at " + x + ", " + z);
Expand Down
17 changes: 16 additions & 1 deletion src/com/wasteofplastic/askyblock/listeners/NetherPortals.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void onEntityPortal(EntityPortalEvent event) {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerPortal(PlayerPortalEvent event) {
if (DEBUG)
plugin.getLogger().info("Player portal event - reason =" + event.getCause());
plugin.getLogger().info("DEBUG: Player portal event - reason = " + event.getCause());
UUID playerUUID = event.getPlayer().getUniqueId();
// If the nether is disabled then quit immediately
if (!Settings.createNether || ASkyBlock.getNetherWorld() == null) {
Expand All @@ -138,12 +138,27 @@ public void onPlayerPortal(PlayerPortalEvent event) {
if ((island == null && !Settings.defaultWorldSettings.get(SettingsFlag.PORTAL))
|| (island != null && !(island.getIgsFlag(SettingsFlag.PORTAL) || island.getMembers().contains(event.getPlayer().getUniqueId())))) {
// Portals use is not allowed
if (DEBUG)
plugin.getLogger().info("DEBUG: portal use not allowed");
if (!event.getPlayer().isOp() && !VaultHelper.checkPerm(event.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) {
Util.sendMessage(event.getPlayer(), ChatColor.RED + plugin.myLocale(event.getPlayer().getUniqueId()).islandProtected);
event.setCancelled(true);
return;
}
}
if (DEBUG) {
plugin.getLogger().info("DEBUG: portal use allowed");
if (island != null) {
plugin.getLogger().info("DEBUG: island is not null, portal flag is " + island.getIgsFlag(SettingsFlag.PORTAL));
plugin.getLogger().info("DEBUG: player is a member? " + island.getMembers().contains(event.getPlayer().getUniqueId()));
plugin.getLogger().info("DEBUG: player is op? " + event.getPlayer().isOp());
plugin.getLogger().info("DEBUG: player has bypass perm? " + VaultHelper.checkPerm(event.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect"));
} else {
plugin.getLogger().info("DEBUG: island is null, default portal flag is " + Settings.defaultWorldSettings.get(SettingsFlag.PORTAL));
plugin.getLogger().info("DEBUG: player is op? " + event.getPlayer().isOp());
plugin.getLogger().info("DEBUG: player has bypass perm? " + VaultHelper.checkPerm(event.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect"));
}
}
// Determine what portal it is
switch (event.getCause()) {
case END_PORTAL:
Expand Down

0 comments on commit 1722382

Please sign in to comment.