Additions & Fixes

# Added the alias 'new' to the '/island create' command.
# Added the alias 'banned' to the '/island bans' command.
# Fixed NPE when loading an Island if an island world name has been changed in the configuration file while there's island data.
# Fixed NPE when teleporting to the set spawn point if the world is not loaded or no longer exists.
This commit is contained in:
Unknown 2018-11-26 14:07:09 +00:00
parent 72ebac3a16
commit decf54202f
15 changed files with 305 additions and 28 deletions

View File

@ -9,9 +9,13 @@ Sound:
# When disabled all sounds will be disabled.
Enable: true
Island:
Size:
# [!] Do not go over 1000 for both of these options.
# The size of an Island when created.
# [!] If you go over 1000, the size of the Island will be 100.
Size: 100
# [!] Do not go over the maximum.
Minimum: 100
# The maximum size of an Island based on the permission note 'skyblock.size.<size>'.
Maximum: 200
Creation:
# Rather than opening the 'Island Creator' menu. Create an island
# as soon as a player performs the '/island' or '/island create'

View File

@ -625,6 +625,24 @@ Command:
Message: "&bSkyBlock &8| &cError&8: &eYou cannot set the spawn point in an Island world."
Set:
Message: "&bSkyBlock &8| &aInfo&8: &eThe spawn point has been set to your location."
SetSize:
Info:
Message: "&f&oSets the size of a players Island."
Permission:
Message: "&bSkyBlock &8| &cError&8: &eYou don't have permission to perform that command."
Invalid:
Message: "&bSkyBlock &8| &cError&8: &eInvalid: /island admin setsize <player_name> <size>"
Numerical:
Message: "&bSkyBlock &8| &cError&8: &eYou must enter a numerical value."
Size:
Greater:
Message: "&bSkyBlock &8| &cError&8: &eThe size of the Island must be greater than 50."
Less:
Message: "&bSkyBlock &8| &cError&8: &eThe size of the Island must be less than 1000."
Island:
Message: "&bSkyBlock &8| &cError&8: &eThat player is not a Member or owns an Island."
Set:
Message: "&bSkyBlock &8| &aInfo&8: &eYou have set the player &d%player's &eIsland size to &d%size&e."
Delete:
Info:
Message: "&f&oDelete a players Island permanently."
@ -886,7 +904,7 @@ Placeholder:
Message: "&f%placeholder"
Scoreboard:
Tutorial:
Displayname: " &b&lSkyBlock &7(&f%players_online&7/&f%players_max&7)"
Displayname: "&b&lSkyBlock"
Displaylines:
- ""
- "&bIsland&f:"
@ -900,7 +918,7 @@ Scoreboard:
- "&ewww.example.net"
Island:
Solo:
Displayname: " &b&lSkyBlock &7(&f%players_online&7/&f%players_max&7)"
Displayname: "&b&lSkyBlock"
Occupied:
Displaylines:
- ""
@ -929,7 +947,7 @@ Scoreboard:
Owner: "Owner"
Operator: "Operator"
Member: "Member"
Displayname: " &b&lSkyBlock &7(&f%players_online&7/&f%players_max&7)"
Displayname: "&b&lSkyBlock"
Occupied:
Displaylines:
- ""

View File

@ -1,6 +1,6 @@
name: SkyBlock
main: me.goodandevil.skyblock.Main
version: 26
version: 27
api-version: 1.13
description: A unique SkyBlock plugin
author: GoodAndEvil

View File

