mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-17 05:31:23 +01:00
Prevent that players are teleported to offline players using /tpa and players that lost their tpahere permission
This commit is contained in:
parent
b619a54105
commit
d2f3bf94ae
@ -1,5 +1,6 @@
|
|||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.OfflinePlayer;
|
||||||
import com.earth2me.essentials.Trade;
|
import com.earth2me.essentials.Trade;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
@ -14,34 +15,36 @@ public class Commandtpaccept extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
User p = user.getTeleportRequest();
|
final User target = user.getTeleportRequest();
|
||||||
if (p == null)
|
if (target == null
|
||||||
|
|| target.getBase() instanceof OfflinePlayer
|
||||||
|
|| (user.isTeleportRequestHere() && !target.isAuthorized("essentials.tpahere")))
|
||||||
{
|
{
|
||||||
throw new Exception(Util.i18n("noPendingRequest"));
|
throw new Exception(Util.i18n("noPendingRequest"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Trade charge = new Trade(this.getName(), ess);
|
final Trade charge = new Trade(this.getName(), ess);
|
||||||
if (user.isTeleportRequestHere())
|
if (user.isTeleportRequestHere())
|
||||||
{
|
{
|
||||||
charge.isAffordableFor(user);
|
charge.isAffordableFor(user);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
charge.isAffordableFor(p);
|
charge.isAffordableFor(target);
|
||||||
}
|
}
|
||||||
user.sendMessage(Util.i18n("requestAccepted"));
|
user.sendMessage(Util.i18n("requestAccepted"));
|
||||||
p.sendMessage(Util.format("requestAcceptedFrom", user.getDisplayName()));
|
target.sendMessage(Util.format("requestAcceptedFrom", user.getDisplayName()));
|
||||||
|
|
||||||
if (user.isTeleportRequestHere())
|
if (user.isTeleportRequestHere())
|
||||||
{
|
{
|
||||||
user.getTeleport().teleport(p, charge);
|
user.getTeleport().teleport(target, charge);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p.getTeleport().teleport(user, charge);
|
target.getTeleport().teleport(user, charge);
|
||||||
}
|
}
|
||||||
user.requestTeleport(null, false);
|
user.requestTeleport(null, false);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user