Initial commit

This commit is contained in:
TheCreeperCow 2018-11-22 16:00:42 +01:00
commit 976870a85d
192 changed files with 25803 additions and 0 deletions

144
.gitignore vendored Normal file
View File

@ -0,0 +1,144 @@
# Created by .ignore support plugin (hsz.mobi)
### Java template
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
### Eclipse template
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# CDT- autotools
.autotools
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Annotation Processing
.apt_generated/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet

13
.idea/misc.xml Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ComposerJsonPluginSettings">
<unboundedVersionInspectionSettings>
<excludedPackages />
</unboundedVersionInspectionSettings>
<customRepositories />
<composerUpdateOptions />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/SkyBlock.iml" filepath="$PROJECT_DIR$/SkyBlock.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

11
SkyBlock.iml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

177
config.yml Normal file
View File

@ -0,0 +1,177 @@
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
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

2003
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

11
plugin.yml Normal file
View File

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

102
settings.yml Normal file
View File

@ -0,0 +1,102 @@
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
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
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

@ -0,0 +1,248 @@
package me.goodandevil.skyblock;
import java.io.File;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import me.goodandevil.skyblock.ban.BanManager;
import me.goodandevil.skyblock.biome.BiomeManager;
import me.goodandevil.skyblock.command.CommandManager;
import me.goodandevil.skyblock.config.FileManager;
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.levelling.LevellingManager;
import me.goodandevil.skyblock.listeners.Block;
import me.goodandevil.skyblock.listeners.Bucket;
import me.goodandevil.skyblock.listeners.Chat;
import me.goodandevil.skyblock.listeners.Death;
import me.goodandevil.skyblock.listeners.Entity;
import me.goodandevil.skyblock.listeners.Interact;
import me.goodandevil.skyblock.listeners.Inventory;
import me.goodandevil.skyblock.listeners.Item;
import me.goodandevil.skyblock.listeners.Join;
import me.goodandevil.skyblock.listeners.Move;
import me.goodandevil.skyblock.listeners.Portal;
import me.goodandevil.skyblock.listeners.Projectile;
import me.goodandevil.skyblock.listeners.Quit;
import me.goodandevil.skyblock.listeners.Respawn;
import me.goodandevil.skyblock.listeners.Teleport;
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.Levelling;
import me.goodandevil.skyblock.menus.Members;
import me.goodandevil.skyblock.menus.Ownership;
import me.goodandevil.skyblock.menus.Rollback;
import me.goodandevil.skyblock.menus.Settings;
import me.goodandevil.skyblock.menus.Structure;
import me.goodandevil.skyblock.menus.Visit;
import me.goodandevil.skyblock.menus.Visitors;
import me.goodandevil.skyblock.menus.Weather;
import me.goodandevil.skyblock.menus.admin.Generator;
import me.goodandevil.skyblock.placeholder.PlaceholderManager;
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
import me.goodandevil.skyblock.playtime.PlaytimeTask;
import me.goodandevil.skyblock.scoreboard.ScoreboardManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.structure.StructureManager;
import me.goodandevil.skyblock.visit.VisitManager;
import me.goodandevil.skyblock.visit.VisitTask;
import me.goodandevil.skyblock.world.WorldManager;
import me.goodandevil.skyblock.world.generator.VoidGenerator;
public class Main extends JavaPlugin {
private static Main instance;
private FileManager fileManager;
private WorldManager worldManager;
private VisitManager visitManager;
private BanManager banManager;
private IslandManager islandManager;
//private CreationManager creationManager;
private PlayerDataManager playerDataManager;
private ScoreboardManager scoreboardManager;
private InviteManager inviteManager;
private BiomeManager biomeManager;
private LevellingManager levellingManager;
private CommandManager commandManager;
private StructureManager structureManager;
private SoundManager soundManager;
private GeneratorManager generatorManager;
private PlaceholderManager placeholderManager;
@Override
public void onEnable() {
instance = this;
fileManager = new FileManager(this);
worldManager = new WorldManager(this);
visitManager = new VisitManager(this);
banManager = new BanManager(this);
islandManager = new IslandManager(this);
//creationManager = new CreationManager(this);
playerDataManager = new PlayerDataManager(this);
if (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Scoreboard.Enable")) {
scoreboardManager = new ScoreboardManager(this);
}
inviteManager = new InviteManager(this);
biomeManager = new BiomeManager(this);
levellingManager = new LevellingManager(this);
commandManager = new CommandManager(this);
structureManager = new StructureManager(this);
soundManager = new SoundManager(this);
if (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Generator.Enable")) {
generatorManager = new GeneratorManager(this);
}
placeholderManager = new PlaceholderManager(this);
placeholderManager.registerPlaceholders();
new PlaytimeTask(playerDataManager, islandManager).runTaskTimerAsynchronously(this, 0L, 20L);
new VisitTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
new ConfirmationTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
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 Biome(), this);
pluginManager.registerEvents(new Weather(), this);
pluginManager.registerEvents(new Rollback(), this);
pluginManager.registerEvents(new Levelling(), this);
pluginManager.registerEvents(new Settings(), this);
pluginManager.registerEvents(new Members(), this);
pluginManager.registerEvents(new Ownership(), this);
pluginManager.registerEvents(new Visit(), this);
pluginManager.registerEvents(new Visitors(), this);
pluginManager.registerEvents(new Bans(), this);
pluginManager.registerEvents(new ControlPanel(), this);
pluginManager.registerEvents(new Creator(), this);
pluginManager.registerEvents(new Structure(), this);
pluginManager.registerEvents(new me.goodandevil.skyblock.menus.admin.Levelling(), this);
pluginManager.registerEvents(new me.goodandevil.skyblock.menus.admin.Creator(), this);
pluginManager.registerEvents(new Generator(), this);
}
@Override
public void onDisable() {
if (this.levellingManager != null) {
this.levellingManager.onDisable();
}
if (this.islandManager != null) {
this.islandManager.onDisable();
}
if (this.visitManager != null) {
this.visitManager.onDisable();
}
if (this.banManager != null) {
this.banManager.onDisable();
}
if (this.biomeManager != null) {
this.biomeManager.onDisable();
}
if (this.playerDataManager != null) {
this.playerDataManager.onDisable();
}
}
public static Main getInstance() {
return instance;
}
public FileManager getFileManager() {
return fileManager;
}
public WorldManager getWorldManager() {
return worldManager;
}
public VisitManager getVisitManager() {
return visitManager;
}
public BanManager getBanManager() {
return banManager;
}
public IslandManager getIslandManager() {
return islandManager;
}
/*public CreationManager getCreationManager() {
return creationManager;
}*/
public PlayerDataManager getPlayerDataManager() {
return playerDataManager;
}
public ScoreboardManager getScoreboardManager() {
return scoreboardManager;
}
public InviteManager getInviteManager() {
return inviteManager;
}
public BiomeManager getBiomeManager() {
return biomeManager;
}
public LevellingManager getLevellingManager() {
return levellingManager;
}
public CommandManager getCommandManager() {
return commandManager;
}
public StructureManager getStructureManager() {
return structureManager;
}
public SoundManager getSoundManager() {
return soundManager;
}
public GeneratorManager getGeneratorManager() {
return generatorManager;
}
public PlaceholderManager getPlaceholderManager() {
return placeholderManager;
}
@Override
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
return new VoidGenerator();
}
}

View File

@ -0,0 +1,93 @@
package me.goodandevil.skyblock.ban;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import me.goodandevil.skyblock.Main;
import me.goodandevil.skyblock.config.FileManager.Config;
import me.goodandevil.skyblock.events.IslandBanEvent;
import me.goodandevil.skyblock.events.IslandUnbanEvent;
public class Ban {
private UUID islandOwnerUUID;
public Ban(UUID islandOwnerUUID) {
this.islandOwnerUUID = islandOwnerUUID;
}
public UUID getOwnerUUID() {
return islandOwnerUUID;
}
public void setOwnerUUID(UUID islandOwnerUUID) {
this.islandOwnerUUID = islandOwnerUUID;
}
public boolean isBanned(UUID uuid) {
return getBans().contains(uuid);
}
public List<UUID> getBans() {
Main plugin = Main.getInstance();
List<UUID> islandBans = new ArrayList<>();
for (String islandBanList : plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"), islandOwnerUUID.toString() + ".yml")).getFileConfiguration().getStringList("Bans")) {
islandBans.add(UUID.fromString(islandBanList));
}
return islandBans;
}
public void addBan(UUID uuid) {
Main plugin = Main.getInstance();
List<String> islandBans = new ArrayList<>();
FileConfiguration configLoad = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"), islandOwnerUUID.toString() + ".yml")).getFileConfiguration();
for (String islandBanList : configLoad.getStringList("Bans")) {
islandBans.add(islandBanList);
}
islandBans.add(uuid.toString());
configLoad.set("Bans", islandBans);
Bukkit.getServer().getPluginManager().callEvent(new IslandBanEvent(uuid, this));
}
public void removeBan(UUID uuid) {
Main plugin = Main.getInstance();
List<String> islandBans = new ArrayList<>();
FileConfiguration configLoad = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"), islandOwnerUUID.toString() + ".yml")).getFileConfiguration();
for (String islandBanList : configLoad.getStringList("Bans")) {
if (!uuid.toString().equals(islandBanList)) {
islandBans.add(islandBanList);
}
}
configLoad.set("Bans", islandBans);
Bukkit.getServer().getPluginManager().callEvent(new IslandUnbanEvent(uuid, this));
}
public void save() {
Main plugin = Main.getInstance();
Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"), islandOwnerUUID.toString() + ".yml"));
try {
config.getFileConfiguration().save(config.getFile());
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,134 @@
package me.goodandevil.skyblock.ban;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import me.goodandevil.skyblock.Main;
import me.goodandevil.skyblock.config.FileManager;
import me.goodandevil.skyblock.config.FileManager.Config;
import me.goodandevil.skyblock.island.Island;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
import me.goodandevil.skyblock.utils.world.LocationUtil;
public class BanManager {
private final Main plugin;
private Map<UUID, Ban> banStorage = new HashMap<>();
public BanManager(Main plugin) {
this.plugin = plugin;
loadIslands();
}
public void onDisable() {
Map<UUID, Ban> banIslands = getIslands();
for (UUID banIslandList : banIslands.keySet()) {
Ban ban = banIslands.get(banIslandList);
ban.save();
}
}
public void loadIslands() {
FileManager fileManager = plugin.getFileManager();
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Unload")) {
File configFile = new File(plugin.getDataFolder().toString() + "/island-data");
if (configFile.exists()) {
for (File fileList : configFile.listFiles()) {
UUID islandOwnerUUID = UUID.fromString(fileList.getName().replaceFirst("[.][^.]+$", ""));
createIsland(islandOwnerUUID);
}
}
}
}
public void transfer(UUID uuid, UUID islandOwnerUUID) {
FileManager fileManager = plugin.getFileManager();
Ban ban = getIsland(islandOwnerUUID);
ban.save();
File oldBanDataFile = new File(new File(plugin.getDataFolder().toString() + "/ban-data"), islandOwnerUUID.toString() + ".yml");
File newBanDataFile = new File(new File(plugin.getDataFolder().toString() + "/ban-data"), uuid.toString() + ".yml");
fileManager.unloadConfig(oldBanDataFile);
fileManager.unloadConfig(newBanDataFile);
oldBanDataFile.renameTo(newBanDataFile);
removeIsland(islandOwnerUUID);
addIsland(uuid, ban);
}
public void removeVisitor(Island island) {
SoundManager soundManager = plugin.getSoundManager();
FileManager fileManager = plugin.getFileManager();
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
for (UUID visitorList : island.getVisitors()) {
Player targetPlayer = Bukkit.getServer().getPlayer(visitorList);
LocationUtil.teleportPlayerToSpawn(targetPlayer);
targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Banned.Message")));
soundManager.playSound(targetPlayer, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
}
}
public boolean hasIsland(UUID islandOwnerUUID) {
return banStorage.containsKey(islandOwnerUUID);
}
public Ban getIsland(UUID islandOwnerUUID) {
if (hasIsland(islandOwnerUUID)) {
return banStorage.get(islandOwnerUUID);
}
return null;
}
public Map<UUID, Ban> getIslands() {
return banStorage;
}
public void createIsland(UUID islandOwnerUUID) {
banStorage.put(islandOwnerUUID, new Ban(islandOwnerUUID));
}
public void addIsland(UUID islandOwnerUUID, Ban ban) {
banStorage.put(islandOwnerUUID, ban);
}
public void removeIsland(UUID islandOwnerUUID) {
if (hasIsland(islandOwnerUUID)) {
banStorage.remove(islandOwnerUUID);
}
}
public void unloadIsland(UUID islandOwnerUUID) {
if (hasIsland(islandOwnerUUID)) {
plugin.getFileManager().unloadConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"), islandOwnerUUID.toString() + ".yml"));
banStorage.remove(islandOwnerUUID);
}
}
public void deleteIsland(UUID islandOwnerUUID) {
if (hasIsland(islandOwnerUUID)) {
plugin.getFileManager().deleteConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"), islandOwnerUUID.toString() + ".yml"));
banStorage.remove(islandOwnerUUID);
}
}
}

View File

@ -0,0 +1,18 @@
package me.goodandevil.skyblock.biome;
public class Biome {
private int time;
public Biome(int time) {
this.time = time;
}
public int getTime() {
return time;
}
public void setTime(int time) {
this.time = time;
}
}

View File

@ -0,0 +1,199 @@
package me.goodandevil.skyblock.biome;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import me.goodandevil.skyblock.Main;
import me.goodandevil.skyblock.config.FileManager.Config;
import me.goodandevil.skyblock.island.Island;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
import me.goodandevil.skyblock.utils.version.NMSUtil;
import me.goodandevil.skyblock.utils.world.LocationUtil;
public class BiomeManager {
private final Main plugin;
private Map<UUID, me.goodandevil.skyblock.biome.Biome> playerBiomeStorage = new HashMap<>();
public BiomeManager(Main plugin) {
this.plugin = plugin;
new BiomeTask(plugin).runTaskTimerAsynchronously(plugin, 0L, 20L);
for (Player all : Bukkit.getOnlinePlayers()) {
loadPlayer(all);
}
}
public void onDisable() {
for (Player all : Bukkit.getOnlinePlayers()) {
savePlayer(all);
}
}
public void setBiome(Player player, Island island, Biome biome) {
new BukkitRunnable() {
@Override
public void run() {
List<Chunk> chunks = new ArrayList<>();
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 {
Block block = locationList.getBlock();
if (block != null) {
block.setBiome(biome);
boolean containsChunk = false;
for (Chunk chunkList : chunks) {
if (chunkList.getX() == block.getChunk().getX() && chunkList.getZ() == block.getChunk().getZ()) {
containsChunk = true;
break;
}
}
if (!containsChunk) {
chunks.add(block.getChunk());
}
}
} catch (Exception e) {}
}
if (player != null) {
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
IslandManager islandManager = plugin.getIslandManager();
if (playerDataManager.hasPlayerData(player)) {
PlayerData playerData = playerDataManager.getPlayerData(player);
if (playerData.getOwner() != null) {
Island island = islandManager.getIsland(playerData.getOwner());
updateBiome(island, chunks);
}
}
}
}
}.runTaskAsynchronously(plugin);
}
public void updateBiome(Island island, List<Chunk> chunks) {
Class<?> packetPlayOutMapChunkClass = NMSUtil.getNMSClass("PacketPlayOutMapChunk");
Class<?> chunkClass = NMSUtil.getNMSClass("Chunk");
for (Player all : plugin.getIslandManager().getPlayersAtIsland(island, me.goodandevil.skyblock.island.Location.World.Normal)) {
for (Chunk chunkList : chunks) {
try {
if (NMSUtil.getVersionNumber() < 10) {
NMSUtil.sendPacket(all, packetPlayOutMapChunkClass.getConstructor(chunkClass, boolean.class, int.class).newInstance(all.getLocation().getChunk().getClass().getMethod("getHandle").invoke(chunkList), true, 20));
} else {
NMSUtil.sendPacket(all, packetPlayOutMapChunkClass.getConstructor(chunkClass, int.class).newInstance(all.getLocation().getChunk().getClass().getMethod("getHandle").invoke(chunkList), 65535));
}
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
e.printStackTrace();
}
}
}
}
public void createPlayer(Player player, int time) {
Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml"));
File configFile = config.getFile();
FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set("Island.Biome.Cooldown", time);
try {
configLoad.save(configFile);
} catch (IOException e) {
e.printStackTrace();
}
me.goodandevil.skyblock.biome.Biome biome = new me.goodandevil.skyblock.biome.Biome(time);
playerBiomeStorage.put(player.getUniqueId(), biome);
}
public void loadPlayer(Player player) {
Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getString("Island.Biome.Cooldown") != null) {
me.goodandevil.skyblock.biome.Biome biome = new me.goodandevil.skyblock.biome.Biome(configLoad.getInt("Island.Biome.Cooldown"));
playerBiomeStorage.put(player.getUniqueId(), biome);
}
}
public void removePlayer(Player player) {
if (hasPlayer(player)) {
Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml"));
File configFile = config.getFile();
FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set("Island.Biome.Cooldown", null);
try {
configLoad.save(configFile);
} catch (IOException e) {
e.printStackTrace();
}
playerBiomeStorage.remove(player.getUniqueId());
}
}
public void savePlayer(Player player) {
if (hasPlayer(player)) {
me.goodandevil.skyblock.biome.Biome biome = getPlayer(player);
Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml"));
File configFile = config.getFile();
FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set("Island.Biome.Cooldown", biome.getTime());
try {
configLoad.save(configFile);
} catch (IOException e) {
e.printStackTrace();
}
}
}
public void unloadPlayer(Player player) {
if (hasPlayer(player)) {
playerBiomeStorage.remove(player.getUniqueId());
}
}
public me.goodandevil.skyblock.biome.Biome getPlayer(Player player) {
if (hasPlayer(player)) {
return playerBiomeStorage.get(player.getUniqueId());
}
return null;
}
public boolean hasPlayer(Player player) {
return playerBiomeStorage.containsKey(player.getUniqueId());
}
}

View File

@ -0,0 +1,32 @@
package me.goodandevil.skyblock.biome;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import me.goodandevil.skyblock.Main;
public class BiomeTask extends BukkitRunnable {
private final Main plugin;
protected BiomeTask(Main plugin) {
this.plugin = plugin;
}
@Override
public void run() {
BiomeManager biomeManager = plugin.getBiomeManager();
for (Player all : Bukkit.getOnlinePlayers()) {
if (biomeManager.hasPlayer(all)) {
me.goodandevil.skyblock.biome.Biome biome = biomeManager.getPlayer(all);
biome.setTime(biome.getTime() - 1);
if (biome.getTime() == 0) {
biomeManager.removePlayer(all);
}
}
}
}
}

View File

@ -0,0 +1,376 @@
package me.goodandevil.skyblock.command;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import me.goodandevil.skyblock.Main;
import me.goodandevil.skyblock.command.commands.AcceptCommand;
import me.goodandevil.skyblock.command.commands.BanCommand;
import me.goodandevil.skyblock.command.commands.BansCommand;
import me.goodandevil.skyblock.command.commands.BiomeCommand;
import me.goodandevil.skyblock.command.commands.CancelCommand;
import me.goodandevil.skyblock.command.commands.ChatCommand;
import me.goodandevil.skyblock.command.commands.CloseCommand;
import me.goodandevil.skyblock.command.commands.ConfirmCommand;
import me.goodandevil.skyblock.command.commands.ControlPanelCommand;
import me.goodandevil.skyblock.command.commands.CreateCommand;
import me.goodandevil.skyblock.command.commands.CurrentCommand;
import me.goodandevil.skyblock.command.commands.DeleteCommand;
import me.goodandevil.skyblock.command.commands.DemoteCommand;
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.LeaveCommand;
import me.goodandevil.skyblock.command.commands.LevelCommand;
import me.goodandevil.skyblock.command.commands.MembersCommand;
import me.goodandevil.skyblock.command.commands.OpenCommand;
import me.goodandevil.skyblock.command.commands.OwnerCommand;
import me.goodandevil.skyblock.command.commands.PromoteCommand;
import me.goodandevil.skyblock.command.commands.PublicCommand;
import me.goodandevil.skyblock.command.commands.SetSpawnCommand;
import me.goodandevil.skyblock.command.commands.SettingsCommand;
import me.goodandevil.skyblock.command.commands.TeleportCommand;
import me.goodandevil.skyblock.command.commands.UnbanCommand;
import me.goodandevil.skyblock.command.commands.VisitCommand;
import me.goodandevil.skyblock.command.commands.VisitorsCommand;
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.StructureCommand;
import me.goodandevil.skyblock.config.FileManager;
import me.goodandevil.skyblock.config.FileManager.Config;
import me.goodandevil.skyblock.menus.ControlPanel;
import me.goodandevil.skyblock.menus.Creator;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.ChatComponent;
import me.goodandevil.skyblock.utils.version.Sounds;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
public class CommandManager implements CommandExecutor, TabCompleter {
private final Main plugin;
private HashMap<CommandManager.Type, List<SubCommand>> subCommands = new HashMap<>();
public CommandManager(Main plugin) {
this.plugin = plugin;
plugin.getCommand("island").setExecutor(this);
plugin.getCommand("island").setTabCompleter(this);
registerSubCommands();
}
public void registerSubCommands() {
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
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 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"))));
subCommands.add(new SetSpawnCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Info.Message"))));
subCommands.add(new AcceptCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Accept.Info.Message"))));
subCommands.add(new DenyCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Deny.Info.Message"))));
subCommands.add(new CancelCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Cancel.Info.Message"))));
subCommands.add(new LeaveCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Leave.Info.Message"))));
subCommands.add(new PromoteCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Info.Message"))));
subCommands.add(new DemoteCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Demote.Info.Message"))));
subCommands.add(new KickCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Kick.Info.Message"))));
subCommands.add(new KickAllCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.KickAll.Info.Message"))));
subCommands.add(new BanCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ban.Info.Message"))));
subCommands.add(new BansCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Bans.Info.Message"))));
subCommands.add(new UnbanCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Unban.Info.Message"))));
subCommands.add(new BiomeCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Biome.Info.Message"))));
subCommands.add(new WeatherCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Weather.Info.Message"))));
//subCommands.add(new RollbackCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Rollback.Info.Message"))));
subCommands.add(new LevelCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Info.Message"))));
subCommands.add(new SettingsCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Settings.Info.Message"))));
subCommands.add(new MembersCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Members.Info.Message"))));
subCommands.add(new OwnerCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Info.Message"))));
subCommands.add(new ConfirmCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Info.Message"))));
subCommands.add(new InviteCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Info.Message"))));
subCommands.add(new ChatCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Chat.Info.Message"))));
subCommands.add(new VisitorsCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Visitors.Info.Message"))));
subCommands.add(new CurrentCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Current.Info.Message"))));
subCommands.add(new PublicCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Public.Info.Message"))));
subCommands.add(new OpenCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Open.Info.Message"))));
subCommands.add(new CloseCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Close.Info.Message"))));
this.subCommands.put(CommandManager.Type.Default, subCommands);
subCommands = new ArrayList<>();
subCommands.add(new me.goodandevil.skyblock.command.commands.admin.LevelCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Level.Info.Message"))));
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 StructureCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.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 DeleteCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Delete.Info.Message"))));
subCommands.add(new OwnerCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Owner.Info.Message"))));
subCommands.add(new ReloadCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Reload.Info.Message"))));
this.subCommands.put(CommandManager.Type.Admin, subCommands);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
return true;
}
Player player = (Player) sender;
if (command.getName().equalsIgnoreCase("island")) {
new BukkitRunnable() {
@Override
public void run() {
SoundManager soundManager = plugin.getSoundManager();
FileManager fileManager = plugin.getFileManager();
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (args.length == 0) {
if (plugin.getIslandManager().hasIsland(player)) {
ControlPanel.getInstance().open(player);
} else {
Creator.getInstance().open(player);
}
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
return;
}
SubCommand subCommand;
if (args[0].equalsIgnoreCase("help")) {
int page = -1;
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Command.Help.List")) {
page = 1;
if (args.length == 2) {
if (args[1].matches("[0-9]+")) {
page = Integer.valueOf(args[1]);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Help.Integer.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
}
}
sendHelpCommands(player, CommandManager.Type.Default, page);
return;
} else if (args[0].equalsIgnoreCase("admin")) {
if (args.length == 1 || (args.length >= 2 && args[1].equalsIgnoreCase("help"))) {
int page = -1;
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Command.Help.List")) {
page = 1;
if (args.length == 3) {
if (args[2].matches("[0-9]+")) {
page = Integer.valueOf(args[2]);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Help.Integer.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
}
}
sendHelpCommands(player, CommandManager.Type.Admin, page);
return;
}
subCommand = getSubCommand(CommandManager.Type.Admin, args[1]);
} else {
subCommand = getSubCommand(CommandManager.Type.Default, args[0]);
}
if (subCommand == null) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Argument.Unrecognised.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
} else {
ArrayList<String> arguments = new ArrayList<>();
arguments.addAll(Arrays.asList(args));
arguments.remove(args[0]);
if (subCommand.getType() == CommandManager.Type.Admin) {
arguments.remove(args[1]);
}
subCommand.onCommand(player, arguments.toArray(new String[0]));
}
}
}.runTaskAsynchronously(plugin);
}
return true;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String s, String[] args) {
if (!(sender instanceof Player)) {
return null;
}
if (command.getName().equalsIgnoreCase("island")) {
List<String> commandAliases = new ArrayList<>();
if (args.length == 1) {
commandAliases.add("admin");
for (SubCommand subCommandList : subCommands.get(Type.Default)) {
commandAliases.add(subCommandList.getName());
}
} else if (args.length == 2) {
if (args[0].equalsIgnoreCase("admin")) {
for (SubCommand subCommandList : subCommands.get(Type.Admin)) {
commandAliases.add(subCommandList.getName());
}
}
} else if (args.length == 3) {
if (args[0].equalsIgnoreCase("admin") && args[1].equalsIgnoreCase("structure")) {
commandAliases.add("tool");
commandAliases.add("save");
}
}
if (commandAliases.size() != 0) {
return commandAliases;
}
}
return null;
}
public void sendHelpCommands(Player player, CommandManager.Type type, int page) {
FileManager fileManager = plugin.getFileManager();
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
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");
String subCommandText = "";
if (type == CommandManager.Type.Admin) {
subCommandText = "admin ";
}
for (String helpLines : configLoad.getStringList("Command.Island.Help.Lines")) {
if (helpLines.contains("%type")) {
helpLines = helpLines.replace("%type", type.name());
}
if (helpLines.contains("%commands")) {
String[] sections = helpLines.split("%commands");
String prefix = "", suffix = "";
if (sections.length >= 1) {
prefix = ChatColor.translateAlternateColorCodes('&', sections[0]);
}
if (sections.length == 2) {
suffix = ChatColor.translateAlternateColorCodes('&', sections[1]);
}
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));
}
}
if (page != -1) {
if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
if (page == 1) {
player.spigot().sendMessage(new ChatComponent(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Help.Word.Next")), false, null, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/island " + subCommandText + "help " + (page + 1)), null).getTextComponent());
} else {
player.spigot().sendMessage(new ChatComponent(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Help.Word.Previous")), false, null, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/island " + subCommandText + "help " + (page - 1)), null).addExtraChatComponent(new ChatComponent(" " + ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Help.Word.Pipe")) + " ", false, null, null, null)).addExtraChatComponent(new ChatComponent(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Help.Word.Next")), false, null, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/island " + subCommandText + "help " + (page + 1)), null)).getTextComponent());
}
} else {
if (page != 1) {
player.spigot().sendMessage(new ChatComponent(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Help.Word.Previous")), false, null, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/island " + subCommandText + "help " + (page - 1)), null).getTextComponent());
}
}
}
plugin.getSoundManager().playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
}
public SubCommand getSubCommand(CommandManager.Type type, String arg) {
for (SubCommand subCommandList : subCommands.get(type)) {
if (subCommandList.getName().equalsIgnoreCase(arg)) {
return subCommandList;
}
for (String argList : subCommandList.getAliases()) {
if (argList.equalsIgnoreCase(arg)) {
return subCommandList;
}
}
}
return null;
}
public enum Type {
Default,
Admin;
}
}

View File

@ -0,0 +1,16 @@
package me.goodandevil.skyblock.command;
import org.bukkit.entity.Player;
public abstract class SubCommand {
public abstract void onCommand(Player player, String[] args);
public abstract String getName();
public abstract String getInfo();
public abstract SubCommand setInfo(String info);
public abstract String[] getAliases();
public abstract CommandManager.Type getType();
}

View File

@ -0,0 +1,224 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import me.goodandevil.skyblock.Main;
import me.goodandevil.skyblock.command.CommandManager.Type;
import me.goodandevil.skyblock.command.CommandManager;
import me.goodandevil.skyblock.command.SubCommand;
import me.goodandevil.skyblock.config.FileManager;
import me.goodandevil.skyblock.config.FileManager.Config;
import me.goodandevil.skyblock.events.IslandJoinEvent;
import me.goodandevil.skyblock.invite.Invite;
import me.goodandevil.skyblock.invite.InviteManager;
import me.goodandevil.skyblock.island.Island;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
import me.goodandevil.skyblock.scoreboard.Scoreboard;
import me.goodandevil.skyblock.scoreboard.ScoreboardManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
public class AcceptCommand extends SubCommand {
private final Main plugin;
private String info;
public AcceptCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
ScoreboardManager scoreboardManager = plugin.getScoreboardManager();
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
FileManager fileManager = plugin.getFileManager();
PlayerData playerData = playerDataManager.getPlayerData(player);
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (args.length == 1) {
InviteManager inviteManager = plugin.getInviteManager();
if (inviteManager.hasInvite(player.getUniqueId())) {
Invite invite = inviteManager.getInvite(player.getUniqueId());
String playerName = args[0];
if (invite.getSenderName().equalsIgnoreCase(playerName)) {
inviteManager.removeInvite(player.getUniqueId());
if (islandManager.hasIsland(player)) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Accept.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
boolean unloadIsland = false;
Island island;
if (islandManager.containsIsland(invite.getOwnerUUID())) {
island = islandManager.getIsland(invite.getOwnerUUID());
} else {
islandManager.loadIsland(invite.getOwnerUUID());
island = islandManager.getIsland(invite.getOwnerUUID());
unloadIsland = true;
}
IslandJoinEvent islandJoinEvent = new IslandJoinEvent(player, island);
Bukkit.getServer().getPluginManager().callEvent(islandJoinEvent);
if (islandJoinEvent.isCancelled()) {
if (unloadIsland) {
islandManager.unloadIsland(invite.getOwnerUUID());
}
} else {
Player targetPlayer = Bukkit.getServer().getPlayer(invite.getSenderUUID());
if (targetPlayer != null) {
targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Accept.Accepted.Target.Message").replace("%player", player.getName())));
soundManager.playSound(targetPlayer, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
}
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Accept.Accepted.Sender.Message").replace("%player", invite.getSenderName())));
soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
playerData.setPlaytime(0);
playerData.setOwner(invite.getOwnerUUID());
playerData.setMemberSince(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(new Date()));
playerData.save();
island.setRole(Role.Member, player.getUniqueId());
island.save();
if ((island.getRole(Role.Member).size() + island.getRole(Role.Operator).size() + 1) >= fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Member.Capacity")) {
Map<UUID, Invite> invites = inviteManager.getInvites();
for (UUID inviteList : invites.keySet()) {
Invite targetInvite = invites.get(inviteList);
if (targetInvite.getOwnerUUID().equals(invite.getOwnerUUID())) {
inviteManager.removeInvite(inviteList);
Player targetInvitePlayer = Bukkit.getServer().getPlayer(inviteList);
if (targetInvitePlayer != null) {
targetInvitePlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Accept.Capacity.Broadcast.Message").replace("%player", targetInvite.getSenderName())));
soundManager.playSound(targetInvitePlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
}
}
}
}
plugin.getVisitManager().getIsland(invite.getOwnerUUID()).removeVoter(player.getUniqueId());
for (Player all : Bukkit.getOnlinePlayers()) {
if (!all.getUniqueId().equals(player.getUniqueId())) {
if (playerDataManager.hasPlayerData(all)) {
playerData = playerDataManager.getPlayerData(all);
if (playerData.getOwner() != null && playerData.getOwner().equals(island.getOwnerUUID())) {
all.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Accept.Accepted.Broadcast.Message").replace("%player", player.getName())));
soundManager.playSound(all, Sounds.FIREWORK_BLAST.bukkitSound(), 1.0F, 1.0F);
if (scoreboardManager != null) {
if (island.getRole(Role.Member).size() == 1 && island.getRole(Role.Operator).size() == 0) {
Scoreboard scoreboard = scoreboardManager.getScoreboard(all);
scoreboard.cancel();
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Scoreboard.Island.Team.Displayname")));
if (island.getVisitors().size() == 0) {
scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Island.Team.Empty.Displaylines"));
} else {
scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Island.Team.Occupied.Displaylines"));
}
Map<String, String> displayVariables = new HashMap<>();
displayVariables.put("%owner", configLoad.getString("Scoreboard.Island.Team.Word.Owner"));
displayVariables.put("%operator", configLoad.getString("Scoreboard.Island.Team.Word.Operator"));
displayVariables.put("%member", configLoad.getString("Scoreboard.Island.Team.Word.Member"));
scoreboard.setDisplayVariables(displayVariables);
scoreboard.run();
}
}
}
}
}
}
if (scoreboardManager != null) {
Scoreboard scoreboard = scoreboardManager.getScoreboard(player);
scoreboard.cancel();
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Scoreboard.Island.Team.Displayname")));
if (island.getVisitors().size() == 0) {
scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Island.Team.Empty.Displaylines"));
} else {
scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Island.Team.Occupied.Displaylines"));
}
Map<String, String> displayVariables = new HashMap<>();
displayVariables.put("%owner", configLoad.getString("Scoreboard.Island.Team.Word.Owner"));
displayVariables.put("%operator", configLoad.getString("Scoreboard.Island.Team.Word.Operator"));
displayVariables.put("%member", configLoad.getString("Scoreboard.Island.Team.Word.Member"));
scoreboard.setDisplayVariables(displayVariables);
scoreboard.run();
}
}
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Accept.Invited.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Accept.Invite.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Accept.Invalid.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "accept";
}
@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.Default;
}
}

View File

@ -0,0 +1,147 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
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.Location;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.island.Settings;
import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.OfflinePlayer;
import me.goodandevil.skyblock.utils.version.Sounds;
import me.goodandevil.skyblock.utils.world.LocationUtil;
import me.goodandevil.skyblock.Main;
import me.goodandevil.skyblock.ban.Ban;
import me.goodandevil.skyblock.command.CommandManager;
import me.goodandevil.skyblock.command.SubCommand;
public class BanCommand extends SubCommand {
private final Main plugin;
private String info;
public BanCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
FileManager fileManager = plugin.getFileManager();
PlayerData playerData = playerDataManager.getPlayerData(player);
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (args.length == 1) {
if (islandManager.hasIsland(player)) {
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning")) {
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(playerData.getOwner());
if (island.isRole(Role.Owner, player.getUniqueId()) || (island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Ban").getStatus())) {
UUID targetPlayerUUID = null;
String targetPlayerName = null;
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
if (targetPlayer == null) {
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
targetPlayerUUID = targetPlayerOffline.getUniqueId();
targetPlayerName = targetPlayerOffline.getName();
} else {
targetPlayerUUID = targetPlayer.getUniqueId();
targetPlayerName = targetPlayer.getName();
}
if (targetPlayerUUID == null) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ban.Found.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (targetPlayerUUID.equals(player.getUniqueId())) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ban.Yourself.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (island.isRole(Role.Member, targetPlayerUUID) || island.isRole(Role.Operator, targetPlayerUUID) || island.isRole(Role.Owner, targetPlayerUUID)) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ban.Member.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (island.getBan().isBanned(targetPlayerUUID)) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ban.Already.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ban.Banned.Sender.Message").replace("%player", targetPlayerName)));
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
Ban ban = island.getBan();
ban.addBan(targetPlayerUUID);
ban.save();
if (targetPlayer != null) {
targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ban.Banned.Target.Message").replace("%player", player.getName())));
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
for (Location.World worldList : Location.World.values()) {
if (LocationUtil.isLocationAtLocationRadius(targetPlayer.getLocation(), island.getLocation(worldList, Location.Environment.Island), island.getRadius())) {
LocationUtil.teleportPlayerToSpawn(targetPlayer);
break;
}
}
}
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ban.Permission.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ban.Disabled.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ban.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ban.Invalid.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "ban";
}
@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.Default;
}
}

View File

@ -0,0 +1,85 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.Config;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.island.Settings;
import me.goodandevil.skyblock.menus.Bans;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
public class BansCommand extends SubCommand {
private final Main plugin;
private String info;
public BansCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (islandManager.hasIsland(player)) {
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(plugin.getPlayerDataManager().getPlayerData(player).getOwner());
if ((island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Unban").getStatus()) || island.isRole(Role.Owner, player.getUniqueId())) {
if (island.getBan().getBans().size() == 0) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Bans.Bans.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
Bans.getInstance().open(player);
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Bans.Permission.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Bans.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "bans";
}
@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.Default;
}
}

View File

@ -0,0 +1,79 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.Config;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.island.Settings;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
public class BiomeCommand extends SubCommand {
private final Main plugin;
private String info;
public BiomeCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (islandManager.hasIsland(player)) {
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(plugin.getPlayerDataManager().getPlayerData(player).getOwner());
if ((island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Biome").getStatus()) || island.isRole(Role.Owner, player.getUniqueId())) {
me.goodandevil.skyblock.menus.Biome.getInstance().open(player);
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Biome.Permission.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Biome.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "biome";
}
@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.Default;
}
}

View File

@ -0,0 +1,110 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.Config;
import me.goodandevil.skyblock.invite.Invite;
import me.goodandevil.skyblock.invite.InviteManager;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
public class CancelCommand extends SubCommand {
private final Main plugin;
private String info;
public CancelCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
IslandManager islandManager = plugin.getIslandManager();
InviteManager inviteManager = plugin.getInviteManager();
SoundManager soundManager = plugin.getSoundManager();
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (args.length == 1) {
if (islandManager.hasIsland(player)) {
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(plugin.getPlayerDataManager().getPlayerData(player).getOwner());
if (island.isRole(Role.Owner, player.getUniqueId()) || island.isRole(Role.Operator, player.getUniqueId())) {
String playerName = args[0];
Player targetPlayer = Bukkit.getServer().getPlayer(playerName);
if (targetPlayer == null) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Cancel.Offline.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (island.isRole(Role.Member, targetPlayer.getUniqueId()) || island.isRole(Role.Operator, targetPlayer.getUniqueId()) || island.isRole(Role.Owner, targetPlayer.getUniqueId())) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Cancel.Member.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (inviteManager.hasInvite(targetPlayer.getUniqueId())) {
Invite invite = inviteManager.getInvite(targetPlayer.getUniqueId());
if (invite.getOwnerUUID().equals(island.getOwnerUUID())) {
inviteManager.removeInvite(targetPlayer.getUniqueId());
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Cancel.Cancelled.Message").replace("%player", targetPlayer.getName())));
soundManager.playSound(player, Sounds.EXPLODE.bukkitSound(), 10.0F, 10.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Cancel.Invited.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Cancel.Invited.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Cancel.Permission.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Cancel.Owner.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Cancel.Invalid.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "cancel";
}
@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.Default;
}
}

View File

@ -0,0 +1,111 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import me.goodandevil.skyblock.command.CommandManager.Type;
import me.goodandevil.skyblock.config.FileManager.Config;
import me.goodandevil.skyblock.events.IslandChatSwitchEvent;
import me.goodandevil.skyblock.island.Island;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
import me.goodandevil.skyblock.Main;
import me.goodandevil.skyblock.command.CommandManager;
import me.goodandevil.skyblock.command.SubCommand;
public class ChatCommand extends SubCommand {
private final Main plugin;
private String info;
public ChatCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (islandManager.hasIsland(player)) {
PlayerData playerData = playerDataManager.getPlayerData(player);
Island island = islandManager.getIsland(playerData.getOwner());
if ((island.getRole(Role.Member).size() + island.getRole(Role.Operator).size()) == 0) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Chat.Team.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
Map<UUID, PlayerData> playerDataStorage = playerDataManager.getPlayerData();
for (UUID playerDataStorageList : playerDataStorage.keySet()) {
if (!playerDataStorageList.equals(player.getUniqueId())) {
PlayerData targetPlayerData = playerDataStorage.get(playerDataStorageList);
if (targetPlayerData.getOwner().equals(playerData.getOwner())) {
if (playerData.isChat()) {
Bukkit.getServer().getPluginManager().callEvent(new IslandChatSwitchEvent(player, island, false));
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Chat.Untoggled.Message")));
playerData.setChat(false);
} else {
Bukkit.getServer().getPluginManager().callEvent(new IslandChatSwitchEvent(player, island, true));
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Chat.Toggled.Message")));
playerData.setChat(true);
}
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
return;
}
}
}
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Chat.Offline.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Chat.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "chat";
}
@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.Default;
}
}

View File

@ -0,0 +1,86 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.Config;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.island.Settings;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
public class CloseCommand extends SubCommand {
private final Main plugin;
private String info;
public CloseCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (islandManager.hasIsland(player)) {
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(plugin.getPlayerDataManager().getPlayerData(player).getOwner());
if (island.isRole(Role.Owner, player.getUniqueId()) || (island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Visitor").getStatus())) {
if (island.isOpen()) {
islandManager.closeIsland(island);
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Close.Closed.Message")));
soundManager.playSound(player, Sounds.DOOR_CLOSE.bukkitSound(), 1.0F, 1.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Close.Already.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Close.Permission.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Close.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "close";
}
@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.Default;
}
}

View File

@ -0,0 +1,178 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import java.util.UUID;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.confirmation.Confirmation;
import me.goodandevil.skyblock.island.Location;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.scoreboard.Scoreboard;
import me.goodandevil.skyblock.scoreboard.ScoreboardManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.OfflinePlayer;
import me.goodandevil.skyblock.utils.version.Sounds;
import me.goodandevil.skyblock.utils.world.LocationUtil;
public class ConfirmCommand extends SubCommand {
private final Main plugin;
private String info;
public ConfirmCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
ScoreboardManager scoreboardManager = plugin.getScoreboardManager();
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
FileManager fileManager = plugin.getFileManager();
PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player);
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (playerData.getConfirmationTime() > 0) {
if (islandManager.hasIsland(player)) {
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(playerData.getOwner());
Confirmation confirmation = playerData.getConfirmation();
if (confirmation == Confirmation.Ownership || confirmation == Confirmation.Deletion) {
if (island.isRole(Role.Owner, player.getUniqueId())) {
if (confirmation == Confirmation.Ownership) {
UUID targetPlayerUUID = playerData.getOwnership();
if (island.isRole(Role.Member, targetPlayerUUID) || island.isRole(Role.Operator, targetPlayerUUID)) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Confirmed.Message")));
String targetPlayerName;
Player targetPlayer = Bukkit.getServer().getPlayer(targetPlayerUUID);
if (targetPlayer == null) {
targetPlayerName = new OfflinePlayer(targetPlayerUUID).getName();
} else {
targetPlayerName = targetPlayer.getName();
targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Ownership.Assigned.Message")));
soundManager.playSound(targetPlayer, Sounds.ANVIL_USE.bukkitSound(), 1.0F, 1.0F);
}
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.isRole(Role.Owner, all.getUniqueId())) && (!all.getUniqueId().equals(targetPlayerUUID))) {
all.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Assigned.Broadcast.Message").replace("%player", targetPlayerName)));
soundManager.playSound(all, Sounds.ANVIL_USE.bukkitSound(), 1.0F, 1.0F);
}
}
playerData.setConfirmation(null);
playerData.setConfirmationTime(0);
islandManager.giveIslandOwnership(targetPlayerUUID);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Ownership.Member.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else if (confirmation == Confirmation.Deletion) {
playerData.setConfirmation(null);
playerData.setConfirmationTime(0);
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Confirmed.Message")));
boolean hasSpawnPoint = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "locations.yml")).getFileConfiguration().getString("Location.Spawn") != null;
for (Player all : Bukkit.getOnlinePlayers()) {
if (island.isRole(Role.Member, all.getUniqueId()) || island.isRole(Role.Operator, all.getUniqueId()) || island.isRole(Role.Owner, all.getUniqueId())) {
if (scoreboardManager != null) {
Scoreboard scoreboard = scoreboardManager.getScoreboard(all);
scoreboard.cancel();
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Scoreboard.Tutorial.Displayname")));
scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Tutorial.Displaylines"));
scoreboard.run();
}
for (Location.World worldList : Location.World.values()) {
if (LocationUtil.isLocationAtLocationRadius(all.getLocation(), island.getLocation(worldList, Location.Environment.Island), island.getRadius())) {
if (hasSpawnPoint) {
LocationUtil.teleportPlayerToSpawn(all);
} else {
Bukkit.getServer().getLogger().log(Level.WARNING, "SkyBlock | Error: A spawn point hasn't been set.");
}
break;
}
}
if (!island.isRole(Role.Owner, all.getUniqueId())) {
all.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Deletion.Broadcast.Message")));
soundManager.playSound(all, Sounds.EXPLODE.bukkitSound(), 10.0F, 10.0F);
}
}
}
islandManager.deleteIsland(island);
plugin.getVisitManager().deleteIsland(player.getUniqueId());
plugin.getBanManager().deleteIsland(player.getUniqueId());
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Deletion.Sender.Message")));
soundManager.playSound(player, Sounds.EXPLODE.bukkitSound(), 10.0F, 10.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Role.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Specified.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Pending.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "confirm";
}
@Override
public String getInfo() {
return info;
}
@Override
public SubCommand setInfo(String info) {
this.info = info;
return this;
}
@Override
public String[] getAliases() {
return new String[] { "confirmation" };
}
@Override
public Type getType() {
return CommandManager.Type.Default;
}
}

View File

@ -0,0 +1,69 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.Config;
import me.goodandevil.skyblock.menus.ControlPanel;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
public class ControlPanelCommand extends SubCommand {
private final Main plugin;
private String info;
public ControlPanelCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
SoundManager soundManager = plugin.getSoundManager();
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (plugin.getIslandManager().hasIsland(player)) {
ControlPanel.getInstance().open(player);
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.ControlPanel.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "controlpanel";
}
@Override
public String getInfo() {
return info;
}
@Override
public SubCommand setInfo(String info) {
this.info = info;
return this;
}
@Override
public String[] getAliases() {
return new String[] { "cp" };
}
@Override
public Type getType() {
return CommandManager.Type.Default;
}
}

View File

@ -0,0 +1,71 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.Config;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.menus.Creator;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
public class CreateCommand extends SubCommand {
private final Main plugin;
private String info;
public CreateCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (islandManager.hasIsland(player)) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Create.Owner.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
} else {
Creator.getInstance().open(player);
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "create";
}
@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.Default;
}
}

View File

@ -0,0 +1,134 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.Config;
import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.OfflinePlayer;
import me.goodandevil.skyblock.utils.version.Sounds;
public class CurrentCommand extends SubCommand {
private final Main plugin;
private String info;
public CurrentCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
SoundManager soundManager = plugin.getSoundManager();
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (args.length > 0) {
if (!args[0].equalsIgnoreCase(player.getName())) {
if (player.hasPermission("skyblock.current") || player.hasPermission("skyblock.*")) {
if (args.length == 1) {
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
if (targetPlayer == null) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Current.Offline.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
if (!targetPlayer.getName().equals(player.getName())) {
PlayerData playerData = playerDataManager.getPlayerData(targetPlayer);
if (playerData.getIsland() == null) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Current.Island.None.Other.Message")));
} else {
String targetPlayerName = targetPlayer.getName(), ownerPlayerName;
targetPlayer = Bukkit.getServer().getPlayer(playerData.getIsland());
if (targetPlayer == null) {
ownerPlayerName = new OfflinePlayer(playerData.getIsland()).getName();
} else {
ownerPlayerName = targetPlayer.getName();
}
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Current.Island.Owner.Other.Message").replace("%target", targetPlayerName).replace("%owner", ownerPlayerName)));
}
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
return;
}
} else if (args.length > 1) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Current.Invalid.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Current.Permission.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
}
}
PlayerData playerData = playerDataManager.getPlayerData(player);
if (playerData.getIsland() == null) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Current.Island.None.Yourself.Message")));
} else {
Player targetPlayer = Bukkit.getServer().getPlayer(playerData.getIsland());
String targetPlayerName;
if (targetPlayer == null) {
targetPlayerName = new OfflinePlayer(playerData.getIsland()).getName();
} else {
targetPlayerName = targetPlayer.getName();
}
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Current.Island.Owner.Yourself.Message").replace("%player", targetPlayerName)));
}
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
}
@Override
public String getName() {
return "current";
}
@Override
public String getInfo() {
return info;
}
@Override
public SubCommand setInfo(String info) {
this.info = info;
return this;
}
@Override
public String[] getAliases() {
return new String[] { "cur" };
}
@Override
public Type getType() {
return CommandManager.Type.Default;
}
}

View File

@ -0,0 +1,97 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import org.bukkit.configuration.file.FileConfiguration;
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.confirmation.Confirmation;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.ChatComponent;
import me.goodandevil.skyblock.utils.version.Sounds;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
public class DeleteCommand extends SubCommand {
private final Main plugin;
private String info;
public DeleteCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
FileManager fileManager = plugin.getFileManager();
PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player);
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (islandManager.hasIsland(player)) {
if (islandManager.getIsland(playerData.getOwner()).isRole(Role.Owner, player.getUniqueId())) {
if (playerData.getConfirmationTime() > 0) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Delete.Confirmation.Pending.Message")));
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
} else {
int confirmationTime = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Confirmation.Timeout");
playerData.setConfirmation(Confirmation.Deletion);
playerData.setConfirmationTime(confirmationTime);
player.spigot().sendMessage(new ChatComponent(configLoad.getString("Command.Island.Delete.Confirmation.Confirm.Message").replace("%time", "" + confirmationTime) + " ", false, null, null, null).addExtra(new ChatComponent(configLoad.getString("Command.Island.Delete.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.Delete.Confirmation.Confirm.Word.Tutorial"))).create()))));
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Delete.Permission.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Delete.Owner.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "delete";
}
@Override
public String getInfo() {
return info;
}
@Override
public SubCommand setInfo(String info) {
this.info = info;
return this;
}
@Override
public String[] getAliases() {
return new String[] { "remove", "disband" };
}
@Override
public Type getType() {
return CommandManager.Type.Default;
}
}

View File

@ -0,0 +1,130 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.Config;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.OfflinePlayer;
import me.goodandevil.skyblock.utils.version.Sounds;
public class DemoteCommand extends SubCommand {
private final Main plugin;
private String info;
public DemoteCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player);
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (args.length == 1) {
if (islandManager.hasIsland(player)) {
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(playerData.getOwner());
if (island.isRole(Role.Owner, player.getUniqueId())) {
if (Bukkit.getServer().getPlayer(args[0]) == null) {
OfflinePlayer targetPlayer = new OfflinePlayer(args[0]);
List<UUID> islandMembers = island.getRole(Role.Member);
if (targetPlayer.getUniqueId() != null && (islandMembers.contains(targetPlayer.getUniqueId()) || island.getRole(Role.Operator).contains(targetPlayer.getUniqueId()))) {
if (islandMembers.contains(targetPlayer.getUniqueId())) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Demote.Role.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Demote.Promoted.Sender.Message").replace("%player", targetPlayer.getName())));
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
island.removeRole(Role.Operator, targetPlayer.getUniqueId());
island.setRole(Role.Member, targetPlayer.getUniqueId());
island.save();
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Demote.Member.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
if (island.isRole(Role.Member, targetPlayer.getUniqueId()) || island.isRole(Role.Operator, targetPlayer.getUniqueId())) {
if (island.isRole(Role.Member, targetPlayer.getUniqueId())) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Demote.Role.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Demote.Demoted.Sender.Message").replace("%player", targetPlayer.getName())));
targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Demote.Demoted.Target.Message")));
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
island.removeRole(Role.Operator, targetPlayer.getUniqueId());
island.setRole(Role.Member, targetPlayer.getUniqueId());
island.save();
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Member.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Demote.Permission.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Demote.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Demote.Invalid.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "demote";
}
@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.Default;
}
}

View File

@ -0,0 +1,95 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.Config;
import me.goodandevil.skyblock.invite.Invite;
import me.goodandevil.skyblock.invite.InviteManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
public class DenyCommand extends SubCommand {
private final Main plugin;
private String info;
public DenyCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
SoundManager soundManager = plugin.getSoundManager();
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (args.length == 1) {
InviteManager inviteManager = plugin.getInviteManager();
if (inviteManager.hasInvite(player.getUniqueId())) {
Invite invite = inviteManager.getInvite(player.getUniqueId());
String playerName = args[0];
if (invite.getSenderName().equalsIgnoreCase(playerName)) {
Player targetPlayer = Bukkit.getServer().getPlayer(invite.getSenderUUID());
if (targetPlayer != null) {
targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Deny.Denied.Target.Message").replace("%player", player.getName())));
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 5.0F, 5.0F);
}
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Deny.Denied.Sender.Message").replace("%player", invite.getSenderName())));
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 5.0F, 5.0F);
inviteManager.removeInvite(player.getUniqueId());
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Deny.Invited.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Deny.Invited.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Deny.Invalid.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "deny";
}
@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.Default;
}
}

View File

@ -0,0 +1,145 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
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.events.IslandInviteEvent;
import me.goodandevil.skyblock.invite.Invite;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.island.Settings;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.ChatComponent;
import me.goodandevil.skyblock.utils.version.Sounds;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
public class InviteCommand extends SubCommand {
private final Main plugin;
private String info;
public InviteCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
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 (args.length == 1) {
if (islandManager.hasIsland(player)) {
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(plugin.getPlayerDataManager().getPlayerData(player).getOwner());
if (island.isRole(Role.Owner, player.getUniqueId()) || (island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Invite").getStatus())) {
Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
if ((island.getRole(Role.Member).size() + island.getRole(Role.Operator).size() + 1) >= mainConfig.getFileConfiguration().getInt("Island.Member.Capacity")) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Capacity.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
String playerName = args[0];
if (playerName.equalsIgnoreCase(player.getName())) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Yourself.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
Player targetPlayer = Bukkit.getServer().getPlayer(playerName);
if (targetPlayer == null) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Offline.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (targetPlayer.getName().equalsIgnoreCase(player.getName())) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Yourself.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (island.isRole(Role.Member, targetPlayer.getUniqueId()) || island.isRole(Role.Operator, targetPlayer.getUniqueId()) || island.isRole(Role.Owner, targetPlayer.getUniqueId())) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Member.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (plugin.getInviteManager().hasInvite(targetPlayer.getUniqueId())) {
Invite invite = plugin.getInviteManager().getInvite(targetPlayer.getUniqueId());
if (invite.getOwnerUUID().equals(island.getOwnerUUID())) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Already.Own.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Already.Other.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
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()))));
} 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()))));
}
Invite invite = plugin.getInviteManager().createInvite(targetPlayer, player, island.getOwnerUUID(), respondTime);
Bukkit.getServer().getPluginManager().callEvent(new IslandInviteEvent(targetPlayer, player, island, invite));
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
soundManager.playSound(targetPlayer, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
}
}
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Permission.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Owner.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invalid.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "invite";
}
@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.Default;
}
}

View File

@ -0,0 +1,115 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.Config;
import me.goodandevil.skyblock.events.IslandKickEvent;
import me.goodandevil.skyblock.island.Island;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.island.Settings;
import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
import me.goodandevil.skyblock.utils.world.LocationUtil;
public class KickAllCommand extends SubCommand {
private final Main plugin;
private String info;
public KickAllCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (islandManager.hasIsland(player)) {
PlayerData playerData = playerDataManager.getPlayerData(player);
Island island = islandManager.getIsland(playerData.getOwner());
if (island.isRole(Role.Owner, player.getUniqueId()) || (island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Kick").getStatus())) {
if (island.isOpen()) {
List<UUID> islandVisitors = island.getVisitors();
if (islandVisitors.size() == 0) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.KickAll.Visitors.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
for (UUID islandVisitorList : islandVisitors) {
Player targetPlayer = Bukkit.getServer().getPlayer(islandVisitorList);
IslandKickEvent islandKickEvent = new IslandKickEvent(island, Role.Visitor, islandVisitorList, player);
Bukkit.getServer().getPluginManager().callEvent(islandKickEvent);
if (!islandKickEvent.isCancelled()) {
LocationUtil.teleportPlayerToSpawn(targetPlayer);
targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.KickAll.Kicked.Target.Message").replace("%player", player.getName())));
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
}
}
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.KickAll.Kicked.Sender.Message").replace("%visitors", "" + islandVisitors.size())));
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.KickAll.Closed.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.KickAll.Role.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.KickAll.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "expel";
}
@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.Default;
}
}

View File

@ -0,0 +1,248 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.events.IslandKickEvent;
import me.goodandevil.skyblock.island.Location;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.island.Settings;
import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
import me.goodandevil.skyblock.scoreboard.Scoreboard;
import me.goodandevil.skyblock.scoreboard.ScoreboardManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.OfflinePlayer;
import me.goodandevil.skyblock.utils.version.Sounds;
import me.goodandevil.skyblock.utils.world.LocationUtil;
public class KickCommand extends SubCommand {
private final Main plugin;
private String info;
public KickCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
ScoreboardManager scoreboardManager = plugin.getScoreboardManager();
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
FileManager fileManager = plugin.getFileManager();
PlayerData playerData = playerDataManager.getPlayerData(player);
Config languageConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
if (args.length == 1) {
if (islandManager.hasIsland(player)) {
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(playerData.getOwner());
boolean isOpen = island.isOpen();
if (island.isRole(Role.Owner, player.getUniqueId()) || (island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Kick").getStatus())) {
UUID targetPlayerUUID = null;
String targetPlayerName = null;
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
List<UUID> islandMembers = island.getRole(Role.Member), islandOperators = island.getRole(Role.Operator), islandVisitors = island.getVisitors();
if (targetPlayer == null) {
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
targetPlayerUUID = targetPlayerOffline.getUniqueId();
targetPlayerName = targetPlayerOffline.getName();
} else {
targetPlayerUUID = targetPlayer.getUniqueId();
targetPlayerName = targetPlayer.getName();
}
if (targetPlayerUUID.equals(player.getUniqueId())) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Yourself.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (islandOperators.contains(player.getUniqueId()) && islandOperators.contains(targetPlayerUUID)) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Role.Operator.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (island.getOwnerUUID().equals(targetPlayerUUID)) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Role.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (isOpen && islandVisitors.contains(targetPlayerUUID) && targetPlayer != null) {
IslandKickEvent islandKickEvent = new IslandKickEvent(island, Role.Visitor, targetPlayerUUID, player);
Bukkit.getServer().getPluginManager().callEvent(islandKickEvent);
if (!islandKickEvent.isCancelled()) {
LocationUtil.teleportPlayerToSpawn(targetPlayer);
player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Kicked.Sender.Message").replace("%player", targetPlayerName)));
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Kicked.Target.Message").replace("%player", player.getName())));
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
}
} else if (islandMembers.contains(targetPlayerUUID) || islandOperators.contains(targetPlayerUUID)) {
Role islandRole = Role.Member;
if (islandOperators.contains(targetPlayerUUID)) {
islandRole = Role.Operator;
}
IslandKickEvent islandKickEvent = new IslandKickEvent(island, islandRole, targetPlayerUUID, player);
Bukkit.getServer().getPluginManager().callEvent(islandKickEvent);
if (!islandKickEvent.isCancelled()) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Kicked.Sender.Message").replace("%player", targetPlayerName)));
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
if (targetPlayer == null) {
Config config = fileManager.getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), targetPlayerUUID.toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set("Statistics.Island.Playtime", null);
configLoad.set("Statistics.Island.Join", null);
configLoad.set("Island.Owner", null);
try {
configLoad.save(config.getFile());
} catch (IOException e) {
e.printStackTrace();
}
} else {
targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Kicked.Target.Message").replace("%player", player.getName())));
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
for (Location.World worldList : Location.World.values()) {
if (LocationUtil.isLocationAtLocationRadius(targetPlayer.getLocation(), island.getLocation(worldList, Location.Environment.Island), island.getRadius())) {
LocationUtil.teleportPlayerToSpawn(targetPlayer);
break;
}
}
if (scoreboardManager != null) {
Scoreboard scoreboard = scoreboardManager.getScoreboard(targetPlayer);
scoreboard.cancel();
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Scoreboard.Tutorial.Displayname")));
scoreboard.setDisplayList(languageConfig.getFileConfiguration().getStringList("Scoreboard.Tutorial.Displaylines"));
scoreboard.run();
}
playerData = playerDataManager.getPlayerData(targetPlayer);
playerData.setPlaytime(0);
playerData.setMemberSince(null);
playerData.setOwner(null);
playerData.setChat(false);
playerData.save();
}
if (islandMembers.contains(targetPlayerUUID)) {
island.removeRole(Role.Member, targetPlayerUUID);
} else if (islandOperators.contains(targetPlayerUUID)) {
island.removeRole(Role.Operator, targetPlayerUUID);
}
island.save();
List<UUID> islandMembersOnline = islandManager.getMembersOnline(island);
if (islandMembersOnline.size() == 1) {
for (UUID islandMembersOnlineList : islandMembersOnline) {
if (!islandMembersOnlineList.equals(player.getUniqueId())) {
targetPlayer = Bukkit.getServer().getPlayer(islandMembersOnlineList);
PlayerData targetPlayerData = playerDataManager.getPlayerData(targetPlayer);
if (targetPlayerData.isChat()) {
targetPlayerData.setChat(false);
targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Chat.Untoggled.Message")));
}
}
}
}
if (scoreboardManager != null) {
if (island.getRole(Role.Member).size() == 0 && island.getRole(Role.Operator).size() == 0) {
Scoreboard scoreboard = scoreboardManager.getScoreboard(player);
scoreboard.cancel();
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname")));
if (island.getVisitors().size() == 0) {
scoreboard.setDisplayList(languageConfig.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Empty.Displaylines"));
} else {
scoreboard.setDisplayList(languageConfig.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Occupied.Displaylines"));
}
scoreboard.run();
}
}
}
} else {
if (isOpen) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Occupant.Visit.Open.Message")));
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Occupant.Visit.Closed.Message")));
}
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
if (isOpen) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Permission.Visit.Open.Message")));
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Permission.Visit.Closed.Message")));
}
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Invalid.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "kick";
}
@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.Default;
}
}

View File

@ -0,0 +1,170 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
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.events.IslandLeaveEvent;
import me.goodandevil.skyblock.island.Location;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
import me.goodandevil.skyblock.scoreboard.Scoreboard;
import me.goodandevil.skyblock.scoreboard.ScoreboardManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
import me.goodandevil.skyblock.utils.world.LocationUtil;
public class LeaveCommand extends SubCommand {
private final Main plugin;
private String info;
public LeaveCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
ScoreboardManager scoreboardManager = plugin.getScoreboardManager();
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
FileManager fileManager = plugin.getFileManager();
PlayerData playerData = playerDataManager.getPlayerData(player);
Config languageConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
if (islandManager.hasIsland(player)) {
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(playerData.getOwner());
if (island.isRole(Role.Owner, player.getUniqueId())) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Leave.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
IslandLeaveEvent islandLeaveEvent = new IslandLeaveEvent(player, island);
Bukkit.getServer().getPluginManager().callEvent(islandLeaveEvent);
if (!islandLeaveEvent.isCancelled()) {
for (Location.World worldList : Location.World.values()) {
if (LocationUtil.isLocationAtLocationRadius(player.getLocation(), island.getLocation(worldList, Location.Environment.Island), island.getRadius())) {
LocationUtil.teleportPlayerToSpawn(player);
break;
}
}
if (island.isRole(Role.Member, player.getUniqueId())) {
island.removeRole(Role.Member, player.getUniqueId());
} else if (island.isRole(Role.Operator, player.getUniqueId())) {
island.removeRole(Role.Operator, player.getUniqueId());
}
island.save();
playerData.setPlaytime(0);
playerData.setOwner(null);
playerData.setMemberSince(null);
playerData.setChat(false);
playerData.save();
List<UUID> islandMembersOnline = islandManager.getMembersOnline(island);
if (islandMembersOnline.size() == 1) {
for (UUID islandMembersOnlineList : islandMembersOnline) {
if (!islandMembersOnlineList.equals(player.getUniqueId())) {
Player targetPlayer = Bukkit.getServer().getPlayer(islandMembersOnlineList);
PlayerData targetPlayerData = playerDataManager.getPlayerData(targetPlayer);
if (targetPlayerData.isChat()) {
targetPlayerData.setChat(false);
targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Chat.Untoggled.Message")));
}
}
}
}
islandManager.unloadIsland(player.getUniqueId());
for (Player all : Bukkit.getOnlinePlayers()) {
if (!all.getUniqueId().equals(player.getUniqueId())) {
if (island.isRole(Role.Member, all.getUniqueId()) || island.isRole(Role.Operator, all.getUniqueId()) || island.isRole(Role.Owner, all.getUniqueId())) {
all.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Leave.Left.Broadcast.Message").replace("%player", player.getName())));
soundManager.playSound(all, Sounds.IRONGOLEM_HIT.bukkitSound(), 5.0F, 5.0F);
if (scoreboardManager != null) {
if (island.getRole(Role.Member).size() == 0 && island.getRole(Role.Operator).size() == 0) {
Scoreboard scoreboard = scoreboardManager.getScoreboard(all);
scoreboard.cancel();
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname")));
if (island.getVisitors().size() == 0) {
scoreboard.setDisplayList(languageConfig.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Empty.Displaylines"));
} else {
scoreboard.setDisplayList(languageConfig.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Occupied.Displaylines"));
}
scoreboard.run();
}
}
}
}
}
player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Leave.Left.Sender.Message")));
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 5.0F, 5.0F);
if (scoreboardManager != null) {
Scoreboard scoreboard = scoreboardManager.getScoreboard(player);
scoreboard.cancel();
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Scoreboard.Tutorial.Displayname")));
scoreboard.setDisplayList(languageConfig.getFileConfiguration().getStringList("Scoreboard.Tutorial.Displaylines"));
scoreboard.run();
}
}
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Leave.Member.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "leave";
}
@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.Default;
}
}

View File

@ -0,0 +1,161 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.Config;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.levelling.LevellingManager;
import me.goodandevil.skyblock.menus.Levelling;
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.visit.VisitManager;
public class LevelCommand extends SubCommand {
private final Main plugin;
private String info;
public LevelCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
VisitManager visitManager = plugin.getVisitManager();
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (args.length == 1) {
if (player.hasPermission("skyblock.level") || player.hasPermission("skyblock.*")) {
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
UUID islandOwnerUUID = null;
String targetPlayerName;
if (targetPlayer == null) {
OfflinePlayer targetOfflinePlayer = new OfflinePlayer(args[0]);
islandOwnerUUID = targetOfflinePlayer.getOwner();
targetPlayerName = targetOfflinePlayer.getName();
} else {
islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner();
targetPlayerName = targetPlayer.getName();
}
if (islandOwnerUUID == null) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Owner.Other.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
} else if (!islandOwnerUUID.equals(playerDataManager.getPlayerData(player).getOwner())) {
if (visitManager.hasIsland(islandOwnerUUID)) {
me.goodandevil.skyblock.visit.Visit visit = visitManager.getIsland(islandOwnerUUID);
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Level.Message").replace("%player", targetPlayerName).replace("%level", "" + visit.getLevel())));
soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
return;
}
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Owner.Other.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Permission.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
} else if (args.length != 0) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Invalid.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
if (islandManager.hasIsland(player)) {
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(plugin.getPlayerDataManager().getPlayerData(player).getOwner());
player.closeInventory();
if (plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), island.getOwnerUUID().toString() + ".yml")).getFileConfiguration().getString("Levelling.Materials") == null) {
LevellingManager levellingManager = plugin.getLevellingManager();
if (levellingManager.hasLevelling(island.getOwnerUUID())) {
me.goodandevil.skyblock.levelling.Levelling levelling = levellingManager.getLevelling(island.getOwnerUUID());
long[] durationTime = NumberUtil.getDuration(levelling.getTime());
if (levelling.getTime() >= 3600) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Cooldown.Message").replace("%time", durationTime[1] + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Minute") + " " + durationTime[2] + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Minute") + " " + durationTime[3] + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Second"))));
} else if (levelling.getTime() >= 60) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Cooldown.Message").replace("%time", durationTime[2] + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Minute") + " " + durationTime[3] + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Second"))));
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Cooldown.Message").replace("%time", levelling.getTime() + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Second"))));
}
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
}
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Processing.Message")));
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
levellingManager.createLevelling(island.getOwnerUUID());
levellingManager.loadLevelling(island.getOwnerUUID());
levellingManager.calculatePoints(player, island);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Loading.Message")));
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
Levelling.getInstance().open(player);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Owner.Yourself.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "level";
}
@Override
public String getInfo() {
return info;
}
@Override
public SubCommand setInfo(String info) {
this.info = info;
return this;
}
@Override
public String[] getAliases() {
return new String[] { "levelling" , "points" };
}
@Override
public Type getType() {
return CommandManager.Type.Default;
}
}

View File

@ -0,0 +1,69 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import org.bukkit.ChatColor;
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.Members;
import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
public class MembersCommand extends SubCommand {
private final Main plugin;
private String info;
public MembersCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
SoundManager soundManager = plugin.getSoundManager();
if (plugin.getIslandManager().hasIsland(player)) {
PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player);
playerData.setType(Members.Type.Default);
playerData.setSort(Members.Sort.Default);
Members.getInstance().open(player, (Members.Type) playerData.getType(), (Members.Sort) playerData.getSort());
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Settings.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "members";
}
@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.Default;
}
}

View File

@ -0,0 +1,86 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.Config;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.island.Settings;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
public class OpenCommand extends SubCommand {
private final Main plugin;
private String info;
public OpenCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (islandManager.hasIsland(player)) {
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(plugin.getPlayerDataManager().getPlayerData(player).getOwner());
if (island.isRole(Role.Owner, player.getUniqueId()) || (island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Visitor").getStatus())) {
if (island.isOpen()) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Open.Already.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
island.setOpen(true);
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Open.Opened.Message")));
soundManager.playSound(player, Sounds.DOOR_OPEN.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Open.Permission.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Open.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "open";
}
@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.Default;
}
}

View File

@ -0,0 +1,160 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
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.confirmation.Confirmation;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.menus.Ownership;
import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.ChatComponent;
import me.goodandevil.skyblock.utils.OfflinePlayer;
import me.goodandevil.skyblock.utils.version.Sounds;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
public class OwnerCommand extends SubCommand {
private final Main plugin;
private String info;
public OwnerCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
FileManager fileManager = plugin.getFileManager();
PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player);
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (islandManager.hasIsland(player)) {
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(playerData.getOwner());
if (args.length == 0) {
if (island.isRole(Role.Owner, player.getUniqueId())) {
playerData.setType(Ownership.Visibility.Hidden);
Ownership.getInstance().open(player);
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
return;
}
} else if (args.length == 1) {
if (island.isRole(Role.Owner, player.getUniqueId())) {
if (playerData.getConfirmationTime() > 0) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Confirmation.Pending.Message")));
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
} else {
UUID targetPlayerUUID;
String targetPlayerName;
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
if (targetPlayer == null) {
OfflinePlayer offlinePlayer = new OfflinePlayer(args[0]);
targetPlayerUUID = offlinePlayer.getUniqueId();
targetPlayerName = offlinePlayer.getName();
} else {
targetPlayerUUID = targetPlayer.getUniqueId();
targetPlayerName = targetPlayer.getName();
}
if (targetPlayerUUID == null || (!island.isRole(Role.Member, targetPlayerUUID) && !island.isRole(Role.Operator, targetPlayerUUID) && !island.isRole(Role.Owner, targetPlayerUUID))) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Member.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (targetPlayerUUID.equals(player.getUniqueId())) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Yourself.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
int confirmationTime = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Confirmation.Timeout");
playerData.setOwnership(targetPlayerUUID);
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()))));
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
}
}
} else {
if (island.hasPassword()) {
if (args[0].equalsIgnoreCase(island.getPassword())) {
for (Player all : Bukkit.getOnlinePlayers()) {
if ((island.isRole(Role.Member, all.getUniqueId()) || island.isRole(Role.Operator, all.getUniqueId()) || island.isRole(Role.Owner, all.getUniqueId())) && (!all.getUniqueId().equals(player.getUniqueId()))) {
all.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Assigned.Broadcast.Message").replace("%player", player.getName())));
soundManager.playSound(all, Sounds.ANVIL_USE.bukkitSound(), 1.0F, 1.0F);
}
}
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Assigned.Sender.Message")));
soundManager.playSound(player, Sounds.ANVIL_USE.bukkitSound(), 1.0F, 1.0F);
islandManager.giveIslandOwnership(player.getUniqueId());
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Password.Incorrect.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Password.Unset.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
return;
}
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Invalid.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "owner";
}
@Override
public String getInfo() {
return info;
}
@Override
public SubCommand setInfo(String info) {
this.info = info;
return this;
}
@Override
public String[] getAliases() {
return new String[] { "ownership", "transfer", "makeleader", "makeowner" };
}
@Override
public Type getType() {
return CommandManager.Type.Default;
}
}

View File

@ -0,0 +1,155 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.Config;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.OfflinePlayer;
import me.goodandevil.skyblock.utils.version.Sounds;
public class PromoteCommand extends SubCommand {
private final Main plugin;
private String info;
public PromoteCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
PlayerData playerData = playerDataManager.getPlayerData(player);
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (args.length == 1) {
if (islandManager.hasIsland(player)) {
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(playerData.getOwner());
if (island.isRole(Role.Owner, player.getUniqueId())) {
if (Bukkit.getServer().getPlayer(args[0]) == null) {
OfflinePlayer targetPlayer = new OfflinePlayer(args[0]);
List<UUID> islandOperators = island.getRole(Role.Operator);
if (targetPlayer.getUniqueId() != null && (island.getRole(Role.Member).contains(targetPlayer.getUniqueId()) || islandOperators.contains(targetPlayer.getUniqueId()))) {
if (islandOperators.contains(targetPlayer.getUniqueId())) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Operator.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Promoted.Sender.Message").replace("%player", targetPlayer.getName())));
for (Player all : Bukkit.getOnlinePlayers()) {
if (islandManager.hasIsland(all)) {
playerData = playerDataManager.getPlayerData(all);
if (islandManager.getIsland(playerData.getOwner()).isRole(Role.Owner, player.getUniqueId())) {
if (!all.getUniqueId().equals(player.getUniqueId())) {
all.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Promoted.Broadcast.Message").replace("%player", targetPlayer.getName())));
}
soundManager.playSound(all, Sounds.FIREWORK_BLAST.bukkitSound(), 1.0F, 1.0F);
}
}
}
island.removeRole(Role.Member, targetPlayer.getUniqueId());
island.setRole(Role.Operator, targetPlayer.getUniqueId());
island.save();
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Member.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
if (island.isRole(Role.Member, targetPlayer.getUniqueId()) || island.isRole(Role.Operator, targetPlayer.getUniqueId())) {
if (island.isRole(Role.Operator, targetPlayer.getUniqueId())) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Operator.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Promoted.Sender.Message").replace("%player", targetPlayer.getName())));
targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Promoted.Target.Message")));
for (Player all : Bukkit.getOnlinePlayers()) {
if (islandManager.hasIsland(all)) {
playerData = playerDataManager.getPlayerData(all);
if (islandManager.getIsland(playerData.getOwner()).isRole(Role.Owner, player.getUniqueId())) {
if (!(all.getUniqueId().equals(player.getUniqueId()) || all.getUniqueId().equals(targetPlayer.getUniqueId()))) {
all.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Promoted.Broadcast.Message").replace("%player", targetPlayer.getName())));
}
soundManager.playSound(all, Sounds.FIREWORK_BLAST.bukkitSound(), 1.0F, 1.0F);
}
}
}
island.setRole(Role.Operator, targetPlayer.getUniqueId());
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Member.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Permission.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Invalid.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "promote";
}
@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.Default;
}
}

View File

@ -0,0 +1,88 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.Config;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.island.Settings;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
public class PublicCommand extends SubCommand {
private final Main plugin;
private String info;
public PublicCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (islandManager.hasIsland(player)) {
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(plugin.getPlayerDataManager().getPlayerData(player).getOwner());
if (island.isRole(Role.Owner, player.getUniqueId()) || (island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Visitor").getStatus())) {
if (island.isOpen()) {
islandManager.closeIsland(island);
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Public.Private.Message")));
soundManager.playSound(player, Sounds.DOOR_CLOSE.bukkitSound(), 1.0F, 1.0F);
} else {
island.setOpen(true);
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Public.Public.Message")));
soundManager.playSound(player, Sounds.DOOR_OPEN.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Public.Permission.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Public.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "public";
}
@Override
public String getInfo() {
return info;
}
@Override
public SubCommand setInfo(String info) {
this.info = info;
return this;
}
@Override
public String[] getAliases() {
return new String[] { "pub", "private", "pri" };
}
@Override
public Type getType() {
return CommandManager.Type.Default;
}
}

View File

@ -0,0 +1,79 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.Config;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.menus.Rollback;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
public class RollbackCommand extends SubCommand {
private final Main plugin;
private String info;
public RollbackCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (islandManager.hasIsland(player)) {
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(plugin.getPlayerDataManager().getPlayerData(player).getOwner());
if (island.isRole(Role.Owner, player.getUniqueId())) {
Rollback.getInstance().open(player);
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Rollback.Role.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Rollback.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "rollback";
}
@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.Default;
}
}

View File

@ -0,0 +1,169 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
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.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.island.Settings;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Materials;
import me.goodandevil.skyblock.utils.version.Sounds;
import me.goodandevil.skyblock.utils.world.LocationUtil;
public class SetSpawnCommand extends SubCommand {
private final Main plugin;
private String info;
private me.goodandevil.skyblock.island.Location.Environment locationEnvironment;
public SetSpawnCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
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 (args.length == 1) {
if (islandManager.hasIsland(player)) {
if (args[0].equalsIgnoreCase("Main")) {
locationEnvironment = me.goodandevil.skyblock.island.Location.Environment.Main;
} else if (args[0].equalsIgnoreCase("Visitor")) {
locationEnvironment = me.goodandevil.skyblock.island.Location.Environment.Visitor;
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Spawn.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(plugin.getPlayerDataManager().getPlayerData(player).getOwner());
if (island.isRole(Role.Operator, player.getUniqueId()) || island.isRole(Role.Owner, player.getUniqueId())) {
if ((island.isRole(Role.Operator, player.getUniqueId()) && (island.getSetting(Settings.Role.Operator, locationEnvironment.name() + "Spawn").getStatus())) || island.isRole(Role.Owner, player.getUniqueId())) {
for (me.goodandevil.skyblock.island.Location.World worldList : me.goodandevil.skyblock.island.Location.World.values()) {
if (LocationUtil.isLocationAtLocationRadius(player.getLocation(), island.getLocation(worldList, me.goodandevil.skyblock.island.Location.Environment.Island), island.getRadius())) {
Location location = player.getLocation();
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
if (location.clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.AIR || location.clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Materials.LEGACY_PISTON_MOVING_PIECE.getPostMaterial()) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Protection.Block.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
} else if (location.getY() - location.getBlockY() != 0.0D) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Protection.Ground.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
} else if (location.getBlock().isLiquid() || location.clone().add(0.0D, 1.0D, 0.0D).getBlock().isLiquid()) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Protection.Liquid.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
} else if (location.getBlock().getType() == Materials.NETHER_PORTAL.parseMaterial() || location.clone().add(0.0D, 1.0D, 0.0D).getBlock().getType() == Materials.NETHER_PORTAL.parseMaterial()) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Protection.Portal.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
} else {
if (LocationUtil.isLocationCentreOfBlock(location)) {
new BukkitRunnable() {
public void run() {
if (location.getBlock().getType() != Material.AIR && location.getBlock().getType() != Materials.MOVING_PISTON.parseMaterial()) {
location.getWorld().dropItemNaturally(location, new ItemStack(location.getBlock().getType()));
}
if (location.clone().add(0.0D, 1.0D, 0.0D).getBlock().getType() != Material.AIR && location.getBlock().getType() != Materials.MOVING_PISTON.parseMaterial()) {
location.getWorld().dropItemNaturally(location.clone().add(0.0D, 1.0D, 0.0D), new ItemStack(location.clone().add(0.0D, 1.0D, 0.0D).getBlock().getType()));
}
islandManager.removeSpawnProtection(island.getLocation(worldList, locationEnvironment));
islandManager.setSpawnProtection(location);
}
}.runTask(plugin);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Protection.Centre.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
}
}
island.setLocation(worldList, locationEnvironment, location);
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Set.Message").replace("%spawn", locationEnvironment.name().toLowerCase())));
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
return;
}
}
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Island.Message").replace("%spawn", locationEnvironment.name().toLowerCase())));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Permission.Message").replace("%spawn", locationEnvironment.name().toLowerCase())));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Role.Message").replace("%spawn", locationEnvironment.name().toLowerCase())));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Invalid.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "setspawn";
}
@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.Default;
}
}

View File

@ -0,0 +1,84 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.Config;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.island.Settings;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
public class SettingsCommand extends SubCommand {
private final Main plugin;
private String info;
public SettingsCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (islandManager.hasIsland(player)) {
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(plugin.getPlayerDataManager().getPlayerData(player).getOwner());
if (island.isRole(Role.Operator, player.getUniqueId()) || island.isRole(Role.Owner, player.getUniqueId())) {
if ((island.isRole(Role.Operator, player.getUniqueId()) && (island.getSetting(Settings.Role.Operator, "Visitor").getStatus() || island.getSetting(Settings.Role.Operator, "Member").getStatus())) || island.isRole(Role.Owner, player.getUniqueId())) {
me.goodandevil.skyblock.menus.Settings.getInstance().open(player, me.goodandevil.skyblock.menus.Settings.Type.Categories, null, null);
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Settings.Permission.Default.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Settings.Role.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Settings.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "settings";
}
@Override
public String getInfo() {
return info;
}
@Override
public SubCommand setInfo(String info) {
this.info = info;
return this;
}
@Override
public String[] getAliases() {
return new String[] { "permissions", "perms", "p" };
}
@Override
public Type getType() {
return CommandManager.Type.Default;
}
}

View File

@ -0,0 +1,146 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.Config;
import me.goodandevil.skyblock.island.Location;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.OfflinePlayer;
import me.goodandevil.skyblock.utils.version.Sounds;
import me.goodandevil.skyblock.visit.VisitManager;
public class TeleportCommand extends SubCommand {
private final Main plugin;
private String info;
public TeleportCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
VisitManager visitManager = plugin.getVisitManager();
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (args.length == 1) {
if (player.hasPermission("skyblock.teleport") || player.hasPermission("skyblock.*")) {
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
UUID islandOwnerUUID = null;
String targetPlayerName;
if (targetPlayer == null) {
OfflinePlayer targetOfflinePlayer = new OfflinePlayer(args[0]);
islandOwnerUUID = targetOfflinePlayer.getOwner();
targetPlayerName = targetOfflinePlayer.getName();
} else {
islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner();
targetPlayerName = targetPlayer.getName();
}
if (islandOwnerUUID == null) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Teleport.Island.None.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
} else if (!islandOwnerUUID.equals(playerDataManager.getPlayerData(player).getOwner())) {
if (visitManager.hasIsland(islandOwnerUUID)) {
me.goodandevil.skyblock.visit.Visit visit = visitManager.getIsland(islandOwnerUUID);
if (visit.isOpen()) {
if (!islandManager.containsIsland(islandOwnerUUID)) {
islandManager.loadIsland(islandOwnerUUID);
}
islandManager.visitIsland(player, islandManager.getIsland(islandOwnerUUID));
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Teleport.Teleported.Other.Message").replace("%player", targetPlayerName)));
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Teleport.Island.Closed.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
return;
}
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Teleport.Island.None.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Teleport.Permission.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
} else if (args.length != 0) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Teleport.Invalid.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
if (islandManager.hasIsland(player)) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Teleport.Teleported.Yourself.Message")));
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(plugin.getPlayerDataManager().getPlayerData(player).getOwner());
Bukkit.getServer().getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
player.teleport(island.getLocation(Location.World.Normal, Location.Environment.Main));
}
});
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Teleport.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "teleport";
}
@Override
public String getInfo() {
return info;
}
@Override
public SubCommand setInfo(String info) {
this.info = info;
return this;
}
@Override
public String[] getAliases() {
return new String[] { "tp", "spawn", "home", "go" };
}
@Override
public Type getType() {
return CommandManager.Type.Default;
}
}

View File

@ -0,0 +1,132 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import me.goodandevil.skyblock.Main;
import me.goodandevil.skyblock.ban.Ban;
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.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.island.Settings;
import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.OfflinePlayer;
import me.goodandevil.skyblock.utils.version.Sounds;
public class UnbanCommand extends SubCommand {
private final Main plugin;
private String info;
public UnbanCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
FileManager fileManager = plugin.getFileManager();
PlayerData playerData = playerDataManager.getPlayerData(player);
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (args.length == 1) {
if (islandManager.hasIsland(player)) {
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning")) {
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(playerData.getOwner());
if (island.isRole(Role.Owner, player.getUniqueId()) || (island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Unban").getStatus())) {
UUID targetPlayerUUID = null;
String targetPlayerName = null;
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
if (targetPlayer == null) {
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
targetPlayerUUID = targetPlayerOffline.getUniqueId();
targetPlayerName = targetPlayerOffline.getName();
} else {
targetPlayerUUID = targetPlayer.getUniqueId();
targetPlayerName = targetPlayer.getName();
}
if (targetPlayerUUID == null) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Unban.Found.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (targetPlayerUUID.equals(player.getUniqueId())) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Unban.Yourself.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (island.isRole(Role.Member, targetPlayerUUID) || island.isRole(Role.Operator, targetPlayerUUID) || island.isRole(Role.Owner, targetPlayerUUID)) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Unban.Member.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (!island.getBan().isBanned(targetPlayerUUID)) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Unban.Banned.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Unban.Unbanned.Message").replace("%player", targetPlayerName)));
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
Ban ban = island.getBan();
ban.removeBan(targetPlayerUUID);
ban.save();
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Unban.Permission.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Unban.Disabled.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Unban.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Unban.Invalid.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "unban";
}
@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.Default;
}
}

View File

@ -0,0 +1,58 @@
package me.goodandevil.skyblock.command.commands;
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.Visit;
import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.utils.version.Sounds;
public class VisitCommand extends SubCommand {
private final Main plugin;
private String info;
public VisitCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player);
playerData.setType(Visit.Type.Default);
playerData.setSort(Visit.Sort.Default);
Visit.getInstance().open(player, (Visit.Type) playerData.getType(), (Visit.Sort) playerData.getSort());
plugin.getSoundManager().playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
}
@Override
public String getName() {
return "visit";
}
@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.Default;
}
}

View File

@ -0,0 +1,83 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import me.goodandevil.skyblock.command.CommandManager.Type;
import me.goodandevil.skyblock.config.FileManager.Config;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.menus.Visitors;
import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
import me.goodandevil.skyblock.Main;
import me.goodandevil.skyblock.command.CommandManager;
import me.goodandevil.skyblock.command.SubCommand;
public class VisitorsCommand extends SubCommand {
private final Main plugin;
private String info;
public VisitorsCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (islandManager.hasIsland(player)) {
PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player);
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(playerData.getOwner());
if (!island.isOpen()) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Visitors.Closed.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (island.getVisitors().size() == 0) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Visitors.Visitors.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
Visitors.getInstance().open(player);
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Visitors.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "visitors";
}
@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.Default;
}
}

View File

@ -0,0 +1,80 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.Config;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.island.Settings;
import me.goodandevil.skyblock.menus.Weather;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
public class WeatherCommand extends SubCommand {
private final Main plugin;
private String info;
public WeatherCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (islandManager.hasIsland(player)) {
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(plugin.getPlayerDataManager().getPlayerData(player).getOwner());
if ((island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Weather").getStatus()) || island.isRole(Role.Owner, player.getUniqueId())) {
Weather.getInstance().open(player);
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Weather.Permission.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Weather.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "weather";
}
@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.Default;
}
}

View File

@ -0,0 +1,77 @@
package me.goodandevil.skyblock.command.commands.admin;
import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.menus.admin.Creator;
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
public class CreateCommand extends SubCommand {
private final Main plugin;
private String info;
public CreateCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
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 (player.hasPermission("skyblock.admin.create") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*")) {
if (playerDataManager.hasPlayerData(player)) {
playerDataManager.getPlayerData(player).setViewer(null);
}
Creator.getInstance().open(player);
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Create.Permission.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "create";
}
@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

@ -0,0 +1,144 @@
package me.goodandevil.skyblock.command.commands.admin;
import java.io.File;
import java.util.UUID;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.Location;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.Role;
import me.goodandevil.skyblock.scoreboard.Scoreboard;
import me.goodandevil.skyblock.scoreboard.ScoreboardManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.OfflinePlayer;
import me.goodandevil.skyblock.utils.version.Sounds;
import me.goodandevil.skyblock.utils.world.LocationUtil;
public class DeleteCommand extends SubCommand {
private final Main plugin;
private String info;
public DeleteCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
ScoreboardManager scoreboardManager = plugin.getScoreboardManager();
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.delete") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*")) {
if (args.length == 1) {
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
UUID targetPlayerUUID;
String targetPlayerName;
if (targetPlayer == null) {
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
targetPlayerUUID = targetPlayerOffline.getUniqueId();
targetPlayerName = targetPlayerOffline.getName();
} else {
targetPlayerUUID = targetPlayer.getUniqueId();
targetPlayerName = targetPlayer.getName();
}
if (islandManager.isIslandExist(targetPlayerUUID)) {
islandManager.loadIsland(targetPlayerUUID);
boolean hasSpawnPoint = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "locations.yml")).getFileConfiguration().getString("Location.Spawn") != null;
Island island = islandManager.getIsland(targetPlayerUUID);
for (Player all : Bukkit.getOnlinePlayers()) {
if (island.isRole(Role.Member, all.getUniqueId()) || island.isRole(Role.Operator, all.getUniqueId()) || island.isRole(Role.Owner, all.getUniqueId())) {
if (scoreboardManager != null) {
Scoreboard scoreboard = scoreboardManager.getScoreboard(all);
scoreboard.cancel();
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Scoreboard.Tutorial.Displayname")));
scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Tutorial.Displaylines"));
scoreboard.run();
}
for (Location.World worldList : Location.World.values()) {
if (LocationUtil.isLocationAtLocationRadius(all.getLocation(), island.getLocation(worldList, Location.Environment.Island), island.getRadius())) {
if (hasSpawnPoint) {
LocationUtil.teleportPlayerToSpawn(all);
} else {
Bukkit.getServer().getLogger().log(Level.WARNING, "SkyBlock | Error: A spawn point hasn't been set.");
}
break;
}
}
if (!island.isRole(Role.Owner, all.getUniqueId())) {
all.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Deletion.Broadcast.Message")));
soundManager.playSound(all, Sounds.EXPLODE.bukkitSound(), 10.0F, 10.0F);
}
}
}
islandManager.deleteIsland(island);
plugin.getVisitManager().deleteIsland(player.getUniqueId());
plugin.getBanManager().deleteIsland(player.getUniqueId());
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Delete.Deleted.Message").replace("%player", targetPlayerName)));
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Delete.Owner.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Delete.Invalid.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Delete.Permission.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "delete";
}
@Override
public String getInfo() {
return info;
}
@Override
public SubCommand setInfo(String info) {
this.info = info;
return this;
}
@Override
public String[] getAliases() {
return new String[] { "remove", "disband" };
}
@Override
public Type getType() {
return CommandManager.Type.Admin;
}
}

View File

@ -0,0 +1,80 @@
package me.goodandevil.skyblock.command.commands.admin;
import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.menus.admin.Generator;
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
public class GeneratorCommand extends SubCommand {
private final Main plugin;
private String info;
public GeneratorCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
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 (!(player.hasPermission("skyblock.admin.generator") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*"))) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Generator.Permission.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (plugin.getGeneratorManager() == null) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Generator.Disabled.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
if (playerDataManager.hasPlayerData(player)) {
playerDataManager.getPlayerData(player).setViewer(null);
}
Generator.getInstance().open(player);
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "generator";
}
@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

@ -0,0 +1,71 @@
package me.goodandevil.skyblock.command.commands.admin;
import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.menus.admin.Levelling;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
public class LevelCommand extends SubCommand {
private final Main plugin;
private String info;
public LevelCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
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.level") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*")) {
Levelling.getInstance().open(player);
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Level.Permission.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "level";
}
@Override
public String getInfo() {
return info;
}
@Override
public SubCommand setInfo(String info) {
this.info = info;
return this;
}
@Override
public String[] getAliases() {
return new String[] { "levelling" , "points" };
}
@Override
public Type getType() {
return CommandManager.Type.Admin;
}
}

View File

@ -0,0 +1,111 @@
package me.goodandevil.skyblock.command.commands.admin;
import java.io.File;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.playerdata.PlayerDataManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.OfflinePlayer;
import me.goodandevil.skyblock.utils.version.Sounds;
public class OwnerCommand extends SubCommand {
private final Main plugin;
private String info;
public OwnerCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
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 (player.hasPermission("skyblock.admin.owner") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*")) {
if (args.length == 1) {
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
UUID targetPlayerUUID, islandOwnerUUID;
String targetPlayerName, islandOwnerName;
if (targetPlayer == null) {
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
targetPlayerUUID = targetPlayerOffline.getUniqueId();
islandOwnerUUID = targetPlayerOffline.getOwner();
targetPlayerName = targetPlayerOffline.getName();
} else {
targetPlayerUUID = targetPlayer.getUniqueId();
islandOwnerUUID = playerDataManager.getPlayerData(player).getOwner();
targetPlayerName = targetPlayer.getName();
}
if (islandOwnerUUID == null) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Owner.Island.None.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
} else if (islandOwnerUUID.equals(targetPlayerUUID)) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Owner.Island.Owner.Message").replace("%player", targetPlayerName)));
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
} else {
targetPlayer = Bukkit.getServer().getPlayer(islandOwnerUUID);
if (targetPlayer == null) {
islandOwnerName = new OfflinePlayer(islandOwnerUUID).getName();
} else {
islandOwnerName = targetPlayer.getName();
}
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Owner.Island.Member.Message").replace("%player", targetPlayerName).replace("%owner", islandOwnerName)));
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Owner.Invalid.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Owner.Permission.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "owner";
}
@Override
public String getInfo() {
return info;
}
@Override
public SubCommand setInfo(String info) {
this.info = info;
return this;
}
@Override
public String[] getAliases() {
return new String[] { "ownership", "leader" };
}
@Override
public Type getType() {
return CommandManager.Type.Admin;
}
}

View File

@ -0,0 +1,87 @@
package me.goodandevil.skyblock.command.commands.admin;
import java.io.File;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
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.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
public class ReloadCommand extends SubCommand {
private final Main plugin;
private String info;
public ReloadCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
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.reload") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*")) {
Map<String, Config> configs = fileManager.getConfigs();
for (int i = 0; i < configs.size(); i++) {
String configFileName = (String) configs.keySet().toArray()[i];
Config configFileConfig = configs.get(configFileName);
String configFilePath = configFileName.replace(configFileConfig.getFile().getName(), "");
if (configFilePath.equals(plugin.getDataFolder().toString() + "\\") || configFilePath.equals(plugin.getDataFolder().toString() + "/") ) {
configFileConfig.loadFile();
}
}
if (plugin.getScoreboardManager() != null) {
plugin.getScoreboardManager().resendScoreboard();
}
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Reload.Reloaded.Message")));
soundManager.playSound(player, Sounds.ANVIL_USE.bukkitSound(), 1.0F, 1.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Reload.Permission.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "reload";
}
@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

@ -0,0 +1,84 @@
package me.goodandevil.skyblock.command.commands.admin;
import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
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.Location;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
public class SetSpawnCommand extends SubCommand {
private final Main plugin;
private String info;
public SetSpawnCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
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.setspawn") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*")) {
for (Location.World worldList : Location.World.values()) {
World world = plugin.getWorldManager().getWorld(worldList);
if (world.getName().equals(player.getWorld().getName())) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.SetSpawn.World.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
}
fileManager.setLocation(fileManager.getConfig(new File(plugin.getDataFolder(), "locations.yml")), "Location.Spawn", player.getLocation(), true);
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.SetSpawn.Set.Message")));
soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.SetSpawn.Permission.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "setspawn";
}
@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

@ -0,0 +1,182 @@
package me.goodandevil.skyblock.command.commands.admin;
import java.io.File;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import me.goodandevil.skyblock.command.CommandManager.Type;
import me.goodandevil.skyblock.config.FileManager.Config;
import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.ChatComponent;
import me.goodandevil.skyblock.utils.structure.StructureUtil;
import me.goodandevil.skyblock.utils.version.Sounds;
import me.goodandevil.skyblock.utils.world.LocationUtil;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import me.goodandevil.skyblock.Main;
import me.goodandevil.skyblock.command.CommandManager;
import me.goodandevil.skyblock.command.SubCommand;
public class StructureCommand extends SubCommand {
private final Main plugin;
private String info;
public StructureCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public void onCommand(Player player, String[] args) {
SoundManager soundManager = plugin.getSoundManager();
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (args.length == 0 || (args.length > 0 && args[0].equalsIgnoreCase("help"))) {
for (String helpLines : configLoad.getStringList("Command.Island.Help.Lines")) {
if (helpLines.contains("%type")) {
helpLines = helpLines.replace("%type", "Structure");
}
if (helpLines.contains("%commands")) {
String[] sections = helpLines.split("%commands");
String prefix = "", suffix = "";
if (sections.length >= 1) {
prefix = ChatColor.translateAlternateColorCodes('&', sections[0]);
}
if (sections.length == 2) {
suffix = ChatColor.translateAlternateColorCodes('&', sections[1]);
}
player.spigot().sendMessage(new ChatComponent(prefix.replace("%info", ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Tool.Info.Message"))) + "/island admin structure tool" + suffix.replace("%info", ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Tool.Info.Message"))), false, null, null, new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Tool.Info.Message"))).create())).getTextComponent());
player.spigot().sendMessage(new ChatComponent(prefix.replace("%info", ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Save.Info.Message"))) + "/island admin structure save" + suffix.replace("%info", ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Save.Info.Message"))), false, null, null, new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Save.Info.Message"))).create())).getTextComponent());
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', helpLines));
}
}
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
return;
} else {
if (args[0].equalsIgnoreCase("tool")) {
if (player.hasPermission("skyblock.admin.structure.tool") || player.hasPermission("skyblock.admin.structure.*") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*")) {
try {
ItemStack is = StructureUtil.getTool();
for (ItemStack itemList : player.getInventory().getContents()) {
if (itemList != null) {
if ((itemList.getType() == is.getType()) && (itemList.hasItemMeta()) && (itemList.getItemMeta().getDisplayName().equals(is.getItemMeta().getDisplayName()))) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Tool.Inventory.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
}
}
player.getInventory().addItem(is);
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Tool.Equiped.Message")));
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F);
} catch (Exception e) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Structure.Tool.Material.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
Bukkit.getServer().getLogger().log(Level.WARNING, "SkyBlock | Error: The defined material in the configuration file for the Structure selection tool could not be found.");
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Tool.Permission.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
return;
} else if (args[0].equalsIgnoreCase("save")) {
if (player.hasPermission("skyblock.admin.structure.save") || player.hasPermission("skyblock.admin.structure.*") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*")) {
if (args.length == 2) {
PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player);
Location position1Location = playerData.getArea().getPosition(1);
Location position2Location = playerData.getArea().getPosition(2);
if (position1Location == null && position2Location == null) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Save.Position.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if ((position1Location == null && position2Location != null) || (position1Location != null && position2Location == null)) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Save.Complete.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (!position1Location.getWorld().getName().equals(position2Location.getWorld().getName())) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Save.Selection.World.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (!player.getWorld().getName().equals(position1Location.getWorld().getName())) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Save.Player.World.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (!LocationUtil.isInsideArea(player.getLocation(), position1Location, position2Location)) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Save.Player.Area.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
try {
File configFile = new File(plugin.getDataFolder().toString() + "/structures/" + args[1] + ".structure");
StructureUtil.saveStructure(configFile, player.getLocation(), StructureUtil.getFixedLocations(position1Location, position2Location));
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Save.Saved.Successful.Message").replace("%name", args[1])));
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
} catch(Exception e) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Save.Saved.Failed.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
e.printStackTrace();
}
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Save.Invalid.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Tool.Save.Message")));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
return;
}
player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Argument.Unrecognised.Message")));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "structure";
}
@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

@ -0,0 +1,110 @@
package me.goodandevil.skyblock.config;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import me.goodandevil.skyblock.Main;
public class FileChecker {
private Map<File.Type, File> loadedFiles;
public FileChecker(Main plugin, String configurationFileName) {
loadedFiles = new EnumMap<>(File.Type.class);
java.io.File configFile = new java.io.File(plugin.getDataFolder(), configurationFileName);
loadedFiles.put(File.Type.CREATED, new File(configFile, YamlConfiguration.loadConfiguration(configFile)));
loadedFiles.put(File.Type.RESOURCE, new File(null, YamlConfiguration.loadConfiguration(new InputStreamReader(plugin.getResource(configurationFileName)))));
}
public void loadSections() {
for (File.Type fileType : File.Type.values()) {
File file = loadedFiles.get(fileType);
FileConfiguration configLoad = file.getFileConfiguration();
Set<String> configKeys = configLoad.getKeys(true);
for (String configKeysList : configKeys) {
file.addKey(configKeysList, configLoad.get(configKeysList));
}
}
}
public void compareFiles() {
for (File.Type fileType : File.Type.values()) {
File file = loadedFiles.get(fileType);
FileConfiguration configLoad = file.getFileConfiguration();
if (fileType == File.Type.CREATED) {
File resourceFile = loadedFiles.get(File.Type.RESOURCE);
for (String configKeysList : file.getKeys().keySet()) {
if (!resourceFile.getKeys().containsKey(configKeysList)) {
configLoad.set(configKeysList, null);
}
}
} else if (fileType == File.Type.RESOURCE) {
File createdFile = loadedFiles.get(File.Type.CREATED);
FileConfiguration createdConfigLoad = createdFile.getFileConfiguration();
for (String configKeysList : file.getKeys().keySet()) {
if (createdConfigLoad.getString(configKeysList) == null) {
createdConfigLoad.set(configKeysList, file.getKeys().get(configKeysList));
}
}
}
}
}
public void saveChanges() {
File file = loadedFiles.get(File.Type.CREATED);
try {
file.getFileConfiguration().save(file.getFile());
} catch (IOException e) {
e.printStackTrace();
}
}
public static class File {
private java.io.File configFile;
private FileConfiguration configLoad;
private HashMap<String, Object> configKeys;
public File(java.io.File configFile, FileConfiguration configLoad) {
this.configFile = configFile;
this.configLoad = configLoad;
configKeys = new HashMap<>();
}
public java.io.File getFile() {
return configFile;
}
public FileConfiguration getFileConfiguration() {
return configLoad;
}
public HashMap<String, Object> getKeys() {
return configKeys;
}
public void addKey(String key, Object object) {
configKeys.put(key, object);
}
public enum Type {
CREATED,
RESOURCE;
}
}
}

View File

@ -0,0 +1,181 @@
package me.goodandevil.skyblock.config;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import com.google.common.io.ByteStreams;
import me.goodandevil.skyblock.Main;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
public class FileManager {
private final Main plugin;
private Map<String, Config> loadedConfigs = new HashMap<>();
public FileManager(Main plugin) {
this.plugin = plugin;
loadConfigs();
}
public void loadConfigs() {
if (!plugin.getDataFolder().exists()) {
plugin.getDataFolder().mkdir();
}
if (!new File(plugin.getDataFolder().toString() + "/structures").exists()) {
new File(plugin.getDataFolder().toString() + "/structures").mkdir();
}
Map<String, File> configFiles = new HashMap<>();
configFiles.put("levelling.yml", new File(plugin.getDataFolder(), "levelling.yml"));
configFiles.put("config.yml", new File(plugin.getDataFolder(), "config.yml"));
configFiles.put("language.yml", new File(plugin.getDataFolder(), "language.yml"));
configFiles.put("settings.yml", new File(plugin.getDataFolder(), "settings.yml"));
configFiles.put("generators.yml", new File(plugin.getDataFolder(), "generators.yml"));
configFiles.put("structures.yml", new File(plugin.getDataFolder(), "structures.yml"));
configFiles.put("structures/default.structure", new File(plugin.getDataFolder().toString() + "/structures", "default.structure"));
for (String configFileList : configFiles.keySet()) {
File configFile = configFiles.get(configFileList);
if (configFile.exists()) {
if (configFileList.equals("config.yml") || configFileList.equals("language.yml")) {
FileChecker fileChecker = new FileChecker(plugin, configFileList);
fileChecker.loadSections();
fileChecker.compareFiles();
fileChecker.saveChanges();
}
} else {
try {
configFile.createNewFile();
try (InputStream is = plugin.getResource(configFileList);
OutputStream os = new FileOutputStream(configFile)) {
ByteStreams.copy(is, os);
}
} catch (IOException ex) {
Bukkit.getServer().getLogger().log(Level.WARNING, "SkyBlock | Error: Unable to create configuration file.");
}
}
}
}
public void setLocation(Config config, String path, Location location, boolean direction) {
File configFile = config.getFile();
FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set(path + ".world", location.getWorld().getName());
configLoad.set(path + ".x", Double.valueOf(location.getX()));
configLoad.set(path + ".y", Double.valueOf(location.getY()));
configLoad.set(path + ".z", Double.valueOf(location.getZ()));
if (direction) {
configLoad.set(path + ".yaw", Float.valueOf(location.getYaw()));
configLoad.set(path + ".pitch", Float.valueOf(location.getPitch()));
}
try {
configLoad.save(configFile);
} catch (IOException ex) {
ex.printStackTrace();
}
plugin.getConfig();
}
public Location getLocation(Config config, String path, boolean direction) {
Location location = null;
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.contains(path)) {
String world = configLoad.getString(path + ".world");
double x = configLoad.getDouble(path + ".x");
double y = configLoad.getDouble(path + ".y");
double z = configLoad.getDouble(path + ".z");
double yaw = 0.0D;
double pitch = 0.0D;
if (configLoad.contains(path + ".yaw")) {
yaw = configLoad.getDouble(path + ".yaw");
pitch = configLoad.getDouble(path + ".pitch");
}
location = new org.bukkit.Location(Bukkit.getWorld(world), x, y, z);
if (direction) {
location.setYaw((float) yaw);
location.setPitch((float) pitch);
}
}
return location;
}
public boolean isFileExist(File configPath) {
return configPath.exists();
}
public void unloadConfig(File configPath) {
loadedConfigs.remove(configPath.getPath());
}
public void deleteConfig(File configPath) {
Config config = getConfig(configPath);
config.getFile().delete();
loadedConfigs.remove(configPath.getPath());
}
public Config getConfig(File configPath) {
if (loadedConfigs.containsKey(configPath.getPath())) {
return loadedConfigs.get(configPath.getPath());
}
Config config = new Config(configPath);
loadedConfigs.put(configPath.getPath(), config);
return config;
}
public Map<String, Config> getConfigs() {
return loadedConfigs;
}
public boolean isConfigLoaded(java.io.File configPath) {
return loadedConfigs.containsKey(configPath.getPath());
}
public static class Config {
private File configFile;
private FileConfiguration configLoad;
public Config(java.io.File configPath) {
configFile = configPath;
configLoad = YamlConfiguration.loadConfiguration(configFile);
}
public File getFile() {
return configFile;
}
public FileConfiguration getFileConfiguration() {
return configLoad;
}
public void loadFile() {
configLoad = YamlConfiguration.loadConfiguration(configFile);
}
}
}

View File

@ -0,0 +1,8 @@
package me.goodandevil.skyblock.confirmation;
public enum Confirmation {
Ownership,
Deletion;
}

View File

@ -0,0 +1,30 @@
package me.goodandevil.skyblock.confirmation;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
public class ConfirmationTask extends BukkitRunnable {
private final PlayerDataManager playerDataManager;
public ConfirmationTask(PlayerDataManager playerDataManager) {
this.playerDataManager = playerDataManager;
}
@Override
public void run() {
for (Player all : Bukkit.getOnlinePlayers()) {
if (playerDataManager.hasPlayerData(all)) {
PlayerData playerData = playerDataManager.getPlayerData(all);
if (playerData.getConfirmationTime() > 0) {
playerData.setConfirmationTime(playerData.getConfirmationTime() - 1);
}
}
}
}
}

View File

@ -0,0 +1,18 @@
package me.goodandevil.skyblock.creation;
public class Creation {
private int time;
public Creation(int time) {
this.time = time;
}
public int getTime() {
return time;
}
public void setTime(int time) {
this.time = time;
}
}

View File

@ -0,0 +1,125 @@
package me.goodandevil.skyblock.creation;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import me.goodandevil.skyblock.Main;
import me.goodandevil.skyblock.config.FileManager.Config;
public class CreationManager {
private final Main plugin;
private Map<UUID, Creation> playerCreationStorage = new HashMap<>();
public CreationManager(Main plugin) {
this.plugin = plugin;
new CreationTask(plugin).runTaskTimerAsynchronously(plugin, 0L, 20L);
for (Player all : Bukkit.getOnlinePlayers()) {
loadPlayer(all);
}
}
public void onDisable() {
for (Player all : Bukkit.getOnlinePlayers()) {
savePlayer(all);
}
}
public void createPlayer(Player player, int time) {
savePlayer(player.getUniqueId(), time);
Creation creation = new Creation(time);
playerCreationStorage.put(player.getUniqueId(), creation);
}
public void createOfflinePlayer(UUID uuid, int time) {
savePlayer(uuid, time);
}
private void savePlayer(UUID uuid, int time) {
Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), uuid.toString() + ".yml"));
File configFile = config.getFile();
FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set("Island.Creation.Cooldown", time);
try {
configLoad.save(configFile);
} catch (IOException e) {
e.printStackTrace();
}
}
public void loadPlayer(Player player) {
Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getString("Island.Creation.Cooldown") != null) {
Creation creation = new Creation(configLoad.getInt("Island.Creation.Cooldown"));
playerCreationStorage.put(player.getUniqueId(), creation);
}
}
public void removePlayer(Player player) {
if (hasPlayer(player)) {
Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml"));
File configFile = config.getFile();
FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set("Island.Creation.Cooldown", null);
try {
configLoad.save(configFile);
} catch (IOException e) {
e.printStackTrace();
}
playerCreationStorage.remove(player.getUniqueId());
}
}
public void savePlayer(Player player) {
if (hasPlayer(player)) {
Creation creation = getPlayer(player);
Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml"));
File configFile = config.getFile();
FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set("Island.Creation.Cooldown", creation.getTime());
try {
configLoad.save(configFile);
} catch (IOException e) {
e.printStackTrace();
}
}
}
public void unloadPlayer(Player player) {
if (hasPlayer(player)) {
playerCreationStorage.remove(player.getUniqueId());
}
}
public Creation getPlayer(Player player) {
if (hasPlayer(player)) {
return playerCreationStorage.get(player.getUniqueId());
}
return null;
}
public boolean hasPlayer(Player player) {
return playerCreationStorage.containsKey(player.getUniqueId());
}
}

View File

@ -0,0 +1,32 @@
package me.goodandevil.skyblock.creation;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import me.goodandevil.skyblock.Main;
public class CreationTask extends BukkitRunnable {
private final Main plugin;
protected CreationTask(Main plugin) {
this.plugin = plugin;
}
@Override
public void run() {
/*CreationManager creationManager = plugin.getCreationManager();
for (Player all : Bukkit.getOnlinePlayers()) {
if (creationManager.hasPlayer(all)) {
Creation creation = creationManager.getPlayer(all);
creation.setTime(creation.getTime() - 1);
if (creation.getTime() == 0) {
creationManager.removePlayer(all);
}
}
}*/
}
}

View File

@ -0,0 +1,37 @@
package me.goodandevil.skyblock.events;
import java.util.UUID;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.ban.Ban;
public class IslandBanEvent extends Event {
private Ban ban;
private UUID uuid;
public IslandBanEvent(UUID uuid, Ban ban) {
this.uuid = uuid;
this.ban = ban;
}
public UUID getUniqueId() {
return uuid;
}
public UUID getUUID() {
return uuid;
}
public Ban getBan() {
return ban;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,37 @@
package me.goodandevil.skyblock.events;
import org.bukkit.block.Biome;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.island.Island;
public class IslandBiomeChangeEvent extends Event {
private Biome oldBiome, newBiome;
private Island island;
public IslandBiomeChangeEvent(Island island, Biome oldBiome, Biome newBiome) {
this.island = island;
this.oldBiome = oldBiome;
this.newBiome = newBiome;
}
public Biome getOldBiome() {
return oldBiome;
}
public Biome getNewBiome() {
return newBiome;
}
public Island getIsland() {
return island;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,60 @@
package me.goodandevil.skyblock.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.island.Island;
public class IslandChatEvent extends Event {
private Player player;
private Island island;
private String message, format;
private boolean cancel = false;
public IslandChatEvent(Player player, Island island, String message, String format) {
this.player = player;
this.island = island;
this.message = message;
this.format = format;
}
public Player getPlayer() {
return player;
}
public Island getIsland() {
return island;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getFormat() {
return format;
}
public void setFormat(String format) {
this.format = format;
}
public boolean isCancelled() {
return cancel;
}
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,38 @@
package me.goodandevil.skyblock.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.island.Island;
public class IslandChatSwitchEvent extends Event {
private Player player;
private Island island;
private boolean chat;
public IslandChatSwitchEvent(Player player, Island island, boolean chat) {
this.player = player;
this.island = island;
this.chat = chat;
}
public Player getPlayer() {
return player;
}
public Island getIsland() {
return island;
}
public boolean isChat() {
return chat;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,32 @@
package me.goodandevil.skyblock.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.island.Island;
public class IslandCreateEvent extends Event {
private Player player;
private Island island;
public IslandCreateEvent(Player player, Island island) {
this.player = player;
this.island = island;
}
public Player getPlayer() {
return player;
}
public Island getIsland() {
return island;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,25 @@
package me.goodandevil.skyblock.events;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.island.Island;
public class IslandDeleteEvent extends Event {
private Island island;
public IslandDeleteEvent(Island island) {
this.island = island;
}
public Island getIsland() {
return island;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,32 @@
package me.goodandevil.skyblock.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.island.Island;
public class IslandEnterEvent extends Event {
private Player player;
private Island island;
public IslandEnterEvent(Player player, Island island) {
this.player = player;
this.island = island;
}
public Player getPlayer() {
return player;
}
public Island getIsland() {
return island;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,32 @@
package me.goodandevil.skyblock.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.island.Island;
public class IslandExitEvent extends Event {
private Player player;
private Island island;
public IslandExitEvent(Player player, Island island) {
this.player = player;
this.island = island;
}
public Player getPlayer() {
return player;
}
public Island getIsland() {
return island;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,44 @@
package me.goodandevil.skyblock.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.invite.Invite;
import me.goodandevil.skyblock.island.Island;
public class IslandInviteEvent extends Event {
private Player invited, inviter;
private Island island;
private Invite invite;
public IslandInviteEvent(Player invited, Player inviter, Island island, Invite invite) {
this.invited = invited;
this.inviter = inviter;
this.island = island;
this.invite = invite;
}
public Player getInvited() {
return invited;
}
public Player getInviter() {
return inviter;
}
public Island getIsland() {
return island;
}
public Invite getInvite() {
return invite;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,41 @@
package me.goodandevil.skyblock.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.island.Island;
public class IslandJoinEvent extends Event {
private Player player;
private Island island;
private boolean cancel = false;
public IslandJoinEvent(Player player, Island island) {
this.player = player;
this.island = island;
}
public Player getPlayer() {
return player;
}
public Island getIsland() {
return island;
}
public boolean isCancelled() {
return cancel;
}
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,56 @@
package me.goodandevil.skyblock.events;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.island.Island;
import me.goodandevil.skyblock.island.Role;
public class IslandKickEvent extends Event {
private Player kicker;
private UUID kicked;
private Island island;
private Role role;
private boolean cancel = false;
public IslandKickEvent(Island island, Role role, UUID kicked, Player kicker) {
this.island = island;
this.role = role;
this.kicked = kicked;
this.kicker = kicker;
}
public UUID getKicked() {
return kicked;
}
public Player getKicker() {
return kicker;
}
public Role getRole() {
return role;
}
public Island getIsland() {
return island;
}
public boolean isCancelled() {
return cancel;
}
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,41 @@
package me.goodandevil.skyblock.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.island.Island;
public class IslandLeaveEvent extends Event {
private Player player;
private Island island;
private boolean cancel = false;
public IslandLeaveEvent(Player player, Island island) {
this.player = player;
this.island = island;
}
public Player getPlayer() {
return player;
}
public Island getIsland() {
return island;
}
public boolean isCancelled() {
return cancel;
}
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,32 @@
package me.goodandevil.skyblock.events;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.island.Island;
import me.goodandevil.skyblock.island.Level;
public class IslandLevelChangeEvent extends Event {
private Island island;
private Level level;
public IslandLevelChangeEvent(Island island, Level level) {
this.island = island;
this.level = level;
}
public Island getIsland() {
return island;
}
public Level getLevel() {
return level;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,25 @@
package me.goodandevil.skyblock.events;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.island.Island;
public class IslandLoadEvent extends Event {
private Island island;
public IslandLoadEvent(Island island) {
this.island = island;
}
public Island getIsland() {
return island;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,37 @@
package me.goodandevil.skyblock.events;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.island.Island;
import me.goodandevil.skyblock.island.Location;
public class IslandLocationChangeEvent extends Event {
private Location oldLocation, newLocation;
private Island island;
public IslandLocationChangeEvent(Island island, Location oldLocation, Location newLocation) {
this.island = island;
this.oldLocation = oldLocation;
this.newLocation = newLocation;
}
public Location getOldLocation() {
return oldLocation;
}
public Location getNewLocation() {
return newLocation;
}
public Island getIsland() {
return island;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,55 @@
package me.goodandevil.skyblock.events;
import java.util.List;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.island.Island;
import me.goodandevil.skyblock.island.Message;
public class IslandMessageChangeEvent extends Event {
private Island island;
private Message message;
private List<String> lines;
private String author;
private boolean cancel = false;
public IslandMessageChangeEvent(Island island, Message message, List<String> lines, String author) {
this.island = island;
this.message = message;
this.lines = lines;
this.author = author;
}
public Island getIsland() {
return island;
}
public Message getMessage() {
return message;
}
public List<String> getLines() {
return lines;
}
public String getAuthor() {
return author;
}
public boolean isCancelled() {
return cancel;
}
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,39 @@
package me.goodandevil.skyblock.events;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.island.Island;
public class IslandOpenEvent extends Event {
private Island island;
private boolean open, cancel = false;
public IslandOpenEvent(Island island, boolean open) {
this.island = island;
this.open = open;
}
public Island getIsland() {
return island;
}
public boolean isOpen() {
return open;
}
public boolean isCancelled() {
return cancel;
}
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,38 @@
package me.goodandevil.skyblock.events;
import java.util.UUID;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.island.Island;
public class IslandOwnershipTransferEvent extends Event {
private UUID oldOwnerUUID, newOwnerUUID;
private Island island;
public IslandOwnershipTransferEvent(Island island, UUID oldOwnerUUID, UUID newOwnerUUID) {
this.island = island;
this.oldOwnerUUID = oldOwnerUUID;
this.newOwnerUUID = newOwnerUUID;
}
public UUID getOldOwnerUUID() {
return oldOwnerUUID;
}
public UUID getNewOwnerUUID() {
return newOwnerUUID;
}
public Island getIsland() {
return island;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,45 @@
package me.goodandevil.skyblock.events;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.island.Island;
public class IslandPasswordChangeEvent extends Event {
private String oldPassword, newPassword;
private boolean cancel = false;
private Island island;
public IslandPasswordChangeEvent(Island island, String oldPassword, String newPassword) {
this.island = island;
this.oldPassword = oldPassword;
this.newPassword = newPassword;
}
public String getOldPassword() {
return oldPassword;
}
public String getNewPassword() {
return newPassword;
}
public Island getIsland() {
return island;
}
public boolean isCancelled() {
return cancel;
}
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,49 @@
package me.goodandevil.skyblock.events;
import java.util.UUID;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.island.Island;
import me.goodandevil.skyblock.island.Role;
public class IslandRoleChangeEvent extends Event {
private UUID uuid;
private Island island;
private Role oldRole, newRole;
public IslandRoleChangeEvent(UUID uuid, Island island, Role oldRole, Role newRole) {
this.uuid = uuid;
this.island = island;
this.oldRole = oldRole;
this.newRole = newRole;
}
public UUID getUUID() {
return uuid;
}
public UUID getUniqueId() {
return uuid;
}
public Role getOldRole() {
return oldRole;
}
public Role getNewRole() {
return newRole;
}
public Island getIsland() {
return island;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,37 @@
package me.goodandevil.skyblock.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.island.Island;
public class IslandSwitchEvent extends Event {
private Player player;
private Island oldIsland, newIsland;
public IslandSwitchEvent(Player player, Island oldIsland, Island newIsland) {
this.player = player;
this.oldIsland = oldIsland;
this.newIsland = newIsland;
}
public Player getPlayer() {
return player;
}
public Island getOldIsland() {
return oldIsland;
}
public Island getNewIsland() {
return newIsland;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,37 @@
package me.goodandevil.skyblock.events;
import java.util.UUID;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.ban.Ban;
public class IslandUnbanEvent extends Event {
private Ban ban;
private UUID uuid;
public IslandUnbanEvent(UUID uuid, Ban ban) {
this.uuid = uuid;
this.ban = ban;
}
public UUID getUniqueId() {
return uuid;
}
public UUID getUUID() {
return uuid;
}
public Ban getBan() {
return ban;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,25 @@
package me.goodandevil.skyblock.events;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.island.Island;
public class IslandUnloadEvent extends Event {
private Island island;
public IslandUnloadEvent(Island island) {
this.island = island;
}
public Island getIsland() {
return island;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,44 @@
package me.goodandevil.skyblock.events;
import org.bukkit.WeatherType;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.goodandevil.skyblock.island.Island;
public class IslandWeatherChangeEvent extends Event {
private Island island;
private WeatherType weather;
private int time;
private boolean synchronised;
public IslandWeatherChangeEvent(Island island, WeatherType weather, int time, boolean synchronised) {
this.island = island;
this.weather = weather;
this.time = time;
this.synchronised = synchronised;
}
public Island getIsland() {
return island;
}
public WeatherType getWeather() {
return weather;
}
public int getTime() {
return time;
}
public boolean isSynchornised() {
return synchronised;
}
private static final HandlerList handlers = new HandlerList();
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,43 @@
package me.goodandevil.skyblock.generator;
import java.util.List;
import me.goodandevil.skyblock.utils.version.Materials;
public class Generator {
private String name;
private Materials materials;
private List<GeneratorMaterial> generatorMaterials;
private boolean permission;
public Generator(String name, Materials materials, List<GeneratorMaterial> generatorMaterials, boolean permission) {
this.name = name;
this.materials = materials;
this.generatorMaterials = generatorMaterials;
}
public String getName() {
return name;
}
public Materials getMaterials() {
return materials;
}
public List<GeneratorMaterial> getGeneratorMaterials() {
return generatorMaterials;
}
public boolean isPermission() {
return permission;
}
public String getPermission() {
return "skyblock.generator." + name.toLowerCase().replace(" ", "_");
}
public void setPermission(boolean permission) {
this.permission = permission;
}
}

View File

@ -0,0 +1,60 @@
package me.goodandevil.skyblock.generator;
import org.bukkit.block.Block;
import me.goodandevil.skyblock.island.Location;
public class GeneratorLocation {
private Location.World world;
private int blockX;
private int blockY;
private int blockZ;
private int liquidX;
private int liquidY;
private int liquidZ;
public GeneratorLocation(Location.World world, Block block, Block liquid) {
this.world = world;
this.blockX = block.getLocation().getBlockX();
this.blockY = block.getLocation().getBlockY();
this.blockZ = block.getLocation().getBlockZ();
if (liquid != null) {
this.liquidX = liquid.getLocation().getBlockX();
this.liquidY = liquid.getLocation().getBlockY();
this.liquidZ = liquid.getLocation().getBlockZ();
}
}
public Location.World getWorld() {
return world;
}
public int getBlockX() {
return blockX;
}
public int getBlockY() {
return blockY;
}
public int getBlockZ() {
return blockZ;
}
public int getLiquidX() {
return liquidX;
}
public int getLiquidY() {
return liquidY;
}
public int getLiquidZ() {
return liquidZ;
}
}

View File

@ -0,0 +1,188 @@
package me.goodandevil.skyblock.generator;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.Levelled;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import me.goodandevil.skyblock.Main;
import me.goodandevil.skyblock.config.FileManager.Config;
import me.goodandevil.skyblock.utils.version.Materials;
import me.goodandevil.skyblock.utils.version.NMSUtil;
import me.goodandevil.skyblock.utils.version.Sounds;
public class GeneratorManager {
private final Main plugin;
private List<Generator> generatorStorage = new ArrayList<>();
public GeneratorManager(Main plugin) {
this.plugin = plugin;
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "generators.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getString("Generators") != null) {
Materials[] oreMaterials = new Materials[] { Materials.COAL, Materials.CHARCOAL, Materials.DIAMOND, Materials.IRON_INGOT, Materials.GOLD_INGOT, Materials.EMERALD };
Random rnd = new Random();
for (String generatorList : configLoad.getConfigurationSection("Generators").getKeys(false)) {
List<GeneratorMaterial> generatorMaterials = new ArrayList<>();
if (configLoad.getString("Generators." + generatorList + ".Materials") != null) {
for (String materialList : configLoad.getConfigurationSection("Generators." + generatorList + ".Materials").getKeys(false)) {
Materials materials = Materials.fromString(materialList);
if (materials != null) {
generatorMaterials.add(new GeneratorMaterial(materials, configLoad.getInt("Generators." + generatorList + ".Materials." + materialList + ".Chance")));
}
}
}
generatorStorage.add(new Generator(configLoad.getString("Generators." + generatorList + ".Name"), oreMaterials[rnd.nextInt(oreMaterials.length)], generatorMaterials, configLoad.getBoolean("Generators." + generatorList + ".Permission")));
}
}
}
@SuppressWarnings("deprecation")
public boolean isGenerator(Block block) {
if (block.getRelative(BlockFace.UP).getType() != Materials.LEGACY_STATIONARY_WATER.getPostMaterial() && block.getRelative(BlockFace.UP).getType() != Materials.WATER.parseMaterial()) {
Block flowBlock = null;
if ((block.getRelative(BlockFace.NORTH).getType() != Materials.LEGACY_STATIONARY_WATER.getPostMaterial() && block.getRelative(BlockFace.NORTH).getType() != Materials.WATER.parseMaterial()) && (block.getRelative(BlockFace.EAST).getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial() || block.getRelative(BlockFace.EAST).getType() == Materials.WATER.parseMaterial()) && (block.getRelative(BlockFace.SOUTH).getType() != Materials.LEGACY_STATIONARY_WATER.getPostMaterial() && block.getRelative(BlockFace.SOUTH).getType() != Materials.WATER.parseMaterial()) && (block.getRelative(BlockFace.WEST).getType() == Materials.LEGACY_STATIONARY_LAVA.getPostMaterial() || block.getRelative(BlockFace.WEST).getType() == Materials.LAVA.parseMaterial()) && (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(BlockFace.EAST).getType() == Material.AIR || block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(BlockFace.EAST).getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial())) {
flowBlock = block.getRelative(BlockFace.EAST);
} else if ((block.getRelative(BlockFace.NORTH).getType() != Materials.LEGACY_STATIONARY_WATER.getPostMaterial() && block.getRelative(BlockFace.NORTH).getType() != Materials.WATER.parseMaterial()) && (block.getRelative(BlockFace.EAST).getType() == Materials.LEGACY_STATIONARY_LAVA.getPostMaterial() || block.getRelative(BlockFace.EAST).getType() == Materials.LAVA.parseMaterial()) && (block.getRelative(BlockFace.SOUTH).getType() != Materials.LEGACY_STATIONARY_WATER.getPostMaterial() && block.getRelative(BlockFace.SOUTH).getType() != Materials.WATER.parseMaterial()) && (block.getRelative(BlockFace.WEST).getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial() || block.getRelative(BlockFace.WEST).getType() == Materials.WATER.parseMaterial()) && (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(BlockFace.WEST).getType() == Material.AIR || block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(BlockFace.WEST).getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial())) {
flowBlock = block.getRelative(BlockFace.WEST);
} else if (((block.getRelative(BlockFace.NORTH).getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial() || block.getRelative(BlockFace.NORTH).getType() == Materials.WATER.parseMaterial()) && block.getRelative(BlockFace.EAST).getType() != Materials.LEGACY_STATIONARY_WATER.getPostMaterial() && block.getRelative(BlockFace.EAST).getType() != Materials.WATER.parseMaterial()) && (block.getRelative(BlockFace.SOUTH).getType() == Materials.LEGACY_STATIONARY_LAVA.getPostMaterial() || block.getRelative(BlockFace.SOUTH).getType() == Materials.LAVA.parseMaterial()) && (block.getRelative(BlockFace.WEST).getType() != Materials.LEGACY_STATIONARY_WATER.getPostMaterial() && block.getRelative(BlockFace.WEST).getType() != Materials.WATER.parseMaterial()) && (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(BlockFace.NORTH).getType() == Material.AIR || block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(BlockFace.NORTH).getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial())) {
flowBlock = block.getRelative(BlockFace.NORTH);
} else if (((block.getRelative(BlockFace.NORTH).getType() == Materials.LEGACY_STATIONARY_LAVA.getPostMaterial() || block.getRelative(BlockFace.NORTH).getType() == Materials.LAVA.parseMaterial()) && block.getRelative(BlockFace.EAST).getType() != Materials.LEGACY_STATIONARY_WATER.getPostMaterial() && block.getRelative(BlockFace.EAST).getType() != Materials.WATER.parseMaterial()) && (block.getRelative(BlockFace.SOUTH).getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial() || block.getRelative(BlockFace.SOUTH).getType() == Materials.WATER.parseMaterial()) && (block.getRelative(BlockFace.WEST).getType() != Materials.LEGACY_STATIONARY_WATER.getPostMaterial() && block.getRelative(BlockFace.WEST).getType() != Materials.WATER.parseMaterial()) && (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(BlockFace.SOUTH).getType() == Material.AIR || block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getRelative(BlockFace.SOUTH).getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial())) {
flowBlock = block.getRelative(BlockFace.SOUTH);
}
if (flowBlock != null) {
if (NMSUtil.getVersionNumber() > 12) {
if (flowBlock.getState().getBlockData() instanceof Levelled) {
if (((Levelled) flowBlock.getState().getBlockData()).getLevel() != 0) {
return true;
}
}
} else {
if (flowBlock.getData() != 0) {
return true;
}
}
}
}
return false;
}
@SuppressWarnings("deprecation")
public void generateBlock(Player player, Block block) {
block.setType(Material.AIR);
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
for (int i = generatorStorage.size() - 1; i >= 0; i--) {
Generator generator = generatorStorage.get(i);
if (generator.isPermission()) {
if (!player.hasPermission(generator.getPermission()) && !player.hasPermission("skyblock.generator.*") && !player.hasPermission("skyblock.*")) {
continue;
}
}
Materials materials = getRandomMaterials(generator);
if (materials != null) {
Bukkit.getScheduler().runTask(plugin, new Runnable() {
public void run() {
plugin.getSoundManager().playSound(block.getLocation(), Sounds.FIZZ.bukkitSound(), 1.0F, 10.0F);
if (NMSUtil.getVersionNumber() > 12) {
block.setType(materials.parseMaterial());
} else {
ItemStack is = materials.parseItem();
block.setType(is.getType());
try {
block.getClass().getMethod("setData", byte.class).invoke(block, (byte) is.getDurability());
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
| NoSuchMethodException | SecurityException e) {
e.printStackTrace();
}
}
}
});
}
return;
}
}
});
}
public Materials getRandomMaterials(Generator generator) {
if (generator.getGeneratorMaterials() != null && generator.getGeneratorMaterials().size() != 0) {
Map<Integer, Integer> chances = new HashMap<>();
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);
}
}
return generator.getGeneratorMaterials().get(chances.get(new Random().nextInt(chances.size()))).getMaterials();
}
return null;
}
public void addGenerator(String name, List<GeneratorMaterial> generatorMaterials, boolean permission) {
Materials[] oreMaterials = new Materials[] { Materials.COAL, Materials.CHARCOAL, Materials.DIAMOND, Materials.IRON_INGOT, Materials.GOLD_INGOT, Materials.EMERALD };
generatorStorage.add(new Generator(name, oreMaterials[new Random().nextInt(oreMaterials.length)], generatorMaterials, permission));
}
public void removeGenerator(Generator generator) {
generatorStorage.remove(generator);
}
public Generator getGenerator(String name) {
for (Generator generatorList : generatorStorage) {
if (generatorList.getName().equalsIgnoreCase(name)) {
return generatorList;
}
}
return null;
}
public boolean containsGenerator(String name) {
for (Generator generatorList : generatorStorage) {
if (generatorList.getName().equalsIgnoreCase(name)) {
return true;
}
}
return false;
}
public List<Generator> getGenerators() {
return generatorStorage;
}
}

View File

@ -0,0 +1,26 @@
package me.goodandevil.skyblock.generator;
import me.goodandevil.skyblock.utils.version.Materials;
public class GeneratorMaterial {
private Materials materials;
private int chance;
public GeneratorMaterial(Materials materials, int chance) {
this.materials = materials;
this.chance = chance;
}
public Materials getMaterials() {
return materials;
}
public int getChance() {
return chance;
}
public void setChance(int chance) {
this.chance = chance;
}
}

View File

@ -0,0 +1,50 @@
package me.goodandevil.skyblock.invite;
import java.util.UUID;
import org.bukkit.entity.Player;
public class Invite {
private UUID playerUUID;
private UUID senderUUID;
private UUID islandOwnerUUID;
private String senderName;
private int time;
public Invite(Player player, Player sender, UUID islandOwnerUUID, int time) {
this.playerUUID = player.getUniqueId();
this.senderUUID = sender.getUniqueId();
this.senderName = sender.getName();
this.islandOwnerUUID = islandOwnerUUID;
this.time = time;
}
public UUID getPlayerUUID() {
return playerUUID;
}
public UUID getSenderUUID() {
return senderUUID;
}
public UUID getOwnerUUID() {
return islandOwnerUUID;
}
public void setOwnerUUID(UUID islandOwnerUUID) {
this.islandOwnerUUID = islandOwnerUUID;
}
public String getSenderName() {
return senderName;
}
public int getTime() {
return time;
}
public void setTime(int time) {
this.time = time;
}
}

View File

@ -0,0 +1,59 @@
package me.goodandevil.skyblock.invite;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.entity.Player;
import me.goodandevil.skyblock.Main;
public class InviteManager {
private Map<UUID, Invite> inviteStorage = new HashMap<>();
public InviteManager(Main plugin) {
new InviteTask(this, plugin).runTaskTimerAsynchronously(plugin, 0L, 20L);
}
public Invite createInvite(Player player, Player sender, UUID owner, int time) {
Invite invite = new Invite(player, sender, owner, time);
inviteStorage.put(player.getUniqueId(), invite);
return invite;
}
public void removeInvite(UUID uuid) {
if (hasInvite(uuid)) {
inviteStorage.remove(uuid);
}
}
public void tranfer(UUID uuid, UUID islandOwnerUUID) {
Map<UUID, Invite> islandInvites = getInvites();
for (UUID islandInviteList : islandInvites.keySet()) {
Invite invite = islandInvites.get(islandInviteList);
if (invite.getOwnerUUID().equals(islandOwnerUUID)) {
invite.setOwnerUUID(uuid);
}
}
}
public Map<UUID, Invite> getInvites() {
return inviteStorage;
}
public Invite getInvite(UUID uuid) {
if (hasInvite(uuid)) {
return inviteStorage.get(uuid);
}
return null;
}
public boolean hasInvite(UUID uuid) {
return inviteStorage.containsKey(uuid);
}
}

View File

@ -0,0 +1,59 @@
package me.goodandevil.skyblock.invite;
import java.io.File;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import me.goodandevil.skyblock.Main;
import me.goodandevil.skyblock.config.FileManager.Config;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.ChatComponent;
import me.goodandevil.skyblock.utils.version.Sounds;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
public class InviteTask extends BukkitRunnable {
private final Main plugin;
private final InviteManager inviteManager;
protected InviteTask(InviteManager inviteManager, Main plugin) {
this.inviteManager = inviteManager;
this.plugin = plugin;
}
@Override
public void run() {
SoundManager soundManager = plugin.getSoundManager();
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
for (Player all : Bukkit.getOnlinePlayers()) {
if (inviteManager.hasInvite(all.getUniqueId())) {
Invite invite = inviteManager.getInvite(all.getUniqueId());
invite.setTime(invite.getTime() - 1);
if (invite.getTime() == 0) {
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()))));
soundManager.playSound(targetPlayer, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
all.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Target.Expired.Message").replace("%player", invite.getSenderName())));
soundManager.playSound(all, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
inviteManager.removeInvite(all.getUniqueId());
}
}
}
}
}

View File

@ -0,0 +1,480 @@
package me.goodandevil.skyblock.island;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.WeatherType;
import org.bukkit.block.Biome;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.scheduler.BukkitRunnable;
import me.goodandevil.skyblock.Main;
import me.goodandevil.skyblock.ban.Ban;
import me.goodandevil.skyblock.ban.BanManager;
import me.goodandevil.skyblock.config.FileManager;
import me.goodandevil.skyblock.config.FileManager.Config;
import me.goodandevil.skyblock.events.IslandBiomeChangeEvent;
import me.goodandevil.skyblock.events.IslandLocationChangeEvent;
import me.goodandevil.skyblock.events.IslandMessageChangeEvent;
import me.goodandevil.skyblock.events.IslandOpenEvent;
import me.goodandevil.skyblock.events.IslandPasswordChangeEvent;
import me.goodandevil.skyblock.events.IslandRoleChangeEvent;
import me.goodandevil.skyblock.events.IslandWeatherChangeEvent;
import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.utils.StringUtil;
import me.goodandevil.skyblock.visit.Visit;
import me.goodandevil.skyblock.visit.VisitManager;
public class Island {
private final Main plugin;
private List<Location> islandLocations = new ArrayList<>();
private Map<Settings.Role, Map<String, Settings>> islandSettings = new EnumMap<>(Settings.Role.class);
private UUID ownerUUID;
private Level level;
private int size;
public Island(UUID ownerUUID, org.bukkit.Location islandNormalLocation, org.bukkit.Location islandNetherLocation) {
this.plugin = Main.getInstance();
FileManager fileManager = plugin.getFileManager();
IslandManager islandManager = plugin.getIslandManager();
this.ownerUUID = ownerUUID;
this.size = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Size");;
if (this.size > 1000) {
this.size = 100;
}
islandLocations.add(new Location(Location.World.Normal, Location.Environment.Island, islandNormalLocation));
islandLocations.add(new Location(Location.World.Nether, Location.Environment.Island, islandNetherLocation));
File configFile = new File(plugin.getDataFolder().toString() + "/island-data");
Config config = fileManager.getConfig(new File(configFile, ownerUUID + ".yml"));
if (fileManager.isFileExist(new File(configFile, ownerUUID + ".yml"))) {
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getString("Size") != null) {
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 (Settings.Role roleList : Settings.Role.values()) {
HashMap<String, Settings> roleSettings = new HashMap<>();
for (String settingList : configLoad.getConfigurationSection("Settings." + roleList.name()).getKeys(false)) {
roleSettings.put(settingList, new Settings(configLoad.getBoolean("Settings." + roleList.name() + "." + settingList)));
}
islandSettings.put(roleList, roleSettings);
}
} else {
islandLocations.add(new Location(Location.World.Normal, Location.Environment.Main, islandNormalLocation.clone().add(0.5D, 0.0D, 0.5D)));
islandLocations.add(new Location(Location.World.Nether, Location.Environment.Main, islandNetherLocation.clone().add(0.5D, 0.0D, 0.5D)));
islandLocations.add(new Location(Location.World.Normal, Location.Environment.Visitor, islandNormalLocation.clone().add(0.5D, 0.0D, 0.5D)));
islandLocations.add(new Location(Location.World.Nether, Location.Environment.Visitor, islandNetherLocation.clone().add(0.5D, 0.0D, 0.5D)));
Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
FileConfiguration mainConfigLoad = mainConfig.getFileConfiguration();
fileManager.setLocation(config, "Location.Normal.Island", islandNormalLocation, true);
fileManager.setLocation(config, "Location.Nether.Island", islandNetherLocation, true);
fileManager.setLocation(config, "Location.Normal.Spawn.Main", islandNormalLocation.clone().add(0.5D, 0.0D, 0.5D), true);
fileManager.setLocation(config, "Location.Nether.Spawn.Main", islandNetherLocation.clone().add(0.5D, 0.0D, 0.5D), true);
fileManager.setLocation(config, "Location.Normal.Spawn.Visitor", islandNormalLocation.clone().add(0.5D, 0.0D, 0.5D), true);
fileManager.setLocation(config, "Location.Nether.Spawn.Visitor", islandNetherLocation.clone().add(0.5D, 0.0D, 0.5D), true);
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"));
configLoad.set("Weather.Time", mainConfigLoad.getInt("Island.Weather.Default.Time"));
configLoad.set("Weather.Weather", mainConfigLoad.getString("Island.Weather.Default.Weather").toUpperCase());
configLoad.set("Ownership.Original", ownerUUID.toString());
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 : settingsConfig.getFileConfiguration().getConfigurationSection(WordUtils.capitalize(roleList.name().toLowerCase())).getKeys(false)) {
roleSettings.put(settingList, new Settings(settingsConfig.getFileConfiguration().getBoolean(WordUtils.capitalize(roleList.name().toLowerCase()) + "." + settingList)));
}
islandSettings.put(roleList, roleSettings);
}
save();
PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(Bukkit.getServer().getPlayer(ownerUUID));
playerData.setPlaytime(0);
playerData.setOwner(ownerUUID);
playerData.setMemberSince(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(new Date()));
playerData.save();
new BukkitRunnable() {
@Override
public void run() {
islandNormalLocation.clone().subtract(0.0D, 1.0D, 0.0D).getBlock().setType(Material.STONE);
islandManager.setSpawnProtection(islandNormalLocation);
islandManager.setSpawnProtection(islandNetherLocation);
}
}.runTask(plugin);
//plugin.getBiomeManager().setBiome(null, islandNormalLocation, Biome.valueOf(mainConfigLoad.getString("Island.Biome.Default.Type").toUpperCase()));
}
level = new Level(this, plugin);
VisitManager visitManager = plugin.getVisitManager();
if (!visitManager.hasIsland(getOwnerUUID())) {
visitManager.createIsland(getOwnerUUID(), new org.bukkit.Location[] { getLocation(Location.World.Normal, Location.Environment.Island), getLocation(Location.World.Nether, Location.Environment.Island) }, size, getRole(Role.Member).size() + getRole(Role.Operator).size() + 1, level.getLevel(), getMessage(Message.Signature), isOpen());
}
BanManager banManager = plugin.getBanManager();
if (!banManager.hasIsland(getOwnerUUID())) {
banManager.createIsland(getOwnerUUID());
}
}
public UUID getOwnerUUID() {
return ownerUUID;
}
public void setOwnerUUID(UUID uuid) {
getVisit().setOwnerUUID(uuid);
ownerUUID = uuid;
}
public UUID getOriginalOwnerUUID() {
return UUID.fromString(plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")).getFileConfiguration().getString("Ownership.Original"));
}
public int getSize() {
return size;
}
public int getRadius() {
return size / 2;
}
public boolean hasPassword() {
return plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")).getFileConfiguration().getString("Ownership.Password") != null;
}
public String getPassword() {
return plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")).getFileConfiguration().getString("Ownership.Password");
}
public void setPassword(String password) {
IslandPasswordChangeEvent islandPasswordChangeEvent = new IslandPasswordChangeEvent(this, getPassword(), password);
Bukkit.getServer().getPluginManager().callEvent(islandPasswordChangeEvent);
if (!islandPasswordChangeEvent.isCancelled()) {
plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")).getFileConfiguration().set("Ownership.Password", password);
}
}
public org.bukkit.Location getLocation(Location.World world, Location.Environment environment) {
for (Location islandLocationList : islandLocations) {
if (islandLocationList.getWorld() == world && islandLocationList.getEnvironment() == environment) {
return islandLocationList.getLocation();
}
}
return null;
}
public void setLocation(Location.World world, Location.Environment environment, org.bukkit.Location location) {
for (Location islandLocationList : islandLocations) {
if (islandLocationList.getWorld() == world && islandLocationList.getEnvironment() == environment) {
Bukkit.getServer().getPluginManager().callEvent(new IslandLocationChangeEvent(this, islandLocationList, new Location(world, environment, location)));
FileManager fileManager = plugin.getFileManager();
fileManager.setLocation(fileManager.getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), getOwnerUUID().toString() + ".yml")), "Location." + world.name() + ".Spawn." + environment.name(), location, true);
islandLocationList.setLocation(location);
break;
}
}
}
public Biome getBiome() {
return Biome.valueOf(plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")).getFileConfiguration().getString("Biome.Type"));
}
public String getBiomeName() {
return StringUtil.capatilizeUppercaseLetters(WordUtils.capitalize(getBiome().name().toLowerCase()).replace("_", " "));
}
public void setBiome(Biome biome) {
Bukkit.getServer().getPluginManager().callEvent(new IslandBiomeChangeEvent(this, getBiome(), biome));
plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")).getFileConfiguration().set("Biome.Type", biome.name());
}
public boolean isWeatherSynchronised() {
return plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")).getFileConfiguration().getBoolean("Weather.Synchronised");
}
public void setWeatherSynchronised(boolean synchronised) {
Bukkit.getServer().getPluginManager().callEvent(new IslandWeatherChangeEvent(this, getWeather(), getTime(), synchronised));
plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")).getFileConfiguration().set("Weather.Synchronised", synchronised);
}
public WeatherType getWeather() {
return WeatherType.valueOf(plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")).getFileConfiguration().getString("Weather.Weather"));
}
public String getWeatherName() {
return WordUtils.capitalize(getWeather().name().toLowerCase());
}
public void setWeather(WeatherType weatherType) {
Bukkit.getServer().getPluginManager().callEvent(new IslandWeatherChangeEvent(this, weatherType, getTime(), isWeatherSynchronised()));
plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")).getFileConfiguration().set("Weather.Weather", weatherType.name());
}
public int getTime() {
return plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")).getFileConfiguration().getInt("Weather.Time");
}
public void setTime(int time) {
Bukkit.getServer().getPluginManager().callEvent(new IslandWeatherChangeEvent(this, getWeather(), time, isWeatherSynchronised()));
plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")).getFileConfiguration().set("Weather.Time", time);
}
public List<UUID> getRole(Role role) {
Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
List<UUID> islandRoles = new ArrayList<>();
if (configLoad.getString(role.name() + "s") != null) {
for (String operatorList : configLoad.getStringList(role.name() + "s")) {
islandRoles.add(UUID.fromString(operatorList));
}
}
return islandRoles;
}
public void setRole(Role role, UUID uuid) {
if (!(role == Role.Visitor || role == Role.Owner)) {
if (!isRole(role, uuid)) {
if (role == Role.Member) {
if (isRole(Role.Operator, uuid)) {
Bukkit.getServer().getPluginManager().callEvent(new IslandRoleChangeEvent(uuid, this, Role.Operator, role));
removeRole(Role.Operator, uuid);
}
} else if (role == Role.Operator) {
if (isRole(Role.Member, uuid)) {
Bukkit.getServer().getPluginManager().callEvent(new IslandRoleChangeEvent(uuid, this, Role.Member, role));
removeRole(Role.Member, uuid);
}
}
Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), getOwnerUUID().toString() + ".yml"));
File configFile = config.getFile();
FileConfiguration configLoad = config.getFileConfiguration();
List<String> islandMembers;
if (configLoad.getString(role.name() + "s") == null) {
islandMembers = new ArrayList<>();
} else {
islandMembers = configLoad.getStringList(role.name() + "s");
}
islandMembers.add(uuid.toString());
configLoad.set(role.name() + "s", islandMembers);
try {
configLoad.save(configFile);
} catch (IOException e) {
e.printStackTrace();
}
getVisit().setMembers(getRole(Role.Member).size() + getRole(Role.Operator).size() + 1);
}
}
}
public void removeRole(Role role, UUID uuid) {
if (!(role == Role.Visitor || role == Role.Owner)) {
if (isRole(role, uuid)) {
Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"));
File configFile = config.getFile();
FileConfiguration configLoad = config.getFileConfiguration();
List<String> islandMembers = configLoad.getStringList(role.name() + "s");
islandMembers.remove(uuid.toString());
configLoad.set(role.name() + "s", islandMembers);
try {
configLoad.save(configFile);
} catch (IOException e) {
e.printStackTrace();
}
getVisit().setMembers(getRole(Role.Member).size() + getRole(Role.Operator).size() + 1);
}
}
}
public boolean isRole(Role role, UUID uuid) {
if (role == Role.Owner) {
return getOwnerUUID().equals(uuid);
}
return getRole(role).contains(uuid);
}
public Settings getSetting(Settings.Role role, String setting) {
if (islandSettings.containsKey(role)) {
Map<String, Settings> roleSettings = islandSettings.get(role);
if (roleSettings.containsKey(setting)) {
return roleSettings.get(setting);
}
}
return null;
}
public Map<String, Settings> getSettings(Settings.Role role) {
if (islandSettings.containsKey(role)) {
return islandSettings.get(role);
}
return null;
}
public void setOpen(boolean open) {
IslandOpenEvent islandOpenEvent = new IslandOpenEvent(this, open);
Bukkit.getServer().getPluginManager().callEvent(islandOpenEvent);
if (!islandOpenEvent.isCancelled()) {
plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")).getFileConfiguration().set("Visitor.Open", open);
getVisit().setOpen(open);
}
}
public boolean isOpen() {
return plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")).getFileConfiguration().getBoolean("Visitor.Open");
}
public List<UUID> getVisitors() {
Map<UUID, PlayerData> playerDataStorage = plugin.getPlayerDataManager().getPlayerData();
List<UUID> islandVisitors = new ArrayList<>();
for (UUID playerDataStorageList : playerDataStorage.keySet()) {
PlayerData playerData = playerDataStorage.get(playerDataStorageList);
UUID islandOwnerUUID = playerData.getIsland();
if (islandOwnerUUID != null && islandOwnerUUID.equals(getOwnerUUID())) {
if (playerData.getOwner() == null || !playerData.getOwner().equals(getOwnerUUID())) {
if (Bukkit.getServer().getPlayer(playerDataStorageList) != null) {
islandVisitors.add(playerDataStorageList);
}
}
}
}
return islandVisitors;
}
public List<String> getMessage(Message message) {
List<String> islandMessage = new ArrayList<>();
Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getString("Visitor." + message.name() + ".Message") != null) {
islandMessage = configLoad.getStringList("Visitor." + message.name() + ".Message");
}
return islandMessage;
}
public String getMessageAuthor(Message message) {
Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getString("Visitor." + message.name() + ".Author") != null) {
return configLoad.getString("Visitor." + message.name() + ".Author");
}
return "";
}
public void setMessage(Message message, String author, List<String> islandMessage) {
IslandMessageChangeEvent islandMessageChangeEvent = new IslandMessageChangeEvent(this, message, islandMessage, author);
Bukkit.getServer().getPluginManager().callEvent(islandMessageChangeEvent);
if (!islandMessageChangeEvent.isCancelled()) {
Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set("Visitor." + message.name() + ".Message", islandMessage);
configLoad.set("Visitor." + message.name() + ".Author", author);
}
}
public Visit getVisit() {
return plugin.getVisitManager().getIsland(getOwnerUUID());
}
public Ban getBan() {
return plugin.getBanManager().getIsland(getOwnerUUID());
}
public Level getLevel() {
return level;
}
public void save() {
Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"));
File configFile = config.getFile();
FileConfiguration configLoad = config.getFileConfiguration();
for (Settings.Role roleList : Settings.Role.values()) {
if (islandSettings.containsKey(roleList)) {
Map<String, Settings> roleSettings = islandSettings.get(roleList);
for (String roleSettingList : roleSettings.keySet()) {
configLoad.set("Settings." + roleList.name() + "." + roleSettingList, roleSettings.get(roleSettingList).getStatus());
}
}
}
try {
configLoad.save(configFile);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,35 @@
package me.goodandevil.skyblock.island;
public class IslandLocation {
private Location.World world;
private double x;
private double z;
public IslandLocation(Location.World world, double x, double z) {
this.world = world;
this.x = x;
this.z = z;
}
public Location.World getWorld() {
return world;
}
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getZ() {
return z;
}
public void setZ(double z) {
this.z = z;
}
}

View File

@ -0,0 +1,670 @@
package me.goodandevil.skyblock.island;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.IllegalPluginAccessException;
import org.bukkit.scheduler.BukkitRunnable;
import me.goodandevil.skyblock.Main;
import me.goodandevil.skyblock.ban.BanManager;
import me.goodandevil.skyblock.config.FileManager;
import me.goodandevil.skyblock.config.FileManager.Config;
import me.goodandevil.skyblock.events.IslandCreateEvent;
import me.goodandevil.skyblock.events.IslandDeleteEvent;
import me.goodandevil.skyblock.events.IslandLoadEvent;
import me.goodandevil.skyblock.events.IslandOwnershipTransferEvent;
import me.goodandevil.skyblock.events.IslandUnloadEvent;
import me.goodandevil.skyblock.invite.Invite;
import me.goodandevil.skyblock.invite.InviteManager;
import me.goodandevil.skyblock.island.Location.World;
import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
import me.goodandevil.skyblock.scoreboard.Scoreboard;
import me.goodandevil.skyblock.scoreboard.ScoreboardManager;
import me.goodandevil.skyblock.structure.Structure;
import me.goodandevil.skyblock.utils.OfflinePlayer;
import me.goodandevil.skyblock.utils.structure.StructureUtil;
import me.goodandevil.skyblock.utils.version.Materials;
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;
public class IslandManager {
private final Main plugin;
private double x = 0, offset = 1200;
private List<IslandLocation> islandLocations = new ArrayList<>();
private Map<UUID, Island> islandStorage = new HashMap<>();
public IslandManager(Main plugin) {
this.plugin = plugin;
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
for (Location.World worldList : Location.World.values()) {
ConfigurationSection configSection = configLoad.getConfigurationSection("World." + worldList.name() + ".nextAvailableLocation");
islandLocations.add(new IslandLocation(worldList, configSection.getDouble("x"), configSection.getDouble("z")));
}
for (Player all : Bukkit.getOnlinePlayers()) {
loadIsland(all.getUniqueId());
}
}
public void onDisable() {
saveNextAvailableLocation();
for (Player all : Bukkit.getOnlinePlayers()) {
unloadIsland(all.getUniqueId());
}
}
public void saveNextAvailableLocation() {
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
File configFile = config.getFile();
FileConfiguration configLoad = config.getFileConfiguration();
for (Location.World worldList : Location.World.values()) {
for (IslandLocation islandLocationList : islandLocations) {
if (islandLocationList.getWorld() == worldList) {
ConfigurationSection configSection = configLoad.createSection("World." + worldList.name() + ".nextAvailableLocation");
configSection.set("x", islandLocationList.getX());
configSection.set("z", islandLocationList.getZ());
}
}
}
try {
configLoad.save(configFile);
} catch (IOException e) {
e.printStackTrace();
}
}
public void setNextAvailableLocation(Location.World world, org.bukkit.Location location) {
for (IslandLocation islandLocationList : islandLocations) {
if (islandLocationList.getWorld() == world) {
islandLocationList.setX(location.getX());
islandLocationList.setZ(location.getZ());
}
}
}
public org.bukkit.Location prepareNextAvailableLocation(Location.World world) {
for (IslandLocation islandLocationList : islandLocations) {
if (islandLocationList.getWorld() == world) {
double x = islandLocationList.getX() + offset, z = islandLocationList.getZ();
if (x > Math.abs(this.x)) {
z += offset;
islandLocationList.setX(this.x);
x = islandLocationList.getX() + offset;
islandLocationList.setZ(z);
}
return new org.bukkit.Location(plugin.getWorldManager().getWorld(world), x, 72, z);
}
}
return null;
}
public void createIsland(Player player, Structure structure) {
ScoreboardManager scoreboardManager = plugin.getScoreboardManager();
FileManager fileManager = plugin.getFileManager();
Island island = new Island(player.getUniqueId(), prepareNextAvailableLocation(Location.World.Normal), prepareNextAvailableLocation(Location.World.Nether));
islandStorage.put(player.getUniqueId(), island);
try {
File structureFile = new File(new File(plugin.getDataFolder().toString() + "/structures"), structure.getFile());
for (World worldList : World.values()) {
Float[] direction = StructureUtil.pasteStructure(StructureUtil.loadStructure(structureFile), island.getLocation(worldList, Location.Environment.Island), BlockDegreesType.ROTATE_360);
org.bukkit.Location spawnLocation = island.getLocation(worldList, Location.Environment.Main).clone();
spawnLocation.setYaw(direction[0]);
spawnLocation.setPitch(direction[1]);
island.setLocation(worldList, Location.Environment.Main, spawnLocation);
island.setLocation(worldList, Location.Environment.Visitor, spawnLocation);
}
} catch (Exception e) {
e.printStackTrace();
}
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
/*if (configLoad.getBoolean("Island.Creation.Cooldown.Creation.Enable")) {
plugin.getCreationManager().createPlayer(player, configLoad.getInt("Island.Creation.Cooldown.Time"));
}*/
Bukkit.getServer().getPluginManager().callEvent(new IslandCreateEvent(player, island));
for (Location.World worldList : Location.World.values()) {
setNextAvailableLocation(worldList, island.getLocation(worldList, Location.Environment.Island));
}
saveNextAvailableLocation();
plugin.getPlayerDataManager().getPlayerData(player).setIsland(player.getUniqueId());
config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
configLoad = config.getFileConfiguration();
if (scoreboardManager != null) {
Scoreboard scoreboard = scoreboardManager.getScoreboard(player);
scoreboard.cancel();
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Scoreboard.Island.Solo.Displayname")));
scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Island.Solo.Empty.Displaylines"));
scoreboard.run();
}
new BukkitRunnable() {
@Override
public void run() {
player.teleport(island.getLocation(Location.World.Normal, Location.Environment.Main));
}
}.runTask(plugin);
}
public void giveIslandOwnership(UUID uuid) {
FileManager fileManager = plugin.getFileManager();
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
Player targetPlayer = Bukkit.getServer().getPlayer(uuid);
UUID islandOwnerUUID;
if (targetPlayer == null) {
OfflinePlayer offlinePlayer = new OfflinePlayer(uuid);
islandOwnerUUID = offlinePlayer.getOwner();
} else {
islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner();
}
if (containsIsland(islandOwnerUUID)) {
Island island = getIsland(islandOwnerUUID);
island.setOwnerUUID(uuid);
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getBoolean("Island.Ownership.Password.Reset")) {
island.setPassword(null);
}
File oldIslandDataFile = new File(new File(plugin.getDataFolder().toString() + "/island-data"), islandOwnerUUID.toString() + ".yml");
File newIslandDataFile = new File(new File(plugin.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml");
fileManager.unloadConfig(oldIslandDataFile);
fileManager.unloadConfig(newIslandDataFile);
oldIslandDataFile.renameTo(newIslandDataFile);
plugin.getVisitManager().transfer(uuid, islandOwnerUUID);
plugin.getBanManager().transfer(uuid, islandOwnerUUID);
plugin.getInviteManager().tranfer(uuid, islandOwnerUUID);
if (configLoad.getBoolean("Island.Ownership.Transfer.Operator")) {
island.setRole(Role.Operator, islandOwnerUUID);
} else {
island.setRole(Role.Member, islandOwnerUUID);
}
if (island.isRole(Role.Member, uuid)) {
island.removeRole(Role.Member, uuid);
} else {
island.removeRole(Role.Operator, uuid);
}
removeIsland(islandOwnerUUID);
islandStorage.put(uuid, island);
Bukkit.getServer().getPluginManager().callEvent(new IslandOwnershipTransferEvent(island, islandOwnerUUID, uuid));
ArrayList<UUID> islandMembers = new ArrayList<>();
islandMembers.addAll(island.getRole(Role.Member));
islandMembers.addAll(island.getRole(Role.Operator));
islandMembers.add(uuid);
for (UUID islandMemberList : islandMembers) {
targetPlayer = Bukkit.getServer().getPlayer(islandMemberList);
if (targetPlayer == null) {
File configFile = new File(new File(plugin.getDataFolder().toString() + "/player-data"), islandMemberList.toString() + ".yml");
configLoad = YamlConfiguration.loadConfiguration(configFile);
configLoad.set("Island.Owner", uuid.toString());
try {
configLoad.save(configFile);
} catch (IOException e) {
e.printStackTrace();
}
} else {
PlayerData playerData = playerDataManager.getPlayerData(targetPlayer);
playerData.setOwner(uuid);
playerData.save();
}
}
}
}
public void deleteIsland(Island island) {
plugin.getVisitManager().removeVisitors(island, VisitManager.Removal.Deleted);
for (Player all : Bukkit.getOnlinePlayers()) {
if (island.isRole(Role.Member, all.getUniqueId()) || island.isRole(Role.Operator, all.getUniqueId()) || island.isRole(Role.Owner, all.getUniqueId())) {
PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(all);
playerData.setOwner(null);
playerData.setMemberSince(null);
playerData.setChat(false);
playerData.save();
}
InviteManager inviteManager = plugin.getInviteManager();
if (inviteManager.hasInvite(all.getUniqueId())) {
Invite invite = inviteManager.getInvite(all.getUniqueId());
if (invite.getOwnerUUID().equals(island.getOwnerUUID())) {
inviteManager.removeInvite(all.getUniqueId());
}
}
}
FileManager fileManager = plugin.getFileManager();
fileManager.deleteConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), island.getOwnerUUID().toString() + ".yml"));
/*Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getBoolean("Island.Creation.Cooldown.Deletion.Enable")) {
plugin.getCreationManager().createPlayer(island.getOwnerUUID(), configLoad.getInt("Island.Creation.Cooldown.Time"));
}*/
Bukkit.getServer().getPluginManager().callEvent(new IslandDeleteEvent(island));
islandStorage.remove(island.getOwnerUUID());
}
public void loadIsland(UUID uuid) {
FileManager fileManager = plugin.getFileManager();
UUID islandOwnerUUID = null;
if (isIslandExist(uuid)) {
islandOwnerUUID = uuid;
} else {
Config config = fileManager.getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), uuid.toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getString("Island.Owner") != null) {
islandOwnerUUID = UUID.fromString(configLoad.getString("Island.Owner"));
}
}
if (islandOwnerUUID != null && !hasIsland(islandOwnerUUID)) {
File configFile = new File(plugin.getDataFolder().toString() + "/island-data");
Config config = fileManager.getConfig(new File(configFile, islandOwnerUUID.toString() + ".yml"));
org.bukkit.Location islandNormalLocation = fileManager.getLocation(config, "Location.Normal.Island", true);
org.bukkit.Location islandNetherLocation = fileManager.getLocation(config, "Location.Nether.Island", true);
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);
Bukkit.getServer().getPluginManager().callEvent(new IslandLoadEvent(island));
}
}
public void unloadIsland(UUID uuid) {
ScoreboardManager scoreboardManager = plugin.getScoreboardManager();
FileManager fileManager = plugin.getFileManager();
if (hasIsland(uuid)) {
UUID islandOwnerUUID = uuid;
if (!isIslandExist(uuid)) {
Config config = fileManager.getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), uuid.toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getString("Island.Owner") != null) {
islandOwnerUUID = UUID.fromString(configLoad.getString("Island.Owner"));
}
}
Island island = getIsland(islandOwnerUUID);
island.save();
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
int islandMembers = island.getRole(Role.Member).size() + island.getRole(Role.Operator).size() + 1, islandVisitors = island.getVisitors().size();
for (Player all : Bukkit.getOnlinePlayers()) {
if (!uuid.equals(islandOwnerUUID)) {
if (all.getUniqueId().equals(uuid)) {
continue;
}
}
if (island.isRole(Role.Member, all.getUniqueId()) || island.isRole(Role.Operator, all.getUniqueId()) || island.isRole(Role.Owner, all.getUniqueId())) {
if (scoreboardManager != null) {
try {
if (islandMembers == 1 && islandVisitors == 0) {
Scoreboard scoreboard = scoreboardManager.getScoreboard(all);
scoreboard.cancel();
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Scoreboard.Island.Solo.Displayname")));
scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Island.Solo.Empty.Displaylines"));
scoreboard.run();
} else if (islandVisitors == 0) {
Scoreboard scoreboard = scoreboardManager.getScoreboard(all);
scoreboard.cancel();
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Scoreboard.Island.Team.Displayname")));
scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Island.Team.Empty.Displaylines"));
HashMap<String, String> displayVariables = new HashMap<>();
displayVariables.put("%owner", configLoad.getString("Scoreboard.Island.Team.Word.Owner"));
displayVariables.put("%operator", configLoad.getString("Scoreboard.Island.Team.Word.Operator"));
displayVariables.put("%member", configLoad.getString("Scoreboard.Island.Team.Word.Member"));
scoreboard.setDisplayVariables(displayVariables);
scoreboard.run();
}
} catch (IllegalPluginAccessException e) {}
}
return;
}
}
boolean unloadIsland = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Unload");
if (unloadIsland) {
VisitManager visitManager = plugin.getVisitManager();
visitManager.removeVisitors(island, VisitManager.Removal.Unloaded);
visitManager.unloadIsland(islandOwnerUUID);
BanManager banManager = plugin.getBanManager();
banManager.unloadIsland(islandOwnerUUID);
} else {
if (island.getVisitors().size() != 0) {
return;
}
}
fileManager.unloadConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), islandOwnerUUID + ".yml"));
islandStorage.remove(islandOwnerUUID);
Bukkit.getServer().getPluginManager().callEvent(new IslandUnloadEvent(island));
}
}
public void visitIsland(Player player, Island island) {
ScoreboardManager scoreboardManager = plugin.getScoreboardManager();
FileManager fileManager = plugin.getFileManager();
Config languageConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = languageConfig.getFileConfiguration();
if (island.isRole(Role.Member, player.getUniqueId()) || island.isRole(Role.Operator, player.getUniqueId()) || island.isRole(Role.Owner, player.getUniqueId())) {
player.teleport(island.getLocation(Location.World.Normal, Location.Environment.Visitor));
} else {
if (scoreboardManager != null) {
int islandVisitors = island.getVisitors().size(), islandMembers = island.getRole(Role.Member).size() + island.getRole(Role.Operator).size() + 1;
if (islandVisitors == 0) {
for (Player all : Bukkit.getOnlinePlayers()) {
PlayerData targetPlayerData = plugin.getPlayerDataManager().getPlayerData(all);
if (targetPlayerData.getOwner() != null && targetPlayerData.getOwner().equals(island.getOwnerUUID())) {
Scoreboard scoreboard = scoreboardManager.getScoreboard(all);
scoreboard.cancel();
if (islandMembers == 1) {
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Scoreboard.Island.Solo.Displayname")));
scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Island.Solo.Occupied.Displaylines"));
} else {
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Scoreboard.Island.Team.Displayname")));
scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Island.Team.Occupied.Displaylines"));
HashMap<String, String> displayVariables = new HashMap<>();
displayVariables.put("%owner", configLoad.getString("Scoreboard.Island.Team.Word.Owner"));
displayVariables.put("%operator", configLoad.getString("Scoreboard.Island.Team.Word.Operator"));
displayVariables.put("%member", configLoad.getString("Scoreboard.Island.Team.Word.Member"));
scoreboard.setDisplayVariables(displayVariables);
}
scoreboard.run();
}
}
}
}
player.teleport(island.getLocation(Location.World.Normal, Location.Environment.Visitor));
List<String> islandWelcomeMessage = island.getMessage(Message.Welcome);
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Welcome.Enable") && islandWelcomeMessage.size() != 0) {
for (String islandWelcomeMessageList : islandWelcomeMessage) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', islandWelcomeMessageList));
}
}
}
player.closeInventory();
}
public void closeIsland(Island island) {
island.setOpen(false);
UUID islandOwnerUUID = island.getOwnerUUID();
Player islandOwnerPlayer = Bukkit.getServer().getPlayer(islandOwnerUUID);
String islandOwnerPlayerName;
if (islandOwnerPlayer == null) {
islandOwnerPlayerName = new OfflinePlayer(islandOwnerUUID).getName();
} else {
islandOwnerPlayerName = islandOwnerPlayer.getName();
}
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
for (UUID visitorList : island.getVisitors()) {
Player targetPlayer = Bukkit.getServer().getPlayer(visitorList);
LocationUtil.teleportPlayerToSpawn(targetPlayer);
targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Closed.Island.Message").replace("%player", islandOwnerPlayerName)));
}
}
public Island getIsland(UUID islandOwnerUUID) {
if (islandStorage.containsKey(islandOwnerUUID)) {
return islandStorage.get(islandOwnerUUID);
}
return null;
}
public void removeIsland(UUID islandOwnerUUID) {
islandStorage.remove(islandOwnerUUID);
}
public Map<UUID, Island> getIslands() {
return islandStorage;
}
public boolean isIslandExist(UUID uuid) {
return plugin.getFileManager().isFileExist(new File(new File(plugin.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml"));
}
public boolean hasIsland(UUID uuid) {
UUID islandOwnerUUID = uuid;
if (!isIslandExist(uuid)) {
Config config = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), uuid.toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getString("Island.Owner") != null) {
islandOwnerUUID = UUID.fromString(configLoad.getString("Island.Owner"));
}
}
return islandStorage.containsKey(islandOwnerUUID);
}
public boolean hasIsland(Player player) {
PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player);
return (playerData == null) ? hasIsland(player.getUniqueId()) : islandStorage.containsKey(playerData.getOwner());
}
public boolean containsIsland(UUID uuid) {
return islandStorage.containsKey(uuid);
}
public boolean hasPermission(Player player, String setting) {
if (hasIsland(player)) {
Island island = getIsland(plugin.getPlayerDataManager().getPlayerData(player).getOwner());
for (Location.World worldList : Location.World.values()) {
if (LocationUtil.isLocationAtLocationRadius(player.getLocation(), island.getLocation(worldList, Location.Environment.Island), island.getRadius())) {
if (island.isRole(Role.Member, player.getUniqueId())) {
if (!island.getSetting(Settings.Role.Member, setting).getStatus()) {
return false;
}
}
return true;
}
}
}
for (UUID islandList : getIslands().keySet()) {
Island island = getIslands().get(islandList);
for (Location.World worldList : Location.World.values()) {
if (LocationUtil.isLocationAtLocationRadius(player.getLocation(), island.getLocation(worldList, Location.Environment.Island), island.getRadius())) {
if (!island.getSetting(Settings.Role.Visitor, setting).getStatus()) {
return false;
}
return true;
}
}
}
return true;
}
public void setSpawnProtection(org.bukkit.Location location) {
location.getBlock().setType(Materials.LEGACY_PISTON_MOVING_PIECE.getPostMaterial());
location.clone().add(0.0D, 1.0D, 0.0D).getBlock().setType(Materials.LEGACY_PISTON_MOVING_PIECE.getPostMaterial());
}
public void removeSpawnProtection(org.bukkit.Location location) {
location.getBlock().setType(Material.AIR);
location.clone().add(0.0D, 1.0D, 0.0D).getBlock().setType(Material.AIR);
}
public List<UUID> getMembersOnline(Island island) {
List<UUID> membersOnline = new ArrayList<>();
for (Player all : Bukkit.getOnlinePlayers()) {
if (island.isRole(Role.Member, all.getUniqueId()) || island.isRole(Role.Operator, all.getUniqueId()) || island.isRole(Role.Owner, all.getUniqueId())) {
membersOnline.add(all.getUniqueId());
}
}
return membersOnline;
}
public List<UUID> getPlayersAtIsland(Island island) {
List<UUID> playersAtIsland = new ArrayList<>();
Map<UUID, PlayerData> playerData = plugin.getPlayerDataManager().getPlayerData();
for (UUID playerDataList : playerData.keySet()) {
UUID islandOwnerUUID = playerData.get(playerDataList).getIsland();
if (islandOwnerUUID != null && island.getOwnerUUID().equals(islandOwnerUUID)) {
playersAtIsland.add(playerDataList);
}
}
return playersAtIsland;
}
public List<Player> getPlayersAtIsland(Island island, Location.World world) {
List<Player> playersAtIsland = new ArrayList<>();
for (Player all : Bukkit.getOnlinePlayers()) {
if (LocationUtil.isLocationAtLocationRadius(all.getLocation(), island.getLocation(world, Location.Environment.Island), island.getRadius())) {
playersAtIsland.add(all);
}
}
return playersAtIsland;
}
public void loadPlayer(Player player) {
new BukkitRunnable() {
@Override
public void run() {
if (player.getWorld().getName().equals(plugin.getWorldManager().getWorld(Location.World.Normal).getName())) {
Island island = null;
if (hasIsland(player)) {
island = getIsland(plugin.getPlayerDataManager().getPlayerData(player).getOwner());
if (!LocationUtil.isLocationAtLocationRadius(player.getLocation(), island.getLocation(Location.World.Normal, Location.Environment.Island), island.getRadius())) {
island = null;
}
}
if (island == null) {
for (UUID islandList : getIslands().keySet()) {
Island targetIsland = getIslands().get(islandList);
if (LocationUtil.isLocationAtLocationRadius(player.getLocation(), targetIsland.getLocation(Location.World.Normal, Location.Environment.Island), targetIsland.getRadius())) {
island = targetIsland;
break;
}
}
}
if (island != null) {
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (!island.isWeatherSynchronised()) {
player.setPlayerTime(island.getTime(), configLoad.getBoolean("Island.Weather.Time.Cycle"));
player.setPlayerWeather(island.getWeather());
}
if (configLoad.getBoolean("Island.WorldBorder.Enable")) {
WorldBorder.send(player, island.getSize(), island.getLocation(Location.World.Normal, Location.Environment.Island));
}
}
}
}
}.runTaskAsynchronously(plugin);
}
}

Some files were not shown because too many files have changed in this diff Show More