Merge branch 'development'

This commit is contained in:
Brianna 2020-09-23 10:46:14 -05:00
commit 0f47bc6fd8
39 changed files with 383 additions and 409 deletions

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.songoda</groupId>
<artifactId>skyblock</artifactId>
<version>2.3.9</version>
<version>2.3.10</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -229,7 +229,7 @@
<dependency>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore</artifactId>
<version>LATEST</version>
<version>2.4.8</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@ -26,6 +26,8 @@ import com.songoda.skyblock.leaderboard.LeaderboardManager;
import com.songoda.skyblock.levelling.IslandLevelManager;
import com.songoda.skyblock.limit.LimitationInstanceHandler;
import com.songoda.skyblock.listeners.*;
import com.songoda.skyblock.listeners.hooks.EpicSpawners;
import com.songoda.skyblock.listeners.hooks.UltimateStacker;
import com.songoda.skyblock.localization.LocalizationManager;
import com.songoda.skyblock.menus.admin.Creator;
import com.songoda.skyblock.menus.admin.Generator;
@ -224,30 +226,30 @@ public class SkyBlock extends SongodaPlugin {
mobNetherWaterTask = MobNetherWaterTask.startTask(this);
PluginManager pluginManager = getServer().getPluginManager();
pluginManager.registerEvents(new Join(this), this);
pluginManager.registerEvents(new Quit(this), this);
pluginManager.registerEvents(new Block(this), this);
pluginManager.registerEvents(new Interact(this), this);
pluginManager.registerEvents(new Entity(this), this);
pluginManager.registerEvents(new Bucket(this), this);
pluginManager.registerEvents(new Projectile(this), this);
pluginManager.registerEvents(new Inventory(this), this);
pluginManager.registerEvents(new Item(this), this);
pluginManager.registerEvents(new Teleport(this), this);
pluginManager.registerEvents(new Portal(this), this);
pluginManager.registerEvents(new Move(this), this);
pluginManager.registerEvents(new Death(this), this);
pluginManager.registerEvents(new Respawn(this), this);
pluginManager.registerEvents(new Chat(this), this);
pluginManager.registerEvents(new Spawner(this), this);
pluginManager.registerEvents(new Food(this), this);
pluginManager.registerEvents(new Grow(this), this);
pluginManager.registerEvents(new Piston(this), this);
pluginManager.registerEvents(new FallBreak(this), this);
pluginManager.registerEvents(new World(this), this);
pluginManager.registerEvents(new JoinListeners(this), this);
pluginManager.registerEvents(new QuitListeners(this), this);
pluginManager.registerEvents(new BlockListeners(this), this);
pluginManager.registerEvents(new InteractListeners(this), this);
pluginManager.registerEvents(new EntityListeners(this), this);
pluginManager.registerEvents(new BucketListeners(this), this);
pluginManager.registerEvents(new ProjectileListeners(this), this);
pluginManager.registerEvents(new InventoryListeners(this), this);
pluginManager.registerEvents(new ItemListeners(this), this);
pluginManager.registerEvents(new TeleportListeners(this), this);
pluginManager.registerEvents(new PortalListeners(this), this);
pluginManager.registerEvents(new MoveListeners(this), this);
pluginManager.registerEvents(new DeathListeners(this), this);
pluginManager.registerEvents(new RespawnListeners(this), this);
pluginManager.registerEvents(new ChatListeners(this), this);
pluginManager.registerEvents(new SpawnerListeners(this), this);
pluginManager.registerEvents(new FoodListeners(this), this);
pluginManager.registerEvents(new GrowListeners(this), this);
pluginManager.registerEvents(new PistonListeners(this), this);
pluginManager.registerEvents(new FallBreakListeners(this), this);
pluginManager.registerEvents(new WorldListeners(this), this);
if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
pluginManager.registerEvents(new Sponge(this), this);
pluginManager.registerEvents(new SpongeListeners(this), this);
}
if (pluginManager.isPluginEnabled("EpicSpawners"))

View File

@ -1,5 +1,6 @@
package com.songoda.skyblock.bank;
import com.songoda.core.hooks.EconomyManager;
import com.songoda.core.hooks.economies.Economy;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
@ -73,7 +74,7 @@ public class BankManager {
}
}
public List<String> getBalanceLore(Player player) {
public List<String> getBalanceLore(Player player) {;
Economy economy = plugin.getEconomyManager().getEconomy();
List<String> result = new ArrayList<>();
@ -82,8 +83,8 @@ public class BankManager {
result.add("If this is null then its a easy to fix bug: "+island.toString());
if (island != null) {
result.clear();
result.add(player.getDisplayName()+"'s balance is "+economy.formatEconomy(economy.getBalance(player)));
result.add(player.getDisplayName()+"'s island has "+ economy.formatEconomy(island.getBankBalance()));
result.add(player.getDisplayName()+"'s balance is "+ EconomyManager.formatEconomy(economy.getBalance(player)));
result.add(player.getDisplayName()+"'s island has "+ EconomyManager.formatEconomy(island.getBankBalance()));
}
return result;
}

View File

@ -21,7 +21,12 @@ import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.*;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.command.TabCompleter;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
@ -145,16 +150,24 @@ public class CommandManager implements CommandExecutor, TabCompleter {
sendConsoleHelpCommands(sender);
} else {
String commandToExecute;
String defaultCommand;
if (plugin.getIslandManager().getIsland(player) == null) {
commandToExecute = mainConfig.getString("Command.Island.Aliases.NoIsland", "island create");
defaultCommand = "island create";
commandToExecute = mainConfig.getString("Command.Island.Aliases.NoIsland", defaultCommand);
} else {
commandToExecute = mainConfig.getString("Command.Island.Aliases.IslandOwned", "island controlpanel");
defaultCommand = "island controlpanel";
commandToExecute = mainConfig.getString("Command.Island.Aliases.IslandOwned", defaultCommand);
}
if(commandToExecute.startsWith("/")) {
if (commandToExecute.trim().equalsIgnoreCase("island") || commandToExecute.trim().equalsIgnoreCase("is")) {
commandToExecute = defaultCommand;
Bukkit.getLogger().warning("Cannot redirect /island to /island or /is, would result in an endless loop. Using the default.");
}
if (commandToExecute.startsWith("/")) {
commandToExecute = commandToExecute.substring(1);
}
String finalCommandToExecute = commandToExecute;
Bukkit.getServer().getScheduler().runTask(plugin, () ->
Bukkit.getServer().dispatchCommand(sender,
@ -408,7 +421,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
if (nextEndIndex <= -7) {
plugin.getMessageManager().sendMessage(player, configLoad.getString("Command.Island.Help.Page.Message"));
plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return;
}

View File

@ -1,6 +1,7 @@
package com.songoda.skyblock.command.commands.admin;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.hooks.EconomyManager;
import com.songoda.core.hooks.economies.Economy;
import com.songoda.skyblock.command.SubCommand;
import com.songoda.skyblock.config.FileManager;
@ -53,15 +54,15 @@ public class AdminBank extends SubCommand {
switch (args[0].toLowerCase()) {
case "balance":
if (args.length >= 3) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + economy.formatEconomy(economy.getBalance(Bukkit.getOfflinePlayer(island.getOwnerUUID())))));
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(economy.getBalance(Bukkit.getOfflinePlayer(island.getOwnerUUID())))));
} else {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + economy.formatEconomy(economy.getBalance(Bukkit.getOfflinePlayer(args[1])))));
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(economy.getBalance(Bukkit.getOfflinePlayer(args[1])))));
}
return;
case "deposit":
if (args.length >= 3) {
islandManager.getIslandByOwner(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).addToBank(Double.parseDouble(args[2]));
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",economy.formatEconomy(Double.parseDouble(args[2]))));
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2]))));
}else {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
}
@ -69,7 +70,7 @@ public class AdminBank extends SubCommand {
case "withdraw":
if (args.length >= 3) {
islandManager.getIslandByOwner(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).removeFromBank(Double.parseDouble(args[2]));
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%",args[1]).replace("%ammount%",economy.formatEconomy(Double.parseDouble(args[2]))));
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2]))));
}else {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
}
@ -118,12 +119,12 @@ public class AdminBank extends SubCommand {
}
switch (args[0]) {
case "balance":
messageManager.sendMessage(sender,configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%",args[1]).replace("%bal%",""+ economy.formatEconomy(economy.getBalance(Bukkit.getOfflinePlayer(args[1])))));
messageManager.sendMessage(sender,configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%",args[1]).replace("%bal%",""+ EconomyManager.formatEconomy(economy.getBalance(Bukkit.getOfflinePlayer(args[1])))));
return;
case "deposit":
if (args.length >= 3) {
islandManager.getIslandByOwner(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).addToBank(Double.parseDouble(args[2]));
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",economy.formatEconomy(Double.parseDouble(args[2]))));
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2]))));
}else {
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
}
@ -131,7 +132,7 @@ public class AdminBank extends SubCommand {
case "withdraw":
if (args.length >= 3) {
islandManager.getIslandByOwner(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).removeFromBank(Double.parseDouble(args[2]));
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%",args[1]).replace("%ammount%",economy.formatEconomy(Double.parseDouble(args[2]))));
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2]))));
}else {
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
}

View File

@ -3,6 +3,7 @@ package com.songoda.skyblock.cooldown;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.List;
public class CooldownTask extends BukkitRunnable {
@ -20,7 +21,7 @@ public class CooldownTask extends BukkitRunnable {
if (cooldownPlayers == null) return;
for (CooldownPlayer cooldownPlayer : cooldownPlayers) {
for (CooldownPlayer cooldownPlayer : new ArrayList<>(cooldownPlayers)) {
Cooldown cooldown = cooldownPlayer.getCooldown();
cooldown.setTime(cooldown.getTime() - 1);
@ -29,7 +30,6 @@ public class CooldownTask extends BukkitRunnable {
cooldownManager.deletePlayer(cooldownType, Bukkit.getServer().getOfflinePlayer(cooldownPlayer.getUUID()));
}
}
}
}
}

View File

@ -463,7 +463,7 @@ public class Island {
}
public Biome getBiome() {
return CompatibleBiome.valueOf(plugin.getFileManager().getConfig(
return CompatibleBiome.getBiome(plugin.getFileManager().getConfig(
new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().getString("Biome.Type")).getBiome();
}

View File

@ -5,10 +5,14 @@ import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.generator.Generator;
import com.songoda.skyblock.generator.GeneratorManager;
import com.songoda.skyblock.island.*;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandEnvironment;
import com.songoda.skyblock.island.IslandLevel;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandRole;
import com.songoda.skyblock.island.IslandWorld;
import com.songoda.skyblock.levelling.IslandLevelManager;
import com.songoda.skyblock.limit.impl.BlockLimitation;
import com.songoda.skyblock.permission.PermissionManager;
@ -20,12 +24,16 @@ import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.utils.world.LocationUtil;
import com.songoda.skyblock.world.WorldManager;
import org.apache.commons.lang.WordUtils;
import org.bukkit.*;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -34,19 +42,26 @@ import org.bukkit.event.block.*;
import org.bukkit.event.world.PortalCreateEvent;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
public class Block implements Listener {
public class BlockListeners implements Listener {
private final SkyBlock plugin;
private final Set<Location> generatorWaitingLocs;
public Block(SkyBlock plugin) {
public BlockListeners(SkyBlock plugin) {
this.plugin = plugin;
this.generatorWaitingLocs = new HashSet<>();
}
@EventHandler(priority = EventPriority.LOW)
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
@ -76,7 +91,7 @@ public class Block implements Listener {
Stackable stackable = stackableManager.getStack(block.getLocation(), CompatibleMaterial.getMaterial(block));
if (stackable != null) {
CompatibleMaterial material = null;
if(ServerVersion.isServerVersion(ServerVersion.V1_8)) {
if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
switch (block.getType().toString().toUpperCase()) {
case "DIODE_BLOCK_OFF":
case "DIODE_BLOCK_ON":
@ -84,7 +99,7 @@ public class Block implements Listener {
break;
}
}
if(material == null) {
if (material == null) {
material = CompatibleMaterial.getMaterial(block);
}
byte data = block.getData();
@ -107,7 +122,7 @@ public class Block implements Listener {
droppedAmount = 1;
}
if(plugin.getCoreProtectAPI() != null) {
if (plugin.getCoreProtectAPI() != null) {
plugin.getCoreProtectAPI().logRemoval(player.getName(), block.getLocation(), material.getMaterial(), null);
}
@ -141,7 +156,7 @@ public class Block implements Listener {
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
if (LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main).clone().subtract(0.0D, 1.0D, 0.0D)) || LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Visitor).clone().subtract(0.0D, 1.0D, 0.0D))
if (LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main).clone().subtract(0.0D, 1.0D, 0.0D)) || LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Visitor).clone().subtract(0.0D, 1.0D, 0.0D))
|| LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
if (configLoad.getBoolean("Island.Spawn.Protection")) {
event.setCancelled(true);
@ -151,9 +166,9 @@ public class Block implements Listener {
}
if (event.isCancelled() || !configLoad.getBoolean("Island.Block.Level.Enable")) return;
CompatibleMaterial material = null;
if(ServerVersion.isServerVersion(ServerVersion.V1_8)) {
if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
switch (block.getType().toString().toUpperCase()) {
case "DIODE_BLOCK_OFF":
case "DIODE_BLOCK_ON":
@ -161,7 +176,7 @@ public class Block implements Listener {
break;
}
}
if(material == null) {
if (material == null) {
material = CompatibleMaterial.getMaterial(block);
}
@ -214,7 +229,7 @@ public class Block implements Listener {
Island island = islandManager.getIslandAtLocation(blockLoc);
// Check permissions.
if (!plugin.getPermissionManager().processPermission(event, player, island)){
if (!plugin.getPermissionManager().processPermission(event, player, island)) {
return;
}
@ -222,11 +237,11 @@ public class Block implements Listener {
event.setCancelled(true);
return;
}
if(ServerVersion.isServerVersionAbove(ServerVersion.V1_8)) {
if(event instanceof BlockMultiPlaceEvent) {
for(BlockState blockState : ((BlockMultiPlaceEvent) event).getReplacedBlockStates()) {
if(!island.equals(islandManager.getIslandAtLocation(blockState.getLocation()))) {
if (ServerVersion.isServerVersionAbove(ServerVersion.V1_8)) {
if (event instanceof BlockMultiPlaceEvent) {
for (BlockState blockState : ((BlockMultiPlaceEvent) event).getReplacedBlockStates()) {
if (!island.equals(islandManager.getIslandAtLocation(blockState.getLocation()))) {
event.setCancelled(true);
return;
}
@ -244,26 +259,28 @@ public class Block implements Listener {
FileConfiguration configLoad = plugin.getConfiguration();
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
if(!player.hasPermission("fabledskyblock.bypass.netherplace") && !islandManager.isIslandWorldUnlocked(island, IslandWorld.Nether)){
if(configLoad.getConfigurationSection("Island.Restrict.NetherBlocks") != null) {
for(String s : configLoad.getConfigurationSection("Island.Restrict.NetherBlocks").getKeys(false)){
if(s.equalsIgnoreCase(block.getType().toString())){
if(configLoad.getBoolean("Island.Restrict.NetherBlocks." + s, false)){
if (!player.hasPermission("fabledskyblock.bypass.netherplace") && !islandManager.isIslandWorldUnlocked(island, IslandWorld.Nether)) {
if (configLoad.getConfigurationSection("Island.Restrict.NetherBlocks") != null) {
for (String s : configLoad.getConfigurationSection("Island.Restrict.NetherBlocks").getKeys(false)) {
if (s.equalsIgnoreCase(block.getType().toString())) {
if (configLoad.getBoolean("Island.Restrict.NetherBlocks." + s, false)) {
plugin.getMessageManager().sendMessage(player, Objects.requireNonNull(plugin.getLanguage().getString("Island.Unlock.NetherBlocksPlace.Message")));
event.setCancelled(true);
return;
}
}
}
}
}
if(!player.hasPermission("fabledskyblock.bypass.endplace") && !islandManager.isIslandWorldUnlocked(island, IslandWorld.End)){
if(configLoad.getConfigurationSection("Island.Restrict.EndBlocks") != null) {
for(String s : configLoad.getConfigurationSection("Island.Restrict.EndBlocks").getKeys(false)){
if(s.equalsIgnoreCase(block.getType().toString())){
if(configLoad.getBoolean("Island.Restrict.EndBlocks." + s)){
if (!player.hasPermission("fabledskyblock.bypass.endplace") && !islandManager.isIslandWorldUnlocked(island, IslandWorld.End)) {
if (configLoad.getConfigurationSection("Island.Restrict.EndBlocks") != null) {
for (String s : configLoad.getConfigurationSection("Island.Restrict.EndBlocks").getKeys(false)) {
if (s.equalsIgnoreCase(block.getType().toString())) {
if (configLoad.getBoolean("Island.Restrict.EndBlocks." + s)) {
plugin.getMessageManager().sendMessage(player, Objects.requireNonNull(plugin.getLanguage().getString("Island.Unlock.EndBlocksPlace.Message")));
event.setCancelled(true);
return;
}
}
}
@ -309,7 +326,7 @@ public class Block implements Listener {
if (limits.isBlockLimitExceeded(block, limit) && CompatibleMaterial.getMaterial(item) != CompatibleMaterial.ENDER_EYE) {
CompatibleMaterial material = null;
if(ServerVersion.isServerVersion(ServerVersion.V1_8)) {
if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
switch (block.getType().toString().toUpperCase()) {
case "DIODE_BLOCK_OFF":
case "DIODE_BLOCK_ON":
@ -317,7 +334,7 @@ public class Block implements Listener {
break;
}
}
if(material == null) {
if (material == null) {
material = CompatibleMaterial.getMaterial(block);
}
@ -333,24 +350,24 @@ public class Block implements Listener {
if (event.getBlock().getType() == CompatibleMaterial.END_PORTAL_FRAME.getMaterial()
&& event.getPlayer().getItemInHand().getType() == CompatibleMaterial.ENDER_EYE.getMaterial()) return;
// Not util used 2 islandLevelManager if condition is true
// Sponge level dupe fix
if(ServerVersion.isServerVersionBelow(ServerVersion.V1_13) &&
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13) &&
block.getType().equals(CompatibleMaterial.SPONGE.getBlockMaterial())) {
Bukkit.getScheduler().runTask(plugin, () -> {
if(blockLoc.getBlock().getType().equals(CompatibleMaterial.WET_SPONGE.getBlockMaterial())) {
if (blockLoc.getBlock().getType().equals(CompatibleMaterial.WET_SPONGE.getBlockMaterial())) {
IslandLevel level = island.getLevel();
CompatibleMaterial material = CompatibleMaterial.SPONGE;
if (level.hasMaterial(material.name())) {
long materialAmount = level.getMaterialAmount(material.name());
if (materialAmount - 1 <= 0) {
level.removeMaterial(material.name());
} else {
level.setMaterialAmount(material.name(), materialAmount - 1);
}
islandLevelManager.updateLevel(island, blockLoc);
}
}
@ -391,30 +408,30 @@ public class Block implements Listener {
}
// Nether mobs
if(configLoad.getBoolean("Island.Nether.WaterDoNotFlowNearNetherMobs", false) && worldManager.getIslandWorld(block.getWorld()).equals(IslandWorld.Nether)){
if (configLoad.getBoolean("Island.Nether.WaterDoNotFlowNearNetherMobs", false) && worldManager.getIslandWorld(block.getWorld()).equals(IslandWorld.Nether)) {
Collection<Entity> entities = block.getWorld().getNearbyEntities(block.getLocation(), 1d, 1d, 1d);
if(entities.size() > 0){
for(Entity ent : entities){
if (entities.size() > 0) {
for (Entity ent : entities) {
boolean witherSkeleton;
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
witherSkeleton = ent.getType().equals(EntityType.WITHER_SKELETON);
} else {
witherSkeleton = ent instanceof Skeleton && ((Skeleton) ent).getSkeletonType().equals(Skeleton.SkeletonType.WITHER);
}
if((((ent instanceof Blaze || ent instanceof MagmaCube) || ent instanceof Wither) || ent instanceof Ghast) || witherSkeleton){
if ((((ent instanceof Blaze || ent instanceof MagmaCube) || ent instanceof Wither) || ent instanceof Ghast) || witherSkeleton) {
event.setCancelled(true);
event.getToBlock().getWorld().playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1f, 1f);
event.getToBlock().getWorld().playEffect(block.getLocation(), Effect.SMOKE, 1);
} else {
if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){
if(((ent instanceof Piglin || ent instanceof Hoglin) || ent instanceof Strider) || ent instanceof Zoglin) {
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) {
if (((ent instanceof Piglin || ent instanceof Hoglin) || ent instanceof Strider) || ent instanceof Zoglin) {
event.setCancelled(true);
event.getToBlock().getWorld().playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1f, 1f);
event.getToBlock().getWorld().playEffect(block.getLocation(), Effect.SMOKE, 1);
}
} else {
if(ent instanceof PigZombie) {
if (ent instanceof PigZombie) {
event.setCancelled(true);
event.getToBlock().getWorld().playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1f, 1f);
event.getToBlock().getWorld().playEffect(block.getLocation(), Effect.SMOKE, 1);
@ -426,114 +443,15 @@ public class Block implements Listener {
}
// Generators
if(this.generatorWaitingLocs.contains(LocationUtil.toBlockLocation(block.getLocation().clone()))) {
if (this.generatorWaitingLocs.contains(LocationUtil.toBlockLocation(block.getLocation().clone()))) {
event.setCancelled(true);
return;
}
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_12)) {
CompatibleMaterial material = CompatibleMaterial.getMaterial(block);
if (material != CompatibleMaterial.WATER
&& material != CompatibleMaterial.LAVA)
return;
BlockState state = event.getToBlock().getState();
Material type = state.getType();
if (type != Material.COBBLESTONE && type != Material.STONE) return;
if (generatorManager == null) return;
List<Generator> generators = Lists.newArrayList(generatorManager.getGenerators());
if (generators.isEmpty()) return;
Collections.reverse(generators); // Use the highest generator available
boolean ignoreVisitors = configLoad.getBoolean("Island.Generator.IgnoreVisitors", false);
// Filter valid players on the island.
List<Player> possiblePlayers = new ArrayList<>();
Set<UUID> visitors = island.getVisit().getVisitors();
for (Player player : Bukkit.getOnlinePlayers()) {
boolean isMember = island.hasRole(IslandRole.Owner, player.getUniqueId()) ||
island.hasRole(IslandRole.Member, player.getUniqueId()) ||
island.hasRole(IslandRole.Coop, player.getUniqueId()) ||
island.hasRole(IslandRole.Operator, player.getUniqueId()) ||
(!ignoreVisitors &&
visitors.contains(player.getUniqueId()) &&
player.hasPermission("fabledskyblock.generator.anywhere"));
if (isMember && islandManager.isLocationAtIsland(island, player.getLocation(), world)) {
possiblePlayers.add(player);
}
}
if(!possiblePlayers.isEmpty()){
boolean nearestPlayer = configLoad.getBoolean("Island.Generator.CheckOnlyNearestPlayer", false);
double distance = possiblePlayers.get(0).getLocation().distance(block.getLocation());
boolean onlyOwner = configLoad.getBoolean("Island.Generator.CheckOnlyOwnerPermissions", false);
if(nearestPlayer){
possiblePlayers.sort(Comparator.comparingDouble(a -> a.getLocation().distance(block.getLocation())));
}
// Find highest generator available
for (Generator generator : generators) {
if(island.getLevel().getLevel() >= generator.getLevel()) {
if(onlyOwner && plugin.getVaultPermission() != null) {
OfflinePlayer owner = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID());
if(owner.isOnline()) {
Player onlineOwner = (Player) owner;
if(onlineOwner.hasPermission(generator.getPermission())) {
applyGenerator(event.getBlock().getWorld(), block, worldManager, islandLevelManager, island, state, generatorManager, generator);
}
} else {
event.setCancelled(true);
org.bukkit.World finalWorld = event.getBlock().getWorld();
this.generatorWaitingLocs.add(LocationUtil.toBlockLocation(block.getLocation().clone()));
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
if(plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, generator.getPermission())) {
Bukkit.getScheduler().runTask(plugin, () -> {
this.generatorWaitingLocs.remove(LocationUtil.toBlockLocation(block.getLocation().clone()));
if(worldManager.getIslandWorld(finalWorld).equals(generator.getIsWorld())){
BlockState genState = generatorManager.generateBlock(generator, block);
block.setType(genState.getType());
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) {
BlockState tempState = block.getState();
tempState.setData(genState.getData());
tempState.update(true, true);
}
islandLevelManager.updateLevel(island, genState.getLocation());
}
});
} else {
Bukkit.getScheduler().runTask(plugin, () -> {
block.setType(CompatibleMaterial.COBBLESTONE.getMaterial());
});
}
});
}
} else {
for (Player player : possiblePlayers) {
if(nearestPlayer && player.getLocation().distance(block.getLocation()) > distance){
break;
}
if (generator.isPermission()) {
if (!player.hasPermission(generator.getPermission()) && !player.hasPermission("fabledskyblock.generator.*") && !player.hasPermission("fabledskyblock.*")) {
continue;
}
}
if (applyGenerator(event.getBlock().getWorld(), block, worldManager, islandLevelManager, island, state, generatorManager, generator))
return;
}
}
}
}
}
}
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_12))
Bukkit.getScheduler().runTaskLater(plugin, () -> {
handleGeneration(block, island, event.getToBlock().getState());
}, 1L);
}
@EventHandler
@ -684,10 +602,9 @@ public class Block implements Listener {
public void onBlockForm(BlockFormEvent event) {
org.bukkit.block.Block block = event.getBlock();
WorldManager worldManager = plugin.getWorldManager();
IslandLevelManager islandLevelManager = plugin.getLevellingManager();
FileConfiguration config = this.plugin.getConfiguration();
if (!worldManager.isIslandWorld(block.getWorld())) return;
// Check ice/snow forming
@ -710,128 +627,10 @@ public class Block implements Listener {
return;
}
}
// Generators
CompatibleMaterial material = CompatibleMaterial.getMaterial(block);
if (material != CompatibleMaterial.WATER
&& material != CompatibleMaterial.LAVA)
return;
BlockState state = event.getNewState();
Material type = state.getType();
if (type != Material.COBBLESTONE && type != Material.STONE) return;
GeneratorManager generatorManager = plugin.getGeneratorManager();
if (generatorManager == null) return;
List<Generator> generators = Lists.newArrayList(generatorManager.getGenerators());
if (generators.isEmpty()) return;
Collections.reverse(generators); // Use the highest generator available
boolean ignoreVisitors = config.getBoolean("Island.Generator.IgnoreVisitors", false);
// Filter valid players on the island.
List<Player> possiblePlayers = new ArrayList<>();
Set<UUID> visitors = island.getVisit().getVisitors();
for (Player player : Bukkit.getOnlinePlayers()) {
boolean isMember = island.hasRole(IslandRole.Owner, player.getUniqueId()) ||
island.hasRole(IslandRole.Member, player.getUniqueId()) ||
island.hasRole(IslandRole.Coop, player.getUniqueId()) ||
island.hasRole(IslandRole.Operator, player.getUniqueId()) ||
(!ignoreVisitors &&
visitors.contains(player.getUniqueId()) &&
player.hasPermission("fabledskyblock.generator.anywhere"));
if (isMember && islandManager.isLocationAtIsland(island, player.getLocation(), world)) {
possiblePlayers.add(player);
}
}
if(!possiblePlayers.isEmpty()){
boolean nearestPlayer = config.getBoolean("Island.Generator.CheckOnlyNearestPlayer", false);
if(nearestPlayer){
possiblePlayers.sort(Comparator.comparingDouble(a -> a.getLocation().distance(block.getLocation())));
}
boolean onlyOwner = config.getBoolean("Island.Generator.CheckOnlyOwnerPermissions", false);
double distance = possiblePlayers.get(0).getLocation().distance(block.getLocation());
// Find highest generator available
for (Generator generator : generators) {
if(island.getLevel().getLevel() >= generator.getLevel()) {
if(onlyOwner && plugin.getVaultPermission() != null) {
OfflinePlayer owner = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID());
if(owner.isOnline()) {
Player onlineOwner = (Player) owner;
if(onlineOwner.hasPermission(generator.getPermission())) {
applyGenerator(event.getBlock().getWorld(), block, worldManager, islandLevelManager, island, state, generatorManager, generator);
}
}
else {
event.setCancelled(true);
org.bukkit.World finalWorld = event.getBlock().getWorld();
this.generatorWaitingLocs.add(LocationUtil.toBlockLocation(block.getLocation().clone()));
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
if (plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, generator.getPermission()) ||
plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.generator.*") ||
plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.*")) {
Bukkit.getScheduler().runTask(plugin, () -> {
this.generatorWaitingLocs.remove(LocationUtil.toBlockLocation(block.getLocation().clone()));
if (worldManager.getIslandWorld(finalWorld).equals(generator.getIsWorld())) {
BlockState genState = generatorManager.generateBlock(generator, block);
block.setType(genState.getType());
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) {
BlockState tempState = block.getState();
tempState.setData(genState.getData());
tempState.update(true, true);
}
islandLevelManager.updateLevel(island, genState.getLocation());
}
});
} else {
Bukkit.getScheduler().runTask(plugin, () -> {
block.setType(CompatibleMaterial.COBBLESTONE.getMaterial());
});
}
});
}
} else {
for (Player player : possiblePlayers) {
if(nearestPlayer && player.getLocation().distance(block.getLocation()) > distance){
break;
}
if (generator.isPermission()) {
if (!player.hasPermission(generator.getPermission()) && !player.hasPermission("fabledskyblock.generator.*") && !player.hasPermission("fabledskyblock.*")) {
continue;
}
}
if (applyGenerator(event.getBlock().getWorld(), block, worldManager, islandLevelManager, island, state, generatorManager, generator))
return;
}
}
}
}
}
if (handleGeneration(block, island, event.getNewState()))
event.setCancelled(true);
}
private boolean applyGenerator(org.bukkit.World world, org.bukkit.block.Block block, WorldManager worldManager, IslandLevelManager islandLevelManager, Island island, BlockState state, GeneratorManager generatorManager, Generator generator) {
if(worldManager.getIslandWorld(world).equals(generator.getIsWorld())){
BlockState genState = generatorManager.generateBlock(generator, block);
state.setType(genState.getType());
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) state.setData(genState.getData());
islandLevelManager.updateLevel(island, genState.getLocation());
return true;
}
return false;
}
@EventHandler(ignoreCancelled = true)
public void onBlockBurn(BlockBurnEvent event) {
org.bukkit.block.Block block = event.getBlock();
@ -841,7 +640,7 @@ public class Block implements Listener {
IslandManager islandManager = plugin.getIslandManager();
PermissionManager permissionManager = plugin.getPermissionManager();
if (!permissionManager.hasPermission(
islandManager.getIslandAtLocation(block.getLocation()),"FireSpread", IslandRole.Owner))
islandManager.getIslandAtLocation(block.getLocation()), "FireSpread", IslandRole.Owner))
event.setCancelled(true);
}
@ -952,7 +751,7 @@ public class Block implements Listener {
CompatibleMaterial srcmaterial = CompatibleMaterial.getMaterial(event.getBlock());
if (srcmaterial != CompatibleMaterial.WATER
&& srcmaterial != CompatibleMaterial.LAVA)
&& srcmaterial != CompatibleMaterial.LAVA)
return;
FileConfiguration configLoad = plugin.getConfiguration();
@ -970,4 +769,131 @@ public class Block implements Listener {
}
}
}
public boolean handleGeneration(Block block, Island island, BlockState state) {
WorldManager worldManager = plugin.getWorldManager();
IslandLevelManager islandLevelManager = plugin.getLevellingManager();
FileConfiguration config = this.plugin.getConfiguration();
IslandManager islandManager = plugin.getIslandManager();
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
CompatibleMaterial material = CompatibleMaterial.getMaterial(block);
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)
&& material != CompatibleMaterial.WATER
&& material != CompatibleMaterial.LAVA)
return false;
Material type = state.getType();
if (type != Material.COBBLESTONE && type != Material.STONE) return false;
GeneratorManager generatorManager = plugin.getGeneratorManager();
if (generatorManager == null) return false;
List<Generator> generators = Lists.newArrayList(generatorManager.getGenerators());
if (generators.isEmpty()) return false;
Collections.reverse(generators); // Use the highest generator available
boolean ignoreVisitors = config.getBoolean("Island.Generator.IgnoreVisitors", false);
// Filter valid players on the island.
List<Player> possiblePlayers = new ArrayList<>();
Set<UUID> visitors = island.getVisit().getVisitors();
for (Player player : Bukkit.getOnlinePlayers()) {
boolean isMember = island.hasRole(IslandRole.Owner, player.getUniqueId()) ||
island.hasRole(IslandRole.Member, player.getUniqueId()) ||
island.hasRole(IslandRole.Coop, player.getUniqueId()) ||
island.hasRole(IslandRole.Operator, player.getUniqueId()) ||
(!ignoreVisitors &&
visitors.contains(player.getUniqueId()) &&
player.hasPermission("fabledskyblock.generator.anywhere"));
if (isMember && islandManager.isLocationAtIsland(island, player.getLocation(), world)) {
possiblePlayers.add(player);
}
}
if (!possiblePlayers.isEmpty()) {
boolean nearestPlayer = config.getBoolean("Island.Generator.CheckOnlyNearestPlayer", false);
if (nearestPlayer) {
possiblePlayers.sort(Comparator.comparingDouble(a -> a.getLocation().distance(block.getLocation())));
}
boolean onlyOwner = config.getBoolean("Island.Generator.CheckOnlyOwnerPermissions", false);
double distance = possiblePlayers.get(0).getLocation().distance(block.getLocation());
// Find highest generator available
for (Generator generator : generators) {
if (island.getLevel().getLevel() < generator.getLevel()) continue;
if (onlyOwner && plugin.getVaultPermission() != null) {
OfflinePlayer owner = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID());
if (owner.isOnline()) {
Player onlineOwner = (Player) owner;
if (onlineOwner.hasPermission(generator.getPermission())) {
applyGenerator(block, worldManager, islandLevelManager, island, state, generatorManager, generator);
}
continue;
}
org.bukkit.World finalWorld = block.getWorld();
this.generatorWaitingLocs.add(LocationUtil.toBlockLocation(block.getLocation().clone()));
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
if (plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, generator.getPermission()) ||
plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.generator.*") ||
plugin.getVaultPermission().playerHas(block.getWorld().getName(), owner, "fabledskyblock.*")) {
Bukkit.getScheduler().runTask(plugin, () -> {
this.generatorWaitingLocs.remove(LocationUtil.toBlockLocation(block.getLocation().clone()));
if (!worldManager.getIslandWorld(finalWorld).equals(generator.getIsWorld()))
return;
BlockState genState = generatorManager.generateBlock(generator, block);
block.setType(genState.getType());
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) {
BlockState tempState = block.getState();
tempState.setData(genState.getData());
tempState.update(true, true);
}
islandLevelManager.updateLevel(island, genState.getLocation());
});
} else {
Bukkit.getScheduler().runTask(plugin, () ->
block.setType(CompatibleMaterial.COBBLESTONE.getMaterial()));
}
});
return true;
}
for (Player player : possiblePlayers) {
if (nearestPlayer && player.getLocation().distance(block.getLocation()) > distance) {
break;
}
if (generator.isPermission()) {
if (!player.hasPermission(generator.getPermission()) && !player.hasPermission("fabledskyblock.generator.*") && !player.hasPermission("fabledskyblock.*")) {
continue;
}
}
if (applyGenerator(block, worldManager, islandLevelManager, island, state, generatorManager, generator))
return false;
}
}
}
return false;
}
private boolean applyGenerator(org.bukkit.block.Block block, WorldManager worldManager, IslandLevelManager islandLevelManager, Island island, BlockState state, GeneratorManager generatorManager, Generator generator) {
if (worldManager.getIslandWorld(block.getWorld()).equals(generator.getIsWorld())) {
BlockState genState = generatorManager.generateBlock(generator, block);
state.setType(genState.getType());
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) state.setData(genState.getData());
islandLevelManager.updateLevel(island, genState.getLocation());
return true;
}
return false;
}
}

View File

@ -16,11 +16,11 @@ import org.bukkit.event.player.PlayerBucketFillEvent;
import java.io.File;
public class Bucket implements Listener {
public class BucketListeners implements Listener {
private final SkyBlock plugin;
public Bucket(SkyBlock plugin) {
public BucketListeners(SkyBlock plugin) {
this.plugin = plugin;
}

View File

@ -24,11 +24,11 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.io.File;
import java.util.UUID;
public class Chat implements Listener {
public class ChatListeners implements Listener {
private final SkyBlock plugin;
public Chat(SkyBlock plugin) {
public ChatListeners(SkyBlock plugin) {
this.plugin = plugin;
}

View File

@ -12,11 +12,11 @@ import org.bukkit.event.entity.PlayerDeathEvent;
import java.io.File;
public class Death implements Listener {
public class DeathListeners implements Listener {
private final SkyBlock plugin;
public Death(SkyBlock plugin) {
public DeathListeners(SkyBlock plugin) {
this.plugin = plugin;
}

View File

@ -41,13 +41,13 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
public class Entity implements Listener {
public class EntityListeners implements Listener {
private final SkyBlock plugin;
private final Set<UUID> preventFireTicks = new HashSet<>();
public Entity(SkyBlock plugin) {
public EntityListeners(SkyBlock plugin) {
this.plugin = plugin;
}

View File

@ -22,13 +22,13 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
public class FallBreak implements Listener {
public class FallBreakListeners implements Listener {
private final SkyBlock plugin;
private final Set<FallingBlock> fallingBlocks;
public FallBreak(SkyBlock plugin) {
public FallBreakListeners(SkyBlock plugin) {
this.plugin = plugin;
this.fallingBlocks = new HashSet<>();

View File

@ -6,11 +6,11 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.FoodLevelChangeEvent;
public class Food implements Listener {
public class FoodListeners implements Listener {
private final SkyBlock plugin;
public Food(SkyBlock plugin) {
public FoodListeners(SkyBlock plugin) {
this.plugin = plugin;
}

View File

@ -27,11 +27,11 @@ import java.util.Iterator;
import java.util.List;
@SuppressWarnings("deprecation")
public class Grow implements Listener {
public class GrowListeners implements Listener {
private final SkyBlock plugin;
public Grow(SkyBlock plugin) {
public GrowListeners(SkyBlock plugin) {
this.plugin = plugin;
}

View File

@ -42,11 +42,11 @@ import org.bukkit.permissions.PermissionAttachmentInfo;
import java.io.File;
import java.util.HashMap;
public class Interact implements Listener {
public class InteractListeners implements Listener {
private final SkyBlock plugin;
public Interact(SkyBlock plugin) {
public InteractListeners(SkyBlock plugin) {
this.plugin = plugin;
}

View File

@ -6,11 +6,11 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryOpenEvent;
public class Inventory implements Listener {
public class InventoryListeners implements Listener {
private final SkyBlock plugin;
public Inventory(SkyBlock plugin) {
public InventoryListeners(SkyBlock plugin) {
this.plugin = plugin;
}

View File

@ -9,11 +9,11 @@ import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
@SuppressWarnings("deprecation")
public class Item implements Listener {
public class ItemListeners implements Listener {
private final SkyBlock plugin;
public Item(SkyBlock plugin) {
public ItemListeners(SkyBlock plugin) {
this.plugin = plugin;
}

View File

@ -27,11 +27,11 @@ import org.bukkit.event.player.PlayerJoinEvent;
import java.io.File;
import java.lang.reflect.Method;
public class Join implements Listener {
public class JoinListeners implements Listener {
private final SkyBlock plugin;
public Join(SkyBlock plugin) {
public JoinListeners(SkyBlock plugin) {
this.plugin = plugin;
}

View File

@ -31,11 +31,11 @@ import org.bukkit.potion.PotionEffect;
import java.io.File;
import java.util.Objects;
public class Move implements Listener {
public class MoveListeners implements Listener {
private final SkyBlock plugin;
public Move(SkyBlock plugin) {
public MoveListeners(SkyBlock plugin) {
this.plugin = plugin;
}

View File

@ -15,11 +15,11 @@ import org.bukkit.event.block.BlockPistonExtendEvent;
import java.io.File;
public class Piston implements Listener {
public class PistonListeners implements Listener {
private final SkyBlock plugin;
public Piston(SkyBlock plugin) {
public PistonListeners(SkyBlock plugin) {
this.plugin = plugin;
}

View File

@ -30,13 +30,13 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class Portal implements Listener {
public class PortalListeners implements Listener {
private final SkyBlock plugin;
private final Map<UUID, Tick> tickCounter = new HashMap<>();
public Portal(SkyBlock plugin) {
public PortalListeners(SkyBlock plugin) {
this.plugin = plugin;
}

View File

@ -7,11 +7,11 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.projectiles.ProjectileSource;
public class Projectile implements Listener {
public class ProjectileListeners implements Listener {
private final SkyBlock plugin;
public Projectile(SkyBlock plugin) {
public ProjectileListeners(SkyBlock plugin) {
this.plugin = plugin;
}

View File

@ -28,11 +28,11 @@ import java.util.Date;
import java.util.Set;
import java.util.UUID;
public class Quit implements Listener {
public class QuitListeners implements Listener {
private final SkyBlock plugin;
public Quit(SkyBlock plugin) {
public QuitListeners(SkyBlock plugin) {
this.plugin = plugin;
}

View File

@ -17,11 +17,11 @@ import org.bukkit.event.player.PlayerTeleportEvent;
import java.io.File;
import java.util.logging.Level;
public class Respawn implements Listener {
public class RespawnListeners implements Listener {
private final SkyBlock plugin;
public Respawn(SkyBlock plugin) {
public RespawnListeners(SkyBlock plugin) {
this.plugin = plugin;
}

View File

@ -14,11 +14,11 @@ import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
public class Spawner implements Listener {
public class SpawnerListeners implements Listener {
private final SkyBlock plugin;
public Spawner(SkyBlock plugin) {
public SpawnerListeners(SkyBlock plugin) {
this.plugin = plugin;
}

View File

@ -14,11 +14,11 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.SpongeAbsorbEvent;
public class Sponge implements Listener {
public class SpongeListeners implements Listener {
private final SkyBlock plugin;
public Sponge(SkyBlock plugin) {
public SpongeListeners(SkyBlock plugin) {
this.plugin = plugin;
}

View File

@ -33,11 +33,11 @@ import org.bukkit.event.player.PlayerTeleportEvent;
import java.io.File;
import java.util.UUID;
public class Teleport implements Listener {
public class TeleportListeners implements Listener {
private final SkyBlock plugin;
public Teleport(SkyBlock plugin) {
public TeleportListeners(SkyBlock plugin) {
this.plugin = plugin;
}

View File

@ -11,11 +11,11 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChangedWorldEvent;
public class World implements Listener {
public class WorldListeners implements Listener {
private final SkyBlock plugin;
public World(SkyBlock plugin) {
public WorldListeners(SkyBlock plugin) {
this.plugin = plugin;
}

View File

@ -1,4 +1,4 @@
package com.songoda.skyblock.listeners;
package com.songoda.skyblock.listeners.hooks;
import com.songoda.epicspawners.api.events.SpawnerBreakEvent;
import com.songoda.epicspawners.api.events.SpawnerChangeEvent;

View File

@ -1,4 +1,4 @@
package com.songoda.skyblock.listeners;
package com.songoda.skyblock.listeners.hooks;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;

View File

@ -40,9 +40,8 @@ public class Border {
MessageManager messageManager = plugin.getMessageManager();
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
FileManager fileManager = plugin.getFileManager();
FileConfiguration configLoad = plugin.getConfiguration();
FileConfiguration configLoad = plugin.getLanguage();
nInventoryUtil nInv = new nInventoryUtil(player, event -> {
Island island = islandManager.getIsland(player);

View File

@ -4,7 +4,6 @@ import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.cooldown.Cooldown;
import com.songoda.skyblock.cooldown.CooldownManager;
import com.songoda.skyblock.cooldown.CooldownPlayer;
@ -32,7 +31,6 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ -207,8 +205,9 @@ public class Levelling {
int playerMenuPage = playerData.getPage(MenuType.LEVELLING), nextEndIndex = islandMaterials.size() - playerMenuPage * 36;
nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(), configLoad.getString("Menu.Levelling.Item.Exit.Displayname"), null, null, null, null), 0, 8);
nInv.addItem(nInv.createItem(CompatibleMaterial.FIREWORK_STAR.getItem(), configLoad.getString("Menu.Levelling.Item.Rescan.Displayname"), configLoad.getStringList("Menu.Levelling.Item.Rescan.Lore"), null, null,
new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 3, 5);
if (player.hasPermission("fabledskyblock.island.level.rescan"))
nInv.addItem(nInv.createItem(CompatibleMaterial.FIREWORK_STAR.getItem(), configLoad.getString("Menu.Levelling.Item.Rescan.Displayname"), configLoad.getStringList("Menu.Levelling.Item.Rescan.Lore"), null, null,
new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 3, 5);
nInv.addItem(
nInv.createItem(new ItemStack(Material.PAINTING), configLoad.getString("Menu.Levelling.Item.Statistics.Displayname"), configLoad.getStringList("Menu.Levelling.Item.Statistics.Lore"),
new Placeholder[]{new Placeholder("%level_points", NumberUtil.formatNumberByDecimal(level.getPoints())), new Placeholder("%level", NumberUtil.formatNumberByDecimal(level.getLevel()))}, null, null),
@ -274,14 +273,14 @@ public class Levelling {
is.setAmount(Math.min(Math.toIntExact(materialAmount), 64));
is.setType(CompatibleMaterial.getMaterial(is).getMaterial());
long finalMaterialAmountCounted = materialAmountCounted;
long finalMaterialAmountCounted = materialAmountCounted;
List<String> lore = configLoad.getStringList("Menu.Levelling.Item.Material.Lore");
lore.replaceAll(x -> x.replace("%points", NumberUtil.formatNumberByDecimal(pointsEarned)).replace("%blocks", NumberUtil.formatNumberByDecimal(materialAmount))
.replace("%material", name).replace("%counted", NumberUtil.formatNumberByDecimal(finalMaterialAmountCounted)));
nInv.addItem(nInv.createItem(is, configLoad.getString("Menu.Levelling.Item.Material.Displayname").replace("%points", NumberUtil.formatNumberByDecimal(pointsEarned))
.replace("%blocks", NumberUtil.formatNumberByDecimal(materialAmount)).replace("%material", name).replace("%counted", NumberUtil.formatNumberByDecimal(finalMaterialAmountCounted))
,lore, null, null, null), inventorySlot);
.replace("%blocks", NumberUtil.formatNumberByDecimal(materialAmount)).replace("%material", name).replace("%counted", NumberUtil.formatNumberByDecimal(finalMaterialAmountCounted))
, lore, null, null, null), inventorySlot);
}
}

View File

@ -24,19 +24,40 @@ public class DoorPermission extends ListeningPermission {
@PermissionHandler
public void onInteract(PlayerInteractEvent event) {
if (event.getAction() != Action.LEFT_CLICK_BLOCK)
if (event.getAction() == Action.LEFT_CLICK_BLOCK)
return;
Player player = event.getPlayer();
CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getClickedBlock());
if (material == CompatibleMaterial.BIRCH_DOOR || material == CompatibleMaterial.ACACIA_DOOR
|| material == CompatibleMaterial.DARK_OAK_DOOR || material == CompatibleMaterial.JUNGLE_DOOR
|| material == CompatibleMaterial.SPRUCE_DOOR || material == CompatibleMaterial.OAK_DOOR)
cancelAndMessage(event, player, plugin, messageManager);
if (material == null) return;
switch (material) {
case OAK_DOOR:
case BIRCH_DOOR:
case ACACIA_DOOR:
case JUNGLE_DOOR:
case SPRUCE_DOOR:
case WARPED_DOOR:
case CRIMSON_DOOR:
case DARK_OAK_DOOR:
case OAK_TRAPDOOR:
case BIRCH_TRAPDOOR:
case ACACIA_TRAPDOOR:
case JUNGLE_TRAPDOOR:
case SPRUCE_TRAPDOOR:
case WARPED_TRAPDOOR:
case CRIMSON_TRAPDOOR:
case DARK_OAK_TRAPDOOR:
case ACACIA_FENCE_GATE:
case OAK_FENCE_GATE:
case BIRCH_FENCE_GATE:
case JUNGLE_FENCE_GATE:
case SPRUCE_FENCE_GATE:
case WARPED_FENCE_GATE:
case CRIMSON_FENCE_GATE:
case DARK_OAK_FENCE_GATE:
cancelAndMessage(event, player, plugin, messageManager);
}
}
}

View File

@ -23,17 +23,23 @@ public class GatePermission extends ListeningPermission {
@PermissionHandler
public void onInteract(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK)
if (event.getAction() == Action.LEFT_CLICK_BLOCK)
return;
Player player = event.getPlayer();
CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getClickedBlock());
if (material == null) return;
if (material == CompatibleMaterial.OAK_FENCE_GATE || material == CompatibleMaterial.ACACIA_FENCE_GATE
|| material == CompatibleMaterial.BIRCH_FENCE_GATE || material == CompatibleMaterial.DARK_OAK_FENCE_GATE
|| material == CompatibleMaterial.JUNGLE_FENCE_GATE || material == CompatibleMaterial.SPRUCE_FENCE_GATE)
cancelAndMessage(event, player, plugin, messageManager);
switch (material) {
case ACACIA_FENCE_GATE:
case OAK_FENCE_GATE:
case BIRCH_FENCE_GATE:
case JUNGLE_FENCE_GATE:
case SPRUCE_FENCE_GATE:
case WARPED_FENCE_GATE:
case CRIMSON_FENCE_GATE:
case DARK_OAK_FENCE_GATE:
cancelAndMessage(event, player, plugin, messageManager);
}
}
}

View File

@ -23,17 +23,23 @@ public class TrapdoorPermission extends ListeningPermission {
@PermissionHandler
public void onInteract(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK)
if (event.getAction() == Action.LEFT_CLICK_BLOCK)
return;
Player player = event.getPlayer();
CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getClickedBlock());
if (material == null) return;
if (material == CompatibleMaterial.OAK_TRAPDOOR || material == CompatibleMaterial.SPRUCE_TRAPDOOR
|| material == CompatibleMaterial.BIRCH_TRAPDOOR || material == CompatibleMaterial.JUNGLE_TRAPDOOR
|| material == CompatibleMaterial.ACACIA_TRAPDOOR || material == CompatibleMaterial.DARK_OAK_TRAPDOOR)
cancelAndMessage(event, player, plugin, messageManager);
switch (material) {
case OAK_TRAPDOOR:
case BIRCH_TRAPDOOR:
case ACACIA_TRAPDOOR:
case JUNGLE_TRAPDOOR:
case SPRUCE_TRAPDOOR:
case WARPED_TRAPDOOR:
case CRIMSON_TRAPDOOR:
case DARK_OAK_TRAPDOOR:
cancelAndMessage(event, player, plugin, messageManager);
}
}
}

View File

@ -192,7 +192,7 @@ public class nInventoryUtil {
public Item(ItemStack is, String itemDisplayname, List<String> itemLore, Placeholder[] placeholders, Enchantment[] itemEnchantments, ItemFlag[] itemFlags) {
this.is = is;
this.itemDisplayname = ChatColor.translateAlternateColorCodes('&', itemDisplayname);
this.itemDisplayname = itemDisplayname == null ? null : ChatColor.translateAlternateColorCodes('&', itemDisplayname);
this.itemLore = itemLore;
this.placeholders = placeholders;
this.itemEnchantments = itemEnchantments;

View File

@ -43,21 +43,21 @@ public class WorldManager {
endWorld = Bukkit.getServer().getWorld(endWorldName);
if (normalWorld == null) {
Bukkit.getServer().getLogger().log(Level.INFO, "SkyBlock | Info: Generating VoidWorld '" + normalWorldName + "'.");
Bukkit.getServer().getLogger().log(Level.INFO, "SkyBlock | Info: Generating Normal World '" + normalWorldName + "'.");
normalWorld = WorldCreator.name(normalWorldName).type(WorldType.FLAT).environment(normalWorldEnvironment).generator(new VoidGenerator()).createWorld();
Bukkit.getServer().getScheduler().runTask(plugin, () -> registerMultiverse(normalWorldName, normalWorldEnvironment));
}
if (netherWorld == null && netherWorldEnabled) {
Bukkit.getServer().getLogger().log(Level.INFO, "SkyBlock | Info: Generating VoidWorld '" + netherWorldName + "'.");
Bukkit.getServer().getLogger().log(Level.INFO, "SkyBlock | Info: Generating Nether World '" + netherWorldName + "'.");
netherWorld = WorldCreator.name(netherWorldName).type(WorldType.FLAT).environment(netherWorldEnvironment).generator(new VoidGenerator()).createWorld();
Bukkit.getServer().getScheduler().runTask(plugin, () -> registerMultiverse(netherWorldName, netherWorldEnvironment));
}
if (endWorld == null && endWorldEnabled) {
Bukkit.getServer().getLogger().log(Level.INFO, "SkyBlock | Info: Generating VoidWorld '" + endWorldName + "'.");
Bukkit.getServer().getLogger().log(Level.INFO, "SkyBlock | Info: Generating Void World '" + endWorldName + "'.");
endWorld = WorldCreator.name(endWorldName).type(WorldType.FLAT).environment(endWorldEnvironment).generator(new VoidGenerator()).createWorld();
Bukkit.getServer().getScheduler().runTask(plugin, () -> registerMultiverse(endWorldName, endWorldEnvironment));

View File

@ -4,13 +4,13 @@ version: maven-version-number
api-version: 1.13
description: A unique SkyBlock plugin
author: Songoda
authors: [Fabrimat]
softdepend: [HolographicDisplays, Holograms, CMI, PlaceholderAPI, MVdWPlaceholderAPI, Vault, Reserve, PlayerPoints,
LeaderHeads, EpicSpawners, UltimateStacker, WorldEdit, Residence, CoreProtect, CMIEInjector]
loadbefore: [Multiverse-Core, ProtocolLib]
authors: [ Fabrimat ]
softdepend: [ HolographicDisplays, Holograms, CMI, PlaceholderAPI, MVdWPlaceholderAPI, Vault, Reserve, PlayerPoints,
LeaderHeads, EpicSpawners, UltimateStacker, WorldEdit, Residence, CoreProtect, CMIEInjector ]
loadbefore: [ Multiverse-Core, ProtocolLib ]
commands:
island:
description: Island command
aliases: [is]
skyblock:
description: Skyblock info command.
island:
description: Island command
aliases: [ is ]
skyblock:
description: Skyblock info command.