1.5.6 p1
This commit is contained in:
parent
5507b1eabf
commit
8c75f6fd38
21 changed files with 455 additions and 355 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -650,7 +650,7 @@ code + .copy-button {
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function configurationCacheProblems() { return (
|
function configurationCacheProblems() { return (
|
||||||
// begin-report-data
|
// begin-report-data
|
||||||
{"diagnostics":[{"locations":[{}],"problem":[{"text":"Properties should be assigned using the 'propName = value' syntax. Setting a property via the Gradle-generated 'propName value' or 'propName(value)' syntax in Groovy DSL has been deprecated."}],"severity":"WARNING","problemDetails":[{"text":"This is scheduled to be removed in Gradle 10.0."}],"contextualLabel":"Properties should be assigned using the 'propName = value' syntax. Setting a property via the Gradle-generated 'propName value' or 'propName(value)' syntax in Groovy DSL has been deprecated.","documentationLink":"https://docs.gradle.org/8.14.5/userguide/upgrading_version_8.html#groovy_space_assignment_syntax","problemId":[{"name":"deprecation","displayName":"Deprecation"},{"name":"properties-should-be-assigned-using-the-propname-value-syntax-setting-a-property-via-the-gradle-generated-propname-value-or-propname-value-syntax-in-groovy-dsl","displayName":"Properties should be assigned using the 'propName = value' syntax. Setting a property via the Gradle-generated 'propName value' or 'propName(value)' syntax in Groovy DSL has been deprecated."}],"solutions":[[{"text":"Use assignment ('filteringCharset = <value>') instead."}]]}],"problemsReport":{"totalProblemCount":1,"buildName":"GrimmsServer","requestedTasks":"build","documentationLink":"https://docs.gradle.org/8.14.5/userguide/reporting_problems.html","documentationLinkCaption":"Problem report","summaries":[]}}
|
{"diagnostics":[{"locations":[{}],"problem":[{"text":"Properties should be assigned using the 'propName = value' syntax. Setting a property via the Gradle-generated 'propName value' or 'propName(value)' syntax in Groovy DSL has been deprecated."}],"severity":"WARNING","problemDetails":[{"text":"This is scheduled to be removed in Gradle 10.0."}],"contextualLabel":"Properties should be assigned using the 'propName = value' syntax. Setting a property via the Gradle-generated 'propName value' or 'propName(value)' syntax in Groovy DSL has been deprecated.","documentationLink":"https://docs.gradle.org/8.14.5/userguide/upgrading_version_8.html#groovy_space_assignment_syntax","problemId":[{"name":"deprecation","displayName":"Deprecation"},{"name":"properties-should-be-assigned-using-the-propname-value-syntax-setting-a-property-via-the-gradle-generated-propname-value-or-propname-value-syntax-in-groovy-dsl","displayName":"Properties should be assigned using the 'propName = value' syntax. Setting a property via the Gradle-generated 'propName value' or 'propName(value)' syntax in Groovy DSL has been deprecated."}],"solutions":[[{"text":"Use assignment ('filteringCharset = <value>') instead."}]]},{"locations":[{"path":"/home/tyuxx/IdeaProjects/GrimmsServer/src/main/java/org/gsdistance/grimmsServer/Commands/MarketComand/BuyEnchantment.java"},{"taskPath":":compileJava"}],"problem":[{"text":"/home/tyuxx/IdeaProjects/GrimmsServer/src/main/java/org/gsdistance/grimmsServer/Commands/MarketComand/BuyEnchantment.java uses or overrides a deprecated API."}],"severity":"ADVICE","problemDetails":[{"text":"Note: /home/tyuxx/IdeaProjects/GrimmsServer/src/main/java/org/gsdistance/grimmsServer/Commands/MarketComand/BuyEnchantment.java uses or overrides a deprecated API."}],"contextualLabel":"/home/tyuxx/IdeaProjects/GrimmsServer/src/main/java/org/gsdistance/grimmsServer/Commands/MarketComand/BuyEnchantment.java uses or overrides a deprecated API.","problemId":[{"name":"java","displayName":"Java compilation"},{"name":"compilation","displayName":"Compilation"},{"name":"compiler.note.deprecated.filename","displayName":"/home/tyuxx/IdeaProjects/GrimmsServer/src/main/java/org/gsdistance/grimmsServer/Commands/MarketComand/BuyEnchantment.java uses or overrides a deprecated API."}]},{"locations":[{"path":"/home/tyuxx/IdeaProjects/GrimmsServer/src/main/java/org/gsdistance/grimmsServer/Commands/MarketComand/BuyEnchantment.java"},{"taskPath":":compileJava"}],"problem":[{"text":"Recompile with -Xlint:deprecation for details."}],"severity":"ADVICE","problemDetails":[{"text":"Note: Recompile with -Xlint:deprecation for details."}],"contextualLabel":"Recompile with -Xlint:deprecation for details.","problemId":[{"name":"java","displayName":"Java compilation"},{"name":"compilation","displayName":"Compilation"},{"name":"compiler.note.deprecated.recompile","displayName":"Recompile with -Xlint:deprecation for details."}]}],"problemsReport":{"totalProblemCount":3,"buildName":"GrimmsServer","requestedTasks":"build","documentationLink":"https://docs.gradle.org/8.14.5/userguide/reporting_problems.html","documentationLinkCaption":"Problem report","summaries":[]}}
|
||||||
// end-report-data
|
// end-report-data
|
||||||
);}
|
);}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -1,36 +1,34 @@
|
||||||
package org.gsdistance.grimmsServer.Commands;
|
package org.gsdistance.grimmsServer.Commands.GUtilCommand;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||||
import org.gsdistance.grimmsServer.Stats.PlayerTitles;
|
import org.gsdistance.grimmsServer.Stats.PlayerTitles;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class AddTitle implements CommandExecutor {
|
public class AddTitle {
|
||||||
public AddTitle() {
|
public AddTitle() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public static boolean subCommand(@NotNull CommandSender sender, @NotNull String[] args) {
|
||||||
if (args.length < 2) {
|
if (args.length < 3) {
|
||||||
return false;
|
return false;
|
||||||
} else if (!PlayerTitles.titles.containsKey(args[1])) {
|
} else if (!PlayerTitles.titles.containsKey(args[2])) {
|
||||||
sender.sendMessage("Title not found.");
|
sender.sendMessage("Title not found.");
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
Player player = GrimmsServer.instance.getServer().getPlayer(args[0]);
|
Player player = GrimmsServer.instance.getServer().getPlayer(args[1]);
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
sender.sendMessage("Player not found.");
|
sender.sendMessage("Player not found.");
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
PlayerTitles playerTitles = PlayerTitles.getPlayerTitles(player);
|
PlayerTitles playerTitles = PlayerTitles.getPlayerTitles(player);
|
||||||
if (playerTitles.hasTitle(args[1])) {
|
if (playerTitles.hasTitle(args[2])) {
|
||||||
sender.sendMessage("Player already has this title.");
|
sender.sendMessage("Player already has this title.");
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
playerTitles.addTitle(args[1]);
|
playerTitles.addTitle(args[2]);
|
||||||
sender.sendMessage("Title " + args[1] + " added to " + player.getDisplayName() + ".");
|
sender.sendMessage("Title " + args[2] + " added to " + player.getDisplayName() + ".");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -87,6 +87,12 @@ public class GUtilBaseCommand implements CommandExecutor {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
case "addtitle" -> {
|
||||||
|
return AddTitle.subCommand(sender, args);
|
||||||
|
}
|
||||||
|
case "removetitle" -> {
|
||||||
|
return RemoveTitle.subCommand(sender, args);
|
||||||
|
}
|
||||||
default -> {
|
default -> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
||||||
import org.gsdistance.grimmsServer.Data.Player.PlayerInventoryData;
|
import org.gsdistance.grimmsServer.Data.Player.PlayerInventoryData;
|
||||||
|
import org.gsdistance.grimmsServer.Stats.PlayerTitles;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
|
@ -17,7 +18,7 @@ import java.util.stream.Stream;
|
||||||
|
|
||||||
public class GUtilTabCompleter implements TabCompleter {
|
public class GUtilTabCompleter implements TabCompleter {
|
||||||
public static final List<String> defSubCommands = List.of("version", "setting", "spawn");
|
public static final List<String> defSubCommands = List.of("version", "setting", "spawn");
|
||||||
public static final List<String> adminSubCommands = List.of("relic", "capability", "broadcast", "inventoryrestore", "fly", "god", "heal", "speed", "enderchest", "invsee");
|
public static final List<String> adminSubCommands = List.of("relic", "capability", "broadcast", "inventoryrestore", "fly", "god", "heal", "speed", "enderchest", "invsee", "addtitle", "removetitle");
|
||||||
|
|
||||||
public GUtilTabCompleter() {
|
public GUtilTabCompleter() {
|
||||||
}
|
}
|
||||||
|
|
@ -44,7 +45,7 @@ public class GUtilTabCompleter implements TabCompleter {
|
||||||
case "setting" -> {
|
case "setting" -> {
|
||||||
return PlayerMetadata.getPlayerMetadata(player).settings.stream().toList();
|
return PlayerMetadata.getPlayerMetadata(player).settings.stream().toList();
|
||||||
}
|
}
|
||||||
case "inventoryrestore", "heal", "spawn", "enderchest", "invsee" -> {
|
case "inventoryrestore", "heal", "spawn", "enderchest", "invsee", "addtitle", "removetitle" -> {
|
||||||
return Bukkit.getOnlinePlayers().stream()
|
return Bukkit.getOnlinePlayers().stream()
|
||||||
.map(Player::getName)
|
.map(Player::getName)
|
||||||
.filter(name -> name.toLowerCase().startsWith(args[1].toLowerCase()))
|
.filter(name -> name.toLowerCase().startsWith(args[1].toLowerCase()))
|
||||||
|
|
@ -89,6 +90,22 @@ public class GUtilTabCompleter implements TabCompleter {
|
||||||
}
|
}
|
||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
|
case "addtitle" -> {
|
||||||
|
// Ensure dynamic titles are populated
|
||||||
|
PlayerTitles.populateDynamicTitles();
|
||||||
|
return PlayerTitles.titles.keySet().stream()
|
||||||
|
.filter(title -> title.toLowerCase().startsWith(args[2].toLowerCase()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
case "removetitle" -> {
|
||||||
|
Player targetPlayer = Bukkit.getPlayer(args[1]);
|
||||||
|
if (targetPlayer != null) {
|
||||||
|
return PlayerTitles.getPlayerTitles(targetPlayer).getTitles().stream()
|
||||||
|
.filter(title -> title.toLowerCase().startsWith(args[2].toLowerCase()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
default -> {
|
default -> {
|
||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,36 +1,34 @@
|
||||||
package org.gsdistance.grimmsServer.Commands;
|
package org.gsdistance.grimmsServer.Commands.GUtilCommand;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||||
import org.gsdistance.grimmsServer.Stats.PlayerTitles;
|
import org.gsdistance.grimmsServer.Stats.PlayerTitles;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class RemoveTitle implements CommandExecutor {
|
public class RemoveTitle {
|
||||||
public RemoveTitle() {
|
public RemoveTitle() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public static boolean subCommand(@NotNull CommandSender sender, @NotNull String[] args) {
|
||||||
if (args.length < 2) {
|
if (args.length < 3) {
|
||||||
return false;
|
return false;
|
||||||
} else if (!PlayerTitles.titles.containsKey(args[1])) {
|
} else if (!PlayerTitles.titles.containsKey(args[2])) {
|
||||||
sender.sendMessage("Title not found.");
|
sender.sendMessage("Title not found.");
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
Player player = GrimmsServer.instance.getServer().getPlayer(args[0]);
|
Player player = GrimmsServer.instance.getServer().getPlayer(args[1]);
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
sender.sendMessage("Player not found.");
|
sender.sendMessage("Player not found.");
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
PlayerTitles playerTitles = PlayerTitles.getPlayerTitles(player);
|
PlayerTitles playerTitles = PlayerTitles.getPlayerTitles(player);
|
||||||
if (!playerTitles.hasTitle(args[1])) {
|
if (!playerTitles.hasTitle(args[2])) {
|
||||||
sender.sendMessage("Player doesn't have this title.");
|
sender.sendMessage("Player doesn't have this title.");
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
playerTitles.removeTitle(args[1]);
|
playerTitles.removeTitle(args[2]);
|
||||||
sender.sendMessage("Title " + args[1] + " revoked from " + player.getDisplayName() + ".");
|
sender.sendMessage("Title " + args[2] + " revoked from " + player.getDisplayName() + ".");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -12,6 +12,8 @@ import org.gsdistance.grimmsServer.Constructable.Data;
|
||||||
import org.gsdistance.grimmsServer.Constructable.Player.PlayerLevelHandler;
|
import org.gsdistance.grimmsServer.Constructable.Player.PlayerLevelHandler;
|
||||||
import org.gsdistance.grimmsServer.Data.PerSessionDataStorage;
|
import org.gsdistance.grimmsServer.Data.PerSessionDataStorage;
|
||||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||||
|
import org.gsdistance.grimmsServer.Shared;
|
||||||
|
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -23,6 +25,7 @@ public class EntityMetadata {
|
||||||
public final UUID uuid;
|
public final UUID uuid;
|
||||||
public final String timestamp;
|
public final String timestamp;
|
||||||
public int level = 1;
|
public int level = 1;
|
||||||
|
public int prestige = 1;
|
||||||
public String originalName;
|
public String originalName;
|
||||||
|
|
||||||
public EntityMetadata(Entity entity) {
|
public EntityMetadata(Entity entity) {
|
||||||
|
|
@ -70,7 +73,7 @@ public class EntityMetadata {
|
||||||
GrimmsServer.logger.info("Retrieved EntityMetadata for " + entity.getUniqueId());
|
GrimmsServer.logger.info("Retrieved EntityMetadata for " + entity.getUniqueId());
|
||||||
}
|
}
|
||||||
// Re-apply levelling when metadata is loaded (e.g., after chunk reload)
|
// Re-apply levelling when metadata is loaded (e.g., after chunk reload)
|
||||||
if (entity instanceof LivingEntity && metadata.level > 1) {
|
if (entity instanceof LivingEntity && (metadata.level > 1 || metadata.prestige > 1)) {
|
||||||
applyLevelling((LivingEntity) entity, metadata);
|
applyLevelling((LivingEntity) entity, metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -82,34 +85,18 @@ public class EntityMetadata {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String generateHealthBar(double currentHealth, double maxHealth) {
|
public static ChatColor getLevelColor(int level) {
|
||||||
if (maxHealth <= 0) return "";
|
if (level < 10) {
|
||||||
|
return ChatColor.GREEN;
|
||||||
int bars = 10;
|
} else if (level < 25) {
|
||||||
double healthPercent = currentHealth / maxHealth;
|
return ChatColor.YELLOW;
|
||||||
int filledBars = (int) Math.round(healthPercent * bars);
|
} else if (level < 50) {
|
||||||
|
return ChatColor.GOLD;
|
||||||
ChatColor barColor;
|
} else if (level < 75) {
|
||||||
if (healthPercent > 0.6) {
|
return ChatColor.RED;
|
||||||
barColor = ChatColor.GREEN;
|
|
||||||
} else if (healthPercent > 0.3) {
|
|
||||||
barColor = ChatColor.YELLOW;
|
|
||||||
} else {
|
} else {
|
||||||
barColor = ChatColor.RED;
|
return ChatColor.DARK_RED;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder healthBar = new StringBuilder(barColor.toString());
|
|
||||||
healthBar.append("[");
|
|
||||||
for (int i = 0; i < bars; i++) {
|
|
||||||
if (i < filledBars) {
|
|
||||||
healthBar.append("|");
|
|
||||||
} else {
|
|
||||||
healthBar.append(ChatColor.GRAY).append("|").append(barColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
healthBar.append("]");
|
|
||||||
|
|
||||||
return healthBar.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void applyLevelling(LivingEntity livingEntity, EntityMetadata metadata) {
|
private static void applyLevelling(LivingEntity livingEntity, EntityMetadata metadata) {
|
||||||
|
|
@ -126,6 +113,7 @@ public class EntityMetadata {
|
||||||
|
|
||||||
// Calculate level based on nearby players
|
// Calculate level based on nearby players
|
||||||
int totalLevel = 0;
|
int totalLevel = 0;
|
||||||
|
int totalPrestige = 0;
|
||||||
List<Player> nearbyPlayers = new ArrayList<>();
|
List<Player> nearbyPlayers = new ArrayList<>();
|
||||||
Integer searchRadius = ActiveConfig.getConfigValue(ConfigKey.LEVELLED_MOBS_SEARCH_RADIUS, Integer.class);
|
Integer searchRadius = ActiveConfig.getConfigValue(ConfigKey.LEVELLED_MOBS_SEARCH_RADIUS, Integer.class);
|
||||||
if (searchRadius == null) searchRadius = 50;
|
if (searchRadius == null) searchRadius = 50;
|
||||||
|
|
@ -136,21 +124,25 @@ public class EntityMetadata {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Player player : nearbyPlayers) {
|
for (Player player : nearbyPlayers) {
|
||||||
totalLevel += PlayerLevelHandler.getLevelHandler(player).getLevel();
|
PlayerStats playerStats = PlayerStats.getPlayerStats(player);
|
||||||
|
totalLevel += playerStats.getStat("level", Integer.class);
|
||||||
|
totalPrestige += playerStats.getStat("prestige", Integer.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
double randomness = Math.sqrt(totalLevel);
|
double randomness = Math.sqrt(totalLevel);
|
||||||
double randomOffset = (Math.random() * 2 * randomness) - randomness;
|
double randomOffset = (Math.random() * 2 * randomness) - randomness;
|
||||||
int finalLevel = (int) Math.max(1, Math.round(totalLevel + randomOffset));
|
int finalLevel = (int) Math.max(1, Math.round(totalLevel + randomOffset));
|
||||||
|
totalPrestige = Math.max(totalPrestige, 1);
|
||||||
|
|
||||||
metadata.level = finalLevel;
|
metadata.level = finalLevel;
|
||||||
|
metadata.prestige = totalPrestige;
|
||||||
|
|
||||||
// Apply attribute modifiers
|
// Apply attribute modifiers
|
||||||
if (livingEntity.getAttribute(Attribute.MAX_HEALTH) != null) {
|
if (livingEntity.getAttribute(Attribute.MAX_HEALTH) != null) {
|
||||||
double baseHealth = livingEntity.getAttribute(Attribute.MAX_HEALTH).getBaseValue();
|
double baseHealth = livingEntity.getAttribute(Attribute.MAX_HEALTH).getBaseValue();
|
||||||
Double healthDivisor = ActiveConfig.getConfigValue(ConfigKey.LEVELLED_MOBS_HEALTH_DIVISOR, Double.class);
|
Double healthDivisor = ActiveConfig.getConfigValue(ConfigKey.LEVELLED_MOBS_HEALTH_DIVISOR, Double.class);
|
||||||
if (healthDivisor == null) healthDivisor = 25.0;
|
if (healthDivisor == null) healthDivisor = 25.0;
|
||||||
double healthBoost = baseHealth * (finalLevel / healthDivisor);
|
double healthBoost = baseHealth * (finalLevel / healthDivisor) * Math.cbrt(totalPrestige);
|
||||||
livingEntity.getAttribute(Attribute.MAX_HEALTH).setBaseValue(baseHealth + healthBoost);
|
livingEntity.getAttribute(Attribute.MAX_HEALTH).setBaseValue(baseHealth + healthBoost);
|
||||||
livingEntity.setHealth(livingEntity.getAttribute(Attribute.MAX_HEALTH).getValue());
|
livingEntity.setHealth(livingEntity.getAttribute(Attribute.MAX_HEALTH).getValue());
|
||||||
}
|
}
|
||||||
|
|
@ -158,36 +150,26 @@ public class EntityMetadata {
|
||||||
if (livingEntity.getAttribute(Attribute.ARMOR) != null) {
|
if (livingEntity.getAttribute(Attribute.ARMOR) != null) {
|
||||||
Double armorDivisor = ActiveConfig.getConfigValue(ConfigKey.LEVELLED_MOBS_ARMOR_DIVISOR, Double.class);
|
Double armorDivisor = ActiveConfig.getConfigValue(ConfigKey.LEVELLED_MOBS_ARMOR_DIVISOR, Double.class);
|
||||||
if (armorDivisor == null) armorDivisor = 2.0;
|
if (armorDivisor == null) armorDivisor = 2.0;
|
||||||
double armorBoost = Math.sqrt(finalLevel) / armorDivisor;
|
double armorBoost = Math.sqrt(finalLevel) * Math.sqrt(totalPrestige) / armorDivisor;
|
||||||
livingEntity.getAttribute(Attribute.ARMOR).setBaseValue(armorBoost);
|
livingEntity.getAttribute(Attribute.ARMOR).setBaseValue(armorBoost);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (livingEntity.getAttribute(Attribute.ATTACK_DAMAGE) != null) {
|
if (livingEntity.getAttribute(Attribute.ATTACK_DAMAGE) != null) {
|
||||||
double damageBoost = Math.cbrt(finalLevel);
|
double damageBoost = Math.cbrt(finalLevel) * Math.sqrt(totalPrestige);
|
||||||
livingEntity.getAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(
|
livingEntity.getAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(
|
||||||
livingEntity.getAttribute(Attribute.ATTACK_DAMAGE).getBaseValue() + damageBoost
|
livingEntity.getAttribute(Attribute.ATTACK_DAMAGE).getBaseValue() + damageBoost
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set custom name with level and health bar
|
// Set custom name with level and health bar
|
||||||
ChatColor levelColor;
|
ChatColor levelColor = getLevelColor(finalLevel);
|
||||||
if (finalLevel < 10) {
|
|
||||||
levelColor = ChatColor.GREEN;
|
|
||||||
} else if (finalLevel < 25) {
|
|
||||||
levelColor = ChatColor.YELLOW;
|
|
||||||
} else if (finalLevel < 50) {
|
|
||||||
levelColor = ChatColor.GOLD;
|
|
||||||
} else if (finalLevel < 75) {
|
|
||||||
levelColor = ChatColor.RED;
|
|
||||||
} else {
|
|
||||||
levelColor = ChatColor.DARK_RED;
|
|
||||||
}
|
|
||||||
|
|
||||||
double maxHealth = livingEntity.getAttribute(Attribute.MAX_HEALTH).getValue();
|
double maxHealth = livingEntity.getAttribute(Attribute.MAX_HEALTH).getValue();
|
||||||
String healthBar = generateHealthBar(livingEntity.getHealth(), maxHealth);
|
String healthBar = Shared.generateHealthBar(livingEntity.getHealth(), maxHealth);
|
||||||
|
|
||||||
metadata.originalName = livingEntity.getName();
|
metadata.originalName = livingEntity.getName();
|
||||||
String displayName = levelColor + "[" + finalLevel + "] " + ChatColor.WHITE + metadata.originalName + " " + healthBar;
|
String prestigeDisplay = totalPrestige > 1 ? ChatColor.DARK_PURPLE + "[" + totalPrestige + "]" : "";
|
||||||
|
String displayName = prestigeDisplay + levelColor + "[" + finalLevel + "] " + ChatColor.WHITE + metadata.originalName + " " + healthBar;
|
||||||
livingEntity.setCustomName(displayName);
|
livingEntity.setCustomName(displayName);
|
||||||
livingEntity.setCustomNameVisible(true);
|
livingEntity.setCustomNameVisible(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,118 +70,38 @@ public class RelicHandler {
|
||||||
int tier = this.getRelicTier();
|
int tier = this.getRelicTier();
|
||||||
int grade = this.getRelicGrade();
|
int grade = this.getRelicGrade();
|
||||||
Material material = this.item.getType();
|
Material material = this.item.getType();
|
||||||
double baseDamage;
|
double baseDamage = switch (material) {
|
||||||
switch (material) {
|
case DIAMOND_SWORD, STONE_AXE -> 7.0F;
|
||||||
case DIAMOND_SWORD:
|
case IRON_SWORD, WOODEN_AXE, GOLDEN_AXE -> 6.0F;
|
||||||
baseDamage = 7.0F;
|
case STONE_SWORD -> 5.0F;
|
||||||
break;
|
case WOODEN_SWORD, GOLDEN_SWORD -> 4.0F;
|
||||||
case IRON_SWORD:
|
case NETHERITE_SWORD, IRON_AXE -> 8.0F;
|
||||||
baseDamage = 6.0F;
|
case DIAMOND_AXE -> 9.0F;
|
||||||
break;
|
case NETHERITE_AXE -> 10.0F;
|
||||||
case STONE_SWORD:
|
default -> 1.0F;
|
||||||
baseDamage = 5.0F;
|
};
|
||||||
break;
|
double baseArmor = switch (material) {
|
||||||
case WOODEN_SWORD:
|
case DIAMOND_HELMET, DIAMOND_CHESTPLATE, DIAMOND_LEGGINGS, DIAMOND_BOOTS -> 3.0F;
|
||||||
case GOLDEN_SWORD:
|
case IRON_HELMET, IRON_CHESTPLATE, IRON_LEGGINGS, IRON_BOOTS -> 2.0F;
|
||||||
baseDamage = 4.0F;
|
case CHAINMAIL_HELMET, CHAINMAIL_CHESTPLATE, CHAINMAIL_LEGGINGS, CHAINMAIL_BOOTS -> 1.5F;
|
||||||
break;
|
case GOLDEN_HELMET, GOLDEN_CHESTPLATE, GOLDEN_LEGGINGS, GOLDEN_BOOTS -> 1.0F;
|
||||||
case NETHERITE_SWORD:
|
case NETHERITE_HELMET, NETHERITE_CHESTPLATE, NETHERITE_LEGGINGS, NETHERITE_BOOTS -> 4.0F;
|
||||||
baseDamage = 8.0F;
|
default -> 0.0F;
|
||||||
break;
|
};
|
||||||
case DIAMOND_AXE:
|
double baseToughness = switch (material) {
|
||||||
baseDamage = 9.0F;
|
case DIAMOND_HELMET, DIAMOND_CHESTPLATE, DIAMOND_LEGGINGS, DIAMOND_BOOTS -> 2.0F;
|
||||||
break;
|
case IRON_HELMET, IRON_CHESTPLATE, IRON_LEGGINGS, IRON_BOOTS -> 1.0F;
|
||||||
case IRON_AXE:
|
case CHAINMAIL_HELMET, CHAINMAIL_CHESTPLATE, CHAINMAIL_LEGGINGS, CHAINMAIL_BOOTS -> 0.5F;
|
||||||
baseDamage = 8.0F;
|
case NETHERITE_HELMET, NETHERITE_CHESTPLATE, NETHERITE_LEGGINGS, NETHERITE_BOOTS -> 3.0F;
|
||||||
break;
|
default -> 0.0F;
|
||||||
case STONE_AXE:
|
};
|
||||||
baseDamage = 7.0F;
|
|
||||||
break;
|
|
||||||
case WOODEN_AXE:
|
|
||||||
case GOLDEN_AXE:
|
|
||||||
baseDamage = 6.0F;
|
|
||||||
break;
|
|
||||||
case NETHERITE_AXE:
|
|
||||||
baseDamage = 10.0F;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
baseDamage = 1.0F;
|
|
||||||
}
|
|
||||||
double baseArmor;
|
|
||||||
switch (material) {
|
|
||||||
case DIAMOND_HELMET:
|
|
||||||
case DIAMOND_CHESTPLATE:
|
|
||||||
case DIAMOND_LEGGINGS:
|
|
||||||
case DIAMOND_BOOTS:
|
|
||||||
baseArmor = 3.0F;
|
|
||||||
break;
|
|
||||||
case IRON_HELMET:
|
|
||||||
case IRON_CHESTPLATE:
|
|
||||||
case IRON_LEGGINGS:
|
|
||||||
case IRON_BOOTS:
|
|
||||||
baseArmor = 2.0F;
|
|
||||||
break;
|
|
||||||
case CHAINMAIL_HELMET:
|
|
||||||
case CHAINMAIL_CHESTPLATE:
|
|
||||||
case CHAINMAIL_LEGGINGS:
|
|
||||||
case CHAINMAIL_BOOTS:
|
|
||||||
baseArmor = 1.5F;
|
|
||||||
break;
|
|
||||||
case GOLDEN_HELMET:
|
|
||||||
case GOLDEN_CHESTPLATE:
|
|
||||||
case GOLDEN_LEGGINGS:
|
|
||||||
case GOLDEN_BOOTS:
|
|
||||||
baseArmor = 1.0F;
|
|
||||||
break;
|
|
||||||
case NETHERITE_HELMET:
|
|
||||||
case NETHERITE_CHESTPLATE:
|
|
||||||
case NETHERITE_LEGGINGS:
|
|
||||||
case NETHERITE_BOOTS:
|
|
||||||
baseArmor = 4.0F;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
baseArmor = 0.0F;
|
|
||||||
}
|
|
||||||
double baseToughness;
|
|
||||||
switch (material) {
|
|
||||||
case DIAMOND_HELMET:
|
|
||||||
case DIAMOND_CHESTPLATE:
|
|
||||||
case DIAMOND_LEGGINGS:
|
|
||||||
case DIAMOND_BOOTS:
|
|
||||||
baseToughness = 2.0F;
|
|
||||||
break;
|
|
||||||
case IRON_HELMET:
|
|
||||||
case IRON_CHESTPLATE:
|
|
||||||
case IRON_LEGGINGS:
|
|
||||||
case IRON_BOOTS:
|
|
||||||
baseToughness = 1.0F;
|
|
||||||
break;
|
|
||||||
case CHAINMAIL_HELMET:
|
|
||||||
case CHAINMAIL_CHESTPLATE:
|
|
||||||
case CHAINMAIL_LEGGINGS:
|
|
||||||
case CHAINMAIL_BOOTS:
|
|
||||||
baseToughness = 0.5F;
|
|
||||||
break;
|
|
||||||
case GOLDEN_HELMET:
|
|
||||||
case GOLDEN_CHESTPLATE:
|
|
||||||
case GOLDEN_LEGGINGS:
|
|
||||||
case GOLDEN_BOOTS:
|
|
||||||
baseToughness = 0.0F;
|
|
||||||
break;
|
|
||||||
case NETHERITE_HELMET:
|
|
||||||
case NETHERITE_CHESTPLATE:
|
|
||||||
case NETHERITE_LEGGINGS:
|
|
||||||
case NETHERITE_BOOTS:
|
|
||||||
baseToughness = 3.0F;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
baseToughness = 0.0F;
|
|
||||||
}
|
|
||||||
switch (this.getRelicType()) {
|
switch (this.getRelicType()) {
|
||||||
case "sword":
|
case "sword":
|
||||||
this.dataHandler.setAttribute(Attribute.ATTACK_DAMAGE, new AttributeModifier(Shared.getNamespacedKey("reliic_attack_damage"), baseDamage + Math.pow(Math.max(2.0F, (double) grade / (double) 25.0F), tier), Operation.ADD_NUMBER, EquipmentSlotGroup.MAINHAND));
|
this.dataHandler.setAttribute(Attribute.ATTACK_DAMAGE, new AttributeModifier(Shared.getNamespacedKey("reliic_attack_damage"), baseDamage + Math.pow(Math.max(2.0F, (double) grade / (double) 25.0F), tier), Operation.ADD_NUMBER, EquipmentSlotGroup.MAINHAND));
|
||||||
if (tier > 1) {
|
if (tier == 1) {
|
||||||
this.dataHandler.setAttribute(Attribute.ATTACK_SPEED, new AttributeModifier(Shared.getNamespacedKey("reliic_attack_speed"), Math.max(1.7, Math.sqrt(grade) * (double) tier / (double) 10.0F), Operation.ADD_NUMBER, EquipmentSlotGroup.MAINHAND));
|
this.dataHandler.setAttribute(Attribute.ATTACK_SPEED, new AttributeModifier(Shared.getNamespacedKey("reliic_attack_speed"), -2.4, Operation.ADD_NUMBER, EquipmentSlotGroup.MAINHAND));
|
||||||
|
} else {
|
||||||
|
this.dataHandler.setAttribute(Attribute.ATTACK_SPEED, new AttributeModifier(Shared.getNamespacedKey("reliic_attack_speed"), -(2.4 - Math.max(Math.max((Math.sqrt(grade) * (double) tier / (double) 10.0F), 2), 1)), Operation.ADD_NUMBER, EquipmentSlotGroup.MAINHAND));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "armor":
|
case "armor":
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ public class PlayerMetadata {
|
||||||
public final UUID uuid;
|
public final UUID uuid;
|
||||||
public Location exitLocation;
|
public Location exitLocation;
|
||||||
public String lastExitTime = LocalDateTime.now().toString();
|
public String lastExitTime = LocalDateTime.now().toString();
|
||||||
public String[] titles;
|
public Set<String> titles;
|
||||||
public final String timestamp;
|
public final String timestamp;
|
||||||
public UUID factionUUID = null;
|
public UUID factionUUID = null;
|
||||||
public double offlineMoney = 0.0F;
|
public double offlineMoney = 0.0F;
|
||||||
|
|
@ -41,7 +41,7 @@ public class PlayerMetadata {
|
||||||
this.uuid = player.getUniqueId();
|
this.uuid = player.getUniqueId();
|
||||||
this.exitLocation = new Location(player.getLocation());
|
this.exitLocation = new Location(player.getLocation());
|
||||||
this.homes = new HashMap<>();
|
this.homes = new HashMap<>();
|
||||||
this.titles = new String[0];
|
this.titles = new HashSet<>();
|
||||||
this.timestamp = LocalDateTime.now().toString();
|
this.timestamp = LocalDateTime.now().toString();
|
||||||
this.capabilities = new HashMap<>();
|
this.capabilities = new HashMap<>();
|
||||||
this.settings = new ArrayList<>();
|
this.settings = new ArrayList<>();
|
||||||
|
|
@ -54,7 +54,7 @@ public class PlayerMetadata {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.titles == null) {
|
if (this.titles == null) {
|
||||||
this.titles = new String[0];
|
this.titles = new HashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.capabilities == null) {
|
if (this.capabilities == null) {
|
||||||
|
|
|
||||||
|
|
@ -1,104 +1,131 @@
|
||||||
package org.gsdistance.grimmsServer.Data.Player;
|
package org.gsdistance.grimmsServer.Data.Player;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||||
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||||
import org.gsdistance.grimmsServer.Stats.PlayerTitles;
|
import org.gsdistance.grimmsServer.Stats.PlayerTitles;
|
||||||
|
import org.gsdistance.grimmsServer.Stats.TitleCriteria;
|
||||||
|
import org.gsdistance.grimmsServer.Stats.TitleGenerator;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class PlayerTitleChecker {
|
public class PlayerTitleChecker {
|
||||||
|
private static final long CHECK_INTERVAL_TICKS = 600; // Check every 30 seconds (20 ticks = 1 second)
|
||||||
|
private static int taskId = -1;
|
||||||
|
|
||||||
public PlayerTitleChecker() {
|
public PlayerTitleChecker() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Start periodic title checking
|
||||||
|
public static void startPeriodicChecking() {
|
||||||
|
if (taskId == -1) {
|
||||||
|
taskId = Bukkit.getScheduler().runTaskTimer(GrimmsServer.instance, () -> {
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
checkAllTitles(player);
|
||||||
|
}
|
||||||
|
}, CHECK_INTERVAL_TICKS, CHECK_INTERVAL_TICKS).getTaskId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop periodic title checking
|
||||||
|
public static void stopPeriodicChecking() {
|
||||||
|
if (taskId != -1) {
|
||||||
|
Bukkit.getScheduler().cancelTask(taskId);
|
||||||
|
taskId = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Manual title awards (not auto-checked)
|
||||||
|
public static void awardTitle(Player player, String titleId) {
|
||||||
|
PlayerTitles.getPlayerTitles(player).addTitle(titleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Event-specific triggers that increment stats only
|
||||||
public static void killedPlayer(Player player) {
|
public static void killedPlayer(Player player) {
|
||||||
PlayerTitles.getPlayerTitles(player).addTitle("Murderer");
|
PlayerStats.getPlayerStats(player).changeStat("total_kill_count", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void gotKilledByPlayer(Player player) {
|
public static void gotKilledByPlayer(Player player) {
|
||||||
PlayerTitles.getPlayerTitles(player).addTitle("Victim");
|
PlayerStats.getPlayerStats(player).changeStat("death_count", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void killedDragon(Player player) {
|
public static void killedDragon(Player player) {
|
||||||
PlayerTitles.getPlayerTitles(player).addTitle("DragonSlayer");
|
// Dragon kills not tracked in persistent stats
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void gotOnLeaderboard(Player player) {
|
public static void gotOnLeaderboard(Player player) {
|
||||||
PlayerTitles.getPlayerTitles(player).addTitle("Leader");
|
// Leaderboard status not tracked in persistent stats
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void joinedGame(Player player) {
|
public static void joinedGame(Player player) {
|
||||||
PlayerTitles.getPlayerTitles(player).addTitle("Newbie");
|
checkAllTitles(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void checkAllTitles(Player player) {
|
||||||
|
PlayerTitles playerTitles = PlayerTitles.getPlayerTitles(player);
|
||||||
|
PlayerStats playerStats = PlayerStats.getPlayerStats(player);
|
||||||
|
|
||||||
|
// Check static criteria titles
|
||||||
|
for (TitleCriteria criteria : TitleCriteria.values()) {
|
||||||
|
if (!playerTitles.hasTitle(criteria.getTitleId()) && criteria.test(player)) {
|
||||||
|
playerTitles.addTitle(criteria.getTitleId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check dynamic money titles (all qualifying titles like achievements)
|
||||||
|
double money = playerStats.getStat("money", Double.class);
|
||||||
|
List<String> moneyTitles = TitleGenerator.getMoneyTitles(money);
|
||||||
|
for (String title : moneyTitles) {
|
||||||
|
if (!playerTitles.hasTitle(title)) {
|
||||||
|
playerTitles.addTitle(title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check dynamic block break titles (all qualifying titles like achievements)
|
||||||
|
long blockBreaks = playerStats.getStat("block_break_count", Long.class);
|
||||||
|
List<String> blockBreakTitles = TitleGenerator.getBlockBreakTitles(blockBreaks);
|
||||||
|
for (String title : blockBreakTitles) {
|
||||||
|
if (!playerTitles.hasTitle(title)) {
|
||||||
|
playerTitles.addTitle(title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check dynamic kill titles (all qualifying titles like achievements)
|
||||||
|
long totalKills = getTotalKills(player);
|
||||||
|
List<String> killTitles = TitleGenerator.getKillTitles(totalKills);
|
||||||
|
for (String title : killTitles) {
|
||||||
|
if (!playerTitles.hasTitle(title)) {
|
||||||
|
playerTitles.addTitle(title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static long getTotalKills(Player player) {
|
||||||
|
Object totalKillsObj = PlayerStats.getPlayerStats(player).getStat("total_kill_count", Object.class);
|
||||||
|
if (totalKillsObj instanceof Integer) {
|
||||||
|
return ((Integer) totalKillsObj).longValue();
|
||||||
|
} else if (totalKillsObj instanceof Long) {
|
||||||
|
return (Long) totalKillsObj;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Legacy method for backward compatibility
|
||||||
public static void checkTitles(Player player) {
|
public static void checkTitles(Player player) {
|
||||||
PlayerTitles playerTitles = PlayerTitles.getPlayerTitles(player);
|
checkAllTitles(player);
|
||||||
if (playerTitles.getTitles().length > 5) {
|
|
||||||
playerTitles.addTitle("Titlemaxxer");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Legacy methods for backward compatibility
|
||||||
public static void checkForMoney(Player player) {
|
public static void checkForMoney(Player player) {
|
||||||
double money = PlayerStats.getPlayerStats(player).getStat("money", Double.class);
|
checkAllTitles(player);
|
||||||
PlayerTitles playerTitles = PlayerTitles.getPlayerTitles(player);
|
|
||||||
if (money > (double) 100000.0F) {
|
|
||||||
playerTitles.addTitle("Richie");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (money > (double) 1000000.0F) {
|
|
||||||
playerTitles.addTitle("Millionaire");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (money > (double) 1.0E9F) {
|
|
||||||
playerTitles.addTitle("Billionaire");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (money > 1.0E12) {
|
|
||||||
playerTitles.addTitle("Trillionaire");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (money > 1.0E15) {
|
|
||||||
playerTitles.addTitle("Trillionaire");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkForBlockBreaks(Player player) {
|
public static void checkForBlockBreaks(Player player) {
|
||||||
long blockBreakCount = PlayerStats.getPlayerStats(player).getStat("block_break_count", Long.class);
|
checkAllTitles(player);
|
||||||
PlayerTitles playerTitles = PlayerTitles.getPlayerTitles(player);
|
|
||||||
if (blockBreakCount > 1000L) {
|
|
||||||
playerTitles.addTitle("Miner");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (blockBreakCount > 10000L) {
|
|
||||||
playerTitles.addTitle("Anti-block");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (blockBreakCount > 100000L) {
|
|
||||||
playerTitles.addTitle("UltimateMiner");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkForTotalKills(Player player) {
|
public static void checkForTotalKills(Player player) {
|
||||||
Object totalKillsObj = PlayerStats.getPlayerStats(player).getStat("total_kill_count", Object.class);
|
checkAllTitles(player);
|
||||||
long totalKills;
|
|
||||||
if (totalKillsObj instanceof Integer) {
|
|
||||||
totalKills = ((Integer) totalKillsObj).longValue();
|
|
||||||
} else {
|
|
||||||
totalKills = (Long) totalKillsObj;
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerTitles playerTitles = PlayerTitles.getPlayerTitles(player);
|
|
||||||
if (totalKills > 100L) {
|
|
||||||
playerTitles.addTitle("KillingMachine");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (totalKills > 1000L) {
|
|
||||||
playerTitles.addTitle("ProGamer");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (totalKills > 10000L) {
|
|
||||||
playerTitles.addTitle("Hitman");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ public class CustomEntityDeathEvent {
|
||||||
if (event.getKiller() instanceof Player) {
|
if (event.getKiller() instanceof Player) {
|
||||||
EntityMetadata metadata = EntityMetadata.getEntityMetadata(event.getEntity());
|
EntityMetadata metadata = EntityMetadata.getEntityMetadata(event.getEntity());
|
||||||
if (metadata != null) {
|
if (metadata != null) {
|
||||||
double extraXp = Math.sqrt(metadata.level);
|
double extraXp = Math.sqrt(metadata.level) * Math.cbrt(metadata.prestige);
|
||||||
PlayerLevelHandler.getLevelHandler((Player) event.getKiller()).addExp(extraXp);
|
PlayerLevelHandler.getLevelHandler((Player) event.getKiller()).addExp(extraXp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,41 +8,12 @@ import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.gsdistance.grimmsServer.Constructable.Entity.EntityMetadata;
|
import org.gsdistance.grimmsServer.Constructable.Entity.EntityMetadata;
|
||||||
import org.gsdistance.grimmsServer.Constructable.Item.ItemLevelHandler;
|
import org.gsdistance.grimmsServer.Constructable.Item.ItemLevelHandler;
|
||||||
|
import org.gsdistance.grimmsServer.Shared;
|
||||||
|
|
||||||
public class EntityDamageEvent {
|
public class EntityDamageEvent {
|
||||||
public EntityDamageEvent() {
|
public EntityDamageEvent() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String generateHealthBar(double currentHealth, double maxHealth) {
|
|
||||||
if (maxHealth <= 0) return "";
|
|
||||||
|
|
||||||
int bars = 10;
|
|
||||||
double healthPercent = currentHealth / maxHealth;
|
|
||||||
int filledBars = (int) Math.round(healthPercent * bars);
|
|
||||||
|
|
||||||
ChatColor barColor;
|
|
||||||
if (healthPercent > 0.6) {
|
|
||||||
barColor = ChatColor.GREEN;
|
|
||||||
} else if (healthPercent > 0.3) {
|
|
||||||
barColor = ChatColor.YELLOW;
|
|
||||||
} else {
|
|
||||||
barColor = ChatColor.RED;
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuilder healthBar = new StringBuilder(barColor.toString());
|
|
||||||
healthBar.append("[");
|
|
||||||
for (int i = 0; i < bars; i++) {
|
|
||||||
if (i < filledBars) {
|
|
||||||
healthBar.append("|");
|
|
||||||
} else {
|
|
||||||
healthBar.append(ChatColor.GRAY).append("|").append(barColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
healthBar.append("]");
|
|
||||||
|
|
||||||
return healthBar.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Event(org.bukkit.event.entity.EntityDamageEvent event) {
|
public static void Event(org.bukkit.event.entity.EntityDamageEvent event) {
|
||||||
Entity var2 = event.getEntity();
|
Entity var2 = event.getEntity();
|
||||||
if (var2 instanceof Player player) {
|
if (var2 instanceof Player player) {
|
||||||
|
|
@ -56,28 +27,19 @@ public class EntityDamageEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (var2 instanceof LivingEntity livingEntity && var2.hasMetadata("customEntityLevel")) {
|
if (var2 instanceof LivingEntity livingEntity) {
|
||||||
int level = var2.getMetadata("customEntityLevel").get(0).asInt();
|
|
||||||
EntityMetadata metadata = EntityMetadata.getEntityMetadata(livingEntity);
|
EntityMetadata metadata = EntityMetadata.getEntityMetadata(livingEntity);
|
||||||
|
if (metadata.level > 1 || metadata.prestige > 1) {
|
||||||
ChatColor levelColor;
|
ChatColor levelColor = EntityMetadata.getLevelColor(metadata.level);
|
||||||
if (level < 10) {
|
|
||||||
levelColor = ChatColor.GREEN;
|
|
||||||
} else if (level < 25) {
|
|
||||||
levelColor = ChatColor.YELLOW;
|
|
||||||
} else if (level < 50) {
|
|
||||||
levelColor = ChatColor.GOLD;
|
|
||||||
} else if (level < 75) {
|
|
||||||
levelColor = ChatColor.RED;
|
|
||||||
} else {
|
|
||||||
levelColor = ChatColor.DARK_RED;
|
|
||||||
}
|
|
||||||
|
|
||||||
double maxHealth = livingEntity.getAttribute(Attribute.MAX_HEALTH).getValue();
|
double maxHealth = livingEntity.getAttribute(Attribute.MAX_HEALTH).getValue();
|
||||||
String healthBar = generateHealthBar(livingEntity.getHealth(), maxHealth);
|
double healthAfterDamage = Math.max(0, livingEntity.getHealth() - event.getDamage());
|
||||||
|
String healthBar = Shared.generateHealthBar(healthAfterDamage, maxHealth);
|
||||||
|
|
||||||
String displayName = levelColor + "[" + level + "] " + ChatColor.WHITE + metadata.originalName + " " + healthBar;
|
String prestigeDisplay = metadata.prestige > 1 ? ChatColor.DARK_PURPLE + "[" + metadata.prestige + "]" : "";
|
||||||
|
String displayName = prestigeDisplay + levelColor + "[" + metadata.level + "] " + ChatColor.WHITE + metadata.originalName + " " + healthBar;
|
||||||
livingEntity.setCustomName(displayName);
|
livingEntity.setCustomName(displayName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,14 @@ import org.gsdistance.grimmsServer.Commands.GUtilCommand.SettingGUIListener;
|
||||||
import org.gsdistance.grimmsServer.Commands.MarketComand.MarketGUIListener;
|
import org.gsdistance.grimmsServer.Commands.MarketComand.MarketGUIListener;
|
||||||
import org.gsdistance.grimmsServer.Config.ConfigLoader;
|
import org.gsdistance.grimmsServer.Config.ConfigLoader;
|
||||||
import org.gsdistance.grimmsServer.Constructable.Market;
|
import org.gsdistance.grimmsServer.Constructable.Market;
|
||||||
|
import org.gsdistance.grimmsServer.Data.Player.PlayerTitleChecker;
|
||||||
import org.gsdistance.grimmsServer.Data.PlayerLoginLogManager;
|
import org.gsdistance.grimmsServer.Data.PlayerLoginLogManager;
|
||||||
import org.gsdistance.grimmsServer.Data.PluginDataStorage;
|
import org.gsdistance.grimmsServer.Data.PluginDataStorage;
|
||||||
import org.gsdistance.grimmsServer.Events.Listeners.ServerStartupEvent;
|
import org.gsdistance.grimmsServer.Events.Listeners.ServerStartupEvent;
|
||||||
import org.gsdistance.grimmsServer.Manage.EventRegistry;
|
import org.gsdistance.grimmsServer.Manage.EventRegistry;
|
||||||
import org.gsdistance.grimmsServer.Stats.HistoricalStatsManager;
|
import org.gsdistance.grimmsServer.Stats.HistoricalStatsManager;
|
||||||
import org.gsdistance.grimmsServer.Stats.PlayerStatLeaderBoard;
|
import org.gsdistance.grimmsServer.Stats.PlayerStatLeaderBoard;
|
||||||
|
import org.gsdistance.grimmsServer.Stats.PlayerTitles;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
|
@ -50,10 +52,13 @@ public final class GrimmsServer extends JavaPlugin {
|
||||||
ServerStartupEvent.Event();
|
ServerStartupEvent.Event();
|
||||||
historicalStatsManager.start();
|
historicalStatsManager.start();
|
||||||
PlayerLoginLogManager.initialize();
|
PlayerLoginLogManager.initialize();
|
||||||
|
PlayerTitles.populateDynamicTitles();
|
||||||
|
PlayerTitleChecker.startPeriodicChecking();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
historicalStatsManager.stop();
|
historicalStatsManager.stop();
|
||||||
|
PlayerTitleChecker.stopPeriodicChecking();
|
||||||
super.onDisable();
|
super.onDisable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,6 @@ public class CommandRegistry {
|
||||||
if (makeItemLevelableCmd != null) makeItemLevelableCmd.setExecutor(new MakeItemLevelable());
|
if (makeItemLevelableCmd != null) makeItemLevelableCmd.setExecutor(new MakeItemLevelable());
|
||||||
PluginCommand setPlayerStatCmd = GrimmsServer.instance.getCommand("setPlayerStat");
|
PluginCommand setPlayerStatCmd = GrimmsServer.instance.getCommand("setPlayerStat");
|
||||||
if (setPlayerStatCmd != null) setPlayerStatCmd.setExecutor(new 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");
|
PluginCommand executePlayerCmd = GrimmsServer.instance.getCommand("executePlayer");
|
||||||
if (executePlayerCmd != null) executePlayerCmd.setExecutor(new ExecutePlayer());
|
if (executePlayerCmd != null) executePlayerCmd.setExecutor(new ExecutePlayer());
|
||||||
PluginCommand withdrawMoneyCmd = GrimmsServer.instance.getCommand("withdrawMoney");
|
PluginCommand withdrawMoneyCmd = GrimmsServer.instance.getCommand("withdrawMoney");
|
||||||
|
|
@ -63,8 +61,6 @@ public class CommandRegistry {
|
||||||
acceptRequestCmd.setExecutor(new AcceptRequest());
|
acceptRequestCmd.setExecutor(new AcceptRequest());
|
||||||
acceptRequestCmd.setTabCompleter(new RequestTabCompleter());
|
acceptRequestCmd.setTabCompleter(new RequestTabCompleter());
|
||||||
}
|
}
|
||||||
PluginCommand removeTitleCmd = GrimmsServer.instance.getCommand("removeTitle");
|
|
||||||
if (removeTitleCmd != null) removeTitleCmd.setExecutor(new RemoveTitle());
|
|
||||||
PluginCommand homeCmd = GrimmsServer.instance.getCommand("home");
|
PluginCommand homeCmd = GrimmsServer.instance.getCommand("home");
|
||||||
if (homeCmd != null) {
|
if (homeCmd != null) {
|
||||||
homeCmd.setExecutor(new HomeBaseCommand());
|
homeCmd.setExecutor(new HomeBaseCommand());
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package org.gsdistance.grimmsServer;
|
package org.gsdistance.grimmsServer;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
@ -188,4 +188,34 @@ public class Shared {
|
||||||
|
|
||||||
return playerSuggestions;
|
return playerSuggestions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String generateHealthBar(double currentHealth, double maxHealth) {
|
||||||
|
if (maxHealth <= 0) return "";
|
||||||
|
|
||||||
|
int bars = 10;
|
||||||
|
double healthPercent = currentHealth / maxHealth;
|
||||||
|
int filledBars = (int) Math.round(healthPercent * bars);
|
||||||
|
|
||||||
|
ChatColor barColor;
|
||||||
|
if (healthPercent > 0.6) {
|
||||||
|
barColor = ChatColor.GREEN;
|
||||||
|
} else if (healthPercent > 0.3) {
|
||||||
|
barColor = ChatColor.YELLOW;
|
||||||
|
} else {
|
||||||
|
barColor = ChatColor.RED;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder healthBar = new StringBuilder(barColor.toString());
|
||||||
|
healthBar.append("[");
|
||||||
|
for (int i = 0; i < bars; i++) {
|
||||||
|
if (i < filledBars) {
|
||||||
|
healthBar.append("|");
|
||||||
|
} else {
|
||||||
|
healthBar.append(ChatColor.GRAY).append("|").append(barColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
healthBar.append("]");
|
||||||
|
|
||||||
|
return healthBar.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,35 @@ import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
||||||
import org.gsdistance.grimmsServer.Data.Player.PlayerTitleChecker;
|
import org.gsdistance.grimmsServer.Data.Player.PlayerTitleChecker;
|
||||||
import org.gsdistance.grimmsServer.Shared;
|
import org.gsdistance.grimmsServer.Shared;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PlayerTitles {
|
public class PlayerTitles {
|
||||||
public static final Map<String, String> titles = Map.ofEntries(Map.entry("Dictator", "The title of a dictator, not to be messed with."), Map.entry("Executioner", "The title and power of execution."), Map.entry("Murderer", "Someone whose crimes follow him till death."), Map.entry("Victim", "Got murdered, unfortunate."), Map.entry("DragonSlayer", "The fabled warrior to defeat the fabled dragon or something like that."), Map.entry("Newbie", "Wowie! Joining the game gives a title!"), Map.entry("Richie", "Money talks, well at least that's what I've been told!"), Map.entry("Millionaire", "Wow, that's quite a lot ya' know!"), Map.entry("Billionaire", "Capitalism at it's finest."), Map.entry("Trillionaire", "Literally insane, no comment."), Map.entry("Quadrillionaire", "Why?"), Map.entry("Miner", "Minin' to the earths core."), Map.entry("Anti-block", "DEMOLISH 10000 blocks"), Map.entry("UltimateMiner", "Mine 100000 blocks"), Map.entry("Titlemaxxer", "Get more than 5 titles"), Map.entry("KillingMachine", "Kill 100 things(?)."), Map.entry("ProGamer", "Kill 1000 things(?)."), Map.entry("Hitman", "Professional killerguy."), Map.entry("Leader", "You got on the leaderboard."), Map.entry("Null", "Not a title bro."), Map.entry("BugSlayer", "Reported a bug."), Map.entry("ExploitDestroyer", "Reported an exploit."), Map.entry("Disgrace.", "Abused an exploit."));
|
// Static titles (manually awarded or event-based)
|
||||||
|
private static final Map<String, String> staticTitles = Map.ofEntries(
|
||||||
|
Map.entry("Dictator", "The title of a dictator, not to be messed with."),
|
||||||
|
Map.entry("Executioner", "The title and power of execution."),
|
||||||
|
Map.entry("Murderer", "Someone whose crimes follow him till death."),
|
||||||
|
Map.entry("Victim", "Got murdered, unfortunate."),
|
||||||
|
Map.entry("DragonSlayer", "The fabled warrior to defeat the fabled dragon or something like that."),
|
||||||
|
Map.entry("Newbie", "Wowie! Joining the game gives a title!"),
|
||||||
|
Map.entry("Titlemaxxer", "Get more than 5 titles"),
|
||||||
|
Map.entry("Leader", "You got on the leaderboard."),
|
||||||
|
Map.entry("Null", "Not a title bro."),
|
||||||
|
Map.entry("BugSlayer", "Reported a bug."),
|
||||||
|
Map.entry("ExploitDestroyer", "Reported an exploit."),
|
||||||
|
Map.entry("Disgrace.", "Abused an exploit.")
|
||||||
|
);
|
||||||
|
|
||||||
|
// Dynamic titles (based on stats) - populated on-demand
|
||||||
|
public static Map<String, String> titles = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
titles.putAll(staticTitles);
|
||||||
|
}
|
||||||
|
|
||||||
private final Player player;
|
private final Player player;
|
||||||
|
|
||||||
public PlayerTitles(Player player) {
|
public PlayerTitles(Player player) {
|
||||||
|
|
@ -28,54 +52,42 @@ public class PlayerTitles {
|
||||||
return new OfflinePlayerTitles(metadata);
|
return new OfflinePlayerTitles(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getTitles() {
|
// Populate dynamic titles from TitleGenerator
|
||||||
|
public static void populateDynamicTitles() {
|
||||||
|
titles.putAll(TitleGenerator.getAllMoneyTitles());
|
||||||
|
for (Map.Entry<Long, String> entry : TitleGenerator.getAllBlockBreakTitles().entrySet()) {
|
||||||
|
titles.put(entry.getKey().toString(), entry.getValue());
|
||||||
|
}
|
||||||
|
for (Map.Entry<Long, String> entry : TitleGenerator.getAllKillTitles().entrySet()) {
|
||||||
|
titles.put(entry.getKey().toString(), entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getTitles() {
|
||||||
return PlayerMetadata.getPlayerMetadata(this.player).titles;
|
return PlayerMetadata.getPlayerMetadata(this.player).titles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTitle(String title) {
|
public void addTitle(String title) {
|
||||||
PlayerMetadata metadata = PlayerMetadata.getPlayerMetadata(this.player);
|
PlayerMetadata metadata = PlayerMetadata.getPlayerMetadata(this.player);
|
||||||
if (!this.hasTitle(title)) {
|
if (!this.hasTitle(title)) {
|
||||||
String[] newTitles = new String[metadata.titles.length + 1];
|
metadata.titles.add(title);
|
||||||
System.arraycopy(metadata.titles, 0, newTitles, 0, metadata.titles.length);
|
|
||||||
newTitles[metadata.titles.length] = title;
|
|
||||||
metadata.titles = newTitles;
|
|
||||||
Shared.Broadcast("Title " + title + " was bestowed upon " + this.player.getDisplayName() + ".", null);
|
Shared.Broadcast("Title " + title + " was bestowed upon " + this.player.getDisplayName() + ".", null);
|
||||||
PlayerTitleChecker.checkTitles(this.player);
|
|
||||||
metadata.saveToPDS();
|
metadata.saveToPDS();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeTitle(String title) {
|
public void removeTitle(String title) {
|
||||||
PlayerMetadata metadata = PlayerMetadata.getPlayerMetadata(this.player);
|
PlayerMetadata metadata = PlayerMetadata.getPlayerMetadata(this.player);
|
||||||
if (this.hasTitle(title)) {
|
if (this.hasTitle(title)) {
|
||||||
String[] newTitles = new String[metadata.titles.length - 1];
|
metadata.titles.remove(title);
|
||||||
int index = 0;
|
|
||||||
|
|
||||||
for (String playerTitle : metadata.titles) {
|
|
||||||
if (!playerTitle.equals(title)) {
|
|
||||||
newTitles[index++] = playerTitle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
metadata.titles = newTitles;
|
|
||||||
Shared.Broadcast("Title " + title + " was revoked from " + this.player.getDisplayName() + ".", null);
|
Shared.Broadcast("Title " + title + " was revoked from " + this.player.getDisplayName() + ".", null);
|
||||||
PlayerTitleChecker.checkTitles(this.player);
|
|
||||||
metadata.saveToPDS();
|
metadata.saveToPDS();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasTitle(String title) {
|
public boolean hasTitle(String title) {
|
||||||
PlayerMetadata metadata = PlayerMetadata.getPlayerMetadata(this.player);
|
PlayerMetadata metadata = PlayerMetadata.getPlayerMetadata(this.player);
|
||||||
|
return metadata.titles.contains(title);
|
||||||
for (String playerTitle : metadata.titles) {
|
|
||||||
if (playerTitle.equals(title)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class OfflinePlayerTitles extends PlayerTitles {
|
private static class OfflinePlayerTitles extends PlayerTitles {
|
||||||
|
|
@ -87,18 +99,13 @@ public class PlayerTitles {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getTitles() {
|
public Set<String> getTitles() {
|
||||||
return this.metadata.titles;
|
return this.metadata.titles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasTitle(String title) {
|
public boolean hasTitle(String title) {
|
||||||
for (String playerTitle : this.metadata.titles) {
|
return this.metadata.titles.contains(title);
|
||||||
if (playerTitle.equals(title)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
package org.gsdistance.grimmsServer.Stats;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||||
|
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
public enum TitleCriteria {
|
||||||
|
NEWBIE("Newbie", "Wowie! Joining the game gives a title!", player -> true),
|
||||||
|
|
||||||
|
MURDERER("Murderer", "Someone whose crimes follow him till death.", player ->
|
||||||
|
PlayerStats.getPlayerStats(player).getStat("total_kill_count", Integer.class) > 0),
|
||||||
|
|
||||||
|
VICTIM("Victim", "Got murdered, unfortunate.", player ->
|
||||||
|
PlayerStats.getPlayerStats(player).getStat("death_count", Integer.class) > 0),
|
||||||
|
|
||||||
|
DRAGON_SLAYER("DragonSlayer", "The fabled warrior to defeat the fabled dragon or something like that.", player ->
|
||||||
|
false), // Dragon kills not tracked in persistent stats
|
||||||
|
|
||||||
|
LEADER("Leader", "You got on the leaderboard.", player ->
|
||||||
|
false), // Leaderboard status not tracked in persistent stats
|
||||||
|
|
||||||
|
TITLEMAXXER("Titlemaxxer", "Get more than 5 titles", player ->
|
||||||
|
PlayerTitles.getPlayerTitles(player).getTitles().size() > 5);
|
||||||
|
|
||||||
|
private final String titleId;
|
||||||
|
private final String description;
|
||||||
|
private final Predicate<Player> condition;
|
||||||
|
|
||||||
|
TitleCriteria(String titleId, String description, Predicate<Player> condition) {
|
||||||
|
this.titleId = titleId;
|
||||||
|
this.description = description;
|
||||||
|
this.condition = condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitleId() {
|
||||||
|
return titleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean test(Player player) {
|
||||||
|
return condition.test(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Special titles that are manually awarded (not auto-checked)
|
||||||
|
public static final String[] MANUAL_TITLES = {
|
||||||
|
"Dictator", "Executioner", "BugSlayer", "ExploitDestroyer", "Disgrace."
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,114 @@
|
||||||
|
package org.gsdistance.grimmsServer.Stats;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class TitleGenerator {
|
||||||
|
private static final Map<String, String> moneyTitles = new HashMap<>();
|
||||||
|
private static final Map<Long, String> blockBreakTitles = new HashMap<>();
|
||||||
|
private static final Map<Long, String> killTitles = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
// Money titles (powers of 10)
|
||||||
|
moneyTitles.put("10", "Pocket Change");
|
||||||
|
moneyTitles.put("100", "Coin Collector");
|
||||||
|
moneyTitles.put("1000", "Wealthy");
|
||||||
|
moneyTitles.put("10000", "Rich");
|
||||||
|
moneyTitles.put("100000", "Affluent");
|
||||||
|
moneyTitles.put("1000000", "Millionaire");
|
||||||
|
moneyTitles.put("10000000", "Multi-Millionaire");
|
||||||
|
moneyTitles.put("100000000", "Hundred-Millionaire");
|
||||||
|
moneyTitles.put("1000000000", "Billionaire");
|
||||||
|
moneyTitles.put("10000000000", "Multi-Billionaire");
|
||||||
|
moneyTitles.put("100000000000", "Hundred-Billionaire");
|
||||||
|
moneyTitles.put("1000000000000", "Trillionaire");
|
||||||
|
moneyTitles.put("10000000000000", "Multi-Trillionaire");
|
||||||
|
moneyTitles.put("100000000000000", "Hundred-Trillionaire");
|
||||||
|
moneyTitles.put("1000000000000000", "Quadrillionaire");
|
||||||
|
moneyTitles.put("10000000000000000", "Multi-Quadrillionaire");
|
||||||
|
moneyTitles.put("100000000000000000", "Hundred-Quadrillionaire");
|
||||||
|
moneyTitles.put("1000000000000000000", "Quintillionaire");
|
||||||
|
|
||||||
|
// Block break titles (powers of 10)
|
||||||
|
blockBreakTitles.put(10L, "Novice Miner");
|
||||||
|
blockBreakTitles.put(100L, "Apprentice Miner");
|
||||||
|
blockBreakTitles.put(1000L, "Miner");
|
||||||
|
blockBreakTitles.put(10000L, "Stone Breaker");
|
||||||
|
blockBreakTitles.put(100000L, "Master Miner");
|
||||||
|
blockBreakTitles.put(1000000L, "Legendary Miner");
|
||||||
|
blockBreakTitles.put(10000000L, "Earth Shatterer");
|
||||||
|
blockBreakTitles.put(100000000L, "World Digger");
|
||||||
|
blockBreakTitles.put(1000000000L, "Void Miner");
|
||||||
|
blockBreakTitles.put(10000000000L, "Dimension Breaker");
|
||||||
|
blockBreakTitles.put(100000000000L, "Reality Shatterer");
|
||||||
|
blockBreakTitles.put(1000000000000L, "Universe Digger");
|
||||||
|
blockBreakTitles.put(10000000000000L, "Cosmic Miner");
|
||||||
|
blockBreakTitles.put(100000000000000L, "Galaxy Breaker");
|
||||||
|
blockBreakTitles.put(1000000000000000L, "Universal Miner");
|
||||||
|
|
||||||
|
// Kill titles (powers of 10)
|
||||||
|
killTitles.put(10L, "Novice Hunter");
|
||||||
|
killTitles.put(100L, "Hunter");
|
||||||
|
killTitles.put(1000L, "Slayer");
|
||||||
|
killTitles.put(10000L, "Executioner");
|
||||||
|
killTitles.put(100000L, "Destroyer");
|
||||||
|
killTitles.put(1000000L, "Godslayer");
|
||||||
|
killTitles.put(10000000L, "World Ender");
|
||||||
|
killTitles.put(100000000L, "Mass Murderer");
|
||||||
|
killTitles.put(1000000000L, "Genocidal");
|
||||||
|
killTitles.put(10000000000L, "Apocalypse Bringer");
|
||||||
|
killTitles.put(100000000000L, "Extinction Event");
|
||||||
|
killTitles.put(1000000000000L, "Universe Ender");
|
||||||
|
killTitles.put(10000000000000L, "Reality Destroyer");
|
||||||
|
killTitles.put(100000000000000L, "Void Consumer");
|
||||||
|
killTitles.put(1000000000000000L, "Oblivion");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> getMoneyTitles(double money) {
|
||||||
|
List<String> earnedTitles = new ArrayList<>();
|
||||||
|
// Check all money titles from lowest to highest
|
||||||
|
for (int i = 1; i <= 18; i++) {
|
||||||
|
String powerOf10 = "1" + "0".repeat(i - 1);
|
||||||
|
if (moneyTitles.containsKey(powerOf10) && money >= Double.parseDouble(powerOf10)) {
|
||||||
|
earnedTitles.add(moneyTitles.get(powerOf10));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return earnedTitles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> getBlockBreakTitles(long blockBreaks) {
|
||||||
|
List<String> earnedTitles = new ArrayList<>();
|
||||||
|
// Check all block break titles from lowest to highest
|
||||||
|
for (long power = 10; power <= 1000000000000000L; power *= 10) {
|
||||||
|
if (blockBreakTitles.containsKey(power) && blockBreaks >= power) {
|
||||||
|
earnedTitles.add(blockBreakTitles.get(power));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return earnedTitles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> getKillTitles(long kills) {
|
||||||
|
List<String> earnedTitles = new ArrayList<>();
|
||||||
|
// Check all kill titles from lowest to highest
|
||||||
|
for (long power = 10; power <= 1000000000000000L; power *= 10) {
|
||||||
|
if (killTitles.containsKey(power) && kills >= power) {
|
||||||
|
earnedTitles.add(killTitles.get(power));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return earnedTitles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, String> getAllMoneyTitles() {
|
||||||
|
return new HashMap<>(moneyTitles);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<Long, String> getAllBlockBreakTitles() {
|
||||||
|
return new HashMap<>(blockBreakTitles);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<Long, String> getAllKillTitles() {
|
||||||
|
return new HashMap<>(killTitles);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -20,10 +20,6 @@ commands:
|
||||||
description: Set a specific stat for any player (admin only)
|
description: Set a specific stat for any player (admin only)
|
||||||
usage: /setPlayerStat <player> <statId> <value>
|
usage: /setPlayerStat <player> <statId> <value>
|
||||||
permission: grimmsserver.setPlayerStat
|
permission: grimmsserver.setPlayerStat
|
||||||
addTitle:
|
|
||||||
description: Add a title to a player (admin only)
|
|
||||||
usage: /addTitle <player> <title>
|
|
||||||
permission: grimmsserver.addTitle
|
|
||||||
executePlayer:
|
executePlayer:
|
||||||
description: Execute a player (requires Executioner title)
|
description: Execute a player (requires Executioner title)
|
||||||
usage: /executePlayer <player>
|
usage: /executePlayer <player>
|
||||||
|
|
@ -40,10 +36,6 @@ commands:
|
||||||
description: Accept a pending request by ID
|
description: Accept a pending request by ID
|
||||||
usage: /acceptRequest <requestId>
|
usage: /acceptRequest <requestId>
|
||||||
permission: grimmsserver.acceptRequest
|
permission: grimmsserver.acceptRequest
|
||||||
removeTitle:
|
|
||||||
description: Remove a title from a player (admin only)
|
|
||||||
usage: /removeTitle <player> <title>
|
|
||||||
permission: grimmsserver.removeTitle
|
|
||||||
gFaction:
|
gFaction:
|
||||||
description: Manage factions - create, join, leave, claim land, and manage members
|
description: Manage factions - create, join, leave, claim land, and manage members
|
||||||
usage: /gFaction <invite|join|leave|kick|info|new|claim|unclaim|setrank|unclaimall> [args]
|
usage: /gFaction <invite|join|leave|kick|info|new|claim|unclaim|setrank|unclaimall> [args]
|
||||||
|
|
@ -73,8 +65,8 @@ commands:
|
||||||
usage: /gDim <create|delete|tp|list|info> [args]
|
usage: /gDim <create|delete|tp|list|info> [args]
|
||||||
permission: grimmsserver.dimensions
|
permission: grimmsserver.dimensions
|
||||||
gUtil:
|
gUtil:
|
||||||
description: Utility commands for version info, relics, capabilities, and settings
|
description: Utility commands for version info, relics, capabilities, settings, and title management
|
||||||
usage: /gUtil <version|relic|capability|setting> [args]
|
usage: /gUtil <version|relic|capability|setting|addtitle|removetitle> [args]
|
||||||
permission: grimmsserver.util
|
permission: grimmsserver.util
|
||||||
gConfig:
|
gConfig:
|
||||||
description: Manage server configuration - dump config or reload settings
|
description: Manage server configuration - dump config or reload settings
|
||||||
|
|
@ -110,9 +102,6 @@ permissions:
|
||||||
grimmsserver.setPlayerStat:
|
grimmsserver.setPlayerStat:
|
||||||
description: Allows setting any player's stats directly (admin only)
|
description: Allows setting any player's stats directly (admin only)
|
||||||
default: op
|
default: op
|
||||||
grimmsserver.addTitle:
|
|
||||||
description: Allows granting titles to players (admin only)
|
|
||||||
default: op
|
|
||||||
grimmsserver.executePlayer:
|
grimmsserver.executePlayer:
|
||||||
description: Allows executing players with the Executioner title
|
description: Allows executing players with the Executioner title
|
||||||
default: true
|
default: true
|
||||||
|
|
@ -131,9 +120,6 @@ permissions:
|
||||||
grimmsserver.acceptRequest:
|
grimmsserver.acceptRequest:
|
||||||
description: Allows accepting pending requests (faction invites, etc.)
|
description: Allows accepting pending requests (faction invites, etc.)
|
||||||
default: true
|
default: true
|
||||||
grimmsserver.removeTitle:
|
|
||||||
description: Allows removing titles from players (admin only)
|
|
||||||
default: op
|
|
||||||
grimmsserver.faction:
|
grimmsserver.faction:
|
||||||
description: Allows using faction commands for group gameplay
|
description: Allows using faction commands for group gameplay
|
||||||
default: true
|
default: true
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue