How to addresident() method and getonlineplayers() townyuniverse #5917
Replies: 6 comments 1 reply
-
use resident.setTown(town, true) to add a player to a town. use TownyAPI.getInstance().getOnlinePlayer(town) for the method that used to be in the TownyUniverse. |
Beta Was this translation helpful? Give feedback.
-
Now all variables have an error Unhandled exception type NotRegisteredException: all variables are inside case "x": ex:: case "X": hmmm >:( idk where the error could be |
Beta Was this translation helpful? Give feedback.
-
Try surrounding your code with |
Beta Was this translation helpful? Give feedback.
-
oux sorry! case "X":
resident = getResident(player); //Unhandled exception type NotRegisteredException
if (resident.hasNation()) {
player.sendMessage(Main.getChatUtils().getMessage("hasNation"));
return true;
}
if (resident.hasTown()) {
player.sendMessage(Main.getChatUtils().getMessage("hasTown"));
return true;
}
if (!this.database.contains(args[1])) {
player.sendMessage(Main.getChatUtils().getMessage("townNotFound"));
return true;
}
if (Main.getEconomy().getBalance((OfflinePlayer) player) < this.database.getData(args[1]).getFileConfiguration().getDouble("price")) {
player.sendMessage(Main.getChatUtils().getMessage("notEnoughMoney"));
return true;
}
if (player.getName().equals(this.database.getData(args[1]).getFileConfiguration().getString("mayorName"))) {
player.sendMessage(Main.getChatUtils().getMessage("youIsOwner"));
return true;
}
townToBuy = getTownByName(args[1]); //Unhandled exception type NotRegisteredException
try {
resident.setTown(townToBuy);
townToBuy.setMayor(resident);
townToBuy.getMayor().updatePerms();
trade(player, this.database.getData(args[1]).getFileConfiguration().getString("mayorUUID"),
this.database.getData(args[1]).getFileConfiguration().getDouble("price"));
this.database.delete(args[1]);
TownyAPI.getInstance().getOnlinePlayers(townToBuy).forEach(players -> players.sendTitle(
Main.getChatUtils().getMessage("buyTownLine1").replace("%mayor%", player.getName()),
Main.getChatUtils().getMessage("buyTownLine2").replace("%mayor%", player.getName()),
20, 40, 20));
} catch (TownyException e) {
e.printStackTrace();
}
return true; |
Beta Was this translation helpful? Give feedback.
-
yep is strange Im using the last I think 0.98 in pom.xml. Thanks LlmDl |
Beta Was this translation helpful? Give feedback.
-
Were you able to solve this issue? |
Beta Was this translation helpful? Give feedback.
-
Hello! I don't know if this is the correct way to post this
I'm trying to remake an old plugin using TownyAPI, I want to add a resident inside a town and get onlinePlayers, but have a couple of errors:
townToBuy = getTownByName(args[1]);
try {
townToBuy.addResident(resident); <--Here The method addResident(Resident) from the type Town is not visible
townToBuy.setMayor(resident);
townToBuy.getMayor().updatePerms();
trade(player, this.database.getData(args[1]).getFileConfiguration().getString("mayorUUID"),
this.database.getData(args[1]).getFileConfiguration().getDouble("price"));
this.database.delete(args[1]);
TownyUniverse.getOnlinePlayers(townToBuy).forEach(players -> players.sendTitle(
and here: he method getOnlinePlayers(Town) is undefined for the type TownyUniverse
variable resident: resident = getResident(player);
I'm making a mistake? Using deprecated methods or incorrects methods?
Thanks!!
Beta Was this translation helpful? Give feedback.
All reactions