2011-06-08 01:18:33 +00:00
|
|
|
package com.earth2me.essentials.signs;
|
|
|
|
|
2011-06-13 13:05:31 +00:00
|
|
|
import com.earth2me.essentials.Trade;
|
2011-06-08 01:18:33 +00:00
|
|
|
import com.earth2me.essentials.ChargeException;
|
|
|
|
import com.earth2me.essentials.IEssentials;
|
|
|
|
import com.earth2me.essentials.User;
|
|
|
|
|
|
|
|
|
|
|
|
public class SignWarp extends EssentialsSign
|
|
|
|
{
|
|
|
|
public SignWarp()
|
|
|
|
{
|
|
|
|
super("Warp");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
|
|
|
|
{
|
2011-06-13 13:05:31 +00:00
|
|
|
validateTrade(sign, 3, ess);
|
2011-06-08 01:18:33 +00:00
|
|
|
final String warpName = sign.getLine(1);
|
|
|
|
|
|
|
|
if (warpName.isEmpty())
|
|
|
|
{
|
|
|
|
sign.setLine(1, "§dWarp name!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
ess.getWarps().getWarp(warpName);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
throw new SignException(ex.getMessage(), ex);
|
|
|
|
}
|
|
|
|
final String group = sign.getLine(2);
|
2011-11-04 00:44:41 +00:00
|
|
|
if ("Everyone".equalsIgnoreCase(group) || "Everybody".equalsIgnoreCase(group))
|
2011-06-08 01:18:33 +00:00
|
|
|
{
|
|
|
|
sign.setLine(2, "§2Everyone");
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException
|
|
|
|
{
|
|
|
|
final String warpName = sign.getLine(1);
|
|
|
|
final String group = sign.getLine(2);
|
|
|
|
if ((!group.isEmpty()
|
|
|
|
&& ("§2Everyone".equals(group)
|
|
|
|
|| player.inGroup(group)))
|
2011-06-30 23:32:49 +00:00
|
|
|
|| (group.isEmpty() && (!ess.getSettings().getPerWarpPermission() || player.isAuthorized("essentials.warp." + warpName))))
|
2011-06-08 01:18:33 +00:00
|
|
|
{
|
2011-06-13 13:05:31 +00:00
|
|
|
final Trade charge = getTrade(sign, 3, ess);
|
2011-06-08 01:18:33 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
player.getTeleport().warp(warpName, charge);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
throw new SignException(ex.getMessage(), ex);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|