Try these.
PlayerInstance.java restoreCustomStatus method.
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
/*
* 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
/*
* 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
/*
* 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;
}
}