@ -52,6 +52,7 @@ import me.goodandevil.skyblock.command.commands.VoteCommand;
import me.goodandevil.skyblock.command.commands.WeatherCommand;
import me.goodandevil.skyblock.command.commands.admin.GeneratorCommand;
import me.goodandevil.skyblock.command.commands.admin.ReloadCommand;
import me.goodandevil.skyblock.command.commands.admin.SetSizeCommand;
import me.goodandevil.skyblock.command.commands.admin.StructureCommand;
import me.goodandevil.skyblock.config.FileManager;
import me.goodandevil.skyblock.config.FileManager.Config;
@ -123,6 +124,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
subCommands = new ArrayList<>();
subCommands.add(new me.goodandevil.skyblock.command.commands.admin.SetSpawnCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.SetSpawn.Info.Message"))));
subCommands.add(new SetSizeCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.SetSize.Info.Message"))));
subCommands.add(new me.goodandevil.skyblock.command.commands.admin.CreateCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Create.Info.Message"))));
subCommands.add(new GeneratorCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Generator.Info.Message"))));
subCommands.add(new me.goodandevil.skyblock.command.commands.admin.LevelCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Level.Info.Message"))));

View File

@ -76,7 +76,7 @@ public class BansCommand extends SubCommand {
@Override
public String[] getAliases() {
return new String[0];
return new String[] { "banned" };
}
@Override

View File

@ -112,7 +112,7 @@ public class CreateCommand extends SubCommand {
@Override
public String[] getAliases() {
return new String[0];
return new String[] { "new" };
}
@Override

View File

@ -88,11 +88,11 @@ public class InviteCommand extends SubCommand {
int respondTime = mainConfig.getFileConfiguration().getInt("Island.Invite.Time");
if (respondTime < 60) {
player.spigot().sendMessage(new ChatComponent(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Sender.Sent.Message").replace("%player", targetPlayer.getName()).replace("%time", respondTime + " " + configLoad.getString("Command.Island.Invite.Invited.Word.Second"))) + " ", false, null, null, null).addExtra(new ChatComponent(configLoad.getString("Command.Island.Invite.Invited.Word.Cancel").toUpperCase(), true, ChatColor.RED, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/island cancel " + targetPlayer.getName()), new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Word.Tutorial").replace("%action", configLoad.getString("Command.Island.Invite.Invited.Word.Cancel")))).create()))));
targetPlayer.spigot().sendMessage(new ChatComponent(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Target.Received.Message").replace("%player", player.getName()).replace("%time", respondTime + " " + configLoad.getString("Command.Island.Invite.Invited.Word.Second"))) + " ", false, null, null, null).addExtraChatComponent(new ChatComponent(configLoad.getString("Command.Island.Invite.Invited.Word.Accept").toUpperCase(), true, ChatColor.GREEN, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/island accept " + player.getName()), new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Word.Tutorial").replace("%action", configLoad.getString("Command.Island.Invite.Invited.Word.Accept")))).create()))).addExtraChatComponent(new ChatComponent(" | ", false, ChatColor.DARK_GRAY, null, null)).addExtra(new ChatComponent(configLoad.getString("Command.Island.Invite.Invited.Word.Deny").toUpperCase(), true, ChatColor.RED, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/island deny " + player.getName()), new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Word.Tutorial").replace("%action", configLoad.getString("Command.Island.Invite.Invited.Word.Deny")))).create()))));
player.spigot().sendMessage(new ChatComponent(messageManager.replaceMessage(player, ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Sender.Sent.Message").replace("%player", targetPlayer.getName()).replace("%time", respondTime + " " + configLoad.getString("Command.Island.Invite.Invited.Word.Second"))) + " "), false, null, null, null).addExtra(new ChatComponent(configLoad.getString("Command.Island.Invite.Invited.Word.Cancel").toUpperCase(), true, ChatColor.RED, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/island cancel " + targetPlayer.getName()), new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Word.Tutorial").replace("%action", configLoad.getString("Command.Island.Invite.Invited.Word.Cancel")))).create()))));
targetPlayer.spigot().sendMessage(new ChatComponent(messageManager.replaceMessage(targetPlayer, ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Target.Received.Message").replace("%player", player.getName()).replace("%time", respondTime + " " + configLoad.getString("Command.Island.Invite.Invited.Word.Second"))) + " "), false, null, null, null).addExtraChatComponent(new ChatComponent(configLoad.getString("Command.Island.Invite.Invited.Word.Accept").toUpperCase(), true, ChatColor.GREEN, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/island accept " + player.getName()), new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Word.Tutorial").replace("%action", configLoad.getString("Command.Island.Invite.Invited.Word.Accept")))).create()))).addExtraChatComponent(new ChatComponent(" | ", false, ChatColor.DARK_GRAY, null, null)).addExtra(new ChatComponent(configLoad.getString("Command.Island.Invite.Invited.Word.Deny").toUpperCase(), true, ChatColor.RED, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/island deny " + player.getName()), new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Word.Tutorial").replace("%action", configLoad.getString("Command.Island.Invite.Invited.Word.Deny")))).create()))));
} else {
player.spigot().sendMessage(new ChatComponent(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Sender.Sent.Message").replace("%player", targetPlayer.getName()).replace("%time", respondTime/60 + " " + configLoad.getString("Command.Island.Invite.Invited.Word.Minute"))) + " ", false, null, null, null).addExtra(new ChatComponent(configLoad.getString("Command.Island.Invite.Invited.Word.Cancel").toUpperCase(), true, ChatColor.RED, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/island cancel " + targetPlayer.getName()), new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Word.Tutorial").replace("%action", configLoad.getString("Command.Island.Invite.Invited.Word.Cancel")))).create()))));
targetPlayer.spigot().sendMessage(new ChatComponent(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Target.Received.Message").replace("%player", player.getName()).replace("%time", respondTime/60 + " " + configLoad.getString("Command.Island.Invite.Invited.Word.Minute"))) + " ", false, null, null, null).addExtraChatComponent(new ChatComponent(configLoad.getString("Command.Island.Invite.Invited.Word.Accept").toUpperCase(), true, ChatColor.GREEN, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/island accept " + player.getName()), new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Word.Tutorial").replace("%action", configLoad.getString("Command.Island.Invite.Invited.Word.Accept")))).create()))).addExtraChatComponent(new ChatComponent(" | ", false, ChatColor.DARK_GRAY, null, null)).addExtra(new ChatComponent(configLoad.getString("Command.Island.Invite.Invited.Word.Deny").toUpperCase(), true, ChatColor.RED, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/island deny " + player.getName()), new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Word.Tutorial").replace("%action", configLoad.getString("Command.Island.Invite.Invited.Word.Deny")))).create()))));
player.spigot().sendMessage(new ChatComponent(messageManager.replaceMessage(player, ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Sender.Sent.Message").replace("%player", targetPlayer.getName()).replace("%time", respondTime/60 + " " + configLoad.getString("Command.Island.Invite.Invited.Word.Minute"))) + " "), false, null, null, null).addExtra(new ChatComponent(configLoad.getString("Command.Island.Invite.Invited.Word.Cancel").toUpperCase(), true, ChatColor.RED, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/island cancel " + targetPlayer.getName()), new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Word.Tutorial").replace("%action", configLoad.getString("Command.Island.Invite.Invited.Word.Cancel")))).create()))));
targetPlayer.spigot().sendMessage(new ChatComponent(messageManager.replaceMessage(targetPlayer, ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Target.Received.Message").replace("%player", player.getName()).replace("%time", respondTime/60 + " " + configLoad.getString("Command.Island.Invite.Invited.Word.Minute"))) + " "), false, null, null, null).addExtraChatComponent(new ChatComponent(configLoad.getString("Command.Island.Invite.Invited.Word.Accept").toUpperCase(), true, ChatColor.GREEN, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/island accept " + player.getName()), new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Word.Tutorial").replace("%action", configLoad.getString("Command.Island.Invite.Invited.Word.Accept")))).create()))).addExtraChatComponent(new ChatComponent(" | ", false, ChatColor.DARK_GRAY, null, null)).addExtra(new ChatComponent(configLoad.getString("Command.Island.Invite.Invited.Word.Deny").toUpperCase(), true, ChatColor.RED, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/island deny " + player.getName()), new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Word.Tutorial").replace("%action", configLoad.getString("Command.Island.Invite.Invited.Word.Deny")))).create()))));
}
Invite invite = plugin.getInviteManager().createInvite(targetPlayer, player, island.getOwnerUUID(), respondTime);

View File

@ -94,7 +94,7 @@ public class OwnerCommand extends SubCommand {
playerData.setConfirmation(Confirmation.Ownership);
playerData.setConfirmationTime(confirmationTime);
player.spigot().sendMessage(new ChatComponent(configLoad.getString("Command.Island.Ownership.Confirmation.Confirm.Message").replace("%player", targetPlayerName).replace("%time", "" + confirmationTime) + " ", false, null, null, null).addExtra(new ChatComponent(configLoad.getString("Command.Island.Ownership.Confirmation.Confirm.Word.Confirm").toUpperCase(), true, ChatColor.RED, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/island confirm"), new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Confirmation.Confirm.Word.Tutorial"))).create()))));
player.spigot().sendMessage(new ChatComponent(messageManager.replaceMessage(player, configLoad.getString("Command.Island.Ownership.Confirmation.Confirm.Message").replace("%player", targetPlayerName).replace("%time", "" + confirmationTime) + " "), false, null, null, null).addExtra(new ChatComponent(configLoad.getString("Command.Island.Ownership.Confirmation.Confirm.Word.Confirm").toUpperCase(), true, ChatColor.RED, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/island confirm"), new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Confirmation.Confirm.Word.Tutorial"))).create()))));
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
}
}

View File

@ -0,0 +1,144 @@
package me.goodandevil.skyblock.command.commands.admin;
import java.io.File;
import java.io.IOException;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import me.goodandevil.skyblock.Main;
import me.goodandevil.skyblock.command.CommandManager;
import me.goodandevil.skyblock.command.SubCommand;
import me.goodandevil.skyblock.command.CommandManager.Type;
import me.goodandevil.skyblock.config.FileManager;
import me.goodandevil.skyblock.config.FileManager.Config;
import me.goodandevil.skyblock.island.Island;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Location;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.message.MessageManager;
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.NumberUtil;
import me.goodandevil.skyblock.utils.OfflinePlayer;
import me.goodandevil.skyblock.utils.version.Sounds;
import me.goodandevil.skyblock.utils.world.WorldBorder;
public class SetSizeCommand extends SubCommand {
private final Main plugin;
private String info;
public SetSizeCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
MessageManager messageManager = plugin.getMessageManager();
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
FileManager fileManager = plugin.getFileManager();
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (player.hasPermission("skyblock.admin.setsize") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*")) {
if (args.length == 2) {
if (args[1].matches("[0-9]+")) {
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
UUID islandOwnerUUID;
String targetPlayerName;
if (targetPlayer == null) {
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
islandOwnerUUID = targetPlayerOffline.getOwner();
targetPlayerName = targetPlayerOffline.getName();
} else {
islandOwnerUUID = playerDataManager.getPlayerData(player).getOwner();
targetPlayerName = targetPlayer.getName();
}
int size = Integer.valueOf(args[1]);
if (islandOwnerUUID == null) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.SetSize.Island.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
} else if (size < 50) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.SetSize.Size.Greater.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
} else if (size > 1000) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.SetSize.Size.Less.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
} else {
if (islandManager.containsIsland(islandOwnerUUID)) {
Island island = islandManager.getIsland(islandOwnerUUID);
island.setSize(size);
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.WorldBorder.Enable")) {
for (Player all : Bukkit.getOnlinePlayers()) {
if (island.isRole(Role.Member, all.getUniqueId()) || island.isRole(Role.Operator, all.getUniqueId()) || island.isRole(Role.Owner, all.getUniqueId()) || island.getVisit().isVisitor(all.getUniqueId())) {
WorldBorder.send(all, island.getSize() + 2.5, island.getLocation(Location.World.Normal, Location.Environment.Island));
}
}
}
} else {
File configFile = new File(plugin.getDataFolder().toString() + "/island-data", islandOwnerUUID.toString() + ".yml");
FileConfiguration islandConfigLoad = YamlConfiguration.loadConfiguration(configFile);
islandConfigLoad.set("Size", size);
try {
islandConfigLoad.save(configFile);
} catch (IOException e) {
e.printStackTrace();
}
}
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.SetSize.Set.Message").replace("%player", targetPlayerName).replace("%size", NumberUtil.formatNumber(size)));
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
}
} else {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.SetSize.Numerical.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.SetSize.Invalid.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.SetSize.Permission.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "setsize";
}
@Override
public String getInfo() {
return info;
}
@Override
public SubCommand setInfo(String info) {
this.info = info;
return this;
}
@Override
public String[] getAliases() {
return new String[0];
}
@Override
public Type getType() {
return CommandManager.Type.Admin;
}
}

View File

@ -46,7 +46,7 @@ public class InviteTask extends BukkitRunnable {
Player targetPlayer = Bukkit.getServer().getPlayer(invite.getOwnerUUID());
if (targetPlayer != null) {
targetPlayer.spigot().sendMessage(new ChatComponent(configLoad.getString("Command.Island.Invite.Invited.Sender.Expired.Message").replace("%player", all.getName()) + " ", false, null, null, null).addExtra(new ChatComponent(configLoad.getString("Command.Island.Invite.Invited.Word.Resend").toUpperCase(), true, ChatColor.AQUA, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/island invite " + all.getName()), new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Word.Tutorial").replace("%action", configLoad.getString("Command.Island.Invite.Invited.Word.Resend")))).create()))));
targetPlayer.spigot().sendMessage(new ChatComponent(messageManager.replaceMessage(targetPlayer, configLoad.getString("Command.Island.Invite.Invited.Sender.Expired.Message").replace("%player", all.getName()) + " "), false, null, null, null).addExtra(new ChatComponent(configLoad.getString("Command.Island.Invite.Invited.Word.Resend").toUpperCase(), true, ChatColor.AQUA, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/island invite " + all.getName()), new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Word.Tutorial").replace("%action", configLoad.getString("Command.Island.Invite.Invited.Word.Resend")))).create()))));
soundManager.playSound(targetPlayer, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}

