aonniemnoi Posted September 27, 2021 Posted September 27, 2021 (edited) 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 September 27, 2021 by aonniemnoi Quote
0 zemaitis Posted September 27, 2021 Posted September 27, 2021 .doSpawn() mentioned 2 times. Maybe thats the problem? Quote
0 Pleyne Posted September 27, 2021 Posted September 27, 2021 (edited) On 9/27/2021 at 12:50 AM, 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 Expand Fix written in red: Edited September 27, 2021 by Pleyne Quote
0 aonniemnoi Posted September 27, 2021 Author Posted September 27, 2021 i should delete that? On 9/27/2021 at 7:09 AM, zemaitis said: .doSpawn() mentioned 2 times. Maybe thats the problem? Expand i should delete that? On 9/27/2021 at 8:53 AM, Pleyne said: Fix written in red: Expand oh thank you ! Quote
0 zemaitis Posted September 27, 2021 Posted September 27, 2021 On 9/27/2021 at 3:23 PM, aonniemnoi said: i should delete that? i should delete that? oh thank you ! Expand 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. Quote
0 aonniemnoi Posted September 27, 2021 Author Posted September 27, 2021 On 9/27/2021 at 3:27 PM, 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. Expand i am new of java i will learning bro thank you very much! Quote
0 zemaitis Posted September 27, 2021 Posted September 27, 2021 On 9/27/2021 at 3:33 PM, aonniemnoi said: i am new of java i will learning bro thank you very much! Expand yes no problem mate just keep trying and dont be afraid of breaking stuff. Quote
0 aonniemnoi Posted September 27, 2021 Author Posted September 27, 2021 On 9/27/2021 at 3:35 PM, zemaitis said: yes no problem mate just keep trying and dont be afraid of breaking stuff. Expand 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) Quote
0 aonniemnoi Posted September 27, 2021 Author Posted September 27, 2021 (edited) On 9/27/2021 at 5:40 PM, splicho said: The Raidboss ID is already existing in your database. Try deleting it, as it tries to duplicate it. Expand 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 September 27, 2021 by aonniemnoi Quote
0 aonniemnoi Posted September 28, 2021 Author Posted September 28, 2021 On 9/27/2021 at 7:05 PM, splicho said: Delete the Raidbross Spawn from your Database..... Expand same... i delete already on raidboss_spawnlist when i do //spawn 40019 also come 2 T_T Quote
0 melron Posted September 28, 2021 Posted September 28, 2021 Did you compile after your last changes? Quote
0 aonniemnoi Posted September 28, 2021 Author Posted September 28, 2021 On 9/28/2021 at 5:12 AM, melron said: Did you compile after your last changes? Expand Yes bro. Everytime before test i do Quote
0 arm4729 Posted October 1, 2021 Posted October 1, 2021 (edited) 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 October 1, 2021 by arm4729 Quote
Question
aonniemnoi
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))
Edited by aonniemnoi{
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
12 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.