L2JMobius

C6 Hero Item

Medson · 8 · 5384

Offline Medson

  • Vassal
  • *
    • Posts: 4
Hero status after logging out of the game does not work after logging in.



Online Mobius

  • Distinguished King
  • *****
    • Posts: 16009

Offline Medson

  • Vassal
  • *
    • Posts: 4
How is this a bug?
After restart character lost hero status.
I have set it should be removed after 30 days and it doesn't work  ;)



Online Mobius

  • Distinguished King
  • *****
    • Posts: 16009
Try these.

PlayerInstance.java restoreCustomStatus method.
Code: [Select]
public void restoreCustomStatus()
{
final boolean donator = getVariables().getBoolean("CustomDonator", false);
final boolean noble = getVariables().getBoolean("CustomNoble", false);
final boolean hero = getVariables().getBoolean("CustomHero", false);
final long heroEnd = getVariables().getLong("CustomHeroEnd", 0);

if (hero && ((heroEnd == 0) || (heroEnd > System.currentTimeMillis())))
{
setHero(true);
}
else if ((Hero.getInstance().getHeroes() != null) && !Hero.getInstance().getHeroes().containsKey(getObjectId()))
{
// delete wings of destiny
destroyItem("HeroEnd", 6842, 1, null, false);
}

if (noble)
{
setNoble(true);
}

if (donator)
{
setDonator(true);
}
}

