Jump to content
  • 0

Help How to set Announce Raidboss spawn to all player by Boss ID


aonniemnoi
 Share

Question

in RaidBossSpawnManager

 

this code. when the raidboss spawn got show announce to all player but.

**The problem is raidboss got spawn  2 raisboss in same location. (spawn double raidboss)**

how to fix it? Thank you some 1 can help me please.ūüėĆ

 -----------------------------------------------------------

 

if ((respawnTime == 0L) || (time > respawnTime))
        {
            L2RaidBossInstance raidboss = null;
            // custom
            if (bossId == 40019)
            {
                raidboss = (L2RaidBossInstance) _spawns.get(bossId).doSpawn();
                Announcements _an = Announcements.getInstance();
¬†¬† ¬†¬†¬† ¬†¬†¬† ¬†¬†¬† ¬†_an.announceToAll("RaidBoss : " + raidboss.getName() + " ŗĻÄŗłĀŗłīŗłĒŗĻĀŗł•ŗĻČŗłß!!!");
            }
            raidboss = (L2RaidBossInstance) spawnDat.doSpawn();
            
            if (raidboss != null)
            {
                raidboss.setCurrentHp(currentHP);
                raidboss.setCurrentMp(currentMP);
                raidboss.setRaidStatus(StatusEnum.ALIVE);
                
                _bosses.put(bossId, raidboss);
                
                final StatsSet info = new StatsSet();
                info.set("currentHP", currentHP);
                info.set("currentMP", currentMP);
                info.set("respawnTime", 0L);
                
                _storedInfo.put(bossId, info);
            }
        }
        else
        {
            final long spawnTime = respawnTime - Calendar.getInstance().getTimeInMillis();
            _schedules.put(bossId, ThreadPoolManager.getInstance().scheduleGeneral(new SpawnSchedule(bossId), spawnTime));
        }
        
        _spawns.put(bossId, spawnDat);
        
        if (storeInDb)
        {
            try (Connection con = L2DatabaseFactory.getInstance().getConnection();
                PreparedStatement statement = con.prepareStatement("INSERT INTO raidboss_spawnlist (boss_id,amount,loc_x,loc_y,loc_z,heading,respawn_time,currentHp,currentMp) VALUES(?,?,?,?,?,?,?,?,?)"))
            {
                statement.setInt(1, spawnDat.getId());
                statement.setInt(2, spawnDat.getAmount());
                statement.setInt(3, spawnDat.getX());
                statement.setInt(4, spawnDat.getY());
                statement.setInt(5, spawnDat.getZ());
                statement.setInt(6, spawnDat.getHeading());
                statement.setLong(7, respawnTime);
                statement.setDouble(8, currentHP);
                statement.setDouble(9, currentMP);
                statement.execute();
            }
            catch (Exception e)
            {
                // problem with storing spawn
                _log.log(Level.WARNING, getClass().getSimpleName() + ": Could not store raidboss #" + bossId + " in the DB:" + e.getMessage(), e);
            }
        }
        // end custom

Edited by aonniemnoi
Link to comment
Share on other sites

14 answers to this question

Recommended Posts

  • 0
8 hours ago, aonniemnoi said:

in RaidBossSpawnManager

 

this code. when the raidboss spawn got show announce to all player but.

**The problem is raidboss got spawn  2 raisboss in same location. (spawn double raidboss)**

how to fix it? Thank you some 1 can help me please.ūüėĆ

 -----------------------------------------------------------

 

