diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 8fcb793f..c6470168 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -41,6 +41,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; import static engine.math.FastMath.acos; import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup; import static engine.objects.MobBase.loadEquipmentSet; +import static engine.util.StringUtils.wordCount; public class NPC extends AbstractCharacter { @@ -181,15 +182,12 @@ public class NPC extends AbstractCharacter { if (this.equipmentSetID == 0 && this.contract != null) this.equipmentSetID = this.contract.equipmentSet; - if (this.contract != null) - this.loadID = this.contract.getMobbaseID(); - else - this.loadID = rs.getInt("npc_raceID"); + this.loadID = rs.getInt("npc_raceID"); - // Default to human male + // Default to contract load ID if (loadID == 0) - loadID = 2100; + loadID = this.contract.getMobbaseID(); this.mobBase = MobBase.getMobBase(this.loadID); this.level = rs.getByte("npc_level"); @@ -246,10 +244,8 @@ public class NPC extends AbstractCharacter { this.name = rs.getString("npc_name"); // Name override for npc - // with an owner. - if (this.guild != null && - !this.guild.isEmptyGuild()) + if (wordCount(this.name) < 2) this.name += " the " + this.contract.getName(); }catch(Exception e){ diff --git a/src/engine/util/StringUtils.java b/src/engine/util/StringUtils.java index e8cbbe66..e7a6f548 100644 --- a/src/engine/util/StringUtils.java +++ b/src/engine/util/StringUtils.java @@ -136,15 +136,27 @@ public class StringUtils { } } - - return outString; + + return outString; + + } + + public static String truncate(String input, int length) { + if (input != null && input.length() > length) + input = input.substring(0, length); + return input; + } + + public static int wordCount(String input) { + + String workString = input.trim(); + + if (workString.isEmpty()) + return 0; + + return workString.split("\\s+").length; + + } } - -public static String truncate(String input, int length) { - if (input != null && input.length() > length) - input = input.substring(0, length); - return input; -} - -} +