-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add translatable messages and configuration
add documentation clean up code
- Loading branch information
Showing
15 changed files
with
258 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,46 @@ | ||
# gringotts-towny | ||
# gringotts-towny | ||
|
||
Gringotts-Towny allows the creation of [Gringotts](https://github.com/nikosgram/gringotts) vaults and account | ||
for [Towny](https://www.spigotmc.org/resources/towny-advanced.72694/)'s nations and towns. | ||
|
||
## Configuration | ||
|
||
```yaml | ||
# supported languages: "custom" (default, english), "de" (german), and "pt-BR" (brazilian portuguese). | ||
language: custom | ||
|
||
# changes the required sign name for the creation of town/nation vaults | ||
# Example: [town vault] | ||
town_sign_vault_name: 'town' | ||
nation_sign_vault_name: 'nation' | ||
``` | ||
## Permissions | ||
`gringotts.createvault.town` | ||
--- | ||
Gives the necessary permissions to the players to create vault for their towns. | ||
|
||
`gringotts.createvault.nation` | ||
--- | ||
Gives the necessary permissions to the players to create vault for their nations. | ||
|
||
|
||
Development | ||
----------- | ||
Would you like to make changes to Gringotts Towny yourself? Fork it! | ||
Pull requests are very welcome, but please make sure your changes fulfill the Gringotts Towny quality baseline: | ||
|
||
* new features, settings, permissions are documented | ||
* required dependencies are all added to the build by Maven, not included in the repo | ||
* the project builds with Maven out-of-the-box | ||
|
||
Gringotts uses the [Maven 3](http://maven.apache.org/) build system. Build a working plugin jar with the command | ||
|
||
```shell | ||
mvn compile install | ||
``` | ||
|
||
License | ||
------- | ||
All code within Gringotts is licensed under the BSD 2-clause license. See `LICENSE` for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/com/oglofus/gringotts/towny/TownyConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.oglofus.gringotts.towny; | ||
|
||
import org.bukkit.configuration.file.FileConfiguration; | ||
|
||
public enum TownyConfiguration { | ||
CONF; | ||
|
||
/** | ||
* Language to be used for messages. Should be an ISO 639-1 (alpha-2) code. | ||
* If a language is not supported by Gringotts, use user-configured or default (English) messages. | ||
*/ | ||
public String language = "custom"; | ||
public String townSignTypeName = "town"; | ||
public String nationSignTypeName = "nation"; | ||
|
||
public void readConfig(FileConfiguration savedConfig) { | ||
CONF.language = savedConfig.getString("language", "custom"); | ||
CONF.townSignTypeName = savedConfig.getString("town_sign_type_name", "town"); | ||
CONF.nationSignTypeName = savedConfig.getString("nation_sign_type_name", "nation"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/com/oglofus/gringotts/towny/TownyLanguage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.oglofus.gringotts.towny; | ||
|
||
import org.bukkit.configuration.file.FileConfiguration; | ||
|
||
import java.util.function.BiFunction; | ||
|
||
import static org.gestern.gringotts.Util.translateColors; | ||
|
||
public enum TownyLanguage { | ||
LANG; | ||
public String noTownVaultPerm; | ||
public String noTownResident; | ||
public String noNationVaultPerm; | ||
public String notInNation; | ||
|
||
public void readLanguage(FileConfiguration savedLanguage) { | ||
BiFunction<String, String, String> translator = | ||
(path, def) -> translateColors(savedLanguage.getString(path, def)); | ||
|
||
//towny plugin | ||
LANG.noTownVaultPerm = | ||
translator.apply("noTownPerm", "You do not have permission to create town vaults here."); | ||
LANG.noTownResident = | ||
translator.apply("noTownResident", "Cannot create town vault: You are not resident of a town."); | ||
LANG.noNationVaultPerm = | ||
translator.apply("NoNationVaultPerm", "You do not have permission to create nation vaults here."); | ||
LANG.notInNation = | ||
translator.apply("notInNation", "Cannot create nation vault: You do not belong to a nation."); | ||
|
||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/oglofus/gringotts/towny/TownyPermissions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.oglofus.gringotts.towny; | ||
|
||
import org.bukkit.entity.Player; | ||
|
||
/** | ||
* The Permissions. | ||
*/ | ||
public enum TownyPermissions { | ||
/** | ||
* Create vault town permissions. | ||
*/ | ||
CREATE_VAULT_TOWN("gringotts.createvault.town"), | ||
/** | ||
* Create vault nation permissions. | ||
*/ | ||
CREATE_VAULT_NATION("gringotts.createvault.nation"); | ||
|
||
/** | ||
* The Node. | ||
*/ | ||
public final String node; | ||
|
||
TownyPermissions(String node) { | ||
this.node = node; | ||
} | ||
|
||
/** | ||
* Check if a player has this permission. | ||
* | ||
* @param player player to check | ||
* @return whether given player has this permission | ||
*/ | ||
@SuppressWarnings("BooleanMethodIsAlwaysInverted") | ||
public boolean isAllowed(Player player) { | ||
return player.hasPermission(this.node); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.