Removed use of deprecated methods

This commit is contained in:
Jules 2024-02-20 00:27:54 +01:00
parent a653ffbfe1
commit 0fd1f6bbce
4 changed files with 24 additions and 25 deletions

View File

@ -46,7 +46,7 @@ public class PlayerStats {
}
public double getStat(String stat) {
return getMap().getInstance(stat).getTotal();
return getMap().getStat(stat);
}
/**

View File

@ -12,30 +12,30 @@ import org.bukkit.entity.Player;
public class StatModifiersCommandTreeNode extends CommandTreeNode {
public StatModifiersCommandTreeNode(CommandTreeNode parent) {
super(parent, "statmods");
public StatModifiersCommandTreeNode(CommandTreeNode parent) {
super(parent, "statmods");
addParameter(new Parameter("<stat>", (explorer, list) -> list.add("STAT_ID")));
}
}
@Override
public CommandResult execute(CommandSender sender, String[] args) {
if (args.length < 3)
return CommandResult.THROW_USAGE;
@Override
public CommandResult execute(CommandSender sender, String[] args) {
if (args.length < 3)
return CommandResult.THROW_USAGE;
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command can only be used by a player.");
return CommandResult.FAILURE;
}
PlayerData data = PlayerData.get((Player) sender);
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command can only be used by a player.");
return CommandResult.FAILURE;
}
PlayerData data = PlayerData.get((Player) sender);
StatInstance instance = data.getMMOPlayerData().getStatMap().getInstance(UtilityMethods.enumName(args[2]));
sender.sendMessage("Stat Modifiers (" + instance.getKeys().size() + "):");
for (String key : instance.getKeys()) {
StatModifier mod = instance.getModifier(key);
sender.sendMessage("- " + key + ": " + mod.getValue() + " " + mod.getType().name());
}
StatInstance instance = data.getMMOPlayerData().getStatMap().getInstance(UtilityMethods.enumName(args[2]));
sender.sendMessage("Stat Modifiers (" + instance.getKeys().size() + "):");
for (String key : instance.getKeys()) {
StatModifier mod = instance.getModifier(key);
sender.sendMessage("-> '" + key + "' " + mod.getValue() + " " + mod.getType().name() + " " + mod.getSlot() + " " + mod.getSource());
}
return CommandResult.SUCCESS;
}
return CommandResult.SUCCESS;
}
}

View File

@ -133,7 +133,7 @@ public class PlayerStats extends EditableInventory {
if (holder.endsWith("_extra")) {
final String stat = UtilityMethods.enumName(holder.substring(0, holder.length() - 6));
return StatManager.format(stat, MythicLib.plugin.getStats().getTotalValue(stat, stats.getMap()) - stats.getBase(stat));
return StatManager.format(stat, stats.getStat(stat) - stats.getBase(stat));
}
if (holder.startsWith("attribute_")) {
@ -142,7 +142,7 @@ public class PlayerStats extends EditableInventory {
}
final String stat = UtilityMethods.enumName(holder);
return StatManager.format(stat, MythicLib.plugin.getStats().getTotalValue(stat, stats.getMap()));
return StatManager.format(stat, stats.getStat(stat));
}
};
}

View File

@ -50,8 +50,7 @@ public class AttributeManager implements MMOCoreManager {
final ConfigurationSection statsConfig = new ConfigFile(MythicLib.plugin, "", "stats").getConfig();
for (PlayerAttribute attr : getAll()) {
final MMOCoreAttributeStatHandler handler = new MMOCoreAttributeStatHandler(statsConfig, attr);
MythicLib.plugin.getStats().registerStat(handler.getStat(), handler);
MythicLib.plugin.getStats().registerStat(handler.getStat() + "_PERCENT", handler);
MythicLib.plugin.getStats().registerStat(handler, handler.getStat() + "_PERCENT");
}
}
}