mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-29 12:37:36 +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;
|
||||
|
||||
import com.earth2me.essentials.OfflinePlayer;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.User;
|
||||
@ -14,34 +15,36 @@ public class Commandtpaccept extends EssentialsCommand
|
||||
}
|
||||
|
||||
@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();
|
||||
if (p == null)
|
||||
final User target = user.getTeleportRequest();
|
||||
if (target == null
|
||||
|| target.getBase() instanceof OfflinePlayer
|
||||
|| (user.isTeleportRequestHere() && !target.isAuthorized("essentials.tpahere")))
|
||||
{
|
||||
throw new Exception(Util.i18n("noPendingRequest"));
|
||||
}
|
||||
|
||||
Trade charge = new Trade(this.getName(), ess);
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
if (user.isTeleportRequestHere())
|
||||
{
|
||||
charge.isAffordableFor(user);
|
||||
}
|
||||
else
|
||||
{
|
||||
charge.isAffordableFor(p);
|
||||
charge.isAffordableFor(target);
|
||||
}
|
||||
user.sendMessage(Util.i18n("requestAccepted"));
|
||||
p.sendMessage(Util.format("requestAcceptedFrom", user.getDisplayName()));
|
||||
|
||||
target.sendMessage(Util.format("requestAcceptedFrom", user.getDisplayName()));
|
||||
|
||||
if (user.isTeleportRequestHere())
|
||||
{
|
||||
user.getTeleport().teleport(p, charge);
|
||||
user.getTeleport().teleport(target, charge);
|
||||
}
|
||||
else
|
||||
{
|
||||
p.getTeleport().teleport(user, charge);
|
||||
target.getTeleport().teleport(user, charge);
|
||||
}
|
||||
user.requestTeleport(null, false);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user