mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 06:36:45 +01:00
Static Abuse Removal - TextComponentFactory
This commit is contained in:
parent
5ec59536c7
commit
bc183cd4f9
@ -90,7 +90,7 @@ public class AcrobaticsCommand extends SkillCommand {
|
||||
protected List<TextComponent> getTextComponents(Player player) {
|
||||
List<TextComponent> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.ACROBATICS);
|
||||
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.ACROBATICS);
|
||||
|
||||
return textComponents;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@
|
||||
// protected List<TextComponent> getTextComponents(Player player) {
|
||||
// List<TextComponent> textComponents = new ArrayList<>();
|
||||
//
|
||||
// TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.ALCHEMY);
|
||||
// pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.ALCHEMY);
|
||||
//
|
||||
// return textComponents;
|
||||
// }
|
||||
|
@ -86,7 +86,7 @@ public class ArcheryCommand extends SkillCommand {
|
||||
protected List<TextComponent> getTextComponents(Player player) {
|
||||
List<TextComponent> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.ARCHERY);
|
||||
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.ARCHERY);
|
||||
|
||||
return textComponents;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ public class AxesCommand extends SkillCommand {
|
||||
protected List<TextComponent> getTextComponents(Player player) {
|
||||
List<TextComponent> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.AXES);
|
||||
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.AXES);
|
||||
|
||||
return textComponents;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class ExcavationCommand extends SkillCommand {
|
||||
protected List<TextComponent> getTextComponents(Player player) {
|
||||
List<TextComponent> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.EXCAVATION);
|
||||
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.EXCAVATION);
|
||||
|
||||
return textComponents;
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ public class FishingCommand extends SkillCommand {
|
||||
protected List<TextComponent> getTextComponents(Player player) {
|
||||
List<TextComponent> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.FISHING);
|
||||
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.FISHING);
|
||||
|
||||
return textComponents;
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ public class HerbalismCommand extends SkillCommand {
|
||||
protected List<TextComponent> getTextComponents(Player player) {
|
||||
List<TextComponent> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.HERBALISM);
|
||||
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.HERBALISM);
|
||||
|
||||
return textComponents;
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ public class MiningCommand extends SkillCommand {
|
||||
protected List<TextComponent> getTextComponents(Player player) {
|
||||
List<TextComponent> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.MINING);
|
||||
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.MINING);
|
||||
|
||||
return textComponents;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public class MmoInfoCommand implements TabExecutor {
|
||||
if (abstractSubSkill != null) {
|
||||
/* New System Skills are programmable */
|
||||
abstractSubSkill.printInfo(player);
|
||||
//TextComponentFactory.sendPlayerUrlHeader(player);
|
||||
//pluginRef.getTextComponentFactory().sendPlayerUrlHeader(player);
|
||||
} else {
|
||||
/*
|
||||
* Skill is only in the old system
|
||||
@ -95,6 +95,6 @@ public class MmoInfoCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
//Send Player Wiki Link
|
||||
TextComponentFactory.sendPlayerSubSkillWikiLink(player, subSkillName);
|
||||
pluginRef.getTextComponentFactory().sendPlayerSubSkillWikiLink(player, subSkillName);
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public class RepairCommand extends SkillCommand {
|
||||
protected List<TextComponent> getTextComponents(Player player) {
|
||||
List<TextComponent> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.REPAIR);
|
||||
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.REPAIR);
|
||||
|
||||
return textComponents;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class SalvageCommand extends SkillCommand {
|
||||
protected List<TextComponent> getTextComponents(Player player) {
|
||||
List<TextComponent> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.SALVAGE);
|
||||
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.SALVAGE);
|
||||
|
||||
return textComponents;
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
|
||||
//Send JSON text components
|
||||
|
||||
TextComponentFactory.sendPlayerSubSkillList(player, subskillTextComponents);
|
||||
pluginRef.getTextComponentFactory().sendPlayerSubSkillList(player, subskillTextComponents);
|
||||
|
||||
/*for(TextComponent tc : subskillTextComponents)
|
||||
{
|
||||
@ -109,7 +109,7 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
//Link Header
|
||||
if (pluginRef.getConfigManager().getConfigAds().isShowWebsiteLinks()) {
|
||||
player.sendMessage(pluginRef.getLocaleManager().getString("Overhaul.mcMMO.Header"));
|
||||
TextComponentFactory.sendPlayerUrlHeader(player);
|
||||
pluginRef.getTextComponentFactory().sendPlayerUrlHeader(player);
|
||||
}
|
||||
|
||||
|
||||
|
@ -89,7 +89,7 @@ public class SmeltingCommand extends SkillCommand {
|
||||
protected List<TextComponent> getTextComponents(Player player) {
|
||||
List<TextComponent> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.SMELTING);
|
||||
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.SMELTING);
|
||||
|
||||
return textComponents;
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ public class SwordsCommand extends SkillCommand {
|
||||
protected List<TextComponent> getTextComponents(Player player) {
|
||||
List<TextComponent> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.SWORDS);
|
||||
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.SWORDS);
|
||||
|
||||
return textComponents;
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ public class TamingCommand extends SkillCommand {
|
||||
protected List<TextComponent> getTextComponents(Player player) {
|
||||
List<TextComponent> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, this.skill);
|
||||
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, this.skill);
|
||||
|
||||
return textComponents;
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ public class UnarmedCommand extends SkillCommand {
|
||||
protected List<TextComponent> getTextComponents(Player player) {
|
||||
List<TextComponent> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.UNARMED);
|
||||
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.UNARMED);
|
||||
|
||||
return textComponents;
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public class WoodcuttingCommand extends SkillCommand {
|
||||
protected List<TextComponent> getTextComponents(Player player) {
|
||||
List<TextComponent> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.WOODCUTTING);
|
||||
pluginRef.getTextComponentFactory().getSubSkillTextComponents(player, textComponents, PrimarySkillType.WOODCUTTING);
|
||||
|
||||
return textComponents;
|
||||
}
|
||||
|
@ -18,20 +18,20 @@ public enum McMMOWebLinks {
|
||||
return StringUtils.getCapitalized(toString());
|
||||
}
|
||||
|
||||
public String getLocaleDescription() {
|
||||
public String getLocaleKey() {
|
||||
switch (this) {
|
||||
case WEBSITE:
|
||||
return pluginRef.getLocaleManager().getString("JSON.URL.Website");
|
||||
return "JSON.URL.Website";
|
||||
case DISCORD:
|
||||
return pluginRef.getLocaleManager().getString("JSON.URL.Discord");
|
||||
return "JSON.URL.Discord";
|
||||
case PATREON:
|
||||
return pluginRef.getLocaleManager().getString("JSON.URL.Patreon");
|
||||
return "JSON.URL.Patreon";
|
||||
case HELP_TRANSLATE:
|
||||
return pluginRef.getLocaleManager().getString("JSON.URL.Translation");
|
||||
return "JSON.URL.Translation";
|
||||
case SPIGOT:
|
||||
return pluginRef.getLocaleManager().getString("JSON.URL.Spigot");
|
||||
return "JSON.URL.Spigot";
|
||||
case WIKI:
|
||||
return pluginRef.getLocaleManager().getString("JSON.URL.Wiki");
|
||||
return "JSON.URL.Wiki";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public abstract class AbstractSubSkill implements SubSkill, Interaction, Rank, S
|
||||
public void printInfo(Player player) {
|
||||
/* DEFAULT SETTINGS PRINT THE BARE MINIMUM */
|
||||
|
||||
//TextComponentFactory.sendPlayerUrlHeader(player);
|
||||
//pluginRef.getTextComponentFactory().sendPlayerUrlHeader(player);
|
||||
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.Header"));
|
||||
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.SubSkillHeader", getConfigKeyName()));
|
||||
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.DetailsHeader"));
|
||||
|
@ -73,30 +73,6 @@ public class BlockListener implements Listener {
|
||||
event.getBlock().removeMetadata(MetadataConstants.BONUS_DROPS_METAKEY, pluginRef);
|
||||
}
|
||||
|
||||
/*@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockDropItemEvent(BlockDropItemEvent event)
|
||||
{
|
||||
for(Item item : event.getItems())
|
||||
{
|
||||
ItemStack is = new ItemStack(item.getItemStack());
|
||||
|
||||
if(event.getBlock().getMetadata(mcMMO.doubleDrops).size() > 0)
|
||||
{
|
||||
List<MetadataValue> metadataValue = event.getBlock().getMetadata(mcMMO.doubleDrops);
|
||||
|
||||
BonusDrops bonusDrops = (BonusDrops) metadataValue.get(0);
|
||||
Collection<ItemStack> potentialDrops = (Collection<ItemStack>) bonusDrops.value();
|
||||
>>>>>>> 2746bac86ac8b201960ac47bc19eac4b84d790a0
|
||||
|
||||
for (int i = 0; i < bonusCount; i++) {
|
||||
event.getBlock().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is);
|
||||
}
|
||||
|
||||
event.getBlock().removeMetadata(MetadataConstants.BONUS_DROPS_METAKEY, plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor BlockPistonExtend events.
|
||||
*
|
||||
|
@ -41,16 +41,17 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
|
||||
public class EntityListener implements Listener {
|
||||
private final mcMMO plugin;
|
||||
private final mcMMO pluginRef;
|
||||
|
||||
public EntityListener(final mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
public EntityListener(final mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onEntityTransform(EntityTransformEvent event) {
|
||||
//Transfer metadata keys from mob-spawned mobs to new mobs
|
||||
if (event.getEntity().getMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY) != null || event.getEntity().getMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY).size() >= 1) {
|
||||
if (event.getEntity().hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY)
|
||||
|| event.getEntity().getMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY).size() >= 1) {
|
||||
for (Entity entity : event.getTransformedEntities()) {
|
||||
entity.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, MetadataConstants.metadataValue);
|
||||
}
|
||||
@ -69,7 +70,8 @@ public class EntityListener implements Listener {
|
||||
|
||||
//Prevent entities from giving XP if they target endermite
|
||||
if (event.getTarget() instanceof Endermite) {
|
||||
if (event.getEntity().getMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY) == null || event.getEntity().getMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY).size() <= 0)
|
||||
if (event.getEntity().hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY)
|
||||
|| event.getEntity().getMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY).size() <= 0)
|
||||
event.getEntity().setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, MetadataConstants.metadataValue);
|
||||
}
|
||||
}
|
||||
@ -85,7 +87,7 @@ public class EntityListener implements Listener {
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if (WorldGuardUtils.isWorldGuardLoaded()) {
|
||||
if (!plugin.getWorldGuardManager().hasMainFlag(player))
|
||||
if (!pluginRef.getWorldGuardManager().hasMainFlag(player))
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -104,10 +106,10 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
projectile.setMetadata(MetadataConstants.BOW_FORCE_METAKEY,
|
||||
new FixedMetadataValue(plugin,
|
||||
new FixedMetadataValue(pluginRef,
|
||||
Math.min(event.getForce()
|
||||
* pluginRef.getConfigManager().getConfigExperience().getExperienceArchery().getForceMultiplier(), 1.0)));
|
||||
projectile.setMetadata(MetadataConstants.ARROW_DISTANCE_METAKEY, new FixedMetadataValue(plugin, projectile.getLocation()));
|
||||
projectile.setMetadata(MetadataConstants.ARROW_DISTANCE_METAKEY, new FixedMetadataValue(pluginRef, projectile.getLocation()));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
@ -122,7 +124,7 @@ public class EntityListener implements Listener {
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if (WorldGuardUtils.isWorldGuardLoaded()) {
|
||||
if (!plugin.getWorldGuardManager().hasMainFlag(player))
|
||||
if (!pluginRef.getWorldGuardManager().hasMainFlag(player))
|
||||
return;
|
||||
}
|
||||
|
||||
@ -131,8 +133,8 @@ public class EntityListener implements Listener {
|
||||
if(!(projectile instanceof Arrow))
|
||||
return;
|
||||
|
||||
projectile.setMetadata(MetadataConstants.BOW_FORCE_METAKEY, new FixedMetadataValue(plugin, 1.0));
|
||||
projectile.setMetadata(MetadataConstants.ARROW_DISTANCE_METAKEY, new FixedMetadataValue(plugin, projectile.getLocation()));
|
||||
projectile.setMetadata(MetadataConstants.BOW_FORCE_METAKEY, new FixedMetadataValue(pluginRef, 1.0));
|
||||
projectile.setMetadata(MetadataConstants.ARROW_DISTANCE_METAKEY, new FixedMetadataValue(pluginRef, projectile.getLocation()));
|
||||
|
||||
for(Enchantment enchantment : player.getInventory().getItemInMainHand().getEnchantments().keySet()) {
|
||||
if(enchantment.getName().equalsIgnoreCase("piercing"))
|
||||
@ -240,7 +242,7 @@ public class EntityListener implements Listener {
|
||||
Entity defender = event.getEntity();
|
||||
|
||||
if (defender.getMetadata(MetadataConstants.CUSTOM_DAMAGE_METAKEY).size() > 0) {
|
||||
defender.removeMetadata(MetadataConstants.CUSTOM_DAMAGE_METAKEY, plugin);
|
||||
defender.removeMetadata(MetadataConstants.CUSTOM_DAMAGE_METAKEY, pluginRef);
|
||||
|
||||
if (defender instanceof Player) {
|
||||
LivingEntity defLive = (LivingEntity) defender;
|
||||
@ -287,7 +289,7 @@ public class EntityListener implements Listener {
|
||||
{
|
||||
if(attacker instanceof Player) {
|
||||
|
||||
if(!plugin.getWorldGuardManager().hasMainFlag((Player) attacker))
|
||||
if(!pluginRef.getWorldGuardManager().hasMainFlag((Player) attacker))
|
||||
return;
|
||||
|
||||
} else if(attacker instanceof Projectile) {
|
||||
@ -295,7 +297,7 @@ public class EntityListener implements Listener {
|
||||
Projectile projectile = (Projectile) attacker;
|
||||
|
||||
if(projectile.getShooter() instanceof Player) {
|
||||
if(!plugin.getWorldGuardManager().hasMainFlag((Player) projectile.getShooter()))
|
||||
if(!pluginRef.getWorldGuardManager().hasMainFlag((Player) projectile.getShooter()))
|
||||
return;
|
||||
}
|
||||
|
||||
@ -406,7 +408,7 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
CombatUtils.processCombatAttack(event, attacker, target);
|
||||
CombatUtils.handleHealthbars(attacker, target, event.getFinalDamage(), plugin);
|
||||
CombatUtils.handleHealthbars(attacker, target, event.getFinalDamage(), pluginRef);
|
||||
|
||||
/**
|
||||
* This sets entity names back to whatever they are supposed to be
|
||||
@ -459,7 +461,7 @@ public class EntityListener implements Listener {
|
||||
Player player = (Player) event.getEntity();
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if (WorldGuardUtils.isWorldGuardLoaded()) {
|
||||
if (!plugin.getWorldGuardManager().hasMainFlag(player))
|
||||
if (!pluginRef.getWorldGuardManager().hasMainFlag(player))
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -468,7 +470,7 @@ public class EntityListener implements Listener {
|
||||
* Process Registered Interactions
|
||||
*/
|
||||
|
||||
InteractionManager.processEvent(event, plugin, InteractType.ON_ENTITY_DAMAGE);
|
||||
InteractionManager.processEvent(event, pluginRef, InteractType.ON_ENTITY_DAMAGE);
|
||||
|
||||
/*
|
||||
* Old code
|
||||
@ -537,7 +539,7 @@ public class EntityListener implements Listener {
|
||||
Player player = (Player) owner;
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if (WorldGuardUtils.isWorldGuardLoaded()) {
|
||||
if (!plugin.getWorldGuardManager().hasMainFlag(player))
|
||||
if (!pluginRef.getWorldGuardManager().hasMainFlag(player))
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -630,16 +632,16 @@ public class EntityListener implements Listener {
|
||||
|
||||
if (entity.hasMetadata(MetadataConstants.CUSTOM_NAME_METAKEY)) {
|
||||
entity.setCustomName(entity.getMetadata(MetadataConstants.CUSTOM_NAME_METAKEY).get(0).asString());
|
||||
entity.removeMetadata(MetadataConstants.CUSTOM_NAME_METAKEY, plugin);
|
||||
entity.removeMetadata(MetadataConstants.CUSTOM_NAME_METAKEY, pluginRef);
|
||||
}
|
||||
|
||||
if (entity.hasMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY)) {
|
||||
entity.setCustomNameVisible(entity.getMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY).get(0).asBoolean());
|
||||
entity.removeMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY, plugin);
|
||||
entity.removeMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY, pluginRef);
|
||||
}
|
||||
|
||||
if (entity.hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY)) {
|
||||
entity.removeMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, plugin);
|
||||
entity.removeMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, pluginRef);
|
||||
}
|
||||
}
|
||||
|
||||
@ -718,7 +720,7 @@ public class EntityListener implements Listener {
|
||||
|
||||
// We can make this assumption because we (should) be the only ones
|
||||
// using this exact metadata
|
||||
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(MetadataConstants.TNT_TRACKING_METAKEY).get(0).asString());
|
||||
Player player = pluginRef.getServer().getPlayerExact(entity.getMetadata(MetadataConstants.TNT_TRACKING_METAKEY).get(0).asString());
|
||||
|
||||
if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
|
||||
return;
|
||||
@ -731,7 +733,7 @@ public class EntityListener implements Listener {
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if (WorldGuardUtils.isWorldGuardLoaded()) {
|
||||
if (!plugin.getWorldGuardManager().hasMainFlag(player))
|
||||
if (!pluginRef.getWorldGuardManager().hasMainFlag(player))
|
||||
return;
|
||||
}
|
||||
|
||||
@ -761,7 +763,7 @@ public class EntityListener implements Listener {
|
||||
|
||||
// We can make this assumption because we (should) be the only ones
|
||||
// using this exact metadata
|
||||
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(MetadataConstants.TNT_TRACKING_METAKEY).get(0).asString());
|
||||
Player player = pluginRef.getServer().getPlayerExact(entity.getMetadata(MetadataConstants.TNT_TRACKING_METAKEY).get(0).asString());
|
||||
|
||||
if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
|
||||
return;
|
||||
@ -769,7 +771,7 @@ public class EntityListener implements Listener {
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if (WorldGuardUtils.isWorldGuardLoaded()) {
|
||||
if (!plugin.getWorldGuardManager().hasMainFlag(player))
|
||||
if (!pluginRef.getWorldGuardManager().hasMainFlag(player))
|
||||
return;
|
||||
}
|
||||
|
||||
@ -832,7 +834,7 @@ public class EntityListener implements Listener {
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if (WorldGuardUtils.isWorldGuardLoaded()) {
|
||||
if (!plugin.getWorldGuardManager().hasMainFlag(player))
|
||||
if (!pluginRef.getWorldGuardManager().hasMainFlag(player))
|
||||
return;
|
||||
}
|
||||
|
||||
@ -933,7 +935,7 @@ public class EntityListener implements Listener {
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if (WorldGuardUtils.isWorldGuardLoaded()) {
|
||||
if (!plugin.getWorldGuardManager().hasMainFlag(player))
|
||||
if (!pluginRef.getWorldGuardManager().hasMainFlag(player))
|
||||
return;
|
||||
}
|
||||
|
||||
@ -979,7 +981,7 @@ public class EntityListener implements Listener {
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if (WorldGuardUtils.isWorldGuardLoaded()) {
|
||||
if (!plugin.getWorldGuardManager().hasMainFlag(player))
|
||||
if (!pluginRef.getWorldGuardManager().hasMainFlag(player))
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -28,10 +28,10 @@ import org.bukkit.metadata.MetadataValue;
|
||||
import java.util.List;
|
||||
|
||||
public class InventoryListener implements Listener {
|
||||
private final mcMMO plugin;
|
||||
private final mcMMO pluginRef;
|
||||
|
||||
public InventoryListener(final mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
public InventoryListener(final mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
@ -79,7 +79,7 @@ public class InventoryListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
furnaceBlock.removeMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY, plugin);
|
||||
furnaceBlock.removeMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY, pluginRef);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@ -100,7 +100,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if (WorldGuardUtils.isWorldGuardLoaded()) {
|
||||
if (!plugin.getWorldGuardManager().hasMainFlag(player))
|
||||
if (!pluginRef.getWorldGuardManager().hasMainFlag(player))
|
||||
return;
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if (WorldGuardUtils.isWorldGuardLoaded()) {
|
||||
if (!plugin.getWorldGuardManager().hasMainFlag(player))
|
||||
if (!pluginRef.getWorldGuardManager().hasMainFlag(player))
|
||||
return;
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if (WorldGuardUtils.isWorldGuardLoaded()) {
|
||||
if (!plugin.getWorldGuardManager().hasMainFlag(player))
|
||||
if (!pluginRef.getWorldGuardManager().hasMainFlag(player))
|
||||
return;
|
||||
}
|
||||
|
||||
@ -232,7 +232,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if (WorldGuardUtils.isWorldGuardLoaded()) {
|
||||
if (!plugin.getWorldGuardManager().hasMainFlag(player))
|
||||
if (!pluginRef.getWorldGuardManager().hasMainFlag(player))
|
||||
return;
|
||||
}
|
||||
|
||||
@ -454,11 +454,11 @@ public class InventoryListener implements Listener {
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if (WorldGuardUtils.isWorldGuardLoaded()) {
|
||||
if (!plugin.getWorldGuardManager().hasMainFlag(player))
|
||||
if (!pluginRef.getWorldGuardManager().hasMainFlag(player))
|
||||
return;
|
||||
}
|
||||
|
||||
new PlayerUpdateInventoryTask((Player) whoClicked).runTaskLater(plugin, 0);
|
||||
new PlayerUpdateInventoryTask((Player) whoClicked).runTaskLater(pluginRef, 0);
|
||||
}
|
||||
|
||||
private Block processInventoryOpenOrCloseEvent(Inventory inventory) {
|
||||
@ -482,6 +482,6 @@ public class InventoryListener implements Listener {
|
||||
return null;
|
||||
}
|
||||
|
||||
return plugin.getServer().getPlayerExact(metadata.get(0).asString());
|
||||
return pluginRef.getServer().getPlayerExact(metadata.get(0).asString());
|
||||
}
|
||||
}
|
||||
|
@ -451,7 +451,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
|
||||
if (!drop.hasMetadata(MetadataConstants.DROPPED_ITEM_TRACKING_METAKEY) && mcMMOPlayer.inParty() && ItemUtils.isSharable(dropStack)) {
|
||||
event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer));
|
||||
event.setCancelled(mcMMOPlayer.getParty().getShareHandler().handleItemShare(drop, mcMMOPlayer));
|
||||
|
||||
SoundManager.sendSound(player, player.getLocation(), SoundType.POP);
|
||||
}
|
||||
|
@ -17,10 +17,10 @@ import org.bukkit.event.Listener;
|
||||
|
||||
public class SelfListener implements Listener {
|
||||
//Used in task scheduling and other things
|
||||
private final mcMMO plugin;
|
||||
private final mcMMO pluginRef;
|
||||
|
||||
public SelfListener(mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
public SelfListener(mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
@ -32,7 +32,7 @@ public class SelfListener implements Listener {
|
||||
for (int i = 0; i < event.getLevelsGained(); i++) {
|
||||
int previousLevelGained = event.getSkillLevel() - i;
|
||||
//Send player skill unlock notifications
|
||||
pluginRef.getUserManager().getPlayer(player).processUnlockNotifications(plugin, event.getSkill(), previousLevelGained);
|
||||
pluginRef.getUserManager().getPlayer(player).processUnlockNotifications(pluginRef, event.getSkill(), previousLevelGained);
|
||||
}
|
||||
|
||||
//Reset the delay timer
|
||||
@ -70,7 +70,7 @@ public class SelfListener implements Listener {
|
||||
event.getXpGainReason() == XPGainReason.SHARED_PVE ||
|
||||
event.getXpGainReason() == XPGainReason.SHARED_PVP) {
|
||||
if (WorldGuardUtils.isWorldGuardLoaded()) {
|
||||
if (!plugin.getWorldGuardManager().hasXPFlag(player)) {
|
||||
if (!pluginRef.getWorldGuardManager().hasXPFlag(player)) {
|
||||
event.setRawXpGained(0);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -16,10 +16,10 @@ import org.bukkit.event.world.WorldUnloadEvent;
|
||||
import java.io.File;
|
||||
|
||||
public class WorldListener implements Listener {
|
||||
private final mcMMO plugin;
|
||||
private final mcMMO pluginRef;
|
||||
|
||||
public WorldListener(final mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
public WorldListener(final mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,11 +55,11 @@ public class WorldListener implements Listener {
|
||||
|
||||
World world = event.getWorld();
|
||||
|
||||
if (!new File(world.getWorldFolder(), "mcmmo_data").exists() || plugin == null) {
|
||||
if (!new File(world.getWorldFolder(), "mcmmo_data").exists() || pluginRef == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getLogger().info("Converting block storage for " + world.getName() + " to a new format.");
|
||||
pluginRef.getLogger().info("Converting block storage for " + world.getName() + " to a new format.");
|
||||
|
||||
//new BlockStoreConversionMain(world).run();
|
||||
}
|
||||
|
@ -60,7 +60,6 @@ public class mcMMO extends JavaPlugin {
|
||||
private ChunkManager placeStore;
|
||||
private ConfigManager configManager;
|
||||
private DynamicSettingsManager dynamicSettingsManager;
|
||||
private DatabaseManagerFactory databaseManagerFactory;
|
||||
private DatabaseManager databaseManager;
|
||||
private FormulaManager formulaManager;
|
||||
private MaterialMapStore materialMapStore;
|
||||
@ -78,7 +77,9 @@ public class mcMMO extends JavaPlugin {
|
||||
private ScoreboardManager scoreboardManager;
|
||||
|
||||
/* Not-Managers but my naming scheme sucks */
|
||||
private DatabaseManagerFactory databaseManagerFactory;
|
||||
private CommandTools commandTools;
|
||||
private TextComponentFactory textComponentFactory;
|
||||
|
||||
/* File Paths */
|
||||
private String mainDirectory;
|
||||
@ -114,6 +115,9 @@ public class mcMMO extends JavaPlugin {
|
||||
loadConfigFiles();
|
||||
registerDynamicSettings(); //Do this after configs are loaded
|
||||
|
||||
//Init TextComponentFactory
|
||||
textComponentFactory = new TextComponentFactory(this);
|
||||
|
||||
if (healthBarPluginEnabled) {
|
||||
getLogger().info("HealthBar plugin found, mcMMO's healthbars are automatically disabled.");
|
||||
}
|
||||
@ -200,7 +204,7 @@ public class mcMMO extends JavaPlugin {
|
||||
playerLevelUtils = new PlayerLevelUtils();
|
||||
|
||||
//Init Notification Manager
|
||||
notificationManager = new NotificationManager();
|
||||
notificationManager = new NotificationManager(this);
|
||||
|
||||
//Init Chat Manager
|
||||
chatManager = new ChatManager(this);
|
||||
@ -674,4 +678,8 @@ public class mcMMO extends JavaPlugin {
|
||||
public ScoreboardManager getScoreboardManager() {
|
||||
return scoreboardManager;
|
||||
}
|
||||
|
||||
public TextComponentFactory getTextComponentFactory() {
|
||||
return textComponentFactory;
|
||||
}
|
||||
}
|
||||
|
@ -462,7 +462,7 @@ public final class PartyManager {
|
||||
public void createParty(McMMOPlayer mcMMOPlayer, String partyName, String password) {
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
Party party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName.replace(".", ""), password);
|
||||
Party party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName.replace(".", ""), password, pluginRef);
|
||||
|
||||
if (password != null) {
|
||||
player.sendMessage(pluginRef.getLocaleManager().getString("Party.Password.Set", password));
|
||||
|
@ -6,6 +6,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
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.mcMMO;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
@ -18,7 +19,14 @@ import java.util.List;
|
||||
/**
|
||||
* This class handles many of the JSON components that mcMMO makes and uses
|
||||
*/
|
||||
//TODO: Needs to be rewritten
|
||||
public class TextComponentFactory {
|
||||
|
||||
private mcMMO pluginRef;
|
||||
|
||||
public TextComponentFactory(mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a text component using strings from a locale and supports passing an undefined number of variables to the LocaleManager
|
||||
@ -27,29 +35,29 @@ public class TextComponentFactory {
|
||||
* @param values vars to be passed to the locale loader
|
||||
* @return
|
||||
*/
|
||||
public static TextComponent getNotificationMultipleValues(String localeKey, String... values)
|
||||
public TextComponent getNotificationMultipleValues(String localeKey, String... values)
|
||||
{
|
||||
String preColoredString = pluginRef.getLocaleManager().getString(localeKey, (Object[]) values);
|
||||
TextComponent msg = new TextComponent(preColoredString);
|
||||
return new TextComponent(msg);
|
||||
}
|
||||
|
||||
public static TextComponent getNotificationTextComponentFromLocale(String localeKey)
|
||||
public TextComponent getNotificationTextComponentFromLocale(String localeKey)
|
||||
{
|
||||
return getNotificationTextComponent(pluginRef.getLocaleManager().getString(localeKey));
|
||||
}
|
||||
|
||||
public static TextComponent getNotificationLevelUpTextComponent(PrimarySkillType skill, int levelsGained, int currentLevel) {
|
||||
public TextComponent getNotificationLevelUpTextComponent(PrimarySkillType skill, int levelsGained, int currentLevel) {
|
||||
TextComponent textComponent = new TextComponent(pluginRef.getLocaleManager().getString("Overhaul.Levelup", pluginRef.getLocaleManager().getString("Overhaul.Name." + StringUtils.getCapitalized(skill.toString())), levelsGained, currentLevel));
|
||||
return textComponent;
|
||||
}
|
||||
|
||||
private static TextComponent getNotificationTextComponent(String text) {
|
||||
private TextComponent getNotificationTextComponent(String text) {
|
||||
//textComponent.setColor(getNotificationColor(notificationType));
|
||||
return new TextComponent(text);
|
||||
}
|
||||
|
||||
public static void sendPlayerSubSkillWikiLink(Player player, String subskillformatted) {
|
||||
public void sendPlayerSubSkillWikiLink(Player player, String subskillformatted) {
|
||||
if (!pluginRef.getConfigManager().getConfigAds().isShowWebsiteLinks())
|
||||
return;
|
||||
|
||||
@ -69,7 +77,7 @@ public class TextComponentFactory {
|
||||
spigotPlayer.sendMessage(ChatMessageType.SYSTEM, wikiLinkComponent);
|
||||
}
|
||||
|
||||
public static void sendPlayerUrlHeader(Player player) {
|
||||
public void sendPlayerUrlHeader(Player player) {
|
||||
Player.Spigot spigotPlayer = player.spigot();
|
||||
|
||||
TextComponent prefix = new TextComponent(pluginRef.getLocaleManager().getString("Overhaul.mcMMO.Url.Wrap.Prefix") + " ");
|
||||
@ -112,7 +120,7 @@ public class TextComponentFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendPlayerSubSkillList(Player player, List<TextComponent> textComponents) {
|
||||
public void sendPlayerSubSkillList(Player player, List<TextComponent> textComponents) {
|
||||
TextComponent emptySpace = new TextComponent(" ");
|
||||
|
||||
ArrayList<BaseComponent> bulkMessage = new ArrayList<>();
|
||||
@ -155,7 +163,7 @@ public class TextComponentFactory {
|
||||
player.spigot().sendMessage(bulkArray);
|
||||
}
|
||||
|
||||
private static TextComponent getWebLinkTextComponent(McMMOWebLinks webLinks) {
|
||||
private TextComponent getWebLinkTextComponent(McMMOWebLinks webLinks) {
|
||||
TextComponent webTextComponent;
|
||||
|
||||
switch (webLinks) {
|
||||
@ -199,51 +207,51 @@ public class TextComponentFactory {
|
||||
return webTextComponent;
|
||||
}
|
||||
|
||||
private static void addChild(TextComponent webTextComponent, String childName) {
|
||||
private void addChild(TextComponent webTextComponent, String childName) {
|
||||
TextComponent childComponent = new TextComponent(childName);
|
||||
childComponent.setColor(ChatColor.BLUE);
|
||||
webTextComponent.addExtra(childComponent);
|
||||
}
|
||||
|
||||
private static BaseComponent[] getUrlHoverEvent(McMMOWebLinks webLinks) {
|
||||
private BaseComponent[] getUrlHoverEvent(McMMOWebLinks webLinks) {
|
||||
ComponentBuilder componentBuilder = new ComponentBuilder(webLinks.getNiceTitle());
|
||||
|
||||
switch (webLinks) {
|
||||
case WEBSITE:
|
||||
addUrlHeaderHover(webLinks, componentBuilder);
|
||||
componentBuilder.append("\n\n").italic(false);
|
||||
componentBuilder.append(webLinks.getLocaleDescription()).color(ChatColor.GREEN);
|
||||
componentBuilder.append(pluginRef.getLocaleManager().getString(webLinks.getLocaleKey())).color(ChatColor.GREEN);
|
||||
componentBuilder.append("\nDev Blogs, and information related to mcMMO can be found here").color(ChatColor.GRAY);
|
||||
break;
|
||||
case SPIGOT:
|
||||
addUrlHeaderHover(webLinks, componentBuilder);
|
||||
componentBuilder.append("\n\n").italic(false);
|
||||
componentBuilder.append(webLinks.getLocaleDescription()).color(ChatColor.GREEN);
|
||||
componentBuilder.append(pluginRef.getLocaleManager().getString(webLinks.getLocaleKey())).color(ChatColor.GREEN);
|
||||
componentBuilder.append("\nI post regularly in the discussion thread here!").color(ChatColor.GRAY);
|
||||
break;
|
||||
case PATREON:
|
||||
addUrlHeaderHover(webLinks, componentBuilder);
|
||||
componentBuilder.append("\n\n").italic(false);
|
||||
componentBuilder.append(webLinks.getLocaleDescription()).color(ChatColor.GREEN);
|
||||
componentBuilder.append(pluginRef.getLocaleManager().getString(webLinks.getLocaleKey())).color(ChatColor.GREEN);
|
||||
componentBuilder.append("\n");
|
||||
componentBuilder.append("Show support by buying me a coffee :)").italic(false).color(ChatColor.GRAY);
|
||||
break;
|
||||
case WIKI:
|
||||
addUrlHeaderHover(webLinks, componentBuilder);
|
||||
componentBuilder.append("\n\n").italic(false);
|
||||
componentBuilder.append(webLinks.getLocaleDescription()).color(ChatColor.GREEN);
|
||||
componentBuilder.append(pluginRef.getLocaleManager().getString(webLinks.getLocaleKey())).color(ChatColor.GREEN);
|
||||
componentBuilder.append("\n");
|
||||
componentBuilder.append("I'm looking for more wiki staff, contact me on our discord!").italic(false).color(ChatColor.DARK_GRAY);
|
||||
break;
|
||||
case DISCORD:
|
||||
addUrlHeaderHover(webLinks, componentBuilder);
|
||||
componentBuilder.append("\n\n").italic(false);
|
||||
componentBuilder.append(webLinks.getLocaleDescription()).color(ChatColor.GREEN);
|
||||
componentBuilder.append(pluginRef.getLocaleManager().getString(webLinks.getLocaleKey())).color(ChatColor.GREEN);
|
||||
break;
|
||||
case HELP_TRANSLATE:
|
||||
addUrlHeaderHover(webLinks, componentBuilder);
|
||||
componentBuilder.append("\n\n").italic(false);
|
||||
componentBuilder.append(webLinks.getLocaleDescription()).color(ChatColor.GREEN);
|
||||
componentBuilder.append(pluginRef.getLocaleManager().getString(webLinks.getLocaleKey())).color(ChatColor.GREEN);
|
||||
componentBuilder.append("\n");
|
||||
componentBuilder.append("You can use this website to help translate mcMMO into your language!" +
|
||||
"\nIf you want to know more contact me in discord.").italic(false).color(ChatColor.DARK_GRAY);
|
||||
@ -252,16 +260,16 @@ public class TextComponentFactory {
|
||||
return componentBuilder.create();
|
||||
}
|
||||
|
||||
private static void addUrlHeaderHover(McMMOWebLinks webLinks, ComponentBuilder componentBuilder) {
|
||||
private void addUrlHeaderHover(McMMOWebLinks webLinks, ComponentBuilder componentBuilder) {
|
||||
componentBuilder.append("\n");
|
||||
componentBuilder.append(webLinks.getUrl()).color(ChatColor.GRAY).italic(true);
|
||||
}
|
||||
|
||||
private static ClickEvent getUrlClickEvent(String url) {
|
||||
private ClickEvent getUrlClickEvent(String url) {
|
||||
return new ClickEvent(ClickEvent.Action.OPEN_URL, url);
|
||||
}
|
||||
|
||||
private static TextComponent getSubSkillTextComponent(Player player, SubSkillType subSkillType) {
|
||||
private TextComponent getSubSkillTextComponent(Player player, SubSkillType subSkillType) {
|
||||
//Get skill name
|
||||
String skillName = subSkillType.getLocaleName();
|
||||
|
||||
@ -278,11 +286,11 @@ public class TextComponentFactory {
|
||||
return textComponent;
|
||||
}
|
||||
|
||||
private static void addNewHoverComponentToTextComponent(TextComponent textComponent, BaseComponent[] baseComponent) {
|
||||
private void addNewHoverComponentToTextComponent(TextComponent textComponent, BaseComponent[] baseComponent) {
|
||||
textComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, baseComponent));
|
||||
}
|
||||
|
||||
private static TextComponent getSubSkillTextComponent(Player player, AbstractSubSkill abstractSubSkill) {
|
||||
private TextComponent getSubSkillTextComponent(Player player, AbstractSubSkill abstractSubSkill) {
|
||||
//String key = abstractSubSkill.getConfigKeyName();
|
||||
String skillName = abstractSubSkill.getNiceName();
|
||||
|
||||
@ -302,7 +310,7 @@ public class TextComponentFactory {
|
||||
return textComponent;
|
||||
}
|
||||
|
||||
private static TextComponent initNewSkillTextComponent(Player player, String skillName, SubSkillType subSkillType, boolean skillUnlocked) {
|
||||
private TextComponent initNewSkillTextComponent(Player player, String skillName, SubSkillType subSkillType, boolean skillUnlocked) {
|
||||
TextComponent textComponent;
|
||||
if (skillUnlocked) {
|
||||
if (RankUtils.getHighestRank(subSkillType) == RankUtils.getRank(player, subSkillType) && subSkillType.getNumRanks() > 1)
|
||||
@ -321,11 +329,11 @@ public class TextComponentFactory {
|
||||
return textComponent;
|
||||
}
|
||||
|
||||
private static BaseComponent[] getSubSkillHoverComponent(Player player, AbstractSubSkill abstractSubSkill) {
|
||||
private BaseComponent[] getSubSkillHoverComponent(Player player, AbstractSubSkill abstractSubSkill) {
|
||||
return getSubSkillHoverEventJSON(abstractSubSkill, player);
|
||||
}
|
||||
|
||||
private static BaseComponent[] getSubSkillHoverComponent(Player player, SubSkillType subSkillType) {
|
||||
private BaseComponent[] getSubSkillHoverComponent(Player player, SubSkillType subSkillType) {
|
||||
return getSubSkillHoverEventJSON(subSkillType, player);
|
||||
}
|
||||
|
||||
@ -336,7 +344,7 @@ public class TextComponentFactory {
|
||||
* @param player the player who owns this subskill
|
||||
* @return the hover basecomponent object for this subskill
|
||||
*/
|
||||
private static BaseComponent[] getSubSkillHoverEventJSON(AbstractSubSkill abstractSubSkill, Player player) {
|
||||
private BaseComponent[] getSubSkillHoverEventJSON(AbstractSubSkill abstractSubSkill, Player player) {
|
||||
String skillName = abstractSubSkill.getNiceName();
|
||||
|
||||
/*
|
||||
@ -388,7 +396,7 @@ public class TextComponentFactory {
|
||||
return componentBuilder.create();
|
||||
}
|
||||
|
||||
private static ComponentBuilder setupSkillComponentNameStyle(Player player, String skillName, SubSkillType subSkillType, boolean skillUnlocked) {
|
||||
private ComponentBuilder setupSkillComponentNameStyle(Player player, String skillName, SubSkillType subSkillType, boolean skillUnlocked) {
|
||||
ComponentBuilder componentBuilder;
|
||||
if (skillUnlocked) {
|
||||
if (RankUtils.getHighestRank(subSkillType) == RankUtils.getRank(player, subSkillType) && subSkillType.getNumRanks() > 1)
|
||||
@ -401,13 +409,13 @@ public class TextComponentFactory {
|
||||
return componentBuilder;
|
||||
}
|
||||
|
||||
private static ComponentBuilder getNewComponentBuilder(String skillName) {
|
||||
private ComponentBuilder getNewComponentBuilder(String skillName) {
|
||||
ComponentBuilder componentBuilder = new ComponentBuilder(skillName);
|
||||
componentBuilder.append("\n");
|
||||
return componentBuilder;
|
||||
}
|
||||
|
||||
private static void addRanked(ChatColor ccRank, ChatColor ccCurRank, ChatColor ccPossessive, ChatColor ccNumRanks, ComponentBuilder componentBuilder, int numRanks, int rank, int nextRank) {
|
||||
private void addRanked(ChatColor ccRank, ChatColor ccCurRank, ChatColor ccPossessive, ChatColor ccNumRanks, ComponentBuilder componentBuilder, int numRanks, int rank, int nextRank) {
|
||||
if (numRanks > 0) {
|
||||
//Rank: x
|
||||
componentBuilder.append(pluginRef.getLocaleManager().getString("JSON.Hover.Rank", String.valueOf(rank))).append("\n")
|
||||
@ -423,26 +431,26 @@ public class TextComponentFactory {
|
||||
}
|
||||
}
|
||||
|
||||
private static void addLocked(SubSkillType subSkillType, ChatColor ccLocked, ChatColor ccLevelRequirement, ChatColor ccLevelRequired, ComponentBuilder componentBuilder) {
|
||||
private void addLocked(SubSkillType subSkillType, ChatColor ccLocked, ChatColor ccLevelRequirement, ChatColor ccLevelRequired, ComponentBuilder componentBuilder) {
|
||||
addLocked(ccLocked, ccLevelRequirement, componentBuilder);
|
||||
componentBuilder.append(String.valueOf(RankUtils.getSubSkillUnlockLevel(subSkillType, 1))).color(ccLevelRequired);
|
||||
//componentBuilder.append("\n");
|
||||
}
|
||||
|
||||
private static void addLocked(AbstractSubSkill abstractSubSkill, ChatColor ccLocked, ChatColor ccLevelRequirement, ChatColor ccLevelRequired, ComponentBuilder componentBuilder) {
|
||||
private void addLocked(AbstractSubSkill abstractSubSkill, ChatColor ccLocked, ChatColor ccLevelRequirement, ChatColor ccLevelRequired, ComponentBuilder componentBuilder) {
|
||||
addLocked(ccLocked, ccLevelRequirement, componentBuilder);
|
||||
componentBuilder.append(String.valueOf(RankUtils.getSubSkillUnlockLevel(abstractSubSkill, 1))).color(ccLevelRequired);
|
||||
//componentBuilder.append("\n");m
|
||||
}
|
||||
|
||||
private static void addLocked(ChatColor ccLocked, ChatColor ccLevelRequirement, ComponentBuilder componentBuilder) {
|
||||
private void addLocked(ChatColor ccLocked, ChatColor ccLevelRequirement, ComponentBuilder componentBuilder) {
|
||||
componentBuilder.append(pluginRef.getLocaleManager().getString("JSON.Locked")).color(ccLocked).bold(true);
|
||||
componentBuilder.append("\n").append("\n").bold(false);
|
||||
componentBuilder.append(pluginRef.getLocaleManager().getString("JSON.LevelRequirement") + ": ").color(ccLevelRequirement);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private static BaseComponent[] getSubSkillHoverEventJSON(SubSkillType subSkillType, Player player) {
|
||||
private BaseComponent[] getSubSkillHoverEventJSON(SubSkillType subSkillType, Player player) {
|
||||
String skillName = subSkillType.getLocaleName();
|
||||
|
||||
/*
|
||||
@ -492,7 +500,7 @@ public class TextComponentFactory {
|
||||
return componentBuilder.create();
|
||||
}
|
||||
|
||||
private static void addSubSkillTypeToHoverEventJSON(AbstractSubSkill abstractSubSkill, ComponentBuilder componentBuilder) {
|
||||
private void addSubSkillTypeToHoverEventJSON(AbstractSubSkill abstractSubSkill, ComponentBuilder componentBuilder) {
|
||||
if (abstractSubSkill.isSuperAbility()) {
|
||||
componentBuilder.append(pluginRef.getLocaleManager().getString("JSON.Type.SuperAbility")).color(ChatColor.LIGHT_PURPLE);
|
||||
componentBuilder.bold(true);
|
||||
@ -507,12 +515,12 @@ public class TextComponentFactory {
|
||||
componentBuilder.append("\n");
|
||||
}
|
||||
|
||||
public static void getSubSkillTextComponents(Player player, List<TextComponent> textComponents, PrimarySkillType parentSkill) {
|
||||
public void getSubSkillTextComponents(Player player, List<TextComponent> textComponents, PrimarySkillType parentSkill) {
|
||||
for (SubSkillType subSkillType : SubSkillType.values()) {
|
||||
if (subSkillType.getParentSkill() == parentSkill) {
|
||||
if (Permissions.isSubSkillEnabled(player, subSkillType)) {
|
||||
if (!InteractionManager.hasSubSkill(subSkillType))
|
||||
textComponents.add(TextComponentFactory.getSubSkillTextComponent(player, subSkillType));
|
||||
textComponents.add(pluginRef.getTextComponentFactory().getSubSkillTextComponent(player, subSkillType));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -521,12 +529,12 @@ public class TextComponentFactory {
|
||||
for (AbstractSubSkill abstractSubSkill : InteractionManager.getSubSkillList()) {
|
||||
if (abstractSubSkill.getPrimarySkill() == parentSkill) {
|
||||
if (Permissions.isSubSkillEnabled(player, abstractSubSkill))
|
||||
textComponents.add(TextComponentFactory.getSubSkillTextComponent(player, abstractSubSkill));
|
||||
textComponents.add(pluginRef.getTextComponentFactory().getSubSkillTextComponent(player, abstractSubSkill));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static TextComponent getSubSkillUnlockedNotificationComponents(Player player, SubSkillType subSkillType) {
|
||||
public TextComponent getSubSkillUnlockedNotificationComponents(Player player, SubSkillType subSkillType) {
|
||||
TextComponent unlockMessage = new TextComponent("");
|
||||
unlockMessage.setText(pluginRef.getLocaleManager().getString("JSON.SkillUnlockMessage", subSkillType.getLocaleName(), RankUtils.getRank(player, subSkillType)));
|
||||
unlockMessage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, getSubSkillHoverComponent(player, subSkillType)));
|
||||
|
@ -7,6 +7,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.events.skills.McMMOPlayerNotificationEvent;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.TextComponentFactory;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
@ -28,8 +29,10 @@ import java.util.HashMap;
|
||||
public class NotificationManager {
|
||||
|
||||
private HashMap<NotificationType, PlayerNotificationSettings> playerNotificationHashMap;
|
||||
private mcMMO pluginRef;
|
||||
|
||||
public NotificationManager() {
|
||||
public NotificationManager(mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
playerNotificationHashMap = new HashMap<>();
|
||||
|
||||
initMaps();
|
||||
@ -65,7 +68,7 @@ public class NotificationManager {
|
||||
if (pluginRef.getUserManager().getPlayer(player) == null || !pluginRef.getUserManager().getPlayer(player).useChatNotifications())
|
||||
return;
|
||||
|
||||
TextComponent textComponent = TextComponentFactory.getNotificationTextComponentFromLocale(key);
|
||||
TextComponent textComponent = pluginRef.getTextComponentFactory().getNotificationTextComponentFromLocale(key);
|
||||
McMMOPlayerNotificationEvent customEvent = pluginRef.getEventManager().createAndCallNotificationEvent(player, notificationType, textComponent);
|
||||
|
||||
sendNotification(customEvent);
|
||||
@ -78,7 +81,7 @@ public class NotificationManager {
|
||||
* @return TextComponent for this message
|
||||
*/
|
||||
public TextComponent buildTextComponent(String key, String... values) {
|
||||
return TextComponentFactory.getNotificationMultipleValues(key, values);
|
||||
return pluginRef.getTextComponentFactory().getNotificationMultipleValues(key, values);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -87,7 +90,7 @@ public class NotificationManager {
|
||||
* @return TextComponent for this message
|
||||
*/
|
||||
public TextComponent buildTextComponent(String key) {
|
||||
return TextComponentFactory.getNotificationTextComponentFromLocale(key);
|
||||
return pluginRef.getTextComponentFactory().getNotificationTextComponentFromLocale(key);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,7 +138,7 @@ public class NotificationManager {
|
||||
if (!mcMMOPlayer.useChatNotifications())
|
||||
return;
|
||||
|
||||
TextComponent levelUpTextComponent = TextComponentFactory.getNotificationLevelUpTextComponent(skillName, levelsGained, newLevel);
|
||||
TextComponent levelUpTextComponent = pluginRef.getTextComponentFactory().getNotificationLevelUpTextComponent(skillName, levelsGained, newLevel);
|
||||
McMMOPlayerNotificationEvent customEvent = pluginRef.getEventManager().createAndCallNotificationEvent(mcMMOPlayer.getPlayer(), NotificationType.LEVEL_UP_MESSAGE, levelUpTextComponent);
|
||||
|
||||
sendNotification(customEvent);
|
||||
@ -179,7 +182,7 @@ public class NotificationManager {
|
||||
return;
|
||||
|
||||
//CHAT MESSAGE
|
||||
mcMMOPlayer.getPlayer().spigot().sendMessage(TextComponentFactory.getSubSkillUnlockedNotificationComponents(mcMMOPlayer.getPlayer(), subSkillType));
|
||||
mcMMOPlayer.getPlayer().spigot().sendMessage(pluginRef.getTextComponentFactory().getSubSkillUnlockedNotificationComponents(mcMMOPlayer.getPlayer(), subSkillType));
|
||||
|
||||
//Unlock Sound Effect
|
||||
SoundManager.sendCategorizedSound(mcMMOPlayer.getPlayer(), mcMMOPlayer.getPlayer().getLocation(), SoundType.SKILL_UNLOCKED, SoundCategory.MASTER);
|
||||
|
Loading…
Reference in New Issue
Block a user