Sync with L2JServer Jan 9th 2015.

This commit is contained in:
mobius
2015-01-09 19:55:02 +00:00
parent 9c9b0aaff7
commit 4c2db62a63
618 changed files with 19803 additions and 7853 deletions

View File

@ -105,6 +105,7 @@ public final class EffectMasterHandler
HealPercent.class,
Hide.class,
HpByLevel.class,
HpCpHeal.class,
HpDrain.class,
ImmobileBuff.class,
ImmobilePetBuff.class,
@ -171,6 +172,7 @@ public final class EffectMasterHandler
SummonTrap.class,
Sweeper.class,
TakeCastle.class,
TakeCastleStart.class,
TakeFort.class,
TakeFortStart.class,
TalismanSlot.class,

View File

@ -18,28 +18,6 @@
*/
package handlers;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.handler.ActionHandler;
import com.l2jserver.gameserver.handler.ActionShiftHandler;
import com.l2jserver.gameserver.handler.AdminCommandHandler;
import com.l2jserver.gameserver.handler.BypassHandler;
import com.l2jserver.gameserver.handler.ChatHandler;
import com.l2jserver.gameserver.handler.CommunityBoardHandler;
import com.l2jserver.gameserver.handler.IHandler;
import com.l2jserver.gameserver.handler.ItemHandler;
import com.l2jserver.gameserver.handler.PunishmentHandler;
import com.l2jserver.gameserver.handler.TargetHandler;
import com.l2jserver.gameserver.handler.TelnetHandler;
import com.l2jserver.gameserver.handler.UserCommandHandler;
import com.l2jserver.gameserver.handler.VoicedCommandHandler;
import handlers.actionhandlers.L2ArtefactInstanceAction;
import handlers.actionhandlers.L2DecoyAction;
import handlers.actionhandlers.L2DoorInstanceAction;
@ -62,8 +40,10 @@ import handlers.admincommandhandlers.AdminBBS;
import handlers.admincommandhandlers.AdminBuffs;
import handlers.admincommandhandlers.AdminCHSiege;
import handlers.admincommandhandlers.AdminCamera;
import handlers.admincommandhandlers.AdminCastle;
import handlers.admincommandhandlers.AdminChangeAccessLevel;
import handlers.admincommandhandlers.AdminClan;
import handlers.admincommandhandlers.AdminClanHall;
import handlers.admincommandhandlers.AdminCreateItem;
import handlers.admincommandhandlers.AdminCursedWeapons;
import handlers.admincommandhandlers.AdminDebug;
@ -115,7 +95,6 @@ import handlers.admincommandhandlers.AdminScan;
import handlers.admincommandhandlers.AdminShop;
import handlers.admincommandhandlers.AdminShowQuests;
import handlers.admincommandhandlers.AdminShutdown;
import handlers.admincommandhandlers.AdminSiege;
import handlers.admincommandhandlers.AdminSkill;
import handlers.admincommandhandlers.AdminSpawn;
import handlers.admincommandhandlers.AdminSummon;
@ -168,6 +147,7 @@ import handlers.chathandlers.ChatPetition;
import handlers.chathandlers.ChatShout;
import handlers.chathandlers.ChatTell;
import handlers.chathandlers.ChatTrade;
import handlers.chathandlers.ChatWorld;
import handlers.communityboard.ClanBoard;
import handlers.communityboard.FavoriteBoard;
import handlers.communityboard.FriendsBoard;
@ -272,6 +252,28 @@ import handlers.voicedcommandhandlers.Lang;
import handlers.voicedcommandhandlers.StatsVCmd;
import handlers.voicedcommandhandlers.Wedding;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.gameserver.handler.ActionHandler;
import com.l2jserver.gameserver.handler.ActionShiftHandler;
import com.l2jserver.gameserver.handler.AdminCommandHandler;
import com.l2jserver.gameserver.handler.BypassHandler;
import com.l2jserver.gameserver.handler.ChatHandler;
import com.l2jserver.gameserver.handler.CommunityBoardHandler;
import com.l2jserver.gameserver.handler.IHandler;
import com.l2jserver.gameserver.handler.ItemHandler;
import com.l2jserver.gameserver.handler.PunishmentHandler;
import com.l2jserver.gameserver.handler.TargetHandler;
import com.l2jserver.gameserver.handler.TelnetHandler;
import com.l2jserver.gameserver.handler.UserCommandHandler;
import com.l2jserver.gameserver.handler.VoicedCommandHandler;
/**
* Master handler.
* @author UnAfraid
@ -330,6 +332,7 @@ public class MasterHandler
AdminChangeAccessLevel.class,
AdminCHSiege.class,
AdminClan.class,
AdminCastle.class,
AdminPcCondOverride.class,
AdminCreateItem.class,
AdminCursedWeapons.class,
@ -381,7 +384,7 @@ public class MasterHandler
AdminShop.class,
AdminShowQuests.class,
AdminShutdown.class,
AdminSiege.class,
AdminClanHall.class,
AdminSkill.class,
AdminSpawn.class,
AdminSummon.class,
@ -440,6 +443,7 @@ public class MasterHandler
ChatShout.class,
ChatTell.class,
ChatTrade.class,
ChatWorld.class,
},
{
// Community Board
@ -627,4 +631,4 @@ public class MasterHandler
_log.log(Level.INFO, "Handlers Loaded...");
}
}
}

View File

@ -26,11 +26,17 @@ import javolution.text.TextBuilder;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.AdminTable;
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Hero;
import com.l2jserver.gameserver.model.olympiad.Olympiad;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.clientpackets.Say2;
import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
import com.l2jserver.gameserver.network.serverpackets.ExWorldChatCnt;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.util.Util;
/**
* This class handles following admin commands: - admin|admin1/admin2/admin3/admin4/admin5 = slots for the 5 starting admin menus - gmliston/gmlistoff = includes/excludes active character from /gmlist results - silence = toggles private messages acceptance mode - diet = toggles weight penalty mode -
@ -64,7 +70,8 @@ public class AdminAdmin implements IAdminCommandHandler
"admin_endolympiad",
"admin_setconfig",
"admin_config_server",
"admin_gmon"
"admin_gmon",
"admin_worldchat",
};
@Override
@ -288,6 +295,87 @@ public class AdminAdmin implements IAdminCommandHandler
{
// nothing
}
else if (command.startsWith("admin_worldchat"))
{
final StringTokenizer st = new StringTokenizer(command);
st.nextToken(); // admin_worldchat
final String subCmd = st.hasMoreTokens() ? st.nextToken() : "";
switch (subCmd)
{
case "shout":
{
final StringBuilder sb = new StringBuilder();
while (st.hasMoreTokens())
{
sb.append(st.nextToken());
sb.append(" ");
}
final CreatureSay cs = new CreatureSay(activeChar, Say2.GLOBAL, sb.toString());
L2World.getInstance().getPlayers().stream().filter(activeChar::isNotBlocked).forEach(cs::sendTo);
break;
}
case "see":
{
final L2Object target = activeChar.getTarget();
if ((target == null) || !target.isPlayer())
{
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
break;
}
final L2PcInstance targetPlayer = target.getActingPlayer();
if (targetPlayer.getLevel() < Config.WORLD_CHAT_MIN_LEVEL)
{
activeChar.sendMessage("Your target's level is below the minimum: " + Config.WORLD_CHAT_MIN_LEVEL);
break;
}
activeChar.sendMessage(targetPlayer.getName() + ": has " + targetPlayer.getWorldChatPoints() + " world chat points");
break;
}
case "set":
{
final L2Object target = activeChar.getTarget();
if ((target == null) || !target.isPlayer())
{
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
break;
}
final L2PcInstance targetPlayer = target.getActingPlayer();
if (targetPlayer.getLevel() < Config.WORLD_CHAT_MIN_LEVEL)
{
activeChar.sendMessage("Your target's level is below the minimum: " + Config.WORLD_CHAT_MIN_LEVEL);
break;
}
if (!st.hasMoreTokens())
{
activeChar.sendMessage("Incorrect syntax, use: //worldchat set <points>");
break;
}
final String valueToken = st.nextToken();
if (!Util.isDigit(valueToken))
{
activeChar.sendMessage("Incorrect syntax, use: //worldchat set <points>");
break;
}
activeChar.sendMessage(targetPlayer.getName() + ": points changed from " + targetPlayer.getWorldChatPoints() + " to " + valueToken);
targetPlayer.setWorldChatPoints(Integer.parseInt(valueToken));
targetPlayer.sendPacket(new ExWorldChatCnt(targetPlayer));
break;
}
default:
{
activeChar.sendMessage("Possible commands:");
activeChar.sendMessage(" - Send message: //worldchat shout <text>");
activeChar.sendMessage(" - See your target's points: //worldchat see");
activeChar.sendMessage(" - Change your target's points: //worldchat set <points>");
break;
}
}
}
return true;
}

View File

@ -0,0 +1,263 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.datatables.ClanTable;
import com.l2jserver.gameserver.enums.CastleSide;
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Castle;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.util.Util;
/**
* Admin Castle manage admin commands.
* @author St3eT
*/
public final class AdminCastle implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_castlemanage",
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
final StringTokenizer st = new StringTokenizer(command, " ");
final String actualCommand = st.nextToken();
if (actualCommand.equals("admin_castlemanage"))
{
if (st.hasMoreTokens())
{
final String param = st.nextToken();
final Castle castle;
if (Util.isDigit(param))
{
castle = CastleManager.getInstance().getCastleById(Integer.parseInt(param));
}
else
{
castle = CastleManager.getInstance().getCastle(param);
}
if (castle == null)
{
activeChar.sendMessage("Invalid parameters! Usage: //castlemanage <castleId[1-9] / castleName>");
return false;
}
if (!st.hasMoreTokens())
{
showCastleMenu(activeChar, castle.getResidenceId());
}
else
{
final String action = st.nextToken();
final L2PcInstance target = checkTarget(activeChar) ? activeChar.getActingPlayer() : null;
switch (action)
{
case "showRegWindow":
{
castle.getSiege().listRegisterClan(activeChar);
break;
}
case "addAttacker":
{
if (checkTarget(activeChar))
{
castle.getSiege().registerAttacker(target, true);
}
else
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
break;
}
case "removeAttacker":
{
if (checkTarget(activeChar))
{
castle.getSiege().removeSiegeClan(activeChar);
}
else
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
break;
}
case "addDeffender":
{
if (checkTarget(activeChar))
{
castle.getSiege().registerDefender(target, true);
}
else
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
break;
}
case "removeDeffender":
{
if (checkTarget(activeChar))
{
castle.getSiege().removeSiegeClan(target);
}
else
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
break;
}
case "startSiege":
{
if (!castle.getSiege().getAttackerClans().isEmpty())
{
castle.getSiege().startSiege();
}
else
{
activeChar.sendMessage("There is currently not registered any clan for castle siege!");
}
break;
}
case "stopSiege":
{
if (castle.getSiege().isInProgress())
{
castle.getSiege().endSiege();
}
else
{
activeChar.sendMessage("Castle siege is not currently in progress!");
}
showCastleMenu(activeChar, castle.getResidenceId());
break;
}
case "setOwner":
{
if ((target == null) || !checkTarget(activeChar))
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
else if (target.getClan().getCastleId() > 0)
{
activeChar.sendMessage("This clan already have castle!");
}
else if (castle.getOwner() != null)
{
activeChar.sendMessage("This castle is already taken by another clan!");
}
else if (!st.hasMoreTokens())
{
activeChar.sendMessage("Invalid parameters!!");
}
else
{
final CastleSide side = Enum.valueOf(CastleSide.class, st.nextToken().toUpperCase());
if (side != null)
{
castle.setSide(side);
castle.setOwner(target.getClan());
}
}
showCastleMenu(activeChar, castle.getResidenceId());
break;
}
case "takeCastle":
{
final L2Clan clan = ClanTable.getInstance().getClan(castle.getOwnerId());
if (clan != null)
{
castle.removeOwner(clan);
}
else
{
activeChar.sendMessage("Error during removing castle!");
}
showCastleMenu(activeChar, castle.getResidenceId());
break;
}
case "switchSide":
{
if (castle.getSide() == CastleSide.DARK)
{
castle.setSide(CastleSide.LIGHT);
}
else if (castle.getSide() == CastleSide.LIGHT)
{
castle.setSide(CastleSide.DARK);
}
else
{
activeChar.sendMessage("You can't switch sides when is castle neutral!");
}
showCastleMenu(activeChar, castle.getResidenceId());
break;
}
}
}
}
else
{
final NpcHtmlMessage html = new NpcHtmlMessage(0, 0);
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/castlemanage.htm"));
activeChar.sendPacket(html);
}
}
return true;
}
private void showCastleMenu(L2PcInstance player, int castleId)
{
final Castle castle = CastleManager.getInstance().getCastleById(castleId);
if (castle != null)
{
final L2Clan ownerClan = castle.getOwner();
final NpcHtmlMessage html = new NpcHtmlMessage(0, 0);
html.setHtml(HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "data/html/admin/castlemanage_selected.htm"));
html.replace("%castleId%", castle.getResidenceId());
html.replace("%castleName%", castle.getName());
html.replace("%ownerName%", ownerClan != null ? ownerClan.getLeaderName() : "NPC");
html.replace("%ownerClan%", ownerClan != null ? ownerClan.getName() : "NPC");
html.replace("%castleSide%", Util.capitalizeFirst(castle.getSide().toString().toLowerCase()));
player.sendPacket(html);
}
}
private boolean checkTarget(L2PcInstance player)
{
return ((player.getTarget() != null) && player.getTarget().isPlayer() && (((L2PcInstance) player.getTarget()).getClan() != null));
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@ -0,0 +1,278 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jserver.gameserver.datatables.ClanTable;
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
import com.l2jserver.gameserver.instancemanager.AuctionManager;
import com.l2jserver.gameserver.instancemanager.CHSiegeManager;
import com.l2jserver.gameserver.instancemanager.ClanHallManager;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.ClanHall;
import com.l2jserver.gameserver.model.entity.clanhall.SiegableHall;
import com.l2jserver.gameserver.model.zone.type.L2ClanHallZone;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.util.Util;
import com.l2jserver.util.StringUtil;
/**
* This class handles Clan Hall commands.
* @author Zoey76 (rework)
*/
public class AdminClanHall implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_clanhall",
"admin_clanhallset",
"admin_clanhalldel",
"admin_clanhallopendoors",
"admin_clanhallclosedoors",
"admin_clanhallteleportself"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
final StringTokenizer st = new StringTokenizer(command, " ");
command = st.nextToken(); // Get actual command
ClanHall clanhall = null;
if (st.hasMoreTokens())
{
L2PcInstance player = null;
if ((activeChar.getTarget() != null) && activeChar.getTarget().isPlayer())
{
player = activeChar.getTarget().getActingPlayer();
}
String val = st.nextToken();
if (command.startsWith("admin_clanhall"))
{
if (Util.isDigit(val))
{
clanhall = ClanHallManager.getInstance().getClanHallById(Integer.parseInt(val));
L2Clan clan = null;
switch (command)
{
case "admin_clanhallset":
if ((player == null) || (player.getClan() == null))
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
return false;
}
if (clanhall.getOwnerId() > 0)
{
activeChar.sendMessage("This Clan Hall is not free!");
return false;
}
clan = player.getClan();
if (clan.getHideoutId() > 0)
{
activeChar.sendMessage("You have already a Clan Hall!");
return false;
}
if (!clanhall.isSiegableHall())
{
ClanHallManager.getInstance().setOwner(clanhall.getId(), clan);
if (AuctionManager.getInstance().getAuction(clanhall.getId()) != null)
{
AuctionManager.getInstance().getAuction(clanhall.getId()).deleteAuctionFromDB();
}
}
else
{
clanhall.setOwner(clan);
clan.setHideoutId(clanhall.getId());
}
break;
case "admin_clanhalldel":
if (!clanhall.isSiegableHall())
{
if (!ClanHallManager.getInstance().isFree(clanhall.getId()))
{
ClanHallManager.getInstance().setFree(clanhall.getId());
AuctionManager.getInstance().initNPC(clanhall.getId());
}
else
{
activeChar.sendMessage("This Clan Hall is already free!");
}
}
else
{
final int oldOwner = clanhall.getOwnerId();
if (oldOwner > 0)
{
clanhall.free();
clan = ClanTable.getInstance().getClan(oldOwner);
if (clan != null)
{
clan.setHideoutId(0);
clan.broadcastClanStatus();
}
}
}
break;
case "admin_clanhallopendoors":
clanhall.openCloseDoors(true);
break;
case "admin_clanhallclosedoors":
clanhall.openCloseDoors(false);
break;
case "admin_clanhallteleportself":
final L2ClanHallZone zone = clanhall.getZone();
if (zone != null)
{
activeChar.teleToLocation(zone.getSpawnLoc(), true);
}
break;
default:
if (!clanhall.isSiegableHall())
{
showClanHallPage(activeChar, clanhall);
}
else
{
showSiegableHallPage(activeChar, (SiegableHall) clanhall);
}
break;
}
}
}
}
else
{
showClanHallSelectPage(activeChar);
}
return true;
}
/**
* Show clan hall select page.
* @param activeChar the active char
*/
private void showClanHallSelectPage(L2PcInstance activeChar)
{
int i = 0;
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/clanhalls.htm");
final StringBuilder cList = new StringBuilder(500);
for (SiegableHall hall : CHSiegeManager.getInstance().getConquerableHalls().values())
{
if (hall != null)
{
StringUtil.append(cList, "<td fixwidth=90><a action=\"bypass -h admin_chsiege_siegablehall ", String.valueOf(hall.getId()), "\">", hall.getName(), "</a></td>");
i++;
}
if (i > 1)
{
cList.append("</tr><tr>");
i = 0;
}
}
adminReply.replace("%siegableHalls%", cList.toString());
cList.setLength(0);
i = 0;
for (ClanHall clanhall : ClanHallManager.getInstance().getClanHalls().values())
{
if (clanhall != null)
{
StringUtil.append(cList, "<td fixwidth=134><a action=\"bypass -h admin_clanhall ", String.valueOf(clanhall.getId()), "\">", clanhall.getName(), "</a></td>");
i++;
}
if (i > 1)
{
cList.append("</tr><tr>");
i = 0;
}
}
adminReply.replace("%clanhalls%", cList.toString());
cList.setLength(0);
i = 0;
for (ClanHall clanhall : ClanHallManager.getInstance().getFreeClanHalls().values())
{
if (clanhall != null)
{
StringUtil.append(cList, "<td fixwidth=134><a action=\"bypass -h admin_clanhall ", String.valueOf(clanhall.getId()), "\">", clanhall.getName(), "</a></td>");
i++;
}
if (i > 1)
{
cList.append("</tr><tr>");
i = 0;
}
}
adminReply.replace("%freeclanhalls%", cList.toString());
activeChar.sendPacket(adminReply);
}
/**
* Show the clan hall page.
* @param activeChar the active char
* @param clanhall the clan hall
*/
private void showClanHallPage(L2PcInstance activeChar, ClanHall clanhall)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/clanhall.htm");
adminReply.replace("%clanhallName%", clanhall.getName());
adminReply.replace("%clanhallId%", String.valueOf(clanhall.getId()));
final L2Clan owner = ClanTable.getInstance().getClan(clanhall.getOwnerId());
adminReply.replace("%clanhallOwner%", (owner == null) ? "None" : owner.getName());
activeChar.sendPacket(adminReply);
}
/**
* Show the siegable hall page.
* @param activeChar the active char
* @param hall the siegable hall
*/
private void showSiegableHallPage(L2PcInstance activeChar, SiegableHall hall)
{
final NpcHtmlMessage msg = new NpcHtmlMessage();
msg.setFile(null, "data/html/admin/siegablehall.htm");
msg.replace("%clanhallId%", String.valueOf(hall.getId()));
msg.replace("%clanhallName%", hall.getName());
if (hall.getOwnerId() > 0)
{
final L2Clan owner = ClanTable.getInstance().getClan(hall.getOwnerId());
msg.replace("%clanhallOwner%", (owner != null) ? owner.getName() : "No Owner");
}
else
{
msg.replace("%clanhallOwner%", "No Owner");
}
activeChar.sendPacket(msg);
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@ -1,513 +0,0 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.admincommandhandlers;
import java.util.Calendar;
import java.util.StringTokenizer;
import com.l2jserver.gameserver.datatables.ClanTable;
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
import com.l2jserver.gameserver.instancemanager.AuctionManager;
import com.l2jserver.gameserver.instancemanager.CHSiegeManager;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.gameserver.instancemanager.ClanHallManager;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Castle;
import com.l2jserver.gameserver.model.entity.ClanHall;
import com.l2jserver.gameserver.model.entity.clanhall.SiegableHall;
import com.l2jserver.gameserver.model.zone.type.L2ClanHallZone;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.util.Util;
import com.l2jserver.util.StringUtil;
/**
* This class handles all siege commands.
* @author Zoey76 (rework)
*/
public class AdminSiege implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
// Castle commands
"admin_siege",
"admin_add_attacker",
"admin_add_defender",
"admin_add_guard",
"admin_list_siege_clans",
"admin_clear_siege_list",
"admin_move_defenders",
"admin_spawn_doors",
"admin_endsiege",
"admin_startsiege",
"admin_setsiegetime",
"admin_setcastle",
"admin_removecastle",
// Clan hall commands
"admin_clanhall",
"admin_clanhallset",
"admin_clanhalldel",
"admin_clanhallopendoors",
"admin_clanhallclosedoors",
"admin_clanhallteleportself"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
StringTokenizer st = new StringTokenizer(command, " ");
command = st.nextToken(); // Get actual command
// Get castle
Castle castle = null;
ClanHall clanhall = null;
if (st.hasMoreTokens())
{
L2PcInstance player = null;
if ((activeChar.getTarget() != null) && activeChar.getTarget().isPlayer())
{
player = activeChar.getTarget().getActingPlayer();
}
String val = st.nextToken();
if (command.startsWith("admin_clanhall"))
{
if (Util.isDigit(val))
{
clanhall = ClanHallManager.getInstance().getClanHallById(Integer.parseInt(val));
L2Clan clan = null;
switch (command)
{
case "admin_clanhallset":
if ((player == null) || (player.getClan() == null))
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
return false;
}
if (clanhall.getOwnerId() > 0)
{
activeChar.sendMessage("This Clan Hall is not free!");
return false;
}
clan = player.getClan();
if (clan.getHideoutId() > 0)
{
activeChar.sendMessage("You have already a Clan Hall!");
return false;
}
if (!clanhall.isSiegableHall())
{
ClanHallManager.getInstance().setOwner(clanhall.getId(), clan);
if (AuctionManager.getInstance().getAuction(clanhall.getId()) != null)
{
AuctionManager.getInstance().getAuction(clanhall.getId()).deleteAuctionFromDB();
}
}
else
{
clanhall.setOwner(clan);
clan.setHideoutId(clanhall.getId());
}
break;
case "admin_clanhalldel":
if (!clanhall.isSiegableHall())
{
if (!ClanHallManager.getInstance().isFree(clanhall.getId()))
{
ClanHallManager.getInstance().setFree(clanhall.getId());
AuctionManager.getInstance().initNPC(clanhall.getId());
}
else
{
activeChar.sendMessage("This Clan Hall is already free!");
}
}
else
{
final int oldOwner = clanhall.getOwnerId();
if (oldOwner > 0)
{
clanhall.free();
clan = ClanTable.getInstance().getClan(oldOwner);
if (clan != null)
{
clan.setHideoutId(0);
clan.broadcastClanStatus();
}
}
}
break;
case "admin_clanhallopendoors":
clanhall.openCloseDoors(true);
break;
case "admin_clanhallclosedoors":
clanhall.openCloseDoors(false);
break;
case "admin_clanhallteleportself":
final L2ClanHallZone zone = clanhall.getZone();
if (zone != null)
{
activeChar.teleToLocation(zone.getSpawnLoc(), true);
}
break;
default:
if (!clanhall.isSiegableHall())
{
showClanHallPage(activeChar, clanhall);
}
else
{
showSiegableHallPage(activeChar, (SiegableHall) clanhall);
}
break;
}
}
}
else
{
castle = CastleManager.getInstance().getCastle(val);
switch (command)
{
case "admin_add_attacker":
if (player == null)
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
else
{
castle.getSiege().registerAttacker(player, true);
}
break;
case "admin_add_defender":
if (player == null)
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
else
{
castle.getSiege().registerDefender(player, true);
}
break;
case "admin_add_guard":
if (st.hasMoreTokens())
{
val = st.nextToken();
if (Util.isDigit(val))
{
castle.getSiege().getSiegeGuardManager().addSiegeGuard(activeChar, Integer.parseInt(val));
break;
}
}
// If doesn't have more tokens or token is not a number.
activeChar.sendMessage("Usage: //add_guard castle npcId");
break;
case "admin_clear_siege_list":
castle.getSiege().clearSiegeClan();
break;
case "admin_endsiege":
castle.getSiege().endSiege();
break;
case "admin_list_siege_clans":
castle.getSiege().listRegisterClan(activeChar);
break;
case "admin_move_defenders":
activeChar.sendMessage("Not implemented yet.");
break;
case "admin_setcastle":
if ((player == null) || (player.getClan() == null))
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
else
{
castle.setOwner(player.getClan());
}
break;
case "admin_removecastle":
final L2Clan clan = ClanTable.getInstance().getClan(castle.getOwnerId());
if (clan != null)
{
castle.removeOwner(clan);
}
else
{
activeChar.sendMessage("Unable to remove castle.");
}
break;
case "admin_setsiegetime":
if (st.hasMoreTokens())
{
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(castle.getSiegeDate().getTimeInMillis());
val = st.nextToken();
if ("month".equals(val))
{
int month = cal.get(Calendar.MONTH) + Integer.parseInt(st.nextToken());
if ((cal.getActualMinimum(Calendar.MONTH) > month) || (cal.getActualMaximum(Calendar.MONTH) < month))
{
activeChar.sendMessage("Unable to change Siege Date - Incorrect month value only " + cal.getActualMinimum(Calendar.MONTH) + "-" + cal.getActualMaximum(Calendar.MONTH) + " is accepted!");
return false;
}
cal.set(Calendar.MONTH, month);
}
else if ("day".equals(val))
{
int day = Integer.parseInt(st.nextToken());
if ((cal.getActualMinimum(Calendar.DAY_OF_MONTH) > day) || (cal.getActualMaximum(Calendar.DAY_OF_MONTH) < day))
{
activeChar.sendMessage("Unable to change Siege Date - Incorrect day value only " + cal.getActualMinimum(Calendar.DAY_OF_MONTH) + "-" + cal.getActualMaximum(Calendar.DAY_OF_MONTH) + " is accepted!");
return false;
}
cal.set(Calendar.DAY_OF_MONTH, day);
}
else if ("hour".equals(val))
{
int hour = Integer.parseInt(st.nextToken());
if ((cal.getActualMinimum(Calendar.HOUR_OF_DAY) > hour) || (cal.getActualMaximum(Calendar.HOUR_OF_DAY) < hour))
{
activeChar.sendMessage("Unable to change Siege Date - Incorrect hour value only " + cal.getActualMinimum(Calendar.HOUR_OF_DAY) + "-" + cal.getActualMaximum(Calendar.HOUR_OF_DAY) + " is accepted!");
return false;
}
cal.set(Calendar.HOUR_OF_DAY, hour);
}
else if ("min".equals(val))
{
int min = Integer.parseInt(st.nextToken());
if ((cal.getActualMinimum(Calendar.MINUTE) > min) || (cal.getActualMaximum(Calendar.MINUTE) < min))
{
activeChar.sendMessage("Unable to change Siege Date - Incorrect minute value only " + cal.getActualMinimum(Calendar.MINUTE) + "-" + cal.getActualMaximum(Calendar.MINUTE) + " is accepted!");
return false;
}
cal.set(Calendar.MINUTE, min);
}
if (cal.getTimeInMillis() < Calendar.getInstance().getTimeInMillis())
{
activeChar.sendMessage("Unable to change Siege Date");
}
else if (cal.getTimeInMillis() != castle.getSiegeDate().getTimeInMillis())
{
castle.getSiegeDate().setTimeInMillis(cal.getTimeInMillis());
castle.getSiege().saveSiegeDate();
activeChar.sendMessage("Castle siege time for castle " + castle.getName() + " has been changed.");
}
}
showSiegeTimePage(activeChar, castle);
break;
case "admin_spawn_doors":
castle.spawnDoor();
break;
case "admin_startsiege":
castle.getSiege().startSiege();
break;
default:
showSiegePage(activeChar, castle.getName());
break;
}
}
}
else
{
showCastleSelectPage(activeChar);
}
return true;
}
/**
* Show castle select page.
* @param activeChar the active char
*/
private void showCastleSelectPage(L2PcInstance activeChar)
{
int i = 0;
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/castles.htm");
final StringBuilder cList = new StringBuilder(500);
for (Castle castle : CastleManager.getInstance().getCastles())
{
if (castle != null)
{
String name = castle.getName();
StringUtil.append(cList, "<td fixwidth=90><a action=\"bypass -h admin_siege ", name, "\">", name, "</a></td>");
i++;
}
if (i > 2)
{
cList.append("</tr><tr>");
i = 0;
}
}
adminReply.replace("%castles%", cList.toString());
cList.setLength(0);
i = 0;
for (SiegableHall hall : CHSiegeManager.getInstance().getConquerableHalls().values())
{
if (hall != null)
{
StringUtil.append(cList, "<td fixwidth=90><a action=\"bypass -h admin_chsiege_siegablehall ", String.valueOf(hall.getId()), "\">", hall.getName(), "</a></td>");
i++;
}
if (i > 1)
{
cList.append("</tr><tr>");
i = 0;
}
}
adminReply.replace("%siegableHalls%", cList.toString());
cList.setLength(0);
i = 0;
for (ClanHall clanhall : ClanHallManager.getInstance().getClanHalls().values())
{
if (clanhall != null)
{
StringUtil.append(cList, "<td fixwidth=134><a action=\"bypass -h admin_clanhall ", String.valueOf(clanhall.getId()), "\">", clanhall.getName(), "</a></td>");
i++;
}
if (i > 1)
{
cList.append("</tr><tr>");
i = 0;
}
}
adminReply.replace("%clanhalls%", cList.toString());
cList.setLength(0);
i = 0;
for (ClanHall clanhall : ClanHallManager.getInstance().getFreeClanHalls().values())
{
if (clanhall != null)
{
StringUtil.append(cList, "<td fixwidth=134><a action=\"bypass -h admin_clanhall ", String.valueOf(clanhall.getId()), "\">", clanhall.getName(), "</a></td>");
i++;
}
if (i > 1)
{
cList.append("</tr><tr>");
i = 0;
}
}
adminReply.replace("%freeclanhalls%", cList.toString());
activeChar.sendPacket(adminReply);
}
/**
* Show the siege page.
* @param activeChar the active char
* @param castleName the castle name
*/
private void showSiegePage(L2PcInstance activeChar, String castleName)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/castle.htm");
adminReply.replace("%castleName%", castleName);
activeChar.sendPacket(adminReply);
}
/**
* Show the siege time page.
* @param activeChar the active char
* @param castle the castle
*/
private void showSiegeTimePage(L2PcInstance activeChar, Castle castle)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/castlesiegetime.htm");
adminReply.replace("%castleName%", castle.getName());
adminReply.replace("%time%", castle.getSiegeDate().getTime().toString());
final Calendar newDay = Calendar.getInstance();
boolean isSunday = false;
if (newDay.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
{
isSunday = true;
}
else
{
newDay.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
}
if (isSunday)
{
adminReply.replace("%sundaylink%", String.valueOf(newDay.get(Calendar.DAY_OF_YEAR)));
adminReply.replace("%sunday%", String.valueOf(newDay.get(Calendar.MONTH) + "/" + String.valueOf(newDay.get(Calendar.DAY_OF_MONTH))));
newDay.add(Calendar.DAY_OF_MONTH, 13);
adminReply.replace("%saturdaylink%", String.valueOf(newDay.get(Calendar.DAY_OF_YEAR)));
adminReply.replace("%saturday%", String.valueOf(newDay.get(Calendar.MONTH) + "/" + String.valueOf(newDay.get(Calendar.DAY_OF_MONTH))));
}
else
{
adminReply.replace("%saturdaylink%", String.valueOf(newDay.get(Calendar.DAY_OF_YEAR)));
adminReply.replace("%saturday%", String.valueOf(newDay.get(Calendar.MONTH) + "/" + String.valueOf(newDay.get(Calendar.DAY_OF_MONTH))));
newDay.add(Calendar.DAY_OF_MONTH, 1);
adminReply.replace("%sundaylink%", String.valueOf(newDay.get(Calendar.DAY_OF_YEAR)));
adminReply.replace("%sunday%", String.valueOf(newDay.get(Calendar.MONTH) + "/" + String.valueOf(newDay.get(Calendar.DAY_OF_MONTH))));
}
activeChar.sendPacket(adminReply);
}
/**
* Show the clan hall page.
* @param activeChar the active char
* @param clanhall the clan hall
*/
private void showClanHallPage(L2PcInstance activeChar, ClanHall clanhall)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/clanhall.htm");
adminReply.replace("%clanhallName%", clanhall.getName());
adminReply.replace("%clanhallId%", String.valueOf(clanhall.getId()));
final L2Clan owner = ClanTable.getInstance().getClan(clanhall.getOwnerId());
adminReply.replace("%clanhallOwner%", (owner == null) ? "None" : owner.getName());
activeChar.sendPacket(adminReply);
}
/**
* Show the siegable hall page.
* @param activeChar the active char
* @param hall the siegable hall
*/
private void showSiegableHallPage(L2PcInstance activeChar, SiegableHall hall)
{
final NpcHtmlMessage msg = new NpcHtmlMessage();
msg.setFile(null, "data/html/admin/siegablehall.htm");
msg.replace("%clanhallId%", String.valueOf(hall.getId()));
msg.replace("%clanhallName%", hall.getName());
if (hall.getOwnerId() > 0)
{
final L2Clan owner = ClanTable.getInstance().getClan(hall.getOwnerId());
msg.replace("%clanhallOwner%", (owner != null) ? owner.getName() : "No Owner");
}
else
{
msg.replace("%clanhallOwner%", "No Owner");
}
activeChar.sendPacket(msg);
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@ -34,7 +34,6 @@ public class AdminVitality implements IAdminCommandHandler
private static final String[] ADMIN_COMMANDS =
{
"admin_set_vitality",
"admin_set_vitality_level",
"admin_full_vitality",
"admin_empty_vitality",
"admin_get_vitality"
@ -54,7 +53,6 @@ public class AdminVitality implements IAdminCommandHandler
return false;
}
int level = 0;
int vitality = 0;
StringTokenizer st = new StringTokenizer(command, " ");
@ -79,35 +77,6 @@ public class AdminVitality implements IAdminCommandHandler
target.setVitalityPoints(vitality, true);
target.sendMessage("Admin set your Vitality points to " + vitality);
}
else if (cmd.equals("admin_set_vitality_level"))
{
try
{
level = Integer.parseInt(st.nextToken());
}
catch (Exception e)
{
activeChar.sendMessage("Incorrect vitality level (0-4)");
}
if ((level >= 0) && (level <= 4))
{
if (level == 0)
{
vitality = PcStat.MIN_VITALITY_POINTS;
}
else
{
vitality = PcStat.VITALITY_LEVELS[level - 1];
}
target.setVitalityPoints(vitality, true);
target.sendMessage("Admin set your Vitality level to " + level);
}
else
{
activeChar.sendMessage("Incorrect vitality level (0-4)");
}
}
else if (cmd.equals("admin_full_vitality"))
{
target.setVitalityPoints(PcStat.MAX_VITALITY_POINTS, true);
@ -120,10 +89,7 @@ public class AdminVitality implements IAdminCommandHandler
}
else if (cmd.equals("admin_get_vitality"))
{
level = target.getVitalityLevel();
vitality = target.getVitalityPoints();
activeChar.sendMessage("Player vitality level: " + level);
activeChar.sendMessage("Player vitality points: " + vitality);
}
return true;

View File

@ -121,8 +121,8 @@ public class QuestLink implements IBypassHandler
state = quest.isCustomQuest() ? " (Done)" : "03";
color = "787878";
}
StringUtil.append(sb, "<a action=\"bypass -h npc_", String.valueOf(npc.getObjectId()), "_Quest ", quest.getName(), "\">");
StringUtil.append(sb, "<font color=\"" + color + "\">[");
StringUtil.append(sb, "<font color=\"" + color + "\">");
StringUtil.append(sb, "<button icon=\"quest\" align=\"left\" action=\"bypass -h npc_", String.valueOf(npc.getObjectId()), "_Quest ", quest.getName(), "\">");
if (quest.isCustomQuest())
{
@ -141,7 +141,7 @@ public class QuestLink implements IBypassHandler
}
StringUtil.append(sb, "<fstring>", String.valueOf(questId), state, "</fstring>");
}
sb.append("]</font></a><br>");
sb.append("</button></font><br>");
}
sb.append("</body></html>");

View File

@ -0,0 +1,104 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.chathandlers;
import java.time.Duration;
import java.time.Instant;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.l2jserver.Config;
import com.l2jserver.gameserver.handler.IChatHandler;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
import com.l2jserver.gameserver.network.serverpackets.ExWorldChatCnt;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.util.Util;
/**
* @author UnAfraid
*/
public class ChatWorld implements IChatHandler
{
private static final Map<Integer, Instant> REUSE = new ConcurrentHashMap<>();
private static final int[] COMMANDS =
{
25
};
@Override
public void handleChat(int type, L2PcInstance activeChar, String target, String text)
{
final Instant now = Instant.now();
if (!REUSE.isEmpty())
{
REUSE.values().removeIf(now::isAfter);
}
if (activeChar.getLevel() < Config.WORLD_CHAT_MIN_LEVEL)
{
final SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.YOU_CAN_USE_WORLD_CHAT_FROM_LV_S1);
msg.addInt(Config.WORLD_CHAT_MIN_LEVEL);
activeChar.sendPacket(msg);
}
else if (activeChar.isChatBanned() && Util.contains(Config.BAN_CHAT_CHANNELS, type))
{
activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED_IF_YOU_TRY_TO_CHAT_BEFORE_THE_PROHIBITION_IS_REMOVED_THE_PROHIBITION_TIME_WILL_INCREASE_EVEN_FURTHER);
}
else if (activeChar.getWorldChatPoints() < 1)
{
activeChar.sendPacket(SystemMessageId.YOU_HAVE_SPENT_YOUR_WORLD_CHAT_QUOTA_FOR_THE_DAY_A_NEW_DAY_STARTS_EVERY_DAY_AT_18_30);
}
else
{
// Verify if player is not spaming.
if (Config.WORLD_CHAT_INTERVAL.getSeconds() > 0)
{
final Instant instant = REUSE.getOrDefault(activeChar.getObjectId(), null);
if ((instant != null) && instant.isAfter(now))
{
final Duration timeDiff = Duration.between(instant, now);
final SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_S1_SEC_UNTIL_YOU_ARE_ABLE_TO_USE_WORLD_CHAT);
msg.addInt((int) timeDiff.getSeconds());
activeChar.sendPacket(msg);
return;
}
}
final CreatureSay cs = new CreatureSay(activeChar, type, text);
L2World.getInstance().getPlayers().stream().filter(activeChar::isNotBlocked).forEach(cs::sendTo);
activeChar.setWorldChatPoints(activeChar.getWorldChatPoints() - 1);
activeChar.sendPacket(new ExWorldChatCnt(activeChar));
if (Config.WORLD_CHAT_INTERVAL.getSeconds() > 0)
{
REUSE.put(activeChar.getObjectId(), now.plus(Config.WORLD_CHAT_INTERVAL));
}
}
}
@Override
public int[] getChatTypeList()
{
return COMMANDS;
}
}