View File

@ -34,6 +34,7 @@ import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.utils.StringUtil;
import me.goodandevil.skyblock.visit.Visit;
import me.goodandevil.skyblock.visit.VisitManager;
import me.goodandevil.skyblock.world.WorldManager;
public class Island {
@ -49,14 +50,15 @@ public class Island {
public Island(UUID ownerUUID, org.bukkit.Location islandNormalLocation, org.bukkit.Location islandNetherLocation) {
this.plugin = Main.getInstance();
FileManager fileManager = plugin.getFileManager();
IslandManager islandManager = plugin.getIslandManager();
WorldManager worldManager = plugin.getWorldManager();
FileManager fileManager = plugin.getFileManager();
this.ownerUUID = ownerUUID;
this.size = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Size");;
this.size = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Size.Minimum");
if (this.size > 1000) {
this.size = 100;
this.size = 50;
}
islandLocations.add(new Location(Location.World.Normal, Location.Environment.Island, islandNormalLocation));
@ -72,10 +74,19 @@ public class Island {
size = configLoad.getInt("Size");
}
islandLocations.add(new Location(Location.World.Normal, Location.Environment.Main, fileManager.getLocation(config, "Location.Normal.Spawn.Main", true)));
islandLocations.add(new Location(Location.World.Nether, Location.Environment.Main, fileManager.getLocation(config, "Location.Nether.Spawn.Main", true)));
islandLocations.add(new Location(Location.World.Normal, Location.Environment.Visitor, fileManager.getLocation(config, "Location.Normal.Spawn.Visitor", true)));
islandLocations.add(new Location(Location.World.Nether, Location.Environment.Visitor, fileManager.getLocation(config, "Location.Nether.Spawn.Visitor", true)));
for (Location.World worldList : Location.World.values()) {
for (Location.Environment environmentList : Location.Environment.values()) {
if (environmentList != Location.Environment.Island) {
Location spawnLocation = new Location(worldList, environmentList, fileManager.getLocation(config, "Location." + worldList.name() + ".Spawn." + environmentList.name(), true));
if (spawnLocation.getLocation().getWorld() == null) {
spawnLocation.getLocation().setWorld(worldManager.getWorld(worldList));
}
islandLocations.add(spawnLocation);
}
}
}
Config settingsConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "settings.yml"));
@ -107,7 +118,6 @@ public class Island {
configFile = config.getFile();
FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set("Size", size);
configLoad.set("Visitor.Open", mainConfigLoad.getBoolean("Island.Visitor.Open"));
configLoad.set("Biome.Type", mainConfigLoad.getString("Island.Biome.Default.Type").toUpperCase());
configLoad.set("Weather.Synchronised", mainConfigLoad.getBoolean("Island.Weather.Default.Synchronised"));
@ -179,6 +189,15 @@ public class Island {
return size;
}
public void setSize(int size) {
if (size > 1000 || size < 0) {
size = 50;
}
this.size = size;
plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")).getFileConfiguration().set("Size", size);
}
public double getRadius() {
return (size / 2) + 0.5;
}

View File

@ -45,6 +45,7 @@ import me.goodandevil.skyblock.utils.world.LocationUtil;
import me.goodandevil.skyblock.utils.world.WorldBorder;
import me.goodandevil.skyblock.utils.world.block.BlockDegreesType;
import me.goodandevil.skyblock.visit.VisitManager;
import me.goodandevil.skyblock.world.WorldManager;
public class IslandManager {
@ -147,6 +148,33 @@ public class IslandManager {
e.printStackTrace();
}
Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
int minimumSize = configLoad.getInt("Island.Size.Minimum");
int maximumSize = configLoad.getInt("Island.Size.Maximum");
if (minimumSize < 0 || minimumSize > 1000) {
minimumSize = 50;
}
if (maximumSize < 0 || maximumSize > 1000) {
maximumSize = 100;
}
for (int i = maximumSize; i > minimumSize; i--) {
if (player.hasPermission("skyblock.size." + i) || player.hasPermission("skyblock.*")) {
island.setSize(i);
break;
}
}
}
});
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
@ -175,12 +203,12 @@ public class IslandManager {
scoreboard.run();
}
new BukkitRunnable() {
Bukkit.getServer().getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
player.teleport(island.getLocation(Location.World.Normal, Location.Environment.Main));
}
}.runTask(plugin);
});
if (NMSUtil.getVersionNumber() < 13) {
Bukkit.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
@ -316,7 +344,9 @@ public class IslandManager {
}
public void loadIsland(UUID uuid) {
WorldManager worldManager = plugin.getWorldManager();
FileManager fileManager = plugin.getFileManager();
UUID islandOwnerUUID = null;
if (isIslandExist(uuid)) {
@ -335,8 +365,17 @@ public class IslandManager {
Config config = fileManager.getConfig(new File(configFile, islandOwnerUUID.toString() + ".yml"));
org.bukkit.Location islandNormalLocation = fileManager.getLocation(config, "Location.Normal.Island", true);
if (islandNormalLocation.getWorld() == null) {
islandNormalLocation.setWorld(worldManager.getWorld(Location.World.Normal));
}
org.bukkit.Location islandNetherLocation = fileManager.getLocation(config, "Location.Nether.Island", true);
if (islandNetherLocation.getWorld() == null) {
islandNetherLocation.setWorld(worldManager.getWorld(Location.World.Nether));
}
Island island = new Island(islandOwnerUUID, new org.bukkit.Location(islandNormalLocation.getWorld(), islandNormalLocation.getBlockX(), 72, islandNormalLocation.getBlockZ()), new org.bukkit.Location(islandNetherLocation.getWorld(), islandNetherLocation.getBlockX(), 72, islandNetherLocation.getBlockZ()));
islandStorage.put(islandOwnerUUID, island);

View File

@ -0,0 +1,34 @@
package me.goodandevil.skyblock.menus;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
public class Information implements Listener {
private static Information instance;
public static Information getInstance(){
if(instance == null) {
instance = new Information();
}
return instance;
}
public void open(Player player) {
}
public class Viewer {
private String name;
public Viewer(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
}

View File

@ -23,4 +23,14 @@ public class MessageManager {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', message));
}
public String replaceMessage(Player player, String message) {
PlaceholderManager placeholderManager = plugin.getPlaceholderManager();
if (placeholderManager.isPlaceholderAPIEnabled()) {
message = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, message.replace("&", "clr")).replace("clr", "&");
}
return message;
}
}

View File

@ -11,7 +11,6 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import me.goodandevil.skyblock.Main;
import me.goodandevil.skyblock.config.FileManager;
@ -176,12 +175,20 @@ public final class LocationUtil {
if (config.getFileConfiguration().getString("Location.Spawn") == null) {
Bukkit.getServer().getLogger().log(Level.WARNING, "SkyBlock | Error: A spawn point hasn't been set.");
} else {
new BukkitRunnable() {
Location spawnLocation = fileManager.getLocation(config, "Location.Spawn", true);
if (spawnLocation.getWorld() == null) {
Bukkit.getServer().getLogger().log(Level.WARNING, "SkyBlock | Error: The world for the spawn point is not loaded or no longer exists.");
return;
}
Bukkit.getServer().getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
player.teleport(fileManager.getLocation(config, "Location.Spawn", true));
}
}.runTask(plugin);
});
}
}
}