prop.setDestination(dest);
p.sendMessage(ChatColor.YELLOW + "You set " + ChatColor.WHITE + dest + ChatColor.YELLOW + " as destination for all the minecarts in this train!");
}
} else if (cmd.equals("remove") || cmd.equals("destroy")) {
Permission.COMMAND_DESTROY.handle(p);
MinecartGroup group = prop.getHolder();
if (group == null) {
TrainPropertiesStore.remove(prop.getTrainName());
OfflineGroupManager.removeGroup(prop.getTrainName());
} else {
group.destroy();
}
p.sendMessage(ChatColor.YELLOW + "The selected train has been destroyed!");
} else if (cmd.equals("public")) {
Permission.COMMAND_SETPUBLIC.handle(p);
boolean pub;
if (args.length == 0) {
pub = true;
} else {
pub = ParseUtil.parseBool(args[0]);
}
prop.setPublic(pub);
p.sendMessage(ChatColor.YELLOW + "The selected train can be used by everyone: " + ChatColor.WHITE + pub);
} else if (cmd.equals("private") || cmd.equals("locked") || cmd.equals("lock")) {
Permission.COMMAND_SETPUBLIC.handle(p);
boolean pub;
if (args.length == 0) {
pub = false;
} else {
pub = !ParseUtil.parseBool(args[0]);
}
prop.setPublic(pub);
p.sendMessage(ChatColor.YELLOW + "The selected train can only be used by the respective owners: " + ChatColor.WHITE + !pub);
} else if (cmd.equals("pickup")) {
Permission.COMMAND_PICKUP.handle(p);
boolean mode = true;
if (args.length > 0) mode = ParseUtil.parseBool(args[0]);
prop.setPickup(mode);
p.sendMessage(ChatColor.YELLOW + "The selected train picks up nearby items: " + ChatColor.WHITE + mode);
} else if (cmd.equals("default") || cmd.equals("def")) {
Permission.COMMAND_DEFAULT.handle(p);
if (args.length == 0) {
} else {
prop.setDefault(args[0]);
p.sendMessage(ChatColor.GREEN + "Train properties has been re-set to the defaults named '" + args[0] + "'!");
}
} else if (cmd.equals("break")) {
Permission.COMMAND_BREAKBLOCK.handle(p);
if (args.length == 0) {
Set<Material> types = new HashSet<Material>();
for (CartProperties cprop : prop) types.addAll(cprop.getBlockBreakTypes());
p.sendMessage(ChatColor.YELLOW + "This train breaks: " + ChatColor.WHITE + StringUtil.combineNames(types));
} else {
if (ParseUtil.isBool(args[0]) && !ParseUtil.parseBool(args[0])) {
for (CartProperties cprop : prop) cprop.clearBlockBreakTypes();
p.sendMessage(ChatColor.YELLOW + "Train block break types have been cleared!");
} else {
boolean asBreak = true;
boolean lastIsBool = ParseUtil.isBool(args[args.length - 1]);
if (lastIsBool) asBreak = ParseUtil.parseBool(args[args.length - 1]);
int count = lastIsBool ? args.length - 1 : args.length;
Set<Material> mats = new HashSet<Material>();
for (int i = 0; i < count; i++) {
Material mat = ParseUtil.parseMaterial(args[i], null);
if (mat != null) {
if (p.hasPermission("train.command.break.admin") || TrainCarts.canBreak(mat)) {
mats.add(mat);
} else {
p.sendMessage(ChatColor.RED + "You are not allowed to make this train break '" + mat.toString() + "'!");
}
}
}
if (mats.isEmpty()) {
p.sendMessage(ChatColor.RED + "Failed to find possible and allowed block types in the list given.");
return true;
}
if (asBreak) {
for (CartProperties cprop : prop) {
cprop.getBlockBreakTypes().addAll(mats);
}
p.sendMessage(ChatColor.YELLOW + "This cart can now (also) break: " + ChatColor.WHITE + StringUtil.combineNames(mats));
} else {
for (CartProperties cprop : prop) {
cprop.getBlockBreakTypes().removeAll(mats);
}
p.sendMessage(ChatColor.YELLOW + "This cart can no longer break: " + ChatColor.WHITE + StringUtil.combineNames(mats));
}
}
}
} else if (cmd.equals("path") || cmd.equals("route") || cmd.equals("pathinfo")) {
Permission.COMMAND_PATHINFO.handle(p);
Commands.showPathInfo(p, prop);
} else if (cmd.equals("teleport") || cmd.equals("tp")) {
Permission.COMMAND_TELEPORT.handle(p);
if (!prop.restore()) {
p.sendMessage(ChatColor.RED + "Train location could not be found: Train is lost");
} else {
BlockLocation bloc = prop.getLocation();
World world = bloc.getWorld();
if (world == null) {
p.sendMessage(ChatColor.RED + "Train is on a world that is not loaded (" + bloc.world + ")");
} else {
EntityUtil.teleport(p, new Location(world, bloc.x + 0.5, bloc.y + 0.5, bloc.z + 0.5));
}
}
} else if (LogicUtil.contains(cmd, "setblock", "setblocks", "changeblock", "changeblocks", "blockchanger")) {
Permission.COMMAND_CHANGEBLOCK.handle(p);
MinecartGroup members = prop.getHolder();
if (members == null) {
p.sendMessage(ChatColor.RED + "The selected train is unloaded: we can not change it at this time!");
} else if (args.length == 0) {
for (MinecartMember<?> member : members) {
member.getEntity().setBlock(Material.AIR);
}
p.sendMessage(ChatColor.YELLOW + "The selected train has its displayed blocks cleared!");
} else {
SignActionBlockChanger.setBlocks(members, StringUtil.join(" ", args));
p.sendMessage(ChatColor.YELLOW + "The selected train has its displayed blocks updated!");
}
} else if (LogicUtil.contains(cmd, "setblockoffset", "changeblockoffset", "blockoffset")) {
Permission.COMMAND_CHANGEBLOCK.handle(p);
MinecartGroup members = prop.getHolder();
if (members == null) {
p.sendMessage(ChatColor.RED + "The selected train is unloaded: we can not change it at this time!");
} else if (args.length == 0) {
for (MinecartMember<?> member : members) {
member.getEntity().setBlockOffset(9);