Fixes some minor issues

Uses Economy.format to display currency correctly
Fixes Vault repo using http
Updates Spigot version to 1.19.2
Fixes formatting of README tables
This commit is contained in:
Kristian Knarvik 2022-11-14 02:17:06 +01:00
parent 3d2194e627
commit 5c927b5607
6 changed files with 25 additions and 41 deletions

View File

@ -15,7 +15,7 @@ permission permanently by another cause) when they expire.
## Commands ## Commands
| Command | Permission | Description | | Command | Permission | Description |
| -------- | -------- | -------- | |------------|------------------------------|-----------------------------------------------------------------|
| /ps about | None | Displays information about the plugin | | /ps about | None | Displays information about the plugin |
| /ps create | permissionsigns.admin.create | Used for creating a new permission sign | | /ps create | permissionsigns.admin.create | Used for creating a new permission sign |
| /ps cancel | permissionsigns.admin.create | Used for manually cancelling a permission sign creation request | | /ps cancel | permissionsigns.admin.create | Used for manually cancelling a permission sign creation request |
@ -48,7 +48,7 @@ this: `world:essentials.gamemode.creatice,any:essentials.gamemode.survival,world
## Permissions ## Permissions
| Node | Description | | Node | Description |
| -------- | -------- | |----------------------------------|---------------------------------------------------------------------------|
| permissionsigns.* | Grants all permissions | | permissionsigns.* | Grants all permissions |
| --permissionsigns.use | Allows the usage of permission signs | | --permissionsigns.use | Allows the usage of permission signs |
| --permissionsigns.admin | Allows the creation of permission signs and access to the /reload command | | --permissionsigns.admin | Allows the creation of permission signs and access to the /reload command |
@ -58,7 +58,7 @@ this: `world:essentials.gamemode.creatice,any:essentials.gamemode.survival,world
## Configuration options ## Configuration options
| Option | Description | | Option | Description |
| -------- | -------- | |-------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| language | The language used for the plugin (en, nb-no) | | language | The language used for the plugin (en, nb-no) |
| perWorldPermissions | Sets permissions for the current world instead of setting them globally | | perWorldPermissions | Sets permissions for the current world instead of setting them globally |
| removePermissionSignIfMissing | If enabled, permission signs that have lost their physical sign will be removed during startup. This prevents permission signs from staying in a broken state until the sign is replaced. | | removePermissionSignIfMissing | If enabled, permission signs that have lost their physical sign will be removed during startup. This prevents permission signs from staying in a broken state until the sign is replaced. |

View File

@ -51,7 +51,7 @@
</repository> </repository>
<repository> <repository>
<id>vault-repo</id> <id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url> <url>https://nexus.hc.to/content/repositories/pub_releases</url>
</repository> </repository>
</repositories> </repositories>
@ -59,7 +59,7 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.19.1-R0.1-SNAPSHOT</version> <version>1.19.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -1,6 +1,5 @@
package net.knarcraft.permissionsigns.container; package net.knarcraft.permissionsigns.container;
import net.knarcraft.permissionsigns.formatting.StringFormatter;
import net.knarcraft.permissionsigns.formatting.TranslatableMessage; import net.knarcraft.permissionsigns.formatting.TranslatableMessage;
import net.knarcraft.permissionsigns.formatting.Translator; import net.knarcraft.permissionsigns.formatting.Translator;
import net.knarcraft.permissionsigns.manager.EconomyManager; import net.knarcraft.permissionsigns.manager.EconomyManager;
@ -198,11 +197,7 @@ public class PermissionSign {
if (cost == 0) { if (cost == 0) {
return Translator.getTranslatedMessage(TranslatableMessage.SIGN_COST_FREE); return Translator.getTranslatedMessage(TranslatableMessage.SIGN_COST_FREE);
} else { } else {
String currency = EconomyManager.getCurrency(cost != 1); return EconomyManager.format(cost);
String format = Translator.getTranslatedMessage(TranslatableMessage.SIGN_COST_FORMAT);
String formatted = StringFormatter.replacePlaceholders(format, new String[]{"{cost}", "{currency}"},
new String[]{"%.2f", currency});
return String.format(formatted, cost);
} }
} }

View File

@ -70,11 +70,6 @@ public enum TranslatableMessage {
*/ */
SIGN_NAME_FORMAT, SIGN_NAME_FORMAT,
/**
* The format for displaying the cost unit on a permission sign
*/
SIGN_COST_FORMAT,
/** /**
* The format for displaying the duration on a permission sign * The format for displaying the duration on a permission sign
*/ */

View File

@ -36,17 +36,13 @@ public final class EconomyManager {
} }
/** /**
* Gets the name of the used currency * Formats the given amount of currency according to the used economy plugin
* *
* @param plural <p>Whether to get the plural name or the singular name</p> * @param amount <p>The amount of currency to format</p>
* @return <p>The name of the used currency</p> * @return <p>The formatted amount of currency</p>
*/ */
public static String getCurrency(boolean plural) { public static String format(double amount) {
if (plural) { return economy.format(amount);
return economy.currencyNamePlural();
} else {
return economy.currencyNameSingular();
}
} }
/** /**

View File

@ -14,7 +14,6 @@ en:
SIGN_DURATION_FORMAT: "{duration} {unit}" SIGN_DURATION_FORMAT: "{duration} {unit}"
SIGN_PERMANENT: "Permanent" SIGN_PERMANENT: "Permanent"
SIGN_COST_FREE: "Free" SIGN_COST_FREE: "Free"
SIGN_COST_FORMAT: "{cost}{currency}"
COST_INVALID_NUMBER: "&7The given cost is not a valid number" COST_INVALID_NUMBER: "&7The given cost is not a valid number"
DURATION_INVALID_NUMBER: "&7The given duration is not a valid number" DURATION_INVALID_NUMBER: "&7The given duration is not a valid number"
COMMAND_PLAYER_ONLY: "&7This command is only available to players" COMMAND_PLAYER_ONLY: "&7This command is only available to players"
@ -58,7 +57,6 @@ nb-no:
SIGN_DURATION_FORMAT: "{duration} {unit}" SIGN_DURATION_FORMAT: "{duration} {unit}"
SIGN_PERMANENT: "Permanent" SIGN_PERMANENT: "Permanent"
SIGN_COST_FREE: "Gratis" SIGN_COST_FREE: "Gratis"
SIGN_COST_FORMAT: "{cost}{currency}"
COST_INVALID_NUMBER: "&7Den gitte kostnaden er ikke et gyldig nummer" COST_INVALID_NUMBER: "&7Den gitte kostnaden er ikke et gyldig nummer"
DURATION_INVALID_NUMBER: "&7Den gitte varigheten er ikke et gyldig nummer" DURATION_INVALID_NUMBER: "&7Den gitte varigheten er ikke et gyldig nummer"
COMMAND_PLAYER_ONLY: "&7Denne kommandoen kan bare brukes av spillere" COMMAND_PLAYER_ONLY: "&7Denne kommandoen kan bare brukes av spillere"