2018-03-27 01:42:26 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.FPlayer;
|
|
|
|
import com.massivecraft.factions.FPlayers;
|
2019-08-02 23:01:33 +02:00
|
|
|
import com.massivecraft.factions.P;
|
2018-03-27 01:42:26 +02:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
|
|
|
import org.bukkit.entity.Entity;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
public class CmdNear extends FCommand {
|
2019-08-24 19:18:50 +02:00
|
|
|
public CmdNear() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.aliases.add("near");
|
|
|
|
this.aliases.add("nearby");
|
|
|
|
|
|
|
|
this.disableOnLock = true;
|
|
|
|
|
|
|
|
|
|
|
|
senderMustBePlayer = true;
|
|
|
|
senderMustBeMember = true;
|
|
|
|
senderMustBeModerator = false;
|
|
|
|
senderMustBeColeader = false;
|
|
|
|
senderMustBeAdmin = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform() {
|
|
|
|
if (!P.p.getConfig().getBoolean("fnear.Enabled")) {
|
|
|
|
fme.msg(TL.COMMAND_NEAR_DISABLED_MSG);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
double range = P.p.getConfig().getInt("fnear.Radius");
|
|
|
|
String format = TL.COMMAND_NEAR_FORMAT.toString();
|
|
|
|
fme.msg(TL.COMMAND_NEAR_USE_MSG);
|
|
|
|
for (Entity e : me.getNearbyEntities(range, 255, range)) {
|
|
|
|
if (e instanceof Player) {
|
|
|
|
Player player = (((Player) e).getPlayer());
|
|
|
|
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
|
|
|
|
if (fme.getFaction() == fplayer.getFaction()) {
|
|
|
|
double distance = me.getLocation().distance(player.getLocation());
|
|
|
|
fme.sendMessage(format.replace("{playername}", player.getDisplayName()).replace("{distance}", (int) distance + ""));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_NEAR_DESCRIPTION;
|
|
|
|
}
|
2018-03-27 01:42:26 +02:00
|
|
|
}
|