1.5r3 p1
This commit is contained in:
parent
5856a07c63
commit
45678728e6
26 changed files with 125 additions and 14 deletions
|
|
@ -23,6 +23,7 @@ public class GDecoBaseCommand implements CommandExecutor {
|
|||
yield SelectTitle.subCommand(player, args[1]);
|
||||
}
|
||||
case "cleartitle" -> SelectTitle.subCommand(player, "");
|
||||
case "toggleprestigedeco" -> TogglePrestigeDeco.subCommand(player);
|
||||
default -> false;
|
||||
};
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
public class GDecoTabCompleter implements TabCompleter {
|
||||
public static final List<String> subCommands = List.of("selectTitle", "clearTitle");
|
||||
public static final List<String> subCommands = List.of("selectTitle", "clearTitle", "togglePrestigeDeco");
|
||||
|
||||
public GDecoTabCompleter() {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GDecoCommand;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
||||
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||
|
||||
public class TogglePrestigeDeco {
|
||||
public static boolean subCommand(Player player) {
|
||||
PlayerMetadata metadata = PlayerMetadata.getPlayerMetadata(player);
|
||||
PlayerStats playerStats = PlayerStats.getPlayerStats(player);
|
||||
|
||||
int prestige = playerStats.getStat("prestige", Integer.class);
|
||||
|
||||
if (prestige == 0) {
|
||||
player.sendMessage(ChatColor.RED + "You must have at least prestige 1 to use the prestige decoration.");
|
||||
return false;
|
||||
}
|
||||
|
||||
metadata.showPrestigeDeco = !metadata.showPrestigeDeco;
|
||||
metadata.saveToPDS();
|
||||
|
||||
if (metadata.showPrestigeDeco) {
|
||||
player.sendMessage(ChatColor.GREEN + "Prestige decoration enabled. Your chat messages will show [" + prestige + "] in dark purple.");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.GREEN + "Prestige decoration disabled.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,30 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GLevelCommand;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
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 GLevelBaseCommand implements CommandExecutor {
|
||||
public GLevelBaseCommand() {
|
||||
}
|
||||
|
||||
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
|
||||
return false;
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Usage: /gLevel <prestige>");
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "prestige":
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command can only be used by players.");
|
||||
return false;
|
||||
}
|
||||
return Prestige.subCommand((Player) sender);
|
||||
default:
|
||||
sender.sendMessage(ChatColor.RED + "Unknown subcommand. Usage: /gLevel <prestige>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,12 @@ import org.jetbrains.annotations.Nullable;
|
|||
import java.util.List;
|
||||
|
||||
public class GLevelTabCompleter implements TabCompleter {
|
||||
public GLevelTabCompleter() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
|
||||
if (strings.length == 1) {
|
||||
return List.of("prestige");
|
||||
}
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,39 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GLevelCommand;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Constructable.Player.PlayerLevelHandler;
|
||||
import org.gsdistance.grimmsServer.Manage.GeneralChatHandler;
|
||||
import org.gsdistance.grimmsServer.Shared;
|
||||
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||
|
||||
public class Prestige {
|
||||
public static boolean subCommand(Player player) {
|
||||
return false;
|
||||
PlayerStats playerStats = PlayerStats.getPlayerStats(player);
|
||||
PlayerLevelHandler levelHandler = PlayerLevelHandler.getLevelHandler(player);
|
||||
|
||||
int currentLevel = levelHandler.getLevel();
|
||||
int currentPrestige = playerStats.getStat("prestige", Integer.class);
|
||||
long requiredLevel = (currentPrestige + 1) * 15L;
|
||||
|
||||
if (currentLevel <= requiredLevel) {
|
||||
player.sendMessage(ChatColor.RED + "You must be at least level " + requiredLevel + " to prestige.");
|
||||
return false;
|
||||
}
|
||||
|
||||
int newPrestige = currentPrestige + 1;
|
||||
long currentPrestigePoints = playerStats.getStat("prestigePoints", Long.class);
|
||||
|
||||
playerStats.setStat("prestige", newPrestige);
|
||||
playerStats.setStat("prestigePoints", currentPrestigePoints + newPrestige);
|
||||
playerStats.setStat("level", 0);
|
||||
playerStats.setStat("xp", 0.0);
|
||||
playerStats.setStat("xp_required", levelHandler.getXpToLevel());
|
||||
|
||||
player.sendMessage(ChatColor.GREEN + "You have prestiged to prestige " + newPrestige + "!");
|
||||
player.sendMessage(ChatColor.GOLD + "You received " + newPrestige + " prestige points. Total: " + (currentPrestigePoints + newPrestige));
|
||||
Shared.Broadcast(ChatColor.DARK_PURPLE + "[" + player.getName() + "] has prestiged to " + newPrestige + "!", null);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ public class Market {
|
|||
for (Enchantment e : enchantments.keySet()) {
|
||||
Double enchantValue = EnchantBaseValues.enchantBaseValues.get(e);
|
||||
if (enchantValue != null) {
|
||||
rt += enchantValue * (double) enchantments.get(e);
|
||||
rt += enchantValue * Math.sqrt(enchantments.get(e));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ public class PlayerMetadata {
|
|||
public List<String> settings;
|
||||
public String decoTitle;
|
||||
public boolean factionChatEnabled = false;
|
||||
public boolean showPrestigeDeco = false;
|
||||
|
||||
public PlayerMetadata(Player player) {
|
||||
this.rank = PlayerRank.DEFAULT;
|
||||
|
|
@ -63,7 +64,6 @@ public class PlayerMetadata {
|
|||
if (this.settings == null) {
|
||||
this.settings = new ArrayList<>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void logMetadata() {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import org.gsdistance.grimmsServer.Commands.GConfigCommand.GConfigBaseCommand;
|
|||
import org.gsdistance.grimmsServer.Commands.GConfigCommand.GConfigTabCompleter;
|
||||
import org.gsdistance.grimmsServer.Commands.GDecoCommand.GDecoBaseCommand;
|
||||
import org.gsdistance.grimmsServer.Commands.GDecoCommand.GDecoTabCompleter;
|
||||
import org.gsdistance.grimmsServer.Commands.GLevelCommand.GLevelBaseCommand;
|
||||
import org.gsdistance.grimmsServer.Commands.GLevelCommand.GLevelTabCompleter;
|
||||
import org.gsdistance.grimmsServer.Commands.GDimensionCommand.GDimBaseCommand;
|
||||
import org.gsdistance.grimmsServer.Commands.GDimensionCommand.GDimTabCompleter;
|
||||
import org.gsdistance.grimmsServer.Commands.GFactionCommand.GFactionBaseCommand;
|
||||
|
|
@ -119,6 +121,11 @@ public class CommandRegistry {
|
|||
gDecoCmd.setExecutor(new GDecoBaseCommand());
|
||||
gDecoCmd.setTabCompleter(new GDecoTabCompleter());
|
||||
}
|
||||
PluginCommand gLevelCmd = GrimmsServer.instance.getCommand("gLevel");
|
||||
if (gLevelCmd != null) {
|
||||
gLevelCmd.setExecutor(new GLevelBaseCommand());
|
||||
gLevelCmd.setTabCompleter(new GLevelTabCompleter());
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean CanExecute(String command, Player player) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.gsdistance.grimmsServer.Manage;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Config.ActiveConfig;
|
||||
|
|
@ -38,6 +39,7 @@ public class GeneralChatHandler {
|
|||
|
||||
public static String handleMessage(String message, Player player) {
|
||||
PlayerMetadata metadata = PlayerMetadata.getPlayerMetadata(player);
|
||||
PlayerStats playerStats = PlayerStats.getPlayerStats(player);
|
||||
String nickname = metadata != null ? metadata.nickname : player.getName();
|
||||
|
||||
// Optimized: Don't fetch metadata twice
|
||||
|
|
@ -45,6 +47,12 @@ public class GeneralChatHandler {
|
|||
nickname = "(" + metadata.decoTitle + ") " + nickname;
|
||||
}
|
||||
|
||||
int prestige = playerStats.getStat("prestige", Integer.class);
|
||||
|
||||
if (metadata != null && metadata.showPrestigeDeco && prestige > 0) {
|
||||
nickname = ChatColor.DARK_PURPLE + "[" + prestige + "] " + ChatColor.RESET + nickname;
|
||||
}
|
||||
|
||||
if (metadata != null) {
|
||||
Faction faction = Faction.getFaction(metadata.factionUUID);
|
||||
if (faction != null) {
|
||||
|
|
|
|||
|
|
@ -112,6 +112,8 @@ public class PlayerStats {
|
|||
Stats.put("jobTitle", PersistentDataType.STRING);
|
||||
Stats.put("pass", PersistentDataType.STRING);
|
||||
Stats.put("autologin", PersistentDataType.BOOLEAN);
|
||||
Stats.put("prestige", PersistentDataType.INTEGER);
|
||||
Stats.put("prestigePoints", PersistentDataType.LONG);
|
||||
StatNames = new Hashtable();
|
||||
StatNames.put("death_count", "Death Count");
|
||||
StatNames.put("money", "Money");
|
||||
|
|
@ -127,7 +129,9 @@ public class PlayerStats {
|
|||
StatNames.put("jobTitle", "Job");
|
||||
StatNames.put("pass", "Password");
|
||||
StatNames.put("autologin", "Login Automatically");
|
||||
StatOrder = List.of("death_count", "money", "total_kill_count", "join_count", "tPoint", "block_break_count", "sent_messages", "level", "xp", "xp_required", "intelligence", "jobTitle");
|
||||
StatDefaultValues = Map.ofEntries(Map.entry("death_count", 0), Map.entry("money", (double) 0.0F), Map.entry("total_kill_count", 0), Map.entry("join_count", 0), Map.entry("tPoint", (double) 0.0F), Map.entry("block_break_count", 0L), Map.entry("level", 1), Map.entry("xp", (double) 0.0F), Map.entry("xp_required", (double) 100.0F), Map.entry("sent_messages", 0L), Map.entry("intelligence", (new Random()).nextInt(0, 100)), Map.entry("jobTitle", ""), Map.entry("pass", ""), Map.entry("autologin", false));
|
||||
StatNames.put("prestige", "Prestige");
|
||||
StatNames.put("prestigePoints", "Prestige Points");
|
||||
StatOrder = List.of("death_count", "money", "total_kill_count", "join_count", "tPoint", "block_break_count", "sent_messages", "level", "xp", "xp_required", "intelligence", "jobTitle", "prestige", "prestigePoints");
|
||||
StatDefaultValues = Map.ofEntries(Map.entry("death_count", 0), Map.entry("money", (double) 0.0F), Map.entry("total_kill_count", 0), Map.entry("join_count", 0), Map.entry("tPoint", (double) 0.0F), Map.entry("block_break_count", 0L), Map.entry("level", 1), Map.entry("xp", (double) 0.0F), Map.entry("xp_required", (double) 100.0F), Map.entry("sent_messages", 0L), Map.entry("intelligence", (new Random()).nextInt(0, 100)), Map.entry("jobTitle", ""), Map.entry("pass", ""), Map.entry("autologin", false), Map.entry("prestige", 0), Map.entry("prestigePoints", 0L));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue