Initial work for Deletion cooldown
This commit is contained in:
parent
0be81ba262
commit
0ebce83d77
|
@ -15,6 +15,7 @@ This fork contains bug fixes, features and improvements:
|
|||
- Added option to let slime splitting bypass limits.yml
|
||||
- Added option to define distance between islands
|
||||
- Added option to clear inventory and/or enderchest on island delete (working only with online players)
|
||||
- Added deletion cooldown
|
||||
- Fixed bugs in Challenges that didn't remove all the items
|
||||
- Fixed WorldBorder size not reflecting real island size
|
||||
- Now you can use `/is chat <message>` to send messages to island chat
|
||||
|
|
|
@ -5,6 +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.confirmation.Confirmation;
|
||||
import com.songoda.skyblock.cooldown.Cooldown;
|
||||
import com.songoda.skyblock.cooldown.CooldownManager;
|
||||
import com.songoda.skyblock.cooldown.CooldownPlayer;
|
||||
import com.songoda.skyblock.cooldown.CooldownType;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
|
@ -12,6 +16,7 @@ import com.songoda.skyblock.message.MessageManager;
|
|||
import com.songoda.skyblock.playerdata.PlayerData;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.ChatComponent;
|
||||
import com.songoda.skyblock.utils.NumberUtil;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
|
@ -28,6 +33,7 @@ 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();
|
||||
|
@ -44,6 +50,32 @@ 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"))
|
||||
.getFileConfiguration().getBoolean("Island.Creation.Cooldown.Creation.Enable")
|
||||
&& cooldownManager.hasPlayer(CooldownType.Deletion, player)) {
|
||||
CooldownPlayer cooldownPlayer = cooldownManager.getCooldownPlayer(CooldownType.Deletion, player);
|
||||
Cooldown cooldown = cooldownPlayer.getCooldown();
|
||||
|
||||
if (cooldown.getTime() < 60) {
|
||||
messageManager.sendMessage(player,
|
||||
config.getFileConfiguration().getString("Island.Deletion.Selector.Cooldown.Message") // TODO Add language.yml values
|
||||
.replace("%time", cooldown.getTime() + " " + config.getFileConfiguration()
|
||||
.getString("Island.Deletion.Selector.Cooldown.Word.Second")));
|
||||
} else {
|
||||
long[] durationTime = NumberUtil.getDuration(cooldown.getTime());
|
||||
messageManager.sendMessage(player,
|
||||
config.getFileConfiguration().getString("Island.Deletion.Selector.Cooldown.Message")
|
||||
.replace("%time", durationTime[2] + " "
|
||||
+ config.getFileConfiguration()
|
||||
.getString("Island.Deletion.Selector.Cooldown.Word.Minute")
|
||||
+ " " + durationTime[3] + " " + config.getFileConfiguration()
|
||||
.getString("Island.Deletion.Selector.Cooldown.Word.Second")));
|
||||
}
|
||||
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
if (playerData.getConfirmationTime() > 0) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Delete.Confirmation.Pending.Message"));
|
||||
|
|
|
@ -36,7 +36,7 @@ public class CooldownManager {
|
|||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
CooldownPlayer cooldownPlayer = null;
|
||||
|
||||
if (cooldownTypeList == CooldownType.Biome || cooldownTypeList == CooldownType.Creation) {
|
||||
if (cooldownTypeList == CooldownType.Biome || cooldownTypeList == CooldownType.Creation || cooldownTypeList == CooldownType.Deletion) {
|
||||
cooldownPlayer = loadCooldownPlayer(cooldownTypeList, all);
|
||||
} else if (cooldownTypeList == CooldownType.Levelling || cooldownTypeList == CooldownType.Ownership) {
|
||||
Island island = islandManager.getIsland(all);
|
||||
|
@ -69,7 +69,7 @@ public class CooldownManager {
|
|||
}
|
||||
|
||||
public CooldownPlayer loadCooldownPlayer(CooldownType cooldownType, OfflinePlayer player) {
|
||||
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) {
|
||||
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation || cooldownType == CooldownType.Deletion) {
|
||||
Config config = skyblock.getFileManager()
|
||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
@ -99,7 +99,7 @@ public class CooldownManager {
|
|||
|
||||
int time = 0;
|
||||
|
||||
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) {
|
||||
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation || cooldownType == CooldownType.Deletion) {
|
||||
time = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getInt("Island." + cooldownType.name() + ".Cooldown.Time");
|
||||
|
||||
|
@ -139,7 +139,7 @@ public class CooldownManager {
|
|||
public void deletePlayer(CooldownType cooldownType, OfflinePlayer player) {
|
||||
for (Iterator<CooldownPlayer> it = getCooldownPlayersOrEmptyList(cooldownType).iterator(); it.hasNext();) {
|
||||
if (it.next().getUUID().equals(player.getUniqueId())) {
|
||||
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) {
|
||||
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation || cooldownType == CooldownType.Deletion) {
|
||||
skyblock.getFileManager()
|
||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"),
|
||||
player.getUniqueId().toString() + ".yml"))
|
||||
|
@ -197,7 +197,7 @@ public class CooldownManager {
|
|||
public void setCooldownPlayer(CooldownType cooldownType, OfflinePlayer player) {
|
||||
for (CooldownPlayer cooldownPlayerList : getCooldownPlayersOrEmptyList(cooldownType)) {
|
||||
if (cooldownPlayerList.getUUID().equals(player.getUniqueId())) {
|
||||
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) {
|
||||
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation || cooldownType == CooldownType.Deletion) {
|
||||
skyblock.getFileManager()
|
||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"),
|
||||
player.getUniqueId().toString() + ".yml"))
|
||||
|
@ -222,7 +222,7 @@ public class CooldownManager {
|
|||
public void saveCooldownPlayer(CooldownType cooldownType, OfflinePlayer player) {
|
||||
Config config = null;
|
||||
|
||||
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) {
|
||||
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation || cooldownType == CooldownType.Deletion) {
|
||||
config = skyblock.getFileManager()
|
||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml"));
|
||||
} else if (cooldownType == CooldownType.Levelling || cooldownType == CooldownType.Ownership) {
|
||||
|
|
|
@ -8,6 +8,7 @@ public enum CooldownType {
|
|||
|
||||
Biome,
|
||||
Creation,
|
||||
Deletion,
|
||||
Levelling,
|
||||
Ownership,
|
||||
Teleport;
|
||||
|
|
|
@ -244,6 +244,9 @@ public class IslandManager {
|
|||
if (configLoad.getBoolean("Island.Creation.Cooldown.Creation.Enable") && !player.hasPermission("fabledskyblock.bypass.cooldown") && !player.hasPermission("fabledskyblock.bypass.*")
|
||||
&& !player.hasPermission("fabledskyblock.*"))
|
||||
skyblock.getCooldownManager().createPlayer(CooldownType.Creation, player);
|
||||
if (configLoad.getBoolean("Island.Deletion.Cooldown.Deletion.Enable") && !player.hasPermission("fabledskyblock.bypass.cooldown") && !player.hasPermission("fabledskyblock.bypass.*")
|
||||
&& !player.hasPermission("fabledskyblock.*"))
|
||||
skyblock.getCooldownManager().createPlayer(CooldownType.Deletion, player);
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(new IslandCreateEvent(island.getAPIWrapper(), player)));
|
||||
|
||||
|
@ -577,7 +580,8 @@ public class IslandManager {
|
|||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
boolean cooldownEnabled = configLoad.getBoolean("Island.Creation.Cooldown.Deletion.Enable");
|
||||
boolean cooldownCreationEnabled = configLoad.getBoolean("Island.Creation.Cooldown.Creation.Enable");
|
||||
boolean cooldownDeletionEnabled = configLoad.getBoolean("Island.Creation.Cooldown.Deletion.Enable");
|
||||
|
||||
config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
configLoad = config.getFileConfiguration();
|
||||
|
@ -611,11 +615,16 @@ public class IslandManager {
|
|||
all.getEnderChest().clear();
|
||||
}
|
||||
|
||||
if (cooldownEnabled) {
|
||||
if (cooldownCreationEnabled) {
|
||||
if (!all.hasPermission("fabledskyblock.bypass.cooldown") && !all.hasPermission("fabledskyblock.bypass.*") && !all.hasPermission("fabledskyblock.*")) {
|
||||
skyblock.getCooldownManager().createPlayer(CooldownType.Creation, all);
|
||||
}
|
||||
}
|
||||
if (cooldownDeletionEnabled) {
|
||||
if (!all.hasPermission("fabledskyblock.bypass.cooldown") && !all.hasPermission("fabledskyblock.bypass.*") && !all.hasPermission("fabledskyblock.*")) {
|
||||
skyblock.getCooldownManager().createPlayer(CooldownType.Deletion, all);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
InviteManager inviteManager = skyblock.getInviteManager();
|
||||
|
|
|
@ -100,6 +100,7 @@ public class Join implements Listener {
|
|||
|
||||
cooldownManager.addCooldownPlayer(CooldownType.Biome, cooldownManager.loadCooldownPlayer(CooldownType.Biome, player));
|
||||
cooldownManager.addCooldownPlayer(CooldownType.Creation, cooldownManager.loadCooldownPlayer(CooldownType.Creation, player));
|
||||
cooldownManager.addCooldownPlayer(CooldownType.Deletion, cooldownManager.loadCooldownPlayer(CooldownType.Deletion, player));
|
||||
|
||||
if (scoreboardManager != null) {
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
|
|
|
@ -94,6 +94,9 @@ public class Quit implements Listener {
|
|||
cooldownManager.setCooldownPlayer(CooldownType.Creation, player);
|
||||
cooldownManager.removeCooldownPlayer(CooldownType.Creation, player);
|
||||
|
||||
cooldownManager.setCooldownPlayer(CooldownType.Deletion, player);
|
||||
cooldownManager.removeCooldownPlayer(CooldownType.Deletion, player);
|
||||
|
||||
playerDataManager.savePlayerData(player);
|
||||
playerDataManager.unloadPlayerData(player);
|
||||
|
||||
|
|
|
@ -32,13 +32,23 @@ Island:
|
|||
# When enabled cooldown will start when a player deletes their Island.
|
||||
Deletion:
|
||||
Enable: true
|
||||
# Time until player can create another island.
|
||||
# Time in seconds until player can create another island.
|
||||
Time: 60
|
||||
# [!] How many seconds to wait before teleporting to a newly created island
|
||||
TeleportTimeout: 1
|
||||
# The distance between the islands
|
||||
Distance: 1200
|
||||
Deletion:
|
||||
# [!] You are adviced to keep these options both enabled to prevent any issues.
|
||||
Cooldown:
|
||||
# When enabled cooldown will start when a player creates an Island.
|
||||
Creation:
|
||||
Enable: true
|
||||
# When enabled cooldown will start when a player deletes their Island.
|
||||
Deletion:
|
||||
Enable: true
|
||||
# Time in seconds until player can delete their island.
|
||||
Time: 60
|
||||
ClearInventory: false
|
||||
ClearEnderChest: false
|
||||
World:
|
||||
|
|
Loading…
Reference in New Issue