Component cleanup and bugsfixings
suicide, voidkiller, getstats rework
This commit is contained in:
1 parent
23d2d378ea
commit
1ce06a5028
15 files changed
+109
-91
No files matched your search
@@ -41,7 +41,6 @@ public class AdminCommandManager implements TabExecutor {
|
||||
public AdminCommandManager(Plugin plugin) {
|
||||
subcommands.add(new KitSupercommand((PureKitPvP) plugin));
|
||||
subcommands.add(new ResetKit());
|
||||
subcommands.add(new SetKillItem(plugin));
|
||||
subcommands.add(new GetKitStats(plugin));
|
||||
this.globalEventManager = new GlobalEventManager(plugin);
|
||||
subcommands.add(new EventCommand(plugin, this.globalEventManager));
|
||||
@@ -155,7 +154,6 @@ public class AdminCommandManager implements TabExecutor {
|
||||
arguments.add("edit");
|
||||
return arguments;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("setkillitem")) {
|
||||
|
||||
if (args.length == 3) {
|
||||
|
||||
@@ -2,7 +2,10 @@ package me.lifelessnerd.purekitpvp;
|
||||
|
||||
import me.lifelessnerd.purekitpvp.files.lang.LanguageConfig;
|
||||
import me.lifelessnerd.purekitpvp.utils.ComponentUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextReplacementConfig;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@@ -44,7 +47,7 @@ public class AdminHelpCommand extends Subcommand {
|
||||
|
||||
@Override
|
||||
public boolean perform(CommandSender sender, String[] args) {
|
||||
|
||||
LegacyComponentSerializer serializer = LegacyComponentSerializer.legacyAmpersand();
|
||||
if (args.length == 1){
|
||||
String message = """
|
||||
&bPureKitPvP - Help Menu
|
||||
@@ -56,7 +59,8 @@ public class AdminHelpCommand extends Subcommand {
|
||||
&a/purekitpvphelp &r- &eShow this menu for non-admins
|
||||
&bFor admin commands, see &a/pkpvp help 2&b!
|
||||
""";
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', message));
|
||||
|
||||
sender.sendMessage(serializer.deserialize(message));
|
||||
|
||||
|
||||
}
|
||||
@@ -64,11 +68,10 @@ public class AdminHelpCommand extends Subcommand {
|
||||
|
||||
if (args[1].equalsIgnoreCase("2")){
|
||||
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&bPureKitPvP - Admin Commands"));
|
||||
sender.sendMessage(Component.text("PureKitPvP - Admin Commands").color(NamedTextColor.BLUE));
|
||||
for (Subcommand subcommand : subcommands){
|
||||
String message =
|
||||
"&a" + subcommand.getSyntax() + " &r- &e" + subcommand.getDescription();
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', message));
|
||||
String message = "&a" + subcommand.getSyntax() + " &r- &e" + subcommand.getDescription();
|
||||
sender.sendMessage(serializer.deserialize(message));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.lifelessnerd.purekitpvp;
|
||||
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -43,7 +44,8 @@ public class InfoCommand extends Subcommand{
|
||||
&6Developer: &ohttps://twitter.com/LukaDeVrij
|
||||
&rIf you have any problems, bugs or glitches, please do reach out to me via any of the links above.
|
||||
""";
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', message));
|
||||
LegacyComponentSerializer serializer = LegacyComponentSerializer.legacyAmpersand();
|
||||
sender.sendMessage(serializer.deserialize(message));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+1
-3
@@ -34,9 +34,7 @@ public class VoidKiller implements Listener {
|
||||
for (PotionEffect effect : p.getActivePotionEffects()) {
|
||||
p.removePotionEffect(effect.getType());
|
||||
}
|
||||
p.setHealth(1);
|
||||
Location tpLoc = new Location(loc.getWorld(), loc.getX(), loc.getY() - 150, loc.getZ());
|
||||
p.teleport(tpLoc);
|
||||
p.chat("/suicide");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Please set voidY in the config!");
|
||||
|
||||
+19
-20
@@ -6,17 +6,20 @@ import me.lifelessnerd.purekitpvp.combathandlers.libs.DamageCauseLib;
|
||||
import me.lifelessnerd.purekitpvp.combathandlers.mobhandler.MobRemover;
|
||||
import me.lifelessnerd.purekitpvp.cosmetics.cosmeticsListeners.KillEffect;
|
||||
import me.lifelessnerd.purekitpvp.cosmetics.cosmeticsListeners.KillMessage;
|
||||
import me.lifelessnerd.purekitpvp.files.lang.LanguageConfig;
|
||||
import me.lifelessnerd.purekitpvp.files.lang.LanguageKey;
|
||||
import me.lifelessnerd.purekitpvp.globalevents.EventDataClass;
|
||||
import me.lifelessnerd.purekitpvp.globalevents.events.JuggernautListeners;
|
||||
import me.lifelessnerd.purekitpvp.perks.perkfirehandler.PerkFireHandler;
|
||||
import me.lifelessnerd.purekitpvp.files.KitConfig;
|
||||
import me.lifelessnerd.purekitpvp.files.PlayerStatsConfig;
|
||||
import me.lifelessnerd.purekitpvp.utils.ComponentUtils;
|
||||
import me.lifelessnerd.purekitpvp.utils.DoubleUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@@ -129,8 +132,9 @@ public class DeathHandler implements Listener {
|
||||
// Get all damage info and print to killed player
|
||||
NamespacedKey key = new NamespacedKey(plugin, "damageDistributionInfo");
|
||||
PlayerDamageDistribution damageData = player.getPersistentDataContainer().get(key, new PlayerDamageDistributionDataType());
|
||||
player.sendMessage(Component.text("You died!").color(NamedTextColor.RED).decoration(TextDecoration.BOLD, true));
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7Death Recap:"));
|
||||
player.sendMessage(LanguageConfig.lang.get(LanguageKey.COMBAT_YOU_DIED.toString()));
|
||||
player.sendMessage(LanguageConfig.lang.get(LanguageKey.COMBAT_DEATH_RECAP.toString()));
|
||||
|
||||
// Printing process and formatting
|
||||
int totalDamageDone = 0;
|
||||
for (String hashmapKey : damageData.damageDistributionMap.keySet()){
|
||||
@@ -139,19 +143,11 @@ public class DeathHandler implements Listener {
|
||||
for (String hashmapKey : damageData.damageDistributionMap.keySet()){
|
||||
int damageValue = damageData.damageDistributionMap.get(hashmapKey);
|
||||
double damagePercentage = (double) damageValue / (double) totalDamageDone * 100.0;
|
||||
|
||||
if (damageCauseLib.damageCauseTranslations.containsKey(hashmapKey)){
|
||||
// hashMapKey is a damageCause object
|
||||
String damageCauseTranslation = damageCauseLib.damageCauseTranslations.get(hashmapKey);
|
||||
String format = "&7-&e" + damageCauseTranslation + "&7 did &a" + (int) damagePercentage + "%";
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', format));
|
||||
|
||||
}
|
||||
else {
|
||||
String format = "&7- &a" + hashmapKey + "&7 did &a" + (int) damagePercentage + "%";
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', format));
|
||||
|
||||
}
|
||||
int damagePercentageInt = (int) damagePercentage;
|
||||
String damageCause = damageCauseLib.damageCauseTranslations.getOrDefault(hashmapKey, hashmapKey);
|
||||
player.sendMessage(LanguageConfig.lang.get(LanguageKey.COMBAT_DEATH_CAUSE.toString()).
|
||||
replaceText(ComponentUtils.replaceConfig("%CAUSE%", damageCause)).
|
||||
replaceText(ComponentUtils.replaceConfig("%VALUE%", String.valueOf(damagePercentageInt))));
|
||||
}
|
||||
|
||||
//Broadcasting and stuff
|
||||
@@ -206,8 +202,7 @@ public class DeathHandler implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Component mainTitle = Component.text("You died!").color(TextColor.color(230,60,60));
|
||||
Component mainTitle = LanguageConfig.lang.get(LanguageKey.COMBAT_YOU_DIED.toString());
|
||||
Title title = Title.title(mainTitle, Component.text(""));
|
||||
player.showTitle(title);
|
||||
|
||||
@@ -296,8 +291,6 @@ public class DeathHandler implements Listener {
|
||||
|
||||
//update level
|
||||
PlayerLeveling.createLevelXPPath(player.getName());
|
||||
// PlayerLeveling.addExperience(player, 1, "Death"); // 1 for DEATH// Ah no: can be exploited
|
||||
// PlayerLeveling.updateLevels();
|
||||
|
||||
//remove any mobs player spawned
|
||||
MobRemover.removeMobs(player);
|
||||
@@ -402,6 +395,7 @@ public class DeathHandler implements Listener {
|
||||
|
||||
}
|
||||
|
||||
// If there is an assistor, we need to do some stuff for that player
|
||||
if (assistor != null){
|
||||
FileConfiguration assistorStats = PlayerStatsConfig.get();
|
||||
if (assistorStats.isSet(assistor.getName())){
|
||||
@@ -517,10 +511,15 @@ public class DeathHandler implements Listener {
|
||||
return; // Prevents NPE's
|
||||
} else if (event.getDamager() instanceof Firework && event.getEntity() instanceof Player){
|
||||
Firework fw = (Firework) event.getDamager();
|
||||
if (fw.hasMetadata("nodamage")) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (fw.getShooter() instanceof Player){
|
||||
player = (Player) event.getEntity();
|
||||
damager = (Player) fw.getShooter();
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
//If we end up here idk what happened but nothing relevant (probably a zombie hitting a pig or something)
|
||||
|
||||
+1
-2
@@ -50,8 +50,7 @@ public class Suicide implements CommandExecutor {
|
||||
}
|
||||
PlayerDamageDistribution damageData = player.getPersistentDataContainer().get(key, new PlayerDamageDistributionDataType());
|
||||
damageData.lastOtherDamager = "SUICIDE"; // NPE lies
|
||||
damageData.lastPlayerDamager = null;
|
||||
damageData.damageDistributionMap.put("SUICIDE", Integer.MAX_VALUE);
|
||||
damageData.damageDistributionMap.put("SUICIDE", 100000);
|
||||
player.getPersistentDataContainer().set(key, new PlayerDamageDistributionDataType(), damageData);
|
||||
|
||||
} catch (Exception e){
|
||||
|
||||
+5
-1
@@ -1,6 +1,9 @@
|
||||
package me.lifelessnerd.purekitpvp.combathandlers.leveling;
|
||||
|
||||
import me.lifelessnerd.purekitpvp.files.PlayerStatsConfig;
|
||||
import me.lifelessnerd.purekitpvp.files.lang.LanguageConfig;
|
||||
import me.lifelessnerd.purekitpvp.files.lang.LanguageKey;
|
||||
import me.lifelessnerd.purekitpvp.utils.ComponentUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@@ -52,7 +55,8 @@ public class PlayerLeveling {
|
||||
int level = xpValue / 100;
|
||||
if (!(level == playerStats.getInt(key + ".level"))){
|
||||
Player player = Bukkit.getPlayerExact(key);
|
||||
player.sendMessage(ChatColor.GOLD + "You leveled up to LEVEL " + level);
|
||||
player.sendMessage(LanguageConfig.lang.get(LanguageKey.STATS_LEVEL_UP.toString()).
|
||||
replaceText(ComponentUtils.replaceConfig("%VALUE%", String.valueOf(level))));
|
||||
|
||||
}
|
||||
playerStats.set(key + ".level", level);
|
||||
|
||||
+28
-28
@@ -38,34 +38,34 @@ public class DamageCauseLib {
|
||||
deathMessages.put("SONIC_BOOM"," got pummeled by a Warden");
|
||||
deathMessages.put("MONSTER", " was killed by a mob, what a noob.");
|
||||
|
||||
damageCauseTranslations.put("CONTACT"," Cactus");
|
||||
damageCauseTranslations.put("SUFFOCATION"," Suffocation");
|
||||
damageCauseTranslations.put("FALL"," Fall Damage");
|
||||
damageCauseTranslations.put("FIRE"," Fire");
|
||||
damageCauseTranslations.put("FIRE_TICK"," Fire");
|
||||
damageCauseTranslations.put("MELTING"," Lava");
|
||||
damageCauseTranslations.put("LAVA"," Lava");
|
||||
damageCauseTranslations.put("DROWNING"," Drowning");
|
||||
damageCauseTranslations.put("BLOCK_EXPLOSION"," Explosion");
|
||||
damageCauseTranslations.put("ENTITY_EXPLOSION"," Explosion");
|
||||
damageCauseTranslations.put("VOID"," Void");
|
||||
damageCauseTranslations.put("LIGHTNING"," Lightning");
|
||||
damageCauseTranslations.put("SUICIDE"," You");
|
||||
damageCauseTranslations.put("STARVATION"," Hunger");
|
||||
damageCauseTranslations.put("POISON"," Poison");
|
||||
damageCauseTranslations.put("MAGIC"," Harming Effect");
|
||||
damageCauseTranslations.put("WITHER"," Wither Effect");
|
||||
damageCauseTranslations.put("FALLING_BLOCK"," Falling Blocks");
|
||||
damageCauseTranslations.put("THORNS"," Thorns");
|
||||
damageCauseTranslations.put("DRAGON_BREATH"," Dragon's Breath");
|
||||
damageCauseTranslations.put("CUSTOM"," ???");
|
||||
damageCauseTranslations.put("FLY_INTO_WALL"," Kinetic Energy");
|
||||
damageCauseTranslations.put("HOT_FLOOR"," Magma");
|
||||
damageCauseTranslations.put("CRAMMING"," Crowding");
|
||||
damageCauseTranslations.put("DRYOUT"," Dryout");
|
||||
damageCauseTranslations.put("FREEZE"," Freezing");
|
||||
damageCauseTranslations.put("SONIC_BOOM"," Warden");
|
||||
damageCauseTranslations.put("MONSTER"," Custom Mob");
|
||||
damageCauseTranslations.put("CONTACT","Cactus");
|
||||
damageCauseTranslations.put("SUFFOCATION","Suffocation");
|
||||
damageCauseTranslations.put("FALL","Fall Damage");
|
||||
damageCauseTranslations.put("FIRE","Fire");
|
||||
damageCauseTranslations.put("FIRE_TICK","Fire");
|
||||
damageCauseTranslations.put("MELTING","Lava");
|
||||
damageCauseTranslations.put("LAVA","Lava");
|
||||
damageCauseTranslations.put("DROWNING","Drowning");
|
||||
damageCauseTranslations.put("BLOCK_EXPLOSION","Explosion");
|
||||
damageCauseTranslations.put("ENTITY_EXPLOSION","Explosion");
|
||||
damageCauseTranslations.put("VOID","Void");
|
||||
damageCauseTranslations.put("LIGHTNING","Lightning");
|
||||
damageCauseTranslations.put("SUICIDE","You");
|
||||
damageCauseTranslations.put("STARVATION","Hunger");
|
||||
damageCauseTranslations.put("POISON","Poison");
|
||||
damageCauseTranslations.put("MAGIC","Harming Effect");
|
||||
damageCauseTranslations.put("WITHER","Wither Effect");
|
||||
damageCauseTranslations.put("FALLING_BLOCK","Falling Blocks");
|
||||
damageCauseTranslations.put("THORNS","Thorns");
|
||||
damageCauseTranslations.put("DRAGON_BREATH","Dragon's Breath");
|
||||
damageCauseTranslations.put("CUSTOM","???");
|
||||
damageCauseTranslations.put("FLY_INTO_WALL","Kinetic Energy");
|
||||
damageCauseTranslations.put("HOT_FLOOR","Magma");
|
||||
damageCauseTranslations.put("CRAMMING","Crowding");
|
||||
damageCauseTranslations.put("DRYOUT","Dryout");
|
||||
damageCauseTranslations.put("FREEZE","Freezing");
|
||||
damageCauseTranslations.put("SONIC_BOOM","Warden");
|
||||
damageCauseTranslations.put("MONSTER","Custom Mob");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,6 +184,12 @@ public class LanguageConfig {
|
||||
defaults.put(LanguageKey.SCOREBOARD_GLOBAL_KILLS, " &dKills");
|
||||
defaults.put(LanguageKey.SCOREBOARD_GLOBAL_KD, " &dK/D Ratio");
|
||||
defaults.put(LanguageKey.SCOREBOARD_GLOBAL_LEVEL, "&dLevel");
|
||||
defaults.put(LanguageKey.STATS_NO_STATS, "That player has no stats attached to them!");
|
||||
defaults.put(LanguageKey.STATS_TITLE, "%PLAYER% &bStatistics");
|
||||
defaults.put(LanguageKey.STATS_LEVEL_UP, "&6You leveled up to LEVEL %VALUE%!");
|
||||
defaults.put(LanguageKey.COMBAT_YOU_DIED, "&c&lYou died!");
|
||||
defaults.put(LanguageKey.COMBAT_DEATH_RECAP, "&7Death Recap");
|
||||
defaults.put(LanguageKey.COMBAT_DEATH_CAUSE, "&7- &e%CAUSE% &7did &a%VALUE%%");
|
||||
|
||||
SortedMap<String, Object> defaultsString = new TreeMap<>();
|
||||
for (LanguageKey key : defaults.keySet()){
|
||||
|
||||
@@ -90,6 +90,12 @@ public enum LanguageKey {
|
||||
SCOREBOARD_GLOBAL_KILLS,
|
||||
SCOREBOARD_GLOBAL_KD,
|
||||
SCOREBOARD_GLOBAL_LEVEL,
|
||||
STATS_NO_STATS,
|
||||
STATS_TITLE,
|
||||
COMBAT_YOU_DIED,
|
||||
COMBAT_DEATH_RECAP,
|
||||
COMBAT_DEATH_CAUSE,
|
||||
STATS_LEVEL_UP,
|
||||
|
||||
;
|
||||
|
||||
|
||||
+4
-1
@@ -142,6 +142,10 @@ public class GlobalEventManager {
|
||||
}
|
||||
|
||||
public Component pauseResumeTimer() {
|
||||
if (currentEvent == null){
|
||||
return Component.text("There is no event running, you may not pause now!").color(NamedTextColor.RED);
|
||||
// TODO temp fix; this should be possible but for some reason NPES everywhere if we dont do this also double events?
|
||||
}
|
||||
if (paused) {
|
||||
currentEvent.pauseResumePasser(true);
|
||||
paused = false;
|
||||
@@ -163,7 +167,6 @@ public class GlobalEventManager {
|
||||
}
|
||||
}.runTaskTimer(plugin, 0, 20);
|
||||
|
||||
|
||||
return Component.text("Global event loop resumed.").color(NamedTextColor.GREEN);
|
||||
} else {
|
||||
currentEvent.pauseResumePasser(false);
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package me.lifelessnerd.purekitpvp.globalevents.events;
|
||||
|
||||
import me.lifelessnerd.purekitpvp.files.lang.LanguageConfig;
|
||||
import me.lifelessnerd.purekitpvp.files.lang.LanguageKey;
|
||||
import me.lifelessnerd.purekitpvp.globalevents.EventDataClass;
|
||||
import me.lifelessnerd.purekitpvp.utils.PlayerUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -28,7 +29,7 @@ public class DoubleHealthEvent extends AbstractEvent{
|
||||
|
||||
@Override
|
||||
public Component getEventDescription() {
|
||||
return LanguageConfig.lang.get("EVENTS_DOUBLE_DESC"); // TODO add lang defs
|
||||
return LanguageConfig.lang.get(LanguageKey.EVENTS_DOUBLE_DESC.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,7 +2,10 @@ package me.lifelessnerd.purekitpvp.kitadmin;
|
||||
|
||||
import me.lifelessnerd.purekitpvp.Subcommand;
|
||||
import me.lifelessnerd.purekitpvp.files.KitConfig;
|
||||
import me.lifelessnerd.purekitpvp.files.lang.LanguageConfig;
|
||||
import me.lifelessnerd.purekitpvp.files.lang.LanguageKey;
|
||||
import me.lifelessnerd.purekitpvp.utils.MyStringUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -46,25 +49,25 @@ public class SetKillItem extends Subcommand {
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (!player.hasPermission("purekitpvp.admin.createkit")){
|
||||
player.sendMessage(ChatColor.RED + "No permission!");
|
||||
player.sendMessage(LanguageConfig.lang.get(LanguageKey.GENERIC_NO_PERMISSION.toString()));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(args.length >= 2)){
|
||||
player.sendMessage(ChatColor.RED + "Please provide arguments!");
|
||||
player.sendMessage(LanguageConfig.lang.get(LanguageKey.GENERIC_LACK_OF_ARGS.toString()));
|
||||
return false;
|
||||
}
|
||||
|
||||
String kitNameArg = MyStringUtils.camelCaseWord(args[1]);
|
||||
|
||||
if (!(KitConfig.get().isSet("kits." + kitNameArg))){
|
||||
player.sendMessage(ChatColor.GRAY + "That kit does not exist.");
|
||||
player.sendMessage(LanguageConfig.lang.get(LanguageKey.KITS_DOES_NOT_EXIST.toString()));
|
||||
return true;
|
||||
}
|
||||
|
||||
ItemStack itemStack = player.getInventory().getItemInMainHand();
|
||||
KitConfig.get().set("kits." + kitNameArg + ".killitem", itemStack);
|
||||
player.sendMessage("Set the kill item of the kit " + kitNameArg + " to " + itemStack.getType());
|
||||
player.sendMessage(Component.text("Set the kill item of the kit " + kitNameArg + " to " + itemStack.getType()));
|
||||
KitConfig.save();
|
||||
KitConfig.reload();
|
||||
|
||||
|
||||
+2
-1
@@ -2,6 +2,7 @@ package me.lifelessnerd.purekitpvp.noncombatstats.commands;
|
||||
|
||||
import me.lifelessnerd.purekitpvp.Subcommand;
|
||||
import me.lifelessnerd.purekitpvp.files.KitStatsConfig;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@@ -70,7 +71,7 @@ public class GetKitStats extends Subcommand {
|
||||
|
||||
for(String key : sortedMap.keySet()){
|
||||
|
||||
sender.sendMessage(key + " - " + kitStats.getInt(key));
|
||||
sender.sendMessage(Component.text(key + " - " + kitStats.getInt(key)));
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
+16
-21
@@ -1,11 +1,17 @@
|
||||
package me.lifelessnerd.purekitpvp.noncombatstats.commands;
|
||||
|
||||
import me.lifelessnerd.purekitpvp.files.PlayerStatsConfig;
|
||||
import me.lifelessnerd.purekitpvp.files.lang.LanguageConfig;
|
||||
import me.lifelessnerd.purekitpvp.files.lang.LanguageKey;
|
||||
import me.lifelessnerd.purekitpvp.utils.ComponentUtils;
|
||||
import me.lifelessnerd.purekitpvp.utils.MyStringUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@@ -37,34 +43,23 @@ public class GetStats implements TabExecutor {
|
||||
|
||||
Set<String> allKeys = playerStatsConfig.getKeys(true);
|
||||
if (!(allKeys.contains(argumentPlayer))){
|
||||
player.sendMessage("That player does not have any stats attached to them.");
|
||||
player.sendMessage(LanguageConfig.lang.get(LanguageKey.STATS_NO_STATS.toString()));
|
||||
return true;
|
||||
}
|
||||
|
||||
player.sendMessage(LanguageConfig.lang.get(LanguageKey.STATS_TITLE.toString()).
|
||||
replaceText(ComponentUtils.replaceConfig("%PLAYER%", argumentPlayer)));
|
||||
|
||||
player.sendMessage(argumentPlayer + "'s " + ChatColor.BLUE + "Statistics");
|
||||
for (String key : allKeys){
|
||||
if (key.split("\\.").length == 1){
|
||||
continue;
|
||||
}
|
||||
if (key.split("\\.")[0].equalsIgnoreCase(argumentPlayer)) {
|
||||
ConfigurationSection playerStatsSection = PlayerStatsConfig.get().getConfigurationSection(argumentPlayer);
|
||||
|
||||
//Only children of player
|
||||
if (key.split("\\.")[1].equalsIgnoreCase("kdratio")) {
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&a " +
|
||||
MyStringUtils.itemCamelCase(key.split("\\.")[1]) + "&c- &r" + playerStatsConfig.getDouble(key)));
|
||||
} else if (key.split("\\.")[1].equalsIgnoreCase("current_kit")){
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&a " +
|
||||
MyStringUtils.itemCamelCase(key.split("\\.")[1]) + "&c- &r" + playerStatsConfig.getString(key)));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&a " +
|
||||
MyStringUtils.itemCamelCase(key.split("\\.")[1]) + "&c- &r" + playerStatsConfig.getInt(key)));
|
||||
}
|
||||
}
|
||||
for (String key : playerStatsSection.getKeys(false)){
|
||||
player.sendMessage(
|
||||
Component.text(" " + MyStringUtils.itemCamelCase(key)).color(NamedTextColor.GREEN).append(
|
||||
Component.text("- ").color(NamedTextColor.RED).append(
|
||||
Component.text(playerStatsSection.get(key).toString()).color(NamedTextColor.WHITE)
|
||||
)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user