forked from MagicBane/Server
NPC table overrides for contracts.
This commit is contained in:
@@ -41,6 +41,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|||||||
import static engine.math.FastMath.acos;
|
import static engine.math.FastMath.acos;
|
||||||
import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup;
|
import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup;
|
||||||
import static engine.objects.MobBase.loadEquipmentSet;
|
import static engine.objects.MobBase.loadEquipmentSet;
|
||||||
|
import static engine.util.StringUtils.wordCount;
|
||||||
|
|
||||||
public class NPC extends AbstractCharacter {
|
public class NPC extends AbstractCharacter {
|
||||||
|
|
||||||
@@ -181,15 +182,12 @@ public class NPC extends AbstractCharacter {
|
|||||||
if (this.equipmentSetID == 0 && this.contract != null)
|
if (this.equipmentSetID == 0 && this.contract != null)
|
||||||
this.equipmentSetID = this.contract.equipmentSet;
|
this.equipmentSetID = this.contract.equipmentSet;
|
||||||
|
|
||||||
if (this.contract != null)
|
this.loadID = rs.getInt("npc_raceID");
|
||||||
this.loadID = this.contract.getMobbaseID();
|
|
||||||
else
|
|
||||||
this.loadID = rs.getInt("npc_raceID");
|
|
||||||
|
|
||||||
// Default to human male
|
// Default to contract load ID
|
||||||
|
|
||||||
if (loadID == 0)
|
if (loadID == 0)
|
||||||
loadID = 2100;
|
loadID = this.contract.getMobbaseID();
|
||||||
|
|
||||||
this.mobBase = MobBase.getMobBase(this.loadID);
|
this.mobBase = MobBase.getMobBase(this.loadID);
|
||||||
this.level = rs.getByte("npc_level");
|
this.level = rs.getByte("npc_level");
|
||||||
@@ -246,10 +244,8 @@ public class NPC extends AbstractCharacter {
|
|||||||
this.name = rs.getString("npc_name");
|
this.name = rs.getString("npc_name");
|
||||||
|
|
||||||
// Name override for npc
|
// Name override for npc
|
||||||
// with an owner.
|
|
||||||
|
|
||||||
if (this.guild != null &&
|
if (wordCount(this.name) < 2)
|
||||||
!this.guild.isEmptyGuild())
|
|
||||||
this.name += " the " + this.contract.getName();
|
this.name += " the " + this.contract.getName();
|
||||||
|
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user