Always remove tags from player.getName()
- Move removal of tags to RSPlayerMixin - Remove tags from players names where needed Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -32,6 +32,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import javax.swing.SwingUtilities;
|
||||
import net.runelite.api.Text;
|
||||
import net.runelite.api.events.ConfigChanged;
|
||||
import net.runelite.api.events.PlayerMenuOptionClicked;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
@@ -138,7 +139,7 @@ public class HiscorePlugin extends Plugin
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
hiscorePanel.lookup(event.getMenuTarget());
|
||||
hiscorePanel.lookup(Text.removeTags(event.getMenuTarget()));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.ItemComposition;
|
||||
import net.runelite.api.MenuEntry;
|
||||
import net.runelite.api.Text;
|
||||
import net.runelite.api.events.ConfigChanged;
|
||||
import net.runelite.api.events.MenuEntryAdded;
|
||||
import net.runelite.api.events.PostItemComposition;
|
||||
@@ -52,7 +53,6 @@ import net.runelite.client.menus.WidgetMenuOption;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.util.Text;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Menu Entry Swapper",
|
||||
|
||||
@@ -39,7 +39,7 @@ import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.util.Text;
|
||||
import net.runelite.api.Text;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Nightmare Zone"
|
||||
|
||||
@@ -45,7 +45,7 @@ import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayPriority;
|
||||
import net.runelite.client.ui.overlay.components.BackgroundComponent;
|
||||
import net.runelite.client.ui.overlay.components.TextComponent;
|
||||
import net.runelite.client.util.Text;
|
||||
import net.runelite.api.Text;
|
||||
|
||||
class OpponentInfoOverlay extends Overlay
|
||||
{
|
||||
|
||||
@@ -35,7 +35,6 @@ import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayPriority;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
import net.runelite.client.util.Text;
|
||||
|
||||
@Singleton
|
||||
public class PlayerIndicatorsMinimapOverlay extends Overlay
|
||||
@@ -66,7 +65,7 @@ public class PlayerIndicatorsMinimapOverlay extends Overlay
|
||||
|
||||
private void renderPlayerOverlay(Graphics2D graphics, Player actor, Color color)
|
||||
{
|
||||
final String name = Text.removeTags(actor.getName());
|
||||
final String name = actor.getName();
|
||||
final net.runelite.api.Point minimapLocation = actor.getMinimapLocation();
|
||||
|
||||
if (minimapLocation != null)
|
||||
|
||||
@@ -51,7 +51,7 @@ import net.runelite.api.IndexedSprite;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.PlayerNameMask;
|
||||
import net.runelite.api.events.SetMessage;
|
||||
import net.runelite.client.util.Text;
|
||||
import net.runelite.api.Text;
|
||||
|
||||
@Singleton
|
||||
@Slf4j
|
||||
@@ -113,7 +113,7 @@ public class PlayerIndicatorsService
|
||||
{
|
||||
if (player != null && player.getName() != null)
|
||||
{
|
||||
player.setName(Text.removeTags(player.getName()));
|
||||
player.setName(player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,11 +228,11 @@ public class PlayerIndicatorsService
|
||||
private void injectData(final Player player, final Color color)
|
||||
{
|
||||
final StringBuilder stringBuilder = new StringBuilder();
|
||||
final String strippedName = Text.removeTags(player.getName());
|
||||
final String playerName = player.getName();
|
||||
|
||||
if (config.showClanRankIcons() && player.isClanMember())
|
||||
{
|
||||
final ClanMemberRank clanMemberRank = clanRanksCache.getUnchecked(strippedName);
|
||||
final ClanMemberRank clanMemberRank = clanRanksCache.getUnchecked(playerName);
|
||||
|
||||
if (clanMemberRank != ClanMemberRank.UNRANKED)
|
||||
{
|
||||
@@ -244,7 +244,7 @@ public class PlayerIndicatorsService
|
||||
}
|
||||
|
||||
stringBuilder.append("<col=").append(parseColor(color)).append(">");
|
||||
player.setName(stringBuilder.toString() + strippedName);
|
||||
player.setName(stringBuilder.toString() + playerName);
|
||||
}
|
||||
|
||||
private static String parseColor(final Color color)
|
||||
|
||||
@@ -70,7 +70,7 @@ import net.runelite.client.plugins.raids.solver.LayoutSolver;
|
||||
import net.runelite.client.plugins.raids.solver.RotationSolver;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||
import net.runelite.client.util.Text;
|
||||
import net.runelite.api.Text;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Chambers Of Xeric"
|
||||
|
||||
@@ -78,7 +78,7 @@ import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.TitleToolbar;
|
||||
import net.runelite.client.ui.overlay.OverlayRenderer;
|
||||
import net.runelite.client.util.Text;
|
||||
import net.runelite.api.Text;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
|
||||
@@ -57,7 +57,7 @@ import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.task.Schedule;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||
import net.runelite.client.util.Text;
|
||||
import net.runelite.api.Text;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Slayer"
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Joshua Filby <joshua@filby.me>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.util;
|
||||
|
||||
/**
|
||||
* A set of utilities to use when dealing with text.
|
||||
*/
|
||||
public class Text
|
||||
{
|
||||
|
||||
/**
|
||||
* Removes all tags from the given `str`.
|
||||
*
|
||||
* @param str The string to remove tags from.
|
||||
* @return The given `str` with all tags removed from it.
|
||||
*/
|
||||
public static String removeTags(String str)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder(str.length());
|
||||
boolean inTag = false;
|
||||
|
||||
for (int i = 0; i < str.length(); i++)
|
||||
{
|
||||
char currentChar = str.charAt(i);
|
||||
|
||||
if (currentChar == '<')
|
||||
{
|
||||
inTag = true;
|
||||
}
|
||||
else if (currentChar == '>')
|
||||
{
|
||||
inTag = false;
|
||||
}
|
||||
else if (!inTag)
|
||||
{
|
||||
builder.append(currentChar);
|
||||
}
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user