cjoint

Publicité


Publicité

Format du document : text/plain

Prévisualisation

package theo.test;

import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.logging.Logger;

import net.classiccraft.compasstracking.PlayerTracking;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;

public class CommandTracking
implements CommandExecutor,
Listener {
Logger log = Bukkit.getLogger();

public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (cmd.getName().equalsIgnoreCase(track)) {
if (sender instanceof Player) {
Player player = (Player)sender;
if (args.length == 0) {
player.sendMessage((Object)ChatColor.DARK_RED + --- + (Object)ChatColor.GREEN + CompassTracking Help + (Object)ChatColor.DARK_RED + ----);
player.sendMessage((Object)ChatColor.DARK_RED + + (Object)ChatColor.DARK_GREEN + track help + (Object)ChatColor.DARK_RED + );
player.sendMessage((Object)ChatColor.DARK_RED + + (Object)ChatColor.DARK_GREEN + track nearby + (Object)ChatColor.DARK_RED + );
player.sendMessage((Object)ChatColor.DARK_RED + + (Object)ChatColor.DARK_GREEN + track player [name] + (Object)ChatColor.DARK_RED + );
player.sendMessage((Object)ChatColor.DARK_RED + + (Object)ChatColor.DARK_GREEN + track reset + (Object)ChatColor.DARK_RED + );
player.sendMessage((Object)ChatColor.DARK_RED + --- + (Object)ChatColor.GREEN + Compass aide + (Object)ChatColor.DARK_RED + ----);
} else if (args.length == 1) {
if (args[0].equalsIgnoreCase(coords)) {
player.sendMessage([ + (Object)ChatColor.GREEN + CompassTracking + (Object)ChatColor.RESET + ] Incorrect usage! Type track coords [x] [z]);
} else if (args[0].equalsIgnoreCase(help)) {
player.performCommand(track);
} else if (args[0].equalsIgnoreCase(player)) {
player.sendMessage([ + (Object)ChatColor.GREEN + CompassTracking + (Object)ChatColor.RESET + ] Incorrect usage! Type track player [name]);
} else if (args[0].equalsIgnoreCase(reset)) {
Location loc = player.getWorld().getSpawnLocation();
player.setCompassTarget(loc);
player.sendMessage([ + (Object)ChatColor.GREEN + CompassTracking + (Object)ChatColor.RESET + ] Your compass point has been reset!);
} else {
player.sendMessage([ + (Object)ChatColor.GREEN + CompassTracking + (Object)ChatColor.RESET + ] Incorrect usage! Type track help for help.);
}
} else if (args.length == 2) {
if (args[0].equalsIgnoreCase(coords)) {
player.sendMessage([ + (Object)ChatColor.GREEN + CompassTracking + (Object)ChatColor.RESET + ] Incorrect usage! Type track coords [x] [z]);
} else if (args[0].equalsIgnoreCase(nearby)) {
for (int i = 0; i 200; ++i) {
List near = player.getNearbyEntities((double)i, 64.0, (double)i);
for (Entity entity near) {
if (!entity.getType().equals((Object)EntityType.PLAYER)) continue;
Player targetplayer = (Player)entity;
Location loc = targetplayer.getLocation();
player.setCompassTarget(loc);
player.sendMessage([ + (Object)ChatColor.GREEN + CompassTracking + (Object)ChatColor.RESET + ] You have successfully set your compass point to + targetplayer.getDisplayName());
}
}
} else if (args[0].equalsIgnoreCase(player)) {
if (sender.getServer().getPlayer(args[1]) != null) {
Player targetplayer = sender.getServer().getPlayer(args[1]);
Location loc = targetplayer.getLocation();
player.setCompassTarget(loc);
player.sendMessage([ + (Object)ChatColor.GREEN + CompassTracking + (Object)ChatColor.RESET + ] You have successfully set your compass point to + targetplayer.getDisplayName());
} else {
player.sendMessage([ + (Object)ChatColor.GREEN + CompassTracking + (Object)ChatColor.RESET + ] That player may be offline.);
}
} else if (args[0].equalsIgnoreCase(autotrack)) {
if (Bukkit.getPlayer((String)args[1]) != null) {
PlayerTracking.autotracks.put(((Player)sender).getUniqueId(), Bukkit.getPlayer((String)args[1]).getUniqueId());
} else {
player.sendMessage([ + (Object)ChatColor.GREEN + CompassTracking + (Object)ChatColor.RESET + ] Player is not online, or is typed incorrectly.);
}
} else {
player.sendMessage([ + (Object)ChatColor.GREEN + CompassTracking + (Object)ChatColor.RESET + ] Incorrect usage! Type track [help] for help.);
}
} else if (args.length == 3) {
if (args[0].equalsIgnoreCase(coords)) {
World world = player.getWorld();
int x = Integer.parseInt(args[2]);
int y = 64;
int z = Integer.parseInt(args[3]);
Location loc = new Location(world, (double)x, (double)y, (double)z);
player.setCompassTarget(loc);
player.sendMessage([ + (Object)ChatColor.GREEN + CompassTracking + (Object)ChatColor.RESET + ] You have set your compass to X + x + , Z + z);
} else {
player.sendMessage([ + (Object)ChatColor.GREEN + CompassTracking + (Object)ChatColor.RESET + ] Incorrect usage! Type track [help] for help.);
}
} else {
player.sendMessage([ + (Object)ChatColor.GREEN + CompassTracking + (Object)ChatColor.RESET + ] Incorrect usage! Type track [help] for help.);
}
} else {
this.log.info([CompassTracking] Track commands can only be used by players!);
}
}
return false;
}

@EventHandler
public void onQuit(PlayerQuitEvent e) {
UUID loggingOutPlayer = e.getPlayer().getUniqueId();
for (Map.Entry ids PlayerTracking.autotracks.entrySet()) {
if (!((UUID)ids.getValue()).equals(loggingOutPlayer)) continue;
PlayerTracking.autotracks.remove(ids.getKey());
}
}
}

Publicité


Signaler le contenu de ce document

Publicité