if ((respawnTime == 0L) || (time > respawnTime))
        {
            L2RaidBossInstance raidboss = null;
            // custom
            if (bossId == 40019)
            {
                raidboss = (L2RaidBossInstance) _spawns.get(bossId).doSpawn();
                Announcements _an = Announcements.getInstance();
¬†¬† ¬†¬†¬† ¬†¬†¬† ¬†¬†¬† ¬†_an.announceToAll("RaidBoss : " + raidboss.getName() + " ŗĻÄŗłĀŗłīŗłĒŗĻĀŗł•ŗĻČŗłß!!!");
            }
            raidboss = (L2RaidBossInstance) spawnDat.doSpawn();
            
            if (raidboss != null)
            {
                raidboss.setCurrentHp(currentHP);
                raidboss.setCurrentMp(currentMP);
                raidboss.setRaidStatus(StatusEnum.ALIVE);
                
                _bosses.put(bossId, raidboss);
                
                final StatsSet info = new StatsSet();
                info.set("currentHP", currentHP);
                info.set("currentMP", currentMP);
                info.set("respawnTime", 0L);
                
                _storedInfo.put(bossId, info);
            }
        }
        else
        {
            final long spawnTime = respawnTime - Calendar.getInstance().getTimeInMillis();
            _schedules.put(bossId, ThreadPoolManager.getInstance().scheduleGeneral(new SpawnSchedule(bossId), spawnTime));
        }
        
        _spawns.put(bossId, spawnDat);
        
        if (storeInDb)
        {
            try (Connection con = L2DatabaseFactory.getInstance().getConnection();
                PreparedStatement statement = con.prepareStatement("INSERT INTO raidboss_spawnlist (boss_id,amount,loc_x,loc_y,loc_z,heading,respawn_time,currentHp,currentMp) VALUES(?,?,?,?,?,?,?,?,?)"))
            {
                statement.setInt(1, spawnDat.getId());
                statement.setInt(2, spawnDat.getAmount());
                statement.setInt(3, spawnDat.getX());
                statement.setInt(4, spawnDat.getY());
                statement.setInt(5, spawnDat.getZ());
                statement.setInt(6, spawnDat.getHeading());
                statement.setLong(7, respawnTime);
                statement.setDouble(8, currentHP);
                statement.setDouble(9, currentMP);
                statement.execute();
            }
            catch (Exception e)
            {
                // problem with storing spawn
                _log.log(Level.WARNING, getClass().getSimpleName() + ": Could not store raidboss #" + bossId + " in the DB:" + e.getMessage(), e);
            }
        }
        // end custom

Fix written in red:

 

image.png.77d24c97ee0c7be536edbde6cdda3f76.png

Edited by Pleyne
Link to comment
Share on other sites

  • 0

i should delete that?

8 hours ago, zemaitis said:

.doSpawn() mentioned 2 times. Maybe thats the problem?

i should delete that?

 

6 hours ago, Pleyne said:

Fix written in red:

 

image.png.77d24c97ee0c7be536edbde6cdda3f76.png

oh thank you !

Link to comment
Share on other sites

  • 0
3 minutes ago, aonniemnoi said:

i should delete that?

i should delete that?

 

oh thank you !

 

Try deleting and try test what your changes do. We can tell you where to look, but you have to try things for yourself bro.

Link to comment
Share on other sites

  • 0
4 minutes ago, zemaitis said:

 

Try deleting and try test what your changes do. We can tell you where to look, but you have to try things for yourself bro.

i am new of java i will learning bro thank you very much!

Link to comment
Share on other sites

  • 0
1 minute ago, aonniemnoi said:

i am new of java i will learning bro thank you very much!

 

yes no problem mate just keep trying and dont be afraid of breaking stuff.

Link to comment
Share on other sites

  • 0
1 hour ago, zemaitis said:

 

yes no problem mate just keep trying and dont be afraid of breaking stuff.

i try it already got show this error...

 

com.l2jserver.gameserver.instancemanager.RaidBossSpawnManager addNewSpawn
WARNING: RaidBossSpawnManager: Could not store raidboss #40019 in the DB:Duplicate entry '40019' for key 'PRIMARY'
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '40019' for key 'PRIMARY'
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:408)
    at com.mysql.jdbc.Util.getInstance(Util.java:383)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1049)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4226)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4158)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2615)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2776)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2840)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082)
    at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1302)
    at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.execute(NewProxyPreparedStatement.java:404)
    at com.l2jserver.gameserver.instancemanager.RaidBossSpawnManager.addNewSpawn(RaidBossSpawnManager.java:352)
    at handlers.admincommandhandlers.AdminSpawn.spawnMonster(AdminSpawn.java:448)
    at handlers.admincommandhandlers.AdminSpawn.useAdminCommand(AdminSpawn.java:271)
    at com.l2jserver.gameserver.network.clientpackets.SendBypassBuildCmd.runImpl(SendBypassBuildCmd.java:87)
    at com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket.run(L2GameClientPacket.java:70)
    at com.l2jserver.gameserver.network.L2GameClient.run(L2GameClient.java:1148)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

Link to comment
Share on other sites

  • 0
15 minutes ago, aonniemnoi said:

 

 


WARNING: RaidBossSpawnManager: Could not store raidboss #40019 in the DB:Duplicate entry '40019' for key 'PRIMARY'
 

The Raidboss ID is already existing in your database. Try deleting it, as it tries to duplicate it.

Edited by splicho
Link to comment
Share on other sites

  • 0
2 minutes ago, splicho said:

The Raidboss ID is already existing in your database. Try deleting it, as it tries to duplicate it.

i try to spawn id 40019 i got this error. and the boss  come 2

 

RaidBossSpawnManager: Could not store raidboss #40019 in the DB:Duplicate entry '40019' for key 'PRIMARY'
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '40019' for key 'PRIMARY'
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:408)
        at com.mysql.jdbc.Util.getInstance(Util.java:383)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1049)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4226)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4158)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2615)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2776)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2840)
        at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082)
        at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1302)
        at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.execute(NewProxyPreparedStatement.java:404)
        at com.l2jserver.gameserver.instancemanager.RaidBossSpawnManager.addNewSpawn(RaidBossSpawnManager.java:352)
        at handlers.admincommandhandlers.AdminSpawn.spawnMonster(AdminSpawn.java:448)
        at handlers.admincommandhandlers.AdminSpawn.useAdminCommand(AdminSpawn.java:271)
        at com.l2jserver.gameserver.network.clientpackets.SendBypassBuildCmd.runImpl(SendBypassBuildCmd.java:87)
        at com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket.run(L2GameClientPacket.java:70)
        at com.l2jserver.gameserver.network.L2GameClient.run(L2GameClient.java:1148)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

Edited by aonniemnoi
Link to comment
Share on other sites

  • 0
1 hour ago, aonniemnoi said:

i try to spawn id 40019 i got this error. and the boss  come 2

 

RaidBossSpawnManager: Could not store raidboss #40019 in the DB:Duplicate entry '40019' for key 'PRIMARY'
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '40019' for key 'PRIMARY'
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:408)
        at com.mysql.jdbc.Util.getInstance(Util.java:383)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1049)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4226)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4158)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2615)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2776)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2840)
        at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082)
        at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1302)
        at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.execute(NewProxyPreparedStatement.java:404)
        at com.l2jserver.gameserver.instancemanager.RaidBossSpawnManager.addNewSpawn(RaidBossSpawnManager.java:352)
        at handlers.admincommandhandlers.AdminSpawn.spawnMonster(AdminSpawn.java:448)
        at handlers.admincommandhandlers.AdminSpawn.useAdminCommand(AdminSpawn.java:271)
        at com.l2jserver.gameserver.network.clientpackets.SendBypassBuildCmd.runImpl(SendBypassBuildCmd.java:87)
        at com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket.run(L2GameClientPacket.java:70)
        at com.l2jserver.gameserver.network.L2GameClient.run(L2GameClient.java:1148)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

Delete the Raidbross Spawn from your Database..... 

Link to comment
Share on other sites

  • 0
9 hours ago, splicho said:

Delete the Raidbross Spawn from your Database..... 

same... i delete already on raidboss_spawnlist

when i do  //spawn 40019  also come 2  T_T

Link to comment
Share on other sites

  • 0

Did you check in your database if raidboss 40019 was already spawned ? just clear raidboss_spawnlist table and restart server and try again  maybe it is already in db and when you try to spawn it again you get duplicate id error from mysql and then shit happens and 2 bosses are spawned ? 

Edited by arm4729
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



√ó
√ó
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disbaled AdBlock