feat: add/coords command
This commit is contained in:
parent
c9d2e16f47
commit
481b2c4004
2 changed files with 55 additions and 0 deletions
|
@ -8,6 +8,7 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import de.cliffbreak.varo.commands.CoordsCommand;
|
||||||
import de.cliffbreak.varo.commands.VaroCommand;
|
import de.cliffbreak.varo.commands.VaroCommand;
|
||||||
import de.cliffbreak.varo.commands.VaroTabCompleter;
|
import de.cliffbreak.varo.commands.VaroTabCompleter;
|
||||||
import de.cliffbreak.varo.listeners.BannedActionListener;
|
import de.cliffbreak.varo.listeners.BannedActionListener;
|
||||||
|
@ -68,6 +69,7 @@ public class Varo extends JavaPlugin {
|
||||||
|
|
||||||
this.getCommand("varo").setExecutor(new VaroCommand(this));
|
this.getCommand("varo").setExecutor(new VaroCommand(this));
|
||||||
this.getCommand("varo").setTabCompleter(new VaroTabCompleter(this));
|
this.getCommand("varo").setTabCompleter(new VaroTabCompleter(this));
|
||||||
|
this.getCommand("coords").setExecutor(new CoordsCommand(this));
|
||||||
|
|
||||||
this.varoUtils.init();
|
this.varoUtils.init();
|
||||||
}
|
}
|
||||||
|
@ -105,6 +107,10 @@ public class Varo extends JavaPlugin {
|
||||||
return this.banUtils;
|
return this.banUtils;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TeamManager getTeamManager() {
|
||||||
|
return teamManager;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean canCreatePortal() {
|
public boolean canCreatePortal() {
|
||||||
return this.canCreatePortal;
|
return this.canCreatePortal;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package de.cliffbreak.varo.commands;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
import de.cliffbreak.varo.Varo;
|
||||||
|
|
||||||
|
public class CoordsCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
private final Varo plugin;
|
||||||
|
private final HashMap<UUID, BukkitTask> playerCoords;
|
||||||
|
|
||||||
|
public CoordsCommand(final Varo plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.playerCoords = new HashMap<UUID, BukkitTask>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
Player p = (Player) sender;
|
||||||
|
if (playerCoords.keySet().contains(p.getUniqueId())) {
|
||||||
|
playerCoords.get(p.getUniqueId()).cancel();
|
||||||
|
playerCoords.remove(p.getUniqueId());
|
||||||
|
} else {
|
||||||
|
playerCoords.put(p.getUniqueId(), new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
final Location loc = p.getLocation();
|
||||||
|
p.sendActionBar(String.format("§6§l%d / %d / %d", (int) Math.floor(loc.getX()),
|
||||||
|
(int) Math.floor(loc.getY()), (int) Math.floor(loc.getZ())));
|
||||||
|
}
|
||||||
|
}.runTaskTimerAsynchronously(this.plugin, 0, 20));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("§c§lFehler:§r§c Dieses Kommando kann nur durch einen Spieler ausgeführt werden.");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue