String iPlayer = arguments[1];
Player onlineTarget = player.getServer().findPlayer(iPlayer);
if (onlineTarget != null) {
iPlayer = onlineTarget.getName();
}
if (!home.invites.contains(new NBTString(iPlayer))) {
home.invites.add(new NBTString(iPlayer));
player.addTMessage(Color.GRAY, "You just invited %s.", iPlayer);
if (onlineTarget != null) {
onlineTarget.addTMessage(Color.GRAY, "You were just invited to visit %s's home.", player.getName());
}
} else {
player.addTMessage(Color.GRAY, "Player has already been invited.");
}
} else if (command.equals("uninvite")) {
HomePoint home = homes.get(playerName);
if (home == null) {
player.addTMessage(Color.RED, "You don't have a home to manage!");
return;
}
if (arguments.length == 1) {
player.addTMessage(Color.RED, "Invalid argument!");
usage(player);
return;
}
String uiPlayer = home.getInvitedPlayer(arguments[1]);
if (home.invites.contains(new NBTString(uiPlayer))) {
home.invites.remove(new NBTString(uiPlayer));
player.addTMessage(Color.GRAY, "You just uninvited %s.", uiPlayer);
} else {
player.addTMessage(Color.GRAY, "Player wasn't invited.");
}
} else if (command.equals("inspect")) {
if (arguments.length < 2) {
player.addTMessage(Color.GRAY, "No player name given!");
return;
}
String vPlayer = arguments[1];
HomePoint home = homes.get(vPlayer);
if (home == null) {
player.addTMessage(Color.GRAY, "Player doesn't have a home set!");
return;
}
player.teleportWithWarmup(home.position);
} else {
if (command.toLowerCase().equals(playerName.toLowerCase())) {
teleportHome(player);
return;
}
String target = command;
String onlinePlayer = player.getServer().findName(target);
if (onlinePlayer != null) {
target = onlinePlayer;
} else {
Set<String> list = homes.getHomesPlayerInvitedTo(playerName);
for (String p : list) {
if (p.startsWith(target)) {
target = p;
break;
}
}
}
HomePoint home = homes.get(target);
if (home == null) {
usage(player);
return;
}
if ((home.isPublic && player.getServer().findPlayer(target) != null) ||
home.invites.contains(new NBTString(playerName)) ||
target.toLowerCase().equals(playerName.toLowerCase())) {
player.teleportWithWarmup(home.position);
} else {
player.addTMessage(Color.RED, "You are not allowed to visit %s's home.", command);
}