View File

@ -66,7 +66,7 @@ public class RegionBoard implements IWriteBoardHandler
final Castle castle = castles.get(i);
final L2Clan clan = ClanTable.getInstance().getClan(castle.getOwnerId());
String link = list.replaceAll("%region_id%", String.valueOf(i));
link = list.replace("%region_name%", String.valueOf(REGIONS[i]));
link = link.replace("%region_name%", String.valueOf(REGIONS[i]));
link = link.replace("%region_owning_clan%", (clan != null ? clan.getName() : "NPC"));
link = link.replace("%region_owning_clan_alliance%", ((clan != null) && (clan.getAllyName() != null) ? clan.getAllyName() : ""));
link = link.replace("%region_tax_rate%", String.valueOf(castle.getTaxRate() * 100) + "%");

View File

@ -0,0 +1,172 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.effecthandlers;
import com.l2jserver.gameserver.enums.ShotType;
import com.l2jserver.gameserver.model.StatsSet;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.conditions.Condition;
import com.l2jserver.gameserver.model.effects.AbstractEffect;
import com.l2jserver.gameserver.model.effects.L2EffectType;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.model.items.type.CrystalType;
import com.l2jserver.gameserver.model.skills.BuffInfo;
import com.l2jserver.gameserver.model.stats.Formulas;
import com.l2jserver.gameserver.model.stats.Stats;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExMagicAttackInfo;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* HpCpHeal effect implementation.
* @author Sdw
*/
public final class HpCpHeal extends AbstractEffect
{
private final double _power;
public HpCpHeal(Condition attachCond, Condition applyCond, StatsSet set, StatsSet params)
{
super(attachCond, applyCond, set, params);
_power = params.getDouble("power", 0);
}
@Override
public L2EffectType getEffectType()
{
return L2EffectType.HEAL;
}
@Override
public boolean isInstant()
{
return true;
}
@Override
public void onStart(BuffInfo info)
{
L2Character target = info.getEffected();
L2Character activeChar = info.getEffector();
if ((target == null) || target.isDead() || target.isDoor() || target.isInvul())
{
return;
}
double amount = _power;
double staticShotBonus = 0;
int mAtkMul = 1;
boolean sps = info.getSkill().isMagic() && activeChar.isChargedShot(ShotType.SPIRITSHOTS);
boolean bss = info.getSkill().isMagic() && activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOTS);
if (((sps || bss) && (activeChar.isPlayer() && activeChar.getActingPlayer().isMageClass())) || activeChar.isSummon())
{
staticShotBonus = info.getSkill().getMpConsume(); // static bonus for spiritshots
mAtkMul = bss ? 4 : 2;
staticShotBonus *= bss ? 2.4 : 1.0;
}
else if ((sps || bss) && activeChar.isNpc())
{
staticShotBonus = 2.4 * info.getSkill().getMpConsume(); // always blessed spiritshots
mAtkMul = 4;
}
else
{
// no static bonus
// grade dynamic bonus
final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
if (weaponInst != null)
{
mAtkMul = weaponInst.getItem().getItemGrade() == CrystalType.S84 ? 4 : weaponInst.getItem().getItemGrade() == CrystalType.S80 ? 2 : 1;
}
// shot dynamic bonus
mAtkMul = bss ? mAtkMul * 4 : mAtkMul + 1;
}
if (!info.getSkill().isStatic())
{
amount += staticShotBonus + Math.sqrt(mAtkMul * activeChar.getMAtk(activeChar, null));
amount = target.calcStat(Stats.HEAL_EFFECT, amount, null, null);
// Heal critic, since CT2.3 Gracia Final
if (info.getSkill().isMagic() && Formulas.calcMCrit(activeChar.getMCriticalHit(target, info.getSkill())))
{
amount *= 3;
activeChar.sendPacket(SystemMessageId.M_CRITICAL);
activeChar.sendPacket(new ExMagicAttackInfo(activeChar.getObjectId(), target.getObjectId(), ExMagicAttackInfo.CRITICAL_HEAL));
if (target.isPlayer() && (target != activeChar))
{
target.sendPacket(new ExMagicAttackInfo(activeChar.getObjectId(), target.getObjectId(), ExMagicAttackInfo.CRITICAL_HEAL));
}
}
}
// Prevents overheal and negative amount
final double healAmount = Math.max(Math.min(amount, target.getMaxRecoverableHp() - target.getCurrentHp()), 0);
if (healAmount != 0)
{
target.setCurrentHp(healAmount + target.getCurrentHp());
}
if (target.isPlayer())
{
if (info.getSkill().getId() == 4051)
{
target.sendPacket(SystemMessageId.REJUVENATING_HP);
}
else
{
if (activeChar.isPlayer() && (activeChar != target))
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S2_HP_HAS_BEEN_RESTORED_BY_C1);
sm.addString(activeChar.getName());
sm.addInt((int) healAmount);
target.sendPacket(sm);
}
else
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HP_HAS_BEEN_RESTORED);
sm.addInt((int) healAmount);
target.sendPacket(sm);
}
}
amount = Math.max(Math.min(amount - healAmount, target.getMaxRecoverableCp() - target.getCurrentCp()), 0);
if (amount != 0)
{
target.setCurrentCp(amount + target.getCurrentCp());
}
if (activeChar.isPlayer() && (activeChar != target))
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S2_CP_HAS_BEEN_RESTORED_BY_C1);
sm.addString(activeChar.getName());
sm.addInt((int) amount);
target.sendPacket(sm);
}
else
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CP_HAS_BEEN_RESTORED);
sm.addInt((int) healAmount);
target.sendPacket(sm);
}
}
}
}

