Results 1 to 8 of 8
  1. #1
    rairaven is offline Member
    Join Date
    Aug 2009
    Posts
    3
    Rep Power
    0

    Default main java lang bla bla bla pls help me

    Aug 30, 2009 12:44:11 AM net.sf.odinms.net.login.LoginServer run
    INFO: Listening on port 8484
    Aug 30, 2009 12:44:15 AM net.sf.odinms.net.channel.ChannelServer run
    INFO: Channel 1: Listening on port 7575
    Aug 30, 2009 12:44:15 AM net.sf.odinms.net.world.WorldChannelInterfaceImpl serve
    rReady
    INFO: Channel 1 is online.
    Exception in thread "main" java.lang.NullPointerException
    at net.sf.odinms.scripting.event.EventScriptManager.i nit(EventScriptMana
    ger.java:54)
    at net.sf.odinms.net.channel.ChannelServer.run(Channe lServer.java:293)
    at net.sf.odinms.net.channel.ChannelServer.main(Chann elServer.java:640)


    that is the error i get

  2. #2
    Evil Smurf is offline Member
    Join Date
    Aug 2009
    Posts
    6
    Rep Power
    0

    Default

    Why don't you provide the code that you've written. It would probably help.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    NullPointerException, somewhere in your code (EventScriptMana ger.java:54) value set to null. Why don't your debug your code and see.

    Yes, at the same time provide more details if you are looking some help. Just looking at your error message we cannot provide more details.

  4. #4
    rairaven is offline Member
    Join Date
    Aug 2009
    Posts
    3
    Rep Power
    0

    Default here

    this is my channelserver.java

    package net.sf.odinms.net.channel;

    import java.awt.Point;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    import java.lang.management.ManagementFactory;
    import java.net.InetSocketAddress;
    import java.rmi.NotBoundException;
    import java.rmi.RemoteException;
    import java.rmi.registry.LocateRegistry;
    import java.rmi.registry.Registry;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    import java.util.Arrays;
    import java.util.Collection;
    import java.util.Collections;
    import java.util.HashMap;
    import java.util.LinkedList;
    import java.util.List;
    import java.util.Map;
    import java.util.Properties;
    import javax.management.InstanceAlreadyExistsException;
    import javax.management.MBeanRegistrationException;
    import javax.management.MBeanServer;
    import javax.management.MalformedObjectNameException;
    import javax.management.NotCompliantMBeanException;
    import javax.management.ObjectName;
    import javax.rmi.ssl.SslRMIClientSocketFactory;
    import net.sf.odinms.client.AutoRegister;
    import net.sf.odinms.client.MapleCharacter;
    import net.sf.odinms.client.messages.CommandProcessor;
    import net.sf.odinms.database.DatabaseConnection;
    import net.sf.odinms.net.MaplePacket;
    import net.sf.odinms.net.MapleServerHandler;
    import net.sf.odinms.net.PacketProcessor;
    import net.sf.odinms.net.channel.remote.ChannelWorldInter face;
    import net.sf.odinms.net.mina.MapleCodecFactory;
    import net.sf.odinms.net.world.MapleParty;
    import net.sf.odinms.net.world.guild.MapleGuild;
    import net.sf.odinms.net.world.guild.MapleGuildCharacter;
    import net.sf.odinms.net.world.guild.MapleGuildSummary;
    import net.sf.odinms.net.world.remote.WorldChannelInterfa ce;
    import net.sf.odinms.net.world.remote.WorldRegistry;
    import net.sf.odinms.provider.MapleDataProviderFactory;
    import net.sf.odinms.scripting.event.EventScriptManager;
    import net.sf.odinms.server.AutobanManager;
    import net.sf.odinms.server.ClanHolder;
    import net.sf.odinms.server.MapleSquad;
    import net.sf.odinms.server.MapleSquadType;
    import net.sf.odinms.server.MapleTrade;
    import net.sf.odinms.server.PlayerInteraction.HiredMercha nt;
    import net.sf.odinms.server.ShutdownServer;
    import net.sf.odinms.server.TimerManager;
    import net.sf.odinms.server.maps.FakeCharacter;
    import net.sf.odinms.server.maps.MapleMapFactory;
    import net.sf.odinms.server.maps.MapleMapObject;
    import net.sf.odinms.server.maps.MapleMapObjectType;
    import net.sf.odinms.tools.MaplePacketCreator;
    import org.apache.mina.common.ByteBuffer;
    import org.apache.mina.common.CloseFuture;
    import org.apache.mina.common.IoAcceptor;
    import org.apache.mina.common.SimpleByteBufferAllocator;
    import org.apache.mina.filter.codec.ProtocolCodecFilter;
    import org.apache.mina.transport.socket.nio.SocketAccepto r;
    import org.apache.mina.transport.socket.nio.SocketAccepto rConfig;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;

    public class ChannelServer implements Runnable, ChannelServerMBean {

    private static int uniqueID = 1;
    private int port = 7575;
    private static Properties initialProp;
    private static final Logger log = LoggerFactory.getLogger(ChannelServer.class);
    //private static ThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(5);
    private static WorldRegistry worldRegistry;
    private PlayerStorage players = new PlayerStorage();
    // private Map<String, MapleCharacter> clients = new LinkedHashMap<String, MapleCharacter>();
    private String serverMessage;
    private String welcomeMessage;
    private int expRate;
    private int mesoRate;
    private int dropRate;
    private int bossdropRate;
    private int petExpRate;
    // private int mapid;
    private boolean dropUndroppables;
    private boolean moreThanOne;
    /* private String skillMaxer;
    private boolean jobAdvancer;
    private String statResetter;
    private String buyNX; */
    private int channel;
    private int instanceId = 0;
    private String key;
    private Properties props = new Properties();
    private ChannelWorldInterface cwi;
    private AutoRegister regi;
    private WorldChannelInterface wci = null;
    private IoAcceptor acceptor;
    private String ip;
    private boolean shutdown = false;
    private boolean finishedShutdown = false;
    private String arrayString = "";
    private String serverName;
    private boolean godlyItems;
    private boolean cooldowns;
    private short itemStatMultiplier;
    private short pvpChannel;
    public boolean eventOn = false;
    public int eventMap = 0;
    // private int spawnRate;
    private short godlyItemRate;
    private MapleMapFactory mapFactory;
    private EventScriptManager eventSM;
    private static Map<Integer, ChannelServer> instances = new HashMap<Integer, ChannelServer>();
    private static Map<String, ChannelServer> pendingInstances = new HashMap<String, ChannelServer>();
    private Map<Integer, MapleGuildSummary> gsStore = new HashMap<Integer, MapleGuildSummary>();
    private Boolean worldReady = true;
    private Map<MapleSquadType, MapleSquad> mapleSquads = new HashMap<MapleSquadType, MapleSquad>();
    private ClanHolder clans = new ClanHolder();
    private Collection<FakeCharacter> clones = new LinkedList<FakeCharacter>();

    private ChannelServer(String key) {
    mapFactory = new MapleMapFactory(MapleDataProviderFactory.getDataPr ovider(new File(System.getProperty("net.sf.odinms.wzpath") + "/Map.wz")), MapleDataProviderFactory.getDataProvider(new File(System.getProperty("net.sf.odinms.wzpath") + "/String.wz")));
    this.key = key;
    }

    public static WorldRegistry getWorldRegistry() {
    return worldRegistry;
    }

    public void reconnectWorld() {
    // check if the connection is really gone
    try {
    wci.isAvailable();
    } catch (RemoteException ex) {
    synchronized (worldReady) {
    worldReady = false;
    }
    synchronized (cwi) {
    synchronized (worldReady) {
    if (worldReady) {
    return;
    }
    }
    log.warn("Reconnecting to world server");
    synchronized (wci) {
    // completely re-establish the rmi connection
    try {
    initialProp = new Properties();
    FileReader fr = new FileReader(System.getProperty("net.sf.odinms.chann el.config"));
    initialProp.load(fr);
    fr.close();
    Registry registry = LocateRegistry.getRegistry(initialProp.getProperty ("net.sf.odinms.world.host"),
    Registry.REGISTRY_PORT, new SslRMIClientSocketFactory());
    worldRegistry = (WorldRegistry) registry.lookup("WorldRegistry");
    cwi = new ChannelWorldInterfaceImpl(this);
    wci = worldRegistry.registerChannelServer(key, cwi);
    props = wci.getGameProperties();
    expRate = Integer.parseInt(props.getProperty("net.sf.odinms. world.exp"));
    mesoRate = Integer.parseInt(props.getProperty("net.sf.odinms. world.meso"));
    dropRate = Integer.parseInt(props.getProperty("net.sf.odinms. world.drop"));
    bossdropRate = Integer.parseInt(props.getProperty("net.sf.odinms. world.bossdrop"));
    petExpRate = Integer.parseInt(props.getProperty("net.sf.odinms. world.petExp"));
    // mapid = Integer.parseInt(props.getProperty("net.sf.odinms. world.mapid"));
    serverMessage = props.getProperty("net.sf.odinms.world.serverMessa ge");
    welcomeMessage = props.getProperty("net.sf.odinms.world.welcomeMess age");
    dropUndroppables = Boolean.parseBoolean(props.getProperty("net.sf.odi nms.world.alldrop", "false"));
    moreThanOne = Boolean.parseBoolean(props.getProperty("net.sf.odi nms.world.morethanone", "false"));
    /* skillMaxer = props.getProperty("net.sf.odinms.world.skillMaxer" );
    jobAdvancer = Boolean.parseBoolean(props.getProperty("net.sf.odi nms.world.jobadvancer", "false"));
    statResetter = props.getProperty("net.sf.odinms.world.statResette r");
    buyNX = props.getProperty("net.sf.odinms.world.buyNX"); */
    serverName = props.getProperty("net.sf.odinms.world.serverName" );
    godlyItems = Boolean.parseBoolean(props.getProperty("net.sf.odi nms.world.godlyItems", "false"));
    cooldowns = Boolean.parseBoolean(props.getProperty("net.sf.odi nms.world.cooldowns", "false"));
    itemStatMultiplier = Short.parseShort(props.getProperty("net.sf.odinms. world.itemStatMultiplier"));
    pvpChannel = Short.parseShort(props.getProperty("net.sf.odinms. world.pvpchannel"));
    // spawnRate = Integer.parseInt(props.getProperty("net.sf.odinms. world.spawnRate"));
    godlyItemRate = Short.parseShort(props.getProperty("net.sf.odinms. world.godlyItemRate"));
    Properties dbProp = new Properties();
    fr = new FileReader("db.properties");
    dbProp.load(fr);
    fr.close();
    DatabaseConnection.setProps(dbProp);
    DatabaseConnection.getConnection();
    wci.serverReady();
    } catch (Exception e) {
    log.error("Reconnecting failed", e);
    }
    worldReady = true;
    }
    }
    synchronized (worldReady) {
    worldReady.notifyAll();
    }
    }
    }

    @Override
    public void run() {
    try {
    cwi = new ChannelWorldInterfaceImpl(this);
    wci = worldRegistry.registerChannelServer(key, cwi);
    props = wci.getGameProperties();
    expRate = Integer.parseInt(props.getProperty("net.sf.odinms. world.exp"));
    mesoRate = Integer.parseInt(props.getProperty("net.sf.odinms. world.meso"));
    dropRate = Integer.parseInt(props.getProperty("net.sf.odinms. world.drop"));
    bossdropRate = Integer.parseInt(props.getProperty("net.sf.odinms. world.bossdrop"));
    petExpRate = Integer.parseInt(props.getProperty("net.sf.odinms. world.petExp"));
    // mapid = Integer.parseInt(props.getProperty("net.sf.odinms. world.mapid"));
    serverMessage = props.getProperty("net.sf.odinms.world.serverMessa ge");
    welcomeMessage = props.getProperty("net.sf.odinms.world.welcomeMess age");
    dropUndroppables = Boolean.parseBoolean(props.getProperty("net.sf.odi nms.world.alldrop", "false"));
    moreThanOne = Boolean.parseBoolean(props.getProperty("net.sf.odi nms.world.morethanone", "false"));
    /* skillMaxer = props.getProperty("net.sf.odinms.world.skillMaxer" );
    jobAdvancer = Boolean.parseBoolean(props.getProperty("net.sf.odi nms.world.jobadvancer", "false"));
    statResetter = props.getProperty("net.sf.odinms.world.statResette r");
    buyNX = props.getProperty("net.sf.odinms.world.buyNX"); */
    eventSM = new EventScriptManager(this, props.getProperty("net.sf.odinms.channel.events"). split(","));
    serverName = props.getProperty("net.sf.odinms.world.serverName" );
    godlyItems = Boolean.parseBoolean(props.getProperty("net.sf.odi nms.world.godlyItems", "false"));
    cooldowns = Boolean.parseBoolean(props.getProperty("net.sf.odi nms.world.cooldowns", "false"));
    itemStatMultiplier = Short.parseShort(props.getProperty("net.sf.odinms. world.itemStatMultiplier"));
    pvpChannel = Short.parseShort(props.getProperty("net.sf.odinms. world.pvpChannel"));
    // spawnRate = Integer.parseInt(props.getProperty("net.sf.odinms. world.spawnRate"));
    godlyItemRate = Short.parseShort(props.getProperty("net.sf.odinms. world.godlyItemRate"));
    Properties dbProp = new Properties();
    FileReader fileReader = new FileReader("db.properties");
    dbProp.load(fileReader);
    fileReader.close();
    DatabaseConnection.setProps(dbProp);
    DatabaseConnection.getConnection();
    Connection c = DatabaseConnection.getConnection();
    PreparedStatement ps;
    try {
    ps = c.prepareStatement("UPDATE accounts SET loggedin = 0");
    ps.executeUpdate();
    ps = c.prepareStatement("UPDATE characters SET HasMerchant = 0");
    ps.executeUpdate();
    ps = c.prepareStatement("DELETE FROM accounts where guest = 1");
    ps.executeUpdate();
    ps.close();
    } catch (SQLException ex) {
    log.error("Could not reset databases", ex);
    }
    } catch (Exception e) {
    throw new RuntimeException(e);
    }
    port = Integer.parseInt(props.getProperty("net.sf.odinms. channel.net.port"));
    ip = props.getProperty("net.sf.odinms.channel.net.inter face") + ":" + port;
    ByteBuffer.setUseDirectBuffers(false);
    ByteBuffer.setAllocator(new SimpleByteBufferAllocator());
    acceptor = new SocketAcceptor();
    SocketAcceptorConfig cfg = new SocketAcceptorConfig();
    // cfg.setThreadModel(ThreadModel.MANUAL); // *fingers crossed*, I hope the executor filter handles everything
    // executor = new ThreadPoolExecutor(16, 16, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
    // cfg.getFilterChain().addLast("executor", new ExecutorFilter(executor));
    cfg.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MapleCodecFactory()));
    // Item.loadInitialDataFromDB();
    TimerManager tMan = TimerManager.getInstance();
    tMan.start();
    tMan.register(AutobanManager.getInstance(), 60000);
    try {
    MapleServerHandler serverHandler = new MapleServerHandler(PacketProcessor.getProcessor(Pa cketProcessor.Mode.CHANNELSERVER), channel);
    acceptor.bind(new InetSocketAddress(port), serverHandler, cfg);
    log.info("Channel {}: Listening on port {}", getChannel(), port);
    wci.serverReady();
    eventSM.init();
    } catch (IOException e) {
    log.error("Binding to port " + port + " failed (ch: " + getChannel() + ")", e);
    }
    Runtime.getRuntime().addShutdownHook(new MapleShutdownHook());

    }

    public void shutdown() {
    // dc all clients by hand so we get sessionClosed...
    shutdown = true;
    List<CloseFuture> futures = new LinkedList<CloseFuture>();
    Collection<MapleCharacter> allchars = players.getAllCharacters();
    MapleCharacter chrs[] = allchars.toArray(new MapleCharacter[allchars.size()]);
    for (MapleCharacter chr : chrs) {
    if (chr.getTrade() != null) {
    MapleTrade.cancelTrade(chr);
    }
    if (chr.getEventInstance() != null) {
    chr.getEventInstance().playerDisconnected(chr);
    }
    if (!chr.getClient().isGuest()) {
    chr.saveToDB(true, true);
    }
    if (chr.getCheatTracker() != null) {
    chr.getCheatTracker().dispose();
    }
    removePlayer(chr);
    }
    for (MapleCharacter chr : chrs) {
    futures.add(chr.getClient().getSession().close());
    }
    for (CloseFuture future : futures) {
    future.join(500);
    }
    finishedShutdown = true;
    wci = null;
    cwi = null;
    }

    public void unbind() {
    acceptor.unbindAll();
    }


    public boolean hasFinishedShutdown() {
    return finishedShutdown;
    }

    public MapleMapFactory getMapFactory() {
    return mapFactory;
    }

    public static ChannelServer newInstance(String key) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, MalformedObjectNameException {
    ChannelServer instance = new ChannelServer(key);
    MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
    mBeanServer.registerMBean(instance, new ObjectName("net.sf.odinms.net.channel:type=Channel Server,name=ChannelServer" + uniqueID++));
    pendingInstances.put(key, instance);
    return instance;
    }

    public static ChannelServer getInstance(int channel) {
    return instances.get(channel);
    }

    public void addPlayer(MapleCharacter chr) {
    players.registerPlayer(chr);
    if (chr.getClan() > -1) {
    clans.playerOnline(chr);
    }
    }

    public IPlayerStorage getPlayerStorage() {
    return players;
    }

    public void removePlayer(MapleCharacter chr) {
    players.deregisterPlayer(chr);
    if (chr.getClan() > -1) {
    clans.deregisterPlayer(chr);
    }
    }

    public void addToClan(MapleCharacter chr) {
    clans.registerPlayer(chr);
    }

    public ClanHolder getClanHolder() {
    return clans;
    }

    public int getConnectedClients() {
    return players.getAllCharacters().size();
    }

    @Override
    public String getServerMessage() {
    return serverMessage;
    }

    @Override
    public void setServerMessage(String newMessage) {
    serverMessage = newMessage;
    broadcastPacket(MaplePacketCreator.serverMessage(s erverMessage));
    }


    public String getWelcomeMessage() {
    return welcomeMessage;
    }


    public void broadcastPacket(MaplePacket data) {
    for (MapleCharacter chr : players.getAllCharacters()) {
    chr.getClient().getSession().write(data);
    }
    }

    @Override
    public int getExpRate() {
    return expRate;
    }

    @Override
    public void setExpRate(int expRate) {
    this.expRate = expRate;
    }

    public String getArrayString() {
    //If you are wondering, this is for the !array command
    return arrayString;
    }

    public void setArrayString(String newStr) {
    arrayString = newStr;
    }

    public int getChannel() {
    return channel;
    }

    public void setChannel(int channel) {
    if (pendingInstances.containsKey(key)) {
    pendingInstances.remove(key);
    }
    if (instances.containsKey(channel)) {
    instances.remove(channel);
    }
    instances.put(channel, this);
    this.channel = channel;
    this.mapFactory.setChannel(channel);
    }

    public static Collection<ChannelServer> getAllInstances() {
    return Collections.unmodifiableCollection(instances.value s());
    }

    public String getIP() {
    return ip;
    }

    public String getIP(int channel) {
    try {
    return getWorldInterface().getIP(channel);
    } catch (RemoteException e) {
    log.error("Lost connection to world server", e);
    throw new RuntimeException("Lost connection to world server");
    }
    }

    public WorldChannelInterface getWorldInterface() {
    synchronized (worldReady) {
    while (!worldReady) {
    try {
    worldReady.wait();
    } catch (InterruptedException e) {
    }
    }
    }
    return wci;
    }

    public String getProperty(String name) {
    return props.getProperty(name);
    }

    public boolean isShutdown() {
    return shutdown;
    }

    @Override
    public void shutdown(int time) {
    broadcastPacket(MaplePacketCreator.serverNotice(0, "The world will be shut down in " + (time / 60000) + " minutes, please log off safely"));
    TimerManager.getInstance().schedule(new ShutdownServer(getChannel()), time);
    }

    @Override
    public void shutdownWorld(int time) {
    try {
    getWorldInterface().shutdown(time);
    } catch (RemoteException e) {
    reconnectWorld();
    }
    }

    public int getLoadedMaps() {
    return mapFactory.getLoadedMaps();
    }

    public EventScriptManager getEventSM() {
    return eventSM;
    }

    public void reloadEvents() {
    eventSM.cancel();
    eventSM = new EventScriptManager(this, props.getProperty("net.sf.odinms.channel.events"). split(","));
    eventSM.init();
    }

    @Override
    public int getMesoRate() {
    return mesoRate;
    }

    @Override
    public void setMesoRate(int mesoRate) {
    this.mesoRate = mesoRate;
    }

    @Override
    public int getDropRate() {
    return dropRate;
    }

    @Override
    public void setDropRate(int dropRate) {
    this.dropRate = dropRate;
    }

    @Override
    public int getBossDropRate() {
    return bossdropRate;
    }

    @Override
    public void setBossDropRate(int bossdropRate) {
    this.bossdropRate = bossdropRate;
    }

    @Override
    public int getPetExpRate() {
    return petExpRate;
    }


    @Override
    public void setPetExpRate(int petExpRate) {
    this.petExpRate = petExpRate;
    }

    public boolean allowUndroppablesDrop() {
    return dropUndroppables;
    }

    public boolean allowMoreThanOne() {
    return moreThanOne;
    }

    /* public String allowSkillMaxer() {
    return skillMaxer;
    }

    public boolean allowJobAdvancer() {
    return jobAdvancer;
    }
    public String allowStatResetter() {
    return statResetter;
    }

    public String allowNxNpc() {
    return buyNX;
    } */



    public MapleGuild getGuild(MapleGuildCharacter mgc) {
    int gid = mgc.getGuildId();
    MapleGuild g = null;
    try {
    g = this.getWorldInterface().getGuild(gid, mgc);
    } catch (RemoteException re) {
    log.error("RemoteException while fetching MapleGuild.", re);
    return null;
    }

    if (gsStore.get(gid) == null) {
    gsStore.put(gid, new MapleGuildSummary(g));
    }

    return g;
    }

    public MapleGuildSummary getGuildSummary(int gid) {
    if (gsStore.containsKey(gid)) {
    return gsStore.get(gid);
    } else { //this shouldn't happen much, if ever, but if we're caught
    //without the summary, we'll have to do a worldop
    try {
    MapleGuild g = this.getWorldInterface().getGuild(gid, null);
    if (g != null) {
    gsStore.put(gid, new MapleGuildSummary(g));
    }
    return gsStore.get(gid); //if g is null, we will end up returning null
    } catch (RemoteException re) {
    log.error("RemoteException while fetching GuildSummary.", re);
    return null;
    }
    }
    }

    public void updateGuildSummary(int gid, MapleGuildSummary mgs) {
    gsStore.put(gid, mgs);
    }

    public void reloadGuildSummary() {
    try {
    MapleGuild g;
    for (int i : gsStore.keySet()) {
    g = this.getWorldInterface().getGuild(i, null);
    if (g != null) {
    gsStore.put(i, new MapleGuildSummary(g));
    } else {
    gsStore.remove(i);
    }
    }
    } catch (RemoteException re) {
    log.error("RemoteException while reloading GuildSummary.", re);
    }
    }


    public static void main(String args[]) throws FileNotFoundException, IOException, NotBoundException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, MalformedObjectNameException {
    initialProp = new Properties();
    initialProp.load(new FileReader(System.getProperty("net.sf.odinms.chann el.config")));
    Registry registry = LocateRegistry.getRegistry(initialProp.getProperty ("net.sf.odinms.world.host"), Registry.REGISTRY_PORT, new SslRMIClientSocketFactory());
    worldRegistry = (WorldRegistry) registry.lookup("WorldRegistry");
    for (int i = 0; i < Integer.parseInt(initialProp.getProperty("net.sf.o dinms.channel.count", "0")); i++) {
    newInstance(initialProp.getProperty("net.sf.odinms .channel." + i + ".key")).run();
    }
    DatabaseConnection.getConnection(); // touch - so we see database problems early...
    CommandProcessor.registerMBean();
    ClanHolder.loadAllClans();
    Runtime.getRuntime().addShutdownHook(new Thread() {

    @Override
    public void run() {
    for (ChannelServer channel : getAllInstances()) {
    for (int i = 910000001; i <= 910000022; i++) {
    for (MapleMapObject obj : channel.getMapFactory().getMap(i).getMapObjectsInR ange(new Point(0, 0), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.HIRED_MERCHANT))) {
    HiredMerchant hm = (HiredMerchant) obj;
    hm.closeShop(true);
    }
    }
    for (MapleCharacter mc : channel.getPlayerStorage().getAllCharacters()) {
    mc.saveToDB(true, true);
    }
    }
    }
    });
    }

    public int getInstanceId() {
    return instanceId;
    }

    /* public int getStarterMap() {
    return mapid;
    } */


    public void setInstanceId(int k) {
    instanceId = k;
    }

    public void addInstanceId() {
    instanceId++;
    }

    public MapleSquad getMapleSquad(MapleSquadType type) {
    return mapleSquads.get(type);
    }

    public boolean addMapleSquad(MapleSquad squad, MapleSquadType type) {
    if (mapleSquads.get(type) == null) {
    mapleSquads.remove(type);
    mapleSquads.put(type, squad);
    return true;
    } else {
    return false;
    }
    }

    public boolean removeMapleSquad(MapleSquad squad, MapleSquadType type) {
    if (mapleSquads.containsKey(type)) {
    if (mapleSquads.get(type) == squad) {
    mapleSquads.remove(type);
    return true;
    }
    }
    return false;
    }

    public boolean isGodlyItems() {
    return godlyItems;
    }

    public void setGodlyItems(boolean blahblah) {
    this.godlyItems = blahblah;
    }

    public boolean getCooldowns() {
    return cooldowns;
    }

    public short getItemMultiplier() {
    return itemStatMultiplier;
    }

    public void setItemMultiplier(Short blahblah) {
    this.itemStatMultiplier = blahblah;
    }

    public short getPvpChannel() {
    return pvpChannel;
    }

    public void setPvpChannel(Short blahblah) {
    this.pvpChannel = blahblah;
    }

    /* public int getSpawnRate() {
    return spawnRate;
    }

    public void setSpawnRate(Short blahblah) {
    this.spawnRate = blahblah;
    } */

    public short getGodlyItemRate() {
    return godlyItemRate;
    }

    public void setGodlyItemRate(Short blahblah) {
    this.godlyItemRate = blahblah;
    }

    public void broadcastSMega(MaplePacket data) {
    for (MapleCharacter chr : players.getAllCharacters()) {
    if (chr.getSmegaEnabled()) {
    chr.getClient().getSession().write(data);
    }
    }
    }

    public void broadcastGMPacket(MaplePacket data) {
    for (MapleCharacter chr : players.getAllCharacters()) {
    if (chr.isGM()) {
    chr.getClient().getSession().write(data);
    }
    }
    }

    public String getServerName() {
    return serverName;
    }

    public void broadcastToClan(MaplePacket data, int clan) {
    for (MapleCharacter chr : clans.getAllOnlinePlayersFromClan(clan)) {
    chr.getClient().getSession().write(data);
    }
    }

    public int onlineClanMembers(int clan) {
    return clans.countOnlineByClan(clan);
    }

    public List<MapleCharacter> getPartyMembers(MapleParty party) {
    List<MapleCharacter> partym = new LinkedList<MapleCharacter>();
    for (net.sf.odinms.net.world.MaplePartyCharacter partychar : party.getMembers()) {
    if (partychar.getChannel() == getChannel()) { // Make sure the thing doesn't get duplicate plays due to ccing bug.
    MapleCharacter chr = getPlayerStorage().getCharacterByName(partychar.ge tName());
    if (chr != null) {
    partym.add(chr);
    }
    }
    }
    return partym;
    }

    public void addClone(FakeCharacter fc) {
    clones.add(fc);
    }

    public void removeClone(FakeCharacter fc) {
    clones.remove(fc);
    }

    public Collection<FakeCharacter> getAllClones() {
    return clones;
    }
    public void returnItems() {

    }

    public class MapleShutdownHook extends Thread {
    public void run() {
    for (ChannelServer cs : ChannelServer.getAllInstances()) {
    for (MapleCharacter chr : cs.getPlayerStorage().getAllCharacters()) {
    chr.saveToDB(true, true);
    try {
    chr.getMerchant().saveItems();
    } catch (SQLException sqle) {}
    }
    }
    }
    }
    }


    ---------------------------------------------
    eventscriptmanager.java

    package net.sf.odinms.scripting.event;

    import java.util.LinkedHashMap;
    import java.util.Map;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.script.Invocable;
    import javax.script.ScriptEngine;
    import javax.script.ScriptException;
    import net.sf.odinms.net.channel.ChannelServer;
    import net.sf.odinms.scripting.AbstractScriptManager;

    /**
    *
    * @author Matze
    */
    public class EventScriptManager extends AbstractScriptManager {

    private class EventEntry {

    public EventEntry(String script, Invocable iv, EventManager em) {
    this.script = script;
    this.iv = iv;
    this.em = em;
    }
    public String script;
    public Invocable iv;
    public EventManager em;
    }
    private Map<String, EventEntry> events = new LinkedHashMap<String, EventEntry>();

    public EventScriptManager(ChannelServer cserv, String[] scripts) {
    super();
    for (String script : scripts) {
    if (!script.equals("")) {
    Invocable iv = getInvocable("event/" + script + ".js", null);
    events.put(script, new EventEntry(script, iv, new EventManager(cserv, iv, script)));
    }
    }
    }

    public EventManager getEventManager(String event) {
    EventEntry entry = events.get(event);
    if (entry == null) {
    return null;
    }
    return entry.em;
    }

    public void init() {
    for (EventEntry entry : events.values()) {
    try {
    ((ScriptEngine) entry.iv).put("em", entry.em);
    entry.iv.invokeFunction("init", (Object) null);
    } catch (ScriptException ex) {
    Logger.getLogger(EventScriptManager.class.getName( )).log(Level.SEVERE, null, ex);
    } catch (NoSuchMethodException ex) {
    Logger.getLogger(EventScriptManager.class.getName( )).log(Level.SEVERE, null, ex);
    }
    }
    }

    public void cancel() {
    for (EventEntry entry : events.values()) {
    entry.em.cancel();
    }
    }
    }
    Last edited by rairaven; 08-30-2009 at 03:54 AM.

  5. #5
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    You didn't have to post all that code. Just have a look at the line numbers reported for the error. You have

    ((ScriptEngine) entry.iv).put("em", entry.em);
    entry.iv.invokeFunction("init", (Object) null);

    Either entry or entry.iv is null just before those lines in the code.
    Put some System.out.printlns to find out which one.
    PS: Why are you casting that null to Object?

  6. #6
    rairaven is offline Member
    Join Date
    Aug 2009
    Posts
    3
    Rep Power
    0

    Default ms

    that is a maplestory repack....erm can u teach me more?i m not really understand ur last post,thx anyway

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Huh, how can we check this much of code. And also it's not formatted, so hard to read it. Please use the code tag next time, and also post only the relative code segment.

  8. #8
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Quote Originally Posted by rairaven View Post
    that is a maplestory repack....erm can u teach me more?i m not really understand ur last post,thx anyway
    Actually I thought I was being very clear. Which specific parts of my post did you not understand.

Similar Threads

  1. Replies: 6
    Last Post: 07-16-2009, 03:30 PM
  2. Replies: 1
    Last Post: 07-16-2009, 10:35 AM
  3. Using Eclipse IDE:java.lang.NoClassDefFoundError: main
    By Ms.Ranjan in forum New To Java
    Replies: 6
    Last Post: 12-12-2008, 10:17 PM
  4. Replies: 1
    Last Post: 08-07-2007, 07:10 AM
  5. Replies: 1
    Last Post: 08-06-2007, 09:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •