mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-01-24 00:11:37 +01:00
Merge branch 'master' into 'development'
Development branch See merge request Songoda/fabledskyblock!83
This commit is contained in:
commit
3231e6d52c
68
pom.xml
68
pom.xml
@ -5,8 +5,12 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>skyblock</artifactId>
|
||||
<version>2.3</version>
|
||||
<version>2.3.7</version>
|
||||
<packaging>jar</packaging>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
</properties>
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>FabledSkyblock-${project.version}</finalName>
|
||||
@ -41,13 +45,12 @@
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
@ -60,12 +63,15 @@
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.songoda:SongodaCore</include>
|
||||
<include>io.papermc:paperlib</include>
|
||||
<include>com.eatthepath:fast-uuid</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<filters>
|
||||
@ -83,6 +89,14 @@
|
||||
<pattern>com.songoda.core</pattern>
|
||||
<shadedPattern>${project.groupId}.skyblock.core</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>io.papermc.lib</pattern>
|
||||
<shadedPattern>${project.groupId}.paperlib</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.eatthepath.uuid</pattern>
|
||||
<shadedPattern>${project.groupId}.fast-uuid</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
@ -100,6 +114,10 @@
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>minecraft-repo</id>
|
||||
<url>https://libraries.minecraft.net/</url>
|
||||
@ -126,10 +144,28 @@
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
<version>1.0.4</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.destroystokyo.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.15</version>
|
||||
<version>1.16.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -183,6 +219,12 @@
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldedit-bukkit</artifactId>
|
||||
<version>7.1.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
@ -190,5 +232,23 @@
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.Zrips</groupId>
|
||||
<artifactId>Residence</artifactId>
|
||||
<scope>provided</scope>
|
||||
<version>4.9.0.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net</groupId>
|
||||
<artifactId>coreprotect</artifactId>
|
||||
<scope>provided</scope>
|
||||
<version>2.18.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.eatthepath</groupId>
|
||||
<artifactId>fast-uuid</artifactId>
|
||||
<version>0.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -3,9 +3,10 @@ package com.songoda.skyblock;
|
||||
import com.songoda.core.SongodaCore;
|
||||
import com.songoda.core.SongodaPlugin;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerProject;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.configuration.Config;
|
||||
import com.songoda.core.gui.GuiManager;
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.songoda.skyblock.api.SkyBlockAPI;
|
||||
import com.songoda.skyblock.ban.BanManager;
|
||||
import com.songoda.skyblock.bank.BankManager;
|
||||
@ -16,22 +17,21 @@ 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.permission.PermissionManager;
|
||||
import com.songoda.skyblock.tasks.HologramTask;
|
||||
import com.songoda.skyblock.invite.InviteManager;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.reward.RewardManager;
|
||||
import com.songoda.skyblock.leaderboard.LeaderboardManager;
|
||||
import com.songoda.skyblock.levelling.rework.IslandLevelManager;
|
||||
import com.songoda.skyblock.levelling.IslandLevelManager;
|
||||
import com.songoda.skyblock.limit.LimitationInstanceHandler;
|
||||
import com.songoda.skyblock.listeners.*;
|
||||
import com.songoda.skyblock.localization.LocalizationManager;
|
||||
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.permission.PermissionManager;
|
||||
import com.songoda.skyblock.placeholder.PlaceholderManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.playtime.PlaytimeTask;
|
||||
@ -39,6 +39,7 @@ 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.tasks.HologramTask;
|
||||
import com.songoda.skyblock.tasks.MobNetherWaterTask;
|
||||
import com.songoda.skyblock.upgrade.UpgradeManager;
|
||||
import com.songoda.skyblock.usercache.UserCacheManager;
|
||||
@ -46,10 +47,14 @@ 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 net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.CoreProtectAPI;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.io.File;
|
||||
@ -72,6 +77,7 @@ public class SkyBlock extends SongodaPlugin {
|
||||
private InviteManager inviteManager;
|
||||
private BiomeManager biomeManager;
|
||||
private IslandLevelManager levellingManager;
|
||||
private com.songoda.skyblock.economy.EconomyManager economyManager;
|
||||
private CommandManager commandManager;
|
||||
private StructureManager structureManager;
|
||||
private StackableManager stackableManager;
|
||||
@ -89,6 +95,12 @@ public class SkyBlock extends SongodaPlugin {
|
||||
private BankManager bankManager;
|
||||
private PermissionManager permissionManager;
|
||||
|
||||
private CoreProtectAPI coreProtectAPI;
|
||||
private Permission vaultPermission;
|
||||
|
||||
private boolean paper;
|
||||
private boolean paperAsync;
|
||||
|
||||
private final GuiManager guiManager = new GuiManager(this);
|
||||
|
||||
public static SkyBlock getInstance() {
|
||||
@ -102,11 +114,30 @@ public class SkyBlock extends SongodaPlugin {
|
||||
|
||||
@Override
|
||||
public void onPluginEnable() {
|
||||
if(ServerVersion.isServerVersionAbove(ServerVersion.V1_16) || ServerVersion.isServerVersionBelow(ServerVersion.V1_8)) {
|
||||
this.getLogger().warning("This Minecraft version is not officially supported.");
|
||||
}
|
||||
|
||||
if(paper = ServerProject.isServer(ServerProject.PAPER)){
|
||||
try {
|
||||
Bukkit.spigot().getClass().getMethod("getPaperConfig");
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) {
|
||||
paperAsync = true;
|
||||
} else {
|
||||
paperAsync = ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) &&
|
||||
Bukkit.spigot().getPaperConfig().getBoolean("settings.async-chunks.enable", false);
|
||||
}
|
||||
} catch (NoSuchMethodException ignored) {
|
||||
paperAsync = false;
|
||||
}
|
||||
this.getLogger().info("Enabling Paper hooks");
|
||||
}
|
||||
|
||||
// Run Songoda Updater
|
||||
SongodaCore.registerPlugin(this, 17, CompatibleMaterial.GRASS_BLOCK);
|
||||
|
||||
// Load Economy
|
||||
EconomyManager.load();
|
||||
economyManager = new EconomyManager(this);
|
||||
|
||||
// Load Holograms
|
||||
com.songoda.core.hooks.HologramManager.load(this);
|
||||
@ -124,14 +155,10 @@ public class SkyBlock extends SongodaPlugin {
|
||||
cooldownManager = new CooldownManager(this);
|
||||
limitationHandler = new LimitationInstanceHandler();
|
||||
fabledChallenge = new FabledChallenge(this);
|
||||
|
||||
if (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Scoreboard.Enable")) {
|
||||
scoreboardManager = new ScoreboardManager(this);
|
||||
}
|
||||
|
||||
scoreboardManager = new ScoreboardManager(this);
|
||||
inviteManager = new InviteManager(this);
|
||||
biomeManager = new BiomeManager(this);
|
||||
levellingManager = new IslandLevelManager();
|
||||
levellingManager = new IslandLevelManager(this);
|
||||
commandManager = new CommandManager(this);
|
||||
structureManager = new StructureManager(this);
|
||||
soundManager = new SoundManager(this);
|
||||
@ -155,7 +182,7 @@ public class SkyBlock extends SongodaPlugin {
|
||||
rewardManager = new RewardManager(this);
|
||||
rewardManager.loadRewards();
|
||||
|
||||
bankManager = new BankManager();
|
||||
bankManager = new BankManager(this);
|
||||
|
||||
new PlaytimeTask(playerDataManager, islandManager).runTaskTimerAsynchronously(this, 0L, 20L);
|
||||
new VisitTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
|
||||
@ -186,17 +213,40 @@ public class SkyBlock extends SongodaPlugin {
|
||||
pluginManager.registerEvents(new Grow(this), this);
|
||||
pluginManager.registerEvents(new Piston(this), this);
|
||||
pluginManager.registerEvents(new FallBreak(this), this);
|
||||
pluginManager.registerEvents(new World(this), this);
|
||||
|
||||
if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
|
||||
pluginManager.registerEvents(new Sponge(this), this);
|
||||
}
|
||||
|
||||
if (pluginManager.isPluginEnabled("EpicSpawners")) pluginManager.registerEvents(new EpicSpawners(this), this);
|
||||
if (pluginManager.isPluginEnabled("EpicSpawners"))
|
||||
pluginManager.registerEvents(new EpicSpawners(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());
|
||||
|
||||
if (pluginManager.isPluginEnabled("Vault")) {
|
||||
this.vaultPermission = getServer().getServicesManager().getRegistration(Permission.class).getProvider();
|
||||
}
|
||||
|
||||
switch (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration().getString("Economy.Manager", "Default")) {
|
||||
case "Vault":
|
||||
getEconomyManager().setEconomy("Vault");
|
||||
break;
|
||||
case "PlayerPoints":
|
||||
getEconomyManager().setEconomy("PlayerPoints");
|
||||
break;
|
||||
case "Reserve":
|
||||
getEconomyManager().setEconomy("Reserve");
|
||||
break;
|
||||
}
|
||||
|
||||
this.coreProtectAPI = loadCoreProtect();
|
||||
|
||||
SkyBlockAPI.setImplementation(INSTANCE);
|
||||
}
|
||||
@ -207,6 +257,10 @@ public class SkyBlock extends SongodaPlugin {
|
||||
this.userCacheManager.onDisable();
|
||||
}
|
||||
|
||||
if (this.scoreboardManager != null) {
|
||||
this.scoreboardManager.disable();
|
||||
}
|
||||
|
||||
if (this.islandManager != null) {
|
||||
this.islandManager.onDisable();
|
||||
}
|
||||
@ -242,6 +296,22 @@ public class SkyBlock extends SongodaPlugin {
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
private CoreProtectAPI loadCoreProtect() {
|
||||
Plugin plugin = getServer().getPluginManager().getPlugin("CoreProtect");
|
||||
|
||||
if (plugin != null) { // Check before loading classes
|
||||
if (plugin instanceof CoreProtect) { // Check that CoreProtect is loaded
|
||||
CoreProtectAPI CoreProtect = ((CoreProtect) plugin).getAPI();
|
||||
if (CoreProtect.isEnabled()) { // Check that the API is enabled
|
||||
if (CoreProtect.APIVersion() >= 6) { // Check that a compatible version of the API is loaded
|
||||
return CoreProtect;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigReload() {
|
||||
|
||||
@ -276,6 +346,10 @@ public class SkyBlock extends SongodaPlugin {
|
||||
return banManager;
|
||||
}
|
||||
|
||||
public BankManager getBankManager() {
|
||||
return bankManager;
|
||||
}
|
||||
|
||||
public IslandManager getIslandManager() {
|
||||
return islandManager;
|
||||
}
|
||||
@ -384,4 +458,24 @@ public class SkyBlock extends SongodaPlugin {
|
||||
public GuiManager getGuiManager() {
|
||||
return guiManager;
|
||||
}
|
||||
|
||||
public CoreProtectAPI getCoreProtectAPI() {
|
||||
return coreProtectAPI;
|
||||
}
|
||||
|
||||
public boolean isPaper() {
|
||||
return paper;
|
||||
}
|
||||
|
||||
public boolean isPaperAsync() {
|
||||
return paperAsync;
|
||||
}
|
||||
|
||||
public Permission getVaultPermission() {
|
||||
return vaultPermission;
|
||||
}
|
||||
|
||||
public EconomyManager getEconomyManager() {
|
||||
return economyManager;
|
||||
}
|
||||
}
|
||||
|
@ -25,9 +25,9 @@ public class SkyBlockAPI {
|
||||
/**
|
||||
* @param implementation the implementation to set
|
||||
*/
|
||||
public static void setImplementation(SkyBlock implementation) {
|
||||
if (SkyBlockAPI.implementation != null) {
|
||||
throw new IllegalArgumentException("Cannot set API implementation twice");
|
||||
public static void setImplementation(SkyBlock implementation) throws IllegalStateException {
|
||||
if (SkyBlockAPI.implementation != null && SkyBlockAPI.implementation != implementation) {
|
||||
throw new IllegalStateException("Cannot set API implementation twice");
|
||||
}
|
||||
|
||||
SkyBlockAPI.implementation = implementation;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.skyblock.api.bank;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.bank.BankManager;
|
||||
import com.songoda.skyblock.bank.Transaction;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -10,7 +11,7 @@ import java.util.UUID;
|
||||
public class TransactionLog {
|
||||
|
||||
public BankManager getImplementation() {
|
||||
return BankManager.getInstance();
|
||||
return SkyBlock.getInstance().getBankManager();
|
||||
}
|
||||
|
||||
public List<Transaction> getLogForPlayer(UUID uuid) {
|
||||
|
@ -2,6 +2,7 @@ package com.songoda.skyblock.api.biome;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import com.songoda.skyblock.island.IslandWorld;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
public class BiomeManager {
|
||||
@ -19,6 +20,6 @@ public class BiomeManager {
|
||||
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);
|
||||
this.biomeManager.setBiome(island.getIsland(), IslandWorld.Normal, biome, null);
|
||||
}
|
||||
}
|
||||
|
@ -4,17 +4,20 @@ import com.songoda.skyblock.api.island.Island;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@Deprecated
|
||||
public class IslandOpenEvent extends IslandEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final boolean open;
|
||||
private boolean cancelled = false;
|
||||
|
||||
|
||||
@Deprecated
|
||||
public IslandOpenEvent(Island island, boolean open) {
|
||||
super(island);
|
||||
this.open = open;
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public boolean isOpen() {
|
||||
return open;
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
package com.songoda.skyblock.api.event.island;
|
||||
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import com.songoda.skyblock.api.island.IslandStatus;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class IslandStatusChangeEvent extends IslandEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final IslandStatus status;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public IslandStatusChangeEvent(Island island, IslandStatus status) {
|
||||
super(island);
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public IslandStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import com.songoda.skyblock.api.utils.APIUtil;
|
||||
import com.songoda.skyblock.api.visit.Visit;
|
||||
import com.songoda.skyblock.island.IslandCoop;
|
||||
import com.songoda.skyblock.island.IslandPermission;
|
||||
import com.songoda.skyblock.island.IslandStatus;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.WeatherType;
|
||||
@ -14,7 +15,10 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Island {
|
||||
|
||||
@ -372,12 +376,14 @@ public class Island {
|
||||
/**
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isOpen() {
|
||||
return handle.isOpen();
|
||||
return handle.getStatus().equals(IslandStatus.OPEN);
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public void setOpen(boolean open) {
|
||||
this.handle.setOpen(open);
|
||||
this.handle.setStatus(open ? IslandStatus.OPEN : IslandStatus.CLOSED);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -459,7 +465,8 @@ public class Island {
|
||||
*/
|
||||
public void load() {
|
||||
if (this.handle == null) {
|
||||
this.handle = SkyBlockAPI.getImplementation().getIslandManager().loadIsland(player);
|
||||
SkyBlockAPI.getImplementation().getIslandManager().loadIsland(player);
|
||||
this.handle = SkyBlockAPI.getImplementation().getIslandManager().getIsland(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
package com.songoda.skyblock.api.island;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class IslandLevel {
|
||||
@ -116,4 +117,13 @@ public class IslandLevel {
|
||||
public Island getIsland() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the island level for a determined location
|
||||
* @param location
|
||||
*/
|
||||
public void updateLevel(Location location){
|
||||
Preconditions.checkArgument(location != null, "Cannot update level of a null island");
|
||||
SkyBlock.getInstance().getLevellingManager().updateLevel(this.handle.getIsland(), location);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import com.google.common.base.Preconditions;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.api.structure.Structure;
|
||||
import com.songoda.skyblock.api.utils.APIUtil;
|
||||
import com.songoda.skyblock.island.IslandPermission;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
@ -0,0 +1,7 @@
|
||||
package com.songoda.skyblock.api.island;
|
||||
|
||||
public enum IslandStatus {
|
||||
OPEN,
|
||||
CLOSED,
|
||||
WHITELISTED
|
||||
}
|
@ -1,13 +1,18 @@
|
||||
package com.songoda.skyblock.api.levelling;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import com.songoda.skyblock.levelling.IslandLevelManager;
|
||||
import com.songoda.skyblock.levelling.calculator.Calculator;
|
||||
import com.songoda.skyblock.levelling.calculator.CalculatorRegistry;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class LevellingManager {
|
||||
|
||||
private final com.songoda.skyblock.levelling.rework.IslandLevelManager levellingManager;
|
||||
private final IslandLevelManager levellingManager;
|
||||
|
||||
public LevellingManager(com.songoda.skyblock.levelling.rework.IslandLevelManager levellingManager) {
|
||||
public LevellingManager(IslandLevelManager levellingManager) {
|
||||
this.levellingManager = levellingManager;
|
||||
}
|
||||
|
||||
@ -18,4 +23,15 @@ public class LevellingManager {
|
||||
Preconditions.checkArgument(island != null, "Cannot calculate points to null island");
|
||||
this.levellingManager.startScan(null, island.getIsland());
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new material calculator for a determined material
|
||||
* @param calculator
|
||||
* @param material
|
||||
*/
|
||||
public void registerCalculator(Calculator calculator, Material material){
|
||||
Preconditions.checkArgument(calculator != null, "Cannot use a null calculator");
|
||||
Preconditions.checkArgument(material != null, "Cannot use a null material");
|
||||
CalculatorRegistry.registerCalculator(calculator, CompatibleMaterial.getMaterial(material));
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,32 @@ public final class APIUtil {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static com.songoda.skyblock.island.IslandStatus toImplementation(IslandStatus status) {
|
||||
switch (status) {
|
||||
case OPEN:
|
||||
return com.songoda.skyblock.island.IslandStatus.OPEN;
|
||||
case CLOSED:
|
||||
return com.songoda.skyblock.island.IslandStatus.CLOSED;
|
||||
case WHITELISTED:
|
||||
return com.songoda.skyblock.island.IslandStatus.WHITELISTED;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IslandStatus fromImplementation(com.songoda.skyblock.island.IslandStatus status) {
|
||||
switch (status) {
|
||||
case OPEN:
|
||||
return IslandStatus.OPEN;
|
||||
case CLOSED:
|
||||
return IslandStatus.CLOSED;
|
||||
case WHITELISTED:
|
||||
return IslandStatus.WHITELISTED;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static com.songoda.skyblock.island.IslandRole toImplementation(IslandRole role) {
|
||||
switch (role) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.skyblock.ban;
|
||||
|
||||
import com.eatthepath.uuid.FastUUID;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.api.event.island.IslandBanEvent;
|
||||
import com.songoda.skyblock.api.event.island.IslandUnbanEvent;
|
||||
@ -32,16 +33,16 @@ public class Ban {
|
||||
}
|
||||
|
||||
public Set<UUID> getBans() {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
SkyBlock plugin = 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"))
|
||||
for (String islandBanList : plugin.getFileManager()
|
||||
.getConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"),
|
||||
FastUUID.toString(islandOwnerUUID) + ".yml"))
|
||||
.getFileConfiguration().getStringList("Bans")) {
|
||||
|
||||
UUID uuid = UUID.fromString(islandBanList);
|
||||
UUID uuid = FastUUID.parseUUID(islandBanList);
|
||||
if (!Bukkit.getOfflinePlayer(uuid).hasPlayedBefore())
|
||||
continue;
|
||||
|
||||
@ -52,19 +53,19 @@ public class Ban {
|
||||
}
|
||||
|
||||
public void addBan(UUID issuer, UUID banned) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
SkyBlock plugin = SkyBlock.getInstance();
|
||||
|
||||
IslandBanEvent islandBanEvent = new IslandBanEvent(
|
||||
skyblock.getIslandManager().getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID))
|
||||
plugin.getIslandManager().getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID))
|
||||
.getAPIWrapper(),
|
||||
Bukkit.getServer().getOfflinePlayer(issuer), Bukkit.getServer().getOfflinePlayer(banned));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(islandBanEvent));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> 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"))
|
||||
FileConfiguration configLoad = plugin.getFileManager()
|
||||
.getConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"),
|
||||
FastUUID.toString(islandOwnerUUID) + ".yml"))
|
||||
.getFileConfiguration();
|
||||
|
||||
for (String islandBanList : configLoad.getStringList("Bans")) {
|
||||
@ -77,16 +78,16 @@ public class Ban {
|
||||
}
|
||||
|
||||
public void removeBan(UUID uuid) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
SkyBlock plugin = SkyBlock.getInstance();
|
||||
|
||||
List<String> islandBans = new ArrayList<>();
|
||||
FileConfiguration configLoad = skyblock.getFileManager()
|
||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/ban-data"),
|
||||
FileConfiguration configLoad = plugin.getFileManager()
|
||||
.getConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"),
|
||||
islandOwnerUUID.toString() + ".yml"))
|
||||
.getFileConfiguration();
|
||||
|
||||
for (String islandBanList : configLoad.getStringList("Bans")) {
|
||||
if (!uuid.toString().equals(islandBanList)) {
|
||||
if (!FastUUID.toString(uuid).equals(islandBanList)) {
|
||||
islandBans.add(islandBanList);
|
||||
}
|
||||
}
|
||||
@ -94,16 +95,16 @@ public class Ban {
|
||||
configLoad.set("Bans", islandBans);
|
||||
|
||||
Bukkit.getServer().getPluginManager()
|
||||
.callEvent(new IslandUnbanEvent(skyblock.getIslandManager()
|
||||
.callEvent(new IslandUnbanEvent(plugin.getIslandManager()
|
||||
.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)).getAPIWrapper(),
|
||||
Bukkit.getServer().getOfflinePlayer(uuid)));
|
||||
}
|
||||
|
||||
public void save() {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
SkyBlock plugin = SkyBlock.getInstance();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(
|
||||
new File(skyblock.getDataFolder().toString() + "/ban-data"), islandOwnerUUID.toString() + ".yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(
|
||||
new File(plugin.getDataFolder().toString() + "/ban-data"), islandOwnerUUID.toString() + ".yml"));
|
||||
|
||||
try {
|
||||
config.getFileConfiguration().save(config.getFile());
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.skyblock.ban;
|
||||
|
||||
import com.eatthepath.uuid.FastUUID;
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
@ -19,11 +20,11 @@ import java.util.UUID;
|
||||
|
||||
public class BanManager {
|
||||
|
||||
private final SkyBlock skyblock;
|
||||
private final SkyBlock plugin;
|
||||
private Map<UUID, Ban> banStorage = new HashMap<>();
|
||||
|
||||
public BanManager(SkyBlock skyblock) {
|
||||
this.skyblock = skyblock;
|
||||
public BanManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
loadIslands();
|
||||
}
|
||||
@ -37,15 +38,15 @@ public class BanManager {
|
||||
}
|
||||
|
||||
public void loadIslands() {
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Visitor.Unload")) {
|
||||
File configFile = new File(skyblock.getDataFolder().toString() + "/island-data");
|
||||
File configFile = new File(plugin.getDataFolder().toString() + "/island-data");
|
||||
|
||||
if (configFile.exists()) {
|
||||
for (File fileList : configFile.listFiles()) {
|
||||
UUID islandOwnerUUID = UUID.fromString(fileList.getName().replaceFirst("[.][^.]+$", ""));
|
||||
UUID islandOwnerUUID = FastUUID.parseUUID(fileList.getName().replaceFirst("[.][^.]+$", ""));
|
||||
createIsland(islandOwnerUUID);
|
||||
}
|
||||
}
|
||||
@ -53,15 +54,15 @@ public class BanManager {
|
||||
}
|
||||
|
||||
public void transfer(UUID uuid1, UUID uuid2) {
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
FileManager fileManager = plugin.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");
|
||||
File oldBanDataFile = new File(new File(plugin.getDataFolder().toString() + "/ban-data"),
|
||||
FastUUID.toString(uuid1) + ".yml");
|
||||
File newBanDataFile = new File(new File(plugin.getDataFolder().toString() + "/ban-data"),
|
||||
FastUUID.toString(uuid2) + ".yml");
|
||||
|
||||
fileManager.unloadConfig(oldBanDataFile);
|
||||
fileManager.unloadConfig(newBanDataFile);
|
||||
@ -73,14 +74,14 @@ public class BanManager {
|
||||
}
|
||||
|
||||
public void removeVisitor(Island island) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
for (UUID visitorList : skyblock.getIslandManager().getVisitorsAtIsland(island)) {
|
||||
for (UUID visitorList : plugin.getIslandManager().getVisitorsAtIsland(island)) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(visitorList);
|
||||
|
||||
LocationUtil.teleportPlayerToSpawn(targetPlayer);
|
||||
@ -116,7 +117,7 @@ public class BanManager {
|
||||
|
||||
public void unloadIsland(UUID islandOwnerUUID) {
|
||||
if (hasIsland(islandOwnerUUID)) {
|
||||
skyblock.getFileManager().unloadConfig(new File(new File(skyblock.getDataFolder().toString() + "/ban-data"),
|
||||
plugin.getFileManager().unloadConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"),
|
||||
islandOwnerUUID.toString() + ".yml"));
|
||||
banStorage.remove(islandOwnerUUID);
|
||||
}
|
||||
@ -124,7 +125,7 @@ public class BanManager {
|
||||
|
||||
public void deleteIsland(UUID islandOwnerUUID) {
|
||||
if (hasIsland(islandOwnerUUID)) {
|
||||
skyblock.getFileManager().deleteConfig(new File(new File(skyblock.getDataFolder().toString() + "/ban-data"),
|
||||
plugin.getFileManager().deleteConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"),
|
||||
islandOwnerUUID.toString() + ".yml"));
|
||||
banStorage.remove(islandOwnerUUID);
|
||||
}
|
||||
|
@ -1,44 +1,40 @@
|
||||
package com.songoda.skyblock.bank;
|
||||
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.songoda.core.hooks.economies.Economy;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
public class BankManager {
|
||||
private static BankManager instance;
|
||||
|
||||
public static BankManager getInstance() {return instance == null ? instance = new BankManager() : instance;}
|
||||
|
||||
private HashMap<UUID, List<Transaction>> log;
|
||||
private final HashMap<UUID, List<Transaction>> log;
|
||||
|
||||
private final SkyBlock plugin;
|
||||
|
||||
public FileConfiguration lang;
|
||||
|
||||
public BankManager() {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
public BankManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
lang = config.getFileConfiguration();
|
||||
log = new HashMap<>();
|
||||
loadTransactions();
|
||||
}
|
||||
|
||||
public List<String> getTransactions(Player player) {
|
||||
/*public List<String> getTransactions(Player player) {
|
||||
if (log.containsKey(player.getUniqueId())&&log.get(player.getUniqueId())!=null&&!log.get(player.getUniqueId()).isEmpty()) {
|
||||
List<String> lore = new ArrayList<>();
|
||||
List<Transaction> transactions = log.get(player.getUniqueId());
|
||||
int size = transactions.size()>10 ? 10 : transactions.size();
|
||||
for (int i = 0;i<size;i++) {
|
||||
Transaction t = transactions.get((transactions.size()-1)-i);
|
||||
lore.add("#" + (i+1) + " " + t.timestamp.toString() +" " + t.player.getPlayer().getDisplayName() + " " + t.action.name().toLowerCase() + " " + EconomyManager.formatEconomy(t.ammount));
|
||||
SimpleDateFormat formatDate = new SimpleDateFormat("dd/MM/yyyy HH:mm");
|
||||
lore.add("#" + (i+1) + " " + formatDate.format(t.timestamp) +" " + t.player.getPlayer().getDisplayName() + " " + t.action.name().toLowerCase() + " " + EconomyManager.formatEconomy(t.ammount));
|
||||
}
|
||||
return lore;
|
||||
}else {
|
||||
@ -46,6 +42,20 @@ public class BankManager {
|
||||
lore.add(lang.getString("Menu.Bank.Item.Log.Empty"));
|
||||
return lore;
|
||||
}
|
||||
}*/
|
||||
|
||||
public List<Transaction> getTransactions(Player player) {
|
||||
return getTransactions(player.getUniqueId());
|
||||
}
|
||||
|
||||
public List<Transaction> getTransactions(UUID uuid) {
|
||||
if (log.containsKey(uuid)
|
||||
&& log.get(uuid) != null
|
||||
&& !log.get(uuid).isEmpty()) {
|
||||
return new ArrayList<>(log.get(uuid));
|
||||
}else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
public void addTransaction(Player p, Transaction transaction) {
|
||||
@ -65,19 +75,104 @@ public class BankManager {
|
||||
}
|
||||
|
||||
public List<String> getBalanceLore(Player player) {
|
||||
Economy economy = plugin.getEconomyManager().getEconomy();
|
||||
|
||||
List<String> result = new ArrayList<>();
|
||||
result.add("Some error occurred while loading your balance!");
|
||||
Island island = SkyBlock.getInstance().getIslandManager().getIsland(player);
|
||||
result.add("If this is null then its a easy to fix bug: "+island.toString());
|
||||
if (island != null) {
|
||||
result.clear();
|
||||
result.add(player.getDisplayName()+"'s balance is "+EconomyManager.formatEconomy(EconomyManager.getBalance(player)));
|
||||
result.add(player.getDisplayName()+"'s island has "+EconomyManager.formatEconomy(island.getBankBalance()));
|
||||
result.add(player.getDisplayName()+"'s balance is "+economy.formatEconomy(economy.getBalance(player)));
|
||||
result.add(player.getDisplayName()+"'s island has "+ economy.formatEconomy(island.getBankBalance()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<Transaction> getTransactionList(Player player) {
|
||||
return log.get(player.getUniqueId());
|
||||
return getTransactionList(player.getUniqueId());
|
||||
}
|
||||
|
||||
public List<Transaction> getTransactionList(UUID uuid) {
|
||||
return log.get(uuid);
|
||||
}
|
||||
|
||||
public BankResponse deposit(Player player, Island island, double amt, boolean admin) {
|
||||
Economy economy = plugin.getEconomyManager().getEconomy();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
// Make sure the amount is positive
|
||||
if (amt <= 0) {
|
||||
return BankResponse.NEGATIVE_AMOUNT;
|
||||
}
|
||||
|
||||
// If decimals aren't allowed, check for them
|
||||
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) {
|
||||
int intAmt = (int) amt;
|
||||
if (intAmt != amt) {
|
||||
return BankResponse.DECIMALS_NOT_ALLOWED;
|
||||
}
|
||||
}
|
||||
|
||||
if(!admin) {
|
||||
if (!economy.hasBalance(player, amt)) {
|
||||
return BankResponse.NOT_ENOUGH_MONEY;
|
||||
}
|
||||
|
||||
economy.withdrawBalance(player, amt);
|
||||
}
|
||||
|
||||
island.addToBank(amt);
|
||||
Transaction t = new Transaction();
|
||||
t.player = player;
|
||||
t.amount = (float) amt;
|
||||
t.timestamp = Calendar.getInstance().getTime();
|
||||
t.action = Transaction.Type.DEPOSIT;
|
||||
t.visibility = admin ? Transaction.Visibility.ADMIN : Transaction.Visibility.USER;
|
||||
this.addTransaction(player, t);
|
||||
return BankResponse.SUCCESS;
|
||||
}
|
||||
|
||||
public BankResponse withdraw(Player player, Island island, double amt, boolean admin) {
|
||||
Economy economy = plugin.getEconomyManager().getEconomy();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
// Make sure the amount is positive
|
||||
if (amt <= 0) {
|
||||
return BankResponse.NEGATIVE_AMOUNT;
|
||||
}
|
||||
|
||||
// If decimals aren't allowed, check for them
|
||||
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) {
|
||||
int intAmt = (int) amt;
|
||||
if (intAmt != amt) {
|
||||
return BankResponse.DECIMALS_NOT_ALLOWED;
|
||||
}
|
||||
}
|
||||
|
||||
if(!admin){
|
||||
if (amt > island.getBankBalance()) {
|
||||
return BankResponse.NOT_ENOUGH_MONEY;
|
||||
}
|
||||
|
||||
economy.deposit(player, amt);
|
||||
}
|
||||
|
||||
island.removeFromBank(amt);
|
||||
Transaction t = new Transaction();
|
||||
t.player = player;
|
||||
t.amount = (float) amt;
|
||||
t.timestamp = Calendar.getInstance().getTime();
|
||||
t.action = Transaction.Type.WITHDRAW;
|
||||
t.visibility = admin ? Transaction.Visibility.ADMIN : Transaction.Visibility.USER;
|
||||
this.addTransaction(player, t);
|
||||
return BankResponse.SUCCESS;
|
||||
}
|
||||
|
||||
public enum BankResponse{
|
||||
NOT_ENOUGH_MONEY,
|
||||
DECIMALS_NOT_ALLOWED,
|
||||
NEGATIVE_AMOUNT,
|
||||
SUCCESS
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,18 @@ import java.util.Date;
|
||||
public class Transaction {
|
||||
|
||||
public OfflinePlayer player;
|
||||
public float ammount;
|
||||
public float amount;
|
||||
public Date timestamp;
|
||||
public Type action;
|
||||
public Visibility visibility;
|
||||
|
||||
public enum Type {
|
||||
WITHDRAW,
|
||||
DEPOSIT
|
||||
}
|
||||
|
||||
public enum Visibility {
|
||||
ADMIN,
|
||||
USER
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package com.songoda.skyblock.bank;
|
||||
|
||||
public enum Type {
|
||||
WITHDRAW,
|
||||
DEPOSIT
|
||||
}
|
@ -1,75 +1,155 @@
|
||||
package com.songoda.skyblock.biome;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.blockscanner.ChunkLoader;
|
||||
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.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class BiomeManager {
|
||||
|
||||
final ServerVersion ASYNC_OBFUSCATOR_VERSION = ServerVersion.V1_9;
|
||||
|
||||
private final SkyBlock skyblock;
|
||||
private final SkyBlock plugin;
|
||||
private final List<Island> updatingIslands;
|
||||
private final FileConfiguration language;
|
||||
private final int runEveryX;
|
||||
|
||||
public BiomeManager(SkyBlock skyblock) {
|
||||
this.skyblock = skyblock;
|
||||
public BiomeManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
this.updatingIslands = new ArrayList<>();
|
||||
this.language = SkyBlock.getInstance().getFileManager().getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
this.runEveryX = language.getInt("Command.Island.Biome.Progress.Display-Every-X-Updates");
|
||||
}
|
||||
|
||||
public boolean isUpdating(Island island) {
|
||||
return updatingIslands.contains(island);
|
||||
}
|
||||
|
||||
public void addUpdatingIsland(Island island) {
|
||||
updatingIslands.add(island);
|
||||
}
|
||||
|
||||
public void removeUpdatingIsland(Island island) {
|
||||
updatingIslands.remove(island);
|
||||
}
|
||||
|
||||
public void setBiome(Island island, Biome biome) {
|
||||
Location location = island.getLocation(IslandWorld.Normal, IslandEnvironment.Island);
|
||||
int radius = (int) Math.ceil(island.getRadius());
|
||||
public void setBiome(Island island, IslandWorld world, Biome biome, CompleteTask task) {
|
||||
addUpdatingIsland(island);
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||
for (int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x++) {
|
||||
for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z++) {
|
||||
location.getWorld().setBiome(x, z, biome);
|
||||
if (island.getLocation(world, IslandEnvironment.Island) == null) return;
|
||||
|
||||
// We keep it sequentially in order to use less RAM
|
||||
int chunkAmount = (int) Math.ceil(Math.pow(island.getSize()/16d, 2d));
|
||||
AtomicInteger progress = new AtomicInteger();
|
||||
|
||||
ChunkLoader.startChunkLoadingPerChunk(island, world, plugin.isPaperAsync(), (futureChunk) -> {
|
||||
Chunk chunk = futureChunk.join();
|
||||
if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ // TODO Should be 1.15 but it works fine there
|
||||
setChunkBiome3D(biome, chunk);
|
||||
} else {
|
||||
try {
|
||||
setChunkBiome2D(biome, chunk);
|
||||
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Bukkit.getScheduler().runTask(skyblock, () -> {
|
||||
for (int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x += 16) {
|
||||
for (int z = location.getBlockZ() - radius; z < location.getBlockZ() + radius; z += 16) {
|
||||
Chunk chunk = location.getWorld().getChunkAt(x >> 4, z >> 4);
|
||||
updateBiome(island, chunk);
|
||||
}
|
||||
updateBiomePacket(island, chunk);
|
||||
|
||||
progress.getAndIncrement();
|
||||
|
||||
if(language.getBoolean("Command.Island.Biome.Progress.Should-Display-Message") &&
|
||||
progress.get() == 1 || progress.get() == chunkAmount || progress.get() % runEveryX == 0){
|
||||
final double percent = ((double) progress.get() / (double) chunkAmount) * 100;
|
||||
|
||||
String message = language.getString("Command.Island.Biome.Progress.Message");
|
||||
message = message.replace("%current_updated_chunks%", String.valueOf(progress.get()));
|
||||
message = message.replace("%max_chunks%", String.valueOf(chunkAmount));
|
||||
message = message.replace("%percent_whole%", String.valueOf((int) percent));
|
||||
message = message.replace("%percent%", NumberFormat.getInstance().format(percent));
|
||||
|
||||
for (Player player : SkyBlock.getInstance().getIslandManager().getPlayersAtIsland(island)) {
|
||||
plugin.getMessageManager().sendMessage(player, message);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}, (island1 -> {
|
||||
removeUpdatingIsland(island1);
|
||||
if(task != null) {
|
||||
task.onCompleteUpdate();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private Class<?> packetPlayOutMapChunkClass;
|
||||
private Class<?> chunkClass;
|
||||
|
||||
private void updateBiome(Island island, Chunk chunk) {
|
||||
if (packetPlayOutMapChunkClass == null) {
|
||||
packetPlayOutMapChunkClass = NMSUtil.getNMSClass("PacketPlayOutMapChunk");
|
||||
chunkClass = NMSUtil.getNMSClass("Chunk");
|
||||
private void setChunkBiome2D(Biome biome, Chunk chunk) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
||||
for(int x = chunk.getX() << 4; x < (chunk.getX()<< 4)+16; x++){
|
||||
for(int z = chunk.getZ() << 4; z < (chunk.getZ()<< 4)+16; z++){
|
||||
World.class.getMethod("setBiome", int.class, int.class, Biome.class).invoke(chunk.getWorld(), x, z, biome);
|
||||
}
|
||||
}
|
||||
|
||||
for (Player all : skyblock.getIslandManager().getPlayersAtIsland(island, IslandWorld.Normal)) {
|
||||
try {
|
||||
if (NMSUtil.getVersionNumber() < 9) {
|
||||
NMSUtil.sendPacket(all,
|
||||
packetPlayOutMapChunkClass.getConstructor(chunkClass, boolean.class, int.class)
|
||||
.newInstance(all.getLocation().getChunk().getClass().getMethod("getHandle")
|
||||
.invoke(chunk), true, 20));
|
||||
return;
|
||||
}
|
||||
|
||||
// Do not use - Too laggy
|
||||
private void setChunkBiome3D(Biome biome, Chunk chunk) {
|
||||
for(int x = chunk.getX() << 4; x < (chunk.getX()<< 4)+16; x++){
|
||||
for(int z = chunk.getZ() << 4; z < (chunk.getZ()<< 4)+16; z++){
|
||||
for(int y = 0; y < chunk.getWorld().getMaxHeight(); ++y) {
|
||||
chunk.getWorld().setBiome(x, y, z, biome);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void updateBiomePacket(Island island, Chunk chunk) {
|
||||
Class<?> packetPlayOutMapChunkClass;
|
||||
Class<?> chunkClass;
|
||||
|
||||
packetPlayOutMapChunkClass = NMSUtil.getNMSClass("PacketPlayOutMapChunk");
|
||||
chunkClass = NMSUtil.getNMSClass("Chunk");
|
||||
|
||||
for (Player player : plugin.getIslandManager().getPlayersAtIsland(island, IslandWorld.Normal)) {
|
||||
try {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
|
||||
if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) {
|
||||
NMSUtil.sendPacket(player,
|
||||
packetPlayOutMapChunkClass.getConstructor(chunkClass, int.class, boolean.class).newInstance(player
|
||||
.getLocation().getChunk().getClass().getMethod("getHandle").invoke(chunk),
|
||||
65535, true));
|
||||
} else {
|
||||
NMSUtil.sendPacket(player,
|
||||
packetPlayOutMapChunkClass.getConstructor(chunkClass, int.class).newInstance(player
|
||||
.getLocation().getChunk().getClass().getMethod("getHandle").invoke(chunk),
|
||||
65535));
|
||||
}
|
||||
} else {
|
||||
NMSUtil.sendPacket(player,
|
||||
packetPlayOutMapChunkClass.getConstructor(chunkClass, boolean.class, int.class)
|
||||
.newInstance(player.getLocation().getChunk().getClass().getMethod("getHandle")
|
||||
.invoke(chunk), true, 20));
|
||||
}
|
||||
NMSUtil.sendPacket(all,
|
||||
packetPlayOutMapChunkClass.getConstructor(chunkClass, int.class).newInstance(all
|
||||
.getLocation().getChunk().getClass().getMethod("getHandle").invoke(chunk),
|
||||
65535));
|
||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
|
||||
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface CompleteTask {
|
||||
void onCompleteUpdate();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,20 @@
|
||||
package com.songoda.skyblock.blockscanner;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandEnvironment;
|
||||
import com.songoda.skyblock.world.WorldManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@ -8,19 +23,7 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.utils.version.NMSUtil;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public final class BlockScanner extends BukkitRunnable {
|
||||
|
||||
@ -31,9 +34,7 @@ public final class BlockScanner extends BukkitRunnable {
|
||||
|
||||
try {
|
||||
temp = ChunkSnapshot.class.getMethod("getBlockTypeId", int.class, int.class, int.class);
|
||||
} catch (NoSuchMethodException ignored) {
|
||||
|
||||
}
|
||||
} catch (NoSuchMethodException ignored) {}
|
||||
|
||||
ID_FIELD = temp;
|
||||
}
|
||||
@ -51,19 +52,30 @@ public final class BlockScanner extends BukkitRunnable {
|
||||
return id;
|
||||
}
|
||||
|
||||
private final static int VERSION = NMSUtil.getVersionNumber();
|
||||
|
||||
private int completedNum;
|
||||
private final AtomicInteger completedNum;
|
||||
|
||||
private final int threadCount;
|
||||
private final Queue<BlockInfo> blocks;
|
||||
private final ScannerTasks tasks;
|
||||
|
||||
private final Island island;
|
||||
|
||||
private final boolean ignoreLiquids;
|
||||
private final boolean ignoreAir;
|
||||
|
||||
private int scanY;
|
||||
|
||||
private BlockScanner(Map<World, List<ChunkSnapshot>> snapshots, ScannerTasks tasks) {
|
||||
private BlockScanner(Map<World, List<ChunkSnapshot>> snapshots,
|
||||
Island island,
|
||||
boolean ignoreLiquids,
|
||||
boolean ignoreLiquidsY,
|
||||
boolean ignoreAir,
|
||||
boolean ignoreY,
|
||||
ScannerTasks tasks) {
|
||||
this.ignoreLiquids = ignoreLiquids;
|
||||
this.ignoreAir = ignoreAir;
|
||||
this.blocks = new ConcurrentLinkedQueue<>();
|
||||
this.tasks = tasks;
|
||||
this.completedNum = new AtomicInteger();
|
||||
this.island = island;
|
||||
|
||||
FileConfiguration config = SkyBlock.getInstance().getFileManager().getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml")).getFileConfiguration();
|
||||
|
||||
@ -72,7 +84,7 @@ public final class BlockScanner extends BukkitRunnable {
|
||||
for (Entry<World, List<ChunkSnapshot>> entry : snapshots.entrySet()) {
|
||||
|
||||
final List<List<ChunkSnapshot>> parts = Lists.partition(entry.getValue(), 16);
|
||||
|
||||
|
||||
threadCount += parts.size();
|
||||
|
||||
World world = entry.getKey();
|
||||
@ -92,34 +104,72 @@ public final class BlockScanner extends BukkitRunnable {
|
||||
|
||||
final ConfigurationSection liquidSection = config.getConfigurationSection("Island.World." + env + ".Liquid");
|
||||
|
||||
for (List<ChunkSnapshot> sub : parts) {
|
||||
queueWork(world, liquidSection.getBoolean("Enable") && !config.getBoolean("Island.Levelling.ScanLiquid") ? liquidSection.getInt("Height") + 1 : 0, sub);
|
||||
int startY;
|
||||
if(ignoreY){
|
||||
startY = 255;
|
||||
} else {
|
||||
startY = !ignoreLiquidsY && liquidSection.getBoolean("Enable") && !config.getBoolean("Island.Levelling.ScanLiquid") ? liquidSection.getInt("Height") + 1 : 0;
|
||||
}
|
||||
|
||||
for (List<ChunkSnapshot> sub : parts) {
|
||||
queueWork(world, startY, sub);
|
||||
}
|
||||
}
|
||||
|
||||
this.threadCount = threadCount;
|
||||
}
|
||||
|
||||
private void queueWork(World world, int scanY, List<ChunkSnapshot> subList) {
|
||||
|
||||
|
||||
WorldManager worldManager = SkyBlock.getInstance().getWorldManager();
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(SkyBlock.getInstance(), () -> {
|
||||
LocationBounds bounds = null;
|
||||
if(island != null) {
|
||||
Location islandLocation = island.getLocation(worldManager.getIslandWorld(world), IslandEnvironment.Island);
|
||||
|
||||
Location minLocation = new Location(world, islandLocation.getBlockX() - island.getRadius(), 0, islandLocation.getBlockZ() - island.getRadius());
|
||||
Location maxLocation = new Location(world, islandLocation.getBlockX() + island.getRadius(), world.getMaxHeight(), islandLocation.getBlockZ() + island.getRadius());
|
||||
|
||||
int minX = Math.min(maxLocation.getBlockX(), minLocation.getBlockX());
|
||||
int minZ = Math.min(maxLocation.getBlockZ(), minLocation.getBlockZ());
|
||||
|
||||
int maxX = Math.max(maxLocation.getBlockX(), minLocation.getBlockX());
|
||||
int maxZ = Math.max(maxLocation.getBlockZ(), minLocation.getBlockZ());
|
||||
|
||||
bounds = new LocationBounds(minX, minZ, maxX, maxZ);
|
||||
}
|
||||
for (ChunkSnapshot shot : subList) {
|
||||
|
||||
final int cX = shot.getX() << 4;
|
||||
final int cZ = shot.getZ() << 4;
|
||||
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int y = scanY; y < 256; y++) {
|
||||
|
||||
|
||||
final CompatibleMaterial type = CompatibleMaterial.getBlockMaterial(VERSION > 12
|
||||
? shot.getBlockType(x, y, z) : MaterialIDHelper.getLegacyMaterial(getBlockTypeID(shot, x, y, z)));
|
||||
|
||||
|
||||
if (type == null || type == CompatibleMaterial.AIR || type == CompatibleMaterial.WATER) continue;
|
||||
|
||||
int initX = 0;
|
||||
int initZ = 0;
|
||||
int lastX = 15;
|
||||
int lastZ = 15;
|
||||
|
||||
if(bounds != null) {
|
||||
initX = Math.max(cX, bounds.getMinX())&0x000F;
|
||||
initZ = Math.max(cZ, bounds.getMinZ())&0x000F;
|
||||
|
||||
lastX = Math.min(cX | 15, bounds.getMaxX()-1)&0x000F;
|
||||
lastZ = Math.min(cZ | 15, bounds.getMaxZ()-1)&0x000F;
|
||||
}
|
||||
|
||||
for (int x = initX; x <= lastX; x++) {
|
||||
for (int z = initZ; z <= lastZ; z++) {
|
||||
for (int y = scanY; y < world.getMaxHeight(); y++) {
|
||||
final CompatibleMaterial type = CompatibleMaterial.getBlockMaterial(
|
||||
ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
|
||||
? shot.getBlockType(x, y, z) :
|
||||
MaterialIDHelper.getLegacyMaterial(getBlockTypeID(shot, x, y, z)));
|
||||
|
||||
if(type == null){
|
||||
continue;
|
||||
} else if(type.equals(CompatibleMaterial.AIR) && ignoreAir){
|
||||
continue;
|
||||
} else if(type.equals(CompatibleMaterial.WATER) && ignoreLiquids){
|
||||
continue;
|
||||
}
|
||||
|
||||
blocks.add(new BlockInfo(world, x + (cX), y, z + (cZ)));
|
||||
}
|
||||
@ -131,12 +181,11 @@ public final class BlockScanner extends BukkitRunnable {
|
||||
}
|
||||
|
||||
private synchronized int increment() {
|
||||
completedNum += 1;
|
||||
return completedNum;
|
||||
return completedNum.getAndIncrement();
|
||||
}
|
||||
|
||||
private synchronized int get() {
|
||||
return completedNum;
|
||||
return completedNum.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -147,17 +196,17 @@ public final class BlockScanner extends BukkitRunnable {
|
||||
cancel();
|
||||
}
|
||||
|
||||
public static void startScanner(Map<World, List<ChunkSnapshot>> snapshots, ScannerTasks tasks) {
|
||||
public static void startScanner(Map<World, List<ChunkSnapshot>> snapshots, Island island, boolean ignoreLiquids, boolean ignoreLiquidsY, boolean ignoreAir, boolean ignoreY, ScannerTasks tasks) {
|
||||
|
||||
if (snapshots == null) throw new IllegalArgumentException("snapshots cannot be null");
|
||||
if (tasks == null) throw new IllegalArgumentException("tasks cannot be null");
|
||||
|
||||
final BlockScanner scanner = new BlockScanner(snapshots, tasks);
|
||||
final BlockScanner scanner = new BlockScanner(snapshots, island, ignoreLiquids, ignoreLiquidsY, ignoreAir, ignoreY, tasks);
|
||||
|
||||
scanner.runTaskTimer(SkyBlock.getInstance(), 5, 5);
|
||||
}
|
||||
|
||||
public static interface ScannerTasks {
|
||||
public interface ScannerTasks {
|
||||
|
||||
void onComplete(Queue<BlockInfo> blocks);
|
||||
|
||||
|
173
src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java
Normal file
173
src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java
Normal file
@ -0,0 +1,173 @@
|
||||
package com.songoda.skyblock.blockscanner;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandEnvironment;
|
||||
import com.songoda.skyblock.island.IslandWorld;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class ChunkLoader extends BukkitRunnable {
|
||||
public final List<CompletableFuture<Chunk>> positions = new LinkedList<>();
|
||||
|
||||
private ChunkScannerTask generalTask;
|
||||
private ChunkForChunkScannerTask chunkTask;
|
||||
private final boolean chunkForChunk;
|
||||
private final boolean paper;
|
||||
private World world;
|
||||
private final Island island;
|
||||
private int x;
|
||||
private int z;
|
||||
private int minZ;
|
||||
private int maxX;
|
||||
private int maxZ;
|
||||
private final int chunkPerTick;
|
||||
private final CompleteTask completeTask;
|
||||
|
||||
private ChunkLoader(Island island,
|
||||
IslandWorld islandWorld,
|
||||
boolean paper,
|
||||
boolean chunkForChunk,
|
||||
ChunkForChunkScannerTask chunkTask,
|
||||
CompleteTask complete) {
|
||||
chunkPerTick = SkyBlock.getInstance().getFileManager()
|
||||
.getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getInt("Island.Performance.ChunkPerTick", 25);
|
||||
|
||||
this.completeTask = complete;
|
||||
this.chunkTask = chunkTask;
|
||||
this.chunkForChunk = chunkForChunk;
|
||||
this.paper = paper;
|
||||
this.island = island;
|
||||
Location islandLocation = island.getLocation(islandWorld, IslandEnvironment.Island);
|
||||
|
||||
if (islandLocation == null) return;
|
||||
|
||||
world = islandLocation.getWorld();
|
||||
|
||||
Location minLocation = new Location(world, islandLocation.getBlockX() - island.getRadius(), 0, islandLocation.getBlockZ() - island.getRadius());
|
||||
Location maxLocation = new Location(world, islandLocation.getBlockX() + island.getRadius(), world.getMaxHeight(), islandLocation.getBlockZ() + island.getRadius());
|
||||
|
||||
int minX = Math.min(maxLocation.getBlockX(), minLocation.getBlockX()) >> 4 << 4 ;
|
||||
minZ = Math.min(maxLocation.getBlockZ(), minLocation.getBlockZ()) >> 4 << 4;
|
||||
|
||||
maxX = Math.max(maxLocation.getBlockX(), minLocation.getBlockX()) >> 4 << 4 | 15;
|
||||
maxZ = Math.max(maxLocation.getBlockZ(), minLocation.getBlockZ()) >> 4 << 4 | 15;
|
||||
|
||||
x = minX;
|
||||
z = minZ;
|
||||
|
||||
if(paper){
|
||||
this.runTaskAsynchronously(SkyBlock.getInstance());
|
||||
} else {
|
||||
this.runTaskTimer(SkyBlock.getInstance(), 1L, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
private ChunkLoader(Island island,
|
||||
IslandWorld islandWorld,
|
||||
boolean paper,
|
||||
boolean chunkForChunk,
|
||||
ChunkScannerTask generalTask,
|
||||
CompleteTask complete) {
|
||||
chunkPerTick = SkyBlock.getInstance().getFileManager()
|
||||
.getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getInt("Island.Performance.ChunkPerTick", 25);
|
||||
|
||||
this.completeTask = complete;
|
||||
this.generalTask = generalTask;
|
||||
this.chunkForChunk = chunkForChunk;
|
||||
this.paper = paper;
|
||||
this.island = island;
|
||||
Location islandLocation = island.getLocation(islandWorld, IslandEnvironment.Island);
|
||||
|
||||
if (islandLocation == null) return;
|
||||
|
||||
world = islandLocation.getWorld();
|
||||
|
||||
Location minLocation = new Location(
|
||||
world,
|
||||
islandLocation.getBlockX() - island.getRadius(),
|
||||
0,
|
||||
islandLocation.getBlockZ() - island.getRadius());
|
||||
Location maxLocation = new Location(
|
||||
world,
|
||||
islandLocation.getBlockX() + island.getRadius(),
|
||||
world.getMaxHeight(),
|
||||
islandLocation.getBlockZ() + island.getRadius());
|
||||
|
||||
int minX = Math.min(maxLocation.getBlockX(), minLocation.getBlockX()) >> 4 << 4;
|
||||
minZ = Math.min(maxLocation.getBlockZ(), minLocation.getBlockZ()) >> 4 << 4;
|
||||
|
||||
maxX = Math.max(maxLocation.getBlockX(), minLocation.getBlockX()) >> 4 << 4 | 15;
|
||||
maxZ = Math.max(maxLocation.getBlockZ(), minLocation.getBlockZ()) >> 4 << 4 | 15;
|
||||
|
||||
x = minX;
|
||||
z = minZ;
|
||||
|
||||
if(paper){
|
||||
this.runTaskAsynchronously(SkyBlock.getInstance());
|
||||
} else {
|
||||
this.runTaskTimer(SkyBlock.getInstance(), 1L, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() { // TODO New algorithm that start from the center of the island
|
||||
for(int i = 0; i < chunkPerTick || paper; i++){
|
||||
if(x <= maxX){
|
||||
if(z <= maxZ){
|
||||
if(!chunkForChunk){
|
||||
positions.add(PaperLib.getChunkAtAsync(world, x >> 4, z >> 4));
|
||||
} else {
|
||||
if(chunkTask != null) {
|
||||
chunkTask.onChunkComplete(PaperLib.getChunkAtAsync(world, x >> 4, z >> 4));
|
||||
}
|
||||
}
|
||||
|
||||
z += 16;
|
||||
} else {
|
||||
z = minZ;
|
||||
x += 16;
|
||||
}
|
||||
} else {
|
||||
if(generalTask != null) {
|
||||
generalTask.onComplete(positions);
|
||||
}
|
||||
if(completeTask != null) {
|
||||
completeTask.onComplete(island);
|
||||
}
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void startChunkLoading(Island island, IslandWorld islandWorld, boolean paper, ChunkScannerTask task, CompleteTask complete){
|
||||
new ChunkLoader(island, islandWorld, paper, false, task, complete);
|
||||
}
|
||||
|
||||
public static void startChunkLoadingPerChunk(Island island, IslandWorld islandWorld, boolean paper, ChunkForChunkScannerTask task, CompleteTask complete){
|
||||
new ChunkLoader(island, islandWorld, paper, true, task, complete);
|
||||
}
|
||||
|
||||
public interface ChunkScannerTask {
|
||||
void onComplete(List<CompletableFuture<Chunk>> chunks);
|
||||
}
|
||||
|
||||
public interface ChunkForChunkScannerTask {
|
||||
void onChunkComplete(CompletableFuture<Chunk> chunk);
|
||||
}
|
||||
|
||||
public interface CompleteTask {
|
||||
void onComplete(Island island);
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.songoda.skyblock.blockscanner;
|
||||
|
||||
public class LocationBounds {
|
||||
private final int minX, minZ, maxX, maxZ;
|
||||
|
||||
public LocationBounds(int minX, int minZ, int maxX, int maxZ) {
|
||||
this.minX = minX;
|
||||
this.minZ = minZ;
|
||||
this.maxX = maxX;
|
||||
this.maxZ = maxZ;
|
||||
}
|
||||
|
||||
public int getMinX() {
|
||||
return minX;
|
||||
}
|
||||
|
||||
public int getMinZ() {
|
||||
return minZ;
|
||||
}
|
||||
|
||||
public int getMaxX() {
|
||||
return maxX;
|
||||
}
|
||||
|
||||
public int getMaxZ() {
|
||||
return maxZ;
|
||||
}
|
||||
}
|
@ -1,27 +1,22 @@
|
||||
package com.songoda.skyblock.blockscanner;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.songoda.skyblock.utils.version.NMSUtil;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public final class MaterialIDHelper {
|
||||
|
||||
private final static int VERSION = NMSUtil.getVersionNumber();
|
||||
|
||||
private MaterialIDHelper() {
|
||||
|
||||
}
|
||||
private MaterialIDHelper() {}
|
||||
|
||||
private final static Map<Integer, Material> MATERIALS;
|
||||
|
||||
static {
|
||||
MATERIALS = new HashMap<>();
|
||||
|
||||
if (VERSION > 12) {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
|
||||
for (Material type : Material.values()) {
|
||||
if (type.isLegacy()) MATERIALS.put(type.getId(), type);
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
package com.songoda.skyblock.challenge;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.challenge.challenge.ChallengeCategory;
|
||||
import com.songoda.skyblock.challenge.challenge.ChallengeManager;
|
||||
@ -10,23 +7,25 @@ import com.songoda.skyblock.challenge.defaultinv.DefaultInventory;
|
||||
import com.songoda.skyblock.challenge.inventory.InventoryManager;
|
||||
import com.songoda.skyblock.challenge.inventory.inv.ChallengeInventory;
|
||||
import com.songoda.skyblock.challenge.player.PlayerManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class FabledChallenge {
|
||||
private SkyBlock skyblock;
|
||||
private ChallengeManager challengeManager;
|
||||
private PlayerManager playerManager;
|
||||
private final SkyBlock plugin;
|
||||
private final ChallengeManager challengeManager;
|
||||
private final PlayerManager playerManager;
|
||||
// I use my own inventory api bc it's hard to implement inventories with the
|
||||
private InventoryManager inventoryManager;
|
||||
private DefaultInventory defaultInventory;
|
||||
private ChallengeInventory challengeInventory;
|
||||
private final InventoryManager inventoryManager;
|
||||
private final DefaultInventory defaultInventory;
|
||||
private final ChallengeInventory challengeInventory;
|
||||
|
||||
public FabledChallenge(SkyBlock skyblock) {
|
||||
this.skyblock = skyblock;
|
||||
this.defaultInventory = new DefaultInventory(skyblock);
|
||||
this.challengeManager = new ChallengeManager(skyblock);
|
||||
this.playerManager = new PlayerManager(skyblock);
|
||||
public FabledChallenge(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
this.defaultInventory = new DefaultInventory(plugin);
|
||||
this.challengeManager = new ChallengeManager(plugin);
|
||||
this.playerManager = new PlayerManager(plugin);
|
||||
this.challengeInventory = new ChallengeInventory(this);
|
||||
this.inventoryManager = new InventoryManager(skyblock);
|
||||
this.inventoryManager = new InventoryManager(plugin);
|
||||
this.inventoryManager.init();
|
||||
}
|
||||
|
||||
@ -37,7 +36,7 @@ public class FabledChallenge {
|
||||
public void openChallengeInventory(Player p, ChallengeCategory category) {
|
||||
if (category == null)
|
||||
return;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
|
||||
inventoryManager.openInventory(challengeInventory, p, params -> {
|
||||
params.put(ChallengeInventory.CATEGORY, category);
|
||||
});
|
||||
|
@ -1,11 +1,10 @@
|
||||
package com.songoda.skyblock.challenge.challenge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.hooks.economies.Economy;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.bank.BankManager;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -17,18 +16,22 @@ import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionData;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import com.songoda.skyblock.api.SkyBlockAPI;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Challenge {
|
||||
private ChallengeCategory category;
|
||||
private int id;
|
||||
private String name;
|
||||
private int maxTimes;
|
||||
private boolean showInChat;
|
||||
|
||||
private final ChallengeCategory category;
|
||||
private final int id;
|
||||
private final String name;
|
||||
private final int maxTimes;
|
||||
private final boolean showInChat;
|
||||
private List<Peer<Type, Object>> requires;
|
||||
private List<Peer<Type, Object>> rewards;
|
||||
private ItemChallenge item;
|
||||
private final ItemChallenge item;
|
||||
|
||||
public Challenge(ChallengeCategory category, int id, String name, int maxTimes, boolean showInChat,
|
||||
List<String> requires, List<String> rewards, ItemChallenge item) {
|
||||
@ -54,7 +57,7 @@ public class Challenge {
|
||||
String arg1 = str.substring(idx + 1);
|
||||
try {
|
||||
Type t = Type.valueOf(arg0);
|
||||
this.requires.add(new Peer<Type, Object>(t, t.convert(arg1)));
|
||||
this.requires.add(new Peer<>(t, t.convert(arg1)));
|
||||
} catch (IllegalArgumentException ex) {
|
||||
throw new IllegalArgumentException("Invalid line : " + str + " : " + ex.getMessage());
|
||||
} catch (Exception ex) {
|
||||
@ -70,7 +73,7 @@ public class Challenge {
|
||||
String arg1 = str.substring(idx + 1);
|
||||
try {
|
||||
Type t = Type.valueOf(arg0);
|
||||
this.rewards.add(new Peer<Type, Object>(t, t.convert(arg1)));
|
||||
this.rewards.add(new Peer<>(t, t.convert(arg1)));
|
||||
} catch (IllegalArgumentException ex) {
|
||||
throw new IllegalArgumentException("Invalid line : " + str + ": " + ex.getMessage());
|
||||
} catch (Exception ex) {
|
||||
@ -113,7 +116,7 @@ public class Challenge {
|
||||
return item;
|
||||
}
|
||||
|
||||
public static enum Type {
|
||||
public enum Type {
|
||||
ITEM {
|
||||
// An item
|
||||
|
||||
@ -121,7 +124,7 @@ public class Challenge {
|
||||
* Convert the value to a useable ItemStack
|
||||
*/
|
||||
@Override
|
||||
public Object convert(String value) throws IllegalArgumentException {
|
||||
public ItemStack convert(String value) throws IllegalArgumentException {
|
||||
if (value == null || "".equalsIgnoreCase(value.trim()))
|
||||
throw new IllegalArgumentException("Value is empty or null");
|
||||
int index = value.indexOf(' ');
|
||||
@ -148,35 +151,55 @@ public class Challenge {
|
||||
|
||||
@Override
|
||||
public boolean has(Player p, Object obj) {
|
||||
// Check if player has specific item in his inventory
|
||||
ItemStack is = (ItemStack) obj;
|
||||
return p.getInventory().containsAtLeast(new ItemStack(is.getType()), is.getAmount());
|
||||
boolean ignoreLore = SkyBlock.getInstance().getFileManager()
|
||||
.getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Challenge.IgnoreItemLore", false);
|
||||
if(obj instanceof ItemStack){
|
||||
// Check if player has specific item in his inventory
|
||||
ItemStack is = (ItemStack) obj;
|
||||
if(ignoreLore){
|
||||
return p.getInventory().contains(is.getType(), is.getAmount());
|
||||
}
|
||||
return p.getInventory().containsAtLeast(new ItemStack(is.getType()), is.getAmount());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRequire(Player p, Object obj) {
|
||||
boolean ignoreLore = SkyBlock.getInstance().getFileManager()
|
||||
.getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Challenge.IgnoreItemLore", false);
|
||||
|
||||
if(obj instanceof ItemStack){
|
||||
// Remove specific item in player's inventory
|
||||
ItemStack is = (ItemStack) obj;
|
||||
//p.getInventory().removeItem(new ItemStack(is.getType(), is.getAmount()));
|
||||
int toRemove = is.getAmount();
|
||||
for(ItemStack jis : p.getInventory().getContents()) {
|
||||
if(jis != null && jis.isSimilar(is)) {
|
||||
if(jis.getAmount() <= toRemove) {
|
||||
toRemove -= jis.getAmount();
|
||||
jis.setAmount(0);
|
||||
if(jis != null) {
|
||||
boolean isItem;
|
||||
if(ignoreLore){
|
||||
isItem = jis.getType().equals(is.getType());
|
||||
} else {
|
||||
jis.setAmount(jis.getAmount() - toRemove);
|
||||
toRemove = 0;
|
||||
isItem = jis.isSimilar(is);
|
||||
}
|
||||
|
||||
if(isItem) {
|
||||
if(jis.getAmount() <= toRemove) {
|
||||
toRemove -= jis.getAmount();
|
||||
p.getInventory().removeItem(jis);
|
||||
} else {
|
||||
jis.setAmount(jis.getAmount() - toRemove);
|
||||
toRemove = 0;
|
||||
}
|
||||
}
|
||||
if(toRemove <= 0) {
|
||||
p.updateInventory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(toRemove <= 0) {
|
||||
p.updateInventory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO LOG
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -187,14 +210,13 @@ public class Challenge {
|
||||
.addItem(new ItemStack(is.getType(), is.getAmount()));
|
||||
for (ItemStack restIs : rest.values())
|
||||
p.getWorld().dropItem(p.getLocation(), restIs);
|
||||
// TODO LOG
|
||||
}
|
||||
},
|
||||
CMD {
|
||||
// A command to execute
|
||||
|
||||
@Override
|
||||
public Object convert(String value) throws IllegalArgumentException {
|
||||
public String convert(String value) throws IllegalArgumentException {
|
||||
// Here we don't have to convert the value because the value is the command
|
||||
if (value == null || "".equalsIgnoreCase(value))
|
||||
throw new IllegalArgumentException("Value is empty or null");
|
||||
@ -223,7 +245,7 @@ public class Challenge {
|
||||
// The level of island of a player
|
||||
|
||||
@Override
|
||||
public Object convert(String value) throws IllegalArgumentException {
|
||||
public Integer convert(String value) throws IllegalArgumentException {
|
||||
// Convert the value to an Integer representing the minimum level of island
|
||||
// required
|
||||
if (value == null || "".equalsIgnoreCase(value))
|
||||
@ -240,11 +262,12 @@ public class Challenge {
|
||||
public boolean has(Player p, Object obj) {
|
||||
// Check if the level of player's island is greater or equals to the required
|
||||
// level
|
||||
Island is = SkyBlockAPI.getIslandManager().getIsland(p);
|
||||
Island is = SkyBlock.getInstance().getIslandManager().getIsland(p);
|
||||
// Player doesn't have an island
|
||||
if (is == null)
|
||||
return false;
|
||||
return is.getLevel().getLevel() >= (Integer) obj;
|
||||
if (is != null && obj instanceof Number) {
|
||||
return is.getLevel().getLevel() >= ((Number) obj).longValue();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -260,7 +283,7 @@ public class Challenge {
|
||||
NEAR {
|
||||
|
||||
@Override
|
||||
public Object convert(String value) throws IllegalArgumentException {
|
||||
public Peer<EntityType, Integer> convert(String value) throws IllegalArgumentException {
|
||||
// We returns the entity type and the number of entity required
|
||||
if (value == null || "".equalsIgnoreCase(value))
|
||||
throw new IllegalArgumentException("Value is empty or null");
|
||||
@ -318,7 +341,7 @@ public class Challenge {
|
||||
private Pattern space = Pattern.compile(" ");
|
||||
|
||||
@Override
|
||||
public Object convert(String value) throws IllegalArgumentException {
|
||||
public Peer<PotionType, Peer<Integer, Integer>> convert(String value) throws IllegalArgumentException {
|
||||
// We returns the potion required
|
||||
if (value == null || "".equalsIgnoreCase(value))
|
||||
throw new IllegalArgumentException("Value is empty or null");
|
||||
@ -334,9 +357,6 @@ public class Challenge {
|
||||
throw new IllegalArgumentException(
|
||||
"\"" + split[0] + "\" isn't a correct Minecraft PotionType (value = \"" + value + "\")");
|
||||
}
|
||||
if (pt == null)
|
||||
throw new IllegalArgumentException(
|
||||
"\"" + split[0] + "\" isn't a correct Minecraft PotionType (value = \"" + value + "\")");
|
||||
// The data
|
||||
int data;
|
||||
try {
|
||||
@ -354,7 +374,7 @@ public class Challenge {
|
||||
throw new IllegalArgumentException(
|
||||
"\"" + split[2] + "\" isn't a correct number (value = \"" + value + "\")");
|
||||
}
|
||||
return new Peer<PotionType, Peer<Integer, Integer>>(pt, new Peer<>(data, amount));
|
||||
return new Peer<>(pt, new Peer<>(data, amount));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -439,11 +459,6 @@ public class Challenge {
|
||||
* <li>7 = lingering extended</li>
|
||||
* <li>8 = lingering ++</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param is
|
||||
* @param type
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
private boolean isSame(ItemStack is, PotionType type, int data) {
|
||||
if (data <= 2 && is.getType() != Material.POTION)
|
||||
@ -460,9 +475,88 @@ public class Challenge {
|
||||
return false;
|
||||
else if ((data == 1 || data == 4 || data == 7) && !pd.isExtended())
|
||||
return false;
|
||||
else if ((data == 2 || data == 5 || data == 8) && !pd.isUpgraded())
|
||||
return false;
|
||||
return true;
|
||||
else return (data != 2 && data != 5 && data != 8) || pd.isUpgraded();
|
||||
}
|
||||
},
|
||||
ECO {
|
||||
@Override
|
||||
public Double convert(String value) throws IllegalArgumentException {
|
||||
if (value == null || "".equalsIgnoreCase(value))
|
||||
throw new IllegalArgumentException("Value is empty or null");
|
||||
try {
|
||||
return Double.parseDouble(value);
|
||||
} catch (NumberFormatException ex) {
|
||||
throw new IllegalArgumentException(
|
||||
"\"" + value + "\" isn't a correct number (value = \"" + value + "\")");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(Player p, Object obj) {
|
||||
Economy economy = SkyBlock.getInstance().getEconomyManager().getEconomy();
|
||||
if (obj instanceof Number) {
|
||||
return economy.getBalance(p) >= ((Number) obj).doubleValue();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRequire(Player p, Object obj) {
|
||||
Economy economy = SkyBlock.getInstance().getEconomyManager().getEconomy();
|
||||
if (obj instanceof Number && ((Number) obj).doubleValue() > 0) {
|
||||
economy.withdrawBalance(p, ((Number) obj).doubleValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeReward(Player p, Object obj) {
|
||||
Economy economy = SkyBlock.getInstance().getEconomyManager().getEconomy();
|
||||
if (obj instanceof Number && ((Number) obj).doubleValue() > 0) {
|
||||
economy.deposit(p, ((Number) obj).doubleValue());
|
||||
}
|
||||
}
|
||||
},
|
||||
BANK {
|
||||
@Override
|
||||
public Double convert(String value) throws IllegalArgumentException {
|
||||
if (value == null || "".equalsIgnoreCase(value))
|
||||
throw new IllegalArgumentException("Value is empty or null");
|
||||
try {
|
||||
return Double.parseDouble(value);
|
||||
} catch (NumberFormatException ex) {
|
||||
throw new IllegalArgumentException(
|
||||
"\"" + value + "\" isn't a correct number (value = \"" + value + "\")");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(Player p, Object obj) {
|
||||
Island is = SkyBlock.getInstance().getIslandManager().getIsland(p);
|
||||
|
||||
if (is != null && obj instanceof Number && ((Number) obj).doubleValue() > 0) {
|
||||
return is.getBankBalance() >= ((Number) obj).doubleValue();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRequire(Player p, Object obj) {
|
||||
Island is = SkyBlock.getInstance().getIslandManager().getIsland(p);
|
||||
BankManager bankManager = SkyBlock.getInstance().getBankManager();
|
||||
|
||||
if (is != null && obj instanceof Number && ((Number) obj).doubleValue() > 0) {
|
||||
bankManager.withdraw(p, is, ((Number) obj).doubleValue(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeReward(Player p, Object obj) {
|
||||
Island is = SkyBlock.getInstance().getIslandManager().getIsland(p);
|
||||
BankManager bankManager = SkyBlock.getInstance().getBankManager();
|
||||
|
||||
if (is != null && obj instanceof Number) {
|
||||
bankManager.deposit(p, is, ((Number) obj).doubleValue(), false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,17 +1,16 @@
|
||||
package com.songoda.skyblock.challenge.challenge;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
public class ChallengeCategory {
|
||||
private int id;
|
||||
private String name;
|
||||
@ -39,7 +38,15 @@ public class ChallengeCategory {
|
||||
String name = ChatColor.translateAlternateColorCodes('&', config.getString(key + ".name"));
|
||||
List<String> require = toColor(config.getStringList(key + ".require"));
|
||||
List<String> reward = toColor(config.getStringList(key + ".reward"));
|
||||
int maxTimes = config.getInt(key + ".maxtimes");
|
||||
int maxTimes = 0;
|
||||
try {
|
||||
Integer.parseInt(config.getString(key + ".maxtimes", "unlimited"));
|
||||
maxTimes = config.getInt(key + ".maxtimes");
|
||||
} catch(NumberFormatException ignored) {
|
||||
if(config.getString(key + ".maxtimes", "unlimited").equalsIgnoreCase("unlimited")) {
|
||||
maxTimes = Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
boolean showInChat = config.getBoolean(key + ".showInChat");
|
||||
// Item
|
||||
boolean show = config.getBoolean(key + ".item.show");
|
||||
|
@ -1,30 +1,28 @@
|
||||
package com.songoda.skyblock.challenge.challenge;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ChallengeManager {
|
||||
private SkyBlock skyblock;
|
||||
private SkyBlock plugin;
|
||||
private HashMap<Integer, ChallengeCategory> categories;
|
||||
|
||||
public ChallengeManager(SkyBlock skyblock) {
|
||||
this.skyblock = skyblock;
|
||||
public ChallengeManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
categories = new HashMap<>();
|
||||
loadChallenges();
|
||||
}
|
||||
|
||||
private void loadChallenges() {
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "challenges.yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "challenges.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
try {
|
||||
|
@ -1,18 +1,16 @@
|
||||
package com.songoda.skyblock.challenge.challenge;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ItemChallenge {
|
||||
private Challenge challenge;
|
||||
@ -40,14 +38,24 @@ public class ItemChallenge {
|
||||
}
|
||||
|
||||
public ItemStack createItem(UUID player, int amount) {
|
||||
FileManager.Config langConfig = SkyBlock.getInstance().getFileManager()
|
||||
.getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml"));
|
||||
FileConfiguration langConfigLoad = langConfig.getFileConfiguration();
|
||||
|
||||
ItemStack is = type.getItem();
|
||||
is.setAmount(this.amount);
|
||||
// Air
|
||||
ItemMeta im = is.getItemMeta();
|
||||
if (im != null) {
|
||||
String maxAmount;
|
||||
if(challenge.getMaxTimes() == Integer.MAX_VALUE) {
|
||||
maxAmount = langConfigLoad.getString("Challenge.Inventory.Unlimited.Message");
|
||||
} else {
|
||||
maxAmount = String.valueOf(challenge.getMaxTimes());
|
||||
}
|
||||
im.setDisplayName(ChatColor.translateAlternateColorCodes('&',
|
||||
itemTitle.replace("%challenge", challenge.getName()).replace("%amount", Integer.toString(amount))
|
||||
.replace("%max", Integer.toString(challenge.getMaxTimes()))));
|
||||
.replace("%max", maxAmount)));
|
||||
im.setLore(lore);
|
||||
is.setItemMeta(im);
|
||||
}
|
||||
|
@ -1,10 +1,8 @@
|
||||
package com.songoda.skyblock.challenge.defaultinv;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -13,16 +11,17 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DefaultInventory {
|
||||
private final Item defaultItem = new Item(new ItemStack(Material.AIR));
|
||||
private int size;
|
||||
private Item[][] items;
|
||||
|
||||
public DefaultInventory(SkyBlock skyblock) {
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "challenges.yml"));
|
||||
public DefaultInventory(SkyBlock plugin) {
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "challenges.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
size = configLoad.getInt("inventory.size");
|
||||
items = new Item[9][size];
|
||||
|
@ -3,11 +3,11 @@
|
||||
*/
|
||||
package com.songoda.skyblock.challenge.inventory;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ClickableItem {
|
||||
private ItemStack item;
|
||||
private Consumer<InventoryClickEvent> event;
|
||||
|
@ -3,15 +3,15 @@
|
||||
*/
|
||||
package com.songoda.skyblock.challenge.inventory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class Inventory {
|
||||
public static final String TICK = "tick";
|
||||
private HashMap<String, Object> values;
|
||||
|
@ -3,11 +3,7 @@
|
||||
*/
|
||||
package com.songoda.skyblock.challenge.inventory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -18,21 +14,24 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class InventoryManager implements Listener {
|
||||
private SkyBlock skyblock;
|
||||
private SkyBlock plugin;
|
||||
private HashMap<UUID, Inventory> inventories;
|
||||
private int task;
|
||||
|
||||
public InventoryManager(SkyBlock skyblock) {
|
||||
this.skyblock = skyblock;
|
||||
public InventoryManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
this.inventories = new HashMap<>();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
Bukkit.getPluginManager().registerEvents(this, skyblock);
|
||||
task = Bukkit.getScheduler().scheduleSyncRepeatingTask(skyblock, () -> {
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
|
||||
if (inventories.size() == 0)
|
||||
return;
|
||||
for (Inventory inv : inventories.values()) {
|
||||
|
@ -3,11 +3,11 @@
|
||||
*/
|
||||
package com.songoda.skyblock.challenge.inventory;
|
||||
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
|
||||
public interface InventoryProvider {
|
||||
|
||||
public String title(Inventory inv);
|
||||
|
@ -3,11 +3,8 @@
|
||||
*/
|
||||
package com.songoda.skyblock.challenge.inventory;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -15,8 +12,10 @@ import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ItemBuilder {
|
||||
private Material m;
|
||||
|
@ -1,18 +1,6 @@
|
||||
package com.songoda.skyblock.challenge.inventory.inv;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.songoda.skyblock.challenge.FabledChallenge;
|
||||
import com.songoda.skyblock.challenge.challenge.Challenge;
|
||||
import com.songoda.skyblock.challenge.challenge.ChallengeCategory;
|
||||
@ -22,8 +10,18 @@ import com.songoda.skyblock.challenge.defaultinv.Item;
|
||||
import com.songoda.skyblock.challenge.inventory.ClickableItem;
|
||||
import com.songoda.skyblock.challenge.inventory.Inventory;
|
||||
import com.songoda.skyblock.challenge.inventory.InventoryProvider;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ChallengeInventory implements InventoryProvider {
|
||||
public static final String CATEGORY = "ChallengeCategory";
|
||||
private FabledChallenge fc;
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.songoda.skyblock.challenge.player;
|
||||
|
||||
import com.songoda.skyblock.challenge.challenge.Challenge;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.songoda.skyblock.challenge.challenge.Challenge;
|
||||
|
||||
public class PlayerChallenge {
|
||||
private UUID uuid;
|
||||
private HashMap<Challenge, Integer> challenges;
|
||||
|
@ -1,5 +1,20 @@
|
||||
package com.songoda.skyblock.challenge.player;
|
||||
|
||||
import com.eatthepath.uuid.FastUUID;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.challenge.challenge.Challenge;
|
||||
import com.songoda.skyblock.challenge.challenge.Challenge.Type;
|
||||
import com.songoda.skyblock.challenge.challenge.ChallengeCategory;
|
||||
import com.songoda.skyblock.challenge.challenge.Peer;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
@ -7,33 +22,19 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.challenge.challenge.Challenge;
|
||||
import com.songoda.skyblock.challenge.challenge.Challenge.Type;
|
||||
import com.songoda.skyblock.challenge.challenge.ChallengeCategory;
|
||||
import com.songoda.skyblock.challenge.challenge.Peer;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
|
||||
public class PlayerManager {
|
||||
private SkyBlock skyblock;
|
||||
private SkyBlock plugin;
|
||||
private HashMap<UUID, HashMap<Challenge, Integer>> islands;
|
||||
private File playersDirectory;
|
||||
|
||||
public PlayerManager(SkyBlock skyblock) {
|
||||
this.skyblock = skyblock;
|
||||
public PlayerManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
islands = new HashMap<>();
|
||||
playersDirectory = new File(skyblock.getDataFolder(), "challenge-data");
|
||||
playersDirectory = new File(plugin.getDataFolder(), "challenge-data");
|
||||
if (!playersDirectory.exists())
|
||||
playersDirectory.mkdirs();
|
||||
|
||||
Bukkit.getScheduler().runTask(skyblock, () -> {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
for(Player p : Bukkit.getServer().getOnlinePlayers()){
|
||||
loadPlayer(p.getUniqueId());
|
||||
}
|
||||
@ -41,9 +42,13 @@ public class PlayerManager {
|
||||
}
|
||||
|
||||
public HashMap<Challenge, Integer> getPlayer(UUID uuid) {
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", false)) {
|
||||
OfflinePlayer player = Bukkit.getPlayer(uuid);
|
||||
if(player == null) {
|
||||
player = Bukkit.getOfflinePlayer(uuid);
|
||||
}
|
||||
Island is = plugin.getIslandManager().getIsland(player);
|
||||
if(is != null){
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
@ -58,22 +63,22 @@ public class PlayerManager {
|
||||
* The uuid of specific player
|
||||
*/
|
||||
public void loadPlayer(UUID uuid) {
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if(is != null){
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
Config config = skyblock.getFileManager().getConfig(new File(playersDirectory,
|
||||
uuid.toString() + ".yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(playersDirectory,
|
||||
FastUUID.toString(uuid) + ".yml"));
|
||||
FileConfiguration fileConfig = config.getFileConfiguration();
|
||||
HashMap<Challenge, Integer> challenges = new HashMap<>();
|
||||
ConfigurationSection section = fileConfig.getConfigurationSection("challenges");
|
||||
Set<String> strs = (section != null) ? section.getKeys(false) : new HashSet<>();
|
||||
for (String k : strs) {
|
||||
int id = fileConfig.getInt("challenges." + k + ".id");
|
||||
ChallengeCategory cc = skyblock.getFabledChallenge().getChallengeManager().getChallenge(id);
|
||||
ChallengeCategory cc = plugin.getFabledChallenge().getChallengeManager().getChallenge(id);
|
||||
// WTF
|
||||
if (cc == null)
|
||||
continue;
|
||||
@ -99,16 +104,24 @@ public class PlayerManager {
|
||||
* The uuid of specific player
|
||||
*/
|
||||
public void unloadPlayer(UUID uuid) {
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", false)) {
|
||||
OfflinePlayer player = Bukkit.getPlayer(uuid);
|
||||
if(player == null) {
|
||||
player = Bukkit.getOfflinePlayer(uuid);
|
||||
}
|
||||
Island is = plugin.getIslandManager().getIsland(player);
|
||||
if(is != null){
|
||||
uuid = is.getOwnerUUID();
|
||||
if (!plugin.getIslandManager().getMembersOnline(is).isEmpty()) {
|
||||
return;
|
||||
} else {
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
}
|
||||
islands.remove(uuid);
|
||||
skyblock.getFileManager().unloadConfig(new File(playersDirectory,
|
||||
uuid.toString() + ".yml"));
|
||||
plugin.getFileManager().unloadConfig(new File(playersDirectory,
|
||||
FastUUID.toString(uuid) + ".yml"));
|
||||
|
||||
}
|
||||
|
||||
@ -125,9 +138,9 @@ public class PlayerManager {
|
||||
if (c == null)
|
||||
return false;
|
||||
UUID uuid = p.getUniqueId();
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if(is != null){
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
@ -161,9 +174,9 @@ public class PlayerManager {
|
||||
if (!canDoChallenge(p, c))
|
||||
return false;
|
||||
UUID uuid = p.getUniqueId();
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if(is != null){
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
@ -173,10 +186,12 @@ public class PlayerManager {
|
||||
done.put(c, count + 1);
|
||||
addChallenge(uuid, c);
|
||||
// Take items
|
||||
for (Peer<Type, Object> peer : c.getRequires())
|
||||
for (Peer<Type, Object> peer : c.getRequires()) {
|
||||
peer.getKey().executeRequire(p, peer.getValue());
|
||||
for (Peer<Type, Object> peer : c.getRewards())
|
||||
}
|
||||
for (Peer<Type, Object> peer : c.getRewards()) {
|
||||
peer.getKey().executeReward(p, peer.getValue());
|
||||
}
|
||||
// Ok, send message
|
||||
String broadcast = ChatColor.translateAlternateColorCodes('&',
|
||||
SkyBlock.getInstance().getFileManager()
|
||||
@ -190,15 +205,15 @@ public class PlayerManager {
|
||||
}
|
||||
|
||||
public void addChallenge(UUID uuid, Challenge c) {
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if(is != null){
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
Config config = skyblock.getFileManager().getConfig(new File(playersDirectory,
|
||||
uuid.toString() + ".yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(playersDirectory,
|
||||
FastUUID.toString(uuid) + ".yml"));
|
||||
FileConfiguration fileConfig = config.getFileConfiguration();
|
||||
int ccId = c.getCategory().getId();
|
||||
int cId = c.getId();
|
||||
@ -209,7 +224,7 @@ public class PlayerManager {
|
||||
fileConfig.set("challenges." + ccId + ".challenges." + cId + ".id", cId);
|
||||
fileConfig.set("challenges." + ccId + ".challenges." + cId + ".count", count);
|
||||
try {
|
||||
fileConfig.save(new File(playersDirectory, uuid.toString() + ".yml"));
|
||||
fileConfig.save(new File(playersDirectory, FastUUID.toString(uuid) + ".yml"));
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@ -229,17 +244,17 @@ public class PlayerManager {
|
||||
if (challenges != null) {
|
||||
return challenges.getOrDefault(c, 0);
|
||||
} else {
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland", true)) {
|
||||
Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
|
||||
if(is != null){
|
||||
uuid = is.getOwnerUUID();
|
||||
}
|
||||
}
|
||||
|
||||
// Not connected, check in file
|
||||
Config config = skyblock.getFileManager().getConfig(new File(playersDirectory,
|
||||
uuid.toString() + ".yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(playersDirectory,
|
||||
FastUUID.toString(uuid) + ".yml"));
|
||||
FileConfiguration fileConfig = config.getFileConfiguration();
|
||||
int ccId = c.getCategory().getId();
|
||||
int cId = c.getId();
|
||||
|
@ -13,7 +13,6 @@ 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;
|
||||
@ -33,15 +32,15 @@ import java.util.List;
|
||||
|
||||
public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
|
||||
private final SkyBlock skyblock;
|
||||
private final SkyBlock plugin;
|
||||
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);
|
||||
public CommandManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
plugin.getCommand("island").setExecutor(this);
|
||||
plugin.getCommand("island").setTabCompleter(this);
|
||||
|
||||
registerSubCommands();
|
||||
}
|
||||
@ -89,7 +88,9 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
new VisitCommand(),
|
||||
new VisitorsCommand(),
|
||||
new VoteCommand(),
|
||||
new WeatherCommand()
|
||||
new ScoreboardCommand(),
|
||||
new WeatherCommand(),
|
||||
new WhitelistCommand()
|
||||
);
|
||||
|
||||
adminCommands = Arrays.asList(
|
||||
@ -114,19 +115,25 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
new StructureCommand(),
|
||||
new com.songoda.skyblock.command.commands.admin.UpgradeCommand(),
|
||||
new StackableCommand(),
|
||||
new AdminBank()
|
||||
new AdminBank(),
|
||||
new SetMaxMembers(),
|
||||
new ChatSpyCommand(),
|
||||
new UpdateAllIslandsCommand()
|
||||
);
|
||||
}
|
||||
|
||||
@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();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
Config languageConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration languageConfigLoad = languageConfig.getFileConfiguration();
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration mainConfig = config.getFileConfiguration();
|
||||
|
||||
Player player = null;
|
||||
|
||||
@ -138,22 +145,21 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
if (player == null) {
|
||||
sendConsoleHelpCommands(sender);
|
||||
} else {
|
||||
if (skyblock.getIslandManager().getIsland(player) == null) {
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> Bukkit.getServer().dispatchCommand(sender, "island create"));
|
||||
String commandToExecute;
|
||||
if (plugin.getIslandManager().getIsland(player) == null) {
|
||||
commandToExecute = mainConfig.getString("Command.Island.Aliases.NoIsland", "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, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
return true;
|
||||
}
|
||||
|
||||
ControlPanel.getInstance().open(player);
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F);
|
||||
commandToExecute = mainConfig.getString("Command.Island.Aliases.IslandOwned", "island controlpanel");
|
||||
}
|
||||
|
||||
if(commandToExecute.startsWith("/")) {
|
||||
commandToExecute = commandToExecute.substring(1);
|
||||
}
|
||||
|
||||
String finalCommandToExecute = commandToExecute;
|
||||
Bukkit.getServer().getScheduler().runTask(plugin, () ->
|
||||
Bukkit.getServer().dispatchCommand(sender,
|
||||
finalCommandToExecute));
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -171,15 +177,14 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
|| player.hasPermission("fabledskyblock.island.help");
|
||||
|
||||
if (!canUseHelp) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.PermissionDenied.Island.Message"));
|
||||
messageManager.sendMessage(player, languageConfigLoad.getString("Command.PermissionDenied.Island.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
return true;
|
||||
}
|
||||
|
||||
int page = -1;
|
||||
|
||||
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Command.Help.List")) {
|
||||
if (!mainConfig.getBoolean("Command.Help.List")) {
|
||||
page = 1;
|
||||
|
||||
if (args.length == 2) {
|
||||
@ -187,7 +192,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
page = Integer.valueOf(args[1]);
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Help.Integer.Message"));
|
||||
languageConfigLoad.getString("Command.Island.Help.Integer.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return true;
|
||||
@ -209,14 +214,14 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
|| player.hasPermission("fabledskyblock.admin.help");
|
||||
|
||||
if (!canUseHelp) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.PermissionDenied.Admin.Message"));
|
||||
messageManager.sendMessage(player, languageConfigLoad.getString("Command.PermissionDenied.Admin.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
return true;
|
||||
}
|
||||
|
||||
int page = -1;
|
||||
|
||||
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Command.Help.List")) {
|
||||
page = 1;
|
||||
|
||||
@ -225,7 +230,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
page = Integer.valueOf(args[2]);
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Help.Integer.Message"));
|
||||
languageConfigLoad.getString("Command.Island.Help.Integer.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
|
||||
1.0F);
|
||||
|
||||
@ -248,13 +253,13 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
}
|
||||
|
||||
if (subCommand == null) {
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Argument.Unrecognised.Message"));
|
||||
messageManager.sendMessage(sender, languageConfigLoad.getString("Command.Island.Argument.Unrecognised.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!subCommand.hasPermission(sender, isAdmin)) {
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.PermissionDenied." + (isAdmin ? "Admin" : "Island") + ".Message"));
|
||||
messageManager.sendMessage(sender, languageConfigLoad.getString("Command.PermissionDenied." + (isAdmin ? "Admin" : "Island") + ".Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
return true;
|
||||
}
|
||||
@ -391,21 +396,21 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
}
|
||||
|
||||
public void sendPlayerHelpCommands(Player player, List<SubCommand> subCommands, int page, boolean isAdmin) {
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.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"))
|
||||
boolean showAlises = fileManager.getConfig(new File(plugin.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, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
plugin.getMessageManager().sendMessage(player, configLoad.getString("Command.Island.Help.Page.Message"));
|
||||
plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -478,7 +483,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
skyblock.getMessageManager().sendMessage(player, helpLines);
|
||||
plugin.getMessageManager().sendMessage(player, helpLines);
|
||||
}
|
||||
}
|
||||
|
||||
@ -533,7 +538,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
}
|
||||
}
|
||||
|
||||
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
|
||||
plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
public void sendConsoleHelpCommands(CommandSender sender) {
|
||||
|
@ -10,12 +10,12 @@ import java.io.File;
|
||||
|
||||
public abstract class SubCommand {
|
||||
|
||||
protected final SkyBlock skyblock;
|
||||
protected final SkyBlock plugin;
|
||||
protected final String info;
|
||||
|
||||
public SubCommand() {
|
||||
this.skyblock = SkyBlock.getInstance();
|
||||
this.info = ChatColor.translateAlternateColorCodes('&', this.skyblock.getFileManager().getConfig(new File(this.skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString(this.getInfoMessagePath()));
|
||||
this.plugin = SkyBlock.getInstance();
|
||||
this.info = ChatColor.translateAlternateColorCodes('&', this.plugin.getFileManager().getConfig(new File(this.plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString(this.getInfoMessagePath()));
|
||||
}
|
||||
|
||||
public abstract void onCommandByPlayer(Player player, String[] args);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.eatthepath.uuid.FastUUID;
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
@ -35,13 +36,13 @@ public class AddUpgradeCommand extends SubCommand {
|
||||
}
|
||||
|
||||
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();
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 2) {
|
||||
@ -57,16 +58,12 @@ public class AddUpgradeCommand extends SubCommand {
|
||||
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;
|
||||
}
|
||||
for(Upgrade.Type type : Upgrade.Type.values()) {
|
||||
if(type.name().toUpperCase().equals(args[1].toUpperCase())) {
|
||||
upgrade = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,8 +89,8 @@ public class AddUpgradeCommand extends SubCommand {
|
||||
|
||||
island.setUpgrade(null, upgrade, true);
|
||||
} else {
|
||||
File islandDataFile = new File(skyblock.getDataFolder().toString() + "/island-data",
|
||||
islandOwnerUUID.toString() + ".yml");
|
||||
File islandDataFile = new File(plugin.getDataFolder().toString() + "/island-data",
|
||||
FastUUID.toString(islandOwnerUUID) + ".yml");
|
||||
|
||||
if (!fileManager.isFileExist(islandDataFile)) {
|
||||
messageManager.sendMessage(sender,
|
||||
|
@ -1,91 +1,115 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.songoda.core.hooks.economies.Economy;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.gui.bank.GuiBank;
|
||||
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 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.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AdminBank 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();
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
Economy economy = plugin.getEconomyManager().getEconomy();
|
||||
|
||||
FileManager.Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(player.getLocation());
|
||||
|
||||
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.Enable")) {
|
||||
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.Enable")) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Disabled.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length < 1) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.admin.Bank.Short01.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
|
||||
if (island == null && args.length <2) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.admin.Bank.NullIsland.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (args[0]) {
|
||||
case "balance":
|
||||
if (args.length <2) {
|
||||
messageManager.sendMessage(player, Objects.requireNonNull(configLoad.getString("Command.Island.Admin.Bank.Balance.Message")).replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(args[1])))));
|
||||
}else {
|
||||
messageManager.sendMessage(player, Objects.requireNonNull(configLoad.getString("Command.Island.Admin.Bank.Balance.Message")).replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(island.getOwnerUUID())))));
|
||||
}
|
||||
return;
|
||||
case "deposit":
|
||||
if (args.length >= 3) {
|
||||
islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Objects.requireNonNull(Bukkit.getPlayer(args[1])).getUniqueId())).addToBank(Double.parseDouble(args[2]));
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2]))));
|
||||
}else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.admin.Bank.ByConsole.Message"));
|
||||
}
|
||||
return;
|
||||
case "withdraw":
|
||||
if (args.length >= 3) {
|
||||
islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).removeFromBank(Double.parseDouble(args[2]));
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2]))));
|
||||
}else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.admin.Bank.ByConsole.Message"));
|
||||
}
|
||||
return;
|
||||
default:
|
||||
configLoad.getString("Command.Island.admin.Bank.Unexpected.Message");
|
||||
return;
|
||||
if (island != null){
|
||||
plugin.getGuiManager().showGUI(player, new GuiBank(plugin, island, null, true));
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.NullIsland.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f);
|
||||
}
|
||||
} else {
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "balance":
|
||||
if (args.length >= 3) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + economy.formatEconomy(economy.getBalance(Bukkit.getOfflinePlayer(island.getOwnerUUID())))));
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + economy.formatEconomy(economy.getBalance(Bukkit.getOfflinePlayer(args[1])))));
|
||||
}
|
||||
return;
|
||||
case "deposit":
|
||||
if (args.length >= 3) {
|
||||
islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).addToBank(Double.parseDouble(args[2]));
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",economy.formatEconomy(Double.parseDouble(args[2]))));
|
||||
}else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
|
||||
}
|
||||
return;
|
||||
case "withdraw":
|
||||
if (args.length >= 3) {
|
||||
islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).removeFromBank(Double.parseDouble(args[2]));
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%",args[1]).replace("%ammount%",economy.formatEconomy(Double.parseDouble(args[2]))));
|
||||
}else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
|
||||
}
|
||||
return;
|
||||
case "open":
|
||||
if(args.length == 2){
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[1]);
|
||||
UUID islandOwnerUUID;
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[1]);
|
||||
islandOwnerUUID = targetPlayerOffline.getOwner();
|
||||
} else {
|
||||
islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner();
|
||||
}
|
||||
|
||||
island = islandManager.getIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
||||
}
|
||||
if (island != null){
|
||||
plugin.getGuiManager().showGUI(player, new GuiBank(plugin, island, null, true));
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.NullIsland.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Unexpected.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
Economy economy = plugin.getEconomyManager().getEconomy();
|
||||
|
||||
FileManager.Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length < 2) {
|
||||
@ -94,27 +118,26 @@ public class AdminBank extends SubCommand {
|
||||
}
|
||||
switch (args[0]) {
|
||||
case "balance":
|
||||
messageManager.sendMessage(sender,configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%",args[1]).replace("%bal%",""+ EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(args[1])))));
|
||||
messageManager.sendMessage(sender,configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%",args[1]).replace("%bal%",""+ economy.formatEconomy(economy.getBalance(Bukkit.getOfflinePlayer(args[1])))));
|
||||
return;
|
||||
case "deposit":
|
||||
if (args.length >= 3) {
|
||||
islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).addToBank(Double.parseDouble(args[2]));
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2]))));
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",economy.formatEconomy(Double.parseDouble(args[2]))));
|
||||
}else {
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.admin.Bank.ByConsole.Message"));
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
|
||||
}
|
||||
return;
|
||||
case "withdraw":
|
||||
if (args.length >= 3) {
|
||||
islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).removeFromBank(Double.parseDouble(args[2]));
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2]))));
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%",args[1]).replace("%ammount%",economy.formatEconomy(Double.parseDouble(args[2]))));
|
||||
}else {
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.admin.Bank.ByConsole.Message"));
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
|
||||
}
|
||||
return;
|
||||
default:
|
||||
configLoad.getString("Command.Island.admin.Bank.Unexpected.Message");
|
||||
return;
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.Unexpected.Message"));
|
||||
}
|
||||
|
||||
}
|
||||
@ -136,6 +159,6 @@ public class AdminBank extends SubCommand {
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
return new String[]{"withdraw", "deposit", "balance", "open"};
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,141 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
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.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 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 ChatSpyCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
FileManager.Config language = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration languageLoad = language.getFileConfiguration();
|
||||
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
if (args.length < 1) {
|
||||
toggleSpy(player, messageManager, languageLoad, playerData);
|
||||
} else {
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "toggle":
|
||||
toggleSpy(player, messageManager, languageLoad, playerData);
|
||||
break;
|
||||
case "global":
|
||||
if(!playerData.isGlobalChatSpy()){
|
||||
playerData.enableGlobalChatSpy();
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.GlobalEnabled.Message"));
|
||||
} else {
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.GlobalAlreadyEnabled.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f);
|
||||
}
|
||||
break;
|
||||
case "add":
|
||||
if(args.length == 2){
|
||||
OfflinePlayer offlinePlayer = new OfflinePlayer(args[1]);
|
||||
Island island = islandManager.getIslandByPlayer(offlinePlayer.getBukkitOfflinePlayer());
|
||||
if(island != null) {
|
||||
playerData.addChatSpyIsland(island);
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.Add.Message")
|
||||
.replace("%owner", new OfflinePlayer(island.getOwnerUUID()).getName()));
|
||||
} else {
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.NullIsland.Message"));
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.InvalidArgNumber.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f);
|
||||
}
|
||||
break;
|
||||
case "remove":
|
||||
if(args.length == 2){
|
||||
OfflinePlayer offlinePlayer = new OfflinePlayer(args[1]);
|
||||
Island island = islandManager.getIslandByPlayer(offlinePlayer.getBukkitOfflinePlayer());
|
||||
if(island != null) {
|
||||
playerData.removeChatSpyIsland(island);
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.Remove.Message")
|
||||
.replace("%owner", new OfflinePlayer(island.getOwnerUUID()).getName()));
|
||||
} else {
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.NullIsland.Message"));
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.InvalidArgNumber.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f);
|
||||
}
|
||||
break;
|
||||
case "list":
|
||||
Set<UUID> uuidSet = playerData.getChatSpyIslands();
|
||||
if(!uuidSet.isEmpty()){
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.List.Start.Message"));
|
||||
for(UUID uuid : uuidSet) {
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.List.List.Message")
|
||||
.replace("%owner", new OfflinePlayer(uuid).getName()));
|
||||
}
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.List.End.Message"));
|
||||
} else {
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.List.Empty.Message"));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.InvalidArgNumber.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleSpy(Player player, MessageManager messageManager, FileConfiguration languageLoad, PlayerData playerData) {
|
||||
if(playerData != null) {
|
||||
if(playerData.isChatSpy()){
|
||||
playerData.setChatSpy(false);
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.Disabled.Message"));
|
||||
} else {
|
||||
playerData.setChatSpy(true);
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.Enabled.Message"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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 "chatspy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Admin.ChatSpy.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[]{"spychat", "spy"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[]{"toggle", "global", "add", "remove", "list"};
|
||||
}
|
||||
}
|
@ -12,8 +12,8 @@ public class CreateCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
playerDataManager.getPlayerData(player).setViewer(null);
|
||||
|
@ -35,12 +35,12 @@ public class DeleteCommand extends SubCommand {
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Player player = null;
|
||||
@ -68,7 +68,8 @@ public class DeleteCommand extends SubCommand {
|
||||
configLoad.getString("Command.Island.Admin.Delete.Owner.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
Island island = islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(targetPlayerUUID));
|
||||
islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(targetPlayerUUID));
|
||||
Island island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(targetPlayerUUID));
|
||||
Location spawnLocation = LocationUtil.getSpawnLocation();
|
||||
|
||||
if (spawnLocation != null && islandManager.isLocationAtIsland(island, spawnLocation)) {
|
||||
|
@ -18,15 +18,15 @@ 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();
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (skyblock.getGeneratorManager() == null) {
|
||||
if (plugin.getGeneratorManager() == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Generator.Disabled.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
|
@ -11,7 +11,7 @@ public class LevelCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
Levelling.getInstance().open(player);
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F);
|
||||
|
@ -5,7 +5,7 @@ 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.rework.IslandLevelManager;
|
||||
import com.songoda.skyblock.levelling.IslandLevelManager;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -30,13 +30,13 @@ public class LevelScanCommand extends SubCommand {
|
||||
}
|
||||
|
||||
private void onCommand(CommandSender sender, String[] args) {
|
||||
IslandLevelManager levellingManager = skyblock.getLevellingManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
IslandLevelManager levellingManager = plugin.getLevellingManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
FileManager.Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 0) {
|
||||
@ -72,7 +72,7 @@ public class LevelScanCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
return new String[]{"scanlevel"};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,12 +30,12 @@ public class OwnerCommand extends SubCommand {
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
|
@ -8,6 +8,7 @@ import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -29,19 +30,20 @@ public class ProxyCommand extends SubCommand {
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
|
||||
UUID islandOwnerUUID = targetPlayerOffline.getOwner();
|
||||
|
||||
if (islandManager.containsIsland(islandOwnerUUID)) {
|
||||
UUID userUUID = targetPlayerOffline.getUUID();
|
||||
|
||||
if (islandManager.getIsland(Bukkit.getOfflinePlayer(userUUID)) != null) {
|
||||
if (islandManager.isPlayerProxyingAnotherPlayer(((Player)sender).getUniqueId())) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.Proxy.IsOffPlayer.Message")
|
||||
@ -55,7 +57,7 @@ public class ProxyCommand extends SubCommand {
|
||||
.replace("%player", targetPlayerOffline.getName()));
|
||||
soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
||||
islandManager.addProxiedPlayer(((Player)sender).getUniqueId(), targetPlayerOffline.getUniqueId());
|
||||
islandManager.addProxiedPlayer(((Player)sender).getUniqueId(), userUUID);
|
||||
}
|
||||
}
|
||||
} else if (args.length == 0){
|
||||
|
@ -28,20 +28,20 @@ public class RefreshHologramsCommand extends SubCommand {
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||
LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
LeaderboardManager leaderboardManager = plugin.getLeaderboardManager();
|
||||
leaderboardManager.clearLeaderboard();
|
||||
leaderboardManager.resetLeaderboard();
|
||||
leaderboardManager.setupLeaderHeads();
|
||||
|
||||
Bukkit.getScheduler().runTask(skyblock, () -> skyblock.getHologramTask().updateHologram());
|
||||
Bukkit.getScheduler().runTask(plugin, () -> plugin.getHologramTask().updateHologram());
|
||||
});
|
||||
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.RefreshHolograms.Refreshed.Message"));
|
||||
|
@ -1,52 +1,51 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
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.island.reward.RewardManager;
|
||||
import com.songoda.skyblock.leaderboard.LeaderboardManager;
|
||||
import com.songoda.skyblock.levelling.IslandLevelManager;
|
||||
import com.songoda.skyblock.limit.LimitationInstanceHandler;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.scoreboard.ScoreboardManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.item.MenuClickRegistry;
|
||||
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 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.leaderboard.LeaderboardManager;
|
||||
import com.songoda.skyblock.levelling.rework.IslandLevelManager;
|
||||
import com.songoda.skyblock.limit.LimitationInstanceHandler;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.scoreboard.ScoreboardManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.item.MenuClickRegistry;
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
public class ReloadCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
onCommand(player, args);
|
||||
onCommand(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
onCommand(sender, args);
|
||||
onCommand(sender);
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
LimitationInstanceHandler limitHandler = skyblock.getLimitationHandler();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
public void onCommand(CommandSender sender) {
|
||||
LeaderboardManager leaderboardManager = plugin.getLeaderboardManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
LimitationInstanceHandler limitHandler = plugin.getLimitationHandler();
|
||||
FileManager fileManager = plugin.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"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Map<String, Config> configs = fileManager.getConfigs();
|
||||
@ -56,48 +55,48 @@ public class ReloadCommand extends SubCommand {
|
||||
Config configFileConfig = configs.get(configFileName);
|
||||
String configFilePath = configFileName.replace(configFileConfig.getFile().getName(), "");
|
||||
|
||||
if (configFilePath.equals(skyblock.getDataFolder().toString() + "\\") || configFilePath.equals(skyblock.getDataFolder().toString() + "/")) {
|
||||
if (configFilePath.equals(plugin.getDataFolder().toString() + "\\") || configFilePath.equals(plugin.getDataFolder().toString() + "/")) {
|
||||
configFileConfig.loadFile();
|
||||
}
|
||||
}
|
||||
|
||||
Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
FileConfiguration mainConfigLoad = mainConfig.getFileConfiguration();
|
||||
|
||||
if (skyblock.getScoreboardManager() == null) {
|
||||
if (plugin.getScoreboardManager() == null) {
|
||||
if (mainConfigLoad.getBoolean("Island.Scoreboard.Enable")) {
|
||||
skyblock.setScoreboardManager(new ScoreboardManager(skyblock));
|
||||
plugin.setScoreboardManager(new ScoreboardManager(plugin));
|
||||
}
|
||||
} else {
|
||||
skyblock.getScoreboardManager().updateScoreboards(false);
|
||||
plugin.getScoreboardManager().reload();
|
||||
}
|
||||
|
||||
if (skyblock.getGeneratorManager() == null) {
|
||||
if (plugin.getGeneratorManager() == null) {
|
||||
if (mainConfigLoad.getBoolean("Island.Generator.Enable")) {
|
||||
skyblock.setGeneratorManager(new GeneratorManager(skyblock));
|
||||
plugin.setGeneratorManager(new GeneratorManager(plugin));
|
||||
}
|
||||
} else {
|
||||
GeneratorManager generatorManager = skyblock.getGeneratorManager();
|
||||
GeneratorManager generatorManager = plugin.getGeneratorManager();
|
||||
generatorManager.unregisterGenerators();
|
||||
generatorManager.registerGenerators();
|
||||
}
|
||||
|
||||
IslandLevelManager levellingManager = skyblock.getLevellingManager();
|
||||
IslandLevelManager levellingManager = plugin.getLevellingManager();
|
||||
levellingManager.reloadWorth();
|
||||
|
||||
RewardManager rewardManager = skyblock.getRewardManager();
|
||||
RewardManager rewardManager = plugin.getRewardManager();
|
||||
rewardManager.loadRewards();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
leaderboardManager.clearLeaderboard();
|
||||
leaderboardManager.resetLeaderboard();
|
||||
leaderboardManager.setupLeaderHeads();
|
||||
|
||||
Bukkit.getScheduler().runTask(skyblock, () -> skyblock.getHologramTask().updateHologram());
|
||||
Bukkit.getScheduler().runTask(plugin, () -> plugin.getHologramTask().updateHologram());
|
||||
});
|
||||
|
||||
limitHandler.reloadAll();
|
||||
skyblock.getLocalizationManager().reloadAll();
|
||||
plugin.getLocalizationManager().reloadAll();
|
||||
MenuClickRegistry.getInstance().reloadAll();
|
||||
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Reload.Reloaded.Message"));
|
||||
|
@ -5,11 +5,10 @@ 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.tasks.HologramTask;
|
||||
import com.songoda.skyblock.hologram.HologramType;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
|
||||
import com.songoda.skyblock.tasks.HologramTask;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -33,12 +32,12 @@ public class RemoveHologramCommand extends SubCommand {
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
HologramTask hologramManager = skyblock.getHologramTask();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
HologramTask hologramManager = plugin.getHologramTask();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
@ -57,7 +56,7 @@ public class RemoveHologramCommand extends SubCommand {
|
||||
}
|
||||
|
||||
if (hologramType != null) {
|
||||
Config locationsConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml"));
|
||||
Config locationsConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "locations.yml"));
|
||||
FileConfiguration locationsConfigLoad = locationsConfig.getFileConfiguration();
|
||||
|
||||
if (locationsConfigLoad.getString("Location.Hologram.Leaderboard." + hologramType.name()) == null) {
|
||||
@ -72,7 +71,7 @@ public class RemoveHologramCommand extends SubCommand {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
|
||||
Bukkit.getServer().getScheduler().runTask(plugin, () -> {
|
||||
HologramType hologramType1 = HologramType.valueOf(WordUtils.capitalize(args[0].toLowerCase()));
|
||||
Hologram hologram = hologramManager.getHologram(hologramType1);
|
||||
|
||||
|
@ -35,13 +35,13 @@ public class RemoveUpgradeCommand extends SubCommand {
|
||||
}
|
||||
|
||||
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();
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 2) {
|
||||
@ -57,16 +57,12 @@ public class RemoveUpgradeCommand extends SubCommand {
|
||||
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;
|
||||
}
|
||||
for(Upgrade.Type type : Upgrade.Type.values()) {
|
||||
if(type.name().toUpperCase().equals(args[1].toUpperCase())) {
|
||||
upgrade = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,7 +88,7 @@ public class RemoveUpgradeCommand extends SubCommand {
|
||||
|
||||
island.removeUpgrade(upgrade);
|
||||
} else {
|
||||
File islandDataFile = new File(skyblock.getDataFolder().toString() + "/island-data",
|
||||
File islandDataFile = new File(plugin.getDataFolder().toString() + "/island-data",
|
||||
islandOwnerUUID.toString() + ".yml");
|
||||
|
||||
if (!fileManager.isFileExist(islandDataFile)) {
|
||||
|
@ -1,15 +1,6 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
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 com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
@ -19,6 +10,14 @@ 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 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 SetAlwaysLoadedCommand extends SubCommand {
|
||||
|
||||
@ -34,10 +33,10 @@ public class SetAlwaysLoadedCommand extends SubCommand {
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
|
||||
if (args.length == 0) {
|
||||
messageManager.sendMessage(sender,
|
||||
@ -45,9 +44,9 @@ public class SetAlwaysLoadedCommand extends SubCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
if (args.length == 1) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleBiome;
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.biome.BiomeManager;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
@ -7,11 +8,12 @@ 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.IslandWorld;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.StringUtil;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import com.songoda.skyblock.utils.version.SBiome;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
@ -34,23 +36,37 @@ public class SetBiomeCommand extends SubCommand {
|
||||
}
|
||||
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
BiomeManager biomeManager = skyblock.getBiomeManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
BiomeManager biomeManager = plugin.getBiomeManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 2) {
|
||||
|
||||
if (args.length >= 2) {
|
||||
String biomeName = args[1].toUpperCase().trim();
|
||||
|
||||
SBiome biome = null;
|
||||
for (SBiome sbiome : SBiome.values()) {
|
||||
if (sbiome.isAvailable() && sbiome.name().equals(biomeName)) {
|
||||
biome = sbiome;
|
||||
|
||||
IslandWorld world = null;
|
||||
if(args[2] != null) {
|
||||
String worldName = args[2].toUpperCase().trim();
|
||||
for(IslandWorld islandWorld : IslandWorld.values()) {
|
||||
if(islandWorld.name().equalsIgnoreCase(worldName)) {
|
||||
world = islandWorld;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(world == null) {
|
||||
world = IslandWorld.Normal;
|
||||
}
|
||||
|
||||
CompatibleBiome biome = null;
|
||||
for (CompatibleBiome cbiome : CompatibleBiome.values()) {
|
||||
if (cbiome.isCompatible() && cbiome.name().equals(biomeName)) {
|
||||
biome = cbiome;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -76,24 +92,32 @@ public class SetBiomeCommand extends SubCommand {
|
||||
} else {
|
||||
if (islandManager.containsIsland(islandOwnerUUID)) {
|
||||
Island island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
|
||||
biomeManager.setBiome(island, biome.getBiome());
|
||||
island.setBiome(biome.getBiome());
|
||||
biomeManager.setBiome(island, world, biome.getBiome(), null);
|
||||
if(world.equals(IslandWorld.Normal)) {
|
||||
island.setBiome(biome.getBiome());
|
||||
}
|
||||
} else {
|
||||
Island island = islandManager.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
||||
islandManager.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
||||
Island island = islandManager.getIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.SetBiome.Island.Data.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
biomeManager.setBiome(island, biome.getBiome());
|
||||
island.setBiome(biome.getBiome());
|
||||
CompatibleBiome finalBiome = biome;
|
||||
IslandWorld finalWorld = world;
|
||||
biomeManager.setBiome(island, world, biome.getBiome(), () -> {
|
||||
if(finalWorld.equals(IslandWorld.Normal)) {
|
||||
island.setBiome(finalBiome.getBiome());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.SetBiome.Set.Message")
|
||||
.replace("%player", targetPlayerName)
|
||||
.replace("%biome", biome.getFormattedBiomeName()));
|
||||
.replace("%biome", StringUtil.capitalizeWord(biome.getBiome().name().replaceAll("_", " "))));
|
||||
soundManager.playSound(sender, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
|
@ -21,12 +21,12 @@ public class SetHologramCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
HologramTask hologramManager = skyblock.getHologramTask();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
HologramTask hologramManager = plugin.getHologramTask();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
@ -46,11 +46,11 @@ public class SetHologramCommand extends SubCommand {
|
||||
|
||||
if (hologramType != null) {
|
||||
fileManager.setLocation(
|
||||
fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml")),
|
||||
fileManager.getConfig(new File(plugin.getDataFolder(), "locations.yml")),
|
||||
"Location.Hologram.Leaderboard." + hologramType.name(), player.getLocation(), true);
|
||||
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
|
||||
Bukkit.getServer().getScheduler().runTask(plugin, () -> {
|
||||
HologramType hologramType1 = HologramType.valueOf(WordUtils.capitalize(args[0].toLowerCase()));
|
||||
Hologram hologram = hologramManager.getHologram(hologramType1);
|
||||
|
||||
|
@ -0,0 +1,147 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
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 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 SetMaxMembers 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 = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (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 maxMembers = Integer.valueOf(args[1]);
|
||||
|
||||
if (islandOwnerUUID == null) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.SetMaxMembers.Island.Owner.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
} else if (maxMembers <= 0) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.SetMaxMembers.Members.Greater.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
} else if (maxMembers > 100000) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.SetMaxMembers.Members.Less.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
if (islandManager.containsIsland(islandOwnerUUID)) {
|
||||
Island island = islandManager
|
||||
.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
|
||||
island.setMaxMembers(maxMembers);
|
||||
|
||||
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.WorldBorder.Enable")
|
||||
&& island.isBorder()) {
|
||||
islandManager.updateBorder(island);
|
||||
}
|
||||
} else {
|
||||
File islandDataFile = new File(plugin.getDataFolder().toString() + "/island-data",
|
||||
islandOwnerUUID.toString() + ".yml");
|
||||
|
||||
if (!fileManager.isFileExist(islandDataFile)) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.SetMaxMembers.Island.Data.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
FileConfiguration islandDataConfigLoad = YamlConfiguration
|
||||
.loadConfiguration(islandDataFile);
|
||||
islandDataConfigLoad.set("MaxMembers", maxMembers);
|
||||
|
||||
try {
|
||||
islandDataConfigLoad.save(islandDataFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.SetMaxMembers.Set.Message")
|
||||
.replace("%player", targetPlayerName)
|
||||
.replace("%maxMembers", NumberUtil.formatNumberByDecimal(maxMembers)));
|
||||
soundManager.playSound(sender, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.SetMaxMembers.Numerical.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.SetMaxMembers.Invalid.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "setmaxmembers";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Admin.SetMaxMembers.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
@ -35,13 +35,13 @@ public class SetSizeCommand extends SubCommand {
|
||||
}
|
||||
|
||||
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();
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 2) {
|
||||
@ -79,13 +79,13 @@ public class SetSizeCommand extends SubCommand {
|
||||
.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
|
||||
island.setSize(size);
|
||||
|
||||
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.WorldBorder.Enable")
|
||||
&& island.isBorder()) {
|
||||
islandManager.updateBorder(island);
|
||||
}
|
||||
} else {
|
||||
File islandDataFile = new File(skyblock.getDataFolder().toString() + "/island-data",
|
||||
File islandDataFile = new File(plugin.getDataFolder().toString() + "/island-data",
|
||||
islandOwnerUUID.toString() + ".yml");
|
||||
|
||||
if (!fileManager.isFileExist(islandDataFile)) {
|
||||
|
@ -16,14 +16,14 @@ 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();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
fileManager.setLocation(fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml")),
|
||||
fileManager.setLocation(fileManager.getConfig(new File(plugin.getDataFolder(), "locations.yml")),
|
||||
"Location.Spawn", player.getLocation(), true);
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.SetSpawn.Set.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_PLAYER_LEVELUP.getSound(), 1.0F, 1.0F);
|
||||
|
@ -2,7 +2,7 @@ package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.menus.admin.Settings;
|
||||
import com.songoda.skyblock.gui.permissions.GuiPermissionsSelector;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -11,9 +11,9 @@ public class SettingsCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
Settings.getInstance().open(player, Settings.Type.Categories, null);
|
||||
plugin.getGuiManager().showGUI(player, new GuiPermissionsSelector(plugin, player, null, null));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
|
@ -1,20 +1,18 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.stackable.Stackable;
|
||||
import com.songoda.skyblock.stackable.StackableManager;
|
||||
import com.songoda.skyblock.utils.StringUtil;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
||||
public class StackableCommand extends SubCommand {
|
||||
@ -22,14 +20,14 @@ public class StackableCommand extends SubCommand {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
final MessageManager messageManager = skyblock.getMessageManager();
|
||||
final MessageManager messageManager = plugin.getMessageManager();
|
||||
|
||||
if (args.length == 0) {
|
||||
player.sendMessage(StringUtil.color("&e/island admin stackable setsize <size> &7- &f&osets the target block's stack size if applicable"));
|
||||
return;
|
||||
}
|
||||
|
||||
final FileConfiguration messageConfig = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
final FileConfiguration messageConfig = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
|
||||
if (args[0].equalsIgnoreCase("setsize")) {
|
||||
|
||||
@ -54,7 +52,7 @@ public class StackableCommand extends SubCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final StackableManager stackableManager = skyblock.getStackableManager();
|
||||
final StackableManager stackableManager = plugin.getStackableManager();
|
||||
final CompatibleMaterial type = CompatibleMaterial.getMaterial(block.getType());
|
||||
|
||||
if (!stackableManager.isStackableMaterial(type)) {
|
||||
|
@ -10,8 +10,6 @@ import com.songoda.skyblock.utils.ChatComponent;
|
||||
import com.songoda.skyblock.utils.Compression;
|
||||
import com.songoda.skyblock.utils.structure.StructureUtil;
|
||||
import com.songoda.skyblock.utils.world.LocationUtil;
|
||||
import java.io.*;
|
||||
import java.util.Base64;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
@ -22,16 +20,21 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Base64;
|
||||
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();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 0 || args[0].equalsIgnoreCase("help")) {
|
||||
@ -140,7 +143,7 @@ public class StructureCommand extends SubCommand {
|
||||
return;
|
||||
} else if (args[0].equalsIgnoreCase("save")) {
|
||||
if (args.length == 2) {
|
||||
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||
PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
Location position1Location = playerData.getArea().getPosition(1);
|
||||
Location position2Location = playerData.getArea().getPosition(2);
|
||||
@ -171,7 +174,7 @@ public class StructureCommand extends SubCommand {
|
||||
} else {
|
||||
try {
|
||||
File configFile = new File(
|
||||
skyblock.getDataFolder().toString() + "/structures/" + args[1] + ".structure");
|
||||
plugin.getDataFolder().toString() + "/structures/" + args[1] + ".structure");
|
||||
StructureUtil.saveStructure(configFile, player.getLocation(),
|
||||
StructureUtil.getFixedLocations(position1Location, position2Location));
|
||||
|
||||
@ -198,7 +201,7 @@ public class StructureCommand extends SubCommand {
|
||||
|
||||
} else if (args[0].equalsIgnoreCase("convert")) {
|
||||
if (args.length == 2) {
|
||||
File structureFile = new File(new File(skyblock.getDataFolder().toString() + "/structures"), args[1]);
|
||||
File structureFile = new File(new File(plugin.getDataFolder().toString() + "/structures"), args[1]);
|
||||
if (!structureFile.exists()) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Admin.Structure.Convert.Invalid.Message")
|
||||
|
@ -0,0 +1,98 @@
|
||||
package com.songoda.skyblock.command.commands.admin;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
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 UpdateAllIslandsCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
processCommand(player, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
processCommand(sender, args);
|
||||
}
|
||||
|
||||
public void processCommand(CommandSender sender, String[] args) {
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length < 1) {
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.UpdateAllIslands.NoArgs.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f);
|
||||
} else {
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "setsize":
|
||||
if (args.length >= 2) {
|
||||
int size;
|
||||
try {
|
||||
size = Integer.parseInt(args[1]);
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.UpdateAllIslands.Start.Message"));
|
||||
islandManager.setAllIslandsSize(Math.abs(size), () ->
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.UpdateAllIslands.Finished.Message")));
|
||||
} catch (NumberFormatException ignored) {
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.UpdateAllIslands.Unexpected.Message"));
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.UpdateAllIslands.NotANumber.Message"));
|
||||
}
|
||||
return;
|
||||
case "adjustsize":
|
||||
if (args.length >= 2) {
|
||||
int size;
|
||||
try {
|
||||
size = Integer.parseInt(args[1]);
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.UpdateAllIslands.Start.Message"));
|
||||
islandManager.adjustAllIslandsSize(size, () ->
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.UpdateAllIslands.Finished.Message")));
|
||||
} catch (NumberFormatException ignored) {
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.UpdateAllIslands.NotANumber.Message"));
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.UpdateAllIslands.Unexpected.Message"));
|
||||
}
|
||||
return;
|
||||
default:
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.UpdateAllIslands.Unexpected.Message"));
|
||||
soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "updateallislands";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Island.Admin.UpdateAllIslands.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[] {"SetSize", "AdjustSize"};
|
||||
}
|
||||
}
|
@ -18,15 +18,15 @@ 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();
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (skyblock.getUpgradeManager() == null) {
|
||||
if (plugin.getUpgradeManager() == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Upgrade.Disabled.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
|
@ -13,7 +13,6 @@ 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 org.bukkit.Bukkit;
|
||||
@ -32,20 +31,20 @@ 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();
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
ScoreboardManager scoreboardManager = plugin.getScoreboardManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
InviteManager inviteManager = skyblock.getInviteManager();
|
||||
InviteManager inviteManager = plugin.getInviteManager();
|
||||
|
||||
if (inviteManager.hasInvite(player.getUniqueId())) {
|
||||
Invite invite = inviteManager.getInvite(player.getUniqueId());
|
||||
@ -62,8 +61,8 @@ public class AcceptCommand extends SubCommand {
|
||||
island = islandManager
|
||||
.getIsland(Bukkit.getServer().getOfflinePlayer(invite.getOwnerUUID()));
|
||||
} else {
|
||||
island = islandManager
|
||||
.loadIsland(Bukkit.getServer().getOfflinePlayer(invite.getOwnerUUID()));
|
||||
islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(invite.getOwnerUUID()));
|
||||
island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(invite.getOwnerUUID()));
|
||||
unloadIsland = true;
|
||||
}
|
||||
|
||||
@ -99,8 +98,7 @@ public class AcceptCommand extends SubCommand {
|
||||
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")) {
|
||||
+ 1) >= island.getMaxMembers()) {
|
||||
Map<UUID, Invite> invites = inviteManager.getInvites();
|
||||
|
||||
for (UUID inviteList : invites.keySet()) {
|
||||
@ -123,66 +121,36 @@ public class AcceptCommand extends SubCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
skyblock.getVisitManager().getIsland(invite.getOwnerUUID())
|
||||
|
||||
plugin.getVisitManager().getIsland(invite.getOwnerUUID())
|
||||
.removeVoter(player.getUniqueId());
|
||||
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
if (!all.getUniqueId().equals(player.getUniqueId())) {
|
||||
if (playerDataManager.hasPlayerData(all)) {
|
||||
playerData = playerDataManager.getPlayerData(all);
|
||||
for (Player loopPlayer : Bukkit.getOnlinePlayers()) {
|
||||
if (!loopPlayer.getUniqueId().equals(player.getUniqueId())) {
|
||||
if (playerDataManager.hasPlayerData(loopPlayer)) {
|
||||
playerData = playerDataManager.getPlayerData(loopPlayer);
|
||||
|
||||
if (playerData.getOwner() != null
|
||||
&& playerData.getOwner().equals(island.getOwnerUUID())) {
|
||||
all.sendMessage(ChatColor.translateAlternateColorCodes('&',
|
||||
loopPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad
|
||||
.getString(
|
||||
"Command.Island.Accept.Accepted.Broadcast.Message")
|
||||
.replace("%player", player.getName())));
|
||||
soundManager.playSound(all, CompatibleSound.ENTITY_FIREWORK_ROCKET_BLAST.getSound(), 1.0F,
|
||||
soundManager.playSound(loopPlayer, CompatibleSound.ENTITY_FIREWORK_ROCKET_BLAST.getSound(), 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"));
|
||||
}
|
||||
|
||||
|
||||
scoreboard.run();
|
||||
}
|
||||
|
||||
if (island.getRole(IslandRole.Member).size() == 1
|
||||
&& island.getRole(IslandRole.Operator).size() == 0) {
|
||||
scoreboardManager.updatePlayerScoreboardType(loopPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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"));
|
||||
}
|
||||
|
||||
|
||||
scoreboard.run();
|
||||
}
|
||||
|
||||
scoreboardManager.updatePlayerScoreboardType(player);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Accept.Owner.Message"));
|
||||
|
@ -1,15 +1,6 @@
|
||||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.songoda.skyblock.ban.Ban;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
@ -18,22 +9,30 @@ 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.permission.PermissionManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
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();
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
PermissionManager permissionManager = plugin.getPermissionManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
@ -42,13 +41,13 @@ public class BanCommand extends SubCommand {
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Owner.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning")) {
|
||||
} else if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning")) {
|
||||
if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId()) && permissionManager.hasPermission(island, "Ban", IslandRole.Operator))) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
|
||||
UUID targetPlayerUUID = null;
|
||||
String targetPlayerName = null;
|
||||
UUID targetPlayerUUID;
|
||||
String targetPlayerName;
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
|
||||
|
@ -1,17 +1,14 @@
|
||||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.gui.bank.GuiBank;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.menus.Bank;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.NumberUtil;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -22,21 +19,30 @@ public class BankCommand 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();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.Enable")) {
|
||||
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.Enable")) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Disabled.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
|
||||
Bank.getInstance().open(player);
|
||||
Island island;
|
||||
island = islandManager.getIsland(player);
|
||||
|
||||
if (island == null) {
|
||||
plugin.getSoundManager().playSound(player, CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1.0F, 1.0F);
|
||||
plugin.getMessageManager().sendMessage(player, configLoad.getString("Command.Bank.Unknown"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getGuiManager().showGUI(player, new GuiBank(plugin, island, null, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,19 +18,19 @@ public class BansCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Island island = skyblock.getIslandManager().getIsland(player);
|
||||
Island island = plugin.getIslandManager().getIsland(player);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bans.Owner.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if ((island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& skyblock.getPermissionManager().hasPermission(island, "Unban", IslandRole.Operator))
|
||||
&& plugin.getPermissionManager().hasPermission(island, "Unban", IslandRole.Operator))
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
if (island.getBan().getBans().size() == 0) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bans.Bans.Message"));
|
||||
|
@ -1,12 +1,14 @@
|
||||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.biome.BiomeManager;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.gui.biome.GuiBiome;
|
||||
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.island.IslandWorld;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
@ -19,23 +21,29 @@ 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();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
BiomeManager biomeManager = plugin.getBiomeManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.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, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if ((island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& skyblock.getPermissionManager().hasPermission(island,"Biome", IslandRole.Operator))
|
||||
&& plugin.getPermissionManager().hasPermission(island,"Biome", IslandRole.Operator))
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
Biome.getInstance().open(player);
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F);
|
||||
if(biomeManager.isUpdating(island)){
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Biome.InProgress.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
plugin.getGuiManager().showGUI(player, new GuiBiome(plugin, player, island, IslandWorld.Normal, null, false)); // TODO Nether and End support
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Biome.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
@ -21,13 +21,13 @@ public class BorderCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
PermissionManager permissionManager = plugin.getPermissionManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
@ -38,7 +38,7 @@ public class BorderCommand extends SubCommand {
|
||||
} else if ((island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& permissionManager.hasPermission(island, "Border", IslandRole.Operator))
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.WorldBorder.Enable")) {
|
||||
Border.getInstance().open(player);
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F);
|
||||
|
@ -21,12 +21,12 @@ 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();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
InviteManager inviteManager = plugin.getInviteManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
|
@ -1,44 +1,43 @@
|
||||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.songoda.skyblock.challenge.FabledChallenge;
|
||||
import com.songoda.skyblock.challenge.challenge.Challenge;
|
||||
import com.songoda.skyblock.challenge.challenge.ChallengeCategory;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class ChallengeCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
FabledChallenge fabledChallenge = skyblock.getFabledChallenge();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
FabledChallenge fabledChallenge = plugin.getFabledChallenge();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
|
||||
Config langConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config langConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration langConfigLoad = langConfig.getFileConfiguration();
|
||||
|
||||
// Not loaded
|
||||
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Challenge.Enable")) {
|
||||
messageManager.sendMessage(player, langConfigLoad.getString("Command.Island.Challenge.Disabled.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
if (args.length == 0) {
|
||||
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Challenge.PerIsland")){
|
||||
if(islandManager.getIsland(player) == null){
|
||||
messageManager.sendMessage(player, langConfigLoad.getString("Command.Island.Challenge.NoIsland.Message"));
|
||||
@ -110,7 +109,7 @@ public class ChallengeCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[] { "c" };
|
||||
return new String[] { "c", "challenges" };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,36 +4,31 @@ import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.api.event.player.PlayerIslandChatEvent;
|
||||
import com.songoda.skyblock.api.event.player.PlayerIslandChatSwitchEvent;
|
||||
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.placeholder.PlaceholderManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerData;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
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.util.UUID;
|
||||
|
||||
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();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
@ -70,41 +65,20 @@ public class ChatCommand extends SubCommand {
|
||||
} else {
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
if (playerData.getOwner() != null) {
|
||||
island = skyblock.getIslandManager().getIsland(player);
|
||||
island = plugin.getIslandManager().getIsland(player);
|
||||
}
|
||||
|
||||
String islandRole = "";
|
||||
|
||||
if (island.hasRole(IslandRole.Member, player.getUniqueId())) {
|
||||
islandRole = configLoad.getString("Island.Chat.Format.Role.Member");
|
||||
} else if (island.hasRole(IslandRole.Operator, player.getUniqueId())) {
|
||||
islandRole = configLoad.getString("Island.Chat.Format.Role.Operator");
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
islandRole = configLoad.getString("Island.Chat.Format.Role.Owner");
|
||||
|
||||
if (island != null) {
|
||||
Island finalIsland = island;
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
PlayerIslandChatEvent islandChatEvent = new PlayerIslandChatEvent(player, finalIsland.getAPIWrapper(),
|
||||
String.join(" ", args), configLoad.getString("Island.Chat.Format.Message"));
|
||||
Bukkit.getServer().getPluginManager().callEvent(islandChatEvent);
|
||||
});
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Owner.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
Island finalIsland = island;
|
||||
String finalIslandRole = islandRole;
|
||||
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||
PlayerIslandChatEvent islandChatEvent = new PlayerIslandChatEvent(player, finalIsland.getAPIWrapper(),
|
||||
String.join(" ", args), configLoad.getString("Island.Chat.Format.Message"));
|
||||
Bukkit.getServer().getPluginManager().callEvent(islandChatEvent);
|
||||
|
||||
if (!islandChatEvent.isCancelled()) {
|
||||
for (UUID islandMembersOnlineList : islandManager.getMembersOnline(finalIsland)) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(islandMembersOnlineList);
|
||||
String message = ChatColor.translateAlternateColorCodes('&', messageManager.replaceMessage(targetPlayer,
|
||||
islandChatEvent.getFormat().replace("%role", finalIslandRole).replace("%player", player.getName())))
|
||||
.replace("%message", islandChatEvent.getMessage());
|
||||
targetPlayer.sendMessage(message);
|
||||
}
|
||||
|
||||
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Chat.OutputToConsole")) {
|
||||
messageManager.sendMessage(Bukkit.getConsoleSender(), islandChatEvent.getFormat().replace("%role", finalIslandRole).replace("%player", player.getName())
|
||||
.replace("%message", islandChatEvent.getMessage()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ 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.IslandStatus;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
@ -18,11 +19,11 @@ 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();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
@ -32,8 +33,8 @@ public class CloseCommand extends SubCommand {
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& skyblock.getPermissionManager().hasPermission(island,"Visitor", IslandRole.Operator))) {
|
||||
if (island.isOpen()) {
|
||||
&& plugin.getPermissionManager().hasPermission(island,"Visitor", IslandRole.Operator))) {
|
||||
if (island.getStatus().equals(IslandStatus.OPEN) || island.getStatus().equals(IslandStatus.WHITELISTED)) {
|
||||
islandManager.closeIsland(island);
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Close.Closed.Message"));
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.songoda.core.hooks.economies.Economy;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
@ -10,9 +10,11 @@ import com.songoda.skyblock.cooldown.CooldownType;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.island.IslandStatus;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerData;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.scoreboard.ScoreboardManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.structure.Structure;
|
||||
import com.songoda.skyblock.structure.StructureManager;
|
||||
@ -32,17 +34,19 @@ 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();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
StructureManager structureManager = plugin.getStructureManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
ScoreboardManager scoreboardManager = plugin.getScoreboardManager();
|
||||
Economy economy = plugin.getEconomyManager().getEconomy();
|
||||
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (playerData.getConfirmationTime() > 0) {
|
||||
@ -99,18 +103,24 @@ public class ConfirmCommand extends SubCommand {
|
||||
islandManager.giveOwnership(island,
|
||||
Bukkit.getServer().getOfflinePlayer(targetPlayerUUID));
|
||||
|
||||
skyblock.getCooldownManager().createPlayer(CooldownType.Ownership,
|
||||
plugin.getCooldownManager().createPlayer(CooldownType.Ownership,
|
||||
Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()));
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad
|
||||
.getString("Command.Island.Confirmation.Ownership.Member.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else if (confirmation == Confirmation.Reset) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
scoreboardManager.updatePlayerScoreboardType(player);
|
||||
});
|
||||
} else if (confirmation.equals(Confirmation.Reset)) {
|
||||
playerData.setConfirmation(null);
|
||||
playerData.setConfirmationTime(0);
|
||||
} else if (confirmation == Confirmation.Deletion) {
|
||||
if (island.isOpen()) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
scoreboardManager.updatePlayerScoreboardType(player);
|
||||
});
|
||||
} else if (confirmation.equals(Confirmation.Deletion)) {
|
||||
if (island.getStatus().equals(IslandStatus.OPEN)) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Confirmation.Deletion.Open.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
@ -126,15 +136,15 @@ public class ConfirmCommand extends SubCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (EconomyManager.isEnabled() && island.getStructure() != null
|
||||
if (economy.isEnabled() && 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.withdrawBalance(player, deletionCost);
|
||||
if (economy.hasBalance(player, deletionCost)) {
|
||||
economy.withdrawBalance(player, deletionCost);
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString(
|
||||
@ -173,6 +183,9 @@ public class ConfirmCommand extends SubCommand {
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1f, 1f);
|
||||
}
|
||||
}
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
scoreboardManager.updatePlayerScoreboardType(player);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
|
@ -15,13 +15,13 @@ public class ControlPanelCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (skyblock.getIslandManager().getIsland(player) == null) {
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
if (plugin.getIslandManager().getIsland(player) == null) {
|
||||
plugin.getMessageManager().sendMessage(player,
|
||||
configLoad.getString("Command.Island.ControlPanel.Owner.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
|
@ -4,11 +4,8 @@ import com.songoda.core.compatibility.CompatibleSound;
|
||||
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.IslandCoop;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.menus.Coop;
|
||||
import com.songoda.skyblock.gui.coop.GuiCoop;
|
||||
import com.songoda.skyblock.island.*;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
@ -26,13 +23,13 @@ public class CoopCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
PermissionManager permissionManager = plugin.getPermissionManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
@ -42,7 +39,7 @@ public class CoopCommand extends SubCommand {
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Coop.Owner.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
} else if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Coop.Enable")) {
|
||||
if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
@ -85,7 +82,8 @@ public class CoopCommand extends SubCommand {
|
||||
} else if (island.isCoopPlayer(targetPlayerUUID)) {
|
||||
if (targetPlayer != null) {
|
||||
if (islandManager.getVisitorsAtIsland(island).contains(targetPlayerUUID)) {
|
||||
if (!island.isOpen()) {
|
||||
if (!(island.getStatus().equals(IslandStatus.OPEN) ||
|
||||
(island.getStatus().equals(IslandStatus.WHITELISTED) && island.isPlayerWhitelisted(player)))) {
|
||||
LocationUtil.teleportPlayerToSpawn(targetPlayer);
|
||||
|
||||
messageManager.sendMessage(targetPlayer,
|
||||
@ -127,8 +125,8 @@ public class CoopCommand extends SubCommand {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Coop.getInstance().open(player);
|
||||
|
||||
plugin.getGuiManager().showGUI(player, new GuiCoop(plugin, island, null));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Coop.Permission.Message"));
|
||||
|
@ -25,19 +25,19 @@ 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();
|
||||
CooldownManager cooldownManager = plugin.getCooldownManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
if (islandManager.getIsland(player) == null) {
|
||||
Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
|
||||
if (args.length == 1) {
|
||||
Structure structure = skyblock.getStructureManager().getStructure(args[0]);
|
||||
Structure structure = plugin.getStructureManager().getStructure(args[0]);
|
||||
|
||||
if (structure != null && islandManager.createIsland(player, structure)) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Creator.Selector.Created.Message"));
|
||||
@ -50,7 +50,7 @@ public class CreateCommand extends SubCommand {
|
||||
Creator.getInstance().open(player);
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
List<Structure> structures = skyblock.getStructureManager().getStructures();
|
||||
List<Structure> structures = plugin.getStructureManager().getStructures();
|
||||
|
||||
if (structures.size() == 0) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Creator.Selector.None.Message"));
|
||||
@ -58,7 +58,7 @@ public class CreateCommand extends SubCommand {
|
||||
|
||||
return;
|
||||
} else if (!fileManager
|
||||
.isFileExist(new File(new File(skyblock.getDataFolder().toString() + "/structures"),
|
||||
.isFileExist(new File(new File(plugin.getDataFolder().toString() + "/structures"),
|
||||
structures.get(0).getOverworldFile()))) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Island.Creator.Selector.File.Overworld.Message"));
|
||||
@ -66,14 +66,14 @@ public class CreateCommand extends SubCommand {
|
||||
|
||||
return;
|
||||
} else if (!fileManager
|
||||
.isFileExist(new File(new File(skyblock.getDataFolder().toString() + "/structures"),
|
||||
.isFileExist(new File(new File(plugin.getDataFolder().toString() + "/structures"),
|
||||
structures.get(0).getNetherFile()))) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Island.Creator.Selector.File.Nether.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
} else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
} else if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Creation.Cooldown.Creation.Enable")
|
||||
&& cooldownManager.hasPlayer(CooldownType.Creation, player)) {
|
||||
CooldownPlayer cooldownPlayer = cooldownManager.getCooldownPlayer(CooldownType.Creation, player);
|
||||
|
@ -19,11 +19,11 @@ 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();
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length > 0) {
|
||||
|
@ -33,15 +33,15 @@ public class DeleteCommand 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();
|
||||
CooldownManager cooldownManager = plugin.getCooldownManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||
PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
@ -50,7 +50,7 @@ public class DeleteCommand extends SubCommand {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Delete.Owner.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Creation.Cooldown.Creation.Enable")
|
||||
&& cooldownManager.hasPlayer(CooldownType.Deletion, player)) {
|
||||
CooldownPlayer cooldownPlayer = cooldownManager.getCooldownPlayer(CooldownType.Deletion, player);
|
||||
@ -81,7 +81,7 @@ public class DeleteCommand extends SubCommand {
|
||||
configLoad.getString("Command.Island.Delete.Confirmation.Pending.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
int confirmationTime = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
int confirmationTime = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getInt("Island.Confirmation.Timeout");
|
||||
|
||||
playerData.setConfirmation(Confirmation.Deletion);
|
||||
|
@ -22,11 +22,11 @@ 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();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
|
@ -18,11 +18,11 @@ 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();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
InviteManager inviteManager = plugin.getInviteManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
|
@ -22,13 +22,13 @@ 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();
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
UUID islandOwnerUUID = null;
|
||||
@ -57,7 +57,7 @@ public class InformationCommand extends SubCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||
PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
if (islandOwnerUUID == null) {
|
||||
if (islandManager.getIsland(player) == null) {
|
||||
|
@ -30,12 +30,12 @@ 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();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
@ -46,11 +46,11 @@ public class InviteCommand extends SubCommand {
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& skyblock.getPermissionManager().hasPermission(island, "Invite", IslandRole.Operator))) {
|
||||
Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
&& plugin.getPermissionManager().hasPermission(island, "Invite", IslandRole.Operator))) {
|
||||
Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
|
||||
if ((island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size()
|
||||
+ 1) >= mainConfig.getFileConfiguration().getInt("Island.Member.Capacity")) {
|
||||
+ 1) >= island.getMaxMembers()) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Invite.Capacity.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
@ -77,8 +77,8 @@ public class InviteCommand extends SubCommand {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Invite.Member.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if (skyblock.getInviteManager().hasInvite(targetPlayer.getUniqueId())) {
|
||||
Invite invite = skyblock.getInviteManager().getInvite(targetPlayer.getUniqueId());
|
||||
} else if (plugin.getInviteManager().hasInvite(targetPlayer.getUniqueId())) {
|
||||
Invite invite = plugin.getInviteManager().getInvite(targetPlayer.getUniqueId());
|
||||
|
||||
if (invite.getOwnerUUID().equals(island.getOwnerUUID())) {
|
||||
messageManager.sendMessage(player,
|
||||
@ -213,7 +213,7 @@ public class InviteCommand extends SubCommand {
|
||||
|
||||
targetPlayer.spigot().sendMessage(chatComponent.getTextComponent());
|
||||
|
||||
Invite invite = skyblock.getInviteManager().createInvite(targetPlayer, player,
|
||||
Invite invite = plugin.getInviteManager().createInvite(targetPlayer, player,
|
||||
island.getOwnerUUID(), respondTime);
|
||||
|
||||
Bukkit.getServer().getPluginManager()
|
||||
|
@ -8,6 +8,7 @@ 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.IslandStatus;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.world.LocationUtil;
|
||||
@ -24,11 +25,11 @@ 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();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
@ -38,8 +39,8 @@ public class KickAllCommand extends SubCommand {
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& skyblock.getPermissionManager().hasPermission(island, "Kick", IslandRole.Operator))) {
|
||||
if (island.isOpen()) {
|
||||
&& plugin.getPermissionManager().hasPermission(island, "Kick", IslandRole.Operator))) {
|
||||
if (!island.getStatus().equals(IslandStatus.CLOSED)) {
|
||||
Set<UUID> islandVisitors = islandManager.getVisitorsAtIsland(island);
|
||||
|
||||
if (islandVisitors.size() == 0) {
|
||||
@ -50,8 +51,7 @@ public class KickAllCommand extends SubCommand {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(islandVisitorList);
|
||||
|
||||
if (targetPlayer != null &&
|
||||
(targetPlayer.hasPermission("fabledskyblock.bypass.ban") ||
|
||||
targetPlayer.hasPermission("fabledskyblock.bypass.kick")))
|
||||
(targetPlayer.hasPermission("fabledskyblock.bypass.kick")))
|
||||
continue;
|
||||
|
||||
IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(),
|
||||
|
@ -1,18 +1,6 @@
|
||||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
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 com.songoda.skyblock.api.event.island.IslandKickEvent;
|
||||
import com.songoda.skyblock.api.utils.APIUtil;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
@ -21,31 +9,41 @@ 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.IslandStatus;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
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.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.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();
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
ScoreboardManager scoreboardManager = plugin.getScoreboardManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
PermissionManager permissionManager = plugin.getPermissionManager();
|
||||
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
Config languageConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config languageConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
|
||||
if (args.length == 1) {
|
||||
Island island = islandManager.getIsland(player);
|
||||
@ -72,8 +70,7 @@ public class KickCommand extends SubCommand {
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
}
|
||||
|
||||
assert targetPlayer != null;
|
||||
if((targetPlayer.hasPermission("fabledskyblock.bypass.kick") || targetPlayer.isOp()) && islandVisitors.contains(targetPlayer.getUniqueId())){
|
||||
if(targetPlayer != null && (targetPlayer.hasPermission("fabledskyblock.bypass.kick") || targetPlayer.isOp()) && islandVisitors.contains(targetPlayer.getUniqueId())){
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Exempt"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if (targetPlayerUUID.equals(player.getUniqueId())) {
|
||||
@ -85,7 +82,7 @@ public class KickCommand extends SubCommand {
|
||||
} else if (island.getOwnerUUID().equals(targetPlayerUUID)) {
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Role.Owner.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if (island.isOpen() && islandVisitors.contains(targetPlayerUUID) && targetPlayer != null) {
|
||||
} else if (!island.getStatus().equals(IslandStatus.CLOSED) && islandVisitors.contains(targetPlayerUUID)) {
|
||||
if (island.isCoopPlayer(targetPlayerUUID)) {
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Cooped.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
@ -93,7 +90,7 @@ public class KickCommand extends SubCommand {
|
||||
IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(), APIUtil.fromImplementation(IslandRole.Visitor),
|
||||
Bukkit.getServer().getOfflinePlayer(targetPlayerUUID), player);
|
||||
|
||||
Bukkit.getScheduler().runTask(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(islandKickEvent));
|
||||
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getServer().getPluginManager().callEvent(islandKickEvent));
|
||||
|
||||
if (!islandKickEvent.isCancelled()) {
|
||||
LocationUtil.teleportPlayerToSpawn(targetPlayer);
|
||||
@ -117,7 +114,7 @@ public class KickCommand extends SubCommand {
|
||||
IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(), APIUtil.fromImplementation(islandRole),
|
||||
Bukkit.getServer().getOfflinePlayer(targetPlayerUUID), player);
|
||||
|
||||
Bukkit.getScheduler().runTask(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(islandKickEvent));
|
||||
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getServer().getPluginManager().callEvent(islandKickEvent));
|
||||
|
||||
if (!islandKickEvent.isCancelled()) {
|
||||
messageManager.sendMessage(player,
|
||||
@ -125,7 +122,7 @@ public class KickCommand extends SubCommand {
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 1.0F, 1.0F);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
Config config = fileManager.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), targetPlayerUUID.toString() + ".yml"));
|
||||
Config config = fileManager.getConfig(new File(new File(plugin.getDataFolder().toString() + "/player-data"), targetPlayerUUID.toString() + ".yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
configLoad.set("Statistics.Island.Playtime", null);
|
||||
@ -147,14 +144,11 @@ public class KickCommand extends SubCommand {
|
||||
&& !targetPlayer.isOp()) {
|
||||
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();
|
||||
}
|
||||
|
||||
Player finalTargetPlayer = targetPlayer;
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
scoreboardManager.updatePlayerScoreboardType(player);
|
||||
});
|
||||
|
||||
playerData = playerDataManager.getPlayerData(targetPlayer);
|
||||
playerData.setPlaytime(0);
|
||||
@ -182,43 +176,39 @@ public class KickCommand extends SubCommand {
|
||||
|
||||
if (targetPlayerData.isChat()) {
|
||||
targetPlayerData.setChat(false);
|
||||
messageManager.sendMessage(targetPlayer, fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
|
||||
messageManager.sendMessage(targetPlayer, fileManager.getConfig(new File(plugin.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();
|
||||
}
|
||||
}
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
scoreboardManager.updatePlayerScoreboardType(player);
|
||||
});
|
||||
}
|
||||
} 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"));
|
||||
switch (island.getStatus()){
|
||||
case OPEN:
|
||||
case WHITELISTED:
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Occupant.Visit.Open.Message"));
|
||||
break;
|
||||
case CLOSED:
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Occupant.Visit.Closed.Message"));
|
||||
break;
|
||||
}
|
||||
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 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"));
|
||||
switch (island.getStatus()){
|
||||
case OPEN:
|
||||
case WHITELISTED:
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Permission.Visit.Open.Message"));
|
||||
break;
|
||||
case CLOSED:
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Permission.Visit.Closed.Message"));
|
||||
break;
|
||||
}
|
||||
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
@ -18,17 +18,17 @@ 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();
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.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()
|
||||
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Visitor.Vote")) {
|
||||
playerDataManager.getPlayerData(player)
|
||||
.setViewer(new Leaderboard.Viewer(Leaderboard.Viewer.Type.Browse));
|
||||
@ -46,7 +46,7 @@ public class LeaderboardCommand extends SubCommand {
|
||||
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")) {
|
||||
if (fileManager.getConfig(new File(plugin.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"));
|
||||
|
@ -11,7 +11,6 @@ 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.world.LocationUtil;
|
||||
@ -28,16 +27,16 @@ 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();
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
ScoreboardManager scoreboardManager = plugin.getScoreboardManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
Config languageConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config languageConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
@ -83,7 +82,7 @@ public class LeaveCommand extends SubCommand {
|
||||
if (targetPlayerData.isChat()) {
|
||||
targetPlayerData.setChat(false);
|
||||
messageManager.sendMessage(targetPlayer,
|
||||
fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Chat.Untoggled.Message"));
|
||||
}
|
||||
}
|
||||
@ -93,29 +92,21 @@ public class LeaveCommand extends SubCommand {
|
||||
// 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('&',
|
||||
for (Player loopPlayer : Bukkit.getOnlinePlayers()) {
|
||||
if (!loopPlayer.getUniqueId().equals(player.getUniqueId())) {
|
||||
if (island.hasRole(IslandRole.Member, loopPlayer.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Operator, loopPlayer.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Owner, loopPlayer.getUniqueId())) {
|
||||
loopPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&',
|
||||
languageConfig.getFileConfiguration()
|
||||
.getString("Command.Island.Leave.Left.Broadcast.Message")
|
||||
.replace("%player", player.getName())));
|
||||
soundManager.playSound(all, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 5.0F, 5.0F);
|
||||
soundManager.playSound(loopPlayer, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 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();
|
||||
}
|
||||
if (islandManager.getVisitorsAtIsland(island).size() != 0) {
|
||||
scoreboardManager.updatePlayerScoreboardType(loopPlayer);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -127,15 +118,8 @@ public class LeaveCommand extends SubCommand {
|
||||
messageManager.sendMessage(player,
|
||||
languageConfig.getFileConfiguration().getString("Command.Island.Leave.Left.Sender.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 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();
|
||||
}
|
||||
|
||||
scoreboardManager.updatePlayerScoreboardType(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ 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.rework.IslandLevelManager;
|
||||
import com.songoda.skyblock.levelling.IslandLevelManager;
|
||||
import com.songoda.skyblock.menus.Levelling;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
@ -30,15 +30,15 @@ public class LevelCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
IslandLevelManager levellingManager = skyblock.getLevellingManager();
|
||||
CooldownManager cooldownManager = skyblock.getCooldownManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
VisitManager visitManager = skyblock.getVisitManager();
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
IslandLevelManager levellingManager = plugin.getLevellingManager();
|
||||
CooldownManager cooldownManager = plugin.getCooldownManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
VisitManager visitManager = plugin.getVisitManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
|
@ -14,15 +14,15 @@ public class MembersCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
if (skyblock.getIslandManager().getIsland(player) == null) {
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
if (plugin.getIslandManager().getIsland(player) == null) {
|
||||
plugin.getMessageManager().sendMessage(player,
|
||||
plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Command.Island.Settings.Owner.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||
PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player);
|
||||
playerData.setType(Members.Type.Default);
|
||||
playerData.setSort(Members.Sort.Default);
|
||||
|
||||
|
@ -6,6 +6,7 @@ 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.IslandStatus;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
@ -19,12 +20,12 @@ 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();
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
PermissionManager permissionManager = plugin.getPermissionManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
@ -35,11 +36,11 @@ public class OpenCommand extends SubCommand {
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& permissionManager.hasPermission(island, "Visitor", IslandRole.Operator))) {
|
||||
if (island.isOpen()) {
|
||||
if (island.getStatus().equals(IslandStatus.OPEN)) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Open.Already.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
island.setOpen(true);
|
||||
island.setStatus(IslandStatus.OPEN);
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Open.Opened.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.getSound(), 1.0F, 1.0F);
|
||||
|
@ -37,15 +37,15 @@ public class OwnerCommand 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();
|
||||
CooldownManager cooldownManager = plugin.getCooldownManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||
PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
@ -126,7 +126,7 @@ public class OwnerCommand extends SubCommand {
|
||||
|
||||
return;
|
||||
} else {
|
||||
int confirmationTime = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
int confirmationTime = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getInt("Island.Confirmation.Timeout");
|
||||
|
||||
playerData.setOwnership(targetPlayerUUID);
|
||||
|
@ -19,40 +19,40 @@ public class PreviewCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
FileManager.Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLang = config.getFileConfiguration();
|
||||
|
||||
if(args.length != 1) {
|
||||
skyblock.getMessageManager().sendMessage(player, configLang.getString("Command.Island.Preview.Argument.Count.Message"));
|
||||
plugin.getMessageManager().sendMessage(player, configLang.getString("Command.Island.Preview.Argument.Count.Message"));
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerData data = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||
Island island = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(player.getUniqueId()));
|
||||
PlayerData data = plugin.getPlayerDataManager().getPlayerData(player);
|
||||
Island island = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(player.getUniqueId()));
|
||||
|
||||
if (args[0].equals("confirm")) {
|
||||
if(data.getConfirmation() == Confirmation.Preview && data.getConfirmationTime() > 0) {
|
||||
Structure islandStructure = skyblock.getStructureManager().getStructure(island.getStructure());
|
||||
Structure islandStructure = plugin.getStructureManager().getStructure(island.getStructure());
|
||||
|
||||
if(skyblock.getIslandManager().deleteIsland(island, true)) {
|
||||
if(plugin.getIslandManager().deleteIsland(island, true)) {
|
||||
island.setDeleted(true);
|
||||
data.setPreview(false);
|
||||
if(player.getGameMode() == GameMode.SPECTATOR) {
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(skyblock, () -> {
|
||||
if(skyblock.getIslandManager().createIsland(player, islandStructure)) {
|
||||
skyblock.getMessageManager().sendMessage(player, configLang.getString("Island.Creator.Selector.Created.Message"));
|
||||
skyblock.getSoundManager().playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||
if(plugin.getIslandManager().createIsland(player, islandStructure)) {
|
||||
plugin.getMessageManager().sendMessage(player, configLang.getString("Island.Creator.Selector.Created.Message"));
|
||||
plugin.getSoundManager().playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}, 30L);
|
||||
}
|
||||
}
|
||||
} else if (args[0].equals("cancel")) {
|
||||
if(data.getConfirmation() == Confirmation.Preview && data.getConfirmationTime() > 0) {
|
||||
if(skyblock.getIslandManager().deleteIsland(island, true)) {
|
||||
if(plugin.getIslandManager().deleteIsland(island, true)) {
|
||||
island.setDeleted(true);
|
||||
data.setPreview(false);
|
||||
if (player.getGameMode() == GameMode.SPECTATOR) {
|
||||
@ -63,15 +63,15 @@ public class PreviewCommand extends SubCommand {
|
||||
} else {
|
||||
// Do not preview if user has an island
|
||||
if (island != null) {
|
||||
skyblock.getMessageManager().sendMessage(player, configLang.getString("Command.Island.Preview.Island.Message"));
|
||||
plugin.getMessageManager().sendMessage(player, configLang.getString("Command.Island.Preview.Island.Message"));
|
||||
return;
|
||||
}
|
||||
Structure structure = skyblock.getStructureManager().getStructure(args[0]);
|
||||
Structure structure = plugin.getStructureManager().getStructure(args[0]);
|
||||
if(structure == null) {
|
||||
skyblock.getMessageManager().sendMessage(player, configLang.getString("Command.Island.Preview.File.Message"));
|
||||
plugin.getMessageManager().sendMessage(player, configLang.getString("Command.Island.Preview.File.Message"));
|
||||
return;
|
||||
}
|
||||
skyblock.getIslandManager().previewIsland(player, structure);
|
||||
plugin.getIslandManager().previewIsland(player, structure);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,11 +23,11 @@ public class PromoteCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length != 1) {
|
||||
|
@ -6,6 +6,7 @@ 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.IslandStatus;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
@ -18,11 +19,11 @@ public class PublicCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
@ -32,17 +33,26 @@ public class PublicCommand extends SubCommand {
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& skyblock.getPermissionManager().hasPermission(island, "Visitor", IslandRole.Operator))) {
|
||||
if (island.isOpen()) {
|
||||
islandManager.closeIsland(island);
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Public.Private.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
island.setOpen(true);
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Public.Public.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.getSound(), 1.0F, 1.0F);
|
||||
&& plugin.getPermissionManager().hasPermission(island, "Visitor", IslandRole.Operator))) {
|
||||
switch (island.getStatus()) {
|
||||
case OPEN:
|
||||
islandManager.whitelistIsland(island);
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Public.Restricted.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1.0F, 1.0F);
|
||||
break;
|
||||
case WHITELISTED:
|
||||
islandManager.closeIsland(island);
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Public.Private.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1.0F, 1.0F);
|
||||
break;
|
||||
case CLOSED:
|
||||
island.setStatus(IslandStatus.OPEN);
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Public.Public.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.getSound(), 1.0F, 1.0F);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Public.Permission.Message"));
|
||||
@ -67,7 +77,7 @@ public class PublicCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[]{"pub", "private", "pri"};
|
||||
return new String[]{"pub", "private", "pri", "restricted", "res"};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,80 @@
|
||||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
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.scoreboard.ScoreboardManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
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 ScoreboardCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
ScoreboardManager scoreboardManager = plugin.getScoreboardManager();
|
||||
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
if (playerData == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Scoreboard.Error.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if(!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Scoreboard.Enable", false)) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Scoreboard.GlobalDisable.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
}else if (playerData.isScoreboard()) {
|
||||
playerData.setScoreboard(false);
|
||||
scoreboardManager.addDisabledPlayer(player);
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Scoreboard.Disabled.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
playerData.setScoreboard(true);
|
||||
scoreboardManager.removeDisabledPlayer(player);
|
||||
Bukkit.getScheduler().runTask(plugin, () ->
|
||||
scoreboardManager.updatePlayerScoreboardType(player));
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Scoreboard.Enabled.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.getSound(), 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 "scoreboard";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfoMessagePath() {
|
||||
return "Command.Scoreboard.Info.Message";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
@ -8,7 +8,6 @@ import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.*;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -20,12 +19,12 @@ public class SetSpawnCommand 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();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
@ -51,14 +50,14 @@ public class SetSpawnCommand extends SubCommand {
|
||||
if (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
if ((island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& (skyblock.getPermissionManager().hasPermission(island,
|
||||
&& (plugin.getPermissionManager().hasPermission(island,
|
||||
environment.name() + "Spawn", IslandRole.Operator)))
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
if (islandManager.isPlayerAtIsland(island, player)) {
|
||||
IslandWorld world = skyblock.getWorldManager().getIslandWorld(player.getWorld());
|
||||
IslandWorld world = plugin.getWorldManager().getIslandWorld(player.getWorld());
|
||||
Location location = player.getLocation();
|
||||
|
||||
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
|
||||
|
||||
CompatibleMaterial toCompare = CompatibleMaterial.getMaterial(location.clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getType());
|
||||
|
@ -3,14 +3,11 @@ package com.songoda.skyblock.command.commands.island;
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.gui.GuiPermissions;
|
||||
import com.songoda.skyblock.gui.GuiPermissionsSelector;
|
||||
import com.songoda.skyblock.gui.permissions.GuiPermissionsSelector;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.menus.Settings;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.permission.PermissionHandler;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
@ -23,12 +20,12 @@ public class SettingsCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
PermissionManager permissionManager = plugin.getPermissionManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
@ -42,7 +39,7 @@ public class SettingsCommand extends SubCommand {
|
||||
&& (permissionManager.hasPermission(island, "Visitor", IslandRole.Operator)
|
||||
|| permissionManager.hasPermission(island, "Member", IslandRole.Operator)))
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
skyblock.getGuiManager().showGUI(player, new GuiPermissionsSelector(skyblock, island, null));
|
||||
plugin.getGuiManager().showGUI(player, new GuiPermissionsSelector(plugin, player, island, null));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F);
|
||||
} else{
|
||||
messageManager.sendMessage(player,
|
||||
|
@ -3,10 +3,7 @@ package com.songoda.skyblock.command.commands.island;
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandEnvironment;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandWorld;
|
||||
import com.songoda.skyblock.island.*;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
@ -14,10 +11,9 @@ import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import com.songoda.skyblock.utils.world.LocationUtil;
|
||||
import com.songoda.skyblock.visit.Visit;
|
||||
import com.songoda.skyblock.visit.VisitManager;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -29,13 +25,13 @@ public class TeleportCommand 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();
|
||||
VisitManager visitManager = skyblock.getVisitManager();
|
||||
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
VisitManager visitManager = plugin.getVisitManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
@ -61,14 +57,23 @@ public class TeleportCommand extends SubCommand {
|
||||
if (visitManager.hasIsland(islandOwnerUUID)) {
|
||||
Visit visit = visitManager.getIsland(islandOwnerUUID);
|
||||
boolean isCoopPlayer = false;
|
||||
boolean isWhitelistedPlayer = false;
|
||||
|
||||
if (islandManager.containsIsland(islandOwnerUUID)) {
|
||||
if (islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)).isCoopPlayer(player.getUniqueId())) {
|
||||
isCoopPlayer = true;
|
||||
}
|
||||
if (visit.getStatus().equals(IslandStatus.WHITELISTED) && islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)).isPlayerWhitelisted(player.getUniqueId())) {
|
||||
isWhitelistedPlayer = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isCoopPlayer || player.hasPermission("fabledskyblock.bypass") || player.hasPermission("fabledskyblock.bypass.*") || player.hasPermission("fabledskyblock.*") || visit.isOpen()) {
|
||||
if (visit.getStatus().equals(IslandStatus.OPEN) ||
|
||||
isCoopPlayer ||
|
||||
isWhitelistedPlayer ||
|
||||
player.hasPermission("fabledskyblock.bypass") ||
|
||||
player.hasPermission("fabledskyblock.bypass.*") ||
|
||||
player.hasPermission("fabledskyblock.*")) {
|
||||
if (!islandManager.containsIsland(islandOwnerUUID)) {
|
||||
islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
|
||||
}
|
||||
@ -108,10 +113,15 @@ public class TeleportCommand extends SubCommand {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Teleported.Yourself.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
|
||||
Bukkit.getServer().getScheduler().runTask(plugin, () -> {
|
||||
Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main);
|
||||
LocationUtil.removeWaterFromLoc(skyblock, loc);
|
||||
player.teleport(loc);
|
||||
PaperLib.getChunkAtAsync(loc).thenRun((() -> {
|
||||
if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Teleport.RemoveWater", false)) {
|
||||
LocationUtil.removeWaterFromLoc(loc);
|
||||
}
|
||||
PaperLib.teleportAsync(player, loc);
|
||||
}));
|
||||
|
||||
if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){
|
||||
player.setFallDistance(0.0F);
|
||||
|
@ -23,12 +23,12 @@ public class UnbanCommand 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();
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
IslandManager islandManager = plugin.getIslandManager();
|
||||
SoundManager soundManager = plugin.getSoundManager();
|
||||
FileManager fileManager = plugin.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 1) {
|
||||
@ -37,11 +37,11 @@ public class UnbanCommand extends SubCommand {
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Unban.Owner.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
} else if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Visitor.Banning")) {
|
||||
if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& skyblock.getPermissionManager().hasPermission(island,"Unban", IslandRole.Operator))) {
|
||||
&& plugin.getPermissionManager().hasPermission(island,"Unban", IslandRole.Operator))) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
|
||||
UUID targetPlayerUUID = null;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user