HeroCustomItem.java
Code: [Select]
/*
 * This file is part of the L2J Mobius project.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.l2jmobius.gameserver.handler.itemhandlers;

import java.util.logging.Logger;

import org.l2jmobius.Config;
import org.l2jmobius.gameserver.handler.IItemHandler;
import org.l2jmobius.gameserver.model.actor.Playable;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;

public class HeroCustomItem implements IItemHandler
{
protected static final Logger LOGGER = Logger.getLogger(HeroCustomItem.class.getName());

private static final int ITEM_IDS[] =
{
Config.HERO_CUSTOM_ITEM_ID
};

@Override
public void useItem(Playable playable, ItemInstance item)
{
if (Config.HERO_CUSTOM_ITEMS)
{
if (!(playable instanceof PlayerInstance))
{
return;
}

final PlayerInstance player = (PlayerInstance) playable;
if (player.isInOlympiadMode())
{
player.sendMessage("This item cannot be used in olympiad mode.");
}

if (player.isHero())
{
player.sendMessage("You already are a hero!");
}
else
{
player.broadcastPacket(new SocialAction(player.getObjectId(), 16));
player.setHero(true);
player.sendMessage("You are now a hero, you are granted with hero status, skills and aura.");
player.broadcastUserInfo();
playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
player.getInventory().addItem("Wings", 6842, 1, player, null);

final long heroTime = Config.HERO_CUSTOM_DAY * 24 * 60 * 60 * 1000;
player.getVariables().set("CustomHero", true);
player.getVariables().set("CustomHeroEnd", heroTime == 0 ? 0 : System.currentTimeMillis() + heroTime);
}
}
}

@Override
public int[] getItemIds()
{
return ITEM_IDS;
}
}

AdminNoble.java
Code: [Select]
/*
 * This file is part of the L2J Mobius project.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.l2jmobius.gameserver.handler.admincommandhandlers;

import java.util.logging.Logger;

import org.l2jmobius.gameserver.datatables.xml.AdminData;
import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
import org.l2jmobius.gameserver.util.BuilderUtil;

public class AdminNoble implements IAdminCommandHandler
{
protected static final Logger LOGGER = Logger.getLogger(AdminNoble.class.getName());

private static final String[] ADMIN_COMMANDS =
{
"admin_setnoble"
};

@Override
public boolean useAdminCommand(String command, PlayerInstance activeChar)
{
if (activeChar == null)
{
return false;
}

if (command.startsWith("admin_setnoble"))
{
final WorldObject target = activeChar.getTarget();
if (target instanceof PlayerInstance)
{
final PlayerInstance targetPlayer = (PlayerInstance) target;
final boolean newNoble = !targetPlayer.isNoble();
if (newNoble)
{
targetPlayer.setNoble(true);
targetPlayer.sendMessage("You are now a noblesse.");
targetPlayer.getVariables().set("CustomNoble", true);
targetPlayer.sendMessage(activeChar.getName() + " has granted noble status from you!");
activeChar.sendMessage("You've granted noble status from " + targetPlayer.getName());
AdminData.broadcastMessageToGMs("Warn: " + activeChar.getName() + " has set " + targetPlayer.getName() + " as noble !");
targetPlayer.broadcastPacket(new SocialAction(targetPlayer.getObjectId(), 16));
}
else
{
targetPlayer.setNoble(false);
targetPlayer.sendMessage("You are no longer a noblesse.");
targetPlayer.getVariables().set("CustomNoble", false);
targetPlayer.sendMessage(activeChar.getName() + " has revoked noble status for you!");
activeChar.sendMessage("You've revoked noble status for " + targetPlayer.getName());
AdminData.broadcastMessageToGMs("Warn: " + activeChar.getName() + " has removed noble status of player" + targetPlayer.getName());
}
}
else
{
BuilderUtil.sendSysMessage(activeChar, "Impossible to set a non player target as noble.");
LOGGER.info("GM: " + activeChar.getName() + " is trying to set a non player target as noble.");
return false;
}
}

return true;
}

@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

AdminDonator.java
Code: [Select]
/*
 * This file is part of the L2J Mobius project.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.l2jmobius.gameserver.handler.admincommandhandlers;

import java.util.logging.Logger;

import org.l2jmobius.gameserver.datatables.xml.AdminData;
import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
import org.l2jmobius.gameserver.util.BuilderUtil;

public class AdminDonator implements IAdminCommandHandler
{
protected static final Logger LOGGER = Logger.getLogger(AdminDonator.class.getName());

private static final String[] ADMIN_COMMANDS =
{
"admin_setdonator"
};

@Override
public boolean useAdminCommand(String command, PlayerInstance activeChar)
{
if (activeChar == null)
{
return false;
}

if (command.startsWith("admin_setdonator"))
{
final WorldObject target = activeChar.getTarget();
if (target instanceof PlayerInstance)
{
final PlayerInstance targetPlayer = (PlayerInstance) target;
final boolean newDonator = !targetPlayer.isDonator();
if (newDonator)
{
targetPlayer.setDonator(true);
targetPlayer.updateNameTitleColor();
targetPlayer.getVariables().set("CustomDonator", true);
targetPlayer.sendMessage(activeChar.getName() + " has granted you donator status!");
activeChar.sendMessage("You have granted donator status to " + targetPlayer.getName());
AdminData.broadcastMessageToGMs("Warn: " + activeChar.getName() + " has set " + targetPlayer.getName() + " as donator !");
targetPlayer.broadcastPacket(new SocialAction(targetPlayer.getObjectId(), 16));
targetPlayer.broadcastUserInfo();
}
else
{
targetPlayer.setDonator(false);
targetPlayer.updateNameTitleColor();
targetPlayer.getVariables().set("CustomDonator", false);
targetPlayer.sendMessage(activeChar.getName() + " has revoked donator status from you!");
activeChar.sendMessage("You have revoked donator status from " + targetPlayer.getName());
AdminData.broadcastMessageToGMs("Warn: " + activeChar.getName() + " has removed donator status from player" + targetPlayer.getName());
targetPlayer.broadcastUserInfo();
}
}
else
{
BuilderUtil.sendSysMessage(activeChar, "Impossible to set a non player target as donator.");
LOGGER.info("GM: " + activeChar.getName() + " is trying to set a non player target as donator.");
return false;
}
}
return true;
}

@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}


Offline Medson

  • Vassal
  • *
    • Posts: 4
Unfortunately, it still doesn't work  :(


Online Mobius

  • Distinguished King
  • *****
    • Posts: 16009
Try additionally this.
Code: [Select]
Index: java/org/l2jmobius/Config.java
===================================================================
--- java/org/l2jmobius/Config.java (revision 7256)
+++ java/org/l2jmobius/Config.java (working copy)
@@ -678,7 +678,7 @@
  public static int DIFFERENT_Z_NEW_MOVIE;
  public static int HERO_CUSTOM_ITEM_ID;
  public static int NOOBLE_CUSTOM_ITEM_ID;
- public static int HERO_CUSTOM_DAY;
+ public static long HERO_CUSTOM_DAY;
  public static boolean ALLOW_FARM1_COMMAND;
  public static boolean ALLOW_FARM2_COMMAND;
  public static boolean ALLOW_PVP1_COMMAND;
@@ -1885,7 +1885,7 @@
  NOOBLE_CUSTOM_ITEM_ID = customServerConfig.getInt("NoobleCustomItemId", 6673);
  HERO_CUSTOM_ITEMS = customServerConfig.getBoolean("EnableHeroCustomItem", true);
  HERO_CUSTOM_ITEM_ID = customServerConfig.getInt("HeroCustomItemId", 3481);
- HERO_CUSTOM_DAY = customServerConfig.getInt("HeroCustomDay", 0);
+ HERO_CUSTOM_DAY = customServerConfig.getLong("HeroCustomDay", 0);
  ALLOW_CREATE_LVL = customServerConfig.getBoolean("CustomStartingLvl", false);
  CHAR_CREATE_LVL = customServerConfig.getInt("CharLvl", 80);
  SPAWN_CHAR = customServerConfig.getBoolean("CustomSpawn", false);


Offline Medson

  • Vassal
  • *
    • Posts: 4
ok now with this code working, thanks for help :)

+ i add this line

PlayerInstance.java
Code: [Select]
import org.l2jmobius.gameserver.model.entity.Hero;