mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Some refactoring
This commit is contained in:
parent
329de942b4
commit
15578bb84e
@ -11,7 +11,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
|
@ -7,9 +7,9 @@ import com.gmail.nossr50.datatypes.notifications.SensitiveCommandType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
|
@ -11,8 +11,8 @@ import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -2,8 +2,8 @@ package com.gmail.nossr50.commands.hardcore;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -6,9 +6,9 @@ import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -5,9 +5,9 @@ import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -7,9 +7,9 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -2,11 +2,11 @@ package com.gmail.nossr50.commands.player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.experience.ExperienceBarManager;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -5,10 +5,10 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||
import com.gmail.nossr50.listeners.InteractionManager;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.random.RandomChanceSkill;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -5,9 +5,9 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.alchemy.AlchemyManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -3,8 +3,8 @@ package com.gmail.nossr50.commands.skills;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.HolidayManager.FakeSkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -4,9 +4,9 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.archery.Archery;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -5,11 +5,11 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.axes.Axes;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -5,9 +5,9 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -9,10 +9,10 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||
import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
@ -4,9 +4,9 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -5,10 +5,10 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -6,7 +6,7 @@ import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||
import com.gmail.nossr50.listeners.InteractionManager;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -10,10 +10,10 @@ import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.RepairManager;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -5,9 +5,9 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.salvage.Salvage;
|
||||
import com.gmail.nossr50.skills.salvage.SalvageManager;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -8,8 +8,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@ -18,6 +16,8 @@ import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
@ -2,7 +2,7 @@ package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -4,10 +4,10 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -5,11 +5,11 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -5,8 +5,8 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.taming.Taming;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -4,11 +4,11 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -4,9 +4,9 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ChatConfig extends AutoUpdateConfigLoader {
|
||||
|
@ -5,7 +5,7 @@ import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
@ -2,7 +2,7 @@ package com.gmail.nossr50.config;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
|
||||
public class CoreSkillsConfig extends AutoUpdateConfigLoader {
|
||||
private static CoreSkillsConfig instance;
|
||||
|
@ -5,7 +5,7 @@ import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.gmail.nossr50.config.party;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
@ -3,7 +3,7 @@ package com.gmail.nossr50.config.treasure;
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.treasure.*;
|
||||
import com.gmail.nossr50.util.EnchantmentUtils;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
|
@ -13,7 +13,7 @@ import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.database.UUIDUpdateAsyncTask;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import java.io.*;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.gmail.nossr50.datatypes.json;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
|
||||
public enum McMMOWebLinks {
|
||||
WEBSITE,
|
||||
|
@ -2,7 +2,7 @@ package com.gmail.nossr50.datatypes.party;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public enum ItemShareType {
|
||||
|
@ -4,7 +4,7 @@ import com.gmail.nossr50.commands.party.PartySubcommandType;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public enum PartyFeature {
|
||||
|
@ -21,8 +21,8 @@ import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.gmail.nossr50.datatypes.skills;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
|
@ -5,7 +5,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -6,7 +6,7 @@ import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.InteractType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.datatypes.skills.subskills.taming;
|
||||
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public enum CallOfTheWildType {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.gmail.nossr50.events.skills;
|
||||
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.util.McMMOMessageType;
|
||||
import com.gmail.nossr50.util.text.McMMOMessageType;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
@ -9,8 +9,8 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -2,7 +2,7 @@ package com.gmail.nossr50.skills.child;
|
||||
|
||||
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
@ -5,7 +5,7 @@ import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -28,6 +28,7 @@ import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
@ -15,7 +15,6 @@ import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
@ -24,6 +23,7 @@ import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -15,7 +15,6 @@ import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
@ -23,6 +22,7 @@ import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
@ -16,7 +16,6 @@ import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.compat.layers.persistentdata.MobMetaFlagType;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
|
||||
@ -26,6 +25,7 @@ import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
|
@ -11,6 +11,7 @@ import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
|
@ -6,6 +6,7 @@ import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||
import com.gmail.nossr50.datatypes.meta.OldName;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.MobHealthDisplayUpdaterTask;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -22,7 +22,7 @@ import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -7,9 +7,9 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -2,13 +2,13 @@ package com.gmail.nossr50.util.compat;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.compat.layers.attackcooldown.PlayerAttackCooldownExploitPreventionLayer;
|
||||
import com.gmail.nossr50.util.compat.layers.persistentdata.AbstractPersistentDataLayer;
|
||||
import com.gmail.nossr50.util.compat.layers.persistentdata.SpigotPersistentDataLayer_1_13;
|
||||
import com.gmail.nossr50.util.compat.layers.persistentdata.SpigotPersistentDataLayer_1_14;
|
||||
import com.gmail.nossr50.util.nms.NMSVersion;
|
||||
import com.gmail.nossr50.util.platform.MinecraftGameVersion;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -4,8 +4,8 @@ import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.player.PlayerLevelUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.boss.BossBar;
|
||||
|
@ -10,11 +10,11 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.events.skills.McMMOPlayerNotificationEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.McMMOMessageType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import com.gmail.nossr50.util.text.McMMOMessageType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.MessageType;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
|
@ -14,10 +14,10 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.compat.layers.persistentdata.AbstractPersistentDataLayer;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.util;
|
||||
package com.gmail.nossr50.util.text;
|
||||
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.MessageType;
|
@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.util;
|
||||
package com.gmail.nossr50.util.text;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.util;
|
||||
package com.gmail.nossr50.util.text;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.RankConfig;
|
||||
@ -10,24 +10,21 @@ import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||
import com.gmail.nossr50.listeners.InteractionManager;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.MessageType;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.ComponentBuilder;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@ -56,7 +53,7 @@ public class TextComponentFactory {
|
||||
|
||||
public static Component getNotificationLevelUpTextComponent(PrimarySkillType skill, int levelsGained, int currentLevel)
|
||||
{
|
||||
return Component.text(LocaleLoader.getString("Overhaul.Levelup", LocaleLoader.getString("Overhaul.Name."+StringUtils.getCapitalized(skill.toString())), levelsGained, currentLevel));
|
||||
return Component.text(LocaleLoader.getString("Overhaul.Levelup", LocaleLoader.getString("Overhaul.Name."+ StringUtils.getCapitalized(skill.toString())), levelsGained, currentLevel));
|
||||
}
|
||||
|
||||
private static TextComponent getNotificationTextComponent(String text)
|
||||
@ -109,6 +106,13 @@ public class TextComponentFactory {
|
||||
), MessageType.SYSTEM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a player a bunch of text components that represent a list of sub-skills
|
||||
* Styling and formatting is applied before sending the messages
|
||||
*
|
||||
* @param player target player
|
||||
* @param subSkillComponents the text components representing the sub-skills by name
|
||||
*/
|
||||
public static void sendPlayerSubSkillList(@NotNull Player player, @NotNull List<Component> subSkillComponents) {
|
||||
final Audience audience = mcMMO.getAudiences().player(player);
|
||||
|
||||
@ -117,12 +121,12 @@ public class TextComponentFactory {
|
||||
TextComponent atSignComponent = Component.text(LocaleLoader.getString("JSON.Hover.AtSymbolSkills"));
|
||||
|
||||
//Only send 3 sub-skills per line
|
||||
Component[][] splitSubSkills = splitComponentsIntoGroups(subSkillComponents, 3);
|
||||
Component[][] splitSubSkills = TextUtils.splitComponentsIntoGroups(subSkillComponents, 3);
|
||||
ArrayList<Component> individualLinesToSend = new ArrayList<>();
|
||||
|
||||
//Create each line
|
||||
for (Component[] componentArray : splitSubSkills) {
|
||||
individualLinesToSend.add(fromArray(componentArray, atSignComponent, space));
|
||||
individualLinesToSend.add(TextUtils.fromArray(componentArray, atSignComponent, space));
|
||||
}
|
||||
|
||||
//Send each group
|
||||
@ -131,116 +135,6 @@ public class TextComponentFactory {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a single component from an array of components, can optionally add prefixes and suffixes to come before and after each component
|
||||
* @param componentsArray target array
|
||||
* @return
|
||||
*/
|
||||
private static @NotNull Component fromArray(@NotNull Component[] componentsArray, @Nullable Component prefixComponent, @Nullable Component suffixComponent) {
|
||||
TextComponent.Builder componentBuilder = Component.text();
|
||||
|
||||
for(Component component : componentsArray) {
|
||||
if(component == null) //Individual elements can be null
|
||||
continue;
|
||||
|
||||
if(prefixComponent != null)
|
||||
componentBuilder.append(prefixComponent);
|
||||
|
||||
componentBuilder.append(component);
|
||||
|
||||
if(suffixComponent != null)
|
||||
componentBuilder.append(suffixComponent);
|
||||
|
||||
}
|
||||
|
||||
return componentBuilder.build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Takes a list of components and splits them into arrays each with a maximum element limit
|
||||
* Individual elements in [][X] may be null
|
||||
*
|
||||
* @param components target component list
|
||||
* @param groupsSize maximum size per array
|
||||
* @return a 2D array with components split into groups
|
||||
*/
|
||||
private static @NotNull Component[][] splitComponentsIntoGroups(@NotNull List<Component> components, int groupsSize) {
|
||||
int groupCount = (int) Math.ceil((double) components.size() / (double) groupsSize);
|
||||
|
||||
Component[][] splitGroups = new Component[groupCount][groupsSize];
|
||||
|
||||
int groupsFinished = 0;
|
||||
|
||||
while (groupsFinished < groupCount) {
|
||||
//Fill group with members
|
||||
for(int i = 0; i < groupsSize; i++) {
|
||||
int indexOfPotentialMember = i + (groupsFinished * 3); //Groups don't always fill all members neatly
|
||||
|
||||
//Some groups won't have entirely non-null elements
|
||||
if(indexOfPotentialMember > components.size()-1) {
|
||||
break;
|
||||
}
|
||||
|
||||
Component potentialMember = components.get(indexOfPotentialMember);
|
||||
|
||||
//Make sure the potential member exists because of rounding
|
||||
if(potentialMember != null) {
|
||||
splitGroups[groupsFinished][i] = potentialMember;
|
||||
}
|
||||
}
|
||||
|
||||
//Another group is finished
|
||||
groupsFinished++;
|
||||
}
|
||||
|
||||
return splitGroups;
|
||||
}
|
||||
|
||||
|
||||
// public static void sendPlayerSubSkillList(Player player, List<Component> textComponents)
|
||||
// {
|
||||
// TextComponent emptySpace = Component.space();
|
||||
//
|
||||
// AtomicReference<Component> messageToSend = new AtomicReference<>();
|
||||
// int newLineCount = 0; //Hacky solution to wordwrap problems
|
||||
//
|
||||
// final Audience audience = mcMMO.getAudiences().player(player);
|
||||
// for (Component textComponent : textComponents) {
|
||||
// //Don't send more than 3 subskills per line to avoid MOST wordwrap problems
|
||||
// if(newLineCount > 2)
|
||||
// {
|
||||
// Component toSend = messageToSend.get();
|
||||
// if (toSend != null) {
|
||||
// audience.sendMessage(Identity.nil(), toSend.append(emptySpace));
|
||||
// }
|
||||
//
|
||||
// messageToSend.set(null);
|
||||
// newLineCount = 0;
|
||||
// }
|
||||
// //Style the skills into @links
|
||||
// final String originalTxt = textComponent instanceof TextComponent ? ((TextComponent) textComponent).content() : "";
|
||||
//
|
||||
// TextComponent.Builder stylizedText = Component.text().content(LocaleLoader.getString("JSON.Hover.AtSymbolSkills"));
|
||||
// addChild(stylizedText, originalTxt);
|
||||
//
|
||||
// if(textComponent.hoverEvent() != null)
|
||||
// stylizedText.hoverEvent(textComponent.hoverEvent());
|
||||
//
|
||||
// if(textComponent.clickEvent() != null)
|
||||
// stylizedText.clickEvent(textComponent.clickEvent());
|
||||
//
|
||||
// messageToSend.set(stylizedText.build().append(emptySpace));
|
||||
//
|
||||
// newLineCount++;
|
||||
// }
|
||||
//
|
||||
// Component toSend = messageToSend.get();
|
||||
// if (toSend != null) {
|
||||
// audience.sendMessage(Identity.nil(), toSend.append(emptySpace));
|
||||
// }
|
||||
// }
|
||||
|
||||
private static Component getWebLinkTextComponent(McMMOWebLinks webLinks)
|
||||
{
|
||||
TextComponent.Builder webTextComponent;
|
||||
@ -249,55 +143,44 @@ public class TextComponentFactory {
|
||||
{
|
||||
case WEBSITE:
|
||||
webTextComponent = Component.text().content(LocaleLoader.getString("JSON.Hover.AtSymbolURL"));
|
||||
addChild(webTextComponent, "Web");
|
||||
TextUtils.addChildWebComponent(webTextComponent, "Web");
|
||||
webTextComponent.clickEvent(getUrlClickEvent(McMMOUrl.urlWebsite));
|
||||
break;
|
||||
case SPIGOT:
|
||||
webTextComponent = Component.text().content(LocaleLoader.getString("JSON.Hover.AtSymbolURL"));
|
||||
addChild(webTextComponent, "Spigot");
|
||||
TextUtils.addChildWebComponent(webTextComponent, "Spigot");
|
||||
webTextComponent.clickEvent(getUrlClickEvent(McMMOUrl.urlSpigot));
|
||||
break;
|
||||
case DISCORD:
|
||||
webTextComponent = Component.text().content(LocaleLoader.getString("JSON.Hover.AtSymbolURL"));
|
||||
addChild(webTextComponent, "Discord");
|
||||
TextUtils.addChildWebComponent(webTextComponent, "Discord");
|
||||
webTextComponent.clickEvent(getUrlClickEvent(McMMOUrl.urlDiscord));
|
||||
break;
|
||||
case PATREON:
|
||||
webTextComponent = Component.text().content(LocaleLoader.getString("JSON.Hover.AtSymbolURL"));
|
||||
addChild(webTextComponent, "Patreon");
|
||||
TextUtils.addChildWebComponent(webTextComponent, "Patreon");
|
||||
webTextComponent.clickEvent(getUrlClickEvent(McMMOUrl.urlPatreon));
|
||||
break;
|
||||
case WIKI:
|
||||
webTextComponent = Component.text().content(LocaleLoader.getString("JSON.Hover.AtSymbolURL"));
|
||||
addChild(webTextComponent, "Wiki");
|
||||
TextUtils.addChildWebComponent(webTextComponent, "Wiki");
|
||||
webTextComponent.clickEvent(getUrlClickEvent(McMMOUrl.urlWiki));
|
||||
break;
|
||||
case HELP_TRANSLATE:
|
||||
webTextComponent = Component.text().content(LocaleLoader.getString("JSON.Hover.AtSymbolURL"));
|
||||
addChild(webTextComponent, "Lang");
|
||||
TextUtils.addChildWebComponent(webTextComponent, "Lang");
|
||||
webTextComponent.clickEvent(getUrlClickEvent(McMMOUrl.urlTranslate));
|
||||
break;
|
||||
default:
|
||||
webTextComponent = Component.text().content("NOT DEFINED");
|
||||
}
|
||||
|
||||
addNewHoverComponentToTextComponent(webTextComponent, getUrlHoverEvent(webLinks));
|
||||
TextUtils.addNewHoverComponentToTextComponent(webTextComponent, getUrlHoverEvent(webLinks));
|
||||
webTextComponent.insertion(webLinks.getUrl());
|
||||
|
||||
return webTextComponent.build();
|
||||
}
|
||||
|
||||
private static void addChild(Component webTextComponent, String childName) {
|
||||
TextComponent childComponent = Component.text(childName);
|
||||
childComponent.color(NamedTextColor.BLUE);
|
||||
webTextComponent.append(childComponent);
|
||||
}
|
||||
|
||||
private static void addChild(ComponentBuilder<?, ?> webTextComponent, String childName) {
|
||||
TextComponent childComponent = Component.text(childName).color(NamedTextColor.BLUE);
|
||||
webTextComponent.append(childComponent);
|
||||
}
|
||||
|
||||
private static Component getUrlHoverEvent(McMMOWebLinks webLinks)
|
||||
{
|
||||
TextComponent.Builder componentBuilder = Component.text().content(webLinks.getNiceTitle());
|
||||
@ -367,7 +250,7 @@ public class TextComponentFactory {
|
||||
TextComponent.Builder textComponent = initNewSkillTextComponent(player, skillName, subSkillType, skillUnlocked);
|
||||
|
||||
//Hover Event
|
||||
addNewHoverComponentToTextComponent(textComponent, getSubSkillHoverComponent(player, subSkillType));
|
||||
TextUtils.addNewHoverComponentToTextComponent(textComponent, getSubSkillHoverComponent(player, subSkillType));
|
||||
|
||||
//Insertion
|
||||
textComponent.insertion(skillName);
|
||||
@ -375,10 +258,6 @@ public class TextComponentFactory {
|
||||
return textComponent.build();
|
||||
}
|
||||
|
||||
private static void addNewHoverComponentToTextComponent(TextComponent.Builder textComponent, Component baseComponent) {
|
||||
textComponent.hoverEvent(HoverEvent.showText(baseComponent));
|
||||
}
|
||||
|
||||
private static TextComponent getSubSkillTextComponent(Player player, AbstractSubSkill abstractSubSkill)
|
||||
{
|
||||
//String key = abstractSubSkill.getConfigKeyName();
|
||||
@ -392,7 +271,7 @@ public class TextComponentFactory {
|
||||
TextComponent.Builder textComponent = initNewSkillTextComponent(player, skillName, subSkillType, skillUnlocked);
|
||||
|
||||
//Hover Event
|
||||
addNewHoverComponentToTextComponent(textComponent, getSubSkillHoverComponent(player, abstractSubSkill));
|
||||
TextUtils.addNewHoverComponentToTextComponent(textComponent, getSubSkillHoverComponent(player, abstractSubSkill));
|
||||
|
||||
//Insertion
|
||||
textComponent.insertion(skillName);
|
87
src/main/java/com/gmail/nossr50/util/text/TextUtils.java
Normal file
87
src/main/java/com/gmail/nossr50/util/text/TextUtils.java
Normal file
@ -0,0 +1,87 @@
|
||||
package com.gmail.nossr50.util.text;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.ComponentBuilder;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TextUtils {
|
||||
/**
|
||||
* Makes a single component from an array of components, can optionally add prefixes and suffixes to come before and after each component
|
||||
* @param componentsArray target array
|
||||
* @return a component with optional styling built from an array
|
||||
*/
|
||||
static @NotNull Component fromArray(@NotNull Component[] componentsArray, @Nullable Component prefixComponent, @Nullable Component suffixComponent) {
|
||||
TextComponent.Builder componentBuilder = Component.text();
|
||||
|
||||
for(Component component : componentsArray) {
|
||||
if(component == null) //Individual elements can be null
|
||||
continue;
|
||||
|
||||
if(prefixComponent != null)
|
||||
componentBuilder.append(prefixComponent);
|
||||
|
||||
componentBuilder.append(component);
|
||||
|
||||
if(suffixComponent != null)
|
||||
componentBuilder.append(suffixComponent);
|
||||
|
||||
}
|
||||
|
||||
return componentBuilder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a list of components and splits them into arrays each with a maximum element limit
|
||||
* Individual elements in [][X] may be null
|
||||
*
|
||||
* @param components target component list
|
||||
* @param groupsSize maximum size per array
|
||||
* @return a 2D array with components split into groups
|
||||
*/
|
||||
static @NotNull Component[][] splitComponentsIntoGroups(@NotNull List<Component> components, int groupsSize) {
|
||||
int groupCount = (int) Math.ceil((double) components.size() / (double) groupsSize);
|
||||
|
||||
Component[][] splitGroups = new Component[groupCount][groupsSize];
|
||||
|
||||
int groupsFinished = 0;
|
||||
|
||||
while (groupsFinished < groupCount) {
|
||||
//Fill group with members
|
||||
for(int i = 0; i < groupsSize; i++) {
|
||||
int indexOfPotentialMember = i + (groupsFinished * 3); //Groups don't always fill all members neatly
|
||||
|
||||
//Some groups won't have entirely non-null elements
|
||||
if(indexOfPotentialMember > components.size()-1) {
|
||||
break;
|
||||
}
|
||||
|
||||
Component potentialMember = components.get(indexOfPotentialMember);
|
||||
|
||||
//Make sure the potential member exists because of rounding
|
||||
if(potentialMember != null) {
|
||||
splitGroups[groupsFinished][i] = potentialMember;
|
||||
}
|
||||
}
|
||||
|
||||
//Another group is finished
|
||||
groupsFinished++;
|
||||
}
|
||||
|
||||
return splitGroups;
|
||||
}
|
||||
|
||||
static void addChildWebComponent(@NotNull ComponentBuilder<?, ?> webTextComponent, @NotNull String childName) {
|
||||
TextComponent childComponent = Component.text(childName).color(NamedTextColor.BLUE);
|
||||
webTextComponent.append(childComponent);
|
||||
}
|
||||
|
||||
static void addNewHoverComponentToTextComponent(@NotNull TextComponent.Builder textComponent, @NotNull Component baseComponent) {
|
||||
textComponent.hoverEvent(HoverEvent.showText(baseComponent));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user