mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-07 03:00:29 +01:00
Max Members upgrade
This commit is contained in:
parent
80ced31cc8
commit
246ab7dd0c
2
pom.xml
2
pom.xml
@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>skyblock</artifactId>
|
||||
<version>2.3.3-DEV</version>
|
||||
<version>2.3.3-DEV2</version>
|
||||
<packaging>jar</packaging>
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
|
@ -114,7 +114,8 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
new StructureCommand(),
|
||||
new com.songoda.skyblock.command.commands.admin.UpgradeCommand(),
|
||||
new StackableCommand(),
|
||||
new AdminBank()
|
||||
new AdminBank(),
|
||||
new SetMaxMembers()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -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 = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 2) {
|
||||
if (args[1].matches("[0-9]+")) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
UUID islandOwnerUUID;
|
||||
String targetPlayerName;
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
|
||||
islandOwnerUUID = targetPlayerOffline.getOwner();
|
||||
targetPlayerName = targetPlayerOffline.getName();
|
||||
} else {
|
||||
islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner();
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
}
|
||||
|
||||
int 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(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.WorldBorder.Enable")
|
||||
&& island.isBorder()) {
|
||||
islandManager.updateBorder(island);
|
||||
}
|
||||
} else {
|
||||
File islandDataFile = new File(skyblock.getDataFolder().toString() + "/island-data",
|
||||
islandOwnerUUID.toString() + ".yml");
|
||||
|
||||
if (!fileManager.isFileExist(islandDataFile)) {
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.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];
|
||||
}
|
||||
}
|
@ -60,7 +60,7 @@ public class Island {
|
||||
this.size = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getInt("Island.Size.Minimum");
|
||||
this.maxMembers = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getInt("Island.InitialMaxMembers", 3);
|
||||
.getInt("Island.Member.Capacity", 3);
|
||||
|
||||
if (this.size > 1000) {
|
||||
this.size = 50;
|
||||
|
@ -346,7 +346,7 @@ public class Information {
|
||||
new Placeholder[]{
|
||||
new Placeholder("%island_members",
|
||||
"" + (islandMembers.size() + islandOperators.size() + 1)),
|
||||
new Placeholder("%island_maxMembers", // %island_capacity
|
||||
new Placeholder("%island_capacity", // %island_capacity
|
||||
"" + island.getMaxMembers()),
|
||||
new Placeholder("%members", "" + islandMembers.size()),
|
||||
new Placeholder("%operators", "" + islandOperators.size())},
|
||||
|
@ -1219,7 +1219,7 @@ public class Upgrade {
|
||||
configLoad.getString("Menu.Admin.Upgrade.Members.Item.Tier.Displayname")
|
||||
.replace("%tier", "" + tier)),
|
||||
configLoad.getStringList("Menu.Admin.Upgrade.Members.Item.Tier.Lore"),
|
||||
new Placeholder[]{new Placeholder("%members", "" + upgrade.getValue()),
|
||||
new Placeholder[]{new Placeholder("%maxMembers", "" + upgrade.getValue()),
|
||||
new Placeholder("%cost",
|
||||
NumberUtil.formatNumberByDecimal(upgrade.getCost()))},
|
||||
null, null), i + 3);
|
||||
|
@ -26,7 +26,7 @@ public class UpgradeManager {
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
for (Upgrade.Type typeList : Upgrade.Type.values()) {
|
||||
if (typeList != Upgrade.Type.Size) {
|
||||
if (typeList != Upgrade.Type.Size && typeList != Upgrade.Type.Members) {
|
||||
List<Upgrade> upgrades = new ArrayList<>();
|
||||
|
||||
Upgrade upgrade = new Upgrade(configLoad.getDouble("Upgrades." + typeList.name() + ".Cost"));
|
||||
|
@ -9,7 +9,6 @@ Sound:
|
||||
# When disabled all sounds will be disabled.
|
||||
Enable: true
|
||||
Island:
|
||||
InitialMaxMembers: 3
|
||||
Size:
|
||||
# [!] Do not go over 1000 for both of these options.
|
||||
# The size of an Island when created.
|
||||
@ -91,6 +90,7 @@ Island:
|
||||
Height: 60
|
||||
Member:
|
||||
# Max amount of players allowed to be in a team.
|
||||
# Can be increased with Upgrades
|
||||
Capacity: 12
|
||||
Chat:
|
||||
# If island chat should be output to console
|
||||
|
@ -1756,7 +1756,7 @@ Menu:
|
||||
- ''
|
||||
- '&eClick to manage tiers!'
|
||||
Members:
|
||||
Displayname: '&aBorder Size'
|
||||
Displayname: '&aMax Members'
|
||||
Lore:
|
||||
- '&7Increases the max amount'
|
||||
- '&7of Island members.'
|
||||
@ -1864,7 +1864,7 @@ Menu:
|
||||
- '&7Max members&8: &f%maxMembers'
|
||||
- '&7Cost&8: &f$%cost'
|
||||
- ''
|
||||
- '&eLeft-Click to set size!'
|
||||
- '&eLeft-Click to set value!'
|
||||
- '&eMiddle-Click to remove!'
|
||||
- '&eRight-Click to set cost!'
|
||||
Displayname: '&bTier #%tier'
|
||||
|
Loading…
Reference in New Issue
Block a user