📄 maplecharacter.java
字号:
if (keybinding.getType() != 0) {
keymap.put(Integer.valueOf(key), keybinding);
} else {
keymap.remove(Integer.valueOf(key));
}
}
public void sendKeymap() {
getClient().getSession().write(MaplePacketCreator.getKeymap(keymap));
}
public void ban(String reason) {
if (lastmonthfameids == null) {
throw new RuntimeException("Trying to ban a non-loaded character (testhack)");
}
try {
getClient().banMacs();
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE accounts SET banned = ?, banreason = ? WHERE id = ?");
ps.setInt(1, 1);
ps.setString(2, reason);
ps.setInt(3, accountid);
ps.executeUpdate();
ps.close();
ps = con.prepareStatement("INSERT INTO ipbans VALUES (DEFAULT, ?)");
String[] ipSplit = client.getSession().getRemoteAddress().toString().split(":");
ps.setString(1, ipSplit[0]);
ps.executeUpdate();
ps.close();
} catch (SQLException ex) {
log.error("Error while banning", ex);
}
client.getSession().close();
}
public static boolean ban(String id, String reason, boolean accountId) {
try {
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps;
if (id.matches("/[0-9]{1,3}\\..*")) {
ps = con.prepareStatement("INSERT INTO ipbans VALUES (DEFAULT, ?)");
ps.setString(1, id);
ps.executeUpdate();
ps.close();
return true;
}
if (accountId) {
ps = con.prepareStatement("SELECT id FROM accounts WHERE name = ?");
} else {
ps = con.prepareStatement("SELECT accountid FROM characters WHERE name = ?");
}
boolean ret = false;
ps.setString(1, id);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
PreparedStatement psb = con.prepareStatement("UPDATE accounts SET banned = 1, banreason = ? WHERE id = ?");
psb.setString(1, reason);
psb.setInt(2, rs.getInt(1));
psb.executeUpdate();
psb.close();
ret = true;
}
rs.close();
ps.close();
return ret;
} catch (SQLException ex) {
log.error("Error while banning", ex);
}
return false;
}
/**
* Oid of players is always = the cid
*/
@Override
public int getObjectId() {
return getId();
}
/**
* Throws unsupported operation exception, oid of players is read only
*/
@Override
public void setObjectId(int id) {
throw new UnsupportedOperationException();
}
public MapleStorage getStorage() {
return storage;
}
public int getCurrentMaxHp() {
return localmaxhp;
}
public int getCurrentMaxMp() {
return localmaxmp;
}
public int getCurrentMaxBaseDamage() {
return localmaxbasedamage;
}
public int calculateMaxBaseDamage (int watk) {
int maxbasedamage;
if (watk == 0) {
maxbasedamage = 1;
} else {
IItem weapon_item = getInventory(MapleInventoryType.EQUIPPED).getItem((byte) -11);
if (weapon_item != null) {
MapleWeaponType weapon = MapleItemInformationProvider.getInstance().getWeaponType(weapon_item.getItemId());
int mainstat;
int secondarystat;
if (weapon == MapleWeaponType.BOW || weapon == MapleWeaponType.CROSSBOW) {
mainstat = localdex;
secondarystat = localstr;
} else if (getJob().isA(MapleJob.THIEF) && (weapon == MapleWeaponType.CLAW || weapon == MapleWeaponType.DAGGER)) {
mainstat = localluk;
secondarystat = localdex + localstr;
} else {
mainstat = localstr;
secondarystat = localdex;
}
maxbasedamage = (int) (((weapon.getMaxDamageMultiplier() * mainstat + secondarystat) / 100.0) * watk);
//just some saveguard against rounding errors, we want to a/b for this
maxbasedamage += 10;
} else {
maxbasedamage = 0;
}
}
return maxbasedamage;
}
public void addVisibleMapObject (MapleMapObject mo) {
visibleMapObjects.add(mo);
}
public void removeVisibleMapObject (MapleMapObject mo) {
visibleMapObjects.remove(mo);
}
public boolean isMapObjectVisible (MapleMapObject mo) {
return visibleMapObjects.contains(mo);
}
public Collection<MapleMapObject> getVisibleMapObjects () {
return Collections.unmodifiableCollection(visibleMapObjects);
}
public boolean isAlive() {
return this.hp > 0;
}
@Override
public void sendDestroyData(MapleClient client) {
client.getSession().write(MaplePacketCreator.removePlayerFromMap(this.getObjectId()));
}
@Override
public void sendSpawnData(MapleClient client) {
if (!this.isHidden()) {
client.getSession().write(MaplePacketCreator.spawnPlayerMapobject(this));
}
}
private void recalcLocalStats() {
int oldmaxhp = localmaxhp;
localmaxhp = getMaxHp();
localmaxmp = getMaxMp();
localdex = getDex();
localint_ = getInt();
localstr = getStr();
localluk = getLuk();
int speed = 100;
int jump = 100;
magic = localint_;
watk = 0;
for (IItem item : getInventory(MapleInventoryType.EQUIPPED)) {
IEquip equip = (IEquip) item;
localmaxhp += equip.getHp();
localmaxmp += equip.getMp();
localdex += equip.getDex();
localint_ += equip.getInt();
localstr += equip.getStr();
localluk += equip.getLuk();
magic += equip.getMatk() + equip.getInt();
watk += equip.getWatk();
speed += equip.getSpeed();
jump += equip.getJump();
}
magic = Math.min(magic, 2000);
Integer hbhp = getBuffedValue(MapleBuffStat.HYPERBODYHP);
if (hbhp != null) {
localmaxhp += (hbhp.doubleValue() / 100) * localmaxhp;
}
Integer hbmp = getBuffedValue(MapleBuffStat.HYPERBODYMP);
if (hbmp != null) {
localmaxmp += (hbmp.doubleValue() / 100) * localmaxmp;
}
localmaxhp = Math.min(30000, localmaxhp);
localmaxmp = Math.min(30000, localmaxmp);
Integer watkbuff = getBuffedValue(MapleBuffStat.WATK);
if (watkbuff != null) {
watk += watkbuff.intValue();
}
if (job.isA(MapleJob.BOWMAN)) {
ISkill expert = null;
if (job.isA(MapleJob.CROSSBOWMASTER)) {
expert = SkillFactory.getSkill(3220004);
} else if (job.isA(MapleJob.BOWMASTER)) {
expert = SkillFactory.getSkill(3120005);
}
if (expert != null) {
int boostLevel = getSkillLevel(expert);
if (boostLevel > 0) {
watk += expert.getEffect(boostLevel).getX();
}
}
}
Integer matkbuff = getBuffedValue(MapleBuffStat.MATK);
if (matkbuff != null) {
magic += matkbuff.intValue();
}
Integer speedbuff = getBuffedValue(MapleBuffStat.SPEED);
if (speedbuff != null) {
speed += speedbuff.intValue();
}
Integer jumpbuff = getBuffedValue(MapleBuffStat.JUMP);
if (jumpbuff != null) {
jump += jumpbuff.intValue();
}
if (speed > 140) {
speed = 140;
}
if (jump > 123) {
jump = 123;
}
speedMod = speed / 100.0;
jumpMod = jump / 100.0;
Integer mount = getBuffedValue(MapleBuffStat.MONSTER_RIDING);
if (mount != null) {
jumpMod = 1.23;
switch (mount.intValue()) {
case 1:
speedMod = 1.5;
break;
case 2:
speedMod = 1.7;
break;
case 3:
speedMod = 1.8;
break;
default:
log.warn("Unhandeled monster riding level");
}
}
localmaxbasedamage = calculateMaxBaseDamage(watk);
if (oldmaxhp != 0 && oldmaxhp != localmaxhp) {
updatePartyMemberHP();
}
}
public void equipChanged() {
getMap().broadcastMessage(this, MaplePacketCreator.updateCharLook(this), false);
recalcLocalStats();
enforceMaxHpMp();
}
public MaplePet getPet() {
return pet;
}
public void setPet(MaplePet pet) {
this.pet = pet;
}
public FameStatus canGiveFame(MapleCharacter from) {
if (lastfametime >= System.currentTimeMillis() - 60*60*24*1000) {
return FameStatus.NOT_TODAY;
} else if (lastmonthfameids.contains(Integer.valueOf(from.getId()))) {
return FameStatus.NOT_THIS_MONTH;
} else {
return FameStatus.OK;
}
}
public void hasGivenFame(MapleCharacter to) {
lastfametime = System.currentTimeMillis();
lastmonthfameids.add(Integer.valueOf(to.getId()));
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps = con
.prepareStatement("INSERT INTO famelog (characterid, characterid_to) VALUES (?, ?)");
ps.setInt(1, getId());
ps.setInt(2, to.getId());
ps.executeUpdate();
ps.close();
} catch (SQLException e) {
log.error("ERROR writing famelog for char " + getName() + " to " + to.getName(), e);
}
}
public MapleParty getParty() {
return party;
}
public int getWorld() {
return world;
}
public void setWorld(int world) {
this.world = world;
}
public void setParty(MapleParty party) {
this.party = party;
}
public MapleTrade getTrade() {
return trade;
}
public void setTrade(MapleTrade trade) {
this.trade = trade;
}
public EventInstanceManager getEventInstance() {
return eventInstance;
}
public void setEventInstance(EventInstanceManager eventInstance) {
this.eventInstance = eventInstance;
}
public void addDoor(MapleDoor door) {
doors.add(door);
}
public void clearDoors() {
doors.clear();
}
public List<MapleDoor> getDoors() {
return new ArrayList<MapleDoor>(doors);
}
public Map<Integer, MapleSummon> getSummons() {
return summons;
}
public int getChair() {
return chair;
}
public int getItemEffect() {
return itemEffect;
}
public void setChair(int chair) {
this.chair = chair;
}
public void setItemEffect(int itemEffect) {
this.itemEffect = itemEffect;
}
@Override
public Collection<MapleInventory> allInventories() {
return Arrays.asList(inventory);
}
@Override
public MapleMapObjectType getType() {
return MapleMapObjectType.PLAYER;
}
private static class MapleBuffStatValueHolder {
public MapleStatEffect effect;
public long startTime;
public int value;
public ScheduledFuture<?> schedule;
public MapleBuffStatValueHolder(MapleStatEffect effect, long startTime, ScheduledFuture<?> schedule, int value) {
super();
this.effect = effect;
this.startTime = startTime;
this.schedule = schedule;
this.value = value;
}
}
public static class SkillEntry {
public int skillevel;
public int masterlevel;
public SkillEntry(int skillevel, int masterlevel) {
this.skillevel = skillevel;
this.masterlevel = masterlevel;
}
@Override
public String toString() {
return skillevel + ":" + masterlevel;
}
}
public enum FameStatus {
OK, NOT_TODAY, NOT_THIS_MONTH
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -