End portal frame stackables fixes, limit npe fix, 1.9 fix, level improv

This commit is contained in:
Esophose 2019-06-29 00:15:41 -06:00
parent a1dc9fa062
commit f155f3e694
6 changed files with 71 additions and 43 deletions

View File

@ -258,7 +258,7 @@ public class IslandManager {
.setBiome(island, biome), 20L); .setBiome(island, biome), 20L);
// Recalculate island level after 5 seconds // Recalculate island level after 5 seconds
if (fileManager.getConfig(new File(this.skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getBoolean("Island.Levelling.ScanAutomatically")) { if (fileManager.getConfig(new File(this.skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Levelling.ScanAutomatically")) {
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> skyblock.getLevellingManager().calculatePoints(null, island), 100L); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> skyblock.getLevellingManager().calculatePoints(null, island), 100L);
} }
@ -815,7 +815,7 @@ public class IslandManager {
pasteStructure(island, islandWorld); pasteStructure(island, islandWorld);
// Recalculate island level after 5 seconds // Recalculate island level after 5 seconds
if (fileManager.getConfig(new File(this.skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getBoolean("Island.Levelling.ScanAutomatically")) { if (fileManager.getConfig(new File(this.skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Levelling.ScanAutomatically")) {
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> skyblock.getLevellingManager().calculatePoints(null, island), 100L); Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> skyblock.getLevellingManager().calculatePoints(null, island), 100L);
} }
} }

View File

@ -94,7 +94,8 @@ public class Chunk {
int x = chunkPosition.getX(); int x = chunkPosition.getX();
int z = chunkPosition.getZ(); int z = chunkPosition.getZ();
if (!world.isChunkLoaded(x, z)) { if (!world.isChunkLoaded(x, z)) {
world.loadChunk(x, z); // Try to load the chunk, but don't generate anything and ignore if we couldn't get it
if (world.loadChunk(x, z, false)) {
org.bukkit.Chunk chunk = world.getChunkAt(x, z); org.bukkit.Chunk chunk = world.getChunkAt(x, z);
ChunkSnapshot chunkSnapshot = chunk.getChunkSnapshot(); ChunkSnapshot chunkSnapshot = chunk.getChunkSnapshot();
if (isWildStackerEnabled) { if (isWildStackerEnabled) {
@ -103,6 +104,7 @@ public class Chunk {
this.chunkSnapshots.add(new ChunkSnapshotWrapper(chunkSnapshot)); this.chunkSnapshots.add(new ChunkSnapshotWrapper(chunkSnapshot));
} }
world.unloadChunk(x, z); world.unloadChunk(x, z);
}
} else { } else {
org.bukkit.Chunk chunk = world.getChunkAt(x, z); org.bukkit.Chunk chunk = world.getChunkAt(x, z);
ChunkSnapshot chunkSnapshot = chunk.getChunkSnapshot(); ChunkSnapshot chunkSnapshot = chunk.getChunkSnapshot();

View File

@ -54,12 +54,17 @@ public class LimitManager {
* @return The max number of the type of block the player can place * @return The max number of the type of block the player can place
*/ */
public long getBlockLimit(Player player, Block block) { public long getBlockLimit(Player player, Block block) {
if (player == null || block == null)
return -1;
if (player.hasPermission("fabledskyblock.limit.block.*")) if (player.hasPermission("fabledskyblock.limit.block.*"))
return -1; return -1;
long limit = -1;
Materials material = Materials.getMaterials(block.getType(), block.getData()); Materials material = Materials.getMaterials(block.getType(), block.getData());
if (material == null)
return -1;
long limit = -1;
if (this.blockLimits.containsKey(material)) if (this.blockLimits.containsKey(material))
limit = Math.max(limit, this.blockLimits.get(material)); limit = Math.max(limit, this.blockLimits.get(material));

View File

@ -4,14 +4,18 @@ import me.goodandevil.skyblock.SkyBlock;
import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.config.FileManager.Config;
import me.goodandevil.skyblock.generator.Generator; import me.goodandevil.skyblock.generator.Generator;
import me.goodandevil.skyblock.generator.GeneratorManager; import me.goodandevil.skyblock.generator.GeneratorManager;
import me.goodandevil.skyblock.island.*; import me.goodandevil.skyblock.island.Island;
import me.goodandevil.skyblock.island.IslandEnvironment;
import me.goodandevil.skyblock.island.IslandLevel;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.IslandRole;
import me.goodandevil.skyblock.island.IslandWorld;
import me.goodandevil.skyblock.levelling.LevellingManager; import me.goodandevil.skyblock.levelling.LevellingManager;
import me.goodandevil.skyblock.limit.LimitManager; import me.goodandevil.skyblock.limit.LimitManager;
import me.goodandevil.skyblock.stackable.Stackable; import me.goodandevil.skyblock.stackable.Stackable;
import me.goodandevil.skyblock.stackable.StackableManager; import me.goodandevil.skyblock.stackable.StackableManager;
import me.goodandevil.skyblock.upgrade.Upgrade; import me.goodandevil.skyblock.upgrade.Upgrade;
import me.goodandevil.skyblock.utils.NumberUtil; import me.goodandevil.skyblock.utils.NumberUtil;
import me.goodandevil.skyblock.utils.StringUtil;
import me.goodandevil.skyblock.utils.version.Materials; import me.goodandevil.skyblock.utils.version.Materials;
import me.goodandevil.skyblock.utils.version.NMSUtil; import me.goodandevil.skyblock.utils.version.NMSUtil;
import me.goodandevil.skyblock.utils.version.Sounds; import me.goodandevil.skyblock.utils.version.Sounds;
@ -30,8 +34,17 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.*; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.EntityCreatePortalEvent; import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockDispenseEvent;
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockGrowEvent;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.world.PortalCreateEvent; import org.bukkit.event.world.PortalCreateEvent;
import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -39,7 +52,11 @@ import org.bukkit.material.Crops;
import java.io.File; import java.io.File;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.*; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class Block implements Listener { public class Block implements Listener {

View File

@ -575,7 +575,7 @@ public class Entity implements Listener {
return; return;
} }
if (NMSUtil.getVersionNumber() > 8) { if (NMSUtil.getVersionNumber() > 9) {
if (livingEntity instanceof Donkey || livingEntity instanceof Mule || livingEntity instanceof ElderGuardian) if (livingEntity instanceof Donkey || livingEntity instanceof Mule || livingEntity instanceof ElderGuardian)
return; return;
} }

View File

@ -473,31 +473,8 @@ public class Interact implements Listener {
.getFileConfiguration().getBoolean("Island.Block.EndFrame.Enable") .getFileConfiguration().getBoolean("Island.Block.EndFrame.Enable")
&& islandManager.hasPermission(player, block.getLocation(), "Destroy")) { && islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
if (Bukkit.getPluginManager().isPluginEnabled("EpicAnchors")) { if (NMSUtil.getVersionNumber() > 8 && event.getHand() == EquipmentSlot.OFF_HAND)
if (com.songoda.epicanchors.EpicAnchorsPlugin.getInstance().getAnchorManager().getAnchor(block.getLocation()) != null) {
event.setCancelled(true);
return; return;
}
}
ItemStack is = event.getPlayer().getItemInHand();
if (is == null || is.getType() == Material.AIR) {
block.setType(Material.AIR);
player.getInventory().addItem(new ItemStack(Materials.END_PORTAL_FRAME.parseMaterial(), 1));
player.updateInventory();
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 10.0F, 10.0F);
event.setCancelled(true);
return;
}
}
} else if (block.getType() == Material.TNT) {
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"))
.getFileConfiguration().getBoolean("Island.Block.EndFrame.Enable")
&& islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
if (Bukkit.getPluginManager().isPluginEnabled("EpicAnchors")) { if (Bukkit.getPluginManager().isPluginEnabled("EpicAnchors")) {
if (com.songoda.epicanchors.EpicAnchorsPlugin.getInstance().getAnchorManager().getAnchor(block.getLocation()) != null) { if (com.songoda.epicanchors.EpicAnchorsPlugin.getInstance().getAnchorManager().getAnchor(block.getLocation()) != null) {
@ -509,14 +486,41 @@ public class Interact implements Listener {
ItemStack is = event.getPlayer().getItemInHand(); ItemStack is = event.getPlayer().getItemInHand();
if (is == null || is.getType() == Material.AIR) { if (is == null || is.getType() == Material.AIR) {
if (stackableManager != null && stackableManager.isStacked(block.getLocation())) {
Stackable stackable = stackableManager.getStack(block.getLocation(), Materials.END_PORTAL_FRAME.parseMaterial());
stackable.takeOne();
if (stackable.getSize() <= 1) {
stackableManager.removeStack(stackable);
}
} else {
block.setType(Material.AIR); block.setType(Material.AIR);
}
player.getInventory().addItem(new ItemStack(Materials.END_PORTAL_FRAME.parseMaterial(), 1)); player.getInventory().addItem(new ItemStack(Materials.END_PORTAL_FRAME.parseMaterial(), 1));
player.updateInventory(); player.updateInventory();
FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
Materials materials = Materials.END_PORTAL_FRAME;
IslandLevel level = island.getLevel();
if (level.hasMaterial(materials.name())) {
long materialAmount = level.getMaterialAmount(materials.name());
if (materialAmount - 1 <= 0) {
level.removeMaterial(materials.name());
} else {
level.setMaterialAmount(materials.name(), materialAmount - 1);
}
}
}
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 10.0F, 10.0F); soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 10.0F, 10.0F);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} }