Leaderboard

# Players will now have to be at an Island to add or remove a vote if Island voting is enabled. You can change the error messages in the language file.
# Added 'DragonEggUse' setting to the settings menu which allows players to interact with Dragon Eggs or not or prevent them from teleporting.
# Added the path in the language configuration file to change the description of the '/island leaderboard' command.
# Added the option in the configuration file to change the reset time for the Leaderboard.
# Fixed exception when changing the option in the configuration file to print a list of all the commands.
# Fixed signature not updating in the 'Visitor Menu' when changing an Island signature.
# Fixed Multiverse-Core error message when setting the generator of an Island world.
# Fixed help commands printing backslash at the end of the command aliases.
# Fixed skulls not displaying skin textures for the menus in 1.8-1.12.
# Fixed biome not changing when creating an Island.
# Fixed generators only generating one material.
This commit is contained in:
Unknown 2018-11-23 13:30:47 +00:00
parent cd4b8368ab
commit 5b62969a6a
25 changed files with 2905 additions and 71 deletions

181
config.yml Normal file
View File

@ -0,0 +1,181 @@
Command:
Help:
# Lists all commands rather than pages.
List: false
# Shows all aliases of the commands.
Aliases:
Enable: true
Sound:
# When disabled all sounds will be disabled.
Enable: true
Island:
# The size of an Island when created.
# [!] If you go over 1000, the size of the Island will be 100.
Size: 100
Creation:
Cooldown:
# When enabled cooldown will start when a player creates an Island.
Creation:
Enable: true
# When enabled cooldown will start when a player deletes their Island.
Deletion:
Enable: true
Time: 300
World:
# [!] The Island height is 72 blocks.
# Delete the Island world when changing the liquid option.
Normal:
Name: "island_normal_world"
Liquid:
Enable: false
Height: 60
Nether:
Name: "island_nether_world"
Enable: true
Liquid:
Enable: false
Height: 60
Member:
# Max amount of players allowed to be in a team.
Capacity: 12
WorldBorder:
# Generates a worldborder around Islands.
# [!] WorldBorders will not show in Nether world due to centring bug
# with some Spigot builds.
Enable: true
# Prevent blocks being placed that would go outside of the Island border
# Pistons | Dispensers | Liquid Flow
Block: true
Spawn:
# Prevents blocks being placed inside the location where players spawn on
# an Island. When setting the spawn points, this option when enabled will
# require the player to position themselves at the centre of the block.
# [!] Recommended to use especially to prevent players glitching in blocks
# and to prevent liquid flow at spawn point.
Protection: true
Block:
Piston:
# Prevent Piston blocks being retracted or extended when connected to a circuit
# [!] Prevents Pistons extending out of Island border bug
Connected:
Retract: false
Extent: false
Leaderboard:
Reset:
# Time until Leaderboard resets
Time: 300
Invite:
# Time until Island invite expires
Time: 300
Visitor:
# When an Island is unloaded if enabled players won't be able to visit the Island
# even if it's open.
# [!] Enabling will prevent possible memory leak issues affecting performance.
Unload: false
# Upon Island creation is the Island open to visit?
Open: false
# Allow players to vote for Islands. This will filter Islands with more votes first
# in the Visit Island menu.
Vote: true
Welcome:
# When disabled Island owners or operators will not be able to set a Welcome Message
# and visitors will not see the Welcome Message.
Enable: true
# Maximum lines allowed for Welcome Message
Lines: 6
# Length allowed for each line
Length: 30
Signature:
# When disabled Island owners or operators will not be able to set a Signature and
# a Signature will not be visible in the Island Visit menu.
Enable: true
# Maximum lines allowed for Signature
Lines: 6
# Length allowed for each line
Length: 30
# Max amount of players allowed at a Island. This also includes Island Members.
# [!] Set to -1 for unlimited capacity.
Capacity: 25
# Allow Island Operators or Owners to ban players from their Island.
Banning: true
Biome:
# Default Biome set when a player creates an Island
# Biomes Available:
# PLAINS | FOREST | SWAMPLAND | DESERT | COLD_BEACH
# JUNGLE | ROOFED_JUNGLE
Default:
Type: Plains
Cooldown: 900
Weather:
Default:
# The weather and time will operate the same weather and time as the world.
# If disabled, the weather and time will be fixed to the weather and time
# options.
Synchronised: true
# [!] Make sure the time is one of the choices below
# Choices: 0 | 1000 | 6000 | 12000 | 13000 | 18000
Time: 6000
Weather: Clear
# Prevents ice and snow layer blocks being set in snowy conditions.
# [!] Recommended to keep this disabled to prevent confusion if island weather
# and time is not synchronised.
IceAndSnow: false
Time:
# When the Island is not synchronised with the time of the World, should the
# time cycle or be fixed.
Cycle: false
Levelling:
# Island Level Points divided by value
Division: 100
# Time until Island level rescan expires
Cooldown: 60
Confirmation:
# Time until confirmation expires for island ownership and island deletion
# confirmations.
Timeout: 10
Ownership:
Transfer:
Role:
# When Island ownership is transfer to a different player the previous
# Island owner will become an operator.
Operator: true
Password:
# When ownership has been assigned to a player the Island password will
# be reset.
Reset: true
Void:
Teleport:
# Prevents players from being killed by the Void when at an Island.
Enable: true
# The Y position that the player is teleported when reached.
Offset: 30
Liquid:
Teleport:
# Teleports the player back to the Island if they enter the liquid if world is a
# liquid world.
Enable: true
Death:
AutoRespawn: true
Respawn:
# When a Player respawns after dying at an Island decide where they respawn.
# [!] If Enabled Players will respawn at the Island they died at. If Disabled
# Players will respawn at the Spawn location.
Island: true
Admin:
Structure:
# Item Material used to select positions for a structure.
Selector: "DIAMOND_AXE"
Scoreboard:
Enable: true
Generator:
Enable: true
# Stuff you shouldn't change
World:
Normal:
nextAvailableLocation:
x: 0.0
z: 0.0
Nether:
nextAvailableLocation:
x: 0.0
z: 0.0

17
generators.yml Normal file
View File

@ -0,0 +1,17 @@
Generators:
Default:
Name: Default
Permission: false
Materials:
COBBLESTONE:
Chance: 60
COAL_ORE:
Chance: 15
IRON_ORE:
Chance: 10
GOLD_ORE:
Chance: 8
EMERALD_ORE:
Chance: 5
DIAMOND_ORE:
Chance: 2

2055
language.yml Normal file

File diff suppressed because it is too large Load Diff

14
levelling.yml Normal file
View File

@ -0,0 +1,14 @@
# Required:
# Material Name
# Points Earned
Materials:
WOOD_BUTTON:
Points: 1
GRANITE:
Points: 10
GRASS:
Points: 5
OAK_LOG:
Points: 100
ALLIUM:
Points: 30

12
plugin.yml Normal file
View File

@ -0,0 +1,12 @@
name: SkyBlock
main: me.goodandevil.skyblock.Main
version: 21
api-version: 1.13
description: A unique SkyBlock plugin
author: GoodAndEvil
softdepend: [PlaceholderAPI, MVdWPlaceholderAPI]
loadbefore: [Multiverse-Core]
commands:
island:
description: Island command
aliases: [is]

104
settings.yml Normal file
View File

@ -0,0 +1,104 @@
Visitor:
Destroy: false
Place: false
Anvil: false
ArmorStand: false
Beacon: false
Bed: false
AnimalBreeding: false
Brewing: false
Bucket: false
WaterCollection: false
Storage: false
Workbench: false
Crop: false
Door: false
Gate: false
Projectile: false
Enchant: false
Fire: false
Furnace: false
HorseInventory: false
MobRiding: false
MobHurting: false
MobTaming: true
Leash: false
LeverButton: false
Milking: false
Jukebox: false
PressurePlate: false
Redstone: false
Shearing: false
Trading: false
ItemDrop: false
ItemPickup: false
Fishing: false
DropperDispenser: false
SpawnEgg: false
Cake: false
DragonEggUse: false
MinecartBoat: false
Portal: false
Hopper: false
Member:
Destroy: true
Place: true
Anvil: true
ArmorStand: true
Beacon: true
Bed: true
AnimalBreeding: true
Brewing: true
Bucket: true
WaterCollection: true
Storage: true
Workbench: true
Crop: true
Door: true
Gate: true
Projectile: true
Enchant: true
Fire: true
Furnace: true
HorseInventory: true
MobRiding: true
MobHurting: true
MobTaming: true
Leash: true
LeverButton: true
Milking: true
Jukebox: true
PressurePlate: true
Redstone: true
Shearing: true
Trading: true
ItemDrop: true
ItemPickup: true
Fishing: true
DropperDispenser: true
SpawnEgg: true
MinecartBoat: true
Cake: true
DragonEggUse: true
Portal: true
Hopper: true
Operator:
Invite: true
Kick: true
Ban: true
Unban: true
Visitor: true
Member: true
Island: false
MainSpawn: false
VisitorSpawn: true
Biome: true
Weather: true
Owner:
NaturalMobSpawning: true
MobGriefing: false
PvP: false
Explosions: false
FireSpread: true
LeafDecay: true
KeepItemsOnDeath: true

View File

@ -14,6 +14,7 @@ import me.goodandevil.skyblock.confirmation.ConfirmationTask;
import me.goodandevil.skyblock.generator.GeneratorManager;
import me.goodandevil.skyblock.invite.InviteManager;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.leaderboard.LeaderboardManager;
import me.goodandevil.skyblock.levelling.LevellingManager;
import me.goodandevil.skyblock.listeners.Block;
import me.goodandevil.skyblock.listeners.Bucket;
@ -34,6 +35,7 @@ import me.goodandevil.skyblock.menus.Bans;
import me.goodandevil.skyblock.menus.Biome;
import me.goodandevil.skyblock.menus.ControlPanel;
import me.goodandevil.skyblock.menus.Creator;
import me.goodandevil.skyblock.menus.Leaderboard;
import me.goodandevil.skyblock.menus.Levelling;
import me.goodandevil.skyblock.menus.Members;
import me.goodandevil.skyblock.menus.Ownership;
@ -75,6 +77,7 @@ public class Main extends JavaPlugin {
private SoundManager soundManager;
private GeneratorManager generatorManager;
private PlaceholderManager placeholderManager;
private LeaderboardManager leaderboardManager;
@Override
public void onEnable() {
@ -106,6 +109,8 @@ public class Main extends JavaPlugin {
placeholderManager = new PlaceholderManager(this);
placeholderManager.registerPlaceholders();
leaderboardManager = new LeaderboardManager(this);
new PlaytimeTask(playerDataManager, islandManager).runTaskTimerAsynchronously(this, 0L, 20L);
new VisitTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
new ConfirmationTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
@ -140,6 +145,7 @@ public class Main extends JavaPlugin {
pluginManager.registerEvents(new ControlPanel(), this);
pluginManager.registerEvents(new Creator(), this);
pluginManager.registerEvents(new Structure(), this);
pluginManager.registerEvents(new Leaderboard(), this);
pluginManager.registerEvents(new me.goodandevil.skyblock.menus.admin.Levelling(), this);
pluginManager.registerEvents(new me.goodandevil.skyblock.menus.admin.Creator(), this);
@ -241,6 +247,10 @@ public class Main extends JavaPlugin {
return placeholderManager;
}
public LeaderboardManager getLeaderboardManager() {
return leaderboardManager;
}
@Override
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
return new VoidGenerator();

View File

@ -57,9 +57,13 @@ public class BiomeManager {
Location location = island.getLocation(me.goodandevil.skyblock.island.Location.World.Normal, me.goodandevil.skyblock.island.Location.Environment.Island);
for (Location locationList : LocationUtil.getLocations(new Location(location.getWorld(), location.getBlockX() - island.getRadius(), 0, location.getBlockZ() - island.getRadius()), new Location(location.getWorld(), location.getBlockX() + island.getRadius(), 256, location.getBlockZ() + island.getRadius()))) {
try {
try {
Block block = locationList.getBlock();
if (!block.getChunk().isLoaded()) {
block.getChunk().load(true);
}
if (block != null) {
block.setBiome(biome);

View File

@ -33,6 +33,7 @@ import me.goodandevil.skyblock.command.commands.DenyCommand;
import me.goodandevil.skyblock.command.commands.InviteCommand;
import me.goodandevil.skyblock.command.commands.KickAllCommand;
import me.goodandevil.skyblock.command.commands.KickCommand;
import me.goodandevil.skyblock.command.commands.LeaderboardCommand;
import me.goodandevil.skyblock.command.commands.LeaveCommand;
import me.goodandevil.skyblock.command.commands.LevelCommand;
import me.goodandevil.skyblock.command.commands.MembersCommand;
@ -83,6 +84,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
List<SubCommand> subCommands = new ArrayList<>();
subCommands.add(new VisitCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Visit.Info.Message"))));
subCommands.add(new ControlPanelCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.ControlPanel.Info.Message"))));
subCommands.add(new LeaderboardCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Leaderboard.Info.Message"))));
subCommands.add(new CreateCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Create.Info.Message"))));
subCommands.add(new DeleteCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Delete.Info.Message"))));
subCommands.add(new TeleportCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Teleport.Info.Message"))));
@ -277,10 +279,6 @@ public class CommandManager implements CommandExecutor, TabCompleter {
int pageSize = 7;
if (page == -1) {
pageSize = 1000;
}
int nextEndIndex = subCommands.get(type).size() - page * pageSize, index = page * pageSize - pageSize, endIndex = index >= subCommands.get(type).size() ? subCommands.get(type).size() - 1 : index + pageSize;
boolean showAlises = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Command.Help.Aliases.Enable");
@ -307,27 +305,50 @@ public class CommandManager implements CommandExecutor, TabCompleter {
suffix = ChatColor.translateAlternateColorCodes('&', sections[1]);
}
for (; index < endIndex; index++) {
if (subCommands.get(type).size() > index) {
SubCommand subCommandFromIndex = subCommands.get(type).get(index);
if (page == -1) {
for (int i = 0; i < subCommands.get(type).size(); i++) {
SubCommand subCommandFromIndex = subCommands.get(type).get(i);
String commandAliases = "";
if (showAlises) {
for (int i = 0; i < subCommandFromIndex.getAliases().length; i++) {
if (i == 0) {
for (int i1 = 0; i1 < subCommandFromIndex.getAliases().length; i1++) {
if (i1 == 0) {
commandAliases = "/";
}
if (i == subCommandFromIndex.getAliases().length) {
commandAliases = commandAliases + subCommandFromIndex.getAliases()[i];
if (i1 == subCommandFromIndex.getAliases().length-1) {
commandAliases = commandAliases + subCommandFromIndex.getAliases()[i1];
} else {
commandAliases = commandAliases + subCommandFromIndex.getAliases()[i] + "/";
commandAliases = commandAliases + subCommandFromIndex.getAliases()[i1] + "/";
}
}
}
player.spigot().sendMessage(new ChatComponent(prefix.replace("%info", subCommandFromIndex.getInfo()) + "/island " + subCommandText + subCommandFromIndex.getName() + commandAliases + suffix.replace("%info", subCommandFromIndex.getInfo()), false, null, null, new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(subCommandFromIndex.getInfo()).create())).getTextComponent());
}
} else {
for (; index < endIndex; index++) {
if (subCommands.get(type).size() > index) {
SubCommand subCommandFromIndex = subCommands.get(type).get(index);
String commandAliases = "";
if (showAlises) {
for (int i = 0; i < subCommandFromIndex.getAliases().length; i++) {
if (i == 0) {
commandAliases = "/";
}
if (i == subCommandFromIndex.getAliases().length) {
commandAliases = commandAliases + subCommandFromIndex.getAliases()[i];
} else {
commandAliases = commandAliases + subCommandFromIndex.getAliases()[i] + "/";
}
}
}
player.spigot().sendMessage(new ChatComponent(prefix.replace("%info", subCommandFromIndex.getInfo()) + "/island " + subCommandText + subCommandFromIndex.getName() + commandAliases + suffix.replace("%info", subCommandFromIndex.getInfo()), false, null, null, new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(subCommandFromIndex.getInfo()).create())).getTextComponent());
}
}
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', helpLines));

View File

@ -0,0 +1,66 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
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.menus.Leaderboard;
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
import me.goodandevil.skyblock.utils.version.Sounds;
public class LeaderboardCommand extends SubCommand {
private final Main plugin;
private String info;
public LeaderboardCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
if (playerDataManager.hasPlayerData(player)) {
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
playerDataManager.getPlayerData(player).setViewer(new Leaderboard.Viewer(Leaderboard.Viewer.Type.Browse));
} else {
playerDataManager.getPlayerData(player).setViewer(new Leaderboard.Viewer(Leaderboard.Viewer.Type.Level));
}
Leaderboard.getInstance().open(player);
plugin.getSoundManager().playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "leaderboard";
}
@Override
public String getInfo() {
return info;
}
@Override
public SubCommand setInfo(String info) {
this.info = info;
return this;
}
@Override
public String[] getAliases() {
return new String[] { "lb", "top" };
}
@Override
public Type getType() {
return CommandManager.Type.Default;
}
}

View File

@ -51,7 +51,7 @@ public class FileManager {
File configFile = configFiles.get(configFileList);
if (configFile.exists()) {
if (configFileList.equals("config.yml") || configFileList.equals("language.yml")) {
if (configFileList.equals("config.yml") || configFileList.equals("language.yml") || configFileList.equals("settings.yml")) {
FileChecker fileChecker = new FileChecker(plugin, configFileList);
fileChecker.loadSections();
fileChecker.compareFiles();

View File

@ -142,8 +142,8 @@ public class GeneratorManager {
for (int index = 0; index < generator.getGeneratorMaterials().size(); index++) {
GeneratorMaterial generatorMaterial = generator.getGeneratorMaterials().get(index);
for (int i = 0; i < generatorMaterial.getChance(); i++ ) {
chances.put(i, index);
for (int i = 0; i < generatorMaterial.getChance(); i++) {
chances.put(chances.size() + 1, index);
}
}

View File

@ -78,10 +78,12 @@ public class Island {
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)));
Config settingsConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "settings.yml"));
for (Settings.Role roleList : Settings.Role.values()) {
HashMap<String, Settings> roleSettings = new HashMap<>();
for (String settingList : configLoad.getConfigurationSection("Settings." + roleList.name()).getKeys(false)) {
for (String settingList : settingsConfig.getFileConfiguration().getConfigurationSection(WordUtils.capitalize(roleList.name().toLowerCase())).getKeys(false)) {
roleSettings.put(settingList, new Settings(configLoad.getBoolean("Settings." + roleList.name() + "." + settingList)));
}
@ -142,8 +144,6 @@ public class Island {
islandManager.setSpawnProtection(islandNetherLocation);
}
}.runTask(plugin);
//plugin.getBiomeManager().setBiome(null, islandNormalLocation, Biome.valueOf(mainConfigLoad.getString("Island.Biome.Default.Type").toUpperCase()));
}
level = new Level(this, plugin);
@ -441,6 +441,10 @@ public class Island {
FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set("Visitor." + message.name() + ".Message", islandMessage);
configLoad.set("Visitor." + message.name() + ".Author", author);
if (message == Message.Signature) {
getVisit().setSignature(islandMessage);
}
}
}

View File

@ -11,6 +11,7 @@ import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
@ -183,6 +184,13 @@ public class IslandManager {
player.teleport(island.getLocation(Location.World.Normal, Location.Environment.Main));
}
}.runTask(plugin);
Bukkit.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
plugin.getBiomeManager().setBiome(null, island, Biome.valueOf(fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getString("Island.Biome.Default.Type").toUpperCase()));
}
}, 20L);
}
public void giveIslandOwnership(UUID uuid) {

View File

@ -1,47 +1,35 @@
package me.goodandevil.skyblock.leaderboard;
import java.util.ArrayList;
import java.util.List;
import me.goodandevil.skyblock.visit.Visit;
public class Leaderboard {
private String playerName;
private Type type;
private final Visit visit;
private int position;
private int level;
private int points;
private int votes;
public Leaderboard(Type type, Visit visit, int position) {
this.type = type;
this.visit = visit;
this.position = position;
}
private List<String> members;
public Type getType() {
return type;
}
public Leaderboard(String playerName, int level, int points, int votes, List<String> members) {
this.playerName = playerName;
this.level = level;
this.points = points;
this.votes = votes;
this.members = members;
public Visit getVisit() {
return visit;
}
public int getPosition() {
return position;
}
public enum Type {
Level,
Votes;
if (members == null) {
this.members = new ArrayList<>();
}
}
public String getPlayerName() {
return playerName;
}
public int getLevel() {
return level;
}
public int getPoints() {
return points;
}
public int getVotes() {
return votes;
}
public List<String> getMembers() {
return members;
}
}

View File

@ -1,10 +1,71 @@
package me.goodandevil.skyblock.leaderboard;
public class LeaderboardManager {
import java.io.File;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import me.goodandevil.skyblock.Main;
import me.goodandevil.skyblock.visit.Visit;
import me.goodandevil.skyblock.visit.VisitManager;
public class LeaderboardManager {
private final Main plugin;
public LeaderboardManager() {
private List<Leaderboard> leaderboardStorage = new ArrayList<>();
public LeaderboardManager(Main plugin) {
this.plugin = plugin;
new LeaderboardTask(plugin).runTaskTimerAsynchronously(plugin, 0L, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Leaderboard.Reset.Time") * 20);
resetLeaderboard();
}
public void resetLeaderboard() {
VisitManager visitManager = plugin.getVisitManager();
Map<UUID, Integer> islandLevels = new LinkedHashMap<>();
Map<UUID, Integer> islandVotes = new LinkedHashMap<>();
for (int i = 0; i < visitManager.getIslands().size(); i++) {
UUID ownerUUID = (UUID) visitManager.getIslands().keySet().toArray()[i];
Visit visit = visitManager.getIslands().get(ownerUUID);
islandLevels.put(ownerUUID, visit.getLevel());
islandVotes.put(ownerUUID, visit.getVoters().size());
}
for (int i = 0; i < 10; i++) {
if (islandLevels.size() != 0 && i <= islandLevels.size()-1) {
leaderboardStorage.add(new Leaderboard(Leaderboard.Type.Level, visitManager.getIsland((UUID) islandLevels.keySet().toArray()[i]), i));
}
if (islandVotes.size() != 0 && i <= islandVotes.size()-1) {
leaderboardStorage.add(new Leaderboard(Leaderboard.Type.Votes, visitManager.getIsland((UUID) islandLevels.keySet().toArray()[i]), i));
}
}
}
public void clearLeaderboard() {
leaderboardStorage.clear();
}
public List<Leaderboard> getLeaderboard(Leaderboard.Type type) {
List<Leaderboard> leaderboardIslands = new ArrayList<>();
for (Leaderboard leaderboardList : leaderboardStorage) {
if (leaderboardList.getType() == type) {
leaderboardIslands.add(leaderboardList);
}
}
return leaderboardIslands;
}
public List<Leaderboard> getLeaderboards() {
return leaderboardStorage;
}
}

View File

@ -0,0 +1,21 @@
package me.goodandevil.skyblock.leaderboard;
import org.bukkit.scheduler.BukkitRunnable;
import me.goodandevil.skyblock.Main;
public class LeaderboardTask extends BukkitRunnable {
private final Main plugin;
public LeaderboardTask(Main plugin) {
this.plugin = plugin;
}
@Override
public void run() {
LeaderboardManager leaderboardManager = plugin.getLeaderboardManager();
leaderboardManager.clearLeaderboard();
leaderboardManager.resetLeaderboard();
}
}

View File

@ -178,6 +178,15 @@ public class Interact implements Listener {
return;
}
} else if (event.getClickedBlock().getType() == Material.DRAGON_EGG) {
if (!islandManager.hasPermission(player, "DragonEggUse")) {
event.setCancelled(true);
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
}
} else if (event.getClickedBlock().getType() == Material.HOPPER) {
if (!islandManager.hasPermission(player, "Hopper")) {
event.setCancelled(true);

View File

@ -14,7 +14,6 @@ import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import me.goodandevil.skyblock.Main;
import me.goodandevil.skyblock.config.FileManager;
import me.goodandevil.skyblock.config.FileManager.Config;
import me.goodandevil.skyblock.utils.item.InventoryUtil;
import me.goodandevil.skyblock.utils.version.Materials;
@ -35,10 +34,8 @@ public class ControlPanel implements Listener {
public void open(Player player) {
Main plugin = Main.getInstance();
FileManager fileManager = plugin.getFileManager();
Config languageConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = languageConfig.getFileConfiguration();
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
InventoryUtil inv = new InventoryUtil(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.ControlPanel.Title")), null, 1);
inv.addItem(inv.createItem(Materials.OAK_DOOR.parseItem(), configLoad.getString("Menu.ControlPanel.Item.Teleport.Displayname"), configLoad.getStringList("Menu.ControlPanel.Item.Teleport.Lore"), null, null, null), 0);

View File

@ -0,0 +1,219 @@
package me.goodandevil.skyblock.menus;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.ItemStack;
import me.goodandevil.skyblock.Main;
import me.goodandevil.skyblock.config.FileManager;
import me.goodandevil.skyblock.config.FileManager.Config;
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.OfflinePlayer;
import me.goodandevil.skyblock.utils.item.InventoryUtil;
import me.goodandevil.skyblock.utils.item.SkullUtil;
import me.goodandevil.skyblock.utils.version.Materials;
import me.goodandevil.skyblock.utils.version.Sounds;
public class Leaderboard implements Listener {
private static Leaderboard instance;
public static Leaderboard getInstance(){
if(instance == null) {
instance = new Leaderboard();
}
return instance;
}
public void open(Player player) {
Main plugin = Main.getInstance();
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
FileManager fileManager = plugin.getFileManager();
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
Viewer viewer = (Viewer) playerDataManager.getPlayerData(player).getViewer();
InventoryUtil inv;
if (viewer.getType() == Viewer.Type.Browse) {
inv = new InventoryUtil(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard." + viewer.getType().name() + ".Title")), InventoryType.HOPPER, 1);
inv.addItem(inv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Leaderboard." + viewer.getType().name() + ".Item.Exit.Displayname"), null, null, null, null), 0, 4);
inv.addItem(inv.createItem(new ItemStack(Material.DIAMOND), configLoad.getString("Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Displayname").replace("%leaderboard", Viewer.Type.Level.name()), configLoad.getStringList("Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Lore"), inv.createItemLoreVariable(new String[] { "%leaderboard#" + Viewer.Type.Level.name() }), null, null), 1);
inv.addItem(inv.createItem(new ItemStack(Material.EMERALD), configLoad.getString("Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Displayname").replace("%leaderboard", Viewer.Type.Votes.name()), configLoad.getStringList("Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Lore"), inv.createItemLoreVariable(new String[] { "%leaderboard#" + Viewer.Type.Votes.name() }), null, null), 3);
} else {
inv = new InventoryUtil(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard.Leaderboard.Title").replace("%leaderboard", viewer.getType().name())), null, 6);
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
inv.addItem(inv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Return.Displayname"), null, null, null, null), 0, 8);
} else {
inv.addItem(inv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Exit.Displayname"), null, null, null, null), 0, 8);
}
List<me.goodandevil.skyblock.leaderboard.Leaderboard> leaderboardIslands = plugin.getLeaderboardManager().getLeaderboard(me.goodandevil.skyblock.leaderboard.Leaderboard.Type.valueOf(viewer.getType().name()));
for (int i = 0; i < leaderboardIslands.size(); i++) {
me.goodandevil.skyblock.leaderboard.Leaderboard leaderboard = leaderboardIslands.get(i);
me.goodandevil.skyblock.visit.Visit visit = leaderboard.getVisit();
int itemSlot = 0;
String playerName;
String[] playerTexture;
Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID());
if (targetPlayer == null) {
OfflinePlayer offlinePlayer = new OfflinePlayer(visit.getOwnerUUID());
playerName = offlinePlayer.getName();
playerTexture = offlinePlayer.getTexture();
} else {
playerName = targetPlayer.getName();
playerTexture = playerDataManager.getPlayerData(targetPlayer).getTexture();
}
if (leaderboard.getPosition() == 0) {
itemSlot = 13;
} else if (leaderboard.getPosition() == 1) {
itemSlot = 21;
} else if (leaderboard.getPosition() == 2) {
itemSlot = 22;
} else if (leaderboard.getPosition() == 3) {
itemSlot = 23;
} else if (leaderboard.getPosition() == 4) {
itemSlot = 29;
} else if (leaderboard.getPosition() == 5) {
itemSlot = 31;
} else if (leaderboard.getPosition() == 6) {
itemSlot = 33;
} else if (leaderboard.getPosition() == 7) {
itemSlot = 37;
} else if (leaderboard.getPosition() == 8) {
itemSlot = 40;
} else if (leaderboard.getPosition() == 9) {
itemSlot = 43;
}
List<String> itemLore = new ArrayList<>();
for (String itemLoreList : configLoad.getStringList("Menu.Leaderboard.Leaderboard.Item.Island." + viewer.getType().name() + ".Lore")) {
if (itemLoreList.contains("%signature")) {
if (visit.getSiganture() == null || visit.getSiganture().size() == 0) {
itemLore.add(configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Island.Word.Empty"));
} else {
for (String signatureList : visit.getSiganture()) {
itemLore.add(signatureList);
}
}
} else {
itemLore.add(itemLoreList);
}
}
inv.addItem(inv.createItem(SkullUtil.create(playerTexture[0], playerTexture[1]), configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Island.Displayname").replace("%position", "" + (leaderboard.getPosition() + 1)), itemLore, inv.createItemLoreVariable(new String[] { "%position#" + (leaderboard.getPosition() + 1), "%owner#" + playerName, "%level#" + visit.getLevel(), "%votes#" + visit.getVoters().size(), "%members#" + visit.getMembers() }), null, null), itemSlot);
}
int[] itemSlots = new int[] { 13, 21, 22, 23, 29, 31, 33, 37, 40, 43 };
for (int i = 0; i < itemSlots.length; i++) {
if (inv.getInventory().getItem(itemSlots[i]) == null) {
inv.addItem(inv.createItem(SkullUtil.create("gi+wnQt/y4Z6E9rn65iDWmt8vUOM2WXY66XvtydqDJZTzwgFrjVcx2c5YwdzvtOIRtiX2nZt4n2uWesUFKb59xS24YWbxCDXnalHhCpPFcIP58SQbCm9AYp3UPzkcRNWzuV4BddrS608QQZGyIFOUaLPOPasGITZu51VLcOKcTyFOCKu1QE2yRo1orTH8bWfdpE769BB/VYGdny0qJtm1amc12wGiVifMJRutZmYo2ZdA0APhIJVaNsPppNESVcbeBCvk60l4QK43C/p98/QEe5U6UJ6Z6N01pBQcswubMu8lCuPLasep+vX3v2K+Ui9jnTQNreGNIZPWVjf6V1GH4xMbbUVQJsoPdcaXG855VdzyoW+kyHdWYEojSn0qAY/moH6JCLnx6PLCv9mITSvOIUHq8ITet0M7Z9KALY5s6eg6VdA8TvClRy2TTm9tIRt//TJo5JxBoTYujawGNSR7ryODj2UEDQ2xOyWSagxAXZpispdrO5jHxRmBZUwX9vxnAp+CNWxifpu9sINJTlqYsT/KlGOJQC483gv5B6Nm5VBB1DRFmQkohzO6Wc2eDixgEbaU795GlLxrNaFfNjVH6Bwr1e7df2H3nE0P0bexs4wYdWplijn4gPyHwjT2LDBPGFQK3Vo2SlaXfPYbkIHX21c9qaz3eWHpLEXUBQfnWc=", "eyJ0aW1lc3RhbXAiOjE1MzE3MTcxNjY3MDAsInByb2ZpbGVJZCI6IjYwNmUyZmYwZWQ3NzQ4NDI5ZDZjZTFkMzMyMWM3ODM4IiwicHJvZmlsZU5hbWUiOiJNSEZfUXVlc3Rpb24iLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2QzNGUwNjNjYWZiNDY3YTVjOGRlNDNlYzc4NjE5Mzk5ZjM2OWY0YTUyNDM0ZGE4MDE3YTk4M2NkZDkyNTE2YTAifX19"), configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Empty.Displayname").replace("%position", "" + (i + 1)), configLoad.getStringList("Menu.Leaderboard.Leaderboard.Item.Empty.Lore"), inv.createItemLoreVariable(new String[] { "%position#" + (i + 1) }), null, null), itemSlots[i]);
}
}
}
player.openInventory(inv.getInventory());
}
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
ItemStack is = event.getCurrentItem();
if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) {
Main plugin = Main.getInstance();
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
SoundManager soundManager = plugin.getSoundManager();
FileManager fileManager = plugin.getFileManager();
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard." + Viewer.Type.Browse.name() + ".Title")))) {
event.setCancelled(true);
if ((event.getCurrentItem().getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard." + Viewer.Type.Browse.name() + ".Item.Exit.Displayname"))))) {
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
player.closeInventory();
} else if ((event.getCurrentItem().getType() == Material.DIAMOND) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard." + Viewer.Type.Browse.name() + ".Item.Leaderboard.Displayname").replace("%leaderboard", Viewer.Type.Level.name()))))) {
playerDataManager.getPlayerData(player).setViewer(new Viewer(Viewer.Type.Level));
open(player);
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
} else if ((event.getCurrentItem().getType() == Material.EMERALD) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard." + Viewer.Type.Browse.name() + ".Item.Leaderboard.Displayname").replace("%leaderboard", Viewer.Type.Votes.name()))))) {
playerDataManager.getPlayerData(player).setViewer(new Viewer(Viewer.Type.Votes));
open(player);
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
}
} else if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard.Leaderboard.Title").replace("%leaderboard", Viewer.Type.Level.name()))) || event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard.Leaderboard.Title").replace("%leaderboard", Viewer.Type.Votes.name())))) {
event.setCancelled(true);
if ((event.getCurrentItem().getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Exit.Displayname")))) {
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
player.closeInventory();
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Return.Displayname")))) {
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
playerDataManager.getPlayerData(player).setViewer(new Viewer(Viewer.Type.Browse));
open(player);
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
} else {
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
player.closeInventory();
}
return;
}
}
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F);
}
}
}
public static class Viewer {
private Type type;
public Viewer(Type type) {
this.type = type;
}
public Type getType() {
return type;
}
public enum Type {
Browse,
Level,
Votes;
}
}
}

View File

@ -129,6 +129,7 @@ public class Settings implements Listener {
inv.addItemStack(createItem(island, role, "DropperDispenser", Material.DISPENSER), 46);
inv.addItemStack(createItem(island, role, "SpawnEgg", Material.EGG), 47);
inv.addItemStack(createItem(island, role, "Cake", Material.CAKE), 48);
inv.addItemStack(createItem(island, role, "DragonEggUse", Material.DRAGON_EGG), 49);
inv.addItemStack(createItem(island, role, "MinecartBoat", Material.MINECART), 50);
inv.addItemStack(createItem(island, role, "Portal", Material.ENDER_PEARL), 51);
inv.addItemStack(createItem(island, role, "Hopper", Material.HOPPER), 52);

View File

@ -337,13 +337,31 @@ public class Visit implements Listener {
List<UUID> islandVotes = visit.getVoters();
if (islandVotes.contains(player.getUniqueId())) {
visit.removeVoter(player.getUniqueId());
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Vote.Removed.Message").replace("%player", targetPlayerName)));
soundManager.playSound(player, Sounds.EXPLODE.bukkitSound(), 1.0F, 1.0F);
for (Location.World worldList : Location.World.values()) {
if (LocationUtil.isLocationAtLocationRadius(player.getLocation(), island.getLocation(worldList, Location.Environment.Island), island.getRadius())) {
visit.removeVoter(player.getUniqueId());
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Vote.Removed.Message").replace("%player", targetPlayerName)));
soundManager.playSound(player, Sounds.EXPLODE.bukkitSound(), 1.0F, 1.0F);
return;
}
}
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Vote.Location.Remove.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
visit.addVoter(player.getUniqueId());
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Vote.Added.Message").replace("%player", targetPlayerName)));
soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
for (Location.World worldList : Location.World.values()) {
if (LocationUtil.isLocationAtLocationRadius(player.getLocation(), island.getLocation(worldList, Location.Environment.Island), island.getRadius())) {
visit.addVoter(player.getUniqueId());
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Vote.Added.Message").replace("%player", targetPlayerName)));
soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
return;
}
}
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Vote.Location.Add.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
open(player, (Visit.Type) playerData.getType(), (Visit.Sort) playerData.getSort());

View File

@ -11,6 +11,7 @@ import org.bukkit.inventory.meta.SkullMeta;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import me.goodandevil.skyblock.utils.version.Materials;
import me.goodandevil.skyblock.utils.version.NMSUtil;
public final class SkullUtil {
@ -67,7 +68,7 @@ public final class SkullUtil {
if (NMSUtil.getVersionNumber() > 12) {
is = new ItemStack(Material.valueOf("PLAYER_HEAD"));
} else {
is = new ItemStack(Material.valueOf("SKULL_ITEM"), 3);
is = Materials.LEGACY_SKULL_ITEM.getPostItem();
}
return is;

View File

@ -39,13 +39,25 @@ public class WorldManager {
if (normalWorld == null) {
Bukkit.getServer().getConsoleSender().sendMessage("SkyBlock | Info: Generating VoidWorld '" + normalWorldName + "'.");
normalWorld = WorldCreator.name(normalWorldName).type(WorldType.FLAT).environment(World.Environment.NORMAL).generator(new VoidGenerator()).createWorld();
registerMultiverse(normalWorldName, World.Environment.NORMAL);
Bukkit.getServer().getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
registerMultiverse(normalWorldName, World.Environment.NORMAL);
}
});
}
if (netherWorld == null) {
Bukkit.getServer().getConsoleSender().sendMessage("SkyBlock | Info: Generating VoidWorld '" + netherWorldName + "'.");
netherWorld = WorldCreator.name(netherWorldName).type(WorldType.FLAT).environment(World.Environment.NETHER).generator(new VoidGenerator()).createWorld();
registerMultiverse(netherWorldName, World.Environment.NETHER);
Bukkit.getServer().getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
registerMultiverse(netherWorldName, World.Environment.NETHER);
}
});
}
}

11
structures.yml Normal file
View File

@ -0,0 +1,11 @@
Structures:
Default:
File: "default.structure"
Name: "Default"
Displayname: "&a&lDefault"
Description:
- "&f&oDefault Island as an"
- "&f&oexample."
Permission: false
Item:
Material: GRASS_BLOCK