Skip to content

Commit

Permalink
Locale and Rank Bug Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Tolmikarc committed Dec 9, 2020
1 parent b455d84 commit 340b3d7
Show file tree
Hide file tree
Showing 5 changed files with 462 additions and 7 deletions.
4 changes: 2 additions & 2 deletions TownyMenu/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>net.tolmikarc</groupId>
<artifactId>TownyMenu</artifactId>
<version>1.2.4</version>
<version>1.2.8</version>


<properties>
Expand Down Expand Up @@ -61,7 +61,7 @@
<dependency>
<groupId>com.github.TownyAdvanced</groupId>
<artifactId>Towny</artifactId>
<version>0.96.3.0</version>
<version>0.96.5.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ protected void onPluginStart() {
registerCommand(new TownMenuCommand());
registerCommand(new PlotMenuCommand());


TownyEconomyHandler.initialize(Towny.getPlugin());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected String getFailedValidationText(ConversationContext context, String inv
@SneakyThrows
@Override
protected @Nullable Prompt acceptValidatedInput(@NotNull ConversationContext context, @NotNull String input) {
if (!getPlayer(context).hasPermission("towny.command.plot.set" + input.toLowerCase()) || input.equalsIgnoreCase(Localization.CANCEL)) {
if (!getPlayer(context).hasPermission("towny.command.plot.set." + input.toLowerCase()) || input.equalsIgnoreCase(Localization.CANCEL)) {
return null;
}
townBlock.setType(TownBlockType.valueOf(input.toUpperCase()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
import com.palmergames.bukkit.towny.object.Resident;
import com.palmergames.bukkit.towny.permissions.TownyPerms;
import lombok.SneakyThrows;
import net.tolmikarc.townymenu.settings.Localization;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt;
Expand Down Expand Up @@ -40,6 +41,7 @@ protected boolean isInputValid(ConversationContext context, String input) {
return (TownyPerms.getTownRanks().contains(input) && !resident.hasTownRank(input)) || (input.toLowerCase().equals(Localization.CANCEL) || input.toLowerCase().equals(Localization.TownConversables.Rank.REMOVE));
}

@SneakyThrows
@Override
protected @Nullable Prompt acceptValidatedInput(@NotNull ConversationContext context, @NotNull String input) {

Expand All @@ -50,8 +52,6 @@ protected boolean isInputValid(ConversationContext context, String input) {
if (resident.hasTownRank(rank)) {
try {
resident.removeTownRank(rank);
TownyAPI.getInstance().getDataSource().saveTown(resident.getTown());
TownyAPI.getInstance().getDataSource().saveResident(resident);
} catch (NotRegisteredException e) {
e.printStackTrace();
}
Expand All @@ -61,12 +61,13 @@ protected boolean isInputValid(ConversationContext context, String input) {
} else {
try {
resident.addTownRank(input);
TownyAPI.getInstance().getDataSource().saveTown(resident.getTown());
tell(Localization.TownConversables.Rank.RESPONSE.replace("{player}", resident.getName()).replace("{input}", input));
} catch (AlreadyRegisteredException | NotRegisteredException e) {
} catch (AlreadyRegisteredException e) {
e.printStackTrace();
}
}
TownyAPI.getInstance().getDataSource().saveTown(resident.getTown());
TownyAPI.getInstance().getDataSource().saveResident(resident);


return null;
Expand Down
Loading

0 comments on commit 340b3d7

Please sign in to comment.