sender.sendMessage(String.format("Unknown achievement or statistic '%s'", statisticString));
return true;
}
if (statistic.getType() == Type.UNTYPED) {
PlayerStatisticIncrementEvent event = new PlayerStatisticIncrementEvent(player, statistic, player.getStatistic(statistic), player.getStatistic(statistic) + 1);
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
sender.sendMessage(String.format("Unable to increment %s for %s", statisticString, player.getName()));
return true;
}
player.incrementStatistic(statistic);
Command.broadcastCommandMessage(sender, String.format("Successfully given %s the stat %s", player.getName(), statisticString));
return true;
}
if (statistic.getType() == Type.ENTITY) {
EntityType entityType = EntityType.fromName(statisticString.substring(statisticString.lastIndexOf(".") + 1));
if (entityType == null) {
sender.sendMessage(String.format("Unknown achievement or statistic '%s'", statisticString));
return true;
}
PlayerStatisticIncrementEvent event = new PlayerStatisticIncrementEvent(player, statistic, player.getStatistic(statistic), player.getStatistic(statistic) + 1, entityType);
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
sender.sendMessage(String.format("Unable to increment %s for %s", statisticString, player.getName()));
return true;
}
try {
player.incrementStatistic(statistic, entityType);
} catch (IllegalArgumentException e) {
sender.sendMessage(String.format("Unknown achievement or statistic '%s'", statisticString));
return true;
}
} else {
int id;
try {
id = getInteger(sender, statisticString.substring(statisticString.lastIndexOf(".") + 1), 0, Integer.MAX_VALUE, true);
} catch (NumberFormatException e) {
sender.sendMessage(e.getMessage());
return true;
}
Material material = Material.getMaterial(id);
if (material == null) {
sender.sendMessage(String.format("Unknown achievement or statistic '%s'", statisticString));
return true;
}
PlayerStatisticIncrementEvent event = new PlayerStatisticIncrementEvent(player, statistic, player.getStatistic(statistic), player.getStatistic(statistic) + 1, material);
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
sender.sendMessage(String.format("Unable to increment %s for %s", statisticString, player.getName()));
return true;
}
try {