View File

@ -18,24 +18,29 @@
*/
package handlers.effecthandlers;
import com.l2jserver.gameserver.enums.CastleSide;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.gameserver.model.StatsSet;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.conditions.Condition;
import com.l2jserver.gameserver.model.effects.AbstractEffect;
import com.l2jserver.gameserver.model.entity.Castle;
import com.l2jserver.gameserver.model.skills.BuffInfo;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* Take Castle effect implementation.
* @author Adry_85
* @author Adry_85, St3eT
*/
public final class TakeCastle extends AbstractEffect
{
private final CastleSide _side;
public TakeCastle(Condition attachCond, Condition applyCond, StatsSet set, StatsSet params)
{
super(attachCond, applyCond, set, params);
_side = params.getEnum("side", CastleSide.class);
}
@Override
@ -52,8 +57,10 @@ public final class TakeCastle extends AbstractEffect
return;
}
Castle castle = CastleManager.getInstance().getCastle(info.getEffector());
castle.engrave(info.getEffector().getActingPlayer().getClan(), info.getEffected());
castle.getSiege().announceToPlayer(SystemMessage.getSystemMessage(SystemMessageId.THE_OPPOSING_CLAN_HAS_STARTED_S1), false);
final L2PcInstance effector = info.getEffector().getActingPlayer();
final Castle castle = CastleManager.getInstance().getCastle(effector);
final L2Character effected = info.getEffected();
castle.engrave(effector.getClan(), effected, _side);
}
}

View File

@ -0,0 +1,61 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 handlers.effecthandlers;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.gameserver.model.StatsSet;
import com.l2jserver.gameserver.model.conditions.Condition;
import com.l2jserver.gameserver.model.effects.AbstractEffect;
import com.l2jserver.gameserver.model.entity.Castle;
import com.l2jserver.gameserver.model.skills.BuffInfo;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* Take Castle Start effect implementation.
* @author St3eT
*/
public final class TakeCastleStart extends AbstractEffect
{
public TakeCastleStart(Condition attachCond, Condition applyCond, StatsSet set, StatsSet params)
{
super(attachCond, applyCond, set, params);
}
@Override
public boolean isInstant()
{
return true;
}
@Override
public void onStart(BuffInfo info)
{
if (!info.getEffector().isPlayer())
{
return;
}
final Castle castle = CastleManager.getInstance().getCastle(info.getEffected());
if ((castle != null) && castle.getSiege().isInProgress())
{
castle.getSiege().announceToPlayer(SystemMessage.getSystemMessage(SystemMessageId.THE_OPPOSING_CLAN_HAS_STARTED_S1).addSkillName(info.getSkill().getId()), false);
}
}
}

View File

@ -30,13 +30,13 @@ import com.l2jserver.gameserver.network.serverpackets.UserInfo;
*/
public final class VitalityPointUp extends AbstractEffect
{
private final float _value;
private final int _value;
public VitalityPointUp(Condition attachCond, Condition applyCond, StatsSet set, StatsSet params)
{
super(attachCond, applyCond, set, params);
_value = params.getFloat("value", 0);
_value = params.getInt("value", 0);
}
@Override