MapleEvent.java
PHP Code:
/*
This file is part of the ZeroFusion MapleStory Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
ZeroFusion organized by "RMZero213" <RMZero213@hotmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
as published by the Free Software Foundation. You may not use, modify
or distribute this program under any other version of the
GNU Affero General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.events;
import clientside.MapleCharacter;
import constants.GameConstants;
import handling.channel.ChannelServer;
import handling.world.World;
import server.MapleInventoryManipulator;
import server.RandomRewards;
import server.Randomizer;
import server.Timer.EventTimer;
import server.maps.FieldLimitType;
import server.maps.MapleMap;
import server.maps.SavedLocationType;
import tools.FileoutputUtil;
import tools.packet.CField;
import tools.StringUtil;
import tools.packet.CWvsContext;
public abstract class MapleEvent {
protected MapleEventType type;
protected int channel, playerCount = 0;
protected boolean isRunning = false;
public MapleEvent(final int channel, final MapleEventType type) {
this.channel = channel;
this.type = type;
}
public void incrementPlayerCount() {
playerCount++;
if (playerCount == 250) {
setEvent(ChannelServer.getInstance(channel), true);
}
}
public MapleEventType getType() {
return type;
}
public boolean isRunning() {
return isRunning;
}
public MapleMap getMap(final int i) {
return getChannelServer().getMapFactory().getMap(type.mapids[i]);
}
public ChannelServer getChannelServer() {
return ChannelServer.getInstance(channel);
}
public void broadcast(final byte[] packet) {
for (int i = 0; i < type.mapids.length; i++) {
getMap(i).broadcastMessage(packet);
}
}
public static void givePrize(final MapleCharacter chr) {
final int reward = RandomRewards.getEventReward();
if (reward == 0) {
final int mes = Randomizer.nextInt(9000000) + 1000000;
chr.gainMeso(mes, true, false);
chr.dropMessage(5, "You gained " + mes + " Mesos.");
} else if (reward == 1) {
final int cs = Randomizer.nextInt(4000) + 1000;
chr.modifyCSPoints(1, cs, true);
chr.dropMessage(5, "You gained " + (GameConstants.GMS ? (cs / 2) : cs) + " cash.");
} else if (reward == 2) {
chr.setVPoints(chr.getVPoints() + 1);
chr.dropMessage(5, "You gained 1 Vote Point.");
} else if (reward == 3) {
chr.addFame(10);
chr.dropMessage(5, "You gained 10 Fame.");
} else if (reward == 4) {
chr.dropMessage(5, "There was no reward.");
} else {
int max_quantity = 1;
switch (reward) {
case 5062000:
max_quantity = 3;
break;
case 5220000:
max_quantity = 25;
break;
case 4031307:
case 5050000:
max_quantity = 5;
break;
case 2022121:
max_quantity = 10;
break;
}
final int quantity = (max_quantity > 1 ? Randomizer.nextInt(max_quantity) : 0) + 1;
if (MapleInventoryManipulator.checkSpace(chr.getClient(), reward, quantity, "")) {
MapleInventoryManipulator.addById(chr.getClient(), reward, (short) quantity, "Event prize on " + FileoutputUtil.CurrentReadable_Date());
} else {
givePrize(chr); //do again until they get
}
//5062000 = 1-3
//5220000 = 1-25
//5050000 = 1-5
//2022121 = 1-10
//4031307 = 1-5
}
}
public abstract void finished(MapleCharacter chr); //most dont do shit here
public abstract void startEvent();
public void onMapLoad(MapleCharacter chr) { //most dont do shit here
if (GameConstants.isEventMap(chr.getMapId()) && FieldLimitType.Event.check(chr.getMap().getFieldLimit()) && FieldLimitType.Event2.check(chr.getMap().getFieldLimit())) {
chr.getClient().getSession().write(CField.showEventInstructions());
}
}
public void warpBack(MapleCharacter chr) {
int map = chr.getSavedLocation(SavedLocationType.EVENT);
if (map <= -1) {
map = 104000000;
}
final MapleMap mapp = chr.getClient().getChannelServer().getMapFactory().getMap(map);
chr.changeMap(mapp, mapp.getPortal(0));
}
public void reset() {
isRunning = true;
playerCount = 0;
}
public void unreset() {
isRunning = false;
playerCount = 0;
}
public static final void setEvent(final ChannelServer cserv, final boolean auto) {
if (auto && cserv.getEvent() > -1) {
for (MapleEventType t : MapleEventType.values()) {
final MapleEvent e = cserv.getEvent(t);
if (e.isRunning) {
for (int i : e.type.mapids) {
if (cserv.getEvent() == i) {
World.Broadcast.broadcastMessage(CWvsContext.serverNotice(0, "Entries for the event are now closed!"));
e.broadcast(CWvsContext.serverNotice(0, "The event will start in 30 seconds!"));
e.broadcast(CField.getClock(30));
EventTimer.getInstance().schedule(new Runnable() {
public void run() {
e.startEvent();
}
}, 30000);
break;
}
}
}
}
}
cserv.setEvent(-1);
}
public static final void mapLoad(final MapleCharacter chr, final int channel) {
if (chr == null) {
return;
} //o_o
for (MapleEventType t : MapleEventType.values()) {
final MapleEvent e = ChannelServer.getInstance(channel).getEvent(t);
if (e.isRunning) {
if (chr.getMapId() == 109050000) { //finished map
e.finished(chr);
}
for (int i = 0; i < e.type.mapids.length; i++) {
if (chr.getMapId() == e.type.mapids[i]) {
e.onMapLoad(chr);
if (i == 0) { //first map
e.incrementPlayerCount();
}
}
}
}
}
}
public static final void onStartEvent(final MapleCharacter chr) {
for (MapleEventType t : MapleEventType.values()) {
final MapleEvent e = chr.getClient().getChannelServer().getEvent(t);
if (e.isRunning) {
for (int i : e.type.mapids) {
if (chr.getMapId() == i) {
e.startEvent();
setEvent(chr.getClient().getChannelServer(), false);
chr.dropMessage(5, String.valueOf(t) + " has been started.");
}
}
}
}
}
public static final String scheduleEvent(final MapleEventType event, final ChannelServer cserv) {
if (cserv.getEvent() != 0 || cserv.getEvent(event) == null) { // 0 = -1
return "The event must not have been already scheduled.";
}
for (int i : cserv.getEvent(event).type.mapids) {
if (cserv.getMapFactory().getMap(i).getCharactersSize() > 0) {
return "The event is already running.";
}
}
cserv.setEvent(cserv.getEvent(event).type.mapids[0]);
cserv.getEvent(event).reset();
World.Broadcast.broadcastMessage(CWvsContext.serverNotice(0, "Hello " + cserv.getServerName() + "! Let's play a " + StringUtil.makeEnumHumanReadable(event.name()) + " event in channel " + cserv.getChannel() + "! Change to channel " + cserv.getChannel() + " and use [MENTION=1333420483]event[/MENTION] command!"));
return "";
}
}
MapleCoconut.java
PHP Code:
/*
This file is part of the ZeroFusion MapleStory Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <mat@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
ZeroFusion organized by "RMZero213" <RMZero213@hotmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
as published by the Free Software Foundation. You may not use, modify
or distribute this program under any other version of the
GNU Affero General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package server.events;
import clientside.MapleCharacter;
import java.util.LinkedList;
import java.util.List;
import server.Timer.EventTimer;
import tools.packet.CField;
import tools.packet.CWvsContext;
public class MapleCoconut extends MapleEvent {
private final List<MapleCoconuts> coconuts = new LinkedList<>();
private final int[] coconutscore = new int[2];
private int countBombing = 0;
private int countFalling = 0;
private int countStopped = 0;
public MapleCoconut(final int channel, final MapleEventType type) {
super(channel, type);
}
[MENTION=2000004426]Override[/MENTION]
public void finished(MapleCharacter chr) { //do nothing.
}
[MENTION=2000004426]Override[/MENTION]
public void reset() {
super.reset();
resetCoconutScore();
}
[MENTION=2000004426]Override[/MENTION]
public void unreset() {
super.unreset();
resetCoconutScore();
setHittable(false);
}
[MENTION=2000004426]Override[/MENTION]
public void onMapLoad(MapleCharacter chr) {
super.onMapLoad(chr);
chr.getClient().getSession().write(CField.coconutScore(getCoconutScore()));
}
public MapleCoconuts getCoconut(int id) {
if (id >= coconuts.size()) {
return null;
}
return coconuts.get(id);
}
public List<MapleCoconuts> getAllCoconuts() {
return coconuts;
}
public void setHittable(boolean hittable) {
for (MapleCoconuts nut : coconuts) {
nut.setHittable(hittable);
}
}
public int getBombings() {
return countBombing;
}
public void bombCoconut() {
countBombing--;
}
public int getFalling() {
return countFalling;
}
public void fallCoconut() {
countFalling--;
}
public int getStopped() {
return countStopped;
}
public void stopCoconut() {
countStopped--;
}
public int[] getCoconutScore() { // coconut event
return coconutscore;
}
public int getMapleScore() { // Team Maple, coconut event
return coconutscore[0];
}
public int getStoryScore() { // Team Story, coconut event
return coconutscore[1];
}
public void addMapleScore() { // Team Maple, coconut event
coconutscore[0]++;
}
public void addStoryScore() { // Team Story, coconut event
coconutscore[1]++;
}
public void resetCoconutScore() {
coconutscore[0] = 0;
coconutscore[1] = 0;
countBombing = 80;
countFalling = 401;
countStopped = 20;
coconuts.clear();
for (int i = 0; i < 506; i++) {
coconuts.add(new MapleCoconuts());
}
}
[MENTION=2000004426]Override[/MENTION]
public void startEvent() {
reset();
setHittable(true);
getMap(0).broadcastMessage(CWvsContext.serverNotice(5, "The event has started!!"));
getMap(0).broadcastMessage(CField.hitCoconut(true, 0, 0));
getMap(0).broadcastMessage(CField.getClock(300));
EventTimer.getInstance().schedule(new Runnable() {
[MENTION=2000004426]Override[/MENTION]
public void run() {
if (getMapleScore() == getStoryScore()) {
bonusTime();
} else {
for (MapleCharacter chr : getMap(0).getCharactersThreadsafe()) {
if (chr.getTeam() == (getMapleScore() > getStoryScore() ? 0 : 1)) {
chr.getClient().getSession().write(CField.showEffect("event/coconut/victory"));
chr.getClient().getSession().write(CField.playSound("Coconut/Victory"));
} else {
chr.getClient().getSession().write(CField.showEffect("event/coconut/lose"));
chr.getClient().getSession().write(CField.playSound("Coconut/Failed"));
}
}
warpOut();
}
}
}, 300000);
}
public void bonusTime() {
getMap(0).broadcastMessage(CField.getClock(60));
EventTimer.getInstance().schedule(new Runnable() {
[MENTION=2000004426]Override[/MENTION]
public void run() {
if (getMapleScore() == getStoryScore()) {
for (MapleCharacter chr : getMap(0).getCharactersThreadsafe()) {
chr.getClient().getSession().write(CField.showEffect("event/coconut/lose"));
chr.getClient().getSession().write(CField.playSound("Coconut/Failed"));
}
warpOut();
} else {
for (MapleCharacter chr : getMap(0).getCharactersThreadsafe()) {
if (chr.getTeam() == (getMapleScore() > getStoryScore() ? 0 : 1)) {
chr.getClient().getSession().write(CField.showEffect("event/coconut/victory"));
chr.getClient().getSession().write(CField.playSound("Coconut/Victory"));
} else {
chr.getClient().getSession().write(CField.showEffect("event/coconut/lose"));
chr.getClient().getSession().write(CField.playSound("Coconut/Failed"));
}
}
warpOut();
}
}
}, 60000);
}
public void warpOut() {
setHittable(false);
EventTimer.getInstance().schedule(new Runnable() {
[MENTION=2000004426]Override[/MENTION]
public void run() {
for (MapleCharacter chr : getMap(0).getCharactersThreadsafe()) {
if ((getMapleScore() > getStoryScore() && chr.getTeam() == 0) || (getStoryScore() > getMapleScore() && chr.getTeam() == 1)) {
givePrize(chr);
}
warpBack(chr);
}
unreset();
}
}, 10000);
}
public static class MapleCoconuts {
private int hits = 0;
private boolean hittable = false;
private boolean stopped = false;
private long hittime = System.currentTimeMillis();
public void hit() {
this.hittime = System.currentTimeMillis() + 1000; // test
hits++;
}
public int getHits() {
return hits;
}
public void resetHits() {
hits = 0;
}
public boolean isHittable() {
return hittable;
}
public void setHittable(boolean hittable) {
this.hittable = hittable;
}
public boolean isStopped() {
return stopped;
}
public void setStopped(boolean stopped) {
this.stopped = stopped;
}
public long getHitTime() {
return hittime;
}
}
}
ChannelServer.java
PHP Code:
package handling.channel;
import clientside.MapleCharacter;
import constants.GameConstants;
import handling.MapleServerHandler;
import handling.cashshop.CashShopServer;
import handling.login.LoginServer;
import handling.mina.MapleCodecFactory;
import handling.world.CheaterData;
import handling.world.MaplePartyCharacter;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.buffer.SimpleBufferAllocator;
import org.apache.mina.core.filterchain.IoFilter;
import org.apache.mina.core.service.IoAcceptor;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFilter;
import org.apache.mina.transport.socket.SocketSessionConfig;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
import scripting.EventScriptManager;
import server.MapleSquad;
import server.ServerProperties;
import server.Start;
import server.events.MapleCoconut;
import server.events.MapleEvent;
import server.events.MapleEventType;
import server.events.MapleFitness;
import server.events.MapleOla;
import server.events.MapleOxQuiz;
import server.events.MapleSnowball;
import server.events.MapleSurvival;
import server.life.PlayerNPC;
import server.maps.AramiaFireWorks;
import server.maps.MapleMapFactory;
import server.maps.MapleMapObject;
import server.shops.HiredMerchant;
import tools.ConcurrentEnumMap;
import tools.packet.CWvsContext;
public class ChannelServer {
public static long serverStartTime;
private int expRate;
private int mesoRate;
private int dropRate = 3;
private int cashRate = 1;
private int traitRate = 10;
private int BossDropRate = 3;
private short port = 8585;
private static final short DEFAULT_PORT = 8585;
private int channel;
private int running_MerchantID = 0;
private int flags = 0;
private String serverMessage;
private String ip;
private String serverName;
private boolean shutdown = false;
private boolean finishedShutdown = false;
private boolean MegaphoneMuteState = false;
private boolean adminOnly = false;
private PlayerStorage players;
private IoAcceptor acceptor;
private final MapleMapFactory mapFactory;
private EventScriptManager eventSM;
private AramiaFireWorks works = new AramiaFireWorks();
private static final Map<Integer, ChannelServer> instances = new HashMap();
private final Map<MapleSquad.MapleSquadType, MapleSquad> mapleSquads = new ConcurrentEnumMap(MapleSquad.MapleSquadType.class);
private final Map<Integer, HiredMerchant> merchants = new HashMap();
private final List<PlayerNPC> playerNPCs = new LinkedList();
private final ReentrantReadWriteLock merchLock = new ReentrantReadWriteLock();
private int eventmap = -1;
private final Map<MapleEventType, MapleEvent> events = new EnumMap<MapleEventType, MapleEvent>(MapleEventType.class);
public boolean eventOn = false;
public int eventMap = 0;
private boolean eventWarp;
private String eventHost;
private String eventName;
private ChannelServer(int channel) {
this.channel = channel;
this.mapFactory = new MapleMapFactory(channel);
}
public static Set<Integer> getAllInstance() {
return new HashSet(instances.keySet());
}
public final void loadEvents() {
if (!events.isEmpty()) {
return;
}
events.put(MapleEventType.CokePlay, new MapleCoconut(channel, MapleEventType.CokePlay)); //yep, coconut. same shit
events.put(MapleEventType.Coconut, new MapleCoconut(channel, MapleEventType.Coconut));
events.put(MapleEventType.Fitness, new MapleFitness(channel, MapleEventType.Fitness));
events.put(MapleEventType.OlaOla, new MapleOla(channel, MapleEventType.OlaOla));
events.put(MapleEventType.OxQuiz, new MapleOxQuiz(channel, MapleEventType.OxQuiz));
events.put(MapleEventType.Snowball, new MapleSnowball(channel, MapleEventType.Snowball));
events.put(MapleEventType.Survival, new MapleSurvival(channel, MapleEventType.Survival));
}
public byte eventChannel;
public final void run_startup_configurations() {
setChannel(this.channel);
try {
this.expRate = Integer.parseInt(ServerProperties.getProperty("net.sf.odinms.world.exp"));
this.mesoRate = Integer.parseInt(ServerProperties.getProperty("net.sf.odinms.world.meso"));
this.serverMessage = ServerProperties.getProperty("net.sf.odinms.world.serverMessage");
this.serverName = ServerProperties.getProperty("net.sf.odinms.login.serverName");
this.flags = Integer.parseInt(ServerProperties.getProperty("net.sf.odinms.world.flags", "0"));
this.eventSM = new EventScriptManager(this, ServerProperties.getProperty("net.sf.odinms.channel.events").split(","));
this.port = Short.parseShort(ServerProperties.getProperty("net.sf.odinms.channel.net.port" + this.channel, String.valueOf(8585 + this.channel)));
} catch (Exception e) {
throw new RuntimeException(e);
}
this.ip = (Start.nexonip + ":" + this.port);
IoBuffer.setUseDirectBuffer(false);
IoBuffer.setAllocator(new SimpleBufferAllocator());
acceptor = new NioSocketAcceptor();
acceptor.getFilterChain().addLast("codec", (IoFilter) new ProtocolCodecFilter(new MapleCodecFactory()));
players = new PlayerStorage(channel);
try {
acceptor.setHandler(new MapleServerHandler(channel, false, false));
acceptor.bind(new InetSocketAddress(port));
((SocketSessionConfig) acceptor.getSessionConfig()).setTcpNoDelay(true);
System.out.println("Channel " + this.channel + ": Listening on port " + this.port + "");
this.eventSM.init();
} catch (IOException e) {
System.out.println("Binding to port " + this.port + " failed (ch: " + getChannel() + ")" + e);
}
}
public final void shutdown() {
if (this.finishedShutdown) {
return;
}
broadcastPacket(CWvsContext.serverNotice(0, "This channel will now shut down."));
this.shutdown = true;
System.out.println("Channel " + this.channel + ", Saving characters...");
getPlayerStorage().disconnectAll();
acceptor.setCloseOnDeactivation(true);
for (IoSession ss : acceptor.getManagedSessions().values()) {
ss.close(true);
}
acceptor.unbind();
acceptor.dispose();
System.out.println("Channel " + this.channel + ", Unbinding...");
instances.remove(Integer.valueOf(this.channel));
setFinishShutdown();
}
public final MapleCharacter getPlayer() {
return getPlayer();
}
public final List<MapleCharacter> getPartyMembers(MapleCharacter party) {
List chars = new LinkedList();
for (MaplePartyCharacter partychar : getPlayer().getParty().getMembers()) {
if (partychar.getChannel() == getChannel()) {
MapleCharacter chr = getPlayerStorage().getCharacterByName(partychar.getName());
if (chr != null) {
chars.add(chr);
}
}
}
return chars;
}
public final boolean hasFinishedShutdown() {
return this.finishedShutdown;
}
public final MapleMapFactory getMapFactory() {
return this.mapFactory;
}
public static final ChannelServer newInstance(int channel) {
return new ChannelServer(channel);
}
public static final ChannelServer getInstance(int channel) {
return (ChannelServer) instances.get(Integer.valueOf(channel));
}
public final void addPlayer(MapleCharacter chr) {
getPlayerStorage().registerPlayer(chr);
}
public PlayerStorage getPlayerStorage() {
if (players == null) { //wth
players = new PlayerStorage(channel); //wthhhh
}
return players;
}
public final void removePlayer(MapleCharacter chr) {
getPlayerStorage().deregisterPlayer(chr);
}
public final void removePlayer(int idz, String namez) {
getPlayerStorage().deregisterPlayer(idz, namez);
}
public final String getServerMessage() {
return this.serverMessage;
}
public final void setServerMessage(String newMessage) {
this.serverMessage = newMessage;
broadcastPacket(CWvsContext.serverMessage(this.serverMessage));
}
public final void broadcastPacket(byte[] data) {
getPlayerStorage().broadcastPacket(data);
}
public final void broadcastSmegaPacket(byte[] data) {
getPlayerStorage().broadcastSmegaPacket(data);
}
public final void broadcastGMPacket(byte[] data) {
getPlayerStorage().broadcastGMPacket(data);
}
public final int getExpRate() {
return this.expRate;
}
public final void setExpRate(int expRate) {
this.expRate = expRate;
}
public final int getCashRate() {
return this.cashRate;
}
public final int getChannel() {
return this.channel;
}
public final void setChannel(int channel) {
instances.put(Integer.valueOf(channel), this);
LoginServer.addChannel(channel);
}
public static final ArrayList<ChannelServer> getAllInstances() {
return new ArrayList(instances.values());
}
public final String getIP() {
return this.ip;
}
public String getIP(int channel) {
try {
return getIP(channel);
} catch (Exception e) {
System.out.println("Lost connection to world server " + e);
}
throw new RuntimeException("Lost connection to world server");
}
public final boolean isShutdown() {
return this.shutdown;
}
public final int getLoadedMaps() {
return this.mapFactory.getLoadedMaps();
}
public final EventScriptManager getEventSM() {
return this.eventSM;
}
public final void reloadEvents() {
this.eventSM.cancel();
this.eventSM = new EventScriptManager(this, ServerProperties.getProperty("net.sf.odinms.channel.events").split(","));
this.eventSM.init();
}
public final int getMesoRate() {
return this.mesoRate;
}
public final void setMesoRate(int mesoRate) {
this.mesoRate = mesoRate;
}
public final void setDropRate(int dropRate) {
this.dropRate = dropRate;
}
public final int getDropRate() {
return this.dropRate;
}
public final int getBossDropRate() {
return this.BossDropRate;
}
public static final void startChannel_Main() {
serverStartTime = System.currentTimeMillis();
for (int i = 0; i < Integer.parseInt(ServerProperties.getProperty("net.sf.odinms.channel.count", "0")); i++) {
newInstance(i + 1).run_startup_configurations();
}
}
public Map<MapleSquad.MapleSquadType, MapleSquad> getAllSquads() {
return Collections.unmodifiableMap(this.mapleSquads);
}
public final MapleSquad getMapleSquad(String type) {
return getMapleSquad(MapleSquad.MapleSquadType.valueOf(type.toLowerCase()));
}
public final MapleSquad getMapleSquad(MapleSquad.MapleSquadType type) {
return (MapleSquad) this.mapleSquads.get(type);
}
public final boolean addMapleSquad(MapleSquad squad, String type) {
MapleSquad.MapleSquadType types = MapleSquad.MapleSquadType.valueOf(type.toLowerCase());
if ((types != null) && (!this.mapleSquads.containsKey(types))) {
this.mapleSquads.put(types, squad);
squad.scheduleRemoval();
return true;
}
return false;
}
public final boolean removeMapleSquad(MapleSquad.MapleSquadType types) {
if ((types != null) && (this.mapleSquads.containsKey(types))) {
this.mapleSquads.remove(types);
return true;
}
return false;
}
public final int closeAllMerchant() {
int ret = 0;
this.merchLock.writeLock().lock();
try {
Iterator merchants_ = this.merchants.entrySet().iterator();
while (merchants_.hasNext()) {
HiredMerchant hm = (HiredMerchant) ((Map.Entry) merchants_.next()).getValue();
hm.closeShop(true, false);
hm.getMap().removeMapObject(hm);
merchants_.remove();
ret++;
}
} finally {
this.merchLock.writeLock().unlock();
}
for (int i = 910000001; i <= 910000022; i++) {
for (MapleMapObject mmo : this.mapFactory.getMap(i).getAllHiredMerchantsThreadsafe()) {
((HiredMerchant) mmo).closeShop(true, false);
ret++;
}
}
return ret;
}
public final int addMerchant(HiredMerchant hMerchant) {
this.merchLock.writeLock().lock();
try {
this.running_MerchantID += 1;
this.merchants.put(Integer.valueOf(this.running_MerchantID), hMerchant);
return this.running_MerchantID;
} finally {
this.merchLock.writeLock().unlock();
}
}
public final void removeMerchant(HiredMerchant hMerchant) {
this.merchLock.writeLock().lock();
try {
this.merchants.remove(Integer.valueOf(hMerchant.getStoreId()));
} finally {
this.merchLock.writeLock().unlock();
}
}
public final boolean containsMerchant(int accid, int cid) {
boolean contains = false;
this.merchLock.readLock().lock();
try {
Iterator itr = this.merchants.values().iterator();
while (itr.hasNext()) {
HiredMerchant hm = (HiredMerchant) itr.next();
if ((hm.getOwnerAccId() == accid) || (hm.getOwnerId() == cid)) {
contains = true;
break;
}
}
} finally {
this.merchLock.readLock().unlock();
}
return contains;
}
public final List<HiredMerchant> searchMerchant(int itemSearch) {
List list = new LinkedList();
this.merchLock.readLock().lock();
try {
Iterator itr = this.merchants.values().iterator();
while (itr.hasNext()) {
HiredMerchant hm = (HiredMerchant) itr.next();
if (hm.searchItem(itemSearch).size() > 0) {
list.add(hm);
}
}
} finally {
this.merchLock.readLock().unlock();
}
return list;
}
public final void toggleMegaphoneMuteState() {
this.MegaphoneMuteState = (!this.MegaphoneMuteState);
}
public final boolean getMegaphoneMuteState() {
return this.MegaphoneMuteState;
}
public int getEvent() {
return eventmap;
}
public final void setEvent(final int ze) {
eventmap = ze;
}
public MapleEvent getEvent(final MapleEventType t) {
return events.get(t);
}
public final Collection<PlayerNPC> getAllPlayerNPC() {
return this.playerNPCs;
}
public final void addPlayerNPC(PlayerNPC npc) {
if (this.playerNPCs.contains(npc)) {
return;
}
this.playerNPCs.add(npc);
getMapFactory().getMap(npc.getMapId()).addMapObject(npc);
}
public final void removePlayerNPC(PlayerNPC npc) {
if (this.playerNPCs.contains(npc)) {
this.playerNPCs.remove(npc);
getMapFactory().getMap(npc.getMapId()).removeMapObject(npc);
}
}
public final String getServerName() {
return this.serverName;
}
public final void setServerName(String sn) {
this.serverName = sn;
}
public final String getTrueServerName() {
return this.serverName.substring(0, this.serverName.length() - (GameConstants.GMS ? 2 : 3));
}
public final int getPort() {
return this.port;
}
public static final Set<Integer> getChannelServer() {
return new HashSet(instances.keySet());
}
public final void setShutdown() {
this.shutdown = true;
System.out.println("Channel " + this.channel + " has set to shutdown and is closing Hired Merchants...");
}
public final void setFinishShutdown() {
this.finishedShutdown = true;
System.out.println("Channel " + this.channel + " has finished shutdown.");
}
public final boolean isAdminOnly() {
return this.adminOnly;
}
public static final int getChannelCount() {
return instances.size();
}
public final int getTempFlag() {
return this.flags;
}
public static Map<Integer, Integer> getChannelLoad() {
Map ret = new HashMap();
for (ChannelServer cs : instances.values()) {
ret.put(Integer.valueOf(cs.getChannel()), Integer.valueOf(cs.getConnectedClients()));
}
return ret;
}
public int getConnectedClients() {
return getPlayerStorage().getConnectedClients();
}
public void broadcastMessage(byte[] message) {
broadcastPacket(message);
}
public void broadcastSmega(byte[] message) {
broadcastSmegaPacket(message);
}
public void broadcastGMMessage(byte[] message) {
broadcastGMPacket(message);
}
public AramiaFireWorks getFireWorks() {
return this.works;
}
public int getTraitRate() {
return this.traitRate;
}
}