本文整理匯總了Java中tools.packet.CWvsContext.InfoPacket類的典型用法代碼示例。如果您正苦於以下問題:Java InfoPacket類的具體用法?Java InfoPacket怎麽用?Java InfoPacket使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
InfoPacket類屬於tools.packet.CWvsContext包,在下文中一共展示了InfoPacket類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: gainGachaponItem
import tools.packet.CWvsContext.InfoPacket; //導入依賴的package包/類
public int gainGachaponItem(int id, int quantity, final String msg) {
try {
if (!MapleItemInformationProvider.getInstance().itemExists(id)) {
return -1;
}
final Item item = MapleInventoryManipulator.addbyId_Gachapon(c, id, (short) quantity);
if (item == null) {
return -1;
}
final byte rareness = GameConstants.gachaponRareItem(item.getItemId());
if (rareness > 0) {
World.Broadcast.broadcastMessage(CWvsContext.getGachaponMega(c.getPlayer().getName(), " : got a(n)",
c.getChannel(), item, (byte) 2, "From Gachapon"));
}
c.getSession().write(InfoPacket.getShowItemGain(item.getItemId(), (short) quantity, true));
return item.getItemId();
} catch (Exception e) {
}
return -1;
}
示例2: deleteNote
import tools.packet.CWvsContext.InfoPacket; //導入依賴的package包/類
public void deleteNote(int id, int fame) {
try {
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT gift FROM notes WHERE `id`=?");
ps.setInt(1, id);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
if (rs.getInt("gift") == fame && fame > 0) { //not exploited! hurray
addFame(fame);
updateSingleStat(MapleStat.FAME, getFame());
client.getSession().write(InfoPacket.getShowFameGain(fame));
}
}
rs.close();
ps.close();
ps = con.prepareStatement("DELETE FROM notes WHERE `id`=?");
ps.setInt(1, id);
ps.execute();
ps.close();
} catch (SQLException e) {
System.err.println("Unable to delete note" + e);
}
}
示例3: removeAll
import tools.packet.CWvsContext.InfoPacket; //導入依賴的package包/類
public void removeAll(int id, boolean show) {
MapleInventoryType type = GameConstants.getInventoryType(id);
int possessed = getInventory(type).countById(id);
if (possessed > 0) {
MapleInventoryManipulator.removeById(getClient(), type, id, possessed, true, false);
if (show) {
getClient().getSession().write(InfoPacket.getShowItemGain(id, (short) -possessed, true));
}
}
/*
* if (type == MapleInventoryType.EQUIP) { //check equipped type =
* MapleInventoryType.EQUIPPED; possessed =
* getInventory(type).countById(id);
*
* if (possessed > 0) {
* MapleInventoryManipulator.removeById(getClient(), type, id,
* possessed, true, false);
* getClient().getSession().write(CField.getShowItemGain(id,
* (short)-possessed, true)); } }
*/
}
示例4: gainGP
import tools.packet.CWvsContext.InfoPacket; //導入依賴的package包/類
public final void gainGP(int amount, final boolean broadcast, final int cid) {
if (amount == 0) { //no change, no broadcast and no sql.
return;
}
if (amount + gp < 0) {
amount = -gp;
} //0 lowest
if (cid > 0 && amount > 0) {
final MapleGuildCharacter mg = getMGC(cid);
if (mg != null) {
mg.setGuildContribution(mg.getGuildContribution() + amount);
if (mg.isOnline()) {
World.Guild.setGuildAndRank(cid, this.id, mg.getGuildRank(), mg.getGuildContribution(), mg.getAllianceRank());
} else {
setOfflineGuildStatus(this.id, (byte) mg.getGuildRank(), mg.getGuildContribution(), (byte) mg.getAllianceRank(), cid);
}
broadcast(GuildPacket.guildContribution(id, cid, mg.getGuildContribution()));
}
}
gp += amount;
level = calculateLevel();
broadcast(GuildPacket.updateGP(id, gp, level));
if (broadcast) {
broadcast(InfoPacket.getGPMessage(amount));
}
}
示例5: gainGachaponItem
import tools.packet.CWvsContext.InfoPacket; //導入依賴的package包/類
public int gainGachaponItem(int id, int quantity, final String msg) {
try {
if (!MapleItemInformationProvider.getInstance().itemExists(id)) {
return -1;
}
final Item item = MapleInventoryManipulator.addbyId_Gachapon(c, id, (short) quantity);
if (item == null) {
return -1;
}
final byte rareness = GameConstants.gachaponRareItem(item.getItemId());
if (rareness > 0) {
World.Broadcast.broadcastMessage(CWvsContext.getGachaponMega(c.getPlayer().getName(), " : got a(n)",
c.getChannel(), item, (byte) 2, "From Gachapon"));
}
c.getSession().write(InfoPacket.getShowItemGain(item.getItemId(), (short) quantity, true));
return item.getItemId();
} catch (Exception e) {
}
return -1;
}
示例6: gainGachaponItem
import tools.packet.CWvsContext.InfoPacket; //導入依賴的package包/類
public int gainGachaponItem(int id, int quantity, final String msg) {
try {
if (!MapleItemInformationProvider.getInstance().itemExists(id)) {
return -1;
}
final Item item = MapleInventoryManipulator.addbyId_Gachapon(c, id, (short) quantity);
if (item == null) {
return -1;
}
final byte rareness = GameConstants.gachaponRareItem(item.getItemId());
if (rareness > 0) {
World.Broadcast.broadcastMessage(CWvsContext.getGachaponMega(c.getPlayer().getName(), " : got a(n)", c.getChannel(), item, rareness, msg));
}
c.getSession().write(InfoPacket.getShowItemGain(item.getItemId(), (short) quantity, true));
return item.getItemId();
} catch (Exception e) {
}
return -1;
}
示例7: gainMeso
import tools.packet.CWvsContext.InfoPacket; //導入依賴的package包/類
public void gainMeso(long gain, boolean show, boolean inChat) {
if (meso + gain < 0L || meso + gain > 9999999999L) {
client.getSession().write(CWvsContext.enableActions());
return;
}
meso += gain;
if (meso >= 1000000L) {
finishAchievement(31);
}
if (meso >= 10000000L) {
finishAchievement(32);
}
if (meso >= 100000000L) {
finishAchievement(33);
}
if (meso >= 1000000000L) {
finishAchievement(34);
}
updateSingleStat(MapleStat.MESO, meso, false);
client.getSession().write(CWvsContext.enableActions());
if (show) {
client.getSession().write(InfoPacket.showMesoGain(gain, inChat));
}
}
示例8: gainGP
import tools.packet.CWvsContext.InfoPacket; //導入依賴的package包/類
public final void gainGP(int amount, final boolean broadcast, final int cid) {
if (amount == 0) { //no change, no broadcast and no sql.
return;
}
if (amount + gp < 0) {
amount = -gp;
} //0 lowest
if (cid > 0 && amount > 0) {
final MapleGuildCharacter mg = getMGC(cid);
if (mg != null) {
mg.setGuildContribution(mg.getGuildContribution() + amount);
if (mg.isOnline()) {
World.Guild.setGuildAndRank(cid, this.id, mg.getGuildRank(), mg.getGuildContribution(), mg.getAllianceRank());
} else {
setOfflineGuildStatus(this.id, mg.getGuildRank(), mg.getGuildContribution(), mg.getAllianceRank(), cid);
}
broadcast(GuildPacket.guildContribution(id, cid, mg.getGuildContribution()));
}
}
gp += amount;
level = calculateLevel();
broadcast(GuildPacket.updateGP(id, gp, level));
if (broadcast) {
broadcast(InfoPacket.getGPMsg(amount));
}
}
示例9: gainItem
import tools.packet.CWvsContext.InfoPacket; //導入依賴的package包/類
public final void gainItem(final int id, final short quantity, final boolean randomStats, final long period, boolean hours, final int slots, final String owner, final MapleClient cg, final boolean show) {
if (quantity >= 0) {
final MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
final MapleInventoryType type = GameConstants.getInventoryType(id);
if (!MapleInventoryManipulator.checkSpace(cg, id, quantity, "")) {
return;
}
if (type.equals(MapleInventoryType.EQUIP) && !GameConstants.isThrowingStar(id) && !GameConstants.isBullet(id)) {
final Equip item = (Equip) (randomStats ? ii.randomizeStats((Equip) ii.getEquipById(id)) : ii.getEquipById(id));
if (period > 0) {
item.setExpiration(System.currentTimeMillis() + (period * (hours ? 1 : 24) * 60 * 60 * 1000));
}
if (slots > 0) {
item.setUpgradeSlots((byte) (item.getUpgradeSlots() + slots));
}
if (owner != null) {
item.setOwner(owner);
}
item.setGMLog("Received from interaction " + this.id + " (" + id2 + ") on " + FileoutputUtil.CurrentReadable_Time());
final String name = ii.getName(id);
if (id / 10000 == 114 && name != null && name.length() > 0) { //medal
final String msg = "< " + name + " > has been rewarded.";
cg.getPlayer().dropMessage(-1, msg);
cg.getPlayer().dropMessage(5, msg);
}
MapleInventoryManipulator.addbyItem(cg, item.copy());
} else {
MapleInventoryManipulator.addById(cg, id, quantity, owner == null ? "" : owner, null, period, hours, "Received from interaction " + this.id + " (" + id2 + ") on " + FileoutputUtil.CurrentReadable_Date());
}
} else {
MapleInventoryManipulator.removeById(cg, GameConstants.getInventoryType(id), id, -quantity, true, false);
}
if (show) {
cg.getSession().write(InfoPacket.getShowItemGain(id, quantity, true));
}
}
示例10: removeItem
import tools.packet.CWvsContext.InfoPacket; //導入依賴的package包/類
public final boolean removeItem(final int id) { //quantity 1
if (MapleInventoryManipulator.removeById_Lock(c, GameConstants.getInventoryType(id), id)) {
c.getSession().write(InfoPacket.getShowItemGain(id, (short) -1, true));
return true;
}
return false;
}
示例11: givePartyItems
import tools.packet.CWvsContext.InfoPacket; //導入依賴的package包/類
public final void givePartyItems(final int id, final short quantity, final List<MapleCharacter> party) {
for (MapleCharacter chr : party) {
if (quantity >= 0) {
MapleInventoryManipulator.addById(chr.getClient(), id, quantity, "Received from party interaction " + id + " (" + id2 + ")");
} else {
MapleInventoryManipulator.removeById(chr.getClient(), GameConstants.getInventoryType(id), id, -quantity, true, false);
}
chr.getClient().getSession().write(InfoPacket.getShowItemGain(id, quantity, true));
}
}
示例12: removeFromParty
import tools.packet.CWvsContext.InfoPacket; //導入依賴的package包/類
public final void removeFromParty(final int id, final List<MapleCharacter> party) {
for (final MapleCharacter chr : party) {
final int possesed = chr.getInventory(GameConstants.getInventoryType(id)).countById(id);
if (possesed > 0) {
MapleInventoryManipulator.removeById(c, GameConstants.getInventoryType(id), id, possesed, true, false);
chr.getClient().getSession().write(InfoPacket.getShowItemGain(id, (short) -possesed, true));
}
}
}
示例13: addTrueExp
import tools.packet.CWvsContext.InfoPacket; //導入依賴的package包/類
public void addTrueExp(int e, MapleCharacter c) {
if (e != 0) {
this.totalExp += e;
this.localTotalExp += e;
c.updateSingleStat(type.stat, totalExp);
c.getClient().getSession().write(InfoPacket.showTraitGain(type, e));
recalcLevel();
}
}
示例14: updateQuest
import tools.packet.CWvsContext.InfoPacket; //導入依賴的package包/類
public final void updateQuest(final MapleQuestStatus quest, final boolean update) {
quests.put(quest.getQuest(), quest);
client.getSession().write(InfoPacket.updateQuest(quest));
if (quest.getStatus() == 1 && !update) {
client.getSession().write(CField.updateQuestInfo(this, quest.getQuest().getId(), quest.getNpc(), (byte) 11));
}
}
示例15: gainMeso
import tools.packet.CWvsContext.InfoPacket; //導入依賴的package包/類
public void gainMeso(long gain, boolean show, boolean inChat) {
if (meso + gain < 0L || meso + gain > 9999999999L) {
client.getSession().write(CWvsContext.enableActions());
return;
}
meso += gain;
updateSingleStat(MapleStat.MESO, meso, false);
client.getSession().write(CWvsContext.enableActions());
if (show) {
client.getSession().write(InfoPacket.showMesoGain(gain, inChat));
}
}