1.4r2 p2
This commit is contained in:
parent
f7f033c36d
commit
90a2a86374
59 changed files with 637 additions and 394 deletions
|
|
@ -6,12 +6,13 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
import org.gsdistance.grimmsServer.Stats.PlayerTitles;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AddTitle implements CommandExecutor {
|
||||
public AddTitle() {
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
if (args.length < 2) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.gsdistance.grimmsServer.Commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
|
|
@ -11,30 +12,41 @@ import org.gsdistance.grimmsServer.Constructable.Item.ItemDataHandler;
|
|||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
import org.gsdistance.grimmsServer.Shared;
|
||||
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DepositMoney implements CommandExecutor {
|
||||
public DepositMoney() {
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
ItemStack itemStack = ((Player) sender).getInventory().getItemInMainHand();
|
||||
ItemDataHandler itemDataHandler = new ItemDataHandler(itemStack, GrimmsServer.instance);
|
||||
Double banknoteValue = itemDataHandler.getItemNBTData("banknoteValue", PersistentDataType.DOUBLE);
|
||||
if (banknoteValue == null) {
|
||||
sender.sendMessage("Not a banknote.");
|
||||
return false;
|
||||
} else {
|
||||
PlayerStats playerStats = PlayerStats.getPlayerStats((Player) sender);
|
||||
playerStats.setStat("money", playerStats.getStat("money", Double.class) + banknoteValue * (double) itemStack.getAmount());
|
||||
((Player) sender).getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||
Double var10001 = banknoteValue * (double) itemStack.getAmount();
|
||||
sender.sendMessage("Deposited " + Shared.formatNumber(var10001) + " money.");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage("This command can only be run by a player.");
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command can only be run by a player.");
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack itemStack = ((Player) sender).getInventory().getItemInMainHand();
|
||||
|
||||
if (itemStack.getType() == Material.AIR) {
|
||||
sender.sendMessage(ChatColor.RED + "You are not holding anything to deposit.");
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemDataHandler itemDataHandler = new ItemDataHandler(itemStack, GrimmsServer.instance);
|
||||
Double banknoteValue = itemDataHandler.getItemNBTData("banknoteValue", PersistentDataType.DOUBLE);
|
||||
|
||||
if (banknoteValue == null) {
|
||||
sender.sendMessage(ChatColor.RED + "This item is not a valid banknote.");
|
||||
return false;
|
||||
}
|
||||
|
||||
PlayerStats playerStats = PlayerStats.getPlayerStats((Player) sender);
|
||||
double totalValue = banknoteValue * itemStack.getAmount();
|
||||
double currentBalance = playerStats.getStat("money", Double.class);
|
||||
|
||||
playerStats.setStat("money", currentBalance + totalValue);
|
||||
((Player) sender).getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Deposited " + ChatColor.GOLD + Shared.formatNumber(totalValue) + ChatColor.GREEN + ". New balance: " + ChatColor.GOLD + Shared.formatNumber(currentBalance + totalValue));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
import org.gsdistance.grimmsServer.Stats.PlayerTitles;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ExecutePlayer implements CommandExecutor {
|
||||
public ExecutePlayer() {
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
if (args.length == 0) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public class GAuthBaseCommand implements CommandExecutor {
|
|||
}
|
||||
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (args.length < 2 && !args[0].equals("autologin")) {
|
||||
if (args.length < 2 && (args.length == 0 || !args[0].equals("autologin"))) {
|
||||
sender.sendMessage(ChatColor.RED + "This command requires a password.");
|
||||
return false;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GConfigCommand;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Config.ActiveConfig;
|
||||
import org.gsdistance.grimmsServer.Config.ConfigKey;
|
||||
|
|
@ -9,11 +10,11 @@ public class Dump {
|
|||
}
|
||||
|
||||
public static boolean subCommand(Player player) {
|
||||
player.sendMessage("Config Dump:");
|
||||
player.sendMessage(ChatColor.GOLD + "=== Config Dump ===");
|
||||
|
||||
for (ConfigKey key : ConfigKey.values()) {
|
||||
String var10001 = key.getKey();
|
||||
player.sendMessage("|" + var10001 + ":" + ActiveConfig.getConfigValue(key, String.class));
|
||||
player.sendMessage(ChatColor.GRAY + "|" + ChatColor.YELLOW + var10001 + ChatColor.GRAY + ":" + ChatColor.WHITE + ActiveConfig.getConfigValue(key, String.class));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GDimensionCommand;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
|
@ -28,7 +29,7 @@ public class GDimBaseCommand implements CommandExecutor {
|
|||
return var10000;
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage("Only players can use this command.");
|
||||
sender.sendMessage(ChatColor.RED + "Only players can use this command.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ import org.bukkit.World;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Tp {
|
||||
public Tp() {
|
||||
}
|
||||
|
|
@ -28,7 +26,10 @@ public class Tp {
|
|||
player.sendMessage("World '" + worldName + "' does not exist.");
|
||||
return false;
|
||||
} else {
|
||||
targetPlayer.teleport(Objects.requireNonNull(GrimmsServer.instance.getServer().getWorld(worldName)).getSpawnLocation());
|
||||
World world = GrimmsServer.instance.getServer().getWorld(worldName);
|
||||
if (world != null) {
|
||||
targetPlayer.teleport(world.getSpawnLocation());
|
||||
}
|
||||
targetPlayer.sendMessage("Teleported to world '" + worldName + "'.");
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GFactionCommand;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Constructable.Data;
|
||||
import org.gsdistance.grimmsServer.Constructable.Faction;
|
||||
|
|
@ -16,24 +17,24 @@ public class Info {
|
|||
PlayerMetadata playerMetadata = PlayerMetadata.getPlayerMetadata(player);
|
||||
Faction faction = Faction.getFaction(playerMetadata.factionUUID);
|
||||
if (faction == null) {
|
||||
player.sendMessage("§cYou are not part of any faction.");
|
||||
player.sendMessage(ChatColor.RED + "You are not part of any faction.");
|
||||
return false;
|
||||
} else {
|
||||
for (Data<UUID, FactionRank> member : faction.members) {
|
||||
PlayerMetadata memberMetadata = PlayerMetadata.getOfflinePlayerMetadata(member.key());
|
||||
if (memberMetadata != null) {
|
||||
String var10001 = memberMetadata.nickname;
|
||||
player.sendMessage("§aMember: " + var10001 + " - Rank: " + member.value().toString());
|
||||
player.sendMessage(ChatColor.GREEN + "Member: " + ChatColor.YELLOW + var10001 + ChatColor.GREEN + " - Rank: " + ChatColor.YELLOW + member.value().toString());
|
||||
} else {
|
||||
player.sendMessage("§cMember with UUID " + member.key() + " not found.");
|
||||
player.sendMessage(ChatColor.RED + "Member with UUID " + member.key() + " not found.");
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMessage("§aFaction Name: " + faction.name);
|
||||
player.sendMessage("§aFaction UUID: " + faction.uuid);
|
||||
player.sendMessage("§aFaction Members Count: " + faction.members.size());
|
||||
player.sendMessage(ChatColor.GREEN + "Faction Name: " + ChatColor.YELLOW + faction.name);
|
||||
player.sendMessage(ChatColor.GREEN + "Faction UUID: " + ChatColor.YELLOW + faction.uuid);
|
||||
player.sendMessage(ChatColor.GREEN + "Faction Members Count: " + ChatColor.YELLOW + faction.members.size());
|
||||
int var6 = faction.claims.size();
|
||||
player.sendMessage("§aFaction Claimed Chunks: " + var6 + "/" + faction.getClaimLimit());
|
||||
player.sendMessage(ChatColor.GREEN + "Faction Claimed Chunks: " + ChatColor.YELLOW + var6 + ChatColor.GREEN + "/" + ChatColor.YELLOW + faction.getClaimLimit());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GFactionCommand;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Constructable.Data;
|
||||
import org.gsdistance.grimmsServer.Constructable.Faction;
|
||||
|
|
@ -22,20 +23,26 @@ public class Invite {
|
|||
if (targetPlayer != null && targetPlayer.isOnline()) {
|
||||
PlayerMetadata playerMetadata = PlayerMetadata.getPlayerMetadata(player);
|
||||
if (playerMetadata.factionUUID == null) {
|
||||
player.sendMessage("§cYou are not a member of any faction.");
|
||||
player.sendMessage(ChatColor.RED + "You are not a member of any faction.");
|
||||
return false;
|
||||
} else if (PlayerMetadata.getPlayerMetadata(targetPlayer).factionUUID != null) {
|
||||
player.sendMessage("§cThe player you are trying to invite is already in a faction.");
|
||||
player.sendMessage(ChatColor.RED + "The player you are trying to invite is already in a faction.");
|
||||
return false;
|
||||
} else {
|
||||
Faction faction = Faction.getFaction(playerMetadata.factionUUID);
|
||||
if (faction.getMemberRank(player.getUniqueId()).weight < FactionRank.MEMBER.weight) {
|
||||
player.sendMessage("§cYou do not have permission to invite players to your faction.");
|
||||
if (faction == null) {
|
||||
player.sendMessage(ChatColor.RED + "Your faction could not be found.");
|
||||
return false;
|
||||
} else if (faction.getMemberRank(player.getUniqueId()).weight < FactionRank.MEMBER.weight) {
|
||||
player.sendMessage(ChatColor.RED + "You do not have permission to invite players to your faction.");
|
||||
return false;
|
||||
} else {
|
||||
Request.newRequest((object) -> {
|
||||
Data<Player, UUID> data = (Data) object;
|
||||
Faction targetFaction = Faction.getFaction(data.value());
|
||||
if (targetFaction == null) {
|
||||
return null;
|
||||
}
|
||||
Player target = data.key();
|
||||
PlayerMetadata targetMetadata = PlayerMetadata.getPlayerMetadata(target);
|
||||
targetMetadata.factionUUID = targetFaction.uuid;
|
||||
|
|
@ -48,7 +55,7 @@ public class Invite {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
player.sendMessage("§cThe player you are trying to invite is not online.");
|
||||
player.sendMessage(ChatColor.RED + "The player you are trying to invite is not online.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GFactionCommand;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Constructable.Data;
|
||||
import org.gsdistance.grimmsServer.Constructable.Faction;
|
||||
|
|
@ -9,7 +10,6 @@ import org.gsdistance.grimmsServer.Constructable.Request;
|
|||
import org.gsdistance.grimmsServer.Data.FactionRank;
|
||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Join {
|
||||
|
|
@ -18,12 +18,12 @@ public class Join {
|
|||
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
if (args.length < 2) {
|
||||
player.sendMessage("§cUsage: /gfaction join <factionName>");
|
||||
player.sendMessage(ChatColor.RED + "Usage: /gfaction join <factionName>");
|
||||
return false;
|
||||
} else {
|
||||
PlayerMetadata playerMetadata = PlayerMetadata.getPlayerMetadata(player);
|
||||
if (playerMetadata.factionUUID != null) {
|
||||
player.sendMessage("§cYou are already a member of a faction. Leave your current faction first.");
|
||||
player.sendMessage(ChatColor.RED + "You are already a member of a faction. Leave your current faction first.");
|
||||
return false;
|
||||
} else {
|
||||
Faction[] factions = GrimmsServer.pds.retrieveAllData(Faction.class, "factions");
|
||||
|
|
@ -37,23 +37,26 @@ public class Join {
|
|||
}
|
||||
|
||||
if (targetFaction == null) {
|
||||
player.sendMessage("§cThe faction you are trying to join does not exist.");
|
||||
player.sendMessage(ChatColor.RED + "The faction you are trying to join does not exist.");
|
||||
return false;
|
||||
} else {
|
||||
UUID leaderUUID = targetFaction.getMemberWithRank(FactionRank.LEADER);
|
||||
if (leaderUUID == null) {
|
||||
player.sendMessage("§cThe faction does not have a leader.");
|
||||
player.sendMessage(ChatColor.RED + "The faction does not have a leader.");
|
||||
return false;
|
||||
} else {
|
||||
Player targetPlayer = Bukkit.getPlayer(leaderUUID);
|
||||
if (targetPlayer != null && targetPlayer.isOnline()) {
|
||||
if (Objects.requireNonNull(targetPlayer).isOnline()) {
|
||||
Request.newRequest((object) -> {
|
||||
Data<Player, UUID> data = (Data) object;
|
||||
Player target = data.key();
|
||||
PlayerMetadata targetMetadata = PlayerMetadata.getPlayerMetadata(target);
|
||||
Faction faction = Faction.getFaction(data.value());
|
||||
target.sendMessage("You have successfully joined the faction " + faction.name + ".");
|
||||
if (faction == null) {
|
||||
target.sendMessage(ChatColor.RED + "The faction no longer exists.");
|
||||
return null;
|
||||
}
|
||||
target.sendMessage(ChatColor.GREEN + "You have successfully joined the faction " + ChatColor.YELLOW + faction.name + ChatColor.GREEN + ".");
|
||||
targetMetadata.factionUUID = faction.uuid;
|
||||
faction.addMember(player.getUniqueId(), FactionRank.RECRUIT);
|
||||
faction.saveToFile();
|
||||
|
|
@ -62,13 +65,9 @@ public class Join {
|
|||
}, targetPlayer, player.getName() + " wants to join your faction.", Data.of(player, targetFaction.uuid));
|
||||
return true;
|
||||
} else {
|
||||
player.sendMessage("§cNo leader or officer is online to accept your request.");
|
||||
player.sendMessage(ChatColor.RED + "No leader or officer is online to accept your request.");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
player.sendMessage("§cThe faction leader is not online.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GFactionCommand;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Constructable.Faction;
|
||||
import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
||||
|
|
@ -13,16 +14,16 @@ public class Leave {
|
|||
PlayerMetadata playerMetadata = PlayerMetadata.getPlayerMetadata(player);
|
||||
Faction faction = Faction.getFaction(playerMetadata.factionUUID);
|
||||
if (faction == null) {
|
||||
player.sendMessage("§cThe faction you are trying to leave does not exist.");
|
||||
player.sendMessage(ChatColor.RED + "The faction you are trying to leave does not exist.");
|
||||
return false;
|
||||
} else if (faction.getMemberRank(player.getUniqueId()) == FactionRank.LEADER) {
|
||||
faction.delete();
|
||||
player.sendMessage("§aYou have successfully disbanded the faction " + faction.name + ".");
|
||||
player.sendMessage(ChatColor.GREEN + "You have successfully disbanded the faction " + ChatColor.YELLOW + faction.name + ChatColor.GREEN + ".");
|
||||
return false;
|
||||
} else {
|
||||
faction.removeMember(player.getUniqueId());
|
||||
playerMetadata.factionUUID = null;
|
||||
player.sendMessage("§aYou have successfully left the faction " + faction.name + ".");
|
||||
player.sendMessage(ChatColor.GREEN + "You have successfully left the faction " + ChatColor.YELLOW + faction.name + ChatColor.GREEN + ".");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GFactionCommand;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarFlag;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.boss.KeyedBossBar;
|
||||
import org.bukkit.entity.Player;
|
||||
|
|
@ -23,17 +23,17 @@ public class New {
|
|||
public static boolean subCommand(Player player, String[] args) {
|
||||
PlayerMetadata playerMetadata = PlayerMetadata.getPlayerMetadata(player);
|
||||
if (playerMetadata.factionUUID != null) {
|
||||
player.sendMessage("You are already in a faction.");
|
||||
player.sendMessage(ChatColor.RED + "You are already in a faction.");
|
||||
return false;
|
||||
} else if (args.length < 3) {
|
||||
return false;
|
||||
} else {
|
||||
Faction[] factions = GrimmsServer.pds.retrieveAllData(Faction.class, "factions");
|
||||
if (factions != null && Arrays.stream(factions).anyMatch((factionx) -> factionx.id.equalsIgnoreCase(args[1]))) {
|
||||
player.sendMessage("§cFaction already exists with this id.");
|
||||
player.sendMessage(ChatColor.RED + "Faction already exists with this id.");
|
||||
return false;
|
||||
} else if (!args[1].matches("[a-zA-Z0-9_]+")) {
|
||||
player.sendMessage("§cFaction id can only contain letters, numbers and underscores.");
|
||||
player.sendMessage(ChatColor.RED + "Faction id can only contain letters, numbers and underscores.");
|
||||
return false;
|
||||
} else {
|
||||
Faction faction = new Faction(args[1], new ArrayList(List.of(new Data(player.getUniqueId(), FactionRank.LEADER))));
|
||||
|
|
@ -45,7 +45,7 @@ public class New {
|
|||
bossBar.setVisible(true);
|
||||
bossBar.setProgress(0.0F);
|
||||
bossBar.setTitle(faction.name);
|
||||
player.sendMessage("Faction " + faction.id + " created successfully.");
|
||||
player.sendMessage(ChatColor.GREEN + "Faction " + ChatColor.YELLOW + faction.id + ChatColor.GREEN + " created successfully.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GFactionCommand;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Constructable.Faction;
|
||||
import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
||||
|
|
@ -23,7 +24,7 @@ public class SetRank {
|
|||
// Guard: Check if target player is online
|
||||
Player targetPlayer = Bukkit.getPlayer(args[1]);
|
||||
if (targetPlayer == null) {
|
||||
player.sendMessage("§cThe player you are trying to set the rank for is not found.");
|
||||
player.sendMessage(ChatColor.RED + "The player you are trying to set the rank for is not found.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -31,19 +32,19 @@ public class SetRank {
|
|||
PlayerMetadata playerMetadata = PlayerMetadata.getPlayerMetadata(player);
|
||||
Faction faction = Faction.getFaction(playerMetadata.factionUUID);
|
||||
if (faction == null) {
|
||||
player.sendMessage("§cYou are not a member of any faction.");
|
||||
player.sendMessage(ChatColor.RED + "You are not a member of any faction.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Guard: Check if target player belongs to the same faction
|
||||
if (!faction.isMember(targetPlayer.getUniqueId())) {
|
||||
player.sendMessage("§cThe player is not a member of your faction.");
|
||||
player.sendMessage(ChatColor.RED + "The player is not a member of your faction.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Guard: Hierarchy check (Cannot alter ranks of peers or superiors)
|
||||
if (faction.getMemberRank(player.getUniqueId()).weight <= faction.getMemberRank(targetPlayer.getUniqueId()).weight) {
|
||||
player.sendMessage("§cYou cannot set the rank of a player with the same or higher rank.");
|
||||
player.sendMessage(ChatColor.RED + "You cannot set the rank of a player with the same or higher rank.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -55,7 +56,7 @@ public class SetRank {
|
|||
.map(FactionRank::toString)
|
||||
.collect(Collectors.joining(", "));
|
||||
|
||||
player.sendMessage("§cInvalid rank specified. Valid ranks are: " + validRanks);
|
||||
player.sendMessage(ChatColor.RED + "Invalid rank specified. Valid ranks are: " + ChatColor.YELLOW + validRanks);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GFactionCommand;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Constructable.Faction;
|
||||
import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
||||
|
|
@ -13,14 +14,14 @@ public class UnClaimAll {
|
|||
PlayerMetadata playerMetadata = PlayerMetadata.getPlayerMetadata(player);
|
||||
Faction faction = Faction.getFaction(playerMetadata.factionUUID);
|
||||
if (faction == null) {
|
||||
player.sendMessage("§cYou are not in a faction.");
|
||||
player.sendMessage(ChatColor.RED + "You are not in a faction.");
|
||||
return false;
|
||||
} else if (faction.getMemberRank(player.getUniqueId()) != FactionRank.LEADER) {
|
||||
player.sendMessage("§cYou must be the leader of the faction to unclaim all land.");
|
||||
player.sendMessage(ChatColor.RED + "You must be the leader of the faction to unclaim all land.");
|
||||
return false;
|
||||
} else {
|
||||
faction.unClaimAllChunks();
|
||||
player.sendMessage("§aYou have successfully unclaimed all land for your faction.");
|
||||
player.sendMessage(ChatColor.GREEN + "You have successfully unclaimed all land for your faction.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,53 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GHelpCommand;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.gsdistance.grimmsServer.Data.HelpStrings;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GHelp implements CommandExecutor {
|
||||
public GHelp() {
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (args.length < 1) {
|
||||
return false;
|
||||
sender.sendMessage(ChatColor.GOLD + "=== Grimm'sServer Commands ===");
|
||||
sender.sendMessage(ChatColor.GRAY + "Use " + ChatColor.YELLOW + "/ghelp <command>" + ChatColor.GRAY + " for detailed help on a specific command.");
|
||||
sender.sendMessage("");
|
||||
|
||||
List<String> commands = new ArrayList<>(HelpStrings.helpStrings.keySet());
|
||||
commands.sort(String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
StringBuilder commandList = new StringBuilder(ChatColor.GRAY + "Available commands: ");
|
||||
for (int i = 0; i < commands.size(); i++) {
|
||||
if (i > 0) {
|
||||
commandList.append(ChatColor.GRAY).append(", ");
|
||||
}
|
||||
commandList.append(ChatColor.YELLOW).append(commands.get(i));
|
||||
}
|
||||
sender.sendMessage(commandList.toString());
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(ChatColor.GRAY + "Total commands: " + ChatColor.GREEN + commands.size());
|
||||
} else {
|
||||
sender.sendMessage("Help string for command " + args[0] + ":");
|
||||
sender.sendMessage(HelpStrings.getHelpString(args[0]));
|
||||
sender.sendMessage(HelpStrings.getHelpUsage(args[0]));
|
||||
return true;
|
||||
String commandName = args[0].toLowerCase();
|
||||
String helpString = HelpStrings.getHelpString(commandName);
|
||||
String helpUsage = HelpStrings.getHelpUsage(commandName);
|
||||
|
||||
if (helpString.equals("Not found.") && helpUsage.equals("Not found.")) {
|
||||
sender.sendMessage(ChatColor.RED + "Command '" + commandName + "' not found.");
|
||||
sender.sendMessage(ChatColor.GRAY + "Use " + ChatColor.YELLOW + "/ghelp" + ChatColor.GRAY + " to see all available commands.");
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GOLD + "=== Help for /" + commandName + " ===");
|
||||
sender.sendMessage(ChatColor.GRAY + "Description: " + ChatColor.WHITE + helpString);
|
||||
sender.sendMessage(ChatColor.GRAY + "Usage: " + ChatColor.YELLOW + helpUsage);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,12 +17,11 @@ public class DelHome {
|
|||
PlayerMetadata meta = PlayerMetadata.getPlayerMetadata(player);
|
||||
if (!meta.homes.containsKey(homeName)) {
|
||||
player.sendMessage("Home '" + homeName + "' does not exist.");
|
||||
return true;
|
||||
} else {
|
||||
meta.homes.remove(homeName);
|
||||
meta.saveToPDS();
|
||||
player.sendMessage("Home '" + homeName + "' deleted.");
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,13 @@ import org.bukkit.command.Command;
|
|||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HomeBaseCommand implements CommandExecutor {
|
||||
public HomeBaseCommand() {
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (sender instanceof Player player) {
|
||||
if (args.length == 0) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@ public class Homes {
|
|||
PlayerMetadata meta = PlayerMetadata.getPlayerMetadata(player);
|
||||
if (meta.homes.isEmpty()) {
|
||||
player.sendMessage("You have no homes set.");
|
||||
return true;
|
||||
} else {
|
||||
player.sendMessage("Your homes: " + String.join(", ", meta.homes.keySet()));
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,12 +17,11 @@ public class TpHome {
|
|||
PlayerMetadata meta = PlayerMetadata.getPlayerMetadata(player);
|
||||
if (!meta.homes.containsKey(homeName)) {
|
||||
player.sendMessage("Home '" + homeName + "' does not exist.");
|
||||
return true;
|
||||
} else {
|
||||
Location loc = meta.homes.get(homeName);
|
||||
player.teleport(loc.toBukkitLocation());
|
||||
player.sendMessage("Teleported to home '" + homeName + "'.");
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import org.bukkit.command.Command;
|
|||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -11,13 +12,16 @@ public class LogGrimmsServerCommands implements CommandExecutor {
|
|||
public LogGrimmsServerCommands() {
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
Map<String, Map<String, Object>> commands = GrimmsServer.instance.getDescription().getCommands();
|
||||
sender.sendMessage("__Available commands:");
|
||||
|
||||
for (String cmd : commands.keySet()) {
|
||||
sender.sendMessage("|" + cmd + ": " + GrimmsServer.instance.getCommand(cmd).getDescription());
|
||||
sender.sendMessage("|Usage: " + GrimmsServer.instance.getCommand(cmd).getUsage());
|
||||
Command cmdObj = GrimmsServer.instance.getCommand(cmd);
|
||||
if (cmdObj != null) {
|
||||
sender.sendMessage("|" + cmd + ": " + cmdObj.getDescription());
|
||||
sender.sendMessage("|Usage: " + cmdObj.getUsage());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Constructable.Item.ItemLevelHandler;
|
||||
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MakeItemLevelable implements CommandExecutor {
|
||||
public MakeItemLevelable() {
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
PlayerStats playerStats = PlayerStats.getPlayerStats((Player) sender);
|
||||
if (((Player) sender).getInventory().getItemInMainHand().getType().getMaxDurability() > 1) {
|
||||
|
|
|
|||
|
|
@ -4,12 +4,13 @@ import org.bukkit.command.Command;
|
|||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MarketBaseCommand implements CommandExecutor {
|
||||
public MarketBaseCommand() {
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (args.length == 0) {
|
||||
return false;
|
||||
} else if (sender instanceof Player player) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.gsdistance.grimmsServer.Commands.MarketComand;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
|
@ -12,22 +13,28 @@ public class Sell {
|
|||
}
|
||||
|
||||
public static boolean SubCommand(CommandSender sender, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Market market = Market.getMarket();
|
||||
ItemStack iS = ((Player) sender).getInventory().getItemInMainHand();
|
||||
if (iS.getType() == Material.AIR) {
|
||||
sender.sendMessage("You are not holding anything.");
|
||||
return false;
|
||||
} else {
|
||||
double sold = market.sell(iS, (Player) sender);
|
||||
market.saveMarket();
|
||||
int var10001 = iS.getAmount();
|
||||
sender.sendMessage("You sold " + var10001 + " many of " + iS.getType().getKey() + " for " + Shared.formatNumber(Math.max(0.25F, (double) Math.round(sold))));
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage("This command can only be run by a player.");
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command can only be run by a player.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Market market = Market.getMarket();
|
||||
ItemStack itemStack = ((Player) sender).getInventory().getItemInMainHand();
|
||||
|
||||
if (itemStack.getType() == Material.AIR) {
|
||||
sender.sendMessage(ChatColor.RED + "You are not holding anything to sell.");
|
||||
return false;
|
||||
}
|
||||
|
||||
double sold = market.sell(itemStack, (Player) sender);
|
||||
market.saveMarket();
|
||||
|
||||
if (sold <= 0) {
|
||||
sender.sendMessage(ChatColor.RED + "This item cannot be sold or has no value.");
|
||||
return false;
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "You sold " + ChatColor.GOLD + itemStack.getAmount() + ChatColor.GREEN + " of " + ChatColor.YELLOW + itemStack.getType().getKey().getKey() + ChatColor.GREEN + " for " + ChatColor.GOLD + Shared.formatNumber(Math.max(0.25, Math.round(sold))));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,62 +7,73 @@ import org.bukkit.command.CommandExecutor;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Nick implements CommandExecutor {
|
||||
public Nick() {
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player player) {
|
||||
if (args.length == 1) {
|
||||
if (!player.hasPermission("grimmsserver.nick")) {
|
||||
player.sendMessage(ChatColor.RED + "You don't have permission to change your nickname.");
|
||||
return true;
|
||||
} else {
|
||||
String newNick = ChatColor.translateAlternateColorCodes('&', args[0]);
|
||||
PlayerMetadata meta = PlayerMetadata.getPlayerMetadata(player);
|
||||
meta.nickname = newNick;
|
||||
meta.saveToPDS();
|
||||
String var13 = String.valueOf(ChatColor.GREEN);
|
||||
player.sendMessage(var13 + "Your nickname has been set to " + newNick);
|
||||
return true;
|
||||
}
|
||||
} else if (args.length >= 2) {
|
||||
if (!player.hasPermission("grimmsserver.nick.others")) {
|
||||
player.sendMessage(ChatColor.RED + "You don't have permission to set others' nicknames.");
|
||||
return true;
|
||||
} else {
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if (target == null) {
|
||||
player.sendMessage(ChatColor.RED + "Player not found.");
|
||||
return true;
|
||||
} else {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (int i = 1; i < args.length; ++i) {
|
||||
sb.append(args[i]);
|
||||
if (i < args.length - 1) {
|
||||
sb.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
String newNick = ChatColor.translateAlternateColorCodes('&', sb.toString());
|
||||
PlayerMetadata meta = PlayerMetadata.getPlayerMetadata(target);
|
||||
meta.nickname = newNick;
|
||||
meta.saveToPDS();
|
||||
String var10001 = String.valueOf(ChatColor.GREEN);
|
||||
player.sendMessage(var10001 + "Set " + target.getName() + "'s nickname to " + newNick);
|
||||
target.sendMessage(ChatColor.YELLOW + "Your nickname has been set to " + newNick + " by " + player.getName());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "Usage: /nick <nickname> OR /nick <player> <nickname>");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage("This command can only be run by a player.");
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command can only be run by a player.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
player.sendMessage(ChatColor.RED + "Usage: /nick <nickname> OR /nick <player> <nickname>");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 1) {
|
||||
if (!player.hasPermission("grimmsserver.nick")) {
|
||||
player.sendMessage(ChatColor.RED + "You don't have permission to change your nickname.");
|
||||
return true;
|
||||
}
|
||||
|
||||
String newNick = ChatColor.translateAlternateColorCodes('&', args[0]);
|
||||
if (newNick.isEmpty()) {
|
||||
player.sendMessage(ChatColor.RED + "Nickname cannot be empty.");
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerMetadata meta = PlayerMetadata.getPlayerMetadata(player);
|
||||
meta.nickname = newNick;
|
||||
meta.saveToPDS();
|
||||
player.sendMessage(ChatColor.GREEN + "Your nickname has been set to " + ChatColor.YELLOW + newNick);
|
||||
}
|
||||
|
||||
else {
|
||||
if (!player.hasPermission("grimmsserver.nick.others")) {
|
||||
player.sendMessage(ChatColor.RED + "You don't have permission to set others' nicknames.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if (target == null) {
|
||||
player.sendMessage(ChatColor.RED + "Player '" + args[0] + "' not found or not online.");
|
||||
return true;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 1; i < args.length; ++i) {
|
||||
sb.append(args[i]);
|
||||
if (i < args.length - 1) {
|
||||
sb.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
String newNick = ChatColor.translateAlternateColorCodes('&', sb.toString());
|
||||
if (newNick.isEmpty()) {
|
||||
player.sendMessage(ChatColor.RED + "Nickname cannot be empty.");
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerMetadata meta = PlayerMetadata.getPlayerMetadata(target);
|
||||
meta.nickname = newNick;
|
||||
meta.saveToPDS();
|
||||
player.sendMessage(ChatColor.GREEN + "Set " + ChatColor.YELLOW + target.getName() + ChatColor.GREEN + "'s nickname to " + ChatColor.YELLOW + newNick);
|
||||
target.sendMessage(ChatColor.YELLOW + "Your nickname has been set to " + newNick + ChatColor.YELLOW + " by " + ChatColor.GREEN + player.getName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
import org.gsdistance.grimmsServer.Stats.PlayerTitles;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class RemoveTitle implements CommandExecutor {
|
||||
public RemoveTitle() {
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
if (args.length < 2) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -4,15 +4,15 @@ import org.bukkit.command.Command;
|
|||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Constructable.Data;
|
||||
import org.gsdistance.grimmsServer.Constructable.Request;
|
||||
import org.gsdistance.grimmsServer.Data.PerSessionDataStorage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AcceptRequest implements CommandExecutor {
|
||||
public AcceptRequest() {
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
if (args.length == 0) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -8,12 +8,13 @@ import org.bukkit.entity.Player;
|
|||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
import org.gsdistance.grimmsServer.Shared;
|
||||
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SendMoney implements CommandExecutor {
|
||||
public SendMoney() {
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(ChatColor.RED + "Usage: /sendMoney <player> <amount>");
|
||||
|
|
|
|||
|
|
@ -7,12 +7,13 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SetPlayerStat implements CommandExecutor {
|
||||
public SetPlayerStat() {
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
if (args.length < 3) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.gsdistance.grimmsServer.Commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
|
|
@ -11,56 +12,88 @@ import org.gsdistance.grimmsServer.Constructable.Item.ItemDataHandler;
|
|||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
import org.gsdistance.grimmsServer.Shared;
|
||||
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public class WithdrawMoney implements CommandExecutor {
|
||||
private static final double MIN_BANKNOTE_VALUE = 25.0;
|
||||
|
||||
public WithdrawMoney() {
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
if (args.length == 0) {
|
||||
return false;
|
||||
} else if (Double.parseDouble(args[0]) < (double) 25.0F) {
|
||||
sender.sendMessage("Smallest banknote is 25 money.");
|
||||
return false;
|
||||
} else {
|
||||
PlayerStats playerStats = PlayerStats.getPlayerStats((Player) sender);
|
||||
if (playerStats.getStat("money", Double.class) < Double.parseDouble(args[0])) {
|
||||
sender.sendMessage("Not enough money.");
|
||||
return false;
|
||||
} else {
|
||||
if (args.length > 1) {
|
||||
double banknoteValue = Double.parseDouble(args[0]) / (double) Integer.parseInt(args[1]);
|
||||
if (banknoteValue < (double) 25.0F) {
|
||||
sender.sendMessage("Smallest banknote is 25 money.");
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack itemStack = new ItemStack(Material.PAPER, Integer.parseInt(args[1]));
|
||||
ItemDataHandler itemDataHandler = new ItemDataHandler(itemStack, GrimmsServer.instance);
|
||||
itemDataHandler.setItemNBTData("banknoteValue", banknoteValue, PersistentDataType.DOUBLE);
|
||||
itemDataHandler.setItemLoreData(List.of("Grimmnote - " + Shared.formatNumber(banknoteValue) + " Money", "Minted by " + sender.getName(), "Minted at " + LocalDateTime.now()));
|
||||
((Player) sender).getInventory().addItem(itemStack);
|
||||
sender.sendMessage("Gave " + args[1] + " banknotes.");
|
||||
} else {
|
||||
ItemStack itemStack = new ItemStack(Material.PAPER, 1);
|
||||
ItemDataHandler itemDataHandler = new ItemDataHandler(itemStack, GrimmsServer.instance);
|
||||
itemDataHandler.setItemNBTData("banknoteValue", Double.parseDouble(args[0]), PersistentDataType.DOUBLE);
|
||||
itemDataHandler.setItemLoreData(List.of("Grimmnote - " + Shared.formatNumber(Double.parseDouble(args[0])) + " Money", "Minted by " + sender.getName(), "Minted at " + LocalDateTime.now()));
|
||||
((Player) sender).getInventory().addItem(itemStack);
|
||||
}
|
||||
|
||||
playerStats.setStat("money", playerStats.getStat("money", Double.class) - Double.parseDouble(args[0]));
|
||||
sender.sendMessage("Withdrew " + args[0] + " money.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage("This command can only be run by a player.");
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command can only be run by a player.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Usage: /withdrawMoney <amount> [banknoteCount]");
|
||||
return false;
|
||||
}
|
||||
|
||||
double amount;
|
||||
try {
|
||||
amount = Double.parseDouble(args[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid amount: '" + args[0] + "'. Must be a number.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (amount < MIN_BANKNOTE_VALUE) {
|
||||
sender.sendMessage(ChatColor.RED + "Smallest banknote is " + ChatColor.GOLD + MIN_BANKNOTE_VALUE + ChatColor.RED + " money.");
|
||||
return false;
|
||||
}
|
||||
|
||||
PlayerStats playerStats = PlayerStats.getPlayerStats((Player) sender);
|
||||
double currentBalance = playerStats.getStat("money", Double.class);
|
||||
|
||||
if (currentBalance < amount) {
|
||||
sender.sendMessage(ChatColor.RED + "Not enough money. Current balance: " + ChatColor.GOLD + Shared.formatNumber(currentBalance));
|
||||
return false;
|
||||
}
|
||||
|
||||
int banknoteCount = 1;
|
||||
double banknoteValue = amount;
|
||||
|
||||
if (args.length > 1) {
|
||||
try {
|
||||
banknoteCount = Integer.parseInt(args[1]);
|
||||
if (banknoteCount <= 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Banknote count must be greater than 0.");
|
||||
return false;
|
||||
}
|
||||
banknoteValue = amount / banknoteCount;
|
||||
if (banknoteValue < MIN_BANKNOTE_VALUE) {
|
||||
sender.sendMessage(ChatColor.RED + "With these parameters, each banknote would be " + ChatColor.GOLD + Shared.formatNumber(banknoteValue) + ChatColor.RED + ". Minimum is " + ChatColor.GOLD + MIN_BANKNOTE_VALUE);
|
||||
return false;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid banknote count: '" + args[1] + "'. Must be a whole number.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack itemStack = new ItemStack(Material.PAPER, banknoteCount);
|
||||
ItemDataHandler itemDataHandler = new ItemDataHandler(itemStack, GrimmsServer.instance);
|
||||
itemDataHandler.setItemNBTData("banknoteValue", banknoteValue, PersistentDataType.DOUBLE);
|
||||
itemDataHandler.setItemLoreData(List.of(
|
||||
ChatColor.GOLD + "Grimmnote - " + Shared.formatNumber(banknoteValue) + " Money",
|
||||
ChatColor.GRAY + "Minted by " + sender.getName(),
|
||||
ChatColor.GRAY + "Minted at " + LocalDateTime.now()
|
||||
));
|
||||
|
||||
((Player) sender).getInventory().addItem(itemStack);
|
||||
playerStats.setStat("money", currentBalance - amount);
|
||||
|
||||
if (banknoteCount > 1) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Withdrew " + ChatColor.GOLD + Shared.formatNumber(amount) + ChatColor.GREEN + " into " + ChatColor.YELLOW + banknoteCount + ChatColor.GREEN + " banknotes of " + ChatColor.GOLD + Shared.formatNumber(banknoteValue) + ChatColor.GREEN + " each.");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GREEN + "Withdrew " + ChatColor.GOLD + Shared.formatNumber(amount) + ChatColor.GREEN + " into a banknote.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package org.gsdistance.grimmsServer.Constructable;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarFlag;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.boss.KeyedBossBar;
|
||||
import org.bukkit.entity.Player;
|
||||
|
|
@ -17,7 +17,6 @@ import org.gsdistance.grimmsServer.Shared;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Faction {
|
||||
|
|
@ -64,18 +63,18 @@ public class Faction {
|
|||
public boolean claimChunk(org.bukkit.Location location, Player player) {
|
||||
int claimLimit = this.getClaimLimit();
|
||||
if (this.claims.size() >= claimLimit) {
|
||||
player.sendMessage("§cYou have reached the claim limit for your faction.");
|
||||
player.sendMessage(ChatColor.RED + "You have reached the claim limit for your faction.");
|
||||
return false;
|
||||
} else if (this.getMemberRank(player.getUniqueId()).weight < FactionRank.MEMBER.weight) {
|
||||
player.sendMessage("§cYou must be above member rank to claim a chunk.");
|
||||
player.sendMessage(ChatColor.RED + "You must be above member rank to claim a chunk.");
|
||||
return false;
|
||||
} else if (location.getWorld() == null) {
|
||||
player.sendMessage("§cInvalid world.");
|
||||
player.sendMessage(ChatColor.RED + "Invalid world.");
|
||||
return false;
|
||||
} else {
|
||||
ChunkMetadata chunkMetadata = ChunkMetadata.getChunkMetadata(location.getChunk());
|
||||
if (chunkMetadata.factionUUID != null) {
|
||||
player.sendMessage("§cThis chunk is already claimed by a faction.");
|
||||
player.sendMessage(ChatColor.RED + "This chunk is already claimed by a faction.");
|
||||
return false;
|
||||
} else {
|
||||
Location claimLocation = new Location(location.getWorld().getName(), location.getChunk().getX(), 0.0F, location.getChunk().getZ());
|
||||
|
|
@ -84,7 +83,7 @@ public class Faction {
|
|||
chunkMetadata.saveToFile();
|
||||
this.saveToFile();
|
||||
this.getBossBar().setProgress((double) this.claims.size() / (double) claimLimit);
|
||||
player.sendMessage("§aChunk (" + claimLocation.x + "/" + claimLocation.z + ") claimed successfully.");
|
||||
player.sendMessage(ChatColor.GREEN + "Chunk (" + ChatColor.YELLOW + claimLocation.x + ChatColor.GREEN + "/" + ChatColor.YELLOW + claimLocation.z + ChatColor.GREEN + ") claimed successfully.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -92,16 +91,20 @@ public class Faction {
|
|||
|
||||
public boolean unClaimChunk(org.bukkit.Location location, Player player) {
|
||||
if (this.getMemberRank(player.getUniqueId()).weight < FactionRank.MEMBER.weight) {
|
||||
player.sendMessage("§cYou must be the above member rank to un-claim a chunk.");
|
||||
player.sendMessage(ChatColor.RED + "You must be the above member rank to un-claim a chunk.");
|
||||
return false;
|
||||
} else {
|
||||
Location claimLocation = new Location(Objects.requireNonNull(location.getWorld()).getName(), location.getChunk().getX(), 0.0F, location.getChunk().getZ());
|
||||
if (location.getWorld() == null) {
|
||||
player.sendMessage(ChatColor.RED + "World not found for this location.");
|
||||
return false;
|
||||
}
|
||||
Location claimLocation = new Location(location.getWorld().getName(), location.getChunk().getX(), 0.0F, location.getChunk().getZ());
|
||||
ChunkMetadata chunkMetadata = ChunkMetadata.getChunkMetadata(location.getChunk());
|
||||
if (chunkMetadata.factionUUID == null) {
|
||||
player.sendMessage("§cThis chunk is not claimed by any faction.");
|
||||
player.sendMessage(ChatColor.RED + "This chunk is not claimed by any faction.");
|
||||
return false;
|
||||
} else if (!chunkMetadata.factionUUID.equals(this.uuid)) {
|
||||
player.sendMessage("§cThis chunk is not claimed by your faction.");
|
||||
player.sendMessage(ChatColor.RED + "This chunk is not claimed by your faction.");
|
||||
return false;
|
||||
} else {
|
||||
this.claims.remove(claimLocation);
|
||||
|
|
@ -109,7 +112,7 @@ public class Faction {
|
|||
chunkMetadata.saveToFile();
|
||||
this.saveToFile();
|
||||
this.getBossBar().setProgress((double) this.claims.size() / (double) this.getClaimLimit());
|
||||
player.sendMessage("§aChunk (" + claimLocation.x + "/" + claimLocation.z + ") un-claimed successfully.");
|
||||
player.sendMessage(ChatColor.GREEN + "Chunk (" + ChatColor.YELLOW + claimLocation.x + ChatColor.GREEN + "/" + ChatColor.YELLOW + claimLocation.z + ChatColor.GREEN + ") un-claimed successfully.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -117,10 +120,11 @@ public class Faction {
|
|||
|
||||
public void unClaimAllChunks() {
|
||||
for (Location claim : this.claims) {
|
||||
if (Bukkit.getWorld(claim.world) == null) {
|
||||
World world = Bukkit.getWorld(claim.world);
|
||||
if (world == null) {
|
||||
GrimmsServer.logger.warning("World " + claim.world + " is not loaded or does not exist. Skipping chunk unclaim for " + claim.x + ", " + claim.z);
|
||||
} else {
|
||||
ChunkMetadata chunkMetadata = ChunkMetadata.getChunkMetadata(Bukkit.getWorld(claim.world).getChunkAt((int) Math.round(claim.x), (int) Math.round(claim.z)));
|
||||
ChunkMetadata chunkMetadata = ChunkMetadata.getChunkMetadata(world.getChunkAt((int) Math.round(claim.x), (int) Math.round(claim.z)));
|
||||
if (chunkMetadata != null) {
|
||||
chunkMetadata.factionUUID = null;
|
||||
chunkMetadata.saveToFile();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.gsdistance.grimmsServer.Constructable.Item;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
|
|
@ -73,9 +74,7 @@ public class ItemLevelHandler {
|
|||
this.setXp(totalXp);
|
||||
ItemStats.getItemStats(this.item).UpdateItemStats();
|
||||
if (levelUps > 0) {
|
||||
Player var10000 = this.player;
|
||||
String var10001 = String.valueOf(this.item.getType());
|
||||
var10000.sendMessage("Your " + var10001 + " has leveled up to " + this.getLevel() + "!");
|
||||
this.player.sendMessage(ChatColor.GREEN + "Your " + ChatColor.YELLOW + this.item.getType() + ChatColor.GREEN + " has leveled up to " + ChatColor.GOLD + this.getLevel() + ChatColor.GREEN + "!");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,11 @@ public class Location {
|
|||
this.x = location.getX();
|
||||
this.y = location.getY();
|
||||
this.z = location.getZ();
|
||||
this.world = Objects.requireNonNull(location.getWorld()).getName();
|
||||
World world = location.getWorld();
|
||||
if (world == null) {
|
||||
throw new IllegalArgumentException("Location world cannot be null");
|
||||
}
|
||||
this.world = world.getName();
|
||||
}
|
||||
|
||||
public Location(String world, double x, double y, double z) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.gsdistance.grimmsServer.Constructable;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Data.PerSessionDataStorage;
|
||||
|
||||
|
|
@ -31,8 +32,8 @@ public class Request {
|
|||
|
||||
public static void newRequest(Function<Object, ?> onAccept, Player forPlayer, String forPurpose, Object requestData) {
|
||||
Request request = new Request(onAccept, forPlayer, forPurpose, requestData);
|
||||
forPlayer.sendMessage("You have a new request: " + forPurpose);
|
||||
forPlayer.sendMessage("Accept with /acceptRequest " + request.requestId);
|
||||
forPlayer.sendMessage(ChatColor.GOLD + "You have a new request: " + ChatColor.WHITE + forPurpose);
|
||||
forPlayer.sendMessage(ChatColor.GRAY + "Accept with " + ChatColor.YELLOW + "/acceptRequest " + request.requestId);
|
||||
PerSessionDataStorage.dataStore.put("request-" + request.requestId, Data.of(request, Request.class));
|
||||
ArrayList<Integer> requestDataList = (ArrayList) PerSessionDataStorage.dataStore.get("requestData-" + forPlayer.getName()).key();
|
||||
requestDataList.add(request.requestId);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package org.gsdistance.grimmsServer.Constructable.World;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldType;
|
||||
|
||||
public class WorldMetadata {
|
||||
public final String name;
|
||||
|
|
@ -10,7 +11,11 @@ public class WorldMetadata {
|
|||
|
||||
public WorldMetadata(World world) {
|
||||
this.name = world.getName();
|
||||
this.worldType = world.getWorldType().getName();
|
||||
WorldType worldType = world.getWorldType();
|
||||
if (worldType == null) {
|
||||
throw new IllegalArgumentException("World type cannot be null");
|
||||
}
|
||||
this.worldType = worldType.getName();
|
||||
this.seed = world.getSeed();
|
||||
this.dimension = world.getEnvironment().getId();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public class StaticLists {
|
|||
if (e.getKey().getKey().toLowerCase().contains("boat")) {
|
||||
xpBlacklist.add(e);
|
||||
}
|
||||
} catch (IllegalArgumentException var5) {
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package org.gsdistance.grimmsServer.Events.Listeners;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Commands.GAuthCommand.GAuthBaseCommand;
|
||||
import org.gsdistance.grimmsServer.Constructable.JobTitle;
|
||||
import org.gsdistance.grimmsServer.Constructable.Market;
|
||||
import org.gsdistance.grimmsServer.Data.JobTitlesBaseValues;
|
||||
import org.gsdistance.grimmsServer.Data.Player.PlayerTitleChecker;
|
||||
|
|
@ -49,7 +49,7 @@ public class ServerTickEvent {
|
|||
double multiplier = (double) 1.0F + Math.pow((double) playerStats.getStat("level", Integer.class), 2.0F) / (double) 100.0F;
|
||||
double payCheck = Math.ceil(JobTitlesBaseValues.jobTitleBaseValues.getOrDefault(jobTitleId, null).paycheckSize() * multiplier);
|
||||
playerStats.setStat("money", playerStats.getStat("money", Double.class) + payCheck);
|
||||
player.sendMessage("You have received your paycheck: " + Shared.formatNumber(payCheck));
|
||||
player.sendMessage(ChatColor.GREEN + "You have received your paycheck: " + ChatColor.GOLD + Shared.formatNumber(payCheck));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import org.gsdistance.grimmsServer.GrimmsServer;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DynamicDimensionGen {
|
||||
|
|
@ -76,11 +75,17 @@ public class DynamicDimensionGen {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void unLoadWorlds() {
|
||||
Stopwatch sw = Stopwatch.createStarted();
|
||||
GrimmsServer.logger.info("Unloading worlds...");
|
||||
|
||||
for (String worldName : (List<String>) Objects.requireNonNull((List<?>) ActiveConfig.getConfigValue(ConfigKey.DISABLED_DIMENSIONS, List.class))) {
|
||||
List<String> disabledDimensions = ActiveConfig.getConfigValue(ConfigKey.DISABLED_DIMENSIONS, List.class);
|
||||
if (disabledDimensions == null) {
|
||||
GrimmsServer.logger.warning("No disabled dimensions configured.");
|
||||
return;
|
||||
}
|
||||
for (String worldName : disabledDimensions) {
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
if (world != null) {
|
||||
GrimmsServer.logger.info("Unloading world: " + worldName);
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ public class ItemIndexer {
|
|||
for (Material material : Material.values()) {
|
||||
if (material.isItem() && material != Material.AIR) {
|
||||
List<Recipe> recipes = Bukkit.getServer().getRecipesFor(new ItemStack(material));
|
||||
if (recipes != null && !recipes.isEmpty()) {
|
||||
if (!recipes.isEmpty()) {
|
||||
recipeCache.put(material, recipes);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.gsdistance.grimmsServer.Manage;
|
||||
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Commands.*;
|
||||
import org.gsdistance.grimmsServer.Commands.GAuthCommand.GAuthBaseCommand;
|
||||
|
|
@ -38,40 +39,86 @@ public class CommandRegistry {
|
|||
}
|
||||
|
||||
public static void registerCommands() {
|
||||
GrimmsServer.instance.getCommand("sendMoney").setExecutor(new SendMoney());
|
||||
GrimmsServer.instance.getCommand("makeItemLevelable").setExecutor(new MakeItemLevelable());
|
||||
GrimmsServer.instance.getCommand("setPlayerStat").setExecutor(new SetPlayerStat());
|
||||
GrimmsServer.instance.getCommand("addTitle").setExecutor(new AddTitle());
|
||||
GrimmsServer.instance.getCommand("executePlayer").setExecutor(new ExecutePlayer());
|
||||
GrimmsServer.instance.getCommand("grimmsServerCommands").setExecutor(new LogGrimmsServerCommands());
|
||||
GrimmsServer.instance.getCommand("withdrawMoney").setExecutor(new WithdrawMoney());
|
||||
GrimmsServer.instance.getCommand("depositMoney").setExecutor(new DepositMoney());
|
||||
GrimmsServer.instance.getCommand("acceptRequest").setExecutor(new AcceptRequest());
|
||||
GrimmsServer.instance.getCommand("acceptRequest").setTabCompleter(new RequestTabCompleter());
|
||||
GrimmsServer.instance.getCommand("removeTitle").setExecutor(new RemoveTitle());
|
||||
GrimmsServer.instance.getCommand("home").setExecutor(new HomeBaseCommand());
|
||||
GrimmsServer.instance.getCommand("home").setTabCompleter(new HomeTabCompleter());
|
||||
GrimmsServer.instance.getCommand("nick").setExecutor(new Nick());
|
||||
GrimmsServer.instance.getCommand("market").setExecutor(new MarketBaseCommand());
|
||||
GrimmsServer.instance.getCommand("market").setTabCompleter(new MarketTabCompleter());
|
||||
GrimmsServer.instance.getCommand("gUtil").setExecutor(new GUtilBaseCommand());
|
||||
GrimmsServer.instance.getCommand("gUtil").setTabCompleter(new GUtilTabCompleter());
|
||||
GrimmsServer.instance.getCommand("gLog").setExecutor(new GLogBaseCommand());
|
||||
GrimmsServer.instance.getCommand("gLog").setTabCompleter(new GLogTabCompleter());
|
||||
GrimmsServer.instance.getCommand("gDim").setExecutor(new GDimBaseCommand());
|
||||
GrimmsServer.instance.getCommand("gDim").setTabCompleter(new GDimTabCompleter());
|
||||
GrimmsServer.instance.getCommand("gFaction").setExecutor(new GFactionBaseCommand());
|
||||
GrimmsServer.instance.getCommand("gFaction").setTabCompleter(new GFactionTabCompleter());
|
||||
GrimmsServer.instance.getCommand("gConfig").setExecutor(new GConfigBaseCommand());
|
||||
GrimmsServer.instance.getCommand("gConfig").setTabCompleter(new GConfigTabCompleter());
|
||||
GrimmsServer.instance.getCommand("job").setExecutor(new JobBaseCommand());
|
||||
GrimmsServer.instance.getCommand("job").setTabCompleter(new JobTabCompleter());
|
||||
GrimmsServer.instance.getCommand("gHelp").setExecutor(new GHelp());
|
||||
GrimmsServer.instance.getCommand("gHelp").setTabCompleter(new GHelpTabCompleter());
|
||||
GrimmsServer.instance.getCommand("gAuth").setExecutor(new GAuthBaseCommand());
|
||||
GrimmsServer.instance.getCommand("gAuth").setTabCompleter(new GAuthTabCompleter());
|
||||
GrimmsServer.instance.getCommand("gDeco").setExecutor(new GDecoBaseCommand());
|
||||
GrimmsServer.instance.getCommand("gDeco").setTabCompleter(new GDecoTabCompleter());
|
||||
PluginCommand sendMoneyCmd = GrimmsServer.instance.getCommand("sendMoney");
|
||||
if (sendMoneyCmd != null) sendMoneyCmd.setExecutor(new SendMoney());
|
||||
PluginCommand makeItemLevelableCmd = GrimmsServer.instance.getCommand("makeItemLevelable");
|
||||
if (makeItemLevelableCmd != null) makeItemLevelableCmd.setExecutor(new MakeItemLevelable());
|
||||
PluginCommand setPlayerStatCmd = GrimmsServer.instance.getCommand("setPlayerStat");
|
||||
if (setPlayerStatCmd != null) setPlayerStatCmd.setExecutor(new SetPlayerStat());
|
||||
PluginCommand addTitleCmd = GrimmsServer.instance.getCommand("addTitle");
|
||||
if (addTitleCmd != null) addTitleCmd.setExecutor(new AddTitle());
|
||||
PluginCommand executePlayerCmd = GrimmsServer.instance.getCommand("executePlayer");
|
||||
if (executePlayerCmd != null) executePlayerCmd.setExecutor(new ExecutePlayer());
|
||||
PluginCommand grimmsServerCommandsCmd = GrimmsServer.instance.getCommand("grimmsServerCommands");
|
||||
if (grimmsServerCommandsCmd != null) grimmsServerCommandsCmd.setExecutor(new LogGrimmsServerCommands());
|
||||
PluginCommand withdrawMoneyCmd = GrimmsServer.instance.getCommand("withdrawMoney");
|
||||
if (withdrawMoneyCmd != null) withdrawMoneyCmd.setExecutor(new WithdrawMoney());
|
||||
PluginCommand depositMoneyCmd = GrimmsServer.instance.getCommand("depositMoney");
|
||||
if (depositMoneyCmd != null) depositMoneyCmd.setExecutor(new DepositMoney());
|
||||
PluginCommand acceptRequestCmd = GrimmsServer.instance.getCommand("acceptRequest");
|
||||
if (acceptRequestCmd != null) {
|
||||
acceptRequestCmd.setExecutor(new AcceptRequest());
|
||||
acceptRequestCmd.setTabCompleter(new RequestTabCompleter());
|
||||
}
|
||||
PluginCommand removeTitleCmd = GrimmsServer.instance.getCommand("removeTitle");
|
||||
if (removeTitleCmd != null) removeTitleCmd.setExecutor(new RemoveTitle());
|
||||
PluginCommand homeCmd = GrimmsServer.instance.getCommand("home");
|
||||
if (homeCmd != null) {
|
||||
homeCmd.setExecutor(new HomeBaseCommand());
|
||||
homeCmd.setTabCompleter(new HomeTabCompleter());
|
||||
}
|
||||
PluginCommand nickCmd = GrimmsServer.instance.getCommand("nick");
|
||||
if (nickCmd != null) nickCmd.setExecutor(new Nick());
|
||||
PluginCommand marketCmd = GrimmsServer.instance.getCommand("market");
|
||||
if (marketCmd != null) {
|
||||
marketCmd.setExecutor(new MarketBaseCommand());
|
||||
marketCmd.setTabCompleter(new MarketTabCompleter());
|
||||
}
|
||||
PluginCommand gUtilCmd = GrimmsServer.instance.getCommand("gUtil");
|
||||
if (gUtilCmd != null) {
|
||||
gUtilCmd.setExecutor(new GUtilBaseCommand());
|
||||
gUtilCmd.setTabCompleter(new GUtilTabCompleter());
|
||||
}
|
||||
PluginCommand gLogCmd = GrimmsServer.instance.getCommand("gLog");
|
||||
if (gLogCmd != null) {
|
||||
gLogCmd.setExecutor(new GLogBaseCommand());
|
||||
gLogCmd.setTabCompleter(new GLogTabCompleter());
|
||||
}
|
||||
PluginCommand gDimCmd = GrimmsServer.instance.getCommand("gDim");
|
||||
if (gDimCmd != null) {
|
||||
gDimCmd.setExecutor(new GDimBaseCommand());
|
||||
gDimCmd.setTabCompleter(new GDimTabCompleter());
|
||||
}
|
||||
PluginCommand gFactionCmd = GrimmsServer.instance.getCommand("gFaction");
|
||||
if (gFactionCmd != null) {
|
||||
gFactionCmd.setExecutor(new GFactionBaseCommand());
|
||||
gFactionCmd.setTabCompleter(new GFactionTabCompleter());
|
||||
}
|
||||
PluginCommand gConfigCmd = GrimmsServer.instance.getCommand("gConfig");
|
||||
if (gConfigCmd != null) {
|
||||
gConfigCmd.setExecutor(new GConfigBaseCommand());
|
||||
gConfigCmd.setTabCompleter(new GConfigTabCompleter());
|
||||
}
|
||||
PluginCommand jobCmd = GrimmsServer.instance.getCommand("job");
|
||||
if (jobCmd != null) {
|
||||
jobCmd.setExecutor(new JobBaseCommand());
|
||||
jobCmd.setTabCompleter(new JobTabCompleter());
|
||||
}
|
||||
PluginCommand gHelpCmd = GrimmsServer.instance.getCommand("gHelp");
|
||||
if (gHelpCmd != null) {
|
||||
gHelpCmd.setExecutor(new GHelp());
|
||||
gHelpCmd.setTabCompleter(new GHelpTabCompleter());
|
||||
}
|
||||
PluginCommand gAuthCmd = GrimmsServer.instance.getCommand("gAuth");
|
||||
if (gAuthCmd != null) {
|
||||
gAuthCmd.setExecutor(new GAuthBaseCommand());
|
||||
gAuthCmd.setTabCompleter(new GAuthTabCompleter());
|
||||
}
|
||||
PluginCommand gDecoCmd = GrimmsServer.instance.getCommand("gDeco");
|
||||
if (gDecoCmd != null) {
|
||||
gDecoCmd.setExecutor(new GDecoBaseCommand());
|
||||
gDecoCmd.setTabCompleter(new GDecoTabCompleter());
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean CanExecute(String command, Player player) {
|
||||
|
|
@ -79,7 +126,8 @@ public class CommandRegistry {
|
|||
if (!GAuthBaseCommand.isLoggedIn(player) && !command.equalsIgnoreCase("gAuth")) {
|
||||
return false;
|
||||
} else {
|
||||
List<String> disabledCommands = (List) ActiveConfig.getConfigValue(ConfigKey.DISABLED_COMMANDS, List.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> disabledCommands = ActiveConfig.getConfigValue(ConfigKey.DISABLED_COMMANDS, List.class);
|
||||
if (disabledCommands != null) {
|
||||
for (String disabledCommand : disabledCommands) {
|
||||
if (disabledCommand.equalsIgnoreCase(command)) {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,8 @@ public class GeneralChatHandler {
|
|||
}
|
||||
|
||||
String formattedMessage = String.format("%s: %s", nickname, message).replace("&timeF", LocalDateTime.now().toString()).replace("&world", player.getWorld().getName()).replace("&pos", player.getLocation().toString()).replace("&player", player.getName()).replace("&uuid", player.getUniqueId().toString()).replace("&date", LocalDateTime.now().toLocalDate().toString()).replace("&time", LocalDateTime.now().toLocalTime().toString()).replace("&nickname", nickname).replace("&day", String.valueOf(player.getWorld().getTime() / 24000L));
|
||||
List<String> bannedWords = (List) ActiveConfig.getConfigValue(ConfigKey.BANNED_WORDS, List.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> bannedWords = ActiveConfig.getConfigValue(ConfigKey.BANNED_WORDS, List.class);
|
||||
if (bannedWords != null) {
|
||||
String regex = "[ .-_,:;!?()\\[\\]{}\"'`~@#$%^&*+=|<>/\\\\]+";
|
||||
String normalizedMessage = message.replaceAll(regex, "").toLowerCase();
|
||||
|
|
@ -70,7 +71,7 @@ public class GeneralChatHandler {
|
|||
if (!Boolean.FALSE.equals(ActiveConfig.getConfigValue(ConfigKey.JOIN_MESSAGE, Boolean.class))) {
|
||||
PlayerMetadata metadata = PlayerMetadata.getPlayerMetadata(player);
|
||||
PlayerStats playerStats = PlayerStats.getPlayerStats(player);
|
||||
ArrayList<String> message = new ArrayList();
|
||||
ArrayList<String> message = new ArrayList<>();
|
||||
if (metadata.firstJoin) {
|
||||
message.add("Welcome to the server, " + player.getName() + ".");
|
||||
message.add("This server is running on GMSv" + GrimmsServer.instance.getDescription().getVersion() + ".");
|
||||
|
|
@ -90,7 +91,7 @@ public class GeneralChatHandler {
|
|||
}
|
||||
|
||||
public static void authMessage(Player player) {
|
||||
ArrayList<String> message = new ArrayList();
|
||||
ArrayList<String> message = new ArrayList<>();
|
||||
if (!GrimmsServer.instance.getServer().isEnforcingSecureProfiles()) {
|
||||
PlayerStats playerStats = PlayerStats.getPlayerStats(player);
|
||||
if (playerStats.getStat("pass", String.class).isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.gsdistance.grimmsServer;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Player;
|
||||
|
|
@ -20,7 +21,9 @@ public class Shared {
|
|||
if (Boolean.TRUE.equals(ActiveConfig.getConfigValue(ConfigKey.FORCE_DISABLE_BC, Boolean.class))) {
|
||||
GrimmsServer.logger.info("Broadcast is disabled by configuration.");
|
||||
} else {
|
||||
GrimmsServer.instance.getServer().broadcastMessage("[" + GrimmsServer.instance.getDescription().getPrefix() + "-BC]: " + (prefix == null ? "" : prefix) + message);
|
||||
String formattedPrefix = prefix == null ? "" : ChatColor.translateAlternateColorCodes('&', prefix);
|
||||
String formattedMessage = ChatColor.translateAlternateColorCodes('&', message);
|
||||
GrimmsServer.instance.getServer().broadcastMessage(ChatColor.GOLD + "[" + ChatColor.YELLOW + GrimmsServer.instance.getDescription().getPrefix() + ChatColor.GOLD + "-BC]: " + ChatColor.WHITE + formattedPrefix + formattedMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public class PlayerStats {
|
|||
}
|
||||
}
|
||||
|
||||
public void changeStat(String stat, int amount) {
|
||||
public void changeStat(String stat, double amount) {
|
||||
PersistentDataType type = Stats.get(stat);
|
||||
if (type == null) {
|
||||
GrimmsServer.logger.warning("Stat " + stat + " does not exist.");
|
||||
|
|
@ -77,14 +77,14 @@ public class PlayerStats {
|
|||
currentStat = 0;
|
||||
}
|
||||
|
||||
this.dataContainer.set(new NamespacedKey(this.plugin, stat), PersistentDataType.INTEGER, currentStat + amount);
|
||||
this.dataContainer.set(new NamespacedKey(this.plugin, stat), PersistentDataType.INTEGER, currentStat + (int) amount);
|
||||
} else if (type == PersistentDataType.DOUBLE) {
|
||||
Double currentStat = this.dataContainer.get(new NamespacedKey(this.plugin, stat), PersistentDataType.DOUBLE);
|
||||
if (currentStat == null) {
|
||||
currentStat = (double) 0.0F;
|
||||
}
|
||||
|
||||
this.dataContainer.set(new NamespacedKey(this.plugin, stat), PersistentDataType.DOUBLE, currentStat + (double) amount);
|
||||
this.dataContainer.set(new NamespacedKey(this.plugin, stat), PersistentDataType.DOUBLE, currentStat + amount);
|
||||
} else if (type == PersistentDataType.LONG) {
|
||||
Long currentStat = this.dataContainer.get(new NamespacedKey(this.plugin, stat), PersistentDataType.LONG);
|
||||
if (currentStat == null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue