04-03-2011, 01:00 AM
Суть темы думаю ясна.
Что собственно меня интересует, как зделать так что-бы профили при рестарте сервера, сохранялись не только баффером, но и в базу добавлялись те баффы которые я сохранил.
1. Сам запрос у меня есть.
2. Баффер работает идеально.
3. Профили в баффере работают идеально. (Только слетают после рестарта сервера).
Просьба помочь тем кто разбераеться, поправить меня, уже как не крутил как не вертел не могу понять, методы вродебы есть что-бы не слетали после рестарта но как я понял их нету в самом баффере, как их туда добавить я чесно говоря ещё слаб в этом, наперёд блогодарен буду за помощь.
Сам класс - AcmeBufferInstance
package com.l2jfrozen.gameserver.model.actor.instance;
import com.l2jfrozen.gameserver.datatables.AcmeCharSchemesTable;
import com.l2jfrozen.gameserver.datatables.SkillTable;
import com.l2jfrozen.gameserver.model.L2Character;
import com.l2jfrozen.gameserver.model.L2Effect;
import com.l2jfrozen.gameserver.model.L2Skill;
import com.l2jfrozen.gameserver.model.L2Summon;
import com.l2jfrozen.gameserver.model.entity.event.CTF;
import com.l2jfrozen.gameserver.model.entity.event.DM;
import com.l2jfrozen.gameserver.model.entity.event.TvT;
import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad;
import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jfrozen.gameserver.powerpak.PowerPakConfig;
import com.l2jfrozen.gameserver.taskmanager.AttackStanceTaskManager;
import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
import javolution.util.FastList;
import javolution.util.FastMap;
import java.util.StringTokenizer;
public class AcmeBufferInstance extends L2FolkInstance {
public int[] TableId;
public int[] TableDialog;
public AcmeBufferInstance(int objectId, L2NpcTemplate template) {
super(objectId, template);
TableId = new int[]{
1068, 1388, 1086, 1077, 1242, 1240, 1085, 1059, 1303, 1062, 1043,
1040, 1389, 1036, 1035, 1243, 1304, 1078, 1087,
1045, 1048, 1204, 1073, 1397, 1044, 1268, 1257,
1182, 1189, 1191, 1033, 1259, 1392, 1393, 1353, 1352, 1354,
271, 272, 273, 274, 275, 276, 277, 307, 309, 310, 311,
264, 265, 266, 267, 268, 269, 270, 304, 305, 306, 308,
1355, 1356, 1357, 1363, 4699, 4554, 365, 363, 364, 349, 4702
};
TableDialog = new int[]{
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
};
}
private boolean checkAllowed(L2PcInstance activeChar)
{
String msg = null;
if(activeChar.isSitting())
msg = "Can't use buffer when sitting";
else if(activeChar.isCastingNow() || activeChar.isCastingPotionNow())
msg = "Can't use buffer when casting";
else if(activeChar.isAlikeDead())
msg = "Can't use buffer while dead";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("ALL"))
msg = "Buffer is not available in this area";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("CURSED") && activeChar.isCursedWeaponEquiped())
msg = "Can't use Buffer with Cursed Weapon";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("ATTACK") && AttackStanceTaskManager.getInstance().getAttackStanceTask(activeChar))
msg = "Buffer is not available during the battle";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("DUNGEON") && activeChar.isIn7sDungeon())
msg = "Buffer is not available in the catacombs and necropolis";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("RB") && activeChar.isInsideZone(L2Character.ZONE_NOSUMMONFRIEND))
msg = "Buffer is not available in this area";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("PVP") && activeChar.isInsideZone(L2Character.ZONE_PVP))
msg = "Buffer is not available in this area";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("PEACE") && activeChar.isInsideZone(L2Character.ZONE_PEACE))
msg = "Buffer is not available in this area";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("SIEGE") && activeChar.isInsideZone(L2Character.ZONE_SIEGE))
msg = "Buffer is not available in this area";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("OLYMPIAD") && (activeChar.isInOlympiadMode() ||
activeChar.isInsideZone(L2Character.ZONE_OLY) || Olympiad.getInstance().isRegistered(activeChar) ||
Olympiad.getInstance().isRegisteredInComp(activeChar)))
msg = "Buffer is not available in Olympiad";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("EVENT") &&
(activeChar.isInFunEvent()))
msg = "Buffer is not available in this event";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("TVT") &&
activeChar._inEventTvT && TvT.is_started() )
msg = "Buffer is not available in TVT";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("CTF") &&
activeChar._inEventCTF && CTF.is_started() )
msg = "Buffer is not available in CTF";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("DM") &&
activeChar._inEventDM && DM.is_started() )
msg = "Buffer is not available in DM";
if(msg!=null)
activeChar.sendMessage(msg);
return msg==null;
}
@Override
public String getHtmlPath(int npcId, int val) {
String pom;
if (val == 0) {
pom = "" + npcId;
} else {
pom = npcId + "-" + val;
}
return "data/html/Acme/mods/Buffer/" + pom + ".htm";
}
@Override
public void onBypassFeedback(L2PcInstance player, String command) {
StringTokenizer st = new StringTokenizer(command, " ");
String actualCommand = st.nextToken(); // Get actual command
if(player == null)
return;
if(!checkAllowed(player))
return;
if (actualCommand.startsWith("Chat")) {
String filename = "data/html/Acme/mods/Buffer/100004.htm";
int cmdChoice = Integer.parseInt(command.substring(5, 7).trim());
if (cmdChoice > 0) {
filename = "data/html/Acme/mods/Buffer/100004-" + cmdChoice + ".htm";
}
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile(filename);
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
} else if (actualCommand.startsWith("Cancel")) {
player.stopAllEffects();
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile("data/html/Acme/mods/Buffer/100004.htm");
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
} /*else if (actualCommand.startsWith("PetCancel")) {
L2Summon pet = player.getPet();
if (pet != null) {
pet.stopAllEffects();
}
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile("data/html/Acme/mods/Buffer/100004-08.htm");
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
}*/ else if (actualCommand.startsWith("Regenerate")) {
player.setCurrentHpMp(player.getMaxHp(), (player.getMaxMp()));
player.setCurrentCp(player.getMaxCp());
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile("data/html/Acme/mods/Buffer/100004.htm");
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
} /*else if (actualCommand.startsWith("PetRegenerate")) {
L2Summon pet = player.getPet();
pet.setCurrentHpMp(pet.getMaxHp(), (pet.getMaxMp()));
pet.setCurrentCp(pet.getMaxCp());
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile("data/html/Acme/mods/Buffer/100004-08.htm");
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
}*/ else if (actualCommand.startsWith("Buff")) {
String filename = "data/html/Acme/mods/Buffer/100004", v;
int cmdChoice = Integer.parseInt(command.substring(5, 7).trim());
int id = TableId[cmdChoice];
int dialog = TableDialog[cmdChoice];
int level = SkillTable.getInstance().getMaxLevel(id, 0);
if (id == 4554) {
level = 4;
}
if (dialog == 0) {
v = "";
} else {
v = "-" + Integer.toString(dialog);
}
player.stopSkillEffects(id);
SkillTable.getInstance().getInfo(id, level).getEffects(player, player);
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile(filename + v + ".htm");
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
} /*else if (actualCommand.startsWith("PetBuff")) {
String filename = "data/html/Acme/mods/Buffer/100004", v;
int cmdChoice = Integer.parseInt(command.substring(5, 7).trim());
int id = TableId[cmdChoice];
int dialog = TableDialog[cmdChoice];
int level = SkillTable.getInstance().getMaxLevel(id, 0);
if (dialog == 0) {
v = "";
} else {
v = "-" + Integer.toString(dialog);
}
L2Summon pet = player.getPet();
if (pet != null) {
pet.stopSkillEffects(id);
SkillTable.getInstance().getInfo(id, level).getEffects(pet, pet);
} else {
player.sendMessage("У вас нет суммона или питомца");
}
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile(filename + v + ".htm");
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
}*/ else if (actualCommand.startsWith("save")) {
int cmdChoice = Integer.parseInt(command.substring(5, 6).trim());
int flag = 0;
NpcHtmlMessage html = new NpcHtmlMessage(1);
if (cmdChoice > 3) {
html.setFile("data/html/Acme/mods/Buffer/100004-11.htm");
flag = 1;
} else {
html.setFile("data/html/Acme/mods/Buffer/100004.htm");
}
CreateScheme(player, Integer.toString(cmdChoice), flag);
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
} else if (actualCommand.startsWith("give")) {
int cmdChoice = Integer.parseInt(command.substring(5, 6).trim());
if ((cmdChoice < 1) && (cmdChoice > 6)) {
return;
}
String key = "data/html/Acme/mods/Buffer/100004", sKey = Integer.toString(cmdChoice);
int flag = 0;
NpcHtmlMessage html = new NpcHtmlMessage(1);
if (cmdChoice > 3) {
flag = 1;
key = "data/html/Acme/mods/Buffer/100004-8";
}
if (AcmeCharSchemesTable.getInstance().getScheme(
player.getObjectId(), sKey) != null) {
if (flag == 0) {
for (L2Skill sk : AcmeCharSchemesTable.getInstance().getScheme(
player.getObjectId(), sKey)) {
player.stopSkillEffects(sk.getId());
sk.getEffects(this, player);
}
} else {
for (L2Skill sk : AcmeCharSchemesTable.getInstance().getScheme(
player.getObjectId(), sKey)) {
L2Summon pet = player.getPet();
if (pet != null) {
pet.stopSkillEffects(sk.getId());
sk.getEffects(this, pet);
}
}
}
html.setFile(key + ".htm");
} else {
player.sendMessage("Профиль " + sKey + " не найден");
return;
}
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
} else {
super.onBypassFeedback(player, command);
}
}
private void sendHtmlMessage(L2PcInstance player, NpcHtmlMessage html) {
if(player == null)
return;
if(!checkAllowed(player))
return;
html.replace("%objectId%", String.valueOf(getObjectId()));
html.replace("%npcId%", String.valueOf(getNpcId()));
player.sendPacket(html);
}
private void CreateScheme(L2PcInstance player, String name, int flag) {
if(player == null)
return;
if(!checkAllowed(player))
return;
if (AcmeCharSchemesTable.getInstance().getAllSchemes(player.getObjectId()) != null
&& AcmeCharSchemesTable.getInstance().getAllSchemes(player.getObjectId()).containsKey(name)) {
AcmeCharSchemesTable.getInstance().getAllSchemes(player.getObjectId()).remove(name);
}
if (AcmeCharSchemesTable.getInstance().getAllSchemes(player.getObjectId()) == null) {
AcmeCharSchemesTable.getInstance().getSchemesTable().put(player.getObjectId(),
new FastMap<String, FastList<L2Skill>>(6));
}
AcmeCharSchemesTable.getInstance().setScheme(player.getObjectId(), name.trim(),
new FastList<L2Skill>(69));
L2Effect[] s;
if (flag == 0) {
s = player.getAllEffects();
} else {
L2Summon pet = player.getPet();
s = pet.getAllEffects();
}
int Id;
Boolean Ok = false;
int i = 0;
while (i < s.length) {
L2Effect value = s[i];
Id = value.getSkill().getId();
int k = 0;
while (k < TableId.length) {
if (Id == TableId[k]) {
Ok = true;
break;
}
k++;
}
if (Ok) {
AcmeCharSchemesTable.getInstance().getScheme(
player.getObjectId(), name).add(
SkillTable.getInstance().getInfo(Id, value.getSkill().getLevel()));
}
Ok = false;
i++;
}
player.sendMessage("Профиль " + name + " успешно сохранён");
}
}
import com.l2jfrozen.gameserver.datatables.AcmeCharSchemesTable;
import com.l2jfrozen.gameserver.datatables.SkillTable;
import com.l2jfrozen.gameserver.model.L2Character;
import com.l2jfrozen.gameserver.model.L2Effect;
import com.l2jfrozen.gameserver.model.L2Skill;
import com.l2jfrozen.gameserver.model.L2Summon;
import com.l2jfrozen.gameserver.model.entity.event.CTF;
import com.l2jfrozen.gameserver.model.entity.event.DM;
import com.l2jfrozen.gameserver.model.entity.event.TvT;
import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad;
import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jfrozen.gameserver.powerpak.PowerPakConfig;
import com.l2jfrozen.gameserver.taskmanager.AttackStanceTaskManager;
import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
import javolution.util.FastList;
import javolution.util.FastMap;
import java.util.StringTokenizer;
public class AcmeBufferInstance extends L2FolkInstance {
public int[] TableId;
public int[] TableDialog;
public AcmeBufferInstance(int objectId, L2NpcTemplate template) {
super(objectId, template);
TableId = new int[]{
1068, 1388, 1086, 1077, 1242, 1240, 1085, 1059, 1303, 1062, 1043,
1040, 1389, 1036, 1035, 1243, 1304, 1078, 1087,
1045, 1048, 1204, 1073, 1397, 1044, 1268, 1257,
1182, 1189, 1191, 1033, 1259, 1392, 1393, 1353, 1352, 1354,
271, 272, 273, 274, 275, 276, 277, 307, 309, 310, 311,
264, 265, 266, 267, 268, 269, 270, 304, 305, 306, 308,
1355, 1356, 1357, 1363, 4699, 4554, 365, 363, 364, 349, 4702
};
TableDialog = new int[]{
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
};
}
private boolean checkAllowed(L2PcInstance activeChar)
{
String msg = null;
if(activeChar.isSitting())
msg = "Can't use buffer when sitting";
else if(activeChar.isCastingNow() || activeChar.isCastingPotionNow())
msg = "Can't use buffer when casting";
else if(activeChar.isAlikeDead())
msg = "Can't use buffer while dead";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("ALL"))
msg = "Buffer is not available in this area";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("CURSED") && activeChar.isCursedWeaponEquiped())
msg = "Can't use Buffer with Cursed Weapon";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("ATTACK") && AttackStanceTaskManager.getInstance().getAttackStanceTask(activeChar))
msg = "Buffer is not available during the battle";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("DUNGEON") && activeChar.isIn7sDungeon())
msg = "Buffer is not available in the catacombs and necropolis";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("RB") && activeChar.isInsideZone(L2Character.ZONE_NOSUMMONFRIEND))
msg = "Buffer is not available in this area";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("PVP") && activeChar.isInsideZone(L2Character.ZONE_PVP))
msg = "Buffer is not available in this area";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("PEACE") && activeChar.isInsideZone(L2Character.ZONE_PEACE))
msg = "Buffer is not available in this area";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("SIEGE") && activeChar.isInsideZone(L2Character.ZONE_SIEGE))
msg = "Buffer is not available in this area";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("OLYMPIAD") && (activeChar.isInOlympiadMode() ||
activeChar.isInsideZone(L2Character.ZONE_OLY) || Olympiad.getInstance().isRegistered(activeChar) ||
Olympiad.getInstance().isRegisteredInComp(activeChar)))
msg = "Buffer is not available in Olympiad";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("EVENT") &&
(activeChar.isInFunEvent()))
msg = "Buffer is not available in this event";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("TVT") &&
activeChar._inEventTvT && TvT.is_started() )
msg = "Buffer is not available in TVT";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("CTF") &&
activeChar._inEventCTF && CTF.is_started() )
msg = "Buffer is not available in CTF";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("DM") &&
activeChar._inEventDM && DM.is_started() )
msg = "Buffer is not available in DM";
if(msg!=null)
activeChar.sendMessage(msg);
return msg==null;
}
@Override
public String getHtmlPath(int npcId, int val) {
String pom;
if (val == 0) {
pom = "" + npcId;
} else {
pom = npcId + "-" + val;
}
return "data/html/Acme/mods/Buffer/" + pom + ".htm";
}
@Override
public void onBypassFeedback(L2PcInstance player, String command) {
StringTokenizer st = new StringTokenizer(command, " ");
String actualCommand = st.nextToken(); // Get actual command
if(player == null)
return;
if(!checkAllowed(player))
return;
if (actualCommand.startsWith("Chat")) {
String filename = "data/html/Acme/mods/Buffer/100004.htm";
int cmdChoice = Integer.parseInt(command.substring(5, 7).trim());
if (cmdChoice > 0) {
filename = "data/html/Acme/mods/Buffer/100004-" + cmdChoice + ".htm";
}
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile(filename);
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
} else if (actualCommand.startsWith("Cancel")) {
player.stopAllEffects();
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile("data/html/Acme/mods/Buffer/100004.htm");
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
} /*else if (actualCommand.startsWith("PetCancel")) {
L2Summon pet = player.getPet();
if (pet != null) {
pet.stopAllEffects();
}
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile("data/html/Acme/mods/Buffer/100004-08.htm");
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
}*/ else if (actualCommand.startsWith("Regenerate")) {
player.setCurrentHpMp(player.getMaxHp(), (player.getMaxMp()));
player.setCurrentCp(player.getMaxCp());
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile("data/html/Acme/mods/Buffer/100004.htm");
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
} /*else if (actualCommand.startsWith("PetRegenerate")) {
L2Summon pet = player.getPet();
pet.setCurrentHpMp(pet.getMaxHp(), (pet.getMaxMp()));
pet.setCurrentCp(pet.getMaxCp());
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile("data/html/Acme/mods/Buffer/100004-08.htm");
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
}*/ else if (actualCommand.startsWith("Buff")) {
String filename = "data/html/Acme/mods/Buffer/100004", v;
int cmdChoice = Integer.parseInt(command.substring(5, 7).trim());
int id = TableId[cmdChoice];
int dialog = TableDialog[cmdChoice];
int level = SkillTable.getInstance().getMaxLevel(id, 0);
if (id == 4554) {
level = 4;
}
if (dialog == 0) {
v = "";
} else {
v = "-" + Integer.toString(dialog);
}
player.stopSkillEffects(id);
SkillTable.getInstance().getInfo(id, level).getEffects(player, player);
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile(filename + v + ".htm");
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
} /*else if (actualCommand.startsWith("PetBuff")) {
String filename = "data/html/Acme/mods/Buffer/100004", v;
int cmdChoice = Integer.parseInt(command.substring(5, 7).trim());
int id = TableId[cmdChoice];
int dialog = TableDialog[cmdChoice];
int level = SkillTable.getInstance().getMaxLevel(id, 0);
if (dialog == 0) {
v = "";
} else {
v = "-" + Integer.toString(dialog);
}
L2Summon pet = player.getPet();
if (pet != null) {
pet.stopSkillEffects(id);
SkillTable.getInstance().getInfo(id, level).getEffects(pet, pet);
} else {
player.sendMessage("У вас нет суммона или питомца");
}
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile(filename + v + ".htm");
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
}*/ else if (actualCommand.startsWith("save")) {
int cmdChoice = Integer.parseInt(command.substring(5, 6).trim());
int flag = 0;
NpcHtmlMessage html = new NpcHtmlMessage(1);
if (cmdChoice > 3) {
html.setFile("data/html/Acme/mods/Buffer/100004-11.htm");
flag = 1;
} else {
html.setFile("data/html/Acme/mods/Buffer/100004.htm");
}
CreateScheme(player, Integer.toString(cmdChoice), flag);
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
} else if (actualCommand.startsWith("give")) {
int cmdChoice = Integer.parseInt(command.substring(5, 6).trim());
if ((cmdChoice < 1) && (cmdChoice > 6)) {
return;
}
String key = "data/html/Acme/mods/Buffer/100004", sKey = Integer.toString(cmdChoice);
int flag = 0;
NpcHtmlMessage html = new NpcHtmlMessage(1);
if (cmdChoice > 3) {
flag = 1;
key = "data/html/Acme/mods/Buffer/100004-8";
}
if (AcmeCharSchemesTable.getInstance().getScheme(
player.getObjectId(), sKey) != null) {
if (flag == 0) {
for (L2Skill sk : AcmeCharSchemesTable.getInstance().getScheme(
player.getObjectId(), sKey)) {
player.stopSkillEffects(sk.getId());
sk.getEffects(this, player);
}
} else {
for (L2Skill sk : AcmeCharSchemesTable.getInstance().getScheme(
player.getObjectId(), sKey)) {
L2Summon pet = player.getPet();
if (pet != null) {
pet.stopSkillEffects(sk.getId());
sk.getEffects(this, pet);
}
}
}
html.setFile(key + ".htm");
} else {
player.sendMessage("Профиль " + sKey + " не найден");
return;
}
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
} else {
super.onBypassFeedback(player, command);
}
}
private void sendHtmlMessage(L2PcInstance player, NpcHtmlMessage html) {
if(player == null)
return;
if(!checkAllowed(player))
return;
html.replace("%objectId%", String.valueOf(getObjectId()));
html.replace("%npcId%", String.valueOf(getNpcId()));
player.sendPacket(html);
}
private void CreateScheme(L2PcInstance player, String name, int flag) {
if(player == null)
return;
if(!checkAllowed(player))
return;
if (AcmeCharSchemesTable.getInstance().getAllSchemes(player.getObjectId()) != null
&& AcmeCharSchemesTable.getInstance().getAllSchemes(player.getObjectId()).containsKey(name)) {
AcmeCharSchemesTable.getInstance().getAllSchemes(player.getObjectId()).remove(name);
}
if (AcmeCharSchemesTable.getInstance().getAllSchemes(player.getObjectId()) == null) {
AcmeCharSchemesTable.getInstance().getSchemesTable().put(player.getObjectId(),
new FastMap<String, FastList<L2Skill>>(6));
}
AcmeCharSchemesTable.getInstance().setScheme(player.getObjectId(), name.trim(),
new FastList<L2Skill>(69));
L2Effect[] s;
if (flag == 0) {
s = player.getAllEffects();
} else {
L2Summon pet = player.getPet();
s = pet.getAllEffects();
}
int Id;
Boolean Ok = false;
int i = 0;
while (i < s.length) {
L2Effect value = s[i];
Id = value.getSkill().getId();
int k = 0;
while (k < TableId.length) {
if (Id == TableId[k]) {
Ok = true;
break;
}
k++;
}
if (Ok) {
AcmeCharSchemesTable.getInstance().getScheme(
player.getObjectId(), name).add(
SkillTable.getInstance().getInfo(Id, value.getSkill().getLevel()));
}
Ok = false;
i++;
}
player.sendMessage("Профиль " + name + " успешно сохранён");
}
}
Сам класс - CharSchemesTable.java
package com.l2jfrozen.gameserver.datatables;
import com.l2jfrozen.Config;
import com.l2jfrozen.gameserver.model.L2Skill;
import com.l2jfrozen.util.database.L2DatabaseFactory;
import javolution.util.FastList;
import javolution.util.FastMap;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.logging.Logger;
/**
*
* @author ZooTee
*/
public class AcmeCharSchemesTable {
private static FastMap<Integer, FastMap<String, FastList<L2Skill>>> _schemesTable;
private static CharSchemesTable _instance = null;
private static Logger _log = Logger.getLogger(CharSchemesTable.class.getName());
private static final String SQL_LOAD_SCHEME = "SELECT * FROM mods_buffer_schemes WHERE ownerId=?";
private static final String SQL_DELETE_SCHEME = "DELETE FROM mods_buffer_schemes WHERE ownerId=?";
private static final String SQL_INSERT_SCHEME = "INSERT INTO mods_buffer_schemes (ownerId, id, level, scheme) VALUES (?,?,?,?)";
public AcmeCharSchemesTable() {
_schemesTable = new FastMap<Integer, FastMap<String, FastList<L2Skill>>>();
}
/**
* This method loads player scheme and put into _schemesTable map.
*
* @param objectId
* : player's objectId
*/
public void loadScheme(int objectId) {
Connection con = null;
try {
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(SQL_LOAD_SCHEME);
statement.setInt(1, objectId);
ResultSet rs = statement.executeQuery();
FastMap<String, FastList<L2Skill>> map = new FastMap<String, FastList<L2Skill>>();
while (rs.next()) {
int skillId = rs.getInt("id");
int skillLevel = rs.getInt("level");
String scheme = rs.getString("scheme");
if (!map.containsKey(scheme) && map.size() <= Config.ACME_NPCBUFFER_MAX_SCHEMES) {
map.put(scheme, new FastList<L2Skill>());
}
if (map.get(scheme) != null && map.get(scheme).size() < Config.ACME_NPCBUFFER_MAX_SKILLS) {
map.get(scheme).add(SkillTable.getInstance().getInfo(skillId, skillLevel));
}
}
if (!map.isEmpty()) {
_schemesTable.put(objectId, map);
}
statement.close();
rs.close();
} catch (Exception e) {
if (Config.ENABLE_ALL_EXCEPTIONS) {
e.printStackTrace();
}
_log.warning("Error trying to load buff scheme from object id: " + objectId);
} finally {
try {
con.close();
} catch (Exception e) {
if (Config.ENABLE_ALL_EXCEPTIONS) {
e.printStackTrace();
}
}
}
}
public void onPlayerLogin(int playerId) {
if (_schemesTable.get(playerId) == null) {
loadScheme(playerId);
}
}
/**
* Do necessary task when server is shutting down or restarting:<br>
* <li>Clears DataBase</li> <li>Saves new info</li>
*/
public void onServerShutdown() {
if (Config.ACME_NPCBUFFER_STORE_SCHEMES) {
clearDB();
saveDataToDB();
}
}
public void clearDB() {
if (_schemesTable.isEmpty()) {
return;
}
Connection con = null;
try {
con = L2DatabaseFactory.getInstance().getConnection();
for (FastMap.Entry<Integer, FastMap<String, FastList<L2Skill>>> e = _schemesTable.head(), end = _schemesTable.tail(); (e = e.getNext()) != end {
PreparedStatement statement = con.prepareStatement(SQL_DELETE_SCHEME);
statement.setInt(1, e.getKey());
statement.execute();
}
} catch (Exception e) {
if (Config.ENABLE_ALL_EXCEPTIONS) {
e.printStackTrace();
}
_log.warning("CharSchemesTable: Error while trying to delete schemes");
} finally {
try {
con.close();
} catch (Exception e) {
if (Config.ENABLE_ALL_EXCEPTIONS) {
e.printStackTrace();
}
}
}
}
public void saveDataToDB() {
if (_schemesTable.isEmpty()) {
return;
}
Connection con = null;
int count = 0;
try {
con = L2DatabaseFactory.getInstance().getConnection();
// _schemesTable
for (FastMap.Entry<Integer, FastMap<String, FastList<L2Skill>>> e = _schemesTable.head(), end = _schemesTable.tail(); (e = e.getNext()) != end {
// each profile
if (e.getValue() == null || e.getValue().isEmpty()) {
continue;
}
for (FastMap.Entry<String, FastList<L2Skill>> a = e.getValue().head(), enda = e.getValue().tail(); (a = a.getNext()) != enda {
if (a.getValue() == null || a.getValue().isEmpty()) {
continue;
}
// each skill
for (L2Skill sk : a.getValue()) {
PreparedStatement statement = con.prepareStatement(SQL_INSERT_SCHEME);
statement.setInt(1, e.getKey());
statement.setInt(2, sk.getId());
statement.setInt(3, sk.getLevel());
statement.setString(4, a.getKey());
statement.execute();
}
}
count++;
}
} catch (Exception e) {
if (Config.ENABLE_ALL_EXCEPTIONS) {
e.printStackTrace();
}
_log.warning("CharSchemesTable: Error while trying to delete schemes");
} finally {
try {
con.close();
} catch (Exception e) {
if (Config.ENABLE_ALL_EXCEPTIONS) {
e.printStackTrace();
}
}
System.out.println("CharSchemeTable: Saved " + String.valueOf(count + " scheme(s)"));
}
}
public FastList<L2Skill> getScheme(int playerid, String scheme_key) {
if (_schemesTable.get(playerid) == null) {
return null;
}
return _schemesTable.get(playerid).get(scheme_key);
}
public boolean getSchemeContainsSkill(int playerId, String scheme_key, int skillId) {
for (L2Skill sk : getScheme(playerId, scheme_key)) {
if (sk.getId() == skillId) {
return true;
}
}
return false;
}
public void setScheme(int playerId, String schemeKey, FastList<L2Skill> list) {
_schemesTable.get(playerId).put(schemeKey, list);
}
public FastMap<String, FastList<L2Skill>> getAllSchemes(int playerId) {
return _schemesTable.get(playerId);
}
public FastMap<Integer, FastMap<String, FastList<L2Skill>>> getSchemesTable() {
return _schemesTable;
}
public static CharSchemesTable getInstance() {
if (_instance == null) {
_instance = new CharSchemesTable();
}
return _instance;
}
}
import com.l2jfrozen.Config;
import com.l2jfrozen.gameserver.model.L2Skill;
import com.l2jfrozen.util.database.L2DatabaseFactory;
import javolution.util.FastList;
import javolution.util.FastMap;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.logging.Logger;
/**
*
* @author ZooTee
*/
public class AcmeCharSchemesTable {
private static FastMap<Integer, FastMap<String, FastList<L2Skill>>> _schemesTable;
private static CharSchemesTable _instance = null;
private static Logger _log = Logger.getLogger(CharSchemesTable.class.getName());
private static final String SQL_LOAD_SCHEME = "SELECT * FROM mods_buffer_schemes WHERE ownerId=?";
private static final String SQL_DELETE_SCHEME = "DELETE FROM mods_buffer_schemes WHERE ownerId=?";
private static final String SQL_INSERT_SCHEME = "INSERT INTO mods_buffer_schemes (ownerId, id, level, scheme) VALUES (?,?,?,?)";
public AcmeCharSchemesTable() {
_schemesTable = new FastMap<Integer, FastMap<String, FastList<L2Skill>>>();
}
/**
* This method loads player scheme and put into _schemesTable map.
*
* @param objectId
* : player's objectId
*/
public void loadScheme(int objectId) {
Connection con = null;
try {
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(SQL_LOAD_SCHEME);
statement.setInt(1, objectId);
ResultSet rs = statement.executeQuery();
FastMap<String, FastList<L2Skill>> map = new FastMap<String, FastList<L2Skill>>();
while (rs.next()) {
int skillId = rs.getInt("id");
int skillLevel = rs.getInt("level");
String scheme = rs.getString("scheme");
if (!map.containsKey(scheme) && map.size() <= Config.ACME_NPCBUFFER_MAX_SCHEMES) {
map.put(scheme, new FastList<L2Skill>());
}
if (map.get(scheme) != null && map.get(scheme).size() < Config.ACME_NPCBUFFER_MAX_SKILLS) {
map.get(scheme).add(SkillTable.getInstance().getInfo(skillId, skillLevel));
}
}
if (!map.isEmpty()) {
_schemesTable.put(objectId, map);
}
statement.close();
rs.close();
} catch (Exception e) {
if (Config.ENABLE_ALL_EXCEPTIONS) {
e.printStackTrace();
}
_log.warning("Error trying to load buff scheme from object id: " + objectId);
} finally {
try {
con.close();
} catch (Exception e) {
if (Config.ENABLE_ALL_EXCEPTIONS) {
e.printStackTrace();
}
}
}
}
public void onPlayerLogin(int playerId) {
if (_schemesTable.get(playerId) == null) {
loadScheme(playerId);
}
}
/**
* Do necessary task when server is shutting down or restarting:<br>
* <li>Clears DataBase</li> <li>Saves new info</li>
*/
public void onServerShutdown() {
if (Config.ACME_NPCBUFFER_STORE_SCHEMES) {
clearDB();
saveDataToDB();
}
}
public void clearDB() {
if (_schemesTable.isEmpty()) {
return;
}
Connection con = null;
try {
con = L2DatabaseFactory.getInstance().getConnection();
for (FastMap.Entry<Integer, FastMap<String, FastList<L2Skill>>> e = _schemesTable.head(), end = _schemesTable.tail(); (e = e.getNext()) != end {
PreparedStatement statement = con.prepareStatement(SQL_DELETE_SCHEME);
statement.setInt(1, e.getKey());
statement.execute();
}
} catch (Exception e) {
if (Config.ENABLE_ALL_EXCEPTIONS) {
e.printStackTrace();
}
_log.warning("CharSchemesTable: Error while trying to delete schemes");
} finally {
try {
con.close();
} catch (Exception e) {
if (Config.ENABLE_ALL_EXCEPTIONS) {
e.printStackTrace();
}
}
}
}
public void saveDataToDB() {
if (_schemesTable.isEmpty()) {
return;
}
Connection con = null;
int count = 0;
try {
con = L2DatabaseFactory.getInstance().getConnection();
// _schemesTable
for (FastMap.Entry<Integer, FastMap<String, FastList<L2Skill>>> e = _schemesTable.head(), end = _schemesTable.tail(); (e = e.getNext()) != end {
// each profile
if (e.getValue() == null || e.getValue().isEmpty()) {
continue;
}
for (FastMap.Entry<String, FastList<L2Skill>> a = e.getValue().head(), enda = e.getValue().tail(); (a = a.getNext()) != enda {
if (a.getValue() == null || a.getValue().isEmpty()) {
continue;
}
// each skill
for (L2Skill sk : a.getValue()) {
PreparedStatement statement = con.prepareStatement(SQL_INSERT_SCHEME);
statement.setInt(1, e.getKey());
statement.setInt(2, sk.getId());
statement.setInt(3, sk.getLevel());
statement.setString(4, a.getKey());
statement.execute();
}
}
count++;
}
} catch (Exception e) {
if (Config.ENABLE_ALL_EXCEPTIONS) {
e.printStackTrace();
}
_log.warning("CharSchemesTable: Error while trying to delete schemes");
} finally {
try {
con.close();
} catch (Exception e) {
if (Config.ENABLE_ALL_EXCEPTIONS) {
e.printStackTrace();
}
}
System.out.println("CharSchemeTable: Saved " + String.valueOf(count + " scheme(s)"));
}
}
public FastList<L2Skill> getScheme(int playerid, String scheme_key) {
if (_schemesTable.get(playerid) == null) {
return null;
}
return _schemesTable.get(playerid).get(scheme_key);
}
public boolean getSchemeContainsSkill(int playerId, String scheme_key, int skillId) {
for (L2Skill sk : getScheme(playerId, scheme_key)) {
if (sk.getId() == skillId) {
return true;
}
}
return false;
}
public void setScheme(int playerId, String schemeKey, FastList<L2Skill> list) {
_schemesTable.get(playerId).put(schemeKey, list);
}
public FastMap<String, FastList<L2Skill>> getAllSchemes(int playerId) {
return _schemesTable.get(playerId);
}
public FastMap<Integer, FastMap<String, FastList<L2Skill>>> getSchemesTable() {
return _schemesTable;
}
public static CharSchemesTable getInstance() {
if (_instance == null) {
_instance = new CharSchemesTable();
}
return _instance;
}
}
1. Сам запрос у меня есть.
2. Баффер работает идеально.
3. Профили в баффере работают идеально. (Только слетают после рестарта сервера).
Просьба помочь тем кто разбераеться, поправить меня, уже как не крутил как не вертел не могу понять, методы вродебы есть что-бы не слетали после рестарта но как я понял их нету в самом баффере, как их туда добавить я чесно говоря ещё слаб в этом, наперёд блогодарен буду за помощь.