From 8a4463b599e6658a1f6f0c086d0b622c1038f7a1 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Mon, 25 Apr 2011 20:29:47 -0500 Subject: [PATCH] Added check to make sure chatTagInsertIndex is valid, to prevent triggering an exception, commented out a bit of debug output --- src/org/mcteam/factions/Factions.java | 2 +- .../factions/listeners/FactionsPlayerListener.java | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/org/mcteam/factions/Factions.java b/src/org/mcteam/factions/Factions.java index 2d69fb24..9c07e0c1 100644 --- a/src/org/mcteam/factions/Factions.java +++ b/src/org/mcteam/factions/Factions.java @@ -95,7 +95,7 @@ public class Factions extends JavaPlugin { log("=== INIT START ==="); long timeInitStart = System.currentTimeMillis(); - log("asdfasdas"+MiscUtil.range(-1, 1)); +// log("asdfasdas"+MiscUtil.range(-1, 1)); // Add the commands commands.add(new FCommandHelp()); diff --git a/src/org/mcteam/factions/listeners/FactionsPlayerListener.java b/src/org/mcteam/factions/listeners/FactionsPlayerListener.java index 0f1bbef8..50392263 100644 --- a/src/org/mcteam/factions/listeners/FactionsPlayerListener.java +++ b/src/org/mcteam/factions/listeners/FactionsPlayerListener.java @@ -65,9 +65,13 @@ public class FactionsPlayerListener extends PlayerListener{ if ( ! Conf.chatTagEnabled) { return; } - - String formatStart = event.getFormat().substring(0, Conf.chatTagInsertIndex); - String formatEnd = event.getFormat().substring(Conf.chatTagInsertIndex); + + int InsertIndex = Conf.chatTagInsertIndex; + if (InsertIndex > event.getFormat().length()) + return; + + String formatStart = event.getFormat().substring(0, InsertIndex); + String formatEnd = event.getFormat().substring(InsertIndex); String nonColoredMsgFormat = formatStart + me.getChatTag() + formatEnd;