mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-09-02 10:00:13 +02:00
Changed package. Cleaned and Formatted code. Fixed hologram issue.
This commit is contained in:
parent
80a889edbb
commit
b35feb51fc
|
@ -1,7 +1,9 @@
|
|||
image: gradle:alpine
|
||||
|
||||
variables:
|
||||
name: "FabledSkyBlock"
|
||||
path: "/builds/$CI_PROJECT_PATH"
|
||||
version: "Build-78.5"
|
||||
|
||||
before_script:
|
||||
- export GRADLE_USER_HOME=`pwd`/.gradle
|
||||
|
@ -12,6 +14,7 @@ stages:
|
|||
build:
|
||||
stage: build
|
||||
script:
|
||||
- find $path/ -type f -name "*.gradle" -print0 | xargs -0 sed -i -e s/maven-version-number/$version/g
|
||||
- gradle build
|
||||
- mv $path/build/libs/*.jar $path/
|
||||
artifacts:
|
||||
|
|
|
@ -0,0 +1,335 @@
|
|||
package com.songoda.skyblock;
|
||||
|
||||
import com.songoda.skyblock.api.SkyBlockAPI;
|
||||
import com.songoda.skyblock.ban.BanManager;
|
||||
import com.songoda.skyblock.biome.BiomeManager;
|
||||
import com.songoda.skyblock.command.CommandManager;
|
||||
import com.songoda.skyblock.command.commands.SkyBlockCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.confirmation.ConfirmationTask;
|
||||
import com.songoda.skyblock.cooldown.CooldownManager;
|
||||
import com.songoda.skyblock.economy.EconomyManager;
|
||||
import com.songoda.skyblock.generator.GeneratorManager;
|
||||
import com.songoda.skyblock.hologram.HologramManager;
|
||||
import com.songoda.skyblock.invite.InviteManager;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.leaderboard.LeaderboardManager;
|
||||
import com.songoda.skyblock.levelling.LevellingManager;
|
||||
import com.songoda.skyblock.limit.LimitManager;
|
||||
import com.songoda.skyblock.listeners.*;
|
||||
import com.songoda.skyblock.menus.Rollback;
|
||||
import com.songoda.skyblock.menus.admin.Creator;
|
||||
import com.songoda.skyblock.menus.admin.Generator;
|
||||
import com.songoda.skyblock.menus.admin.Levelling;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.placeholder.PlaceholderManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.playtime.PlaytimeTask;
|
||||
import com.songoda.skyblock.scoreboard.ScoreboardManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.stackable.StackableManager;
|
||||
import com.songoda.skyblock.structure.StructureManager;
|
||||
import com.songoda.skyblock.upgrade.UpgradeManager;
|
||||
import com.songoda.skyblock.usercache.UserCacheManager;
|
||||
import com.songoda.skyblock.utils.Metrics;
|
||||
import com.songoda.skyblock.visit.VisitManager;
|
||||
import com.songoda.skyblock.visit.VisitTask;
|
||||
import com.songoda.skyblock.world.WorldManager;
|
||||
import com.songoda.skyblock.world.generator.VoidGenerator;
|
||||
import com.songoda.update.Plugin;
|
||||
import com.songoda.update.SongodaUpdate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class SkyBlock extends JavaPlugin {
|
||||
|
||||
private static SkyBlock instance;
|
||||
|
||||
private FileManager fileManager;
|
||||
private WorldManager worldManager;
|
||||
private UserCacheManager userCacheManager;
|
||||
private VisitManager visitManager;
|
||||
private BanManager banManager;
|
||||
private IslandManager islandManager;
|
||||
private UpgradeManager upgradeManager;
|
||||
private PlayerDataManager playerDataManager;
|
||||
private CooldownManager cooldownManager;
|
||||
private LimitManager limitManager;
|
||||
private ScoreboardManager scoreboardManager;
|
||||
private InviteManager inviteManager;
|
||||
private BiomeManager biomeManager;
|
||||
private LevellingManager levellingManager;
|
||||
private CommandManager commandManager;
|
||||
private StructureManager structureManager;
|
||||
private StackableManager stackableManager;
|
||||
private SoundManager soundManager;
|
||||
private GeneratorManager generatorManager;
|
||||
private LeaderboardManager leaderboardManager;
|
||||
private PlaceholderManager placeholderManager;
|
||||
private MessageManager messageManager;
|
||||
private EconomyManager economyManager;
|
||||
private HologramManager hologramManager;
|
||||
|
||||
public static SkyBlock getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
ConsoleCommandSender console = Bukkit.getConsoleSender();
|
||||
console.sendMessage(formatText("&a============================="));
|
||||
console.sendMessage(formatText("&7FabledSkyBlock " + this.getDescription().getVersion() + " by &5Songoda <3&7!"));
|
||||
console.sendMessage(formatText("&7Action: &aEnabling&7..."));
|
||||
console.sendMessage(formatText("&a============================="));
|
||||
|
||||
instance = this;
|
||||
|
||||
fileManager = new FileManager(this);
|
||||
worldManager = new WorldManager(this);
|
||||
userCacheManager = new UserCacheManager(this);
|
||||
economyManager = new EconomyManager();
|
||||
visitManager = new VisitManager(this);
|
||||
banManager = new BanManager(this);
|
||||
islandManager = new IslandManager(this);
|
||||
upgradeManager = new UpgradeManager(this);
|
||||
playerDataManager = new PlayerDataManager(this);
|
||||
cooldownManager = new CooldownManager(this);
|
||||
limitManager = new LimitManager(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);
|
||||
}
|
||||
|
||||
if (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Stackable.Enable")) {
|
||||
stackableManager = new StackableManager(this);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> stackableManager.loadSavedStackables(), 5L);
|
||||
}
|
||||
|
||||
leaderboardManager = new LeaderboardManager(this);
|
||||
|
||||
placeholderManager = new PlaceholderManager(this);
|
||||
placeholderManager.registerPlaceholders();
|
||||
|
||||
messageManager = new MessageManager(this);
|
||||
hologramManager = new HologramManager(this);
|
||||
|
||||
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 Spawner(this), this);
|
||||
pluginManager.registerEvents(new Food(this), this);
|
||||
|
||||
if (pluginManager.isPluginEnabled("EpicSpawners"))
|
||||
pluginManager.registerEvents(new EpicSpawners(this), this);
|
||||
if (pluginManager.isPluginEnabled("WildStacker"))
|
||||
pluginManager.registerEvents(new WildStacker(this), this);
|
||||
if (pluginManager.isPluginEnabled("UltimateStacker"))
|
||||
pluginManager.registerEvents(new UltimateStacker(this), this);
|
||||
|
||||
pluginManager.registerEvents(new Rollback(), this);
|
||||
pluginManager.registerEvents(new Levelling(), this);
|
||||
pluginManager.registerEvents(new Generator(), this);
|
||||
pluginManager.registerEvents(new Creator(), this);
|
||||
|
||||
this.getCommand("skyblock").setExecutor(new SkyBlockCommand());
|
||||
|
||||
// bStats Metrics
|
||||
new Metrics(this);
|
||||
|
||||
// Songoda Updater
|
||||
Plugin plugin = new Plugin(this, 17);
|
||||
SongodaUpdate.load(plugin);
|
||||
|
||||
SkyBlockAPI.setImplementation(instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
ConsoleCommandSender console = Bukkit.getConsoleSender();
|
||||
console.sendMessage(formatText("&a============================="));
|
||||
console.sendMessage(formatText("&7FabledSkyBlock " + this.getDescription().getVersion() + " by &5Songoda <3&7!"));
|
||||
console.sendMessage(formatText("&7Action: &cDisabling&7..."));
|
||||
console.sendMessage(formatText("&a============================="));
|
||||
|
||||
if (this.userCacheManager != null) {
|
||||
this.userCacheManager.onDisable();
|
||||
}
|
||||
|
||||
if (this.islandManager != null) {
|
||||
this.islandManager.onDisable();
|
||||
}
|
||||
|
||||
if (this.visitManager != null) {
|
||||
this.visitManager.onDisable();
|
||||
}
|
||||
|
||||
if (this.banManager != null) {
|
||||
this.banManager.onDisable();
|
||||
}
|
||||
|
||||
if (this.playerDataManager != null) {
|
||||
this.playerDataManager.onDisable();
|
||||
}
|
||||
|
||||
if (this.cooldownManager != null) {
|
||||
this.cooldownManager.onDisable();
|
||||
}
|
||||
|
||||
if (this.hologramManager != null) {
|
||||
this.hologramManager.onDisable();
|
||||
}
|
||||
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
private String formatText(String string) {
|
||||
return ChatColor.translateAlternateColorCodes('&', string);
|
||||
}
|
||||
|
||||
public FileManager getFileManager() {
|
||||
return fileManager;
|
||||
}
|
||||
|
||||
public WorldManager getWorldManager() {
|
||||
return worldManager;
|
||||
}
|
||||
|
||||
public UserCacheManager getUserCacheManager() {
|
||||
return userCacheManager;
|
||||
}
|
||||
|
||||
public VisitManager getVisitManager() {
|
||||
return visitManager;
|
||||
}
|
||||
|
||||
public BanManager getBanManager() {
|
||||
return banManager;
|
||||
}
|
||||
|
||||
public IslandManager getIslandManager() {
|
||||
return islandManager;
|
||||
}
|
||||
|
||||
public UpgradeManager getUpgradeManager() {
|
||||
return upgradeManager;
|
||||
}
|
||||
|
||||
public PlayerDataManager getPlayerDataManager() {
|
||||
return playerDataManager;
|
||||
}
|
||||
|
||||
public CooldownManager getCooldownManager() {
|
||||
return cooldownManager;
|
||||
}
|
||||
|
||||
public LimitManager getLimitManager() {
|
||||
return limitManager;
|
||||
}
|
||||
|
||||
public ScoreboardManager getScoreboardManager() {
|
||||
return scoreboardManager;
|
||||
}
|
||||
|
||||
public void setScoreboardManager(ScoreboardManager scoreboardManager) {
|
||||
this.scoreboardManager = 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 void setGeneratorManager(GeneratorManager generatorManager) {
|
||||
this.generatorManager = generatorManager;
|
||||
}
|
||||
|
||||
public LeaderboardManager getLeaderboardManager() {
|
||||
return leaderboardManager;
|
||||
}
|
||||
|
||||
public PlaceholderManager getPlaceholderManager() {
|
||||
return placeholderManager;
|
||||
}
|
||||
|
||||
public MessageManager getMessageManager() {
|
||||
return messageManager;
|
||||
}
|
||||
|
||||
public EconomyManager getEconomyManager() {
|
||||
return economyManager;
|
||||
}
|
||||
|
||||
public HologramManager getHologramManager() {
|
||||
return hologramManager;
|
||||
}
|
||||
|
||||
public StackableManager getStackableManager() {
|
||||
return stackableManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
|
||||
return new VoidGenerator();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package com.songoda.skyblock.api;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.api.biome.BiomeManager;
|
||||
import com.songoda.skyblock.api.island.IslandManager;
|
||||
import com.songoda.skyblock.api.levelling.LevellingManager;
|
||||
import com.songoda.skyblock.api.structure.StructureManager;
|
||||
|
||||
public class SkyBlockAPI {
|
||||
|
||||
private static SkyBlock implementation;
|
||||
|
||||
private static IslandManager islandManager;
|
||||
private static BiomeManager biomeManager;
|
||||
private static LevellingManager levellingManager;
|
||||
private static StructureManager structureManager;
|
||||
|
||||
/**
|
||||
* @return The SkyBlock implementation
|
||||
*/
|
||||
public static SkyBlock getImplementation() {
|
||||
return implementation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param implementation the implementation to set
|
||||
*/
|
||||
public static void setImplementation(SkyBlock implementation) {
|
||||
if (SkyBlockAPI.implementation != null) {
|
||||
throw new IllegalArgumentException("Cannot set API implementation twice");
|
||||
}
|
||||
|
||||
SkyBlockAPI.implementation = implementation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The IslandManager implementation
|
||||
*/
|
||||
public static IslandManager getIslandManager() {
|
||||
if (islandManager == null) {
|
||||
islandManager = new IslandManager(implementation.getIslandManager());
|
||||
}
|
||||
|
||||
return islandManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The BiomeManager implementation
|
||||
*/
|
||||
public static BiomeManager getBiomeManager() {
|
||||
if (biomeManager == null) {
|
||||
biomeManager = new BiomeManager(implementation.getBiomeManager());
|
||||
}
|
||||
|
||||
return biomeManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The LevellingManager implementation
|
||||
*/
|
||||
public static LevellingManager getLevellingManager() {
|
||||
if (levellingManager == null) {
|
||||
levellingManager = new LevellingManager(implementation.getLevellingManager());
|
||||
}
|
||||
|
||||
return levellingManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The StructureManager implementation
|
||||
*/
|
||||
public static StructureManager getStructureManager() {
|
||||
if (structureManager == null) {
|
||||
structureManager = new StructureManager(implementation.getStructureManager());
|
||||
}
|
||||
|
||||
return structureManager;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package com.songoda.skyblock.api.ban;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Ban {
|
||||
|
||||
private final Island handle;
|
||||
|
||||
public Ban(Island handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isBanned(UUID uuid) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot return condition to null uuid");
|
||||
return getBans().contains(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A Set of players that have banned from the Island
|
||||
*/
|
||||
public Set<UUID> getBans() {
|
||||
return handle.getIsland().getBan().getBans();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a player to the banned players for the Island
|
||||
*/
|
||||
public void addBan(UUID issuer, UUID banned) {
|
||||
Preconditions.checkArgument(banned != null, "Cannot add ban to null banned uuid");
|
||||
handle.getIsland().getBan().addBan(issuer, banned);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a player from the banned players for the Island
|
||||
*/
|
||||
public void removeBan(UUID uuid) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot remove ban to null uuid");
|
||||
handle.getIsland().getBan().removeBan(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Implementation for the Island
|
||||
*/
|
||||
public Island getIsland() {
|
||||
return handle;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.songoda.skyblock.api.biome;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
public class BiomeManager {
|
||||
|
||||
private final com.songoda.skyblock.biome.BiomeManager biomeManager;
|
||||
|
||||
public BiomeManager(com.songoda.skyblock.biome.BiomeManager biomeManager) {
|
||||
this.biomeManager = biomeManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Biome of an Island
|
||||
*/
|
||||
public void setBiome(Island island, Biome biome) {
|
||||
Preconditions.checkArgument(island != null, "Cannot set biome to null island");
|
||||
Preconditions.checkArgument(biome != null, "Cannot set biome to null biome");
|
||||
|
||||
this.biomeManager.setBiome(island.getIsland(), biome);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class IslandBanEvent extends IslandEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final OfflinePlayer issuer, banned;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public IslandBanEvent(Island island, OfflinePlayer issuer, OfflinePlayer banned) {
|
||||
super(island);
|
||||
this.issuer = issuer;
|
||||
this.banned = banned;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public OfflinePlayer getIssuer() {
|
||||
return issuer;
|
||||
}
|
||||
|
||||
public OfflinePlayer getBanned() {
|
||||
return banned;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class IslandBiomeChangeEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private Biome biome;
|
||||
|
||||
public IslandBiomeChangeEvent(Island island, Biome biome) {
|
||||
super(island);
|
||||
this.biome = biome;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public Biome getBiome() {
|
||||
return biome;
|
||||
}
|
||||
|
||||
public void setBiome(Biome biome) {
|
||||
this.biome = biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class IslandCreateEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final Player player;
|
||||
|
||||
public IslandCreateEvent(Island island, Player player) {
|
||||
super(island, true);
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class IslandDeleteEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
public IslandDeleteEvent(Island island) {
|
||||
super(island);
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
public abstract class IslandEvent extends Event {
|
||||
|
||||
private final Island island;
|
||||
|
||||
protected IslandEvent(Island island) {
|
||||
this.island = island;
|
||||
}
|
||||
|
||||
protected IslandEvent(Island island, boolean async) {
|
||||
super(async);
|
||||
this.island = island;
|
||||
}
|
||||
|
||||
public Island getIsland() {
|
||||
return island;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.invite.IslandInvitation;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class IslandInviteEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final IslandInvitation invite;
|
||||
|
||||
public IslandInviteEvent(Island island, IslandInvitation invite) {
|
||||
super(island);
|
||||
this.invite = invite;
|
||||
}
|
||||
|
||||
public IslandInvitation getInvite() {
|
||||
return invite;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import com.songoda.skyblock.api.island.IslandRole;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class IslandKickEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final Player kicker;
|
||||
private final OfflinePlayer kicked;
|
||||
private final IslandRole role;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public IslandKickEvent(Island island, IslandRole role, OfflinePlayer kicked, Player kicker) {
|
||||
super(island);
|
||||
this.role = role;
|
||||
this.kicked = kicked;
|
||||
this.kicker = kicker;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public OfflinePlayer getKicked() {
|
||||
return kicked;
|
||||
}
|
||||
|
||||
public Player getKicker() {
|
||||
return kicker;
|
||||
}
|
||||
|
||||
public IslandRole getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import com.songoda.skyblock.api.island.IslandLevel;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class IslandLevelChangeEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final IslandLevel level;
|
||||
|
||||
public IslandLevelChangeEvent(Island island, IslandLevel level) {
|
||||
super(island);
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public IslandLevel getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class IslandLoadEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
public IslandLoadEvent(Island island) {
|
||||
super(island);
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import com.songoda.skyblock.api.island.IslandLocation;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class IslandLocationChangeEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final IslandLocation location;
|
||||
|
||||
public IslandLocationChangeEvent(Island island, IslandLocation location) {
|
||||
super(island, true);
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public IslandLocation getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import com.songoda.skyblock.api.island.IslandMessage;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class IslandMessageChangeEvent extends IslandEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final IslandMessage message;
|
||||
private boolean cancelled = false;
|
||||
private List<String> lines;
|
||||
private String author;
|
||||
|
||||
public IslandMessageChangeEvent(Island island, IslandMessage message, List<String> lines, String author) {
|
||||
super(island);
|
||||
this.message = message;
|
||||
this.lines = lines;
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public IslandMessage getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public List<String> getLines() {
|
||||
return lines;
|
||||
}
|
||||
|
||||
public void setLines(List<String> lines) {
|
||||
this.lines = lines;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class IslandOpenEvent extends IslandEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final boolean open;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public IslandOpenEvent(Island island, boolean open) {
|
||||
super(island);
|
||||
this.open = open;
|
||||
}
|
||||
|
||||
public boolean isOpen() {
|
||||
return open;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class IslandOwnershipTransferEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final OfflinePlayer owner;
|
||||
|
||||
public IslandOwnershipTransferEvent(Island island, OfflinePlayer owner) {
|
||||
super(island);
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public OfflinePlayer getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class IslandPasswordChangeEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private String password;
|
||||
|
||||
public IslandPasswordChangeEvent(Island island, String password) {
|
||||
super(island);
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import com.songoda.skyblock.api.island.IslandRole;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class IslandRoleChangeEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final OfflinePlayer player;
|
||||
private final IslandRole role;
|
||||
|
||||
public IslandRoleChangeEvent(Island island, OfflinePlayer player, IslandRole role) {
|
||||
super(island);
|
||||
this.player = player;
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public OfflinePlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public IslandRole getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class IslandUnbanEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final OfflinePlayer unbanned;
|
||||
|
||||
public IslandUnbanEvent(Island island, OfflinePlayer unbanned) {
|
||||
super(island);
|
||||
this.unbanned = unbanned;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public OfflinePlayer getUnbanned() {
|
||||
return unbanned;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class IslandUnloadEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
public IslandUnloadEvent(Island island) {
|
||||
super(island);
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import com.songoda.skyblock.api.island.IslandUpgrade;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class IslandUpgradeEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final Player player;
|
||||
private IslandUpgrade upgrade;
|
||||
|
||||
public IslandUpgradeEvent(Island island, Player player, IslandUpgrade upgrade) {
|
||||
super(island);
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public IslandUpgrade getUpgrade() {
|
||||
return upgrade;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.WeatherType;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class IslandWeatherChangeEvent extends IslandEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final boolean sync;
|
||||
private WeatherType weather;
|
||||
private int time;
|
||||
|
||||
public IslandWeatherChangeEvent(Island island, WeatherType weather, int time, boolean sync) {
|
||||
super(island);
|
||||
this.weather = weather;
|
||||
this.time = time;
|
||||
this.sync = sync;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public WeatherType getWeather() {
|
||||
return weather;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public boolean isSync() {
|
||||
return sync;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.songoda.skyblock.api.event.player;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
public abstract class PlayerEvent extends Event {
|
||||
|
||||
private final Player player;
|
||||
private final Island island;
|
||||
|
||||
protected PlayerEvent(Player player, Island island) {
|
||||
this.player = player;
|
||||
this.island = island;
|
||||
}
|
||||
|
||||
protected PlayerEvent(Player player, Island island, boolean async) {
|
||||
super(async);
|
||||
this.player = player;
|
||||
this.island = island;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public Island getIsland() {
|
||||
return island;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.songoda.skyblock.api.event.player;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class PlayerIslandChatEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private boolean cancelled = false;
|
||||
private String message, format;
|
||||
|
||||
public PlayerIslandChatEvent(Player player, Island island, String message, String format) {
|
||||
super(player, island, true);
|
||||
this.message = message;
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
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 cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.songoda.skyblock.api.event.player;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class PlayerIslandChatSwitchEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private boolean chat;
|
||||
|
||||
public PlayerIslandChatSwitchEvent(Player player, Island island, boolean chat) {
|
||||
super(player, island);
|
||||
this.chat = chat;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public boolean isChat() {
|
||||
return chat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.songoda.skyblock.api.event.player;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class PlayerIslandEnterEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
public PlayerIslandEnterEvent(Player player, Island island) {
|
||||
super(player, island);
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.songoda.skyblock.api.event.player;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class PlayerIslandExitEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
public PlayerIslandExitEvent(Player player, Island island) {
|
||||
super(player, island);
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.songoda.skyblock.api.event.player;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class PlayerIslandJoinEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private boolean cancelled = false;
|
||||
|
||||
public PlayerIslandJoinEvent(Player player, Island island) {
|
||||
super(player, island);
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.songoda.skyblock.api.event.player;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class PlayerIslandLeaveEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private boolean cancelled = false;
|
||||
|
||||
public PlayerIslandLeaveEvent(Player player, Island island) {
|
||||
super(player, island);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.songoda.skyblock.api.event.player;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class PlayerIslandSwitchEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final Island lastIsland;
|
||||
|
||||
public PlayerIslandSwitchEvent(Player player, Island lastIsland, Island island) {
|
||||
super(player, island);
|
||||
this.lastIsland = lastIsland;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public Island getLastIsland() {
|
||||
return lastIsland;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.songoda.skyblock.api.event.player;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class PlayerWithdrawMoneyEvent extends Event {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private Player player;
|
||||
private double money;
|
||||
|
||||
public PlayerWithdrawMoneyEvent(Player player, double money) {
|
||||
this.player = player;
|
||||
this.money = money;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public double getMoney() {
|
||||
return money;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.songoda.skyblock.api.invite;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class IslandInvitation {
|
||||
|
||||
private final Player invited, inviter;
|
||||
private int time;
|
||||
|
||||
public IslandInvitation(Player invited, Player inviter, int time) {
|
||||
this.invited = invited;
|
||||
this.inviter = inviter;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public Player getInvited() {
|
||||
return invited;
|
||||
}
|
||||
|
||||
public Player getInviter() {
|
||||
return inviter;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,507 @@
|
|||
package com.songoda.skyblock.api.island;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.songoda.skyblock.api.SkyBlockAPI;
|
||||
import com.songoda.skyblock.api.ban.Ban;
|
||||
import com.songoda.skyblock.api.utils.APIUtil;
|
||||
import com.songoda.skyblock.api.visit.Visit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.WeatherType;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Island {
|
||||
|
||||
private com.songoda.skyblock.island.Island handle;
|
||||
private OfflinePlayer player;
|
||||
|
||||
public Island(com.songoda.skyblock.island.Island handle, OfflinePlayer player) {
|
||||
this.handle = handle;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Island UUID
|
||||
*/
|
||||
public UUID getIslandUUID() {
|
||||
return this.handle.getIslandUUID();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Island owner UUID
|
||||
*/
|
||||
public UUID getOwnerUUID() {
|
||||
return this.handle.getOwnerUUID();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The original Island owner UUID
|
||||
*/
|
||||
public UUID getOriginalOwnerUUID() {
|
||||
return this.handle.getOriginalOwnerUUID();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Island size
|
||||
*/
|
||||
public int getSize() {
|
||||
return this.handle.getSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the size of the Island
|
||||
*/
|
||||
public void setSize(int size) {
|
||||
Preconditions.checkArgument(size <= 1000, "Cannot set size to greater than 1000");
|
||||
Preconditions.checkArgument(size >= 50, "Cannot set size to less than 50");
|
||||
this.handle.setSize(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Island radius
|
||||
*/
|
||||
public double getRadius() {
|
||||
return this.handle.getRadius();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if not null, false otherwise
|
||||
*/
|
||||
public boolean hasPassword() {
|
||||
return this.handle.hasPassword();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the password for ownership
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
Preconditions.checkArgument(password != null, "Cannot set password to null password");
|
||||
this.handle.setPassword(password);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Location from the World in island world from World in environment.
|
||||
*
|
||||
* @return Location of Island
|
||||
*/
|
||||
public Location getLocation(IslandWorld world, IslandEnvironment environment) {
|
||||
Preconditions.checkArgument(world != null, "World in island world null does not exist");
|
||||
Preconditions.checkArgument(environment != null, "World in environment null does not exist");
|
||||
|
||||
return handle.getLocation(APIUtil.toImplementation(world), APIUtil.toImplementation(environment));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Location from the World in island world from world in environment
|
||||
* followed by position
|
||||
*/
|
||||
public void setLocation(IslandWorld world, IslandEnvironment environment, int x, int y, int z) {
|
||||
Preconditions.checkArgument(world != null, "World in island world null does not exist");
|
||||
Preconditions.checkArgument(environment != null, "World in environment null does not exist");
|
||||
|
||||
World bukkitWorld = getLocation(world, environment).getWorld();
|
||||
this.handle.setLocation(APIUtil.toImplementation(world), APIUtil.toImplementation(environment),
|
||||
new Location(bukkitWorld, x, y, z));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isBorder() {
|
||||
return this.handle.isBorder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the border visible to players for the Island
|
||||
*/
|
||||
public void setBorder(boolean border) {
|
||||
this.handle.setBorder(border);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The color of the Island border
|
||||
*/
|
||||
public IslandBorderColor getBorderColor() {
|
||||
return APIUtil.fromImplementation(this.handle.getBorderColor());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the border color for the Island
|
||||
*/
|
||||
public void setBorderColor(IslandBorderColor color) {
|
||||
Preconditions.checkArgument(color != null, "IslandBorderColor null does not exist");
|
||||
this.handle.setBorderColor(APIUtil.toImplementation(color));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The biome set for the Island
|
||||
*/
|
||||
public Biome getBiome() {
|
||||
return this.handle.getBiome();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the biome for the Island
|
||||
*/
|
||||
public void setBiome(Biome biome) {
|
||||
Preconditions.checkArgument(biome != null, "Cannot set biome to null biome");
|
||||
this.handle.setBiome(biome);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isDayCycleSynchronizedSynchronized() {
|
||||
return this.handle.isWeatherSynchronized();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Day Cycle of the Island to be Synchronized with the World cycle
|
||||
*/
|
||||
public void setDayCycleSynchronzied(boolean sync) {
|
||||
this.handle.setWeatherSynchronized(sync);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The WeatherType set for the Island
|
||||
*/
|
||||
public WeatherType getWeather() {
|
||||
return this.handle.getWeather();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the weather for the Island
|
||||
*/
|
||||
public void setWeather(WeatherType weatherType) {
|
||||
Preconditions.checkArgument(weatherType != null, "Cannot set weather to null weather");
|
||||
this.handle.setWeather(weatherType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The time set for the Island
|
||||
*/
|
||||
public int getTime() {
|
||||
return this.handle.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the time for the Island
|
||||
*/
|
||||
public void setTime(int time) {
|
||||
this.handle.setTime(time);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A Set of cooped players
|
||||
*/
|
||||
public Set<UUID> getCoopPlayers() {
|
||||
return this.handle.getCoopPlayers();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a player to the coop players for the Island
|
||||
*/
|
||||
public void addCoopPlayer(UUID uuid) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot add coop player to null uuid");
|
||||
this.handle.addCoopPlayer(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a player to the coop players for the Island
|
||||
*/
|
||||
public void addCoopPlayer(OfflinePlayer player) {
|
||||
Preconditions.checkArgument(player != null, "Cannot add coop player to null player");
|
||||
this.handle.addCoopPlayer(player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a player from the coop players for the Island
|
||||
*/
|
||||
public void removeCoopPlayer(UUID uuid) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot remove coop player to null uuid");
|
||||
this.handle.removeCoopPlayer(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a player from the coop players for the Island
|
||||
*/
|
||||
public void removeCoopPlayer(OfflinePlayer player) {
|
||||
Preconditions.checkArgument(player != null, "Cannot remove coop player to null player");
|
||||
this.handle.removeCoopPlayer(player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isCoopPlayer(UUID uuid) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot return condition to null uuid");
|
||||
return this.handle.isCoopPlayer(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isCoopPlayer(OfflinePlayer player) {
|
||||
Preconditions.checkArgument(player != null, "Cannot return condition to null player");
|
||||
return this.handle.isCoopPlayer(player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The IslandRole of a player
|
||||
*/
|
||||
public IslandRole getRole(OfflinePlayer player) {
|
||||
Preconditions.checkArgument(player != null, "Cannot get role for null player");
|
||||
|
||||
for (com.songoda.skyblock.island.IslandRole role : com.songoda.skyblock.island.IslandRole.values()) {
|
||||
if (this.handle.hasRole(role, player.getUniqueId())) {
|
||||
return APIUtil.fromImplementation(role);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A Set of players with IslandRole
|
||||
*/
|
||||
public Set<UUID> getPlayersWithRole(IslandRole role) {
|
||||
Preconditions.checkArgument(role != null, "Cannot get players will null role");
|
||||
return this.handle.getRole(APIUtil.toImplementation(role));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the IslandRole of a player for the Island
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean setRole(OfflinePlayer player, IslandRole role) {
|
||||
Preconditions.checkArgument(player != null, "Cannot set role of null player");
|
||||
return setRole(player.getUniqueId(), role);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the IslandRole of a player for the Island
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean setRole(UUID uuid, IslandRole role) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot set role of null player");
|
||||
Preconditions.checkArgument(role != null, "Cannot set role to null role");
|
||||
|
||||
return this.handle.setRole(APIUtil.toImplementation(role), uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the IslandRole of a player for the Island
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean removeRole(OfflinePlayer player, IslandRole role) {
|
||||
Preconditions.checkArgument(player != null, "Cannot remove role of null player");
|
||||
return removeRole(player.getUniqueId(), role);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the IslandRole of a player for the Island
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean removeRole(UUID uuid, IslandRole role) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot remove role of null player");
|
||||
Preconditions.checkArgument(role != null, "Cannot remove role to null role");
|
||||
|
||||
return this.handle.removeRole(APIUtil.toImplementation(role), uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean hasRole(OfflinePlayer player, IslandRole role) {
|
||||
Preconditions.checkArgument(player != null, "Cannot check role of null player");
|
||||
return handle.hasRole(APIUtil.toImplementation(role), player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean hasRole(UUID uuid, IslandRole role) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot check role of null player");
|
||||
Preconditions.checkArgument(role != null, "Cannot check role to null role");
|
||||
|
||||
return handle.hasRole(APIUtil.toImplementation(role), uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the condition of an IslandUpgrade for the Island
|
||||
*/
|
||||
public void setUpgrade(Player player, IslandUpgrade upgrade, boolean status) {
|
||||
Preconditions.checkArgument(upgrade != null, "Cannot set upgrade to null upgrade");
|
||||
this.handle.setUpgrade(player, APIUtil.toImplementation(upgrade), status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean hasUpgrade(IslandUpgrade upgrade) {
|
||||
Preconditions.checkArgument(upgrade != null, "Cannot check upgrade to null upgrade");
|
||||
return this.handle.hasUpgrade(APIUtil.toImplementation(upgrade));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isUpgrade(IslandUpgrade upgrade) {
|
||||
Preconditions.checkArgument(upgrade != null, "Cannot check upgrade to null upgrade");
|
||||
return this.handle.isUpgrade(APIUtil.toImplementation(upgrade));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Setting of an IslandRole for the Island
|
||||
*/
|
||||
public IslandSetting getSetting(IslandRole role, String setting) {
|
||||
Preconditions.checkArgument(role != null, "Cannot get setting to null role");
|
||||
Preconditions.checkArgument(setting != null, "Cannot get setting for null setting");
|
||||
|
||||
return new IslandSetting(this.handle.getSetting(APIUtil.toImplementation(role), setting));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A List of Settings of an IslandRole for the Island
|
||||
*/
|
||||
public List<IslandSetting> getSettings(IslandRole role) {
|
||||
Preconditions.checkArgument(role != null, "Cannot get settings to null role");
|
||||
List<IslandSetting> settings = new ArrayList<>();
|
||||
|
||||
for (com.songoda.skyblock.island.IslandSetting settingList : this.handle
|
||||
.getSettings(APIUtil.toImplementation(role))) {
|
||||
settings.add(new IslandSetting(settingList));
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isOpen() {
|
||||
return handle.isOpen();
|
||||
}
|
||||
|
||||
public void setOpen(boolean open) {
|
||||
this.handle.setOpen(open);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A List from IslandMessage for the Island
|
||||
*/
|
||||
public List<String> getMessage(IslandMessage message) {
|
||||
Preconditions.checkArgument(message != null, "Cannot get message for null message");
|
||||
return this.handle.getMessage(APIUtil.toImplementation(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The author of an IslandMessage for the Island
|
||||
*/
|
||||
public String getMessageAuthor(IslandMessage message) {
|
||||
Preconditions.checkArgument(message != null, "Cannot get message author for null message");
|
||||
return this.handle.getMessageAuthor(APIUtil.toImplementation(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the IslandMessage for the Island
|
||||
*/
|
||||
public void setMessage(IslandMessage message, String author, List<String> messageLines) {
|
||||
Preconditions.checkArgument(message != null, "Cannot set message for null message");
|
||||
this.handle.setMessage(APIUtil.toImplementation(message), author, messageLines);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean hasStructure() {
|
||||
return this.handle.hasStructure();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Structure name for the Island
|
||||
*/
|
||||
public String getStructure() {
|
||||
return this.handle.getStructure();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Structure for the Island
|
||||
*/
|
||||
public void setStructure(String structure) {
|
||||
Preconditions.checkArgument(structure != null, "Cannot set structure to null structure");
|
||||
this.handle.setStructure(structure);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Visit implementation for the Island
|
||||
*/
|
||||
public Visit getVisit() {
|
||||
return new Visit(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Ban implementation for the Island
|
||||
*/
|
||||
public Ban getBan() {
|
||||
return new Ban(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Level implementation for the Island
|
||||
*/
|
||||
public IslandLevel getLevel() {
|
||||
return new IslandLevel(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isLoaded() {
|
||||
return this.handle != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the Island if unloaded
|
||||
*/
|
||||
public void load() {
|
||||
if (this.handle == null) {
|
||||
this.handle = SkyBlockAPI.getImplementation().getIslandManager().loadIsland(player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unloads the Island if loaded
|
||||
*/
|
||||
public void unload() {
|
||||
if (this.handle != null) {
|
||||
SkyBlockAPI.getImplementation().getIslandManager().unloadIsland(getIsland(), null);
|
||||
this.handle = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the player of the Island
|
||||
*/
|
||||
public void setPlayer(OfflinePlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Implementation for the Island
|
||||
*/
|
||||
public com.songoda.skyblock.island.Island getIsland() {
|
||||
return handle;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.songoda.skyblock.api.island;
|
||||
|
||||
public enum IslandBorderColor {
|
||||
|
||||
Blue, Green, Red
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.songoda.skyblock.api.island;
|
||||
|
||||
public enum IslandEnvironment {
|
||||
|
||||
ISLAND, VISITOR, MAIN
|
||||
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
package com.songoda.skyblock.api.island;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.songoda.skyblock.utils.version.Materials;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class IslandLevel {
|
||||
|
||||
private final Island handle;
|
||||
|
||||
public IslandLevel(Island handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Points of the Island from gathered materials
|
||||
*/
|
||||
public long getPoints() {
|
||||
return this.handle.getIsland().getLevel().getPoints();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Level of the Island from points
|
||||
*/
|
||||
public long getLevel() {
|
||||
return this.handle.getIsland().getLevel().getLevel();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Last calculated points of the Island
|
||||
*/
|
||||
public long getLastCalculatedPoints() {
|
||||
return this.handle.getIsland().getLevel().getLastCalculatedPoints();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Last calculated level of the Island
|
||||
*/
|
||||
public long getLastCalculatedLevel() {
|
||||
return this.handle.getIsland().getLevel().getLastCalculatedLevel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the amount of a Material for the Island
|
||||
*/
|
||||
public void setMaterialAmount(Material material, int amount) {
|
||||
Preconditions.checkArgument(material != null, "Cannot set material amount to null material");
|
||||
this.handle.getIsland().getLevel().setMaterialAmount(Materials.fromString(material.name()).name(), amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the amount of a Material for the Island
|
||||
*/
|
||||
public void setMaterialAmount(Material material, byte data, int amount) {
|
||||
Preconditions.checkArgument(material != null, "Cannot set material amount to null material");
|
||||
this.handle.getIsland().getLevel().setMaterialAmount(Materials.requestMaterials(material.name(), data).name(),
|
||||
amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The amount of a Material from the Island
|
||||
*/
|
||||
public long getMaterialAmount(Material material) {
|
||||
Preconditions.checkArgument(material != null, "Cannot get material amount to null material");
|
||||
|
||||
Materials materials = Materials.fromString(material.name());
|
||||
com.songoda.skyblock.island.IslandLevel level = this.handle.getIsland().getLevel();
|
||||
|
||||
if (level.getMaterials().containsKey(materials.name())) {
|
||||
return level.getMaterials().get(materials.name());
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The amount of a Material from the Island
|
||||
*/
|
||||
public long getMaterialAmount(Material material, byte data) {
|
||||
Preconditions.checkArgument(material != null, "Cannot get material amount to null material");
|
||||
|
||||
Materials materials = Materials.requestMaterials(material.name(), data);
|
||||
com.songoda.skyblock.island.IslandLevel level = this.handle.getIsland().getLevel();
|
||||
|
||||
if (level.getMaterials().containsKey(materials.name())) {
|
||||
return level.getMaterials().get(materials.name());
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The points earned for a Material from the Island
|
||||
*/
|
||||
public long getMaterialPoints(Material material) {
|
||||
Preconditions.checkArgument(material != null, "Cannot get material points to null material");
|
||||
return this.handle.getIsland().getLevel().getMaterialPoints(Materials.fromString(material.name()).name());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The points earned for a Material from the Island
|
||||
*/
|
||||
public long getMaterialPoints(Material material, byte data) {
|
||||
Preconditions.checkArgument(material != null, "Cannot get material points to null material");
|
||||
return this.handle.getIsland().getLevel()
|
||||
.getMaterialPoints(Materials.requestMaterials(material.name(), data).name());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Implementation for the Island
|
||||
*/
|
||||
public Island getIsland() {
|
||||
return handle;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.songoda.skyblock.api.island;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class IslandLocation {
|
||||
|
||||
private IslandEnvironment environment;
|
||||
private IslandWorld world;
|
||||
private Location location;
|
||||
|
||||
public IslandLocation(IslandEnvironment environment, IslandWorld world, Location location) {
|
||||
this.environment = environment;
|
||||
this.world = world;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public IslandEnvironment getEnvironment() {
|
||||
return environment;
|
||||
}
|
||||
|
||||
public IslandWorld getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public World getBukkitWorld() {
|
||||
return location.getWorld();
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return location.getBlockX();
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return location.getBlockY();
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return location.getBlockZ();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,377 @@
|
|||
package com.songoda.skyblock.api.island;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.songoda.skyblock.api.structure.Structure;
|
||||
import com.songoda.skyblock.api.utils.APIUtil;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class IslandManager {
|
||||
|
||||
private final com.songoda.skyblock.island.IslandManager islandManager;
|
||||
|
||||
public IslandManager(com.songoda.skyblock.island.IslandManager islandManager) {
|
||||
this.islandManager = islandManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public static boolean hasIsland(OfflinePlayer player) {
|
||||
Preconditions.checkArgument(player != null, "Cannot check island to null player");
|
||||
return new com.songoda.skyblock.utils.player.OfflinePlayer(player.getUniqueId()).getOwner() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the Island border for players occupying an Island
|
||||
*/
|
||||
public void updateBorder(Island island) {
|
||||
Preconditions.checkArgument(island != null, "Cannot update border to null island");
|
||||
|
||||
this.islandManager.updateBorder(island.getIsland());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives Island ownership to a player of their Island
|
||||
*/
|
||||
public void giveOwnership(Island island, OfflinePlayer player) {
|
||||
Preconditions.checkArgument(player != null, "Cannot give ownership to null island");
|
||||
Preconditions.checkArgument(player != null, "Cannot give ownership to null player");
|
||||
|
||||
this.islandManager.giveOwnership(island.getIsland(), player);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Visitors occupying an Island
|
||||
*/
|
||||
public Set<UUID> getVisitorsAtIsland(Island island) {
|
||||
Preconditions.checkArgument(island != null, "Cannot get visitors at island to null island");
|
||||
|
||||
return this.islandManager.getVisitorsAtIsland(island.getIsland());
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a player a Visitor of an Island
|
||||
*/
|
||||
public void visitIsland(Player player, Island island) {
|
||||
Preconditions.checkArgument(player != null, "Cannot visit island to null player");
|
||||
Preconditions.checkArgument(island != null, "Cannot visit island to null island");
|
||||
|
||||
this.islandManager.visitIsland(player, island.getIsland());
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes an Island from Visitors
|
||||
*/
|
||||
public void closeIsland(Island island) {
|
||||
Preconditions.checkArgument(island != null, "Cannot closed island to null island");
|
||||
|
||||
this.islandManager.closeIsland(island.getIsland());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player has permission at an Island for a Setting
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean hasPermission(Player player, String setting) {
|
||||
Preconditions.checkArgument(player != null, "Cannot check permission to null player");
|
||||
|
||||
return this.islandManager.hasPermission(player, setting);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player has permission at a location of an Island for a Setting
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean hasPermission(Player player, Location location, String setting) {
|
||||
Preconditions.checkArgument(player != null, "Cannot check permission to null player");
|
||||
Preconditions.checkArgument(location != null, "Cannot check permission to null location");
|
||||
|
||||
return this.islandManager.hasPermission(player, location, setting);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the permission of a Setting for a Role at a Location
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean hasSetting(Location location, IslandRole role, String setting) {
|
||||
Preconditions.checkArgument(location != null, "Cannot check setting to null location");
|
||||
Preconditions.checkArgument(role != null, "Cannot check setting to null role");
|
||||
|
||||
return this.islandManager.hasSetting(location, APIUtil.toImplementation(role), setting);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A Set of Members of an Island that are online
|
||||
*/
|
||||
public Set<UUID> getMembersOnline(Island island) {
|
||||
Preconditions.checkArgument(island != null, "Cannot get online members to null island");
|
||||
|
||||
return this.islandManager.getMembersOnline(island.getIsland());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A List of Players at an Island
|
||||
*/
|
||||
public List<Player> getPlayersAtIsland(Island island) {
|
||||
Preconditions.checkArgument(island != null, "Cannot get players at island to null island");
|
||||
|
||||
return this.islandManager.getPlayersAtIsland(island.getIsland());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A List of Players at an Island by IslandWorld
|
||||
*/
|
||||
public List<Player> getPlayersAtIsland(Island island, IslandWorld world) {
|
||||
Preconditions.checkArgument(island != null, "Cannot get players at island to null island");
|
||||
Preconditions.checkArgument(world != null, "Cannot get players at island to null world");
|
||||
|
||||
return this.islandManager.getPlayersAtIsland(island.getIsland(), APIUtil.toImplementation(world));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives the Island Upgrades to a player
|
||||
*
|
||||
* @deprecated use {@link #updateFlight(Player)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void giveUgrades(Player player, Island island) {
|
||||
Preconditions.checkArgument(player != null, "Cannot give upgrades to null player");
|
||||
Preconditions.checkArgument(island != null, "Cannot give upgrades to null island");
|
||||
|
||||
this.islandManager.updateFlight(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives Fly to a player if they have permission at an Island
|
||||
*
|
||||
* @deprecated use {@link #updateFlight(Player)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void giveFly(Player player, Island island) {
|
||||
Preconditions.checkArgument(player != null, "Cannot give upgrades to null player");
|
||||
Preconditions.checkArgument(island != null, "Cannot give upgrades to null island");
|
||||
|
||||
this.islandManager.updateFlight(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the Island Upgrades from a player
|
||||
*
|
||||
* @deprecated use {@link #updateFlight(Player)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void removeUpgrades(Player player) {
|
||||
Preconditions.checkArgument(player != null, "Cannot remove upgrades to null player");
|
||||
|
||||
this.islandManager.updateFlight(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the flight of a player based on their permissions and current island upgrades
|
||||
*/
|
||||
public void updateFlight(Player player) {
|
||||
Preconditions.checkArgument(player != null, "Cannot update flight of a null player");
|
||||
|
||||
this.islandManager.updateFlight(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the flight of all players on an island based on their permissions and island upgrades
|
||||
*/
|
||||
public void updateFlightAtIsland(Island island) {
|
||||
Preconditions.checkArgument(island != null, "Cannot update flight of a null island");
|
||||
|
||||
this.islandManager.updateFlightAtIsland(island.getIsland());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A Set of Cooped Players at an Island
|
||||
*/
|
||||
public Set<UUID> getCoopPlayersAtIsland(Island island) {
|
||||
Preconditions.checkArgument(island != null, "Cannot get coop players to null island");
|
||||
|
||||
return this.islandManager.getCoopPlayersAtIsland(island.getIsland());
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes Coop Players occupying an Island
|
||||
*/
|
||||
public void removeCoopPlayersAtIsland(Island island) {
|
||||
Preconditions.checkArgument(island != null, "Cannot remove coop players to null island");
|
||||
this.islandManager.removeCoopPlayers(island.getIsland(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an Island for a player from a Structure
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean createIsland(Player player, Structure structure) {
|
||||
Preconditions.checkArgument(player != null, "Cannot create island to null player");
|
||||
Preconditions.checkArgument(structure != null, "Cannot create island to null structure");
|
||||
|
||||
if (!hasIsland(player)) {
|
||||
return islandManager.createIsland(player, (com.songoda.skyblock.structure.Structure) structure);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an Island permanently
|
||||
*/
|
||||
public void deleteIsland(Island island) {
|
||||
Preconditions.checkArgument(island != null, "Cannot delete island to null island");
|
||||
|
||||
this.islandManager.deleteIsland(island.getIsland());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player is occupying an Island
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isPlayerAtIsland(Island island, Player player) {
|
||||
Preconditions.checkArgument(island != null, "Cannot check to null island");
|
||||
Preconditions.checkArgument(player != null, "Cannot check to null player");
|
||||
return this.islandManager.isPlayerAtIsland(island.getIsland(), player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player is occupying an Island by IslandWorld
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isPlayerAtIsland(Island island, Player player, IslandWorld world) {
|
||||
Preconditions.checkArgument(island != null, "Cannot check to null island");
|
||||
Preconditions.checkArgument(player != null, "Cannot check to null player");
|
||||
Preconditions.checkArgument(world != null, "Cannot check to null world");
|
||||
|
||||
return this.islandManager.isPlayerAtIsland(island.getIsland(), player, APIUtil.toImplementation(world));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a location is at an Island
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isLocationAtIsland(Island island, Location location) {
|
||||
Preconditions.checkArgument(island != null, "Cannot check to null island");
|
||||
Preconditions.checkArgument(location != null, "Cannot check to null location");
|
||||
|
||||
return this.islandManager.isLocationAtIsland(island.getIsland(), location);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Island at a location
|
||||
*/
|
||||
public Island getIslandAtLocation(Location location) {
|
||||
Preconditions.checkArgument(location != null, "Cannot get island to null location");
|
||||
|
||||
com.songoda.skyblock.island.Island island = this.islandManager.getIslandAtLocation(location);
|
||||
|
||||
if (island != null) {
|
||||
return island.getAPIWrapper();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a location is at an Island by IslandWorld
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isPlayerAtIsland(Island island, Location location, IslandWorld world) {
|
||||
Preconditions.checkArgument(island != null, "Cannot check to null island");
|
||||
Preconditions.checkArgument(location != null, "Cannot check to null location");
|
||||
Preconditions.checkArgument(world != null, "Cannot check to null world");
|
||||
|
||||
return this.islandManager.isLocationAtIsland(island.getIsland(), location, APIUtil.toImplementation(world));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Island the player is occupying
|
||||
*/
|
||||
public Island getIslandPlayerAt(Player player) {
|
||||
Preconditions.checkArgument(player != null, "Cannot get Island to null player");
|
||||
|
||||
com.songoda.skyblock.island.Island island = this.islandManager.getIslandPlayerAt(player);
|
||||
|
||||
if (island != null) {
|
||||
return island.getAPIWrapper();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isPlayerAtAnIsland(Player player) {
|
||||
Preconditions.checkArgument(player != null, "Cannot check to null player");
|
||||
return this.islandManager.isPlayerAtAnIsland(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets an Island permanently
|
||||
*/
|
||||
public void resetIsland(Island island) {
|
||||
Preconditions.checkArgument(island != null, "Cannot reset island to null island");
|
||||
this.islandManager.resetIsland(island.getIsland());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Island of a player
|
||||
*/
|
||||
public Island getIsland(OfflinePlayer player) {
|
||||
Preconditions.checkArgument(player != null, "Cannot get island to null player");
|
||||
|
||||
com.songoda.skyblock.island.Island island = this.islandManager.getIsland(player);
|
||||
|
||||
if (island != null) {
|
||||
return island.getAPIWrapper();
|
||||
}
|
||||
|
||||
return new Island(null, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an Island by its UUID
|
||||
* Returns null if an Island with the given UUID does not exist
|
||||
*
|
||||
* @param islandUUID The UUID of the Island
|
||||
* @return The Island with the given UUID, or null if one was not found
|
||||
*/
|
||||
public Island getIslandByUUID(UUID islandUUID) {
|
||||
Preconditions.checkArgument(islandUUID != null, "Cannot get island with a null UUID");
|
||||
|
||||
com.songoda.skyblock.island.Island island = this.islandManager.getIslandByUUID(islandUUID);
|
||||
|
||||
return island != null ? island.getAPIWrapper() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A List of loaded Islands
|
||||
*/
|
||||
public List<Island> getIslands() {
|
||||
List<Island> islands = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < this.islandManager.getIslands().size(); i++) {
|
||||
islands.add(this.islandManager.getIslands().get(this.islandManager.getIslands().keySet().toArray()[i])
|
||||
.getAPIWrapper());
|
||||
}
|
||||
|
||||
return islands;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.songoda.skyblock.api.island;
|
||||
|
||||
public enum IslandMessage {
|
||||
|
||||
WELCOME, SIGNATURE, SIGN
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.songoda.skyblock.api.island;
|
||||
|
||||
public enum IslandRole {
|
||||
|
||||
COOP, VISITOR, MEMBER, OPERATOR, OWNER
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.songoda.skyblock.api.island;
|
||||
|
||||
public class IslandSetting {
|
||||
|
||||
private final com.songoda.skyblock.island.IslandSetting handle;
|
||||
|
||||
public IslandSetting(com.songoda.skyblock.island.IslandSetting handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The name of the Setting
|
||||
*/
|
||||
public String getName() {
|
||||
return this.handle.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The status condition of the Setting
|
||||
*/
|
||||
public boolean getStatus() {
|
||||
return this.handle.getStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param status condition for the Setting
|
||||
*/
|
||||
public void setStatus(boolean status) {
|
||||
this.handle.setStatus(status);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.songoda.skyblock.api.island;
|
||||
|
||||
public enum IslandUpgrade {
|
||||
|
||||
CROP, SPAWNER, FLY, DROPS, SIZE, SPEED, JUMP
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.songoda.skyblock.api.island;
|
||||
|
||||
public enum IslandWorld {
|
||||
|
||||
OVERWORLD, NETHER, END
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.songoda.skyblock.api.levelling;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
|
||||
public class LevellingManager {
|
||||
|
||||
private final com.songoda.skyblock.levelling.LevellingManager levellingManager;
|
||||
|
||||
public LevellingManager(com.songoda.skyblock.levelling.LevellingManager levellingManager) {
|
||||
this.levellingManager = levellingManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the points of an Island to determine what the Island level is
|
||||
*/
|
||||
public void calculatePoints(Island island) {
|
||||
Preconditions.checkArgument(island != null, "Cannot calculate points to null island");
|
||||
this.levellingManager.calculatePoints(null, island.getIsland());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.songoda.skyblock.api.structure;
|
||||
|
||||
import com.songoda.skyblock.utils.version.Materials;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface Structure {
|
||||
|
||||
String getName();
|
||||
|
||||
Materials getMaterials();
|
||||
|
||||
void setMaterials(Materials materials);
|
||||
|
||||
String getOverworldFile();
|
||||
|
||||
void setOverworldFile(String file);
|
||||
|
||||
String getNetherFile();
|
||||
|
||||
void setNetherFile(String file);
|
||||
|
||||
String getDisplayname();
|
||||
|
||||
void setDisplayname(String displayName);
|
||||
|
||||
boolean isPermission();
|
||||
|
||||
String getPermission();
|
||||
|
||||
void setPermission(boolean permission);
|
||||
|
||||
List<String> getDescription();
|
||||
|
||||
void addLine(String line);
|
||||
|
||||
void removeLine(int index);
|
||||
|
||||
List<String> getCommands();
|
||||
|
||||
void addCommand(String command);
|
||||
|
||||
void removeCommand(int index);
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.songoda.skyblock.api.structure;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class StructureManager {
|
||||
|
||||
private final com.songoda.skyblock.structure.StructureManager structureManager;
|
||||
|
||||
public StructureManager(com.songoda.skyblock.structure.StructureManager structureManager) {
|
||||
this.structureManager = structureManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Structure for an Island
|
||||
*/
|
||||
public Structure getStructure(String structure) {
|
||||
return this.structureManager.getStructure(structure);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean hasStructure(String structure) {
|
||||
return structureManager.containsStructure(structure);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A List of Structures for an Island
|
||||
*/
|
||||
public List<Structure> getStructures() {
|
||||
List<Structure> structures = new ArrayList<>();
|
||||
|
||||
for (Structure structureList : structureManager.getStructures()) {
|
||||
structures.add(structureList);
|
||||
}
|
||||
|
||||
return structures;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,188 @@
|
|||
package com.songoda.skyblock.api.utils;
|
||||
|
||||
import com.songoda.skyblock.api.island.*;
|
||||
import com.songoda.skyblock.upgrade.Upgrade;
|
||||
import com.songoda.skyblock.utils.world.WorldBorder;
|
||||
|
||||
public final class APIUtil {
|
||||
|
||||
public static com.songoda.skyblock.island.IslandWorld toImplementation(IslandWorld world) {
|
||||
switch (world) {
|
||||
case NETHER:
|
||||
return com.songoda.skyblock.island.IslandWorld.Nether;
|
||||
case OVERWORLD:
|
||||
return com.songoda.skyblock.island.IslandWorld.Normal;
|
||||
case END:
|
||||
return com.songoda.skyblock.island.IslandWorld.End;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IslandWorld fromImplementation(com.songoda.skyblock.island.IslandWorld world) {
|
||||
switch (world) {
|
||||
case Nether:
|
||||
return IslandWorld.NETHER;
|
||||
case Normal:
|
||||
return IslandWorld.OVERWORLD;
|
||||
case End:
|
||||
return IslandWorld.END;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static com.songoda.skyblock.island.IslandEnvironment toImplementation(IslandEnvironment environment) {
|
||||
switch (environment) {
|
||||
case ISLAND:
|
||||
return com.songoda.skyblock.island.IslandEnvironment.Island;
|
||||
case MAIN:
|
||||
return com.songoda.skyblock.island.IslandEnvironment.Main;
|
||||
case VISITOR:
|
||||
return com.songoda.skyblock.island.IslandEnvironment.Visitor;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IslandEnvironment fromImplementation(com.songoda.skyblock.island.IslandEnvironment environment) {
|
||||
switch (environment) {
|
||||
case Island:
|
||||
return IslandEnvironment.ISLAND;
|
||||
case Main:
|
||||
return IslandEnvironment.MAIN;
|
||||
case Visitor:
|
||||
return IslandEnvironment.VISITOR;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static com.songoda.skyblock.island.IslandRole toImplementation(IslandRole role) {
|
||||
switch (role) {
|
||||
case VISITOR:
|
||||
return com.songoda.skyblock.island.IslandRole.Visitor;
|
||||
case COOP:
|
||||
return com.songoda.skyblock.island.IslandRole.Coop;
|
||||
case MEMBER:
|
||||
return com.songoda.skyblock.island.IslandRole.Member;
|
||||
case OPERATOR:
|
||||
return com.songoda.skyblock.island.IslandRole.Operator;
|
||||
case OWNER:
|
||||
return com.songoda.skyblock.island.IslandRole.Owner;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IslandRole fromImplementation(com.songoda.skyblock.island.IslandRole role) {
|
||||
switch (role) {
|
||||
case Visitor:
|
||||
return IslandRole.VISITOR;
|
||||
case Coop:
|
||||
return IslandRole.COOP;
|
||||
case Member:
|
||||
return IslandRole.MEMBER;
|
||||
case Operator:
|
||||
return IslandRole.OPERATOR;
|
||||
case Owner:
|
||||
return IslandRole.OWNER;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Upgrade.Type toImplementation(IslandUpgrade upgrade) {
|
||||
switch (upgrade) {
|
||||
case CROP:
|
||||
return Upgrade.Type.Crop;
|
||||
case DROPS:
|
||||
return Upgrade.Type.Drops;
|
||||
case FLY:
|
||||
return Upgrade.Type.Fly;
|
||||
case JUMP:
|
||||
return Upgrade.Type.Jump;
|
||||
case SIZE:
|
||||
return Upgrade.Type.Size;
|
||||
case SPAWNER:
|
||||
return Upgrade.Type.Spawner;
|
||||
case SPEED:
|
||||
return Upgrade.Type.Speed;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IslandUpgrade fromImplementation(Upgrade.Type upgrade) {
|
||||
switch (upgrade) {
|
||||
case Crop:
|
||||
return IslandUpgrade.CROP;
|
||||
case Drops:
|
||||
return IslandUpgrade.DROPS;
|
||||
case Fly:
|
||||
return IslandUpgrade.FLY;
|
||||
case Jump:
|
||||
return IslandUpgrade.JUMP;
|
||||
case Size:
|
||||
return IslandUpgrade.SIZE;
|
||||
case Spawner:
|
||||
return IslandUpgrade.SPAWNER;
|
||||
case Speed:
|
||||
return IslandUpgrade.SPEED;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static com.songoda.skyblock.island.IslandMessage toImplementation(IslandMessage message) {
|
||||
switch (message) {
|
||||
case SIGN:
|
||||
return com.songoda.skyblock.island.IslandMessage.Sign;
|
||||
case SIGNATURE:
|
||||
return com.songoda.skyblock.island.IslandMessage.Signature;
|
||||
case WELCOME:
|
||||
return com.songoda.skyblock.island.IslandMessage.Welcome;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IslandMessage fromImplementation(com.songoda.skyblock.island.IslandMessage message) {
|
||||
switch (message) {
|
||||
case Sign:
|
||||
return IslandMessage.SIGN;
|
||||
case Signature:
|
||||
return IslandMessage.SIGNATURE;
|
||||
case Welcome:
|
||||
return IslandMessage.WELCOME;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static WorldBorder.Color toImplementation(IslandBorderColor color) {
|
||||
switch (color) {
|
||||
case Blue:
|
||||
return WorldBorder.Color.Blue;
|
||||
case Green:
|
||||
return WorldBorder.Color.Green;
|
||||
case Red:
|
||||
return WorldBorder.Color.Red;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IslandBorderColor fromImplementation(WorldBorder.Color color) {
|
||||
switch (color) {
|
||||
case Blue:
|
||||
return IslandBorderColor.Blue;
|
||||
case Green:
|
||||
return IslandBorderColor.Green;
|
||||
case Red:
|
||||
return IslandBorderColor.Red;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package com.songoda.skyblock.api.visit;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Visit {
|
||||
|
||||
private final Island handle;
|
||||
|
||||
public Visit(Island handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Safe Level for the Island
|
||||
*/
|
||||
public int getSafeLevel() {
|
||||
return this.handle.getIsland().getVisit().getSafeLevel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Safe Level for the Island
|
||||
*/
|
||||
public void setSafeLevel(int safeLevel) {
|
||||
this.handle.getIsland().getVisit().setSafeLevel(safeLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isVisitor(UUID uuid) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot return condition to null uuid");
|
||||
return getVisitors().contains(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A Set of players that have visited the Island
|
||||
*/
|
||||
public Set<UUID> getVisitors() {
|
||||
return this.handle.getIsland().getVisit().getVisitors();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a player to the visited players for the Island
|
||||
*/
|
||||
public void addVisitor(UUID uuid) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot add visitor to null uuid");
|
||||
this.handle.getIsland().getVisit().addVisitor(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a player from the visited players for the Island
|
||||
*/
|
||||
public void removeVisitor(UUID uuid) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot remove visitor to null uuid");
|
||||
this.handle.getIsland().getVisit().removeVisitor(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean isVoter(UUID uuid) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot return condition to null uuid");
|
||||
return getVoters().contains(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A Set of players that have voted for the Island
|
||||
*/
|
||||
public Set<UUID> getVoters() {
|
||||
return this.handle.getIsland().getVisit().getVoters();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a player to the voted players for the Island
|
||||
*/
|
||||
public void addVoter(UUID uuid) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot add voter to null uuid");
|
||||
this.handle.getIsland().getVisit().addVoter(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a player from the voted players for the Island
|
||||
*/
|
||||
public void removeVoter(UUID uuid) {
|
||||
Preconditions.checkArgument(uuid != null, "Cannot remove voter to null uuid");
|
||||
this.handle.getIsland().getVisit().removeVoter(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Implementation for the Island
|
||||
*/
|
||||
public Island getIsland() {
|
||||
return handle;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package com.songoda.skyblock.ban;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.api.event.island.IslandBanEvent;
|
||||
import com.songoda.skyblock.api.event.island.IslandUnbanEvent;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
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 Set<UUID> getBans() {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
Set<UUID> islandBans = new HashSet<>();
|
||||
|
||||
for (String islandBanList : skyblock.getFileManager()
|
||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/ban-data"),
|
||||
islandOwnerUUID.toString() + ".yml"))
|
||||
.getFileConfiguration().getStringList("Bans")) {
|
||||
|
||||
UUID uuid = UUID.fromString(islandBanList);
|
||||
if (!Bukkit.getOfflinePlayer(uuid).hasPlayedBefore())
|
||||
continue;
|
||||
|
||||
islandBans.add(uuid);
|
||||
}
|
||||
|
||||
return islandBans;
|
||||
}
|
||||
|
||||
public void addBan(UUID issuer, UUID banned) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
IslandBanEvent islandBanEvent = new IslandBanEvent(
|
||||
skyblock.getIslandManager().getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID))
|
||||
.getAPIWrapper(),
|
||||
Bukkit.getServer().getOfflinePlayer(issuer), Bukkit.getServer().getOfflinePlayer(banned));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(islandBanEvent));
|
||||
|
||||
if (!islandBanEvent.isCancelled()) {
|
||||
List<String> islandBans = new ArrayList<>();
|
||||
FileConfiguration configLoad = skyblock.getFileManager()
|
||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/ban-data"),
|
||||
islandOwnerUUID.toString() + ".yml"))
|
||||
.getFileConfiguration();
|
||||
|
||||
for (String islandBanList : configLoad.getStringList("Bans")) {
|
||||
islandBans.add(islandBanList);
|
||||
}
|
||||
|
||||
islandBans.add(banned.toString());
|
||||
configLoad.set("Bans", islandBans);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeBan(UUID uuid) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
List<String> islandBans = new ArrayList<>();
|
||||
FileConfiguration configLoad = skyblock.getFileManager()
|
||||
.getConfig(new File(new File(skyblock.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(skyblock.getIslandManager()
|
||||
.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)).getAPIWrapper(),
|
||||
Bukkit.getServer().getOfflinePlayer(uuid)));
|
||||
}
|
||||
|
||||
public void save() {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(
|
||||
new File(skyblock.getDataFolder().toString() + "/ban-data"), islandOwnerUUID.toString() + ".yml"));
|
||||
|
||||
try {
|
||||
config.getFileConfiguration().save(config.getFile());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
package com.songoda.skyblock.ban;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import com.songoda.skyblock.utils.world.LocationUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BanManager {
|
||||
|
||||
private final SkyBlock skyblock;
|
||||
private Map<UUID, Ban> banStorage = new HashMap<>();
|
||||
|
||||
public BanManager(SkyBlock skyblock) {
|
||||
this.skyblock = skyblock;
|
||||
|
||||
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 = skyblock.getFileManager();
|
||||
|
||||
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Visitor.Unload")) {
|
||||
File configFile = new File(skyblock.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 uuid1, UUID uuid2) {
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Ban ban = getIsland(uuid1);
|
||||
ban.save();
|
||||
|
||||
File oldBanDataFile = new File(new File(skyblock.getDataFolder().toString() + "/ban-data"),
|
||||
uuid1.toString() + ".yml");
|
||||
File newBanDataFile = new File(new File(skyblock.getDataFolder().toString() + "/ban-data"),
|
||||
uuid2.toString() + ".yml");
|
||||
|
||||
fileManager.unloadConfig(oldBanDataFile);
|
||||
fileManager.unloadConfig(newBanDataFile);
|
||||
|
||||
oldBanDataFile.renameTo(newBanDataFile);
|
||||
|
||||
removeIsland(uuid1);
|
||||
addIsland(uuid2, ban);
|
||||
}
|
||||
|
||||
public void removeVisitor(Island island) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
for (UUID visitorList : skyblock.getIslandManager().getVisitorsAtIsland(island)) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(visitorList);
|
||||
|
||||
LocationUtil.teleportPlayerToSpawn(targetPlayer);
|
||||
|
||||
messageManager.sendMessage(targetPlayer, configLoad.getString("Island.Visit.Banned.Island.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)) {
|
||||
skyblock.getFileManager().unloadConfig(new File(new File(skyblock.getDataFolder().toString() + "/ban-data"),
|
||||
islandOwnerUUID.toString() + ".yml"));
|
||||
banStorage.remove(islandOwnerUUID);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteIsland(UUID islandOwnerUUID) {
|
||||
if (hasIsland(islandOwnerUUID)) {
|
||||
skyblock.getFileManager().deleteConfig(new File(new File(skyblock.getDataFolder().toString() + "/ban-data"),
|
||||
islandOwnerUUID.toString() + ".yml"));
|
||||
banStorage.remove(islandOwnerUUID);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
package me.goodandevil.skyblock.biome;
|
||||
package com.songoda.skyblock.biome;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
import me.goodandevil.skyblock.island.Island;
|
||||
import me.goodandevil.skyblock.island.IslandEnvironment;
|
||||
import me.goodandevil.skyblock.island.IslandWorld;
|
||||
import me.goodandevil.skyblock.utils.version.NMSUtil;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandEnvironment;
|
||||
import com.songoda.skyblock.island.IslandWorld;
|
||||
import com.songoda.skyblock.utils.version.NMSUtil;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Biome;
|
|
@ -0,0 +1,564 @@
|
|||
package com.songoda.skyblock.command;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.command.commands.admin.*;
|
||||
import com.songoda.skyblock.command.commands.island.CreateCommand;
|
||||
import com.songoda.skyblock.command.commands.island.DeleteCommand;
|
||||
import com.songoda.skyblock.command.commands.island.LevelCommand;
|
||||
import com.songoda.skyblock.command.commands.island.OwnerCommand;
|
||||
import com.songoda.skyblock.command.commands.island.SetSpawnCommand;
|
||||
import com.songoda.skyblock.command.commands.island.SettingsCommand;
|
||||
import com.songoda.skyblock.command.commands.island.UpgradeCommand;
|
||||
import com.songoda.skyblock.command.commands.island.*;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.menus.ControlPanel;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.ChatComponent;
|
||||
import com.songoda.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;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
|
||||
private final SkyBlock skyblock;
|
||||
private List<SubCommand> islandCommands;
|
||||
private List<SubCommand> adminCommands;
|
||||
|
||||
public CommandManager(SkyBlock skyblock) {
|
||||
this.skyblock = skyblock;
|
||||
|
||||
skyblock.getCommand("island").setExecutor(this);
|
||||
skyblock.getCommand("island").setTabCompleter(this);
|
||||
|
||||
registerSubCommands();
|
||||
}
|
||||
|
||||
public void registerSubCommands() {
|
||||
islandCommands = Arrays.asList(
|
||||
new AcceptCommand(),
|
||||
new BanCommand(),
|
||||
new BankCommand(),
|
||||
new BansCommand(),
|
||||
new BiomeCommand(),
|
||||
new BorderCommand(),
|
||||
new CancelCommand(),
|
||||
new ChatCommand(),
|
||||
new CloseCommand(),
|
||||
new ConfirmCommand(),
|
||||
new ControlPanelCommand(),
|
||||
new CoopCommand(),
|
||||
new CreateCommand(),
|
||||
new CurrentCommand(),
|
||||
new DeleteCommand(),
|
||||
new DemoteCommand(),
|
||||
new DenyCommand(),
|
||||
new InformationCommand(),
|
||||
new InviteCommand(),
|
||||
new KickAllCommand(),
|
||||
new KickCommand(),
|
||||
new LeaderboardCommand(),
|
||||
new LeaveCommand(),
|
||||
new LevelCommand(),
|
||||
new MembersCommand(),
|
||||
new OpenCommand(),
|
||||
new OwnerCommand(),
|
||||
new PromoteCommand(),
|
||||
new PublicCommand(),
|
||||
new SetSpawnCommand(),
|
||||
new SettingsCommand(),
|
||||
new TeleportCommand(),
|
||||
new UnbanCommand(),
|
||||
new UnlockCommand(),
|
||||
new UpgradeCommand(),
|
||||
new ValueCommand(),
|
||||
new VisitCommand(),
|
||||
new VisitorsCommand(),
|
||||
new VoteCommand(),
|
||||
new WeatherCommand()
|
||||
);
|
||||
|
||||
adminCommands = Arrays.asList(
|
||||
new AddUpgradeCommand(),
|
||||
new com.songoda.skyblock.command.commands.admin.CreateCommand(),
|
||||
new com.songoda.skyblock.command.commands.admin.DeleteCommand(),
|
||||
new GeneratorCommand(),
|
||||
new com.songoda.skyblock.command.commands.admin.LevelCommand(),
|
||||
new LevelScanCommand(),
|
||||
new com.songoda.skyblock.command.commands.admin.OwnerCommand(),
|
||||
new RefreshHologramsCommand(),
|
||||
new ReloadCommand(),
|
||||
new RemoveHologramCommand(),
|
||||
new RemoveUpgradeCommand(),
|
||||
new SetBiomeCommand(),
|
||||
new SetHologramCommand(),
|
||||
new SetSizeCommand(),
|
||||
new com.songoda.skyblock.command.commands.admin.SetSpawnCommand(),
|
||||
new com.songoda.skyblock.command.commands.admin.SettingsCommand(),
|
||||
new StructureCommand(),
|
||||
new com.songoda.skyblock.command.commands.admin.UpgradeCommand()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
|
||||
if (command.getName().equalsIgnoreCase("island")) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Player player = null;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
if (player == null) {
|
||||
sendConsoleHelpCommands(sender);
|
||||
} else {
|
||||
if (skyblock.getIslandManager().getIsland(player) == null) {
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> Bukkit.getServer().dispatchCommand(sender, "island create"));
|
||||
} else {
|
||||
boolean canUseControlPanel = player.hasPermission("fabledskyblock.*")
|
||||
|| player.hasPermission("fabledskyblock.island.*")
|
||||
|| player.hasPermission("fabledskyblock.island.controlpanel");
|
||||
|
||||
if (!canUseControlPanel) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.PermissionDenied.Island.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
return true;
|
||||
}
|
||||
|
||||
ControlPanel.getInstance().open(player);
|
||||
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
SubCommand subCommand;
|
||||
boolean isAdmin;
|
||||
|
||||
if (args[0].equalsIgnoreCase("help")) {
|
||||
if (player == null) {
|
||||
sendConsoleHelpCommands(sender);
|
||||
} else {
|
||||
boolean canUseHelp = player.hasPermission("fabledskyblock.*")
|
||||
|| player.hasPermission("fabledskyblock.island.*")
|
||||
|| player.hasPermission("fabledskyblock.island.help");
|
||||
|
||||
if (!canUseHelp) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.PermissionDenied.Island.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
return true;
|
||||
}
|
||||
|
||||
int page = -1;
|
||||
|
||||
if (!fileManager.getConfig(new File(skyblock.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 {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Help.Integer.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sendPlayerIslandHelpCommands(player, page);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("admin")) {
|
||||
if (args.length == 1 || args[1].equalsIgnoreCase("help")) {
|
||||
if (player == null) {
|
||||
sendConsoleHelpCommands(sender);
|
||||
} else {
|
||||
boolean canUseHelp = player.hasPermission("fabledskyblock.*")
|
||||
|| player.hasPermission("fabledskyblock.admin.*")
|
||||
|| player.hasPermission("fabledskyblock.admin.help");
|
||||
|
||||
if (!canUseHelp) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.PermissionDenied.Admin.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
return true;
|
||||
}
|
||||
|
||||
int page = -1;
|
||||
|
||||
if (!fileManager.getConfig(new File(skyblock.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 {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Help.Integer.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F,
|
||||
1.0F);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sendPlayerAdminHelpCommands(player, page);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
subCommand = getAdminSubCommand(args[1]);
|
||||
isAdmin = true;
|
||||
} else {
|
||||
subCommand = getIslandSubCommand(args[0]);
|
||||
isAdmin = false;
|
||||
}
|
||||
|
||||
if (subCommand == null) {
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Argument.Unrecognised.Message"));
|
||||
soundManager.playSound(sender, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!subCommand.hasPermission(sender, isAdmin)) {
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.PermissionDenied." + (isAdmin ? "Admin" : "Island") + ".Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
return true;
|
||||
}
|
||||
|
||||
List<String> arguments = new ArrayList<>(Arrays.asList(args));
|
||||
arguments.remove(args[0]);
|
||||
|
||||
if (adminCommands.contains(subCommand)) {
|
||||
arguments.remove(args[1]);
|
||||
}
|
||||
|
||||
if (sender instanceof Player) {
|
||||
subCommand.onCommandByPlayer(player, arguments.toArray(new String[0]));
|
||||
} else if (sender instanceof ConsoleCommandSender) {
|
||||
subCommand.onCommandByConsole((ConsoleCommandSender) sender,
|
||||
arguments.toArray(new String[0]));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String s, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean isAdmin = sender.hasPermission("fabledskyblock.admin.*") || sender.hasPermission("fabledskyblock.*");
|
||||
|
||||
if (command.getName().equalsIgnoreCase("island")) {
|
||||
List<String> commandAliases = new ArrayList<>();
|
||||
|
||||
if (args.length == 1) {
|
||||
if (args[0] == null || args[0].isEmpty()) {
|
||||
commandAliases.add("admin");
|
||||
|
||||
for (SubCommand subCommandList : islandCommands) {
|
||||
commandAliases.add(subCommandList.getName());
|
||||
}
|
||||
} else {
|
||||
if (isAdmin) {
|
||||
if ("admin".contains(args[0].toLowerCase())) {
|
||||
commandAliases.add("admin");
|
||||
}
|
||||
}
|
||||
|
||||
for (SubCommand subCommandList : islandCommands) {
|
||||
if (subCommandList.getName().toLowerCase().contains(args[0].toLowerCase())) {
|
||||
commandAliases.add(subCommandList.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (args.length == 2) {
|
||||
if (isAdmin) {
|
||||
if (args[0].equalsIgnoreCase("admin")) {
|
||||
if (args[1] == null || args[1].isEmpty()) {
|
||||
for (SubCommand subCommandList : adminCommands) {
|
||||
commandAliases.add(subCommandList.getName());
|
||||
}
|
||||
} else {
|
||||
for (SubCommand subCommandList : adminCommands) {
|
||||
if (subCommandList.getName().toLowerCase().contains(args[1].toLowerCase())) {
|
||||
commandAliases.add(subCommandList.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<String> arguments = getIslandArguments(args[0], args[1]);
|
||||
|
||||
if (arguments.size() != 0) {
|
||||
commandAliases.addAll(arguments);
|
||||
}
|
||||
} else if (args.length == 3) {
|
||||
if (isAdmin) {
|
||||
if (args[0].equalsIgnoreCase("admin")) {
|
||||
List<String> arguments = getAdminArguments(args[1], args[2]);
|
||||
|
||||
if (arguments.size() != 0) {
|
||||
commandAliases.addAll(arguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (commandAliases.size() != 0) {
|
||||
return commandAliases;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<String> getIslandArguments(String arg1, String arg2) {
|
||||
return this.getArguments(islandCommands, arg1, arg2);
|
||||
}
|
||||
|
||||
public List<String> getAdminArguments(String arg1, String arg2) {
|
||||
return this.getArguments(adminCommands, arg1, arg2);
|
||||
}
|
||||
|
||||
public List<String> getArguments(List<SubCommand> subCommands, String arg1, String arg2) {
|
||||
List<String> arguments = new ArrayList<>();
|
||||
|
||||
for (SubCommand subCommandList : subCommands) {
|
||||
if (arg1.equalsIgnoreCase(subCommandList.getName())) {
|
||||
if (arg2 == null || arg2.isEmpty()) {
|
||||
arguments.addAll(Arrays.asList(subCommandList.getArguments()));
|
||||
} else {
|
||||
for (String argumentList : subCommandList.getArguments()) {
|
||||
if (argumentList.contains(arg2.toLowerCase())) {
|
||||
arguments.add(argumentList);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return arguments;
|
||||
}
|
||||
|
||||
public void sendPlayerIslandHelpCommands(Player player, int page) {
|
||||
this.sendPlayerHelpCommands(player, islandCommands, page, false);
|
||||
}
|
||||
|
||||
public void sendPlayerAdminHelpCommands(Player player, int page) {
|
||||
this.sendPlayerHelpCommands(player, adminCommands, page, true);
|
||||
}
|
||||
|
||||
public void sendPlayerHelpCommands(Player player, List<SubCommand> subCommands, int page, boolean isAdmin) {
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
int pageSize = 7;
|
||||
|
||||
int nextEndIndex = subCommands.size() - page * pageSize, index = page * pageSize - pageSize,
|
||||
endIndex = index >= subCommands.size() ? subCommands.size() - 1 : index + pageSize;
|
||||
boolean showAlises = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Command.Help.Aliases.Enable");
|
||||
|
||||
if (nextEndIndex <= -7) {
|
||||
skyblock.getMessageManager().sendMessage(player, configLoad.getString("Command.Island.Help.Page.Message"));
|
||||
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
String subCommandText = "";
|
||||
|
||||
if (isAdmin) {
|
||||
subCommandText = "admin ";
|
||||
}
|
||||
|
||||
for (String helpLines : configLoad.getStringList("Command.Island.Help.Lines")) {
|
||||
if (helpLines.contains("%type")) {
|
||||
helpLines = helpLines.replace("%type", "Admin");
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
if (page == -1) {
|
||||
for (SubCommand subCommand : subCommands) {
|
||||
StringBuilder commandAliases = new StringBuilder();
|
||||
|
||||
if (showAlises) {
|
||||
for (int i = 0; i < subCommand.getAliases().length; i++) {
|
||||
commandAliases.append("/").append(subCommand.getAliases()[i]);
|
||||
}
|
||||
}
|
||||
|
||||
player.spigot()
|
||||
.sendMessage(new ChatComponent(
|
||||
prefix.replace("%info", subCommand.getInfo()) + "/island "
|
||||
+ subCommandText + subCommand.getName() + commandAliases
|
||||
+ suffix.replace("%info", subCommand.getInfo()),
|
||||
false, null, null,
|
||||
new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder(subCommand.getInfo()).create()))
|
||||
.getTextComponent());
|
||||
}
|
||||
} else {
|
||||
for (; index < endIndex; index++) {
|
||||
if (subCommands.size() > index) {
|
||||
SubCommand subCommandFromIndex = subCommands.get(index);
|
||||
StringBuilder commandAliases = new StringBuilder();
|
||||
|
||||
if (showAlises) {
|
||||
for (int i = 0; i < subCommandFromIndex.getAliases().length; i++) {
|
||||
commandAliases.append("/").append(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 {
|
||||
skyblock.getMessageManager().sendMessage(player, 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
skyblock.getSoundManager().playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
public void sendConsoleHelpCommands(CommandSender sender) {
|
||||
sender.sendMessage("SkyBlock - Console Commands");
|
||||
|
||||
String[] commands = {"delete", "owner", "reload", "removehologram", "setsize"};
|
||||
|
||||
for (String commandList : commands) {
|
||||
SubCommand subCommand = this.getAdminSubCommand(commandList);
|
||||
sender.sendMessage("* /island admin " + subCommand.getName() + " - " + subCommand.getInfo());
|
||||
}
|
||||
}
|
||||
|
||||
public SubCommand getIslandSubCommand(String cmdName) {
|
||||
return this.getSubCommand(islandCommands, cmdName);
|
||||
}
|
||||
|
||||
public SubCommand getAdminSubCommand(String cmdName) {
|
||||
return this.getSubCommand(adminCommands, cmdName);
|
||||
}
|
||||
|
||||
public SubCommand getSubCommand(List<SubCommand> subCommands, String cmdName) {
|
||||
for (SubCommand command : subCommands) {
|
||||
if (command.getName().equalsIgnoreCase(cmdName))
|
||||
return command;
|
||||
|
||||
for (String argList : command.getAliases())
|
||||
if (argList.equalsIgnoreCase(cmdName))
|
||||
return command;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package me.goodandevil.skyblock.command;
|
||||
package com.songoda.skyblock.command;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -30,7 +30,9 @@ public abstract class SubCommand {
|
|||
|
||||
public abstract String[] getArguments();
|
||||
|
||||
public String getInfo() { return this.info; }
|
||||
public String getInfo() {
|
||||
return this.info;
|
||||
}
|
||||
|
||||
public boolean hasPermission(Permissible toCheck, boolean isAdmin) {
|
||||
if (toCheck.hasPermission("fabledskyblock.*"))
|
|
@ -1,6 +1,6 @@
|
|||
package me.goodandevil.skyblock.command.commands;
|
||||
package com.songoda.skyblock.command.commands;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
|
@ -17,7 +17,7 @@ public class SkyBlockCommand implements CommandExecutor {
|
|||
return true;
|
||||
}
|
||||
|
||||
private String formatText(String string){
|
||||
private String formatText(String string) {
|
||||
return ChatColor.translateAlternateColorCodes('&', string);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,156 @@
|
|||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.upgrade.Upgrade;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AddUpgradeCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
onCommand(player, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
onCommand(sender, args);
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 2) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
UUID islandOwnerUUID;
|
||||
String targetPlayerName;
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
|
||||
islandOwnerUUID = targetPlayerOffline.getOwner();
|
||||
targetPlayerName = targetPlayerOffline.getName();
|
||||
} else {
|
||||
islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner();
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
}
|
||||
|
||||
Upgrade.Type upgrade = null;
|
||||
|
||||
for (Upgrade.Type upgradeList : Upgrade.Type.values()) {
|
||||
if (upgradeList != Upgrade.Type.Size) {
|
||||
if (args[1].toUpperCase().equals(upgradeList.name().toUpperCase())) {
|
||||
upgrade = upgradeList;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (islandOwnerUUID == null) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.AddUpgrade.Island.Owner.Message"));
|
||||
soundManager.playSound(sender, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (upgrade == null) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.AddUpgrade.Upgrade.Exist.Message"));
|
||||
soundManager.playSound(sender, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
if (islandManager.containsIsland(islandOwnerUUID)) {
|
||||
Island island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
|
||||
|
||||
if (island.hasUpgrade(upgrade)) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.AddUpgrade.Upgrade.Already.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
island.setUpgrade(null, upgrade, true);
|
||||
} else {
|
||||
File islandDataFile = new File(skyblock.getDataFolder().toString() + "/island-data",
|
||||
islandOwnerUUID.toString() + ".yml");
|
||||
|
||||
if (!fileManager.isFileExist(islandDataFile)) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.AddUpgrade.Island.Data.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
FileConfiguration islandDataConfigLoad = YamlConfiguration.loadConfiguration(islandDataFile);
|
||||
|
||||
if (islandDataConfigLoad.getString("Upgrade." + upgrade.name()) != null) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.AddUpgrade.Upgrade.Already.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
islandDataConfigLoad.set("Upgrade." + upgrade.name(), true);
|
||||
|
||||
try {
|
||||
islandDataConfigLoad.save(islandDataFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.AddUpgrade.Added.Message")
|
||||
.replace("%player", targetPlayerName).replace("%upgrade", upgrade.name()));
|
||||
soundManager.playSound(sender, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.AddUpgrade.Invalid.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "addupgrade";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Admin.AddUpgrade.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.menus.admin.Creator;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CreateCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
playerDataManager.getPlayerData(player).setViewer(null);
|
||||
}
|
||||
|
||||
Creator.getInstance().open(player);
|
||||
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "create";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Admin.Create.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import com.songoda.skyblock.utils.world.LocationUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DeleteCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
onCommand(player, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
onCommand(sender, args);
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Player player = null;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
}
|
||||
|
||||
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 (targetPlayerUUID == null || !islandManager.isIslandExist(targetPlayerUUID)) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.Delete.Owner.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
Island island = islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(targetPlayerUUID));
|
||||
Location spawnLocation = LocationUtil.getSpawnLocation();
|
||||
|
||||
if (spawnLocation != null && islandManager.isLocationAtIsland(island, spawnLocation)) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Admin.Delete.Spawn.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
islandManager.unloadIsland(island, null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
if (island.hasRole(IslandRole.Member, all.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Operator, all.getUniqueId())) {
|
||||
all.sendMessage(ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Command.Island.Confirmation.Deletion.Broadcast.Message")));
|
||||
soundManager.playSound(all, Sounds.EXPLODE.bukkitSound(), 10.0F, 10.0F);
|
||||
}
|
||||
}
|
||||
|
||||
island.setDeleted(true);
|
||||
islandManager.deleteIsland(island);
|
||||
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.Delete.Deleted.Message").replace("%player",
|
||||
targetPlayerName));
|
||||
soundManager.playSound(sender, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Delete.Invalid.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "delete";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Admin.Delete.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[]{"remove", "disband"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.menus.admin.Generator;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class GeneratorCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (skyblock.getGeneratorManager() == null) {
|
||||
messageManager.sendMessage(player, 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 void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "generator";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Admin.Generator.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.menus.admin.Levelling;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LevelCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
Levelling.getInstance().open(player);
|
||||
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "level";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Admin.Level.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[]{"levelling", "points"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.levelling.LevellingManager;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class LevelScanCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
this.onCommand(player, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
this.onCommand(sender, args);
|
||||
}
|
||||
|
||||
private void onCommand(CommandSender sender, String[] args) {
|
||||
LevellingManager levellingManager = skyblock.getLevellingManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
FileManager.Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 0) {
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.LevelScan.Invalid.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(args[0]);
|
||||
Island island = islandManager.getIsland(offlinePlayer);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.LevelScan.NoIsland.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
|
||||
levellingManager.calculatePoints(sender instanceof Player ? (Player) sender : null, island);
|
||||
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.LevelScan.Started.Message"));
|
||||
soundManager.playSound(sender, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "levelscan";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Admin.LevelScan.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public class OwnerCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
onCommand(player, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
onCommand(sender, args);
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
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(targetPlayer).getOwner();
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
}
|
||||
|
||||
if (islandOwnerUUID == null) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.Owner.Island.None.Message"));
|
||||
soundManager.playSound(sender, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (islandOwnerUUID.equals(targetPlayerUUID)) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.Owner.Island.Owner.Message").replace("%player",
|
||||
targetPlayerName));
|
||||
soundManager.playSound(sender, 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();
|
||||
}
|
||||
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.Owner.Island.Member.Message")
|
||||
.replace("%player", targetPlayerName).replace("%owner", islandOwnerName));
|
||||
soundManager.playSound(sender, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Owner.Invalid.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "owner";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Admin.Owner.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[]{"ownership", "leader"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -1,16 +1,12 @@
|
|||
package me.goodandevil.skyblock.command.commands.admin;
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import me.goodandevil.skyblock.command.SubCommand;
|
||||
import me.goodandevil.skyblock.config.FileManager;
|
||||
import me.goodandevil.skyblock.config.FileManager.Config;
|
||||
import me.goodandevil.skyblock.hologram.Hologram;
|
||||
import me.goodandevil.skyblock.hologram.HologramManager;
|
||||
import me.goodandevil.skyblock.hologram.HologramType;
|
||||
import me.goodandevil.skyblock.leaderboard.LeaderboardManager;
|
||||
import me.goodandevil.skyblock.message.MessageManager;
|
||||
import me.goodandevil.skyblock.sound.SoundManager;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.leaderboard.LeaderboardManager;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
|
@ -18,7 +14,6 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class RefreshHologramsCommand extends SubCommand {
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.generator.GeneratorManager;
|
||||
import com.songoda.skyblock.hologram.HologramManager;
|
||||
import com.songoda.skyblock.leaderboard.LeaderboardManager;
|
||||
import com.songoda.skyblock.levelling.LevellingManager;
|
||||
import com.songoda.skyblock.limit.LimitManager;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.scoreboard.ScoreboardManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
public class ReloadCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
onCommand(player, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
onCommand(sender, args);
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager();
|
||||
HologramManager hologramManager = skyblock.getHologramManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
LimitManager limitManager = skyblock.getLimitManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
messageManager.sendMessage(sender, "&cPlease note that this command is not supported and may " +
|
||||
"cause issues that could put the plugin in an unstable state. " +
|
||||
"If you encounter any issues please stop your server, edit the configuration files, " +
|
||||
"and then start your server again. This command does NOT reload all the plugin files, only " +
|
||||
"the config.yml, language.yml, generators.yml, levelling.yml, and limits.yml.");
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
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(skyblock.getDataFolder().toString() + "\\")
|
||||
|| configFilePath.equals(skyblock.getDataFolder().toString() + "/")) {
|
||||
configFileConfig.loadFile();
|
||||
}
|
||||
}
|
||||
|
||||
Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration mainConfigLoad = mainConfig.getFileConfiguration();
|
||||
|
||||
if (skyblock.getScoreboardManager() == null) {
|
||||
if (mainConfigLoad.getBoolean("Island.Scoreboard.Enable")) {
|
||||
skyblock.setScoreboardManager(new ScoreboardManager(skyblock));
|
||||
}
|
||||
} else {
|
||||
skyblock.getScoreboardManager().resendScoreboard();
|
||||
}
|
||||
|
||||
if (skyblock.getGeneratorManager() == null) {
|
||||
if (mainConfigLoad.getBoolean("Island.Generator.Enable")) {
|
||||
skyblock.setGeneratorManager(new GeneratorManager(skyblock));
|
||||
}
|
||||
} else {
|
||||
GeneratorManager generatorManager = skyblock.getGeneratorManager();
|
||||
generatorManager.unregisterGenerators();
|
||||
generatorManager.registerGenerators();
|
||||
}
|
||||
|
||||
LevellingManager levellingManager = skyblock.getLevellingManager();
|
||||
levellingManager.unregisterMaterials();
|
||||
levellingManager.registerMaterials();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||
leaderboardManager.clearLeaderboard();
|
||||
leaderboardManager.resetLeaderboard();
|
||||
leaderboardManager.setupLeaderHeads();
|
||||
|
||||
Bukkit.getScheduler().runTask(skyblock, () -> skyblock.getHologramManager().resetHologram());
|
||||
});
|
||||
|
||||
limitManager.reload();
|
||||
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Reload.Reloaded.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_USE.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Admin.Reload.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.hologram.Hologram;
|
||||
import com.songoda.skyblock.hologram.HologramManager;
|
||||
import com.songoda.skyblock.hologram.HologramType;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class RemoveHologramCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
onCommand(player, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
onCommand(sender, args);
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
HologramManager hologramManager = skyblock.getHologramManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
HologramType hologramType = null;
|
||||
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "level":
|
||||
hologramType = HologramType.Level;
|
||||
break;
|
||||
case "bank":
|
||||
hologramType = HologramType.Bank;
|
||||
break;
|
||||
case "votes":
|
||||
hologramType = HologramType.Votes;
|
||||
break;
|
||||
}
|
||||
|
||||
if (hologramType != null) {
|
||||
Config locationsConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml"));
|
||||
FileConfiguration locationsConfigLoad = locationsConfig.getFileConfiguration();
|
||||
|
||||
if (locationsConfigLoad.getString("Location.Hologram.Leaderboard." + hologramType.name()) == null) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.RemoveHologram.Set.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
locationsConfigLoad.set("Location.Hologram.Leaderboard." + hologramType.name(), null);
|
||||
|
||||
try {
|
||||
locationsConfigLoad.save(locationsConfig.getFile());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
|
||||
HologramType hologramType1 = HologramType
|
||||
.valueOf(WordUtils.capitalize(args[0].toLowerCase()));
|
||||
Hologram hologram = hologramManager.getHologram(hologramType1);
|
||||
|
||||
if (hologram != null) {
|
||||
hologramManager.removeHologram(hologram);
|
||||
}
|
||||
});
|
||||
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.RemoveHologram.Removed.Message")
|
||||
.replace("%type", hologramType.name()));
|
||||
soundManager.playSound(sender, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.RemoveHologram.Invalid.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "removehologram";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Admin.RemoveHologram.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[]{"level", "bank", "votes"};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,156 @@
|
|||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.upgrade.Upgrade;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public class RemoveUpgradeCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
onCommand(player, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
onCommand(sender, args);
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 2) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
UUID islandOwnerUUID;
|
||||
String targetPlayerName;
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
|
||||
islandOwnerUUID = targetPlayerOffline.getOwner();
|
||||
targetPlayerName = targetPlayerOffline.getName();
|
||||
} else {
|
||||
islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner();
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
}
|
||||
|
||||
Upgrade.Type upgrade = null;
|
||||
|
||||
for (Upgrade.Type upgradeList : Upgrade.Type.values()) {
|
||||
if (upgradeList != Upgrade.Type.Size) {
|
||||
if (args[1].toUpperCase().equals(upgradeList.name().toUpperCase())) {
|
||||
upgrade = upgradeList;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (islandOwnerUUID == null) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.RemoveUpgrade.Island.Owner.Message"));
|
||||
soundManager.playSound(sender, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (upgrade == null) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.RemoveUpgrade.Upgrade.Exist.Message"));
|
||||
soundManager.playSound(sender, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
if (islandManager.containsIsland(islandOwnerUUID)) {
|
||||
Island island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
|
||||
|
||||
if (!island.hasUpgrade(upgrade)) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.RemoveUpgrade.Upgrade.Missing.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
island.removeUpgrade(upgrade);
|
||||
} else {
|
||||
File islandDataFile = new File(skyblock.getDataFolder().toString() + "/island-data",
|
||||
islandOwnerUUID.toString() + ".yml");
|
||||
|
||||
if (!fileManager.isFileExist(islandDataFile)) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.RemoveUpgrade.Island.Data.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
FileConfiguration islandDataConfigLoad = YamlConfiguration.loadConfiguration(islandDataFile);
|
||||
|
||||
if (islandDataConfigLoad.getString("Upgrade." + upgrade.name()) == null) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.RemoveUpgrade.Upgrade.Missing.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
islandDataConfigLoad.set("Upgrade." + upgrade.name(), null);
|
||||
|
||||
try {
|
||||
islandDataConfigLoad.save(islandDataFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.RemoveUpgrade.Removed.Message")
|
||||
.replace("%player", targetPlayerName).replace("%upgrade", upgrade.name()));
|
||||
soundManager.playSound(sender, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.RemoveUpgrade.Invalid.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "removeupgrade";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Admin.RemoveUpgrade.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -1,27 +1,24 @@
|
|||
package me.goodandevil.skyblock.command.commands.admin;
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import me.goodandevil.skyblock.biome.BiomeManager;
|
||||
import me.goodandevil.skyblock.command.SubCommand;
|
||||
import me.goodandevil.skyblock.config.FileManager;
|
||||
import me.goodandevil.skyblock.config.FileManager.Config;
|
||||
import me.goodandevil.skyblock.island.Island;
|
||||
import me.goodandevil.skyblock.island.IslandManager;
|
||||
import me.goodandevil.skyblock.message.MessageManager;
|
||||
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
|
||||
import me.goodandevil.skyblock.sound.SoundManager;
|
||||
import me.goodandevil.skyblock.utils.NumberUtil;
|
||||
import me.goodandevil.skyblock.utils.player.OfflinePlayer;
|
||||
import me.goodandevil.skyblock.utils.version.SBiome;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
import com.songoda.skyblock.biome.BiomeManager;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import com.songoda.skyblock.utils.version.SBiome;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SetBiomeCommand extends SubCommand {
|
|
@ -0,0 +1,102 @@
|
|||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.hologram.Hologram;
|
||||
import com.songoda.skyblock.hologram.HologramManager;
|
||||
import com.songoda.skyblock.hologram.HologramType;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class SetHologramCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
HologramManager hologramManager = skyblock.getHologramManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
HologramType hologramType = null;
|
||||
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "level":
|
||||
hologramType = HologramType.Level;
|
||||
break;
|
||||
case "bank":
|
||||
hologramType = HologramType.Bank;
|
||||
break;
|
||||
case "votes":
|
||||
hologramType = HologramType.Votes;
|
||||
break;
|
||||
}
|
||||
|
||||
if (hologramType != null) {
|
||||
fileManager.setLocation(
|
||||
fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml")),
|
||||
"Location.Hologram.Leaderboard." + hologramType.name(), player.getLocation(), true);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
|
||||
HologramType hologramType1 = HologramType
|
||||
.valueOf(WordUtils.capitalize(args[0].toLowerCase()));
|
||||
Hologram hologram = hologramManager.getHologram(hologramType1);
|
||||
|
||||
if (hologram != null) {
|
||||
hologramManager.removeHologram(hologram);
|
||||
}
|
||||
|
||||
hologramManager.spawnHologram(hologramType1);
|
||||
});
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Admin.SetHologram.Set.Message").replace("%type",
|
||||
hologramType.name()));
|
||||
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Admin.SetHologram.Invalid.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "sethologram";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Admin.SetHologram.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[]{"level", "bank", "votes"};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,147 @@
|
|||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.NumberUtil;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SetSizeCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
onCommand(player, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
onCommand(sender, args);
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 2) {
|
||||
if (args[1].matches("[0-9]+")) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
UUID islandOwnerUUID;
|
||||
String targetPlayerName;
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
|
||||
islandOwnerUUID = targetPlayerOffline.getOwner();
|
||||
targetPlayerName = targetPlayerOffline.getName();
|
||||
} else {
|
||||
islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner();
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
}
|
||||
|
||||
int size = Integer.valueOf(args[1]);
|
||||
|
||||
if (islandOwnerUUID == null) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.SetSize.Island.Owner.Message"));
|
||||
soundManager.playSound(sender, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (size < 50) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.SetSize.Size.Greater.Message"));
|
||||
soundManager.playSound(sender, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (size > 1000) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.SetSize.Size.Less.Message"));
|
||||
soundManager.playSound(sender, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
if (islandManager.containsIsland(islandOwnerUUID)) {
|
||||
Island island = islandManager
|
||||
.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
|
||||
island.setSize(size);
|
||||
|
||||
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.WorldBorder.Enable")
|
||||
&& island.isBorder()) {
|
||||
islandManager.updateBorder(island);
|
||||
}
|
||||
} else {
|
||||
File islandDataFile = new File(skyblock.getDataFolder().toString() + "/island-data",
|
||||
islandOwnerUUID.toString() + ".yml");
|
||||
|
||||
if (!fileManager.isFileExist(islandDataFile)) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.SetSize.Island.Data.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
FileConfiguration islandDataConfigLoad = YamlConfiguration
|
||||
.loadConfiguration(islandDataFile);
|
||||
islandDataConfigLoad.set("Size", size);
|
||||
|
||||
try {
|
||||
islandDataConfigLoad.save(islandDataFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.SetSize.Set.Message")
|
||||
.replace("%player", targetPlayerName)
|
||||
.replace("%size", NumberUtil.formatNumberByDecimal(size)));
|
||||
soundManager.playSound(sender, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.SetSize.Numerical.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.SetSize.Invalid.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "setsize";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Admin.SetSize.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class SetSpawnCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
fileManager.setLocation(fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml")),
|
||||
"Location.Spawn", player.getLocation(), true);
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.SetSpawn.Set.Message"));
|
||||
soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "setspawn";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Admin.SetSpawn.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.menus.admin.Settings;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SettingsCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
Settings.getInstance().open(player, Settings.Type.Categories, null);
|
||||
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "settings";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Admin.Settings.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[]{"permissions", "perms", "p"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,211 @@
|
|||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerData;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.ChatComponent;
|
||||
import com.songoda.skyblock.utils.structure.StructureUtil;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import com.songoda.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 org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class StructureCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (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 {
|
||||
messageManager.sendMessage(player, helpLines);
|
||||
}
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
if (args[0].equalsIgnoreCase("tool")) {
|
||||
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()))) {
|
||||
messageManager.sendMessage(player, 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);
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Admin.Structure.Tool.Equiped.Message"));
|
||||
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F);
|
||||
} catch (Exception e) {
|
||||
messageManager.sendMessage(player,
|
||||
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.");
|
||||
}
|
||||
|
||||
return;
|
||||
} else if (args[0].equalsIgnoreCase("save")) {
|
||||
if (args.length == 2) {
|
||||
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
Location position1Location = playerData.getArea().getPosition(1);
|
||||
Location position2Location = playerData.getArea().getPosition(2);
|
||||
|
||||
if (position1Location == null && position2Location == null) {
|
||||
messageManager.sendMessage(player,
|
||||
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)) {
|
||||
messageManager.sendMessage(player,
|
||||
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())) {
|
||||
messageManager.sendMessage(player, 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())) {
|
||||
messageManager.sendMessage(player,
|
||||
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)) {
|
||||
messageManager.sendMessage(player,
|
||||
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(
|
||||
skyblock.getDataFolder().toString() + "/structures/" + args[1] + ".structure");
|
||||
StructureUtil.saveStructure(configFile, player.getLocation(),
|
||||
StructureUtil.getFixedLocations(position1Location, position2Location));
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
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) {
|
||||
messageManager.sendMessage(player, configLoad
|
||||
.getString("Command.Island.Admin.Structure.Save.Saved.Failed.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Admin.Structure.Save.Invalid.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Argument.Unrecognised.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "structure";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Admin.Structure.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[]{"tool", "save"};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.menus.admin.Upgrade;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class UpgradeCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (skyblock.getUpgradeManager() == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Upgrade.Disabled.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
playerDataManager.getPlayerData(player)
|
||||
.setViewer(new Upgrade.Viewer(Upgrade.Viewer.Type.Upgrades, null));
|
||||
Upgrade.getInstance().open(player);
|
||||
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "upgrade";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Admin.Upgrade.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,246 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.api.event.player.PlayerIslandJoinEvent;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.invite.Invite;
|
||||
import com.songoda.skyblock.invite.InviteManager;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerData;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.scoreboard.Scoreboard;
|
||||
import com.songoda.skyblock.scoreboard.ScoreboardManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AcceptCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
ScoreboardManager scoreboardManager = skyblock.getScoreboardManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
InviteManager inviteManager = skyblock.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.getIsland(player) == null) {
|
||||
boolean unloadIsland = false;
|
||||
Island island;
|
||||
|
||||
if (islandManager.containsIsland(invite.getOwnerUUID())) {
|
||||
island = islandManager
|
||||
.getIsland(Bukkit.getServer().getOfflinePlayer(invite.getOwnerUUID()));
|
||||
} else {
|
||||
island = islandManager
|
||||
.loadIsland(Bukkit.getServer().getOfflinePlayer(invite.getOwnerUUID()));
|
||||
unloadIsland = true;
|
||||
}
|
||||
|
||||
PlayerIslandJoinEvent islandJoinEvent = new PlayerIslandJoinEvent(player,
|
||||
island.getAPIWrapper());
|
||||
Bukkit.getServer().getPluginManager().callEvent(islandJoinEvent);
|
||||
|
||||
if (islandJoinEvent.isCancelled()) {
|
||||
if (unloadIsland) {
|
||||
islandManager.unloadIsland(island, null);
|
||||
}
|
||||
} else {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(invite.getSenderUUID());
|
||||
|
||||
if (targetPlayer != null) {
|
||||
messageManager.sendMessage(targetPlayer,
|
||||
configLoad.getString("Command.Island.Accept.Accepted.Target.Message")
|
||||
.replace("%player", player.getName()));
|
||||
soundManager.playSound(targetPlayer, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
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(IslandRole.Member, player.getUniqueId());
|
||||
island.save();
|
||||
|
||||
if ((island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size()
|
||||
+ 1) >= fileManager.getConfig(new File(skyblock.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
skyblock.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(IslandRole.Member).size() == 1
|
||||
&& island.getRole(IslandRole.Operator).size() == 0) {
|
||||
Scoreboard scoreboard = scoreboardManager.getScoreboard(all);
|
||||
scoreboard.setDisplayName(
|
||||
ChatColor.translateAlternateColorCodes('&', configLoad
|
||||
.getString("Scoreboard.Island.Team.Displayname")));
|
||||
|
||||
if (islandManager.getVisitorsAtIsland(island).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.setDisplayName(ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Scoreboard.Island.Team.Displayname")));
|
||||
|
||||
if (islandManager.getVisitorsAtIsland(island).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 {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Accept.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Accept.Invited.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Accept.Invite.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Accept.Invalid.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "accept";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Accept.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.ban.Ban;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.island.IslandWorld;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import com.songoda.skyblock.utils.world.LocationUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BanCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Visitor.Banning")) {
|
||||
if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Ban").getStatus())) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
|
||||
if (targetPlayer != null && targetPlayer.hasPermission("fabledskyblock.bypass.ban"))
|
||||
return;
|
||||
|
||||
UUID targetPlayerUUID = null;
|
||||
String targetPlayerName = null;
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
|
||||
targetPlayerUUID = targetPlayerOffline.getUniqueId();
|
||||
targetPlayerName = targetPlayerOffline.getName();
|
||||
|
||||
if (skyblock.getEconomyManager().hasPermission(skyblock.getWorldManager().getWorld(IslandWorld.Normal).getName(), Bukkit.getOfflinePlayer(targetPlayerUUID), "fabledskyblock.bypass.ban"))
|
||||
return;
|
||||
} else {
|
||||
targetPlayerUUID = targetPlayer.getUniqueId();
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
}
|
||||
|
||||
if (targetPlayerUUID == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Found.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (targetPlayerUUID.equals(player.getUniqueId())) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Yourself.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Member, targetPlayerUUID)
|
||||
|| island.hasRole(IslandRole.Operator, targetPlayerUUID)
|
||||
|| island.hasRole(IslandRole.Owner, targetPlayerUUID)) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Member.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.getBan().isBanned(targetPlayerUUID)) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Already.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Ban.Banned.Sender.Message").replace("%player",
|
||||
targetPlayerName));
|
||||
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
if (island.isCoopPlayer(targetPlayerUUID)) {
|
||||
island.removeCoopPlayer(targetPlayerUUID);
|
||||
}
|
||||
|
||||
Ban ban = island.getBan();
|
||||
ban.addBan(player.getUniqueId(), targetPlayerUUID);
|
||||
ban.save();
|
||||
|
||||
if (targetPlayer != null) {
|
||||
if (islandManager.isPlayerAtIsland(island, targetPlayer)) {
|
||||
messageManager.sendMessage(targetPlayer,
|
||||
configLoad.getString("Command.Island.Ban.Banned.Target.Message")
|
||||
.replace("%player", player.getName()));
|
||||
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
LocationUtil.teleportPlayerToSpawn(targetPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Disabled.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Invalid.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "ban";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Ban.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -1,16 +1,16 @@
|
|||
package me.goodandevil.skyblock.command.commands.island;
|
||||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import me.goodandevil.skyblock.command.SubCommand;
|
||||
import me.goodandevil.skyblock.config.FileManager;
|
||||
import me.goodandevil.skyblock.config.FileManager.Config;
|
||||
import me.goodandevil.skyblock.economy.EconomyManager;
|
||||
import me.goodandevil.skyblock.island.Island;
|
||||
import me.goodandevil.skyblock.island.IslandManager;
|
||||
import me.goodandevil.skyblock.island.IslandRole;
|
||||
import me.goodandevil.skyblock.message.MessageManager;
|
||||
import me.goodandevil.skyblock.sound.SoundManager;
|
||||
import me.goodandevil.skyblock.utils.NumberUtil;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.economy.EconomyManager;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.NumberUtil;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
|
@ -0,0 +1,72 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.menus.Bans;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class BansCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Island island = skyblock.getIslandManager().getIsland(player);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bans.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Unban").getStatus())
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
if (island.getBan().getBans().size() == 0) {
|
||||
messageManager.sendMessage(player, 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 {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bans.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "bans";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Bans.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[]{"banned"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.menus.Biome;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class BiomeCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Biome.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Biome").getStatus())
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
Biome.getInstance().open(player);
|
||||
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Biome.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "biome";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Biome.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.menus.Border;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class BorderCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Border.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Border").getStatus())
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.WorldBorder.Enable")) {
|
||||
Border.getInstance().open(player);
|
||||
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Border.Disabled.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Border.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "border";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Border.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[]{"worldborder", "wb"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.invite.Invite;
|
||||
import com.songoda.skyblock.invite.InviteManager;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CancelCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
InviteManager inviteManager = skyblock.getInviteManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Cancel.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Operator, player.getUniqueId())) {
|
||||
String playerName = args[0];
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(playerName);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Cancel.Offline.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Member, targetPlayer.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Operator, targetPlayer.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Owner, targetPlayer.getUniqueId())) {
|
||||
messageManager.sendMessage(player, 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());
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Cancel.Cancelled.Message").replace("%player",
|
||||
targetPlayer.getName()));
|
||||
soundManager.playSound(player, Sounds.EXPLODE.bukkitSound(), 10.0F, 10.0F);
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Cancel.Invited.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Cancel.Invited.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Cancel.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Cancel.Invalid.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "cancel";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Cancel.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.api.event.player.PlayerIslandChatSwitchEvent;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerData;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class ChatCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
if (playerData.isChat() && island != null) {
|
||||
Bukkit.getServer().getPluginManager()
|
||||
.callEvent(new PlayerIslandChatSwitchEvent(player, island.getAPIWrapper(), false));
|
||||
playerData.setChat(false);
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Untoggled.Message"));
|
||||
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size()) == 0) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Team.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((islandManager.getMembersOnline(island).size() - 1) <= 0) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Offline.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
Bukkit.getServer().getPluginManager()
|
||||
.callEvent(new PlayerIslandChatSwitchEvent(player, island.getAPIWrapper(), true));
|
||||
playerData.setChat(true);
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Toggled.Message"));
|
||||
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "chat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Chat.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CloseCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Close.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Visitor").getStatus())) {
|
||||
if (island.isOpen()) {
|
||||
islandManager.closeIsland(island);
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Close.Closed.Message"));
|
||||
soundManager.playSound(player, Sounds.DOOR_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Close.Already.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Close.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "close";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Close.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[]{"lock"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,219 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.confirmation.Confirmation;
|
||||
import com.songoda.skyblock.cooldown.CooldownType;
|
||||
import com.songoda.skyblock.economy.EconomyManager;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerData;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.structure.Structure;
|
||||
import com.songoda.skyblock.structure.StructureManager;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import com.songoda.skyblock.utils.world.LocationUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ConfirmCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
StructureManager structureManager = skyblock.getStructureManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
EconomyManager economyManager = skyblock.getEconomyManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (playerData.getConfirmationTime() > 0) {
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Confirmation.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
Confirmation confirmation = playerData.getConfirmation();
|
||||
|
||||
if (confirmation == Confirmation.Ownership || confirmation == Confirmation.Reset
|
||||
|| confirmation == Confirmation.Deletion) {
|
||||
if (island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
if (confirmation == Confirmation.Ownership) {
|
||||
UUID targetPlayerUUID = playerData.getOwnership();
|
||||
|
||||
if (island.hasRole(IslandRole.Member, targetPlayerUUID)
|
||||
|| island.hasRole(IslandRole.Operator, targetPlayerUUID)) {
|
||||
messageManager.sendMessage(player,
|
||||
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();
|
||||
messageManager.sendMessage(targetPlayer, 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.hasRole(IslandRole.Member, all.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Operator, all.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Owner, all.getUniqueId())
|
||||
|| island.hasRole(IslandRole.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.giveOwnership(island,
|
||||
Bukkit.getServer().getOfflinePlayer(targetPlayerUUID));
|
||||
|
||||
skyblock.getCooldownManager().createPlayer(CooldownType.Ownership,
|
||||
Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()));
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad
|
||||
.getString("Command.Island.Confirmation.Ownership.Member.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else if (confirmation == Confirmation.Reset) {
|
||||
playerData.setConfirmation(null);
|
||||
playerData.setConfirmationTime(0);
|
||||
} else if (confirmation == Confirmation.Deletion) {
|
||||
if (island.isOpen()) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Confirmation.Deletion.Open.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
Location spawnLocation = LocationUtil.getSpawnLocation();
|
||||
|
||||
if (spawnLocation != null
|
||||
&& islandManager.isLocationAtIsland(island, spawnLocation)) {
|
||||
messageManager.sendMessage(player, configLoad
|
||||
.getString("Command.Island.Confirmation.Deletion.Spawn.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (economyManager.isEconomy() && island.getStructure() != null
|
||||
&& !island.getStructure().isEmpty()
|
||||
&& structureManager.containsStructure(island.getStructure())) {
|
||||
Structure structure = structureManager.getStructure(island.getStructure());
|
||||
double deletionCost = structure.getDeletionCost();
|
||||
|
||||
if (deletionCost != 0.0D) {
|
||||
if (economyManager.hasBalance(player, deletionCost)) {
|
||||
economyManager.withdraw(player, deletionCost);
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString(
|
||||
"Command.Island.Confirmation.Deletion.Money.Message")
|
||||
.replace("%cost", "" + deletionCost));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F,
|
||||
1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
playerData.setConfirmation(null);
|
||||
playerData.setConfirmationTime(0);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Confirmation.Confirmed.Message"));
|
||||
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
if (island.hasRole(IslandRole.Member, all.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Operator, all.getUniqueId())) {
|
||||
all.sendMessage(
|
||||
ChatColor.translateAlternateColorCodes('&', configLoad.getString(
|
||||
"Command.Island.Confirmation.Deletion.Broadcast.Message")));
|
||||
soundManager.playSound(all, Sounds.EXPLODE.bukkitSound(), 10.0F, 10.0F);
|
||||
}
|
||||
}
|
||||
|
||||
island.setDeleted(true);
|
||||
islandManager.deleteIsland(island);
|
||||
|
||||
messageManager.sendMessage(player, configLoad
|
||||
.getString("Command.Island.Confirmation.Deletion.Sender.Message"));
|
||||
soundManager.playSound(player, Sounds.EXPLODE.bukkitSound(), 10.0F, 10.0F);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Confirmation.Role.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Confirmation.Specified.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Pending.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "confirm";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Confirmation.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[]{"confirmation"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.menus.ControlPanel;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class ControlPanelCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (skyblock.getIslandManager().getIsland(player) == null) {
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
configLoad.getString("Command.Island.ControlPanel.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
ControlPanel.getInstance().open(player);
|
||||
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "controlpanel";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.ControlPanel.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[]{"cp"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,158 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.menus.Coop;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import com.songoda.skyblock.utils.world.LocationUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CoopCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Coop.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Coop.Enable")) {
|
||||
if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "CoopPlayers").getStatus())) {
|
||||
if (args.length == 1) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
|
||||
UUID targetPlayerUUID = null;
|
||||
String targetPlayerName = null;
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer offlinePlayer = new OfflinePlayer(args[0]);
|
||||
targetPlayerUUID = offlinePlayer.getUniqueId();
|
||||
targetPlayerName = offlinePlayer.getName();
|
||||
|
||||
if (targetPlayerUUID != null && !Bukkit.getOfflinePlayer(targetPlayerUUID).hasPlayedBefore()) {
|
||||
targetPlayerUUID = null;
|
||||
targetPlayerName = null;
|
||||
}
|
||||
} else {
|
||||
targetPlayerUUID = targetPlayer.getUniqueId();
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
}
|
||||
|
||||
if (targetPlayerUUID == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Coop.Found.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (targetPlayerUUID.equals(player.getUniqueId())) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Coop.Yourself.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Member, targetPlayerUUID)
|
||||
|| island.hasRole(IslandRole.Operator, targetPlayerUUID)
|
||||
|| island.hasRole(IslandRole.Owner, targetPlayerUUID)) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Coop.Member.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.getBan().isBanned(targetPlayerUUID)) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Coop.Banned.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.isCoopPlayer(targetPlayerUUID)) {
|
||||
if (targetPlayer != null) {
|
||||
if (islandManager.getVisitorsAtIsland(island).contains(targetPlayerUUID)) {
|
||||
if (!island.isOpen()) {
|
||||
LocationUtil.teleportPlayerToSpawn(targetPlayer);
|
||||
|
||||
messageManager.sendMessage(targetPlayer,
|
||||
configLoad.getString("Command.Island.Coop.Removed.Target.Message"));
|
||||
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F,
|
||||
1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
island.removeCoopPlayer(targetPlayerUUID);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Coop.Removed.Sender.Message").replace("%player",
|
||||
targetPlayerName));
|
||||
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
island.addCoopPlayer(targetPlayerUUID);
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Coop.Added.Message")
|
||||
.replace("%player", targetPlayerName));
|
||||
|
||||
if (targetPlayer != null) {
|
||||
messageManager.sendMessage(targetPlayer, configLoad.getString("Command.Island.Coop.AddedTarget.Message")
|
||||
.replace("%player", player.getName()));
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
return;
|
||||
} else if (args.length != 0) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Coop.Invalid.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Coop.getInstance().open(player);
|
||||
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Coop.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Coop.Disabled.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "coop";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Coop.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.cooldown.Cooldown;
|
||||
import com.songoda.skyblock.cooldown.CooldownManager;
|
||||
import com.songoda.skyblock.cooldown.CooldownPlayer;
|
||||
import com.songoda.skyblock.cooldown.CooldownType;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.menus.Creator;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.structure.Structure;
|
||||
import com.songoda.skyblock.utils.NumberUtil;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class CreateCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
CooldownManager cooldownManager = skyblock.getCooldownManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (islandManager.getIsland(player) == null) {
|
||||
Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
|
||||
if (mainConfig.getFileConfiguration().getBoolean("Island.Creation.Menu.Enable")) {
|
||||
Creator.getInstance().open(player);
|
||||
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
List<Structure> structures = skyblock.getStructureManager().getStructures();
|
||||
|
||||
if (structures.size() == 0) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Creator.Selector.None.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
} else if (!fileManager
|
||||
.isFileExist(new File(new File(skyblock.getDataFolder().toString() + "/structures"),
|
||||
structures.get(0).getOverworldFile()))) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Island.Creator.Selector.File.Overworld.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
} else if (!fileManager
|
||||
.isFileExist(new File(new File(skyblock.getDataFolder().toString() + "/structures"),
|
||||
structures.get(0).getNetherFile()))) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Island.Creator.Selector.File.Nether.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
} else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Creation.Cooldown.Creation.Enable")
|
||||
&& cooldownManager.hasPlayer(CooldownType.Creation, player)) {
|
||||
CooldownPlayer cooldownPlayer = cooldownManager.getCooldownPlayer(CooldownType.Creation, player);
|
||||
Cooldown cooldown = cooldownPlayer.getCooldown();
|
||||
|
||||
if (cooldown.getTime() < 60) {
|
||||
messageManager.sendMessage(player,
|
||||
config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Message")
|
||||
.replace("%time", cooldown.getTime() + " " + config.getFileConfiguration()
|
||||
.getString("Island.Creator.Selector.Cooldown.Word.Second")));
|
||||
} else {
|
||||
long[] durationTime = NumberUtil.getDuration(cooldown.getTime());
|
||||
messageManager.sendMessage(player,
|
||||
config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Message")
|
||||
.replace("%time", durationTime[2] + " "
|
||||
+ config.getFileConfiguration()
|
||||
.getString("Island.Creator.Selector.Cooldown.Word.Minute")
|
||||
+ " " + durationTime[3] + " " + config.getFileConfiguration()
|
||||
.getString("Island.Creator.Selector.Cooldown.Word.Second")));
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (islandManager.createIsland(player, structures.get(0))) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Creator.Selector.Created.Message"));
|
||||
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Create.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "create";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Create.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[]{"new"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerData;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CurrentCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length > 0) {
|
||||
if (!args[0].equalsIgnoreCase(player.getName())) {
|
||||
if (args.length == 1) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
messageManager.sendMessage(player,
|
||||
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) {
|
||||
messageManager.sendMessage(player,
|
||||
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();
|
||||
}
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
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) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Current.Invalid.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
if (playerData.getIsland() == null) {
|
||||
messageManager.sendMessage(player,
|
||||
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();
|
||||
}
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
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 void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "current";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Current.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[]{"cur"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.confirmation.Confirmation;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerData;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.ChatComponent;
|
||||
import com.songoda.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;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.chat.ComponentSerializer;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class DeleteCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Delete.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
if (playerData.getConfirmationTime() > 0) {
|
||||
messageManager.sendMessage(player,
|
||||
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(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getInt("Island.Confirmation.Timeout");
|
||||
|
||||
playerData.setConfirmation(Confirmation.Deletion);
|
||||
playerData.setConfirmationTime(confirmationTime);
|
||||
|
||||
String confirmationMessage = configLoad.getString("Command.Island.Delete.Confirmation.Confirm.Message")
|
||||
.replace("%time", "" + confirmationTime);
|
||||
|
||||
if (confirmationMessage.contains("%confirm")) {
|
||||
String[] confirmationMessages = confirmationMessage.split("%confirm");
|
||||
|
||||
if (confirmationMessages.length == 0) {
|
||||
player.spigot().sendMessage(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())).getTextComponent());
|
||||
} else {
|
||||
ChatComponent chatComponent = new ChatComponent("", false, null, null, null);
|
||||
|
||||
for (int i = 0; i < confirmationMessages.length; i++) {
|
||||
String message = confirmationMessages[i];
|
||||
|
||||
if (message.contains("\n") || message.contains("\\n")) {
|
||||
message = message.replace("\\n", "\n");
|
||||
|
||||
for (String messageList : message.split("\n")) {
|
||||
chatComponent
|
||||
.addExtraChatComponent(
|
||||
new ChatComponent(
|
||||
messageManager.replaceMessage(player,
|
||||
messageList.replace("%time",
|
||||
"" + confirmationTime)),
|
||||
false, null, null, null));
|
||||
|
||||
chatComponent
|
||||
.addExtra(new TextComponent(ComponentSerializer.parse("{text: \"\n\"}")));
|
||||
}
|
||||
} else {
|
||||
chatComponent.addExtraChatComponent(new ChatComponent(
|
||||
messageManager.replaceMessage(player,
|
||||
message.replace("%time", "" + confirmationTime)),
|
||||
false, null, null, null));
|
||||
}
|
||||
|
||||
if (confirmationMessages.length == 1 || i + 1 != confirmationMessages.length) {
|
||||
chatComponent.addExtraChatComponent(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())));
|
||||
}
|
||||
}
|
||||
|
||||
player.spigot().sendMessage(chatComponent.getTextComponent());
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, confirmationMessage.replace("%time", "" + confirmationTime));
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Delete.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "delete";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Delete.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[]{"remove", "disband", "reset", "restart"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DemoteCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Demote.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer offlinePlayer = new OfflinePlayer(args[0]);
|
||||
Set<UUID> islandMembers = island.getRole(IslandRole.Member);
|
||||
|
||||
if (offlinePlayer.getUniqueId() != null && (islandMembers.contains(offlinePlayer.getUniqueId())
|
||||
|| island.getRole(IslandRole.Operator).contains(offlinePlayer.getUniqueId()))) {
|
||||
if (islandMembers.contains(offlinePlayer.getUniqueId())) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Demote.Role.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Demote.Demoted.Sender.Message")
|
||||
.replace("%player", offlinePlayer.getName()));
|
||||
|
||||
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
island.removeRole(IslandRole.Operator, offlinePlayer.getUniqueId());
|
||||
island.setRole(IslandRole.Member, offlinePlayer.getUniqueId());
|
||||
island.save();
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Demote.Member.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
if (island.hasRole(IslandRole.Member, targetPlayer.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Operator, targetPlayer.getUniqueId())) {
|
||||
if (island.hasRole(IslandRole.Member, targetPlayer.getUniqueId())) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Demote.Role.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Demote.Demoted.Sender.Message")
|
||||
.replace("%player", targetPlayer.getName()));
|
||||
messageManager.sendMessage(targetPlayer,
|
||||
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(IslandRole.Operator, targetPlayer.getUniqueId());
|
||||
island.setRole(IslandRole.Member, targetPlayer.getUniqueId());
|
||||
island.save();
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Promote.Member.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Demote.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Demote.Invalid.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "demote";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Demote.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.invite.Invite;
|
||||
import com.songoda.skyblock.invite.InviteManager;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class DenyCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
InviteManager inviteManager = skyblock.getInviteManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
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) {
|
||||
messageManager.sendMessage(targetPlayer,
|
||||
configLoad.getString("Command.Island.Deny.Denied.Target.Message").replace("%player",
|
||||
player.getName()));
|
||||
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 5.0F, 5.0F);
|
||||
}
|
||||
|
||||
messageManager.sendMessage(player, 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 {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Deny.Invited.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Deny.Invited.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Deny.Invalid.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "deny";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Deny.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.menus.Information;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerData;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public class InformationCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
UUID islandOwnerUUID = null;
|
||||
|
||||
if (args.length == 1) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer targetOfflinePlayer = new OfflinePlayer(args[0]);
|
||||
islandOwnerUUID = targetOfflinePlayer.getOwner();
|
||||
} else {
|
||||
islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner();
|
||||
}
|
||||
|
||||
if (islandOwnerUUID == null) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Information.Island.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (args.length != 0) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Information.Invalid.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
if (islandOwnerUUID == null) {
|
||||
if (islandManager.getIsland(player) == null) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Information.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
} else {
|
||||
islandOwnerUUID = playerData.getOwner();
|
||||
}
|
||||
}
|
||||
|
||||
playerData.setViewer(new Information.Viewer(islandOwnerUUID, Information.Viewer.Type.Categories));
|
||||
Information.getInstance().open(player);
|
||||
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "information";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Information.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[]{"info"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,262 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.api.event.island.IslandInviteEvent;
|
||||
import com.songoda.skyblock.api.invite.IslandInvitation;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.invite.Invite;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.ChatComponent;
|
||||
import com.songoda.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;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.chat.ComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class InviteCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Invite.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Invite").getStatus())) {
|
||||
Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
|
||||
if ((island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size()
|
||||
+ 1) >= mainConfig.getFileConfiguration().getInt("Island.Member.Capacity")) {
|
||||
messageManager.sendMessage(player, 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())) {
|
||||
messageManager.sendMessage(player,
|
||||
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) {
|
||||
messageManager.sendMessage(player,
|
||||
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())) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Invite.Yourself.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Member, targetPlayer.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Operator, targetPlayer.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Owner, targetPlayer.getUniqueId())) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Invite.Member.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (skyblock.getInviteManager().hasInvite(targetPlayer.getUniqueId())) {
|
||||
Invite invite = skyblock.getInviteManager().getInvite(targetPlayer.getUniqueId());
|
||||
|
||||
if (invite.getOwnerUUID().equals(island.getOwnerUUID())) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Invite.Already.Own.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
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");
|
||||
|
||||
String cancellationMessage = configLoad
|
||||
.getString("Command.Island.Invite.Invited.Sender.Sent.Message");
|
||||
String timeMessage;
|
||||
|
||||
if (respondTime < 60) {
|
||||
timeMessage = respondTime + " "
|
||||
+ configLoad.getString("Command.Island.Invite.Invited.Word.Second");
|
||||
} else {
|
||||
timeMessage = respondTime / 60 + " "
|
||||
+ configLoad.getString("Command.Island.Invite.Invited.Word.Minute");
|
||||
}
|
||||
|
||||
// TODO: Use this same logic wherever a clickable placeholder has to be replaced at
|
||||
String placeholderName = "%cancel";
|
||||
if (cancellationMessage.contains(placeholderName)) {
|
||||
if (cancellationMessage.equals(placeholderName)) {
|
||||
player.spigot().sendMessage(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())).getTextComponent());
|
||||
} else {
|
||||
ChatComponent chatComponent = new ChatComponent("", false, null, null, null);
|
||||
|
||||
String[] messagePieces = cancellationMessage.replace("\\n", "\n").split("\n");
|
||||
for (int i = 0; i < messagePieces.length; i++) {
|
||||
String piece = messagePieces[i].replace("%player", targetPlayer.getName()).replace("%time", timeMessage);
|
||||
|
||||
if (piece.contains(placeholderName)) {
|
||||
String before = piece.substring(0, piece.indexOf(placeholderName));
|
||||
String after = piece.substring(piece.indexOf(placeholderName) + placeholderName.length());
|
||||
|
||||
chatComponent.addExtraChatComponent(new ChatComponent(before, false, null, null, null));
|
||||
|
||||
chatComponent.addExtraChatComponent(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())));
|
||||
|
||||
chatComponent.addExtraChatComponent(new ChatComponent(after, false, null, null, null));
|
||||
} else {
|
||||
chatComponent.addExtraChatComponent(new ChatComponent(piece, false, null, null, null));
|
||||
}
|
||||
|
||||
if (i != messagePieces.length - 1)
|
||||
chatComponent.addExtra(new TextComponent(ComponentSerializer.parse("{text: \"\n\"}")));
|
||||
}
|
||||
|
||||
player.spigot().sendMessage(chatComponent.getTextComponent());
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, cancellationMessage
|
||||
.replace("%player", targetPlayer.getName()).replace("%time", timeMessage));
|
||||
}
|
||||
|
||||
String invitationMessage = configLoad
|
||||
.getString("Command.Island.Invite.Invited.Target.Received.Message");
|
||||
ChatComponent chatComponent = new ChatComponent("", false, null, null, null);
|
||||
|
||||
if (invitationMessage.contains("\n") || invitationMessage.contains("\\n")) {
|
||||
invitationMessage = invitationMessage.replace("\\n", "\n");
|
||||
|
||||
for (String messageList : invitationMessage.split("\n")) {
|
||||
chatComponent
|
||||
.addExtra(new ChatComponent(
|
||||
messageManager.replaceMessage(player,
|
||||
messageList.replace("%player", player.getName())
|
||||
.replace("%time", timeMessage)),
|
||||
false, null, null, null));
|
||||
|
||||
chatComponent
|
||||
.addExtra(new TextComponent(ComponentSerializer.parse("{text: \"\n\"}")));
|
||||
}
|
||||
} else {
|
||||
chatComponent
|
||||
.addExtra(new ChatComponent(
|
||||
messageManager.replaceMessage(player,
|
||||
invitationMessage.replace("%player", player.getName())
|
||||
.replace("%time", timeMessage)),
|
||||
false, null, null, null));
|
||||
}
|
||||
|
||||
chatComponent.addExtra(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())));
|
||||
|
||||
chatComponent.addExtra(new ChatComponent(" | ", false, ChatColor.DARK_GRAY, null, null));
|
||||
|
||||
chatComponent.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())));
|
||||
|
||||
targetPlayer.spigot().sendMessage(chatComponent.getTextComponent());
|
||||
|
||||
Invite invite = skyblock.getInviteManager().createInvite(targetPlayer, player,
|
||||
island.getOwnerUUID(), respondTime);
|
||||
|
||||
Bukkit.getServer().getPluginManager()
|
||||
.callEvent(new IslandInviteEvent(island.getAPIWrapper(),
|
||||
new IslandInvitation(targetPlayer, player, invite.getTime())));
|
||||
|
||||
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
|
||||
soundManager.playSound(targetPlayer, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Invite.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Invite.Invalid.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "invite";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Invite.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.api.event.island.IslandKickEvent;
|
||||
import com.songoda.skyblock.api.utils.APIUtil;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import com.songoda.skyblock.utils.world.LocationUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class KickAllCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.KickAll.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Kick").getStatus())) {
|
||||
if (island.isOpen()) {
|
||||
Set<UUID> islandVisitors = islandManager.getVisitorsAtIsland(island);
|
||||
|
||||
if (islandVisitors.size() == 0) {
|
||||
messageManager.sendMessage(player, 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);
|
||||
|
||||
if (targetPlayer != null && targetPlayer.hasPermission("fabledskyblock.bypass.ban"))
|
||||
continue;
|
||||
|
||||
IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(),
|
||||
APIUtil.fromImplementation(IslandRole.Visitor),
|
||||
Bukkit.getServer().getOfflinePlayer(islandVisitorList), player);
|
||||
Bukkit.getServer().getPluginManager().callEvent(islandKickEvent);
|
||||
|
||||
if (!islandKickEvent.isCancelled()) {
|
||||
LocationUtil.teleportPlayerToSpawn(targetPlayer);
|
||||
|
||||
messageManager.sendMessage(targetPlayer,
|
||||
configLoad.getString("Command.Island.KickAll.Kicked.Target.Message")
|
||||
.replace("%player", player.getName()));
|
||||
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.KickAll.Kicked.Sender.Message").replace("%visitors",
|
||||
"" + islandVisitors.size()));
|
||||
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.KickAll.Closed.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.KickAll.Role.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "expel";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.KickAll.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,285 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.api.event.island.IslandKickEvent;
|
||||
import com.songoda.skyblock.api.utils.APIUtil;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.island.IslandWorld;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerData;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.scoreboard.Scoreboard;
|
||||
import com.songoda.skyblock.scoreboard.ScoreboardManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import com.songoda.skyblock.utils.world.LocationUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class KickCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
ScoreboardManager scoreboardManager = skyblock.getScoreboardManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
Config languageConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
|
||||
if (args.length == 1) {
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player,
|
||||
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Kick").getStatus())) {
|
||||
UUID targetPlayerUUID = null;
|
||||
String targetPlayerName = null;
|
||||
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
|
||||
if (targetPlayer != null && targetPlayer.hasPermission("fabledskyblock.bypass.ban"))
|
||||
return;
|
||||
|
||||
Set<UUID> islandMembers = island.getRole(IslandRole.Member),
|
||||
islandOperators = island.getRole(IslandRole.Operator),
|
||||
islandVisitors = islandManager.getVisitorsAtIsland(island);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
|
||||
targetPlayerUUID = targetPlayerOffline.getUniqueId();
|
||||
targetPlayerName = targetPlayerOffline.getName();
|
||||
|
||||
if (skyblock.getEconomyManager().hasPermission(skyblock.getWorldManager().getWorld(IslandWorld.Normal).getName(), Bukkit.getOfflinePlayer(targetPlayerUUID), "fabledskyblock.bypass.ban"))
|
||||
return;
|
||||
} else {
|
||||
targetPlayerUUID = targetPlayer.getUniqueId();
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
}
|
||||
|
||||
if (targetPlayerUUID.equals(player.getUniqueId())) {
|
||||
messageManager.sendMessage(player,
|
||||
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)) {
|
||||
messageManager.sendMessage(player, 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)) {
|
||||
messageManager.sendMessage(player,
|
||||
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Role.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.isOpen() && islandVisitors.contains(targetPlayerUUID) && targetPlayer != null) {
|
||||
if (island.isCoopPlayer(targetPlayerUUID)) {
|
||||
messageManager.sendMessage(player,
|
||||
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Cooped.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(),
|
||||
APIUtil.fromImplementation(IslandRole.Visitor),
|
||||
Bukkit.getServer().getOfflinePlayer(targetPlayerUUID), player);
|
||||
|
||||
Bukkit.getScheduler().runTask(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(islandKickEvent));
|
||||
|
||||
if (!islandKickEvent.isCancelled()) {
|
||||
LocationUtil.teleportPlayerToSpawn(targetPlayer);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
languageConfig.getFileConfiguration()
|
||||
.getString("Command.Island.Kick.Kicked.Sender.Message")
|
||||
.replace("%player", targetPlayerName));
|
||||
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
messageManager.sendMessage(targetPlayer,
|
||||
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)) {
|
||||
IslandRole islandRole = IslandRole.Member;
|
||||
|
||||
if (islandOperators.contains(targetPlayerUUID)) {
|
||||
islandRole = IslandRole.Operator;
|
||||
}
|
||||
|
||||
IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(),
|
||||
APIUtil.fromImplementation(islandRole),
|
||||
Bukkit.getServer().getOfflinePlayer(targetPlayerUUID), player);
|
||||
|
||||
Bukkit.getScheduler().runTask(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(islandKickEvent));
|
||||
|
||||
if (!islandKickEvent.isCancelled()) {
|
||||
messageManager.sendMessage(player,
|
||||
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(skyblock.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 {
|
||||
messageManager.sendMessage(targetPlayer,
|
||||
languageConfig.getFileConfiguration()
|
||||
.getString("Command.Island.Kick.Kicked.Target.Message")
|
||||
.replace("%player", player.getName()));
|
||||
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
if (islandManager.isPlayerAtIsland(island, targetPlayer)) {
|
||||
LocationUtil.teleportPlayerToSpawn(targetPlayer);
|
||||
}
|
||||
|
||||
if (scoreboardManager != null) {
|
||||
Scoreboard scoreboard = scoreboardManager.getScoreboard(targetPlayer);
|
||||
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(IslandRole.Member, targetPlayerUUID);
|
||||
} else if (islandOperators.contains(targetPlayerUUID)) {
|
||||
island.removeRole(IslandRole.Operator, targetPlayerUUID);
|
||||
}
|
||||
|
||||
island.save();
|
||||
|
||||
Set<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);
|
||||
messageManager.sendMessage(targetPlayer, fileManager
|
||||
.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Chat.Untoggled.Message"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (scoreboardManager != null) {
|
||||
if (island.getRole(IslandRole.Member).size() == 0
|
||||
&& island.getRole(IslandRole.Operator).size() == 0) {
|
||||
Scoreboard scoreboard = scoreboardManager.getScoreboard(player);
|
||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', languageConfig
|
||||
.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname")));
|
||||
|
||||
if (islandManager.getVisitorsAtIsland(island).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 (island.isOpen()) {
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration()
|
||||
.getString("Command.Island.Kick.Occupant.Visit.Open.Message"));
|
||||
} else {
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration()
|
||||
.getString("Command.Island.Kick.Occupant.Visit.Closed.Message"));
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
if (island.isOpen()) {
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration()
|
||||
.getString("Command.Island.Kick.Permission.Visit.Open.Message"));
|
||||
} else {
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration()
|
||||
.getString("Command.Island.Kick.Permission.Visit.Closed.Message"));
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Invalid.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "kick";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Kick.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.menus.Leaderboard;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class LeaderboardCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
if (args.length == 0) {
|
||||
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Visitor.Vote")) {
|
||||
playerDataManager.getPlayerData(player)
|
||||
.setViewer(new Leaderboard.Viewer(Leaderboard.Viewer.Type.Browse));
|
||||
} else {
|
||||
playerDataManager.getPlayerData(player)
|
||||
.setViewer(new Leaderboard.Viewer(Leaderboard.Viewer.Type.Level));
|
||||
}
|
||||
} else if (args.length == 1) {
|
||||
String type = args[0].toLowerCase();
|
||||
switch (type) {
|
||||
case "level":
|
||||
playerDataManager.getPlayerData(player).setViewer(new Leaderboard.Viewer(Leaderboard.Viewer.Type.Level));
|
||||
break;
|
||||
case "bank":
|
||||
playerDataManager.getPlayerData(player).setViewer(new Leaderboard.Viewer(Leaderboard.Viewer.Type.Bank));
|
||||
break;
|
||||
case "votes":
|
||||
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
|
||||
playerDataManager.getPlayerData(player).setViewer(new Leaderboard.Viewer(Leaderboard.Viewer.Type.Votes));
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Leaderboard.Disabled.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Leaderboard.Invalid.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Leaderboard.Invalid.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Leaderboard.getInstance().open(player);
|
||||
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "leaderboard";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Leaderboard.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[]{"lb", "top"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[]{"level", "bank", "votes"};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,167 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.api.event.player.PlayerIslandLeaveEvent;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerData;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.scoreboard.Scoreboard;
|
||||
import com.songoda.skyblock.scoreboard.ScoreboardManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import com.songoda.skyblock.utils.world.LocationUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class LeaveCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
ScoreboardManager scoreboardManager = skyblock.getScoreboardManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
Config languageConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player,
|
||||
languageConfig.getFileConfiguration().getString("Command.Island.Leave.Member.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
messageManager.sendMessage(player,
|
||||
languageConfig.getFileConfiguration().getString("Command.Island.Leave.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
PlayerIslandLeaveEvent islandLeaveEvent = new PlayerIslandLeaveEvent(player, island.getAPIWrapper());
|
||||
Bukkit.getServer().getPluginManager().callEvent(islandLeaveEvent);
|
||||
|
||||
if (!islandLeaveEvent.isCancelled()) {
|
||||
if (islandManager.isPlayerAtIsland(island, player)) {
|
||||
LocationUtil.teleportPlayerToSpawn(player);
|
||||
}
|
||||
|
||||
if (island.hasRole(IslandRole.Member, player.getUniqueId())) {
|
||||
island.removeRole(IslandRole.Member, player.getUniqueId());
|
||||
} else if (island.hasRole(IslandRole.Operator, player.getUniqueId())) {
|
||||
island.removeRole(IslandRole.Operator, player.getUniqueId());
|
||||
}
|
||||
|
||||
island.save();
|
||||
|
||||
playerData.setPlaytime(0);
|
||||
playerData.setOwner(null);
|
||||
playerData.setMemberSince(null);
|
||||
playerData.setChat(false);
|
||||
playerData.save();
|
||||
|
||||
Set<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);
|
||||
messageManager.sendMessage(targetPlayer,
|
||||
fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Chat.Untoggled.Message"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Check if player has been teleported
|
||||
islandManager.unloadIsland(island, null);
|
||||
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
if (!all.getUniqueId().equals(player.getUniqueId())) {
|
||||
if (island.hasRole(IslandRole.Member, all.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Operator, all.getUniqueId())
|
||||
|| island.hasRole(IslandRole.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 (island.getRole(IslandRole.Member).size() == 0
|
||||
&& island.getRole(IslandRole.Operator).size() == 0) {
|
||||
if (scoreboardManager != null) {
|
||||
if (islandManager.getVisitorsAtIsland(island).size() != 0) {
|
||||
Scoreboard scoreboard = scoreboardManager.getScoreboard(all);
|
||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&',
|
||||
languageConfig.getFileConfiguration()
|
||||
.getString("Scoreboard.Island.Solo.Displayname")));
|
||||
scoreboard.setDisplayList(languageConfig.getFileConfiguration()
|
||||
.getStringList("Scoreboard.Island.Solo.Occupied.Displaylines"));
|
||||
scoreboard.run();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
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.setDisplayName(ChatColor.translateAlternateColorCodes('&',
|
||||
languageConfig.getFileConfiguration().getString("Scoreboard.Tutorial.Displayname")));
|
||||
scoreboard.setDisplayList(
|
||||
languageConfig.getFileConfiguration().getStringList("Scoreboard.Tutorial.Displaylines"));
|
||||
scoreboard.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "leave";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Leave.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,174 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.cooldown.Cooldown;
|
||||
import com.songoda.skyblock.cooldown.CooldownManager;
|
||||
import com.songoda.skyblock.cooldown.CooldownPlayer;
|
||||
import com.songoda.skyblock.cooldown.CooldownType;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.levelling.LevellingManager;
|
||||
import com.songoda.skyblock.menus.Levelling;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.NumberUtil;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import com.songoda.skyblock.visit.Visit;
|
||||
import com.songoda.skyblock.visit.VisitManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public class LevelCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
LevellingManager levellingManager = skyblock.getLevellingManager();
|
||||
CooldownManager cooldownManager = skyblock.getCooldownManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
VisitManager visitManager = skyblock.getVisitManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
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) {
|
||||
messageManager.sendMessage(player,
|
||||
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)) {
|
||||
Visit visit = visitManager.getIsland(islandOwnerUUID);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Level.Level.Message")
|
||||
.replace("%player", targetPlayerName).replace("%level",
|
||||
"" + NumberUtil.formatNumberByDecimal(visit.getLevel().getLevel())));
|
||||
soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Level.Owner.Other.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (args.length != 0) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Invalid.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Owner.Yourself.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
player.closeInventory();
|
||||
|
||||
if (!island.getLevel().hasMaterials()) {
|
||||
org.bukkit.OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID());
|
||||
|
||||
if (cooldownManager.hasPlayer(CooldownType.Levelling, offlinePlayer)) {
|
||||
CooldownPlayer cooldownPlayer = cooldownManager.getCooldownPlayer(CooldownType.Levelling,
|
||||
offlinePlayer);
|
||||
Cooldown cooldown = cooldownPlayer.getCooldown();
|
||||
|
||||
long[] durationTime = NumberUtil.getDuration(cooldown.getTime());
|
||||
|
||||
if (cooldown.getTime() >= 3600) {
|
||||
messageManager.sendMessage(player,
|
||||
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 (cooldown.getTime() >= 60) {
|
||||
messageManager.sendMessage(player,
|
||||
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 {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Level.Cooldown.Message").replace("%time",
|
||||
cooldown.getTime() + " "
|
||||
+ configLoad.getString("Command.Island.Level.Cooldown.Word.Second")));
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Processing.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
cooldownManager.createPlayer(CooldownType.Levelling,
|
||||
Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()));
|
||||
levellingManager.calculatePoints(player, island);
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Loading.Message"));
|
||||
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
|
||||
Levelling.getInstance().open(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "level";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Level.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[]{"levelling", "points"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.menus.Members;
|
||||
import com.songoda.skyblock.playerdata.PlayerData;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class MembersCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
if (skyblock.getIslandManager().getIsland(player) == null) {
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Command.Island.Settings.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
PlayerData playerData = skyblock.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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "members";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Members.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class OpenCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Open.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Visitor").getStatus())) {
|
||||
if (island.isOpen()) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Open.Already.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
island.setOpen(true);
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Open.Opened.Message"));
|
||||
soundManager.playSound(player, Sounds.DOOR_OPEN.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Open.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "open";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Open.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user