From 3aebd137a5621bb3f0b6558ccf17ec60c622540b Mon Sep 17 00:00:00 2001 From: Etienne Dx Date: Wed, 8 Sep 2021 22:32:39 +0200 Subject: [PATCH 01/16] added messages, fixed sign header color --- .gitignore | 1 + plugin.yml | 4 +- pom.xml | 24 +++++++--- src/me/EtienneDx/RealEstate/Config.java | 2 +- src/me/EtienneDx/RealEstate/Messages.java | 46 ++++++++++--------- .../RealEstate/Transactions/ClaimLease.java | 2 +- .../RealEstate/Transactions/ClaimRent.java | 2 +- .../RealEstate/Transactions/ClaimSell.java | 2 +- .../Transactions/TransactionsStore.java | 2 - 9 files changed, 49 insertions(+), 36 deletions(-) diff --git a/.gitignore b/.gitignore index 5c2d75b..5318537 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ target/* build.bat /bin/ /target/ +.vscode \ No newline at end of file diff --git a/plugin.yml b/plugin.yml index 802974e..4ef629d 100644 --- a/plugin.yml +++ b/plugin.yml @@ -2,8 +2,8 @@ name: RealEstate main: me.EtienneDx.RealEstate.RealEstate version: ${project.version} authors: [EtienneDx, DmitryRendov] -depend: [GriefPrevention, Vault] -api-version: "1.15" +depend: [Vault] +api-version: "1.17" commands: re: diff --git a/pom.xml b/pom.xml index b0a8080..ab586db 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 Me.EtienneDx RealEstate - 1.2.2 + 1.3.0-SNAPSHOT RealEstate A spigot plugin for selling, renting and leasing GriefPrevention claims @@ -25,14 +25,14 @@ maven-compiler-plugin 3.8.0 - 1.8 - 1.8 + 16 + 16 org.apache.maven.plugins maven-shade-plugin - 3.2.1 + 3.3.0-SNAPSHOT false @@ -44,6 +44,10 @@ me.EtienneDx.AnnotationConfig me.EtienneDx.RealEstate.AnnotationConfig + + me.ryanhamshire.GriefPrevention + me.EtienneDx.RealEstate.GriefPrevention + @@ -72,7 +76,7 @@ vault-repo - http://nexus.hc.to/content/repositories/pub_releases + https://nexus.hc.to/content/repositories/pub_releases aikar @@ -84,11 +88,17 @@ https://ci.ender.zone/plugin/repository/everything/ + + + maven-snapshots + https://repository.apache.org/content/repositories/snapshots/ + + org.spigotmc spigot-api - 1.16.3-R0.1-SNAPSHOT + 1.17.1-R0.1-SNAPSHOT provided @@ -112,7 +122,7 @@ com.github.EtienneDx GriefPrevention 1a4b2ea0b639c90f3858316fc4655478b5f0cdbc - provided + com.github.EtienneDx diff --git a/src/me/EtienneDx/RealEstate/Config.java b/src/me/EtienneDx/RealEstate/Config.java index b6f0e35..f86086c 100644 --- a/src/me/EtienneDx/RealEstate/Config.java +++ b/src/me/EtienneDx/RealEstate/Config.java @@ -21,7 +21,7 @@ public class Config extends AnnotationConfig public final String chatPrefix = "[" + ChatColor.GOLD + "RealEstate" + ChatColor.WHITE + "] "; @ConfigField(name="RealEstate.Keywords.SignsHeader", comment = "What is displayed in top of the signs") - public String cfgSignsHeader = ChatColor.GOLD + "[RealEstate]"; + public String cfgSignsHeader = "$6[RealEstate]"; //public List cfgSigns; @ConfigField(name="RealEstate.Keywords.Sell", comment = "List of all possible possible signs headers to sell a claim") diff --git a/src/me/EtienneDx/RealEstate/Messages.java b/src/me/EtienneDx/RealEstate/Messages.java index 4d69565..189e073 100644 --- a/src/me/EtienneDx/RealEstate/Messages.java +++ b/src/me/EtienneDx/RealEstate/Messages.java @@ -1,17 +1,11 @@ package me.EtienneDx.RealEstate; -import me.EtienneDx.AnnotationConfig.AnnotationConfig; -import me.EtienneDx.AnnotationConfig.ConfigField; -import me.EtienneDx.AnnotationConfig.ConfigFile; - -import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.entity.Player; import org.bukkit.plugin.PluginDescriptionFile; -import java.util.Arrays; -import java.util.List; +import me.EtienneDx.AnnotationConfig.AnnotationConfig; +import me.EtienneDx.AnnotationConfig.ConfigField; +import me.EtienneDx.AnnotationConfig.ConfigFile; @ConfigFile(header = "Use a YAML editor like NotepadPlusPlus to edit this file. \nAfter editing, back up your changes before reloading the server in case you made a syntax error. \nUse dollar signs ($) for formatting codes, which are documented here: http://minecraft.gamepedia.com/Formatting_codes.\n You can use {0}, {1} to include the different values indicated in the comments") public class Messages extends AnnotationConfig @@ -33,28 +27,38 @@ public class Messages extends AnnotationConfig @ConfigField(name="RealEstate.RenewRentCurrently", comment = "0: enabled/disabled; 1: type of claim") public String msgRenewRentCurrently = "$bAutomatic renew is currently $a{0} $bfor this {1}"; - public String msgErrorOutOfClaim = ChatColor.RED + "You must stand inside of a claim to use this command!"; + @ConfigField(name="RealEstate.Errors.OutOfClaim") + public String msgErrorOutOfClaim = "$cYou must stand inside of a claim to use this command!"; - public String msgErrorPlayerOnly = ChatColor.RED + "Only Players can perform this command!"; + @ConfigField(name="RealEstate.Errors.PlayerOnlyCmd") + public String msgErrorPlayerOnly = "$cOnly Players can perform this command!"; - public String msgErrorNoOngoingTransaction = ChatColor.RED + "This claim has no ongoing transactions!"; + @ConfigField(name="RealEstate.Errors.NoOngoingTransaction") + public String msgErrorNoOngoingTransaction = "$cThis claim has no ongoing transactions!"; - public String msgErrorNotRentNorLease = ChatColor.RED + "This claim is neither to rent or to lease!"; + @ConfigField(name="RealEstate.Errors.NotRentNorLease") + public String msgErrorNotRentNorLease = "$cThis claim is neither to rent or to lease!"; - public String msgErrorAlreadyBought = ChatColor.RED + "This claim already has a buyer!"; + @ConfigField(name="RealEstate.Errors.AlreadyBought") + public String msgErrorAlreadyBought = "$cThis claim already has a buyer!"; - public String msgErrorNotPartOfTransaction = ChatColor.RED + "You are not part of this transaction!"; + @ConfigField(name="RealEstate.Errors.NotPartOfTransaction") + public String msgErrorNotPartOfTransaction = "$cYou are not part of this transaction!"; - public String msgErrorRentOnly = ChatColor.RED + "This command only applies to rented claims!"; + @ConfigField(name="RealEstate.Errors.RentOnly") + public String msgErrorRentOnly = "$cThis command only applies to rented claims!"; - public String msgErrorValueGreaterThanZero = ChatColor.RED + "The value must be greater than zero!"; + @ConfigField(name="RealEstate.Errors.ValueGreaterThanZero") + public String msgErrorValueGreaterThanZero = "$cThe value must be greater than zero!"; - public String msgErrorInvalidOption = ChatColor.RED + "Invalid option provided!"; + @ConfigField(name="RealEstate.Errors.InvalidOption") + public String msgErrorInvalidOption = "$cInvalid option provided!"; - public String msgListTransactionsHeader = ChatColor.DARK_BLUE + "----= " + ChatColor.WHITE + "[ " + ChatColor.GOLD + "{0} page " + ChatColor.DARK_GREEN + " {1}" + - ChatColor.GOLD + " / " + ChatColor.DARK_GREEN + "{2}" + ChatColor.WHITE + " ]" + ChatColor.DARK_BLUE + " =----"; + @ConfigField(name="RealEstate.List.Header", comment = "0: RE Offers|Sell Offers|Rent Offers|Lease Offers; 1: Page number; 2: Page count") + public String msgListTransactionsHeader = "$1----= $f[ $6{0} page $2 {1} $6/ $2{2} $f] $1=----"; - public String msgListNextPage = ChatColor.GOLD + "To see the next page, type " + ChatColor.GREEN + "/re list {0} {1}"; + @ConfigField(name="RealEstate.List.NextPage", comment="0: all|sell|rent|lease; 1: next page number") + public String msgListNextPage = "$6To see the next page, type $a/re list {0} {1}"; public Messages() { diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java index 2eb7461..af8f20a 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java @@ -65,7 +65,7 @@ public boolean update() if(sign.getBlock().getState() instanceof Sign) { Sign s = (Sign)sign.getBlock().getState(); - s.setLine(0, RealEstate.instance.config.cfgSignsHeader); + s.setLine(0, RealEstate.instance.messages.getMessage(RealEstate.instance.config.cfgSignsHeader)); s.setLine(1, ChatColor.DARK_GREEN + RealEstate.instance.config.cfgReplaceLease); //s.setLine(2, owner != null ? Bukkit.getOfflinePlayer(owner).getName() : "SERVER"); //s.setLine(2, paymentsLeft + "x " + price + " " + RealEstate.econ.currencyNamePlural()); diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java index 92be5ad..d288039 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java @@ -80,7 +80,7 @@ public boolean update() if(sign.getBlock().getState() instanceof Sign) { Sign s = (Sign) sign.getBlock().getState(); - s.setLine(0, RealEstate.instance.config.cfgSignsHeader); + s.setLine(0, RealEstate.instance.messages.getMessage(RealEstate.instance.config.cfgSignsHeader)); s.setLine(1, ChatColor.DARK_GREEN + RealEstate.instance.config.cfgReplaceRent); //s.setLine(2, owner != null ? Bukkit.getOfflinePlayer(owner).getName() : "SERVER"); String price_line = ""; diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimSell.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimSell.java index 38d6f94..db06f6c 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimSell.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimSell.java @@ -37,7 +37,7 @@ public boolean update() if(sign.getBlock().getState() instanceof Sign) { Sign s = (Sign) sign.getBlock().getState(); - s.setLine(0, RealEstate.instance.config.cfgSignsHeader); + s.setLine(0, RealEstate.instance.messages.getMessage(RealEstate.instance.config.cfgSignsHeader)); s.setLine(1, ChatColor.DARK_GREEN + RealEstate.instance.config.cfgReplaceSell); s.setLine(2, owner != null ? Utils.getSignString(Bukkit.getOfflinePlayer(owner).getName()) : "SERVER"); if(RealEstate.instance.config.cfgUseCurrencySymbol) diff --git a/src/me/EtienneDx/RealEstate/Transactions/TransactionsStore.java b/src/me/EtienneDx/RealEstate/Transactions/TransactionsStore.java index 1cf30ba..ba99442 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/TransactionsStore.java +++ b/src/me/EtienneDx/RealEstate/Transactions/TransactionsStore.java @@ -42,7 +42,6 @@ public TransactionsStore() public void run() { Iterator ite = claimRent.values().iterator(); - int i = 0; while(ite.hasNext()) { if(ite.next().update()) @@ -74,7 +73,6 @@ public void loadData() try { RealEstate.instance.addLogEntry(new String(Files.readAllBytes(FileSystems.getDefault().getPath(this.dataFilePath)))); } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); } ConfigurationSection sell = config.getConfigurationSection("Sell"); From bb71f58f8193cd84fb8e6fbd46417e33b3c16f44 Mon Sep 17 00:00:00 2001 From: Etienne Dx Date: Wed, 8 Sep 2021 22:32:52 +0200 Subject: [PATCH 02/16] docs: Added changelog & readme --- CHANGELOG.md | 15 +++++++++++++++ README.md | 19 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 CHANGELOG.md create mode 100644 README.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d883470 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,15 @@ +# Changelog + +## 1.3.0 - Unreleased + +### Added +* Readme and changelog files +* Error messages to *messages.yml* +* List messages to *messages.yml* + +### Modified +* Changed java version to java 16 +* Changed spigot version to 1.17.1 + +### Fixed +* Sign header color formatting being lost on server restart \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..a8ee50d --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# RealEstate + +RealEstate is a spigot plugin built on top of GriefPrevention to provide players with an ability to sell, rent and lease claims to other players. + +The plugin is documented in the [GitHub wiki](https://github.com/EtienneDx/RealEstate/wiki). + +Please feel free to report any issue in the [GitHub Issue section](https://github.com/EtienneDx/RealEstate/issues). + +## GriefPrevention + +This plugin is dependent on GriefPrevention, which since version 1.3.0 will be included directly within the `RealEstate.jar` file. + +The original GriefPrevention plugin can be found [here](https://github.com/TechFortress/GriefPrevention). To make RealEstate possible, I had to implement some modifications to GriefPrevention, which I did in this [fork](https://github.com/EtienneDx/GriefPrevention). + +
+ Code ownership disclaimer + + **I AM NOT THE AUTHOR OF *GriefPrevention*, I MERELY MADE A FEW MODIFICATIONS TO IT. I DO NOT CLAIM ANY PROPERTY OVER THE *GriefPrevention* CODE.** +
\ No newline at end of file From 0326917f5f4ba2b5d52ca7a92aa99b2b536a851d Mon Sep 17 00:00:00 2001 From: Etienne Dx Date: Wed, 8 Sep 2021 22:39:25 +0200 Subject: [PATCH 03/16] fix: fixed version --- CHANGELOG.md | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d883470..0dd3067 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## 1.3.0 - Unreleased +## 1.4.0 - Unreleased ### Added * Readme and changelog files diff --git a/pom.xml b/pom.xml index ab586db..7916e17 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 Me.EtienneDx RealEstate - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT RealEstate A spigot plugin for selling, renting and leasing GriefPrevention claims From c9a619c027a300a8d86c05a8d110166a51fbf5da Mon Sep 17 00:00:00 2001 From: Etienne Dx Date: Thu, 9 Sep 2021 11:29:12 +0200 Subject: [PATCH 04/16] fix: artifact-id to lower --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b1233a7..e83f858 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 Me.EtienneDx - RealEstate + real-estate 1.4.0-pre1 RealEstate A spigot plugin for selling, renting and leasing GriefPrevention claims From 20fea59a39eaf73fc7de22664af1bfcf290d99e2 Mon Sep 17 00:00:00 2001 From: Etienne Dx Date: Thu, 9 Sep 2021 12:05:40 +0200 Subject: [PATCH 05/16] fix: build pipeline & revoked action --- pom.xml | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index e83f858..a06d862 100644 --- a/pom.xml +++ b/pom.xml @@ -35,6 +35,14 @@ 3.3.0-SNAPSHOT false + + + *:* + + META-INF/MANIFEST.MF + + + co.aikar.commands @@ -44,10 +52,6 @@ me.EtienneDx.AnnotationConfig me.EtienneDx.RealEstate.AnnotationConfig - - me.ryanhamshire.GriefPrevention - me.EtienneDx.RealEstate.GriefPrevention - @@ -59,15 +63,33 @@
+ + maven-assembly-plugin + 2.4.1 + + ${project.name}-${project.version} + false + + jar-with-dependencies + + + + sampler.Main + + + + + + make-assembly + package + + single + + + +
- - - github - GitHub Packages - https://maven.pkg.github.com/EtienneDx/RealEstate - - spigot-repo @@ -129,7 +151,7 @@ com.github.EtienneDx GriefPrevention 1a4b2ea0b639c90f3858316fc4655478b5f0cdbc - + provided com.github.EtienneDx From 2b9a5a97e3743e24e2090a88bdb574c64becdbf1 Mon Sep 17 00:00:00 2001 From: Etienne Dx Date: Thu, 9 Sep 2021 12:07:06 +0200 Subject: [PATCH 06/16] docs: changelog --- .github/workflows/maven-publish.yml | 20 -------------------- CHANGELOG.md | 1 + 2 files changed, 1 insertion(+), 20 deletions(-) delete mode 100644 .github/workflows/maven-publish.yml diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml deleted file mode 100644 index 0cba306..0000000 --- a/.github/workflows/maven-publish.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Publish package to GitHub Packages -on: - release: - types: [created] -jobs: - publish: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v2 - with: - java-version: '16' - distribution: 'adopt' - - name: Publish package - run: mvn --batch-mode deploy - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dd3067..fb125e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Readme and changelog files * Error messages to *messages.yml* * List messages to *messages.yml* +* Fixed build pipeline to build with GP ### Modified * Changed java version to java 16 From df6b5bede06ccd6596196b97cbc7025e74485afe Mon Sep 17 00:00:00 2001 From: Etienne Dx Date: Fri, 14 Jan 2022 13:04:57 +0100 Subject: [PATCH 07/16] feat: updated to spigot 1.18.1 and GP 16.18-RC1 as a native dependency --- CHANGELOG.md | 5 +- pom.xml | 6 +- .../RealEstate/ClaimPermissionListener.java | 49 ++++++++++ .../RealEstate/GP_RealEstateHook.java | 93 ------------------- src/me/EtienneDx/RealEstate/Messages.java | 15 +++ src/me/EtienneDx/RealEstate/RealEstate.java | 3 +- .../RealEstate/Transactions/ClaimLease.java | 2 +- .../RealEstate/Transactions/ClaimRent.java | 2 +- 8 files changed, 73 insertions(+), 102 deletions(-) create mode 100644 src/me/EtienneDx/RealEstate/ClaimPermissionListener.java delete mode 100644 src/me/EtienneDx/RealEstate/GP_RealEstateHook.java diff --git a/CHANGELOG.md b/CHANGELOG.md index fb125e4..8e4c667 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,12 @@ * Readme and changelog files * Error messages to *messages.yml* * List messages to *messages.yml* -* Fixed build pipeline to build with GP +* Support of [GriefPrevention v16.18-RC1](https://github.com/TechFortress/GriefPrevention/releases/tag/16.18-RC1) ### Modified * Changed java version to java 16 -* Changed spigot version to 1.17.1 +* Changed spigot version to 1.18.1 +* Removed requirement for custom GP jar file ### Fixed * Sign header color formatting being lost on server restart \ No newline at end of file diff --git a/pom.xml b/pom.xml index a06d862..4030e1c 100644 --- a/pom.xml +++ b/pom.xml @@ -127,7 +127,7 @@ org.spigotmc spigot-api - 1.17.1-R0.1-SNAPSHOT + 1.18.1-R0.1-SNAPSHOT provided @@ -148,9 +148,9 @@ provided - com.github.EtienneDx + com.github.TechFortress GriefPrevention - 1a4b2ea0b639c90f3858316fc4655478b5f0cdbc + 16.18-RC1 provided diff --git a/src/me/EtienneDx/RealEstate/ClaimPermissionListener.java b/src/me/EtienneDx/RealEstate/ClaimPermissionListener.java new file mode 100644 index 0000000..8accc72 --- /dev/null +++ b/src/me/EtienneDx/RealEstate/ClaimPermissionListener.java @@ -0,0 +1,49 @@ +package me.EtienneDx.RealEstate; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.plugin.PluginManager; + +import me.EtienneDx.RealEstate.Transactions.BoughtTransaction; +import me.EtienneDx.RealEstate.Transactions.Transaction; +import me.ryanhamshire.GriefPrevention.events.ClaimPermissionCheckEvent; + +public class ClaimPermissionListener implements Listener { + void registerEvents() + { + PluginManager pm = RealEstate.instance.getServer().getPluginManager(); + + pm.registerEvents(this, RealEstate.instance); + } + + @EventHandler + public void onClaimPermission(ClaimPermissionCheckEvent event) { + Transaction b = RealEstate.transactionsStore.getTransaction(event.getClaim()); + if( + b != null && + event.getCheckedUUID().equals(b.getOwner()) && + b instanceof BoughtTransaction && + ((BoughtTransaction)b).getBuyer() != null + ) { + switch(event.getRequiredPermission()) { + case Edit: + event.setDenialReason(() -> RealEstate.instance.messages.msgErrorClaimInTransactionCantEdit); + break; + case Access: + event.setDenialReason(() -> RealEstate.instance.messages.msgErrorClaimInTransactionCantAccess); + break; + case Build: + event.setDenialReason(() -> RealEstate.instance.messages.msgErrorClaimInTransactionCantBuild); + break; + case Inventory: + event.setDenialReason(() -> RealEstate.instance.messages.msgErrorClaimInTransactionCantInventory); + break; + case Manage: + event.setDenialReason(() -> RealEstate.instance.messages.msgErrorClaimInTransactionCantManage); + break; + default: + break; + } + } + } +} diff --git a/src/me/EtienneDx/RealEstate/GP_RealEstateHook.java b/src/me/EtienneDx/RealEstate/GP_RealEstateHook.java deleted file mode 100644 index 39b25bd..0000000 --- a/src/me/EtienneDx/RealEstate/GP_RealEstateHook.java +++ /dev/null @@ -1,93 +0,0 @@ -package me.EtienneDx.RealEstate; - -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import me.EtienneDx.RealEstate.Transactions.BoughtTransaction; -import me.EtienneDx.RealEstate.Transactions.Transaction; -import me.ryanhamshire.GriefPrevention.Claim; -import me.ryanhamshire.GriefPrevention.IAddonPlugin; - -public class GP_RealEstateHook implements IAddonPlugin -{ - @Override - public String allowEdit(Claim claim, Player player) - { - Transaction b = RealEstate.transactionsStore.getTransaction(claim); - if(b != null && player.getUniqueId().equals(b.getOwner()) && b instanceof BoughtTransaction) - { - if(((BoughtTransaction)b).getBuyer() != null) - return "This claim is currently involved in a transaction, you can't edit it!"; - } - return null; - } - - @Override - public String allowBuild(Claim claim, Player player, Material material) - { - Transaction b = RealEstate.transactionsStore.getTransaction(claim); - if(b != null && player.getUniqueId().equals(b.getOwner()) && b instanceof BoughtTransaction)// ?? - { - if(((BoughtTransaction)b).getBuyer() != null) - return "This claim is currently involved in a transaction, you can't build on it!"; - } - return null; - } - - @Override - public String allowAccess(Claim claim, Player player) - { - Transaction b = RealEstate.transactionsStore.getTransaction(claim); - if(b != null && player.getUniqueId().equals(b.getOwner()) && b instanceof BoughtTransaction) - { - if(((BoughtTransaction)b).getBuyer() != null) - return "This claim is currently involved in a transaction, you can't access it!"; - } - return null; - } - - @Override - public String allowContainers(Claim claim, Player player) - { - Transaction b = RealEstate.transactionsStore.getTransaction(claim); - if(b != null && player.getUniqueId().equals(b.getOwner()) && b instanceof BoughtTransaction) - { - if(((BoughtTransaction)b).getBuyer() != null) - return "This claim is currently involved in a transaction, you can't access it's containers!"; - } - return null; - } - - @Override - public String allowGrantPermission(Claim claim, Player player) - { - Transaction b = RealEstate.transactionsStore.getTransaction(claim); - if(b != null && b instanceof BoughtTransaction) - { - if(((BoughtTransaction)b).getBuyer() != null && !((BoughtTransaction)b).getBuyer().equals(player.getUniqueId())) - return "This claim is currently involved in a transaction, you can't change any permission!"; - } - return null; - } - - @Override - public String mayResizeClaim(Claim claim, Player player, int newx1, int newx2, int newy1, int newy2, int newz1, - int newz2) - { - if(RealEstate.transactionsStore.anyTransaction(claim)) - { - return "This claim is currently involved in a transaction, you can't resize it!"; - } - return null; - } - - @Override - public String mayAbandonClaim(Claim claim, Player player) - { - if(RealEstate.transactionsStore.anyTransaction(claim)) - { - return "This claim is currently involved in a transaction, you can't abandon it!"; - } - return null; - } -} diff --git a/src/me/EtienneDx/RealEstate/Messages.java b/src/me/EtienneDx/RealEstate/Messages.java index 189e073..9a66097 100644 --- a/src/me/EtienneDx/RealEstate/Messages.java +++ b/src/me/EtienneDx/RealEstate/Messages.java @@ -60,6 +60,21 @@ public class Messages extends AnnotationConfig @ConfigField(name="RealEstate.List.NextPage", comment="0: all|sell|rent|lease; 1: next page number") public String msgListNextPage = "$6To see the next page, type $a/re list {0} {1}"; + @ConfigField(name="RealEstate.Errors.ClaimInTransaction.CantEdit") + public String msgErrorClaimInTransactionCantEdit = "$cThis claim is currently involved in a transaction, you can't edit it!"; + + @ConfigField(name="RealEstate.Errors.ClaimInTransaction.CantAccess") + public String msgErrorClaimInTransactionCantAccess = "$cThis claim is currently involved in a transaction, you can't access it!"; + + @ConfigField(name="RealEstate.Errors.ClaimInTransaction.CantBuild") + public String msgErrorClaimInTransactionCantBuild = "$cThis claim is currently involved in a transaction, you can't build on it!"; + + @ConfigField(name="RealEstate.Errors.ClaimInTransaction.CantInventory") + public String msgErrorClaimInTransactionCantInventory = "$cThis claim is currently involved in a transaction, you can't access its containers!"; + + @ConfigField(name="RealEstate.Errors.ClaimInTransaction.CantManage") + public String msgErrorClaimInTransactionCantManage = "$cThis claim is currently involved in a transaction, you can't manage it!"; + public Messages() { this.pdf = RealEstate.instance.getDescription(); diff --git a/src/me/EtienneDx/RealEstate/RealEstate.java b/src/me/EtienneDx/RealEstate/RealEstate.java index ada18f3..cdec591 100644 --- a/src/me/EtienneDx/RealEstate/RealEstate.java +++ b/src/me/EtienneDx/RealEstate/RealEstate.java @@ -96,13 +96,12 @@ public void onEnable() RealEstate.transactionsStore = new TransactionsStore(); new REListener().registerEvents(); + new ClaimPermissionListener().registerEvents(); manager = new BukkitCommandManager(this); manager.enableUnstableAPI("help"); registerConditions(); manager.registerCommand(new RECommand()); - - GriefPrevention.addonPlugins.add(new GP_RealEstateHook()); } private void registerConditions() diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java index af8f20a..b59e57a 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java @@ -355,7 +355,7 @@ public void interact(Player player) lastPayment = LocalDateTime.now(); paymentsLeft--; claim.setPermission(buyer.toString(), ClaimPermission.Build); - claim.allowGrantPermission(player); + claim.setPermission(player.getUniqueId().toString(), ClaimPermission.Manage); GriefPrevention.instance.dataStore.saveClaim(claim); getHolder().breakNaturally();// leases don't have signs indicating the remaining time update(); diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java index d288039..c5f148d 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java @@ -329,7 +329,7 @@ public void interact(Player player) startDate = LocalDateTime.now(); autoRenew = false; claim.setPermission(buyer.toString(), buildTrust ? ClaimPermission.Build : ClaimPermission.Inventory); - claim.allowGrantPermission(player); + claim.setPermission(player.getUniqueId().toString(), ClaimPermission.Manage); claim.managers.add(player.getUniqueId().toString()); claim.setSubclaimRestrictions(true); GriefPrevention.instance.dataStore.saveClaim(claim); From 7e7ca3b39843d2f14fd5b01e3bdb7405b3d778b1 Mon Sep 17 00:00:00 2001 From: Etienne Dx Date: Fri, 14 Jan 2022 18:38:17 +0100 Subject: [PATCH 08/16] feat: Moved most messages to Messages.java config file --- CHANGELOG.md | 1 + src/me/EtienneDx/RealEstate/Messages.java | 236 +++++++++++++++++- src/me/EtienneDx/RealEstate/RECommand.java | 148 ++++++----- src/me/EtienneDx/RealEstate/REListener.java | 90 +++---- .../RealEstate/Transactions/ClaimLease.java | 150 +++++------ .../RealEstate/Transactions/ClaimRent.java | 3 +- 6 files changed, 430 insertions(+), 198 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e4c667..136c406 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Readme and changelog files * Error messages to *messages.yml* * List messages to *messages.yml* +* Info messages to *messages.yml* * Support of [GriefPrevention v16.18-RC1](https://github.com/TechFortress/GriefPrevention/releases/tag/16.18-RC1) ### Modified diff --git a/src/me/EtienneDx/RealEstate/Messages.java b/src/me/EtienneDx/RealEstate/Messages.java index 9a66097..e30c164 100644 --- a/src/me/EtienneDx/RealEstate/Messages.java +++ b/src/me/EtienneDx/RealEstate/Messages.java @@ -12,6 +12,18 @@ public class Messages extends AnnotationConfig { public PluginDescriptionFile pdf; + @ConfigField(name="RealEstate.Keywords.Enabled", comment = "Keywords used within other messages") + public String keywordEnabled = "enabled"; + + @ConfigField(name="RealEstate.Keywords.Disabled") + public String keywordDisabled = "disabled"; + + @ConfigField(name="RealEstate.Keywords.Claim") + public String keywordClaim = "claim"; + + @ConfigField(name="RealEstate.Keywords.Subclaim") + public String keywordSubclaim = "subclaim"; + @ConfigField(name="RealEstate.NoTransactionFound") public String msgNoTransactionFound = "$cNo transaction found at your location!"; @@ -53,12 +65,6 @@ public class Messages extends AnnotationConfig @ConfigField(name="RealEstate.Errors.InvalidOption") public String msgErrorInvalidOption = "$cInvalid option provided!"; - - @ConfigField(name="RealEstate.List.Header", comment = "0: RE Offers|Sell Offers|Rent Offers|Lease Offers; 1: Page number; 2: Page count") - public String msgListTransactionsHeader = "$1----= $f[ $6{0} page $2 {1} $6/ $2{2} $f] $1=----"; - - @ConfigField(name="RealEstate.List.NextPage", comment="0: all|sell|rent|lease; 1: next page number") - public String msgListNextPage = "$6To see the next page, type $a/re list {0} {1}"; @ConfigField(name="RealEstate.Errors.ClaimInTransaction.CantEdit") public String msgErrorClaimInTransactionCantEdit = "$cThis claim is currently involved in a transaction, you can't edit it!"; @@ -74,6 +80,220 @@ public class Messages extends AnnotationConfig @ConfigField(name="RealEstate.Errors.ClaimInTransaction.CantManage") public String msgErrorClaimInTransactionCantManage = "$cThis claim is currently involved in a transaction, you can't manage it!"; + + @ConfigField(name="RealEstate.Errors.Command.Usage", comment = "0: command usage") + public String msgErrorCommandUsage = "$cUsage: {0}"; + + @ConfigField(name="RealEstate.Errors.BuyerOnly") + public String msgErrorBuyerOnly = "$cOnly the buyer can perform this command!"; + + @ConfigField(name="RealEstate.Errors.InvalidNumber", comment = "0: number") + public String msgErrorInvalidNumber = "$c{0} is not a valid number!"; + + @ConfigField(name="RealEstate.Errors.NegativeNumber", comment = "0: number") + public String msgErrorNegativeNumber = "$c{0} is a negative number!"; + + @ConfigField(name="RealEstate.Errors.NegativePrice", comment = "0: price") + public String msgErrorNegativePrice = "$cThe price must be greater than zero!"; + + @ConfigField(name="RealEstate.Errors.NonIntegerPrice", comment = "0: price") + public String msgErrorNonIntegerPrice = "$cThe price must be an integer!"; + + @ConfigField(name="RealEstate.Errors.InvalidDuration", comment = "0: duration, 1: example of duration format, 2: example, 3: example") + public String msgErrorInvalidDuration = "$c{0} is not a valid duration! Durations must be in the format {1} or {2} or {3}!"; + + @ConfigField(name="RealEstate.Errors.AutoRenew.Disabled") + public String msgErrorAutoRenewDisabled = "$cAutomatic renew is disabled!"; + + @ConfigField(name="RealEstate.Errors.ExitOffer.AlreadyExists") + public String msgErrorExitOfferAlreadyExists = "$cThere is already an exit proposition for this transaction!"; + + @ConfigField(name="RealEstate.Errors.ExitOffer.NoBuyer") + public String msgErrorExitOfferNoBuyer = "$cNo one is engaged by this transaction yet!"; + + @ConfigField(name="RealEstate.Errors.ExitOffer.None") + public String msgErrorExitOfferNone = "$cThere is currently no exit offer for this claim!"; + + @ConfigField(name="RealEstate.Errors.ExitOffer.CantAcceptSelf") + public String msgErrorExitOfferCantAcceptSelf = "$cYou can't accept your own exit offer!"; + + @ConfigField(name="RealEstate.Errors.ExitOffer.CantRefuseSelf") + public String msgErrorExitOfferCantRefuseSelf = "$cYou can't refuse your own exit offer!"; + + @ConfigField(name="RealEstate.Errors.ExitOffer.CantCancelOther") + public String msgErrorExitOfferCantCancelOther = "$cOnly the player who created this exit proposition may cancel it!"; + + @ConfigField(name="RealEstate.Errors.Sign.NotInClaim") + public String msgErrorSignNotInClaim = "$cThe sign you placed is not inside a claim!"; + + @ConfigField(name="RealEstate.Errors.Sign.OngoingTransaction") + public String msgErrorSignOngoingTransaction = "$cThis claim already has an ongoing transaction!"; + + @ConfigField(name="RealEstate.Errors.Sign.ParentOngoingTransaction") + public String msgErrorSignParentOngoingTransaction = "$cThis claim's parent already has an ongoing transaction!"; + + @ConfigField(name="RealEstate.Errors.Sign.SubclaimOngoingTransaction") + public String msgErrorSignSubclaimOngoingTransaction = "$cThis claim has subclaims with ongoing transactions!"; + + @ConfigField(name="RealEstate.Errors.Sign.SellingDisabled") + public String msgErrorSignSellingDisabled = "$cSelling is disabled!"; + + @ConfigField(name="RealEstate.Errors.Sign.LeasingDisabled") + public String msgErrorSignLeasingDisabled = "$cLeasing is disabled!"; + + @ConfigField(name="RealEstate.Errors.Sign.RentingDisabled") + public String msgErrorSignRentingDisabled = "$cRenting is disabled!"; + + @ConfigField(name="RealEstate.Errors.Sign.NoSellPermission", comment = "0: claim type") + public String msgErrorSignNoSellPermission = "$cYou don't have permission to sell this {0}!"; + + @ConfigField(name="RealEstate.Errors.Sign.NoLeasePermission", comment = "0: claim type") + public String msgErrorSignNoLeasePermission = "$cYou don't have permission to lease this {0}!"; + + @ConfigField(name="RealEstate.Errors.Sign.NoRentPermission", comment = "0: claim type") + public String msgErrorSignNoRentPermission = "$cYou don't have permission to rent this {0}!"; + + @ConfigField(name="RealEstate.Errors.Sign.NoAdminSellPermission", comment = "0: claim type") + public String msgErrorSignNoAdminSellPermission = "$cYou don't have permission to sell this admin {0}!"; + + @ConfigField(name="RealEstate.Errors.Sign.NoAdminLeasePermission", comment = "0: claim type") + public String msgErrorSignNoAdminLeasePermission = "$cYou don't have permission to lease this admin {0}!"; + + @ConfigField(name="RealEstate.Errors.Sign.NoAdminRentPermission", comment = "0: claim type") + public String msgErrorSignNoAdminRentPermission = "$cYou don't have permission to rent this admin {0}!"; + + @ConfigField(name="RealEstate.Errors.Sign.NotOwner", comment = "0: claim type") + public String msgErrorSignNotOwner = "$cYou can only sell/rent/lease {0} you own!"; + + @ConfigField(name="RealEstate.Errors.Sign.NotAuthor") + public String msgErrorSignNotAuthor = "$cOnly the author of the sell/rent/lease sign is allowed to destroy it!"; + + @ConfigField(name="RealEstate.Errors.Sign.NotAdmin") + public String msgErrorSignNotAdmin = "$cOnly an admin is allowed to destroy this sign!"; + + @ConfigField(name="RealEstate.Errors.Sign.NoTransaction") + public String msgErrorSignNoTransaction = "$cThis claim is no longer for rent, sell or lease, sorry..."; + + @ConfigField(name="RealEstate.Errors.Claim.DoesNotExist") + public String msgErrorClaimDoesNotExist = "$cThis claim does not exist!"; + + @ConfigField(name="RealEstate.Errors.Claim.AlreadyOwner", comment = "0: claim type") + public String msgErrorClaimAlreadyOwner = "$cYou are already the owner of this {0}!"; + + @ConfigField(name="RealEstate.Errors.Claim.NotSoldByOwner", comment = "0: claim type") + public String msgErrorClaimNotSoldByOwner = "$cThis {0} is not sold by its owner!"; + + @ConfigField(name="RealEstate.Errors.Claim.NotLeasedByOwner", comment = "0: claim type") + public String msgErrorClaimNotLeasedByOwner = "$cThis {0} is not leased by its owner!"; + + @ConfigField(name="RealEstate.Errors.Claim.NotRentedByOwner", comment = "0: claim type") + public String msgErrorClaimNotRentedByOwner = "$cThis {0} is not rented by its owner!"; + + @ConfigField(name="RealEstate.Errors.Claim.NoBuyPermission", comment = "0: claim type") + public String msgErrorClaimNoBuyPermission = "$cYou don't have permission to buy this {0}!"; + + @ConfigField(name="RealEstate.Errors.Claim.NoLeasePermission", comment = "0: claim type") + public String msgErrorClaimNoLeasePermission = "$cYou don't have permission to lease this {0}!"; + + @ConfigField(name="RealEstate.Errors.Claim.NoRentPermission", comment = "0: claim type") + public String msgErrorClaimNoRentPermission = "$cYou don't have permission to rent this {0}!"; + + @ConfigField(name="RealEstate.Errors.Claim.AlreadyLeased", comment = "0: claim type") + public String msgErrorClaimAlreadyLeased = "$cThis {0} is already leased!"; + + @ConfigField(name="RealEstate.Errors.Claim.AlreadyRented", comment = "0: claim type") + public String msgErrorClaimAlreadyRented = "$cThis {0} is already rented!"; + + @ConfigField(name="RealEstate.Errors.Claim.NoInfoPermission") + public String msgErrorClaimNoInfoPermission = "$cYou don't have permission to view this real estate informations!"; + + @ConfigField(name="RealEstate.Info.ExitOffer.None") + public String msgInfoExitOfferNone = "$bThere is currently no exit offer for this claim!"; + + @ConfigField(name="RealEstate.Info.ExitOffer.MadeByStatus", comment = "0: formatted price") + public String msgInfoExitOfferMadeByStatus = "$bYou offered to exit the contract for $a{0}, but your offer hasn't been accepted or denied yet..."; + + @ConfigField(name="RealEstate.Info.ExitOffer.MadeToStatus", comment = "0: player who made the offer; 1: formatted price") + public String msgInfoExitOfferMadeToStatus = "$a{0} $boffered to exit the contract for $a{1}"; + + @ConfigField(name="RealEstate.Info.ExitOffer.Cancel", comment = "0: cancel command") + public String msgInfoExitOfferCancel = "$bTo cancel your offer, use $d{0}"; + + @ConfigField(name="RealEstate.Info.ExitOffer.Accept", comment = "0: accept command") + public String msgInfoExitOfferAccept = "$bTo accept this offer, use $d{0}"; + + @ConfigField(name="RealEstate.Info.ExitOffer.Reject", comment = "0: reject command") + public String msgInfoExitOfferReject = "$bTo reject this offer, use $d{0}"; + + @ConfigField(name="RealEstate.Info.ExitOffer.CreatedBySelf", comment = "0: formatted price") + public String msgInfoExitOfferCreatedBySelf = "$bThe offer has been successfully created for $a{0}"; + + @ConfigField(name="RealEstate.Info.ExitOffer.CreatedByOther", comment = "0: player name, 1: claim type, 2: formatted price, 3: claim location") + public String msgInfoExitOfferCreatedByOther = "$a{0} $bhas created an offer to exit the transaction for the {1} at $a{3} $bfor $a{2}"; + + @ConfigField(name="RealEstate.Info.ExitOffer.AcceptedBySelf", comment = "0: claim type, 1:formatted price") + public String msgInfoExitOfferAcceptedBySelf = "$bThe {0} is no longer rented or leased, you have been charged $a{1}"; + + @ConfigField(name="RealEstate.Info.ExitOffer.AcceptedByOther", comment = "0: player name, 1: claim type, 2: formatted price, 3: claim location") + public String msgInfoExitOfferAcceptedByOther = "$a{0} $bhas accepted the offer to exit the transaction for the {1} at $a{3} $bfor $a{2}. It is no longer leased or rented."; + + @ConfigField(name="RealEstate.Info.ExitOffer.RejectedBySelf") + public String msgInfoExitOfferRejectedBySelf = "$bThe exit offer has been refused."; + + @ConfigField(name="RealEstate.Info.ExitOffer.RejectedByOther", comment = "0: player name, 1: claim type, 2: claim location") + public String msgInfoExitOfferRejectedByOther = "$a{0} $bhas refused the offer to exit the transaction for the {1} at $a{2}"; + + @ConfigField(name="RealEstate.Info.ExitOffer.CancelledBySelf") + public String msgInfoExitOfferCancelledBySelf = "$bThe exit offer has been cancelled."; + + @ConfigField(name="RealEstate.Info.ExitOffer.CancelledByOther", comment = "0: player name, 1: claim type, 2: claim location") + public String msgInfoExitOfferCancelledByOther = "$a{0} $bhas cancelled the offer to exit the transaction for the {1} at $a{2}"; + + @ConfigField(name="RealEstate.Info.Claim.OwnerSold", comment = "0: buyer name, 1: claim type, 2: formatted price, 3: claim location") + public String msgInfoClaimOwnerSold = "$a{0} $bhas bought the {1} at $a{3} $bfor $a{2}"; + + @ConfigField(name="RealEstate.Info.Claim.OwnerLeaseStarted", comment = "0: buyer name, 1: claim type, 2: formatted price, 3: claim location, 4: payments left") + public String msgInfoClaimOwnerLeaseStarted = "$a{0} $bhas leased the {1} at $a{3} $bfor $a{2} with $a{4} $bpayments left"; + + @ConfigField(name="RealEstate.Info.Claim.OwnerRented", comment = "0: buyer name, 1: claim type, 2: formatted price, 3: claim location") + public String msgInfoClaimOwnerRented = "$a{0} $bhas rented the {1} at $a{3} $bfor $a{2}"; + + @ConfigField(name="RealEstate.Info.Claim.BuyerBought", comment = "1: claim type, 2: formatted price") + public String msgInfoClaimBuyerSold = "$bYou have bought the {1} for $a{2}"; + + @ConfigField(name="RealEstate.Info.Claim.BuyerLeaseStarted", comment = "1: claim type, 2: formatted price, 3: payments left") + public String msgInfoClaimBuyerLeaseStarted = "$bYou have leased the {1} for $a{2} with $a{3} $bpayments left"; + + @ConfigField(name="RealEstate.Info.Claim.BuyerRented", comment = "1: claim type, 2: formatted price") + public String msgInfoClaimBuyerRented = "$bYou have rented the {1} for $a{2}"; + + @ConfigField(name="RealEstate.Info.Claim.Info.Header") + public String msgInfoClaimInfoHeader = "$9-----= $f[$6RealEstate Lease Info$f]$9 =-----"; + + @ConfigField(name="RealEstate.Info.Claim.Info.Lease.GeneralNoBuyer", comment = "0: claim type, 1: payments left, 2: formatted price, 3: frequency") + public String msgInfoClaimInfoGeneralLeaseNoBuyer = "$bThis {0} is for lease for $a{1} $bpayments of $a{2} each. Payments are due every $a{3}"; + + @ConfigField(name="RealEstate.Info.Claim.Info.Lease.GeneralBuyer", comment = "0: claim type, 1: buyer name, 2: formatted price, 3: payments left, 4: next payment due, 5: frequency") + public String msgInfoClaimInfoGeneralLeaseBuyer = "$bThis {0} is currently leased by $a{1}$b for $a{2}$b. There is $a{3} $bpayments left. Next payment is in $a{4}$b. Payments are due every $a{5}"; + + @ConfigField(name="RealEstate.Info.Claim.Info.Lease.Oneline", comment = "0: claim area, 1: location, 2: payments left, 3: period, 4: formatted price") + public String msgInfoClaimInfoLeaseOneline = "$2{0} $bblocks to $2Lease $bat $2{1} $bfor $a{2} periods of $a{3}$b, each period costs $a{4}"; + + @ConfigField(name="RealEstate.Info.Claim.Info.Owner", comment = "0: owner name") + public String msgInfoClaimInfoOwner = "$bThe current owner is $a{0}"; + + @ConfigField(name="RealEstate.Info.Claim.Info.MainOwner", comment = "0: owner name") + public String msgInfoClaimInfoMainOwner = "$bThe main claim's owner is $a{0}"; + + @ConfigField(name="RealEstate.Info.Claim.Info.Note") + public String msgInfoClaimInfoNote = "$dNote: You will only get access to this subclaim."; + + @ConfigField(name="RealEstate.List.Header", comment = "0: RE Offers|Sell Offers|Rent Offers|Lease Offers; 1: Page number; 2: Page count") + public String msgListTransactionsHeader = "$1----= $f[ $6{0} page $2 {1} $6/ $2{2} $f] $1=----"; + + @ConfigField(name="RealEstate.List.NextPage", comment="0: all|sell|rent|lease; 1: next page number") + public String msgListNextPage = "$6To see the next page, type $a/re list {0} {1}"; + public Messages() { @@ -86,7 +306,7 @@ public void loadConfig() this.loadConfig(RealEstate.languagesDirectory + "/" + RealEstate.instance.config.languageFile); } - synchronized public String getMessage(String msgTemplate, String... args) { + public static String getMessage(String msgTemplate, String... args) { for (int i = 0; i < args.length; i++) { String param = args[i]; msgTemplate = msgTemplate.replace("{" + i + "}", param); @@ -101,7 +321,7 @@ public static void sendMessage(CommandSender player, String msgTemplate, String. //sends a color-coded message to a player public static void sendMessage(CommandSender player, String msgTemplate, long delayInTicks, String... args) { - String message = RealEstate.instance.messages.getMessage(msgTemplate, args); + String message = getMessage(msgTemplate, args); sendMessage(player, message, delayInTicks); } diff --git a/src/me/EtienneDx/RealEstate/RECommand.java b/src/me/EtienneDx/RealEstate/RECommand.java index b57c134..fd01a8f 100644 --- a/src/me/EtienneDx/RealEstate/RECommand.java +++ b/src/me/EtienneDx/RealEstate/RECommand.java @@ -4,7 +4,6 @@ import java.util.UUID; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; @@ -156,29 +155,36 @@ public static void renewRent(Player player, @Optional String newStatus) Location loc = player.getLocation(); Claim claim = GriefPrevention.instance.dataStore.getClaimAt(loc, false, null); ClaimRent cr = (ClaimRent)RealEstate.transactionsStore.getTransaction(claim); - String claimType = claim.parent == null ? "claim" : "subclaim"; + String claimType = claim.parent == null ? + RealEstate.instance.messages.keywordClaim : RealEstate.instance.messages.keywordSubclaim; if(!RealEstate.instance.config.cfgEnableAutoRenew) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Automatic renew is disabled!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorAutoRenewDisabled); return; } if(newStatus == null) { - Messages.sendMessage(player, RealEstate.instance.messages.msgRenewRentCurrently, cr.autoRenew ? "enabled" : "disabled", claimType); + Messages.sendMessage(player, RealEstate.instance.messages.msgRenewRentCurrently, cr.autoRenew ? + RealEstate.instance.messages.keywordEnabled : + RealEstate.instance.messages.keywordDisabled, + claimType); } else if(!newStatus.equalsIgnoreCase("enable") && !newStatus.equalsIgnoreCase("disable")) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Usage : /re renewrent [enable|disable]!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorCommandUsage, "/re renewrent [enable|disable]"); } else if(cr.buyer.equals(player.getUniqueId())) { cr.autoRenew = newStatus.equalsIgnoreCase("enable"); RealEstate.transactionsStore.saveData(); - Messages.sendMessage(player, RealEstate.instance.messages.msgRenewRentNow, cr.autoRenew ? "enabled" : "disabled", claimType); + Messages.sendMessage(player, RealEstate.instance.messages.msgRenewRentNow, cr.autoRenew ? + RealEstate.instance.messages.keywordEnabled : + RealEstate.instance.messages.keywordDisabled, + claimType); } else { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Only the buyer may change this setting!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorBuyerOnly); } } @@ -194,24 +200,23 @@ public void info(Player player) BoughtTransaction bt = (BoughtTransaction)RealEstate.transactionsStore.getTransaction(player); if(bt.exitOffer == null) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + "There is currently no exit offer for this claim!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgInfoExitOfferNone); } else if(bt.exitOffer.offerBy.equals(player.getUniqueId())) { - String msg = RealEstate.instance.config.chatPrefix + ChatColor.AQUA + "You offered to exit the contract for " + - ChatColor.GREEN + bt.exitOffer.price + " " + RealEstate.econ.currencyNamePlural() + ChatColor.AQUA + - ", but your offer hasn't been accepted or denied yet...\n"; - msg += ChatColor.AQUA + "To cancel your offer, just type " + ChatColor.LIGHT_PURPLE + "/re exitoffer cancel"; - player.sendMessage(msg); + Messages.sendMessage(player, RealEstate.instance.messages.msgInfoExitOfferMadeByStatus, + RealEstate.econ.format(bt.exitOffer.price)); + Messages.sendMessage(player, RealEstate.instance.messages.msgInfoExitOfferCancel, + "/re exitoffer cancel"); } - else// it is the other person + else// it is the other player { - String msg = RealEstate.instance.config.chatPrefix + ChatColor.GREEN + Bukkit.getOfflinePlayer(bt.exitOffer.offerBy).getName() + - ChatColor.AQUA + " offered to exit the contract for " + - ChatColor.GREEN + bt.exitOffer.price + " " + RealEstate.econ.currencyNamePlural() + "\n"; - msg += ChatColor.AQUA + "To accept the offer, just type " + ChatColor.LIGHT_PURPLE + "/re exitoffer accept\n"; - msg += ChatColor.AQUA + "To refuse the offer, just type " + ChatColor.LIGHT_PURPLE + "/re exitoffer refuse\n"; - player.sendMessage(msg); + Messages.sendMessage(player, RealEstate.instance.messages.msgInfoExitOfferMadeToStatus, + Bukkit.getOfflinePlayer(bt.exitOffer.offerBy).getName(), RealEstate.econ.format(bt.exitOffer.price)); + Messages.sendMessage(player, RealEstate.instance.messages.msgInfoExitOfferAccept, + "/re exitoffer accept"); + Messages.sendMessage(player, RealEstate.instance.messages.msgInfoExitOfferReject, + "/re exitoffer refuse"); } } @@ -223,40 +228,40 @@ public void create(Player player, @Conditions("positiveDouble") Double price) BoughtTransaction bt = (BoughtTransaction)RealEstate.transactionsStore.getTransaction(player); if(bt.exitOffer != null) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + - "There is already an exit proposition for this transaction!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorExitOfferAlreadyExists); return; } if(bt.buyer == null) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + - "No one is engaged by this transaction yet!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorExitOfferNoBuyer); return; } bt.exitOffer = new ExitOffer(player.getUniqueId(), price); - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + - "The proposition has been successfully created!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgInfoExitOfferCreatedBySelf, + RealEstate.econ.format(price)); + UUID other = player.getUniqueId().equals(bt.owner) ? bt.buyer : bt.owner; if(other != null)// not an admin claim { OfflinePlayer otherP = Bukkit.getOfflinePlayer(other); Location loc = player.getLocation(); - String claimType = GriefPrevention.instance.dataStore.getClaimAt(loc, false, null).parent == null ? "claim" : "subclaim"; + String claimType = GriefPrevention.instance.dataStore.getClaimAt(loc, false, null).parent == null ? + RealEstate.instance.messages.keywordClaim : RealEstate.instance.messages.keywordSubclaim; + String location = "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() + ", Z: " + + loc.getBlockZ() + "]"; + if(otherP.isOnline()) { - ((Player)otherP).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + player.getName() + - ChatColor.AQUA + " has created an offer to exit the rent/lease contract for the " + claimType + " at " + - ChatColor.BLUE + "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() + ", Z: " - + loc.getBlockZ() + "]" + ChatColor.AQUA + " for " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural()); + Messages.sendMessage(otherP.getPlayer(), RealEstate.instance.messages.msgInfoExitOfferCreatedByOther, + player.getName(), claimType, RealEstate.econ.format(price), location); } else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) { User u = RealEstate.ess.getUser(other); - u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + player.getName() + - ChatColor.AQUA + " has created an offer to exit the rent/lease contract for the " + claimType + " at " + - ChatColor.BLUE + "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() + ", Z: " - + loc.getBlockZ() + "]" + ChatColor.AQUA + " for " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural()); + u.addMail(RealEstate.instance.config.chatPrefix + + Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferCreatedByOther, + player.getName(), claimType, RealEstate.econ.format(price), location)); } } } @@ -271,36 +276,35 @@ public void accept(Player player) String claimType = claim.parent == null ? "claim" : "subclaim"; if(bt.exitOffer == null) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + - "There has been no exit propositions for this transaction!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorExitOfferNone); } else if(bt.exitOffer.offerBy.equals(player.getUniqueId())) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + - "You can't accept or refuse an offer you made!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorExitOfferCantAcceptSelf); } else if(Utils.makePayment(player.getUniqueId(), bt.exitOffer.offerBy, bt.exitOffer.price, true, false)) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + - "This exit offer has been accepted, the " + claimType + " is no longer rented or leased!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgInfoExitOfferAcceptedBySelf, + claimType, RealEstate.econ.format(bt.exitOffer.price)); + UUID other = player.getUniqueId().equals(bt.owner) ? bt.buyer : bt.owner; + String location = "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() + + ", Z: " + loc.getBlockZ() + "]"; if(other != null) { OfflinePlayer otherP = Bukkit.getOfflinePlayer(other); if(otherP.isOnline()) { - ((Player)otherP).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + player.getName() + - ChatColor.AQUA + " has accepted your offer to exit the rent/lease contract for the " + claimType + " at " + - ChatColor.BLUE + "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() + - ", Z: " + loc.getBlockZ() + "]. It is no longer rented or leased."); + Messages.sendMessage(otherP.getPlayer(), RealEstate.instance.messages.msgInfoExitOfferAcceptedByOther, + player.getName(), claimType, RealEstate.econ.format(bt.exitOffer.price), location); } else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) { User u = RealEstate.ess.getUser(other); - u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + player.getName() + - ChatColor.AQUA + " has accepted your offer to exit the rent/lease contract for the " + claimType + " at " + - ChatColor.BLUE + "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() + - ", Z: " + loc.getBlockZ() + "]. It is no longer rented or leased."); + + u.addMail(RealEstate.instance.config.chatPrefix + + Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferAcceptedByOther, + player.getName(), claimType, RealEstate.econ.format(bt.exitOffer.price), location)); } } bt.exitOffer = null; @@ -323,37 +327,33 @@ public void refuse(Player player) String claimType = claim.parent == null ? "claim" : "subclaim"; if(bt.exitOffer == null) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + - "There has been no exit propositions for this transaction!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorExitOfferNone); } else if(bt.exitOffer.offerBy.equals(player.getUniqueId())) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + - "You can't accept or refuse an offer you made!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorExitOfferCantRefuseSelf); } else { bt.exitOffer = null; - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + - "This exit offer has been refused"); + Messages.sendMessage(player, RealEstate.instance.messages.msgInfoExitOfferRejectedBySelf); UUID other = player.getUniqueId().equals(bt.owner) ? bt.buyer : bt.owner; + String location = "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() + + ", Z: " + loc.getBlockZ() + "]"; if(other != null) { OfflinePlayer otherP = Bukkit.getOfflinePlayer(other); if(otherP.isOnline()) { - ((Player)otherP).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + player.getName() + - ChatColor.AQUA + " has refused your offer to exit the rent/lease contract for the " + claimType + " at " + - ChatColor.BLUE + "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() + - ", Z: " + loc.getBlockZ() + "]"); + Messages.sendMessage(otherP.getPlayer(), RealEstate.instance.messages.msgInfoExitOfferRejectedByOther, + player.getName(), claimType, location); } else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) { User u = RealEstate.ess.getUser(other); - u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + player.getName() + - ChatColor.AQUA + " has refused your offer to exit the rent/lease contract for the " + claimType + " at " + - ChatColor.BLUE + "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() + - ", Z: " + loc.getBlockZ() + "]"); + u.addMail(RealEstate.instance.config.chatPrefix + + Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferRejectedByOther, + player.getName(), claimType, location)); } } } @@ -370,33 +370,31 @@ public void cancel(Player player) if(bt.exitOffer.offerBy.equals(player.getUniqueId())) { bt.exitOffer = null; - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + - "This exit offer has been cancelled"); + Messages.sendMessage(player, RealEstate.instance.messages.msgInfoExitOfferCancelledBySelf); + UUID other = player.getUniqueId().equals(bt.owner) ? bt.buyer : bt.owner; + String location = "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() + + ", Z: " + loc.getBlockZ() + "]"; if(other != null) { OfflinePlayer otherP = Bukkit.getOfflinePlayer(other); if(otherP.isOnline()) { - ((Player)otherP).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + player.getName() + - ChatColor.AQUA + " has cancelled his offer to exit the rent/lease contract for the " + claimType + " at " + - ChatColor.BLUE + "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() + ", Z: " - + loc.getBlockZ() + "]"); + Messages.sendMessage(otherP.getPlayer(), RealEstate.instance.messages.msgInfoExitOfferCancelledByOther, + player.getName(), claimType, location); } else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) { User u = RealEstate.ess.getUser(other); - u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + player.getName() + - ChatColor.AQUA + " has cancelled his offer to exit the rent/lease contract for the " + claimType + " at " + - ChatColor.BLUE + "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() + ", Z: " - + loc.getBlockZ() + "]"); + u.addMail(RealEstate.instance.config.chatPrefix + + Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferCancelledByOther, + player.getName(), claimType, location)); } } } else { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + - "Only the player who created this exit proposition may cancel it"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorExitOfferCantCancelOther); } } } diff --git a/src/me/EtienneDx/RealEstate/REListener.java b/src/me/EtienneDx/RealEstate/REListener.java index 9c1675f..29afac9 100644 --- a/src/me/EtienneDx/RealEstate/REListener.java +++ b/src/me/EtienneDx/RealEstate/REListener.java @@ -44,21 +44,21 @@ public void onSignChange(SignChangeEvent event) Claim claim = GriefPrevention.instance.dataStore.getClaimAt(loc, false, null); if(claim == null)// must have something to sell { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "The sign you placed is not inside a claim!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignNotInClaim); event.setCancelled(true); event.getBlock().breakNaturally(); return; } if(RealEstate.transactionsStore.anyTransaction(claim)) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "This claim already has an ongoing transaction!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignOngoingTransaction); event.setCancelled(true); event.getBlock().breakNaturally(); return; } if(RealEstate.transactionsStore.anyTransaction(claim.parent)) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "The parent claim already has an ongoing transaction!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignParentOngoingTransaction); event.setCancelled(true); event.getBlock().breakNaturally(); return; @@ -67,8 +67,7 @@ public void onSignChange(SignChangeEvent event) { if(RealEstate.transactionsStore.anyTransaction(c)) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + - "A subclaim of this claim already has an ongoing transaction!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignSubclaimOngoingTransaction); event.setCancelled(true); event.getBlock().breakNaturally(); return; @@ -80,16 +79,18 @@ public void onSignChange(SignChangeEvent event) { if(!RealEstate.instance.config.cfgEnableSell) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Selling is disabled!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignSellingDisabled); event.setCancelled(true); event.getBlock().breakNaturally(); return; } String type = claim.parent == null ? "claim" : "subclaim"; + String typeDisplay = claim.parent == null ? + RealEstate.instance.messages.keywordClaim : RealEstate.instance.messages.keywordSubclaim; if(!RealEstate.perms.has(player, "realestate." + type + ".sell")) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You don't have the permission to sell " + type + "s!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignNoSellPermission, typeDisplay); event.setCancelled(true); event.getBlock().breakNaturally(); return; @@ -103,21 +104,21 @@ public void onSignChange(SignChangeEvent event) } catch (NumberFormatException e) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "The price you entered is not a valid number!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorInvalidNumber, event.getLine(1)); event.setCancelled(true); event.getBlock().breakNaturally(); return; } if(price <= 0) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "The price must be greater than 0!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorNegativePrice, event.getLine(1)); event.setCancelled(true); event.getBlock().breakNaturally(); return; } if((price%1)!=0 && !RealEstate.instance.config.cfgUseDecimalCurrency) //if the price has a decimal number AND Decimal currency is disabled { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "The price cannot have a decimal number!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorNonIntegerPrice, event.getLine(1)); event.setCancelled(true); event.getBlock().breakNaturally(); return; @@ -127,7 +128,7 @@ public void onSignChange(SignChangeEvent event) { if(!RealEstate.perms.has(player, "realestate.admin"))// admin may sell admin claims { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You don't have the permission to sell admin claims!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignNoAdminSellPermission, typeDisplay); event.setCancelled(true); event.getBlock().breakNaturally(); return; @@ -135,7 +136,7 @@ public void onSignChange(SignChangeEvent event) } else if(type.equals("claim") && !player.getUniqueId().equals(claim.ownerID))// only the owner may sell his claim { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You can only sell claims you own!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignNotOwner, typeDisplay); event.setCancelled(true); event.getBlock().breakNaturally(); return; @@ -150,15 +151,17 @@ else if(RealEstate.instance.config.cfgRentKeywords.contains(event.getLine(0).toL { if(!RealEstate.instance.config.cfgEnableRent) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Renting is disabled!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignRentingDisabled); event.setCancelled(true); event.getBlock().breakNaturally(); return; } String type = claim.parent == null ? "claim" : "subclaim"; + String typeDisplay = claim.parent == null ? + RealEstate.instance.messages.keywordClaim : RealEstate.instance.messages.keywordSubclaim; if(!RealEstate.perms.has(player, "realestate." + type + ".rent")) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You don't have the permission to rent " + type + "s!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignNoRentPermission, typeDisplay); event.setCancelled(true); event.getBlock().breakNaturally(); return; @@ -172,21 +175,21 @@ else if(RealEstate.instance.config.cfgRentKeywords.contains(event.getLine(0).toL } catch (NumberFormatException e) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "The price you entered is not a valid number!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorInvalidNumber, event.getLine(1)); event.setCancelled(true); event.getBlock().breakNaturally(); return; } if(price <= 0) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "The price must be greater than 0!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorNegativePrice, event.getLine(1)); event.setCancelled(true); event.getBlock().breakNaturally(); return; } if((price%1)!=0 && !RealEstate.instance.config.cfgUseDecimalCurrency) //if the price has a decimal number AND Decimal currency is disabled { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "The price cannot have a decimal number!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorNonIntegerPrice, event.getLine(1)); event.setCancelled(true); event.getBlock().breakNaturally(); return; @@ -199,9 +202,10 @@ else if(RealEstate.instance.config.cfgRentKeywords.contains(event.getLine(0).toL int duration = parseDuration(event.getLine(2)); if(duration == 0) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Couldn't read the date!\n" + - "Date must be formatted as follow : " + ChatColor.GREEN + "10 weeks" + ChatColor.RED + " or " + - ChatColor.GREEN + "3 days" + ChatColor.RED + " or " + ChatColor.GREEN + "1 week 3 days"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorInvalidDuration, event.getLine(2), + ChatColor.GREEN + "10 weeks", + ChatColor.GREEN + "3 days", + ChatColor.GREEN + "1 week 3 days"); event.setCancelled(true); event.getBlock().breakNaturally(); return; @@ -219,16 +223,14 @@ else if(RealEstate.instance.config.cfgRentKeywords.contains(event.getLine(0).toL } catch (NumberFormatException e) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + - "The number of rent periods you entered is not a valid number!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorInvalidNumber, event.getLine(3)); event.setCancelled(true); event.getBlock().breakNaturally(); return; } if(rentPeriods <= 0) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + - "The number of rent periods must be greater than 0!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorNegativeNumber, event.getLine(3)); event.setCancelled(true); event.getBlock().breakNaturally(); return; @@ -239,7 +241,7 @@ else if(RealEstate.instance.config.cfgRentKeywords.contains(event.getLine(0).toL { if(!RealEstate.perms.has(player, "realestate.admin"))// admin may sell admin claims { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You don't have the permission to rent admin claims!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignNoAdminRentPermission, typeDisplay); event.setCancelled(true); event.getBlock().breakNaturally(); return; @@ -247,7 +249,7 @@ else if(RealEstate.instance.config.cfgRentKeywords.contains(event.getLine(0).toL } else if(type.equals("claim") && !player.getUniqueId().equals(claim.ownerID))// only the owner may sell his claim { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You can only rent claims you own!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignNotOwner, typeDisplay); event.setCancelled(true); event.getBlock().breakNaturally(); return; @@ -262,15 +264,18 @@ else if(RealEstate.instance.config.cfgLeaseKeywords.contains(event.getLine(0).to { if(!RealEstate.instance.config.cfgEnableLease) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Leasing is disabled!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignLeasingDisabled); event.setCancelled(true); event.getBlock().breakNaturally(); return; } String type = claim.parent == null ? "claim" : "subclaim"; + String typeDisplay = claim.parent == null ? + RealEstate.instance.messages.keywordClaim : + RealEstate.instance.messages.keywordSubclaim; if(!RealEstate.perms.has(player, "realestate." + type + ".lease")) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You don't have the permission to lease " + type + "s!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignNoLeasePermission, typeDisplay); event.setCancelled(true); event.getBlock().breakNaturally(); return; @@ -284,21 +289,21 @@ else if(RealEstate.instance.config.cfgLeaseKeywords.contains(event.getLine(0).to } catch (NumberFormatException e) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "The price you entered is not a valid number!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorInvalidNumber, event.getLine(1)); event.setCancelled(true); event.getBlock().breakNaturally(); return; } if(price <= 0) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "The price must be greater than 0!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorNegativePrice, event.getLine(1)); event.setCancelled(true); event.getBlock().breakNaturally(); return; } if((price%1)!=0 && !RealEstate.instance.config.cfgUseDecimalCurrency) //if the price has a decimal number AND Decimal currency is disabled { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "The price cannot have a decimal number!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorNonIntegerPrice, event.getLine(1)); event.setCancelled(true); event.getBlock().breakNaturally(); return; @@ -315,8 +320,7 @@ else if(RealEstate.instance.config.cfgLeaseKeywords.contains(event.getLine(0).to } catch(Exception e) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + - "The number of payments you enterred is not a valid number!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorInvalidNumber, event.getLine(2)); event.setCancelled(true); event.getBlock().breakNaturally(); return; @@ -329,9 +333,10 @@ else if(RealEstate.instance.config.cfgLeaseKeywords.contains(event.getLine(0).to int frequency = parseDuration(event.getLine(3)); if(frequency == 0) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Couldn't read the date!\n" + - "Date must be formatted as follow" + ChatColor.GREEN + "10 weeks" + ChatColor.RED + " or " + - ChatColor.GREEN + "3 days" + ChatColor.RED + " or " + ChatColor.GREEN + "1 week 3 days"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorInvalidDuration, event.getLine(3), + ChatColor.GREEN + "10 weeks", + ChatColor.GREEN + "3 days", + ChatColor.GREEN + "1 week 3 days"); event.setCancelled(true); event.getBlock().breakNaturally(); return; @@ -341,7 +346,7 @@ else if(RealEstate.instance.config.cfgLeaseKeywords.contains(event.getLine(0).to { if(!RealEstate.perms.has(player, "realestate.admin"))// admin may sell admin claims { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You don't have the permission to lease admin claims!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignNoAdminLeasePermission, typeDisplay); event.setCancelled(true); event.getBlock().breakNaturally(); return; @@ -349,7 +354,7 @@ else if(RealEstate.instance.config.cfgLeaseKeywords.contains(event.getLine(0).to } else if(type.equals("claim") && !player.getUniqueId().equals(claim.ownerID))// only the owner may sell his claim { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You can only lease claims you own!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignNotOwner, typeDisplay); event.setCancelled(true); event.getBlock().breakNaturally(); return; @@ -402,8 +407,7 @@ public void onPlayerInteract(PlayerInteractEvent event) if(!RealEstate.transactionsStore.anyTransaction(claim)) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + - "This claim is no longer for rent, sell or lease, sorry..."); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignNoTransaction); event.getClickedBlock().breakNaturally(); event.setCancelled(true); return; @@ -432,15 +436,13 @@ public void onBreakBlock(BlockBreakEvent event) if(event.getPlayer() != null && tr.getOwner() != null && !event.getPlayer().getUniqueId().equals(tr.getOwner()) && !RealEstate.perms.has(event.getPlayer(), "realestate.destroysigns")) { - event.getPlayer().sendMessage(RealEstate.instance.config.chatPrefix + - ChatColor.RED + "Only the author of the sell/rent/lease sign is allowed to destroy it"); + Messages.sendMessage(event.getPlayer(), RealEstate.instance.messages.msgErrorSignNotAuthor); event.setCancelled(true); return; } else if(event.getPlayer() != null && tr.getOwner() == null && !RealEstate.perms.has(event.getPlayer(), "realestate.admin")) { - event.getPlayer().sendMessage(RealEstate.instance.config.chatPrefix + - ChatColor.RED + "Only an admin is allowed to destroy this sign"); + Messages.sendMessage(event.getPlayer(), RealEstate.instance.messages.msgErrorSignNotAdmin); event.setCancelled(true); return; } diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java index b59e57a..6a0cdd4 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java @@ -16,6 +16,7 @@ import com.earth2me.essentials.User; +import me.EtienneDx.RealEstate.Messages; import me.EtienneDx.RealEstate.RealEstate; import me.EtienneDx.RealEstate.Utils; import me.ryanhamshire.GriefPrevention.Claim; @@ -65,7 +66,7 @@ public boolean update() if(sign.getBlock().getState() instanceof Sign) { Sign s = (Sign)sign.getBlock().getState(); - s.setLine(0, RealEstate.instance.messages.getMessage(RealEstate.instance.config.cfgSignsHeader)); + s.setLine(0, Messages.getMessage(RealEstate.instance.config.cfgSignsHeader)); s.setLine(1, ChatColor.DARK_GREEN + RealEstate.instance.config.cfgReplaceLease); //s.setLine(2, owner != null ? Bukkit.getOfflinePlayer(owner).getName() : "SERVER"); //s.setLine(2, paymentsLeft + "x " + price + " " + RealEstate.econ.currencyNamePlural()); @@ -312,40 +313,34 @@ public void interact(Player player) Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null);// getting by id creates errors for subclaims if(claim == null) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "This claim does not exist!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimDoesNotExist); RealEstate.transactionsStore.cancelTransaction(claim); return; } String claimType = claim.parent == null ? "claim" : "subclaim"; + String claimTypeDisplay = claim.parent == null ? + RealEstate.instance.messages.keywordClaim : + RealEstate.instance.messages.keywordSubclaim; if (owner != null && owner.equals(player.getUniqueId())) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You already own this " + claimType + "!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimAlreadyOwner, claimTypeDisplay); return; } if(claim.parent == null && owner != null && !owner.equals(claim.ownerID)) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + Bukkit.getPlayer(owner).getDisplayName() + - " does not have the right to put this " + claimType + " for lease!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimNotLeasedByOwner, claimTypeDisplay); RealEstate.transactionsStore.cancelTransaction(claim); return; } if(!player.hasPermission("realestate." + claimType + ".lease")) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You do not have the permission to lease " + - claimType + "s!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimNoLeasePermission, claimTypeDisplay); return; } - if(player.getUniqueId().equals(buyer)) + if(player.getUniqueId().equals(buyer) || buyer != null) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You are already leasing this " + - claimType + "!"); - return; - } - if(buyer != null) - { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Someone already leases this " + - claimType + "!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimAlreadyLeased, claimTypeDisplay); return; } @@ -360,43 +355,47 @@ public void interact(Player player) getHolder().breakNaturally();// leases don't have signs indicating the remaining time update(); RealEstate.transactionsStore.saveData(); + + String location = "[" + player.getLocation().getWorld() + ", " + + "X: " + player.getLocation().getBlockX() + ", " + + "Y: " + player.getLocation().getBlockY() + ", " + + "Z: " + player.getLocation().getBlockZ() + "]"; RealEstate.instance.addLogEntry( "[" + RealEstate.transactionsStore.dateFormat.format(RealEstate.transactionsStore.date) + "] " + player.getName() + " has started leasing a " + claimType + " at " + - "[" + player.getLocation().getWorld() + ", " + - "X: " + player.getLocation().getBlockX() + ", " + - "Y: " + player.getLocation().getBlockY() + ", " + - "Z: " + player.getLocation().getBlockZ() + "] " + - "Price: " + price + " " + RealEstate.econ.currencyNamePlural()); + location + + " Price: " + price + " " + RealEstate.econ.currencyNamePlural()); if(owner != null) { OfflinePlayer seller = Bukkit.getOfflinePlayer(owner); if(RealEstate.instance.config.cfgMessageOwner && seller.isOnline()) { - ((Player)seller).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + player.getName() + ChatColor.AQUA + - " has just paid for your lease for the " + claimType + " at " + - ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " + sign.getBlockY() + ", Z: " - + sign.getBlockZ() + "]" + ChatColor.AQUA + - " for " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + ChatColor.AQUA + ", " + - ChatColor.GREEN + paymentsLeft + ChatColor.AQUA + " payments left"); + Messages.sendMessage(seller.getPlayer(), RealEstate.instance.messages.msgInfoClaimOwnerLeaseStarted, + player.getName(), + claimTypeDisplay, + RealEstate.econ.format(price), + location, + paymentsLeft + ""); } else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) { User u = RealEstate.ess.getUser(this.owner); - u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + player.getName() + ChatColor.AQUA + - " has just paid for your lease for the " + claimType + " at " + - ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " + sign.getBlockY() + ", Z: " - + sign.getBlockZ() + "]" + ChatColor.AQUA + - " for " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + ChatColor.AQUA + ", " + - ChatColor.GREEN + paymentsLeft + ChatColor.AQUA + " payments left"); + u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + Messages.getMessage( + RealEstate.instance.messages.msgInfoClaimOwnerLeaseStarted, + player.getName(), + claimTypeDisplay, + RealEstate.econ.format(price), + location, + paymentsLeft + "")); } } - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + "You have successfully paid lease for this " + claimType + - " for " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + ChatColor.AQUA + ", " + - ChatColor.GREEN + paymentsLeft + ChatColor.AQUA + " payments left"); + Messages.sendMessage(player, RealEstate.instance.messages.msgInfoClaimBuyerLeaseStarted, + claimTypeDisplay, + RealEstate.econ.format(price), + paymentsLeft + ""); } } @@ -404,27 +403,32 @@ else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) public void preview(Player player) { Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null); - String msg = ""; if(player.hasPermission("realestate.info")) { String claimType = claim.parent == null ? "claim" : "subclaim"; - msg = ChatColor.BLUE + "-----= " + ChatColor.WHITE + "[" + ChatColor.GOLD + "RealEstate Rent Info" + ChatColor.WHITE + "]" + - ChatColor.BLUE + " =-----\n"; + String claimTypeDisplay = claim.parent == null ? + RealEstate.instance.messages.keywordClaim : + RealEstate.instance.messages.keywordSubclaim; + String msg; + msg = Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoHeader) + "\n"; if(buyer == null) { - msg += ChatColor.AQUA + "This " + claimType + " is for lease for " + - ChatColor.GREEN + paymentsLeft + ChatColor.AQUA + " payments of " + - ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + ChatColor.AQUA + " each.\nPayments are due every " + - ChatColor.GREEN + Utils.getTime(frequency, null, true) + "\n"; + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoGeneralLeaseNoBuyer, + claimTypeDisplay, + paymentsLeft + "", + RealEstate.econ.format(price), + Utils.getTime(frequency, null, true)) + "\n"; if(claimType.equalsIgnoreCase("claim")) { - msg += ChatColor.AQUA + "The current owner is: " + ChatColor.GREEN + claim.getOwnerName(); + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoOwner, + claim.getOwnerName()) + "\n"; } else { - msg += ChatColor.AQUA + "The main claim owner is: " + ChatColor.GREEN + claim.getOwnerName() + "\n"; - msg += ChatColor.LIGHT_PURPLE + "Note: " + ChatColor.AQUA + "You will only get access to this subclaim!"; + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoMainOwner, + claim.parent.getOwnerName()) + "\n"; + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoNote) + "\n"; } } else @@ -439,40 +443,46 @@ public void preview(Player player) int daysLeft = frequency - days - 1;// we need to remove the current day Duration timeRemaining = Duration.ofHours(24).minus(hours); - msg += ChatColor.AQUA + "This " + claimType + " is currently leased by " + - ChatColor.GREEN + Bukkit.getOfflinePlayer(buyer).getName() + ChatColor.AQUA + " for " + - ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + ChatColor.AQUA + ". There is " + - ChatColor.GREEN + paymentsLeft + ChatColor.AQUA + " payments left. Next payment is in " + - ChatColor.GREEN + Utils.getTime(daysLeft, timeRemaining, true) + ChatColor.AQUA + ".\n"; - if(claimType.equalsIgnoreCase("claim")) - { - msg += ChatColor.AQUA + "The current owner is: " + ChatColor.GREEN + claim.getOwnerName(); - } - else - { - msg += ChatColor.AQUA + "The main claim owner is: " + ChatColor.GREEN + claim.getOwnerName(); - } + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoGeneralLeaseBuyer, + claimTypeDisplay, + Bukkit.getOfflinePlayer(buyer).getName(), + RealEstate.econ.format(price), + paymentsLeft + "", + Utils.getTime(daysLeft, timeRemaining, true), + Utils.getTime(frequency, null, true)) + "\n"; + if(claimType.equalsIgnoreCase("claim")) + { + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoOwner, + claim.getOwnerName()) + "\n"; + } + else + { + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoMainOwner, + claim.parent.getOwnerName()) + "\n"; + } } + Messages.sendMessage(player, msg); } else { - msg = RealEstate.instance.config.chatPrefix + ChatColor.RED + "You don't have the permission to view real estate informations!"; + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimNoInfoPermission); } - player.sendMessage(msg); } @Override public void msgInfo(CommandSender cs) { - cs.sendMessage(ChatColor.DARK_GREEN + "" + GriefPrevention.instance.dataStore.getClaim(claimId).getArea() + - ChatColor.AQUA + " blocks to " + ChatColor.DARK_GREEN + "Lease " + ChatColor.AQUA + "at " + ChatColor.DARK_GREEN + - "[" + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getWorld().getName() + ", " + - "X: " + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getBlockX() + ", " + - "Y: " + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getBlockY() + ", " + - "Z: " + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getBlockZ() + "] " + ChatColor.AQUA + "for " + - ChatColor.GREEN + paymentsLeft + ChatColor.AQUA + " periods of " + ChatColor.GREEN + Utils.getTime(frequency, Duration.ZERO, false) + - ChatColor.AQUA + ", each period costs " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() - ); + Claim claim = GriefPrevention.instance.dataStore.getClaim(claimId); + String location = "[" + claim.getLesserBoundaryCorner().getWorld().getName() + ", " + + "X: " + claim.getLesserBoundaryCorner().getBlockX() + ", " + + "Y: " + claim.getLesserBoundaryCorner().getBlockY() + ", " + + "Z: " + claim.getLesserBoundaryCorner().getBlockZ() + "]"; + + Messages.sendMessage(cs, RealEstate.instance.messages.msgInfoClaimInfoLeaseOneline, + claim.getArea(), + location, + RealEstate.econ.format(price), + paymentsLeft + ""); } } diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java index c5f148d..62f3332 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java @@ -16,6 +16,7 @@ import com.earth2me.essentials.User; +import me.EtienneDx.RealEstate.Messages; import me.EtienneDx.RealEstate.RealEstate; import me.EtienneDx.RealEstate.Utils; import me.ryanhamshire.GriefPrevention.Claim; @@ -80,7 +81,7 @@ public boolean update() if(sign.getBlock().getState() instanceof Sign) { Sign s = (Sign) sign.getBlock().getState(); - s.setLine(0, RealEstate.instance.messages.getMessage(RealEstate.instance.config.cfgSignsHeader)); + s.setLine(0, Messages.getMessage(RealEstate.instance.config.cfgSignsHeader)); s.setLine(1, ChatColor.DARK_GREEN + RealEstate.instance.config.cfgReplaceRent); //s.setLine(2, owner != null ? Bukkit.getOfflinePlayer(owner).getName() : "SERVER"); String price_line = ""; From 75ba2173bc3a7b2a2ff742e5644b96f9a3a4611f Mon Sep 17 00:00:00 2001 From: Etienne Dx Date: Sun, 16 Jan 2022 17:58:40 +0100 Subject: [PATCH 09/16] feat: rent messages --- src/me/EtienneDx/RealEstate/Messages.java | 25 +++- .../RealEstate/Transactions/ClaimLease.java | 22 +-- .../RealEstate/Transactions/ClaimRent.java | 130 +++++++++++------- 3 files changed, 117 insertions(+), 60 deletions(-) diff --git a/src/me/EtienneDx/RealEstate/Messages.java b/src/me/EtienneDx/RealEstate/Messages.java index e30c164..1eb44f5 100644 --- a/src/me/EtienneDx/RealEstate/Messages.java +++ b/src/me/EtienneDx/RealEstate/Messages.java @@ -267,8 +267,8 @@ public class Messages extends AnnotationConfig @ConfigField(name="RealEstate.Info.Claim.BuyerRented", comment = "1: claim type, 2: formatted price") public String msgInfoClaimBuyerRented = "$bYou have rented the {1} for $a{2}"; - @ConfigField(name="RealEstate.Info.Claim.Info.Header") - public String msgInfoClaimInfoHeader = "$9-----= $f[$6RealEstate Lease Info$f]$9 =-----"; + @ConfigField(name="RealEstate.Info.Claim.Info.Lease.Header") + public String msgInfoClaimInfoLeaseHeader = "$9-----= $f[$6RealEstate Lease Info$f]$9 =-----"; @ConfigField(name="RealEstate.Info.Claim.Info.Lease.GeneralNoBuyer", comment = "0: claim type, 1: payments left, 2: formatted price, 3: frequency") public String msgInfoClaimInfoGeneralLeaseNoBuyer = "$bThis {0} is for lease for $a{1} $bpayments of $a{2} each. Payments are due every $a{3}"; @@ -279,6 +279,27 @@ public class Messages extends AnnotationConfig @ConfigField(name="RealEstate.Info.Claim.Info.Lease.Oneline", comment = "0: claim area, 1: location, 2: payments left, 3: period, 4: formatted price") public String msgInfoClaimInfoLeaseOneline = "$2{0} $bblocks to $2Lease $bat $2{1} $bfor $a{2} periods of $a{3}$b, each period costs $a{4}"; + @ConfigField(name="RealEstate.Info.Claim.Info.Rent.Header") + public String msgInfoClaimInfoRentHeader = "$9-----= $f[$6RealEstate Rent Info$f]$9 =-----"; + + @ConfigField(name="RealEstate.Info.Claim.Info.Rent.GeneralNoBuyer", comment = "0: claim type, 1: formatted price, 2: duration") + public String msgInfoClaimInfoGeneralRentNoBuyer = "$bThis {0} is for rent for $a{1}$b per $a{3}."; + + @ConfigField(name="RealEstate.Info.Claim.Info.Rent.GeneralBuyer", comment = "0: claim type, 1: buyer name, 2: formatted price, 3: time left in current period, 5: duration of a period") + public String msgInfoClaimInfoGeneralRentBuyer = "$bThis {0} is currently rented by $a{1}$b for $a{2}$b. The {0} is rented until $a{3}$b. The rent period is $a{5}"; + + @ConfigField(name="RealEstate.Info.Claim.Info.Rent.MaxPeriod", comment = "0: max periods") + public String msgInfoClaimInfoRentMaxPeriod = "$bIt can be rented for a maximum of $a{0}$b periods."; + + @ConfigField(name="RealEstate.Info.Claim.Info.Rent.RemainingPeriods", comment = "0: periods left") + public String msgInfoClaimInfoRentRemainingPeriods = "$bThe contract will end after another $a{0}$b periods."; + + @ConfigField(name="RealEstate.Info.Claim.Info.Rent.AutoRenew", comment = "0: enabled / disabled") + public String msgInfoClaimInfoRentAutoRenew = "$bAutomatic renew is currently $a{0}$b."; + + @ConfigField(name="RealEstate.Info.Claim.Info.Rent.Oneline", comment = "0: claim area, 1: location, 2: formatted price, 3: duration") + public String msgInfoClaimInfoRentOneline = "$2{0} $bblocks to $2Rent $bat $2{1} $bfor $a{2}$b per $a{3}"; + @ConfigField(name="RealEstate.Info.Claim.Info.Owner", comment = "0: owner name") public String msgInfoClaimInfoOwner = "$bThe current owner is $a{0}"; diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java index 6a0cdd4..bffdf71 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java @@ -410,7 +410,7 @@ public void preview(Player player) RealEstate.instance.messages.keywordClaim : RealEstate.instance.messages.keywordSubclaim; String msg; - msg = Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoHeader) + "\n"; + msg = Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoLeaseHeader) + "\n"; if(buyer == null) { msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoGeneralLeaseNoBuyer, @@ -450,16 +450,16 @@ public void preview(Player player) paymentsLeft + "", Utils.getTime(daysLeft, timeRemaining, true), Utils.getTime(frequency, null, true)) + "\n"; - if(claimType.equalsIgnoreCase("claim")) - { - msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoOwner, - claim.getOwnerName()) + "\n"; - } - else - { - msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoMainOwner, - claim.parent.getOwnerName()) + "\n"; - } + if(claimType.equalsIgnoreCase("claim")) + { + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoOwner, + claim.getOwnerName()) + "\n"; + } + else + { + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoMainOwner, + claim.parent.getOwnerName()) + "\n"; + } } Messages.sendMessage(player, msg); } diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java index 62f3332..aca1548 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java @@ -287,40 +287,33 @@ public void interact(Player player) Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null);// getting by id creates errors for subclaims if(claim == null) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "This claim does not exist!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimDoesNotExist); RealEstate.transactionsStore.cancelTransaction(claim); return; } String claimType = claim.parent == null ? "claim" : "subclaim"; + String claimTypeDisplay = claim.parent == null ? + RealEstate.instance.messages.keywordClaim : RealEstate.instance.messages.keywordSubclaim; if (owner != null && owner.equals(player.getUniqueId())) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You already own this " + claimType + "!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimAlreadyOwner, claimTypeDisplay); return; } if(claim.parent == null && owner != null && !owner.equals(claim.ownerID)) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + Bukkit.getOfflinePlayer(owner).getName() + - " does not have the right to rent this " + claimType + "!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimNotRentedByOwner, claimTypeDisplay); RealEstate.transactionsStore.cancelTransaction(claim); return; } if(!player.hasPermission("realestate." + claimType + ".rent")) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You do not have the permission to rent " + - claimType + "s!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimNoRentPermission, claimTypeDisplay); return; } - if(player.getUniqueId().equals(buyer)) + if(player.getUniqueId().equals(buyer) || buyer != null) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You are already renting this " + - claimType + "!"); - return; - } - if(buyer != null) - { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Someone already rents this " + - claimType + "!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimAlreadyRented, claimTypeDisplay); return; } @@ -349,28 +342,33 @@ public void interact(Player player) if(owner != null) { OfflinePlayer seller = Bukkit.getOfflinePlayer(owner); + String location = "[" + sign.getWorld().getName() + ", " + + "X: " + sign.getBlockX() + ", " + + "Y: " + sign.getBlockY() + ", " + + "Z: " + sign.getBlockZ() + "]"; if(RealEstate.instance.config.cfgMessageOwner && seller.isOnline()) { - ((Player)seller).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + player.getName() + ChatColor.AQUA + - " has just rented your " + claimType + " at " + - ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " + sign.getBlockY() + ", Z: " - + sign.getBlockZ() + "]" + ChatColor.AQUA + - " for " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural()); + Messages.sendMessage(seller.getPlayer(), RealEstate.instance.messages.msgInfoClaimOwnerRented, + player.getName(), + claimTypeDisplay, + RealEstate.econ.format(price), + location); } else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) { User u = RealEstate.ess.getUser(this.owner); - u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + player.getName() + ChatColor.AQUA + - " has just rented your " + claimType + " at " + - ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " + sign.getBlockY() + ", Z: " - + sign.getBlockZ() + "]" + ChatColor.AQUA + - " for " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural()); + u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimOwnerRented, + player.getName(), + claimTypeDisplay, + RealEstate.econ.format(price), + location)); } } - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + "You have successfully rented this " + claimType + - " for " + ChatColor.GREEN + price + RealEstate.econ.currencyNamePlural()); + Messages.sendMessage(player, RealEstate.instance.messages.msgInfoClaimBuyerRented, + claimTypeDisplay, + RealEstate.econ.format(price)); destroySign(); } @@ -380,27 +378,36 @@ else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) public void preview(Player player) { Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null); - String msg = ""; if(player.hasPermission("realestate.info")) { String claimType = claim.parent == null ? "claim" : "subclaim"; - msg = ChatColor.BLUE + "-----= " + ChatColor.WHITE + "[" + ChatColor.GOLD + "RealEstate Rent Info" + ChatColor.WHITE + "]" + - ChatColor.BLUE + " =-----\n"; + String claimTypeDisplay = claim.parent == null ? + RealEstate.instance.messages.keywordClaim : + RealEstate.instance.messages.keywordSubclaim; + String msg; + msg = Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoRentHeader) + "\n"; if(buyer == null) { - msg += ChatColor.AQUA + "This " + claimType + " is for rent for " + - ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + ChatColor.AQUA + " for " + - (maxPeriod > 1 ? "" + ChatColor.GREEN + maxPeriod + ChatColor.AQUA + " periods of " : "") + - ChatColor.GREEN + Utils.getTime(duration, null, true) + "\n"; - + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoGeneralRentNoBuyer, + claimTypeDisplay, + RealEstate.econ.format(price), + Utils.getTime(duration, null, true)) + "\n"; + if(maxPeriod > 1) + { + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoRentMaxPeriod, + maxPeriod + "") + "\n"; + } + if(claimType.equalsIgnoreCase("claim")) { - msg += ChatColor.AQUA + "The current owner is: " + ChatColor.GREEN + claim.getOwnerName(); + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoOwner, + claim.getOwnerName()) + "\n"; } else { - msg += ChatColor.AQUA + "The main claim owner is: " + ChatColor.GREEN + claim.getOwnerName() + "\n"; - msg += ChatColor.LIGHT_PURPLE + "Note: " + ChatColor.AQUA + "You will only rent access to this subclaim!"; + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoMainOwner, + claim.parent.getOwnerName()) + "\n"; + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoNote) + "\n"; } } else @@ -415,36 +422,65 @@ public void preview(Player player) int daysLeft = duration - days - 1;// we need to remove the current day Duration timeRemaining = Duration.ofHours(24).minus(hours); + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoGeneralRentBuyer, + claimTypeDisplay, + Bukkit.getOfflinePlayer(buyer).getName(), + RealEstate.econ.format(price), + Utils.getTime(daysLeft, timeRemaining, true), + Utils.getTime(duration, null, true)) + "\n"; msg += ChatColor.AQUA + "This " + claimType + " is currently rented by " + ChatColor.GREEN + Bukkit.getOfflinePlayer(buyer).getName() + ChatColor.AQUA + " for " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + ChatColor.AQUA + " for " + (maxPeriod - periodCount > 1 ? "" + ChatColor.GREEN + (maxPeriod - periodCount) + ChatColor.AQUA + " periods of " + ChatColor.GREEN + Utils.getTime(duration, null, false) + ChatColor.AQUA + ". The current period will end in " : "another ") + ChatColor.GREEN + Utils.getTime(daysLeft, timeRemaining, true) + "\n"; + + if(maxPeriod > 1 && maxPeriod - periodCount > 0) + { + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoRentRemainingPeriods, + (maxPeriod - periodCount) + "") + "\n"; + } + if((owner != null && owner.equals(player.getUniqueId()) || buyer.equals(player.getUniqueId())) && RealEstate.instance.config.cfgEnableAutoRenew) { - msg += ChatColor.AQUA + "Automatic renew is currently " + ChatColor.LIGHT_PURPLE + (autoRenew ? "enabled" : "disabled") + "\n"; + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoRentAutoRenew, + autoRenew ? + RealEstate.instance.messages.keywordEnabled : + RealEstate.instance.messages.keywordDisabled) + "\n"; } if(claimType.equalsIgnoreCase("claim")) { - msg += ChatColor.AQUA + "The current owner is: " + ChatColor.GREEN + claim.getOwnerName(); - } - else - { - msg += ChatColor.AQUA + "The main claim owner is: " + ChatColor.GREEN + claim.getOwnerName(); - } + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoOwner, + claim.getOwnerName()) + "\n"; + } + else + { + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoMainOwner, + claim.parent.getOwnerName()) + "\n"; + } } + Messages.sendMessage(player, msg); } else { - msg = RealEstate.instance.config.chatPrefix + ChatColor.RED + "You don't have the permission to view real estate informations!"; + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimNoInfoPermission); } - player.sendMessage(msg); } @Override public void msgInfo(CommandSender cs) { + Claim claim = GriefPrevention.instance.dataStore.getClaim(claimId); + String location = "[" + claim.getLesserBoundaryCorner().getWorld().getName() + ", " + + "X: " + claim.getLesserBoundaryCorner().getBlockX() + ", " + + "Y: " + claim.getLesserBoundaryCorner().getBlockY() + ", " + + "Z: " + claim.getLesserBoundaryCorner().getBlockZ() + "]"; + + Messages.sendMessage(cs, RealEstate.instance.messages.msgInfoClaimInfoRentOneline, + claim.getArea(), + location, + RealEstate.econ.format(price), + Utils.getTime(duration, Duration.ZERO, false)); cs.sendMessage(ChatColor.DARK_GREEN + "" + GriefPrevention.instance.dataStore.getClaim(claimId).getArea() + ChatColor.AQUA + " blocks to " + ChatColor.DARK_GREEN + "Rent " + ChatColor.AQUA + "at " + ChatColor.DARK_GREEN + "[" + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getWorld().getName() + ", " + From d870f5e04dde227e7758c978155643031fba54db Mon Sep 17 00:00:00 2001 From: Etienne Dx Date: Tue, 18 Jan 2022 19:20:34 +0100 Subject: [PATCH 10/16] feat: added last messages & fixed event checks with GP --- pom.xml | 2 +- .../RealEstate/ClaimPermissionListener.java | 51 ++++-- src/me/EtienneDx/RealEstate/Config.java | 4 +- src/me/EtienneDx/RealEstate/Messages.java | 152 +++++++++++++++--- src/me/EtienneDx/RealEstate/RECommand.java | 14 +- src/me/EtienneDx/RealEstate/REListener.java | 4 +- src/me/EtienneDx/RealEstate/RealEstate.java | 44 ++--- .../RealEstate/SendPlayerMessageTask.java | 13 +- .../RealEstate/Transactions/ClaimLease.java | 149 +++++++++-------- .../RealEstate/Transactions/ClaimRent.java | 93 ++++++----- .../RealEstate/Transactions/ClaimSell.java | 117 ++++++++------ .../Transactions/TransactionsStore.java | 77 ++++++--- src/me/EtienneDx/RealEstate/Utils.java | 20 +-- 13 files changed, 466 insertions(+), 274 deletions(-) diff --git a/pom.xml b/pom.xml index 4030e1c..4ced1b0 100644 --- a/pom.xml +++ b/pom.xml @@ -156,7 +156,7 @@ com.github.EtienneDx AnnotationConfig - cff4221 + e9eab24 diff --git a/src/me/EtienneDx/RealEstate/ClaimPermissionListener.java b/src/me/EtienneDx/RealEstate/ClaimPermissionListener.java index 8accc72..a016bba 100644 --- a/src/me/EtienneDx/RealEstate/ClaimPermissionListener.java +++ b/src/me/EtienneDx/RealEstate/ClaimPermissionListener.java @@ -6,6 +6,9 @@ import me.EtienneDx.RealEstate.Transactions.BoughtTransaction; import me.EtienneDx.RealEstate.Transactions.Transaction; +import me.ryanhamshire.GriefPrevention.Claim; +import me.ryanhamshire.GriefPrevention.ClaimPermission; +import me.ryanhamshire.GriefPrevention.events.ClaimDeletedEvent; import me.ryanhamshire.GriefPrevention.events.ClaimPermissionCheckEvent; public class ClaimPermissionListener implements Listener { @@ -18,32 +21,60 @@ void registerEvents() @EventHandler public void onClaimPermission(ClaimPermissionCheckEvent event) { - Transaction b = RealEstate.transactionsStore.getTransaction(event.getClaim()); + Transaction transaction = RealEstate.transactionsStore.getTransaction(event.getClaim()); + // we only have to remove the owner's access, the rest is handled by GP if( - b != null && - event.getCheckedUUID().equals(b.getOwner()) && - b instanceof BoughtTransaction && - ((BoughtTransaction)b).getBuyer() != null + // if there is a transaction and the player is the owner + transaction != null && + ( + event.getCheckedUUID().equals(transaction.getOwner()) || + (event.getClaim().isAdminClaim() && event.getCheckedPlayer().hasPermission("griefprevention.adminclaims")) + ) && + transaction instanceof BoughtTransaction && + ((BoughtTransaction)transaction).getBuyer() != null ) { switch(event.getRequiredPermission()) { case Edit: - event.setDenialReason(() -> RealEstate.instance.messages.msgErrorClaimInTransactionCantEdit); + event.setDenialReason(() -> Messages.getMessage(RealEstate.instance.messages.msgErrorClaimInTransactionCantEdit)); break; case Access: - event.setDenialReason(() -> RealEstate.instance.messages.msgErrorClaimInTransactionCantAccess); + event.setDenialReason(() -> Messages.getMessage(RealEstate.instance.messages.msgErrorClaimInTransactionCantAccess)); break; case Build: - event.setDenialReason(() -> RealEstate.instance.messages.msgErrorClaimInTransactionCantBuild); + event.setDenialReason(() -> Messages.getMessage(RealEstate.instance.messages.msgErrorClaimInTransactionCantBuild)); break; case Inventory: - event.setDenialReason(() -> RealEstate.instance.messages.msgErrorClaimInTransactionCantInventory); + event.setDenialReason(() -> Messages.getMessage(RealEstate.instance.messages.msgErrorClaimInTransactionCantInventory)); break; case Manage: - event.setDenialReason(() -> RealEstate.instance.messages.msgErrorClaimInTransactionCantManage); + event.setDenialReason(() -> Messages.getMessage(RealEstate.instance.messages.msgErrorClaimInTransactionCantManage)); break; default: break; } } + + if(event.getRequiredPermission() == ClaimPermission.Edit || event.getRequiredPermission() == ClaimPermission.Manage) { + for (Claim child : event.getClaim().children) { + Transaction tr = RealEstate.transactionsStore.getTransaction(child); + if(tr != null && + tr instanceof BoughtTransaction && + ((BoughtTransaction)tr).getBuyer() != null + ) { + event.setDenialReason(() -> Messages.getMessage(RealEstate.instance.messages.msgErrorSubclaimInTransaction)); + } + } + } + } + + // more of a safety measure, normally it shouldn't be needed + @EventHandler + public void onClaimDeleted(ClaimDeletedEvent event) { + Transaction tr = RealEstate.transactionsStore.getTransaction(event.getClaim()); + if(tr != null) tr.tryCancelTransaction(null, true); + for (Claim child : event.getClaim().children) { + tr = RealEstate.transactionsStore.getTransaction(child); + if(tr != null) tr.tryCancelTransaction(null, true); + } } } diff --git a/src/me/EtienneDx/RealEstate/Config.java b/src/me/EtienneDx/RealEstate/Config.java index f86086c..f57d493 100644 --- a/src/me/EtienneDx/RealEstate/Config.java +++ b/src/me/EtienneDx/RealEstate/Config.java @@ -18,7 +18,9 @@ public class Config extends AnnotationConfig public final String configFilePath = RealEstate.pluginDirPath + "config.yml"; public final String logFilePath = RealEstate.pluginDirPath + "GriefProtection_RealEstate.log"; - public final String chatPrefix = "[" + ChatColor.GOLD + "RealEstate" + ChatColor.WHITE + "] "; + + @ConfigField(name="RealEstate.Keywords.ChatPrefix", comment="What is displayed before any chat message") + public String chatPrefix = "$f[$6RealEstate$f] "; @ConfigField(name="RealEstate.Keywords.SignsHeader", comment = "What is displayed in top of the signs") public String cfgSignsHeader = "$6[RealEstate]"; diff --git a/src/me/EtienneDx/RealEstate/Messages.java b/src/me/EtienneDx/RealEstate/Messages.java index 1eb44f5..7166b28 100644 --- a/src/me/EtienneDx/RealEstate/Messages.java +++ b/src/me/EtienneDx/RealEstate/Messages.java @@ -6,13 +6,14 @@ import me.EtienneDx.AnnotationConfig.AnnotationConfig; import me.EtienneDx.AnnotationConfig.ConfigField; import me.EtienneDx.AnnotationConfig.ConfigFile; +import net.md_5.bungee.api.ChatColor; @ConfigFile(header = "Use a YAML editor like NotepadPlusPlus to edit this file. \nAfter editing, back up your changes before reloading the server in case you made a syntax error. \nUse dollar signs ($) for formatting codes, which are documented here: http://minecraft.gamepedia.com/Formatting_codes.\n You can use {0}, {1} to include the different values indicated in the comments") public class Messages extends AnnotationConfig { public PluginDescriptionFile pdf; - @ConfigField(name="RealEstate.Keywords.Enabled", comment = "Keywords used within other messages") + @ConfigField(name="RealEstate.Keywords.Enabled", comment = "Keywords used within other messages but with a longer text at the end just because i need to test some stuff") public String keywordEnabled = "enabled"; @ConfigField(name="RealEstate.Keywords.Disabled") @@ -24,8 +25,20 @@ public class Messages extends AnnotationConfig @ConfigField(name="RealEstate.Keywords.Subclaim") public String keywordSubclaim = "subclaim"; + @ConfigField(name="RealEstate.Keywords.AdminClaimPrefix") + public String keywordAdminClaimPrefix = "an admin"; + + @ConfigField(name="RealEstate.Keywords.ClaimPrefix") + public String keywordClaimPrefix = "a"; + + @ConfigField(name="RealEstate.Keywords.TheServer") + public String keywordTheServer = "The server"; + @ConfigField(name="RealEstate.NoTransactionFound") - public String msgNoTransactionFound = "$cNo transaction found at your location!"; + public String msgNoTransactionFound = "$cNo transaction found!"; + + @ConfigField(name="RealEstate.NoTransactionFoundHere") + public String msgNoTransactionFoundHere = "$cNo transaction found at your location!"; @ConfigField(name="RealEstate.PageMustBePositive") public String msgPageMustBePositive = "$cPage must be a positive option"; @@ -66,6 +79,9 @@ public class Messages extends AnnotationConfig @ConfigField(name="RealEstate.Errors.InvalidOption") public String msgErrorInvalidOption = "$cInvalid option provided!"; + @ConfigField(name="RealEstate.Errors.ClaimInTransaction.CantOwner") + public String msgErrorClaimInTransactionCantOwner = "$cThis claim is currently involved in a transaction, you can't modify it!"; + @ConfigField(name="RealEstate.Errors.ClaimInTransaction.CantEdit") public String msgErrorClaimInTransactionCantEdit = "$cThis claim is currently involved in a transaction, you can't edit it!"; @@ -80,6 +96,9 @@ public class Messages extends AnnotationConfig @ConfigField(name="RealEstate.Errors.ClaimInTransaction.CantManage") public String msgErrorClaimInTransactionCantManage = "$cThis claim is currently involved in a transaction, you can't manage it!"; + + @ConfigField(name="RealEstate.Errors.ClaimInTransaction.Subclaim") + public String msgErrorSubclaimInTransaction = "$cA subclaim is currently involved in a transaction, you can't edit or manage the parent claim!"; @ConfigField(name="RealEstate.Errors.Command.Usage", comment = "0: command usage") public String msgErrorCommandUsage = "$cUsage: {0}"; @@ -87,6 +106,9 @@ public class Messages extends AnnotationConfig @ConfigField(name="RealEstate.Errors.BuyerOnly") public String msgErrorBuyerOnly = "$cOnly the buyer can perform this command!"; + @ConfigField(name="RealEstate.Errors.Unexpected") + public String msgErrorUnexpected = "$cAn unexpected error has occured!"; + @ConfigField(name="RealEstate.Errors.InvalidNumber", comment = "0: number") public String msgErrorInvalidNumber = "$c{0} is not a valid number!"; @@ -102,6 +124,30 @@ public class Messages extends AnnotationConfig @ConfigField(name="RealEstate.Errors.InvalidDuration", comment = "0: duration, 1: example of duration format, 2: example, 3: example") public String msgErrorInvalidDuration = "$c{0} is not a valid duration! Durations must be in the format {1} or {2} or {3}!"; + @ConfigField(name="RealEstate.Errors.NoMoneySelf") + public String msgErrorNoMoneySelf = "$cYou don't have enough money to make this transaction!"; + + @ConfigField(name="RealEstate.Errors.NoMoneyOther", comment = "0: Other player") + public String msgErrorNoMoneyOther = "$c{0} doesn't have enough money to make this transaction!"; + + @ConfigField(name="RealEstate.Errors.NoWithdrawSelf") + public String msgErrorNoWithdrawSelf = "$cCould not withdraw the money!"; + + @ConfigField(name="RealEstate.Errors.NoWithdrawOther", comment = "0: Other player") + public String msgErrorNoWithdrawOther = "$cCould not withdraw the money from {0}!"; + + @ConfigField(name="RealEstate.Errors.NoDepositSelf", comment = "0: Other player") + public String msgErrorNoDepositSelf = "$cCould not deposit the money to you, refunding {0}!"; + + @ConfigField(name="RealEstate.Errors.NoDepositOther", comment = "0: Other player") + public String msgErrorNoDepositOther = "$cCould not deposit the money to {0}, refunding you!"; + + @ConfigField(name="RealEstate.Errors.CantCancelAlreadyLeased", comment = "0: claim type") + public String msgErrorCantCancelAlreadyLeased = "$cThis {0} is currently being leased, you can't cancel the transaction!"; + + @ConfigField(name="RealEstate.Errors.CantCancelAlreadyRented", comment = "0: claim type") + public String msgErrorCantCancelAlreadyRented = "$cThis {0} is currently being rented, you can't cancel the transaction!"; + @ConfigField(name="RealEstate.Errors.AutoRenew.Disabled") public String msgErrorAutoRenewDisabled = "$cAutomatic renew is disabled!"; @@ -207,11 +253,14 @@ public class Messages extends AnnotationConfig @ConfigField(name="RealEstate.Errors.Claim.NoInfoPermission") public String msgErrorClaimNoInfoPermission = "$cYou don't have permission to view this real estate informations!"; + @ConfigField(name="RealEstate.Errors.Claim.NoClaimBlocks", comment = "0: area; 1: claim blocks remaining; 2: missing claim blocks") + public String msgErrorClaimNoClaimBlocks = "$cYou don't have enough claim blocks! You need $a{2}$c more claim blocks to claim this area. The claim requires $a{0}$c claim blocks, you only have $a{1}$c claim blocks left."; + @ConfigField(name="RealEstate.Info.ExitOffer.None") public String msgInfoExitOfferNone = "$bThere is currently no exit offer for this claim!"; @ConfigField(name="RealEstate.Info.ExitOffer.MadeByStatus", comment = "0: formatted price") - public String msgInfoExitOfferMadeByStatus = "$bYou offered to exit the contract for $a{0}, but your offer hasn't been accepted or denied yet..."; + public String msgInfoExitOfferMadeByStatus = "$bYou offered to exit the contract for $a{0}$b, but your offer hasn't been accepted or denied yet..."; @ConfigField(name="RealEstate.Info.ExitOffer.MadeToStatus", comment = "0: player who made the offer; 1: formatted price") public String msgInfoExitOfferMadeToStatus = "$a{0} $boffered to exit the contract for $a{1}"; @@ -258,14 +307,14 @@ public class Messages extends AnnotationConfig @ConfigField(name="RealEstate.Info.Claim.OwnerRented", comment = "0: buyer name, 1: claim type, 2: formatted price, 3: claim location") public String msgInfoClaimOwnerRented = "$a{0} $bhas rented the {1} at $a{3} $bfor $a{2}"; - @ConfigField(name="RealEstate.Info.Claim.BuyerBought", comment = "1: claim type, 2: formatted price") - public String msgInfoClaimBuyerSold = "$bYou have bought the {1} for $a{2}"; + @ConfigField(name="RealEstate.Info.Claim.BuyerBought", comment = "0: claim type, 1: formatted price") + public String msgInfoClaimBuyerSold = "$bYou have bought the {0} for $a{1}"; - @ConfigField(name="RealEstate.Info.Claim.BuyerLeaseStarted", comment = "1: claim type, 2: formatted price, 3: payments left") - public String msgInfoClaimBuyerLeaseStarted = "$bYou have leased the {1} for $a{2} with $a{3} $bpayments left"; + @ConfigField(name="RealEstate.Info.Claim.BuyerLeaseStarted", comment = "0: claim type, 1: formatted price, 2: payments left") + public String msgInfoClaimBuyerLeaseStarted = "$bYou have leased the {0} for $a{1} with $a{2} $bpayments left"; - @ConfigField(name="RealEstate.Info.Claim.BuyerRented", comment = "1: claim type, 2: formatted price") - public String msgInfoClaimBuyerRented = "$bYou have rented the {1} for $a{2}"; + @ConfigField(name="RealEstate.Info.Claim.BuyerRented", comment = "0: claim type, 1: formatted price") + public String msgInfoClaimBuyerRented = "$bYou have rented the {0} for $a{1}"; @ConfigField(name="RealEstate.Info.Claim.Info.Lease.Header") public String msgInfoClaimInfoLeaseHeader = "$9-----= $f[$6RealEstate Lease Info$f]$9 =-----"; @@ -279,14 +328,32 @@ public class Messages extends AnnotationConfig @ConfigField(name="RealEstate.Info.Claim.Info.Lease.Oneline", comment = "0: claim area, 1: location, 2: payments left, 3: period, 4: formatted price") public String msgInfoClaimInfoLeaseOneline = "$2{0} $bblocks to $2Lease $bat $2{1} $bfor $a{2} periods of $a{3}$b, each period costs $a{4}"; + @ConfigField(name="RealEstate.Info.Claim.Info.Lease.PaymentBuyer", comment = "0: claim type, 1: location, 2: formatted price, 3: payments left") + public String msgInfoClaimInfoLeasePaymentBuyer = "$bPaid lease for the {0} at $a{1} $bfor $a{2}$b. There are $a{3} $bpayments left."; + + @ConfigField(name="RealEstate.Info.Claim.Info.Lease.PaymentOwner", comment = "0: player name, 1: claim type, 2: location, 3: formatted price, 4: payments left") + public String msgInfoClaimInfoLeasePaymentOwner = "$a{0} $bpaid lease for the {1} at $a{2} $bfor $a{3}$b. There are $a{4} $bpayments left."; + + @ConfigField(name="RealEstate.Info.Claim.Info.Lease.PaymentBuyerFinal", comment = "0: claim type, 1: location, 2: formatted price") + public String msgInfoClaimInfoLeasePaymentBuyerFinal = "$bPaid final lease for the {0} at $a{1} $bfor $a{2}$b. The {0} is now your property."; + + @ConfigField(name="RealEstate.Info.Claim.Info.Lease.PaymentOwnerFinal", comment = "0: player name, 1: claim type, 2: location, 3: formatted price") + public String msgInfoClaimInfoLeasePaymentOwnerFinal = "$a{0} $bpaid final lease for the {1} at $a{2} $bfor $a{3}$b. The {1} is now $a{0}$b's property."; + + @ConfigField(name="RealEstate.Info.Claim.Info.Lease.PaymentBuyerCancelled", comment = "0: claim type, 1: location, 2: formatted price") + public String msgInfoClaimInfoLeasePaymentBuyerCancelled = "$bCouldn't pay the lease for the {0} at $a{1} $bfor $a{2}$b. The lease has been cancelled."; + + @ConfigField(name="RealEstate.Info.Claim.Info.Lease.PaymentOwnerCancelled", comment = "0: player name, 1: claim type, 2: location, 3: formatted price") + public String msgInfoClaimInfoLeasePaymentOwnerCancelled = "$a{0} $bcouldn't pay the lease for the {1} at $a{2} $bfor $a{3}$b. The lease has been cancelled."; + @ConfigField(name="RealEstate.Info.Claim.Info.Rent.Header") public String msgInfoClaimInfoRentHeader = "$9-----= $f[$6RealEstate Rent Info$f]$9 =-----"; @ConfigField(name="RealEstate.Info.Claim.Info.Rent.GeneralNoBuyer", comment = "0: claim type, 1: formatted price, 2: duration") - public String msgInfoClaimInfoGeneralRentNoBuyer = "$bThis {0} is for rent for $a{1}$b per $a{3}."; + public String msgInfoClaimInfoGeneralRentNoBuyer = "$bThis {0} is for rent for $a{1}$b per $a{2}."; - @ConfigField(name="RealEstate.Info.Claim.Info.Rent.GeneralBuyer", comment = "0: claim type, 1: buyer name, 2: formatted price, 3: time left in current period, 5: duration of a period") - public String msgInfoClaimInfoGeneralRentBuyer = "$bThis {0} is currently rented by $a{1}$b for $a{2}$b. The {0} is rented until $a{3}$b. The rent period is $a{5}"; + @ConfigField(name="RealEstate.Info.Claim.Info.Rent.GeneralBuyer", comment = "0: claim type, 1: buyer name, 2: formatted price, 3: time left in current period, 4: duration of a period") + public String msgInfoClaimInfoGeneralRentBuyer = "$bThis {0} is currently rented by $a{1}$b for $a{2}$b. The {0} is rented until $a{3}$b. The rent period is $a{4}"; @ConfigField(name="RealEstate.Info.Claim.Info.Rent.MaxPeriod", comment = "0: max periods") public String msgInfoClaimInfoRentMaxPeriod = "$bIt can be rented for a maximum of $a{0}$b periods."; @@ -300,6 +367,30 @@ public class Messages extends AnnotationConfig @ConfigField(name="RealEstate.Info.Claim.Info.Rent.Oneline", comment = "0: claim area, 1: location, 2: formatted price, 3: duration") public String msgInfoClaimInfoRentOneline = "$2{0} $bblocks to $2Rent $bat $2{1} $bfor $a{2}$b per $a{3}"; + @ConfigField(name="RealEstate.Info.Claim.Info.Rent.PaymentBuyer", comment = "0: claim type, 1: location, 2: formatted price") + public String msgInfoClaimInfoRentPaymentBuyer = "$bPaid rent for the {0} at $a{1} $bfor $a{2}$b."; + + @ConfigField(name="RealEstate.Info.Claim.Info.Rent.PaymentOwner", comment = "0: player name, 1: claim type, 2: location, 3: formatted price") + public String msgInfoClaimInfoRentPaymentOwner = "$a{0} $bpaid rent for the {1} at $a{2} $bfor $a{3}$b."; + + @ConfigField(name="RealEstate.Info.Claim.Info.Rent.PaymentBuyerCancelled", comment = "0: claim type, 1: location, 2: formatted price") + public String msgInfoClaimInfoRentPaymentBuyerCancelled = "$bCouldn't pay the rent for the {0} at $a{1} $bfor $a{2}$b. The rent has been cancelled."; + + @ConfigField(name="RealEstate.Info.Claim.Info.Rent.PaymentOwnerCancelled", comment = "0: player name, 1: claim type, 2: location, 3: formatted price") + public String msgInfoClaimInfoRentPaymentOwnerCancelled = "$a{0} $bcouldn't pay the rent for the {1} at $a{2} $bfor $a{3}$b. The rent has been cancelled."; + + @ConfigField(name="RealEstate.Info.Claim.Info.Rent.RentCancelled", comment = "0: claim type, 1: location") + public String msgInfoClaimInfoRentCancelled = "$bThe rent for the {0} at $a{1} $bis now over, your access has been revoked."; + + @ConfigField(name="RealEstate.Info.Claim.Info.Sell.Header") + public String msgInfoClaimInfoSellHeader = "$9-----= $f[$6RealEstate Sale Info$f]$9 =-----"; + + @ConfigField(name="RealEstate.Info.Claim.Info.Sell.General", comment = "0: claim type, 1: formatted price") + public String msgInfoClaimInfoSellGeneral = "$bThis {0} is for sale for $a{1}"; + + @ConfigField(name="RealEstate.Info.Claim.Info.Sell.Oneline", comment = "0: claim area, 1: location, 2: formatted price") + public String msgInfoClaimInfoSellOneline = "$2{0} $bblocks to $2Sell $bat $2{1} $bfor $a{2}"; + @ConfigField(name="RealEstate.Info.Claim.Info.Owner", comment = "0: owner name") public String msgInfoClaimInfoOwner = "$bThe current owner is $a{0}"; @@ -309,6 +400,24 @@ public class Messages extends AnnotationConfig @ConfigField(name="RealEstate.Info.Claim.Info.Note") public String msgInfoClaimInfoNote = "$dNote: You will only get access to this subclaim."; + @ConfigField(name="RealEstate.Info.Claim.Created.Sell", comment = "0: claim prefix, 1: claim type, 2: formatted price") + public String msgInfoClaimCreatedSell = "$bYou have successfully created {0} {1} sale for $a{2}"; + + @ConfigField(name="RealEstate.Info.Claim.Created.Lease", comment = "0: claim prefix, 1: claim type, 2: formatted price, 3: payments count, 4: frequency") + public String msgInfoClaimCreatedLease = "$bYou have successfully created {0} {1} lease for $a{3}$b payments of $a{2}$b each. Payments are due every $a{4}"; + + @ConfigField(name="RealEstate.Info.Claim.Created.Rent", comment = "0: claim prefix, 1: claim type, 2: formatted price, 3: duration") + public String msgInfoClaimCreatedRent = "$bYou have successfully created {0} {1} rent for $a{2}$b per $a{3}"; + + @ConfigField(name="RealEstate.Info.Claim.Created.SellBroadcast", comment = "0: player name, 1: claim prefix, 2: claim type, 3: formatted price") + public String msgInfoClaimCreatedSellBroadcast = "$a{0} $bhas created {1} {2} sale for $a{3}"; + + @ConfigField(name="RealEstate.Info.Claim.Created.LeaseBroadcast", comment = "0: player name, 1: claim prefix, 2: claim type, 3: formatted price, 4: payments count, 5: frequency") + public String msgInfoClaimCreatedLeaseBroadcast = "$a{0} $bhas created {1} {2} lease for $a{4}$b payments of $a{3}$b each. Payments are due every $a{5}"; + + @ConfigField(name="RealEstate.Info.Claim.Created.RentBroadcast", comment = "0: player name, 1: claim prefix, 2: claim type, 3: formatted price, 4: duration") + public String msgInfoClaimCreatedRentBroadcast = "$a{0} $bhas created {1} {2} rent for $a{3}$b per $a{4}"; + @ConfigField(name="RealEstate.List.Header", comment = "0: RE Offers|Sell Offers|Rent Offers|Lease Offers; 1: Page number; 2: Page count") public String msgListTransactionsHeader = "$1----= $f[ $6{0} page $2 {1} $6/ $2{2} $f] $1=----"; @@ -328,12 +437,19 @@ public void loadConfig() } public static String getMessage(String msgTemplate, String... args) { + return getMessage(msgTemplate, true, args); + } + + public static String getMessage(String msgTemplate, boolean withPrefix, String... args) { + if (withPrefix) { + msgTemplate = RealEstate.instance.config.chatPrefix + msgTemplate; + } for (int i = 0; i < args.length; i++) { String param = args[i]; - msgTemplate = msgTemplate.replace("{" + i + "}", param); + msgTemplate = msgTemplate.replaceAll("\\{" + i + "\\}", param); } - return msgTemplate.replace('$', (char) 0x00A7); + return msgTemplate.replace('$', ChatColor.COLOR_CHAR); } //sends a color-coded message to a player public static void sendMessage(CommandSender player, String msgTemplate, String... args) { @@ -348,13 +464,7 @@ public static void sendMessage(CommandSender player, String msgTemplate, long de //sends a color-coded message to a player public static void sendMessage(CommandSender player, String message) { - if (message == null || message.length() == 0) return; - - if (player == null) { - RealEstate.instance.log.info(message); - } else { - player.sendMessage(RealEstate.instance.config.chatPrefix + message.replace('$', (char) 0x00A7)); - } + sendMessage(player, getMessage(message), 0); } public static void sendMessage(CommandSender player, String message, long delayInTicks) { diff --git a/src/me/EtienneDx/RealEstate/RECommand.java b/src/me/EtienneDx/RealEstate/RECommand.java index fd01a8f..41ef016 100644 --- a/src/me/EtienneDx/RealEstate/RECommand.java +++ b/src/me/EtienneDx/RealEstate/RECommand.java @@ -47,7 +47,7 @@ public static void info(Player player) } else { - Messages.sendMessage(player, RealEstate.instance.messages.msgNoTransactionFound); + Messages.sendMessage(player, RealEstate.instance.messages.msgNoTransactionFoundHere); } } @@ -259,8 +259,7 @@ public void create(Player player, @Conditions("positiveDouble") Double price) else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) { User u = RealEstate.ess.getUser(other); - u.addMail(RealEstate.instance.config.chatPrefix + - Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferCreatedByOther, + u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferCreatedByOther, player.getName(), claimType, RealEstate.econ.format(price), location)); } } @@ -302,8 +301,7 @@ else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) { User u = RealEstate.ess.getUser(other); - u.addMail(RealEstate.instance.config.chatPrefix + - Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferAcceptedByOther, + u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferAcceptedByOther, player.getName(), claimType, RealEstate.econ.format(bt.exitOffer.price), location)); } } @@ -351,8 +349,7 @@ else if(bt.exitOffer.offerBy.equals(player.getUniqueId())) else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) { User u = RealEstate.ess.getUser(other); - u.addMail(RealEstate.instance.config.chatPrefix + - Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferRejectedByOther, + u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferRejectedByOther, player.getName(), claimType, location)); } } @@ -386,8 +383,7 @@ public void cancel(Player player) else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) { User u = RealEstate.ess.getUser(other); - u.addMail(RealEstate.instance.config.chatPrefix + - Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferCancelledByOther, + u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferCancelledByOther, player.getName(), claimType, location)); } } diff --git a/src/me/EtienneDx/RealEstate/REListener.java b/src/me/EtienneDx/RealEstate/REListener.java index 29afac9..717bbf0 100644 --- a/src/me/EtienneDx/RealEstate/REListener.java +++ b/src/me/EtienneDx/RealEstate/REListener.java @@ -399,8 +399,10 @@ public void onPlayerInteract(PlayerInteractEvent event) event.getClickedBlock().getState() instanceof Sign) { Sign sign = (Sign)event.getClickedBlock().getState(); + RealEstate.instance.log.info(sign.getLine(0)); // it is a real estate sign - if(ChatColor.stripColor(sign.getLine(0)).equalsIgnoreCase(ChatColor.stripColor(RealEstate.instance.config.cfgSignsHeader))) + if(ChatColor.stripColor(sign.getLine(0)).equalsIgnoreCase(ChatColor.stripColor( + Messages.getMessage(RealEstate.instance.config.cfgSignsHeader, false)))) { Player player = event.getPlayer(); Claim claim = GriefPrevention.instance.dataStore.getClaimAt(event.getClickedBlock().getLocation(), false, null); diff --git a/src/me/EtienneDx/RealEstate/RealEstate.java b/src/me/EtienneDx/RealEstate/RealEstate.java index cdec591..a40a846 100644 --- a/src/me/EtienneDx/RealEstate/RealEstate.java +++ b/src/me/EtienneDx/RealEstate/RealEstate.java @@ -112,78 +112,78 @@ private void registerConditions() { return; } - throw new ConditionFailedException(config.chatPrefix + messages.msgErrorOutOfClaim); + throw new ConditionFailedException(Messages.getMessage(messages.msgErrorOutOfClaim)); }); manager.getCommandConditions().addCondition("claimHasTransaction", (context) -> { if(!context.getIssuer().isPlayer()) { - throw new ConditionFailedException(config.chatPrefix + messages.msgErrorPlayerOnly); + throw new ConditionFailedException(Messages.getMessage(messages.msgErrorPlayerOnly)); } Claim c = GriefPrevention.instance.dataStore.getClaimAt(context.getIssuer().getPlayer().getLocation(), false, null); if(c == null) { - throw new ConditionFailedException(config.chatPrefix + messages.msgErrorOutOfClaim); + throw new ConditionFailedException(Messages.getMessage(messages.msgErrorOutOfClaim)); } Transaction tr = transactionsStore.getTransaction(c); if(tr == null) { - throw new ConditionFailedException(config.chatPrefix + messages.msgErrorNoOngoingTransaction); + throw new ConditionFailedException(Messages.getMessage(messages.msgErrorNoOngoingTransaction)); } }); manager.getCommandConditions().addCondition("inPendingTransactionClaim", (context) -> { if(!context.getIssuer().isPlayer()) { - throw new ConditionFailedException(config.chatPrefix + messages.msgErrorPlayerOnly); + throw new ConditionFailedException(Messages.getMessage(messages.msgErrorPlayerOnly)); } Claim c = GriefPrevention.instance.dataStore.getClaimAt(context.getIssuer().getPlayer().getLocation(), false, null); if(c == null) { - throw new ConditionFailedException(config.chatPrefix + messages.msgErrorOutOfClaim); + throw new ConditionFailedException(Messages.getMessage(messages.msgErrorOutOfClaim)); } Transaction tr = transactionsStore.getTransaction(c); if(tr == null) { - throw new ConditionFailedException(config.chatPrefix + messages.msgErrorNotRentNorLease); + throw new ConditionFailedException(Messages.getMessage(messages.msgErrorNotRentNorLease)); } else if(tr instanceof BoughtTransaction && ((BoughtTransaction)tr).getBuyer() != null) { - throw new ConditionFailedException(config.chatPrefix + messages.msgErrorAlreadyBought); + throw new ConditionFailedException(Messages.getMessage(messages.msgErrorAlreadyBought)); } }); manager.getCommandConditions().addCondition("inBoughtClaim", (context) -> { if(!context.getIssuer().isPlayer()) { - throw new ConditionFailedException(config.chatPrefix + messages.msgErrorPlayerOnly); + throw new ConditionFailedException(Messages.getMessage(messages.msgErrorPlayerOnly)); } Claim c = GriefPrevention.instance.dataStore.getClaimAt(context.getIssuer().getPlayer().getLocation(), false, null); if(c == null) { - throw new ConditionFailedException(config.chatPrefix + messages.msgErrorOutOfClaim); + throw new ConditionFailedException(Messages.getMessage(messages.msgErrorOutOfClaim)); } Transaction tr = transactionsStore.getTransaction(c); if(tr == null || !(tr instanceof BoughtTransaction)) { - throw new ConditionFailedException(config.chatPrefix + messages.msgErrorNotRentNorLease); + throw new ConditionFailedException(Messages.getMessage(messages.msgErrorNotRentNorLease)); } }); manager.getCommandConditions().addCondition("partOfBoughtTransaction", context -> { if(!context.getIssuer().isPlayer()) { - throw new ConditionFailedException(config.chatPrefix + messages.msgErrorPlayerOnly); + throw new ConditionFailedException(Messages.getMessage(messages.msgErrorPlayerOnly)); } Claim c = GriefPrevention.instance.dataStore.getClaimAt(context.getIssuer().getPlayer().getLocation(), false, null); if(c == null) { - throw new ConditionFailedException(config.chatPrefix + messages.msgErrorOutOfClaim); + throw new ConditionFailedException(Messages.getMessage(messages.msgErrorOutOfClaim)); } Transaction tr = transactionsStore.getTransaction(c); if(tr == null) { - throw new ConditionFailedException(config.chatPrefix + messages.msgErrorNoOngoingTransaction); + throw new ConditionFailedException(Messages.getMessage(messages.msgErrorNoOngoingTransaction)); } if(!(tr instanceof BoughtTransaction)) { - throw new ConditionFailedException(config.chatPrefix + messages.msgErrorNotRentNorLease); + throw new ConditionFailedException(Messages.getMessage(messages.msgErrorNotRentNorLease)); } if((((BoughtTransaction)tr).buyer != null && ((BoughtTransaction)tr).buyer.equals(context.getIssuer().getPlayer().getUniqueId())) || (tr.getOwner() != null && (tr.getOwner().equals(context.getIssuer().getPlayer().getUniqueId()))) || @@ -191,26 +191,26 @@ else if(tr instanceof BoughtTransaction && ((BoughtTransaction)tr).getBuyer() != { return; } - throw new ConditionFailedException(config.chatPrefix + messages.msgErrorNotPartOfTransaction); + throw new ConditionFailedException(Messages.getMessage(messages.msgErrorNotPartOfTransaction)); }); manager.getCommandConditions().addCondition("partOfRent", context -> { if(!context.getIssuer().isPlayer()) { - throw new ConditionFailedException(config.chatPrefix + messages.msgErrorPlayerOnly); + throw new ConditionFailedException(Messages.getMessage(messages.msgErrorPlayerOnly)); } Claim c = GriefPrevention.instance.dataStore.getClaimAt(context.getIssuer().getPlayer().getLocation(), false, null); if(c == null) { - throw new ConditionFailedException(config.chatPrefix + messages.msgErrorOutOfClaim); + throw new ConditionFailedException(Messages.getMessage(messages.msgErrorOutOfClaim)); } Transaction tr = transactionsStore.getTransaction(c); if(tr == null) { - throw new ConditionFailedException(config.chatPrefix + messages.msgErrorNoOngoingTransaction); + throw new ConditionFailedException(Messages.getMessage(messages.msgErrorNoOngoingTransaction)); } if(!(tr instanceof ClaimRent)) { - throw new ConditionFailedException(config.chatPrefix + messages.msgErrorRentOnly); + throw new ConditionFailedException(Messages.getMessage(messages.msgErrorRentOnly)); } if((((ClaimRent)tr).buyer != null && ((ClaimRent)tr).buyer.equals(context.getIssuer().getPlayer().getUniqueId())) || (tr.getOwner() != null && (tr.getOwner().equals(context.getIssuer().getPlayer().getUniqueId()))) || @@ -218,11 +218,11 @@ else if(tr instanceof BoughtTransaction && ((BoughtTransaction)tr).getBuyer() != { return; } - throw new ConditionFailedException(config.chatPrefix + messages.msgErrorNotPartOfTransaction); + throw new ConditionFailedException(Messages.getMessage(messages.msgErrorNotPartOfTransaction)); }); manager.getCommandConditions().addCondition(Double.class, "positiveDouble", (c, exec, value) -> { if(value > 0) return; - throw new ConditionFailedException(config.chatPrefix + messages.msgErrorValueGreaterThanZero); + throw new ConditionFailedException(Messages.getMessage(messages.msgErrorValueGreaterThanZero)); }); } diff --git a/src/me/EtienneDx/RealEstate/SendPlayerMessageTask.java b/src/me/EtienneDx/RealEstate/SendPlayerMessageTask.java index ba53f8b..177b7c4 100644 --- a/src/me/EtienneDx/RealEstate/SendPlayerMessageTask.java +++ b/src/me/EtienneDx/RealEstate/SendPlayerMessageTask.java @@ -17,11 +17,12 @@ public SendPlayerMessageTask(CommandSender player, String message) @Override public void run() { - if(player == null) - { - RealEstate.instance.log.info(message); - return; - } - Messages.sendMessage(this.player, this.message); + if (message == null || message.length() == 0) return; + + if (player == null) { + RealEstate.instance.log.info(message); + } else { + player.sendMessage(message); + } } } diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java index bffdf71..fe60218 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java @@ -66,7 +66,7 @@ public boolean update() if(sign.getBlock().getState() instanceof Sign) { Sign s = (Sign)sign.getBlock().getState(); - s.setLine(0, Messages.getMessage(RealEstate.instance.config.cfgSignsHeader)); + s.setLine(0, Messages.getMessage(RealEstate.instance.config.cfgSignsHeader, false)); s.setLine(1, ChatColor.DARK_GREEN + RealEstate.instance.config.cfgReplaceLease); //s.setLine(2, owner != null ? Bukkit.getOfflinePlayer(owner).getName() : "SERVER"); //s.setLine(2, paymentsLeft + "x " + price + " " + RealEstate.econ.currencyNamePlural()); @@ -125,7 +125,10 @@ private void payLease() OfflinePlayer buyerPlayer = Bukkit.getOfflinePlayer(buyer); OfflinePlayer seller = owner == null ? null : Bukkit.getOfflinePlayer(owner); - String claimType = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null).parent == null ? "claim" : "subclaim"; + String claimType = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null).parent == null ? + RealEstate.instance.messages.keywordClaim : RealEstate.instance.messages.keywordSubclaim; + String location = "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() + + ", Y: " + sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]"; if(Utils.makePayment(owner, buyer, price, false, false)) { @@ -135,42 +138,42 @@ private void payLease() { if(buyerPlayer.isOnline() && RealEstate.instance.config.cfgMessageBuyer) { - ((Player)buyerPlayer).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + - "Paid lease for the " + claimType + " at " + ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() + - ", Y: " + sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + - ChatColor.AQUA + " for the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + - ChatColor.AQUA + ", " + ChatColor.GREEN + paymentsLeft + ChatColor.AQUA + " payments left"); + Messages.sendMessage(buyerPlayer.getPlayer(), RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentBuyer, + claimType, + location, + RealEstate.econ.format(price), + paymentsLeft + ""); } else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) { User u = RealEstate.ess.getUser(this.buyer); - u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + - "Paid lease for the " + claimType + " at " + ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() + - ", Y: " + sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + - ChatColor.AQUA + " for the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + - ChatColor.AQUA + ", " + ChatColor.GREEN + paymentsLeft + ChatColor.AQUA + " payments left"); + u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentBuyer, + claimType, + location, + RealEstate.econ.format(price), + paymentsLeft + "")); } if(owner != null) { if(seller.isOnline() && RealEstate.instance.config.cfgMessageOwner) { - ((Player)seller).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + buyerPlayer.getName() + - ChatColor.AQUA + " has paid lease for the " + claimType + " at " + ChatColor.BLUE + "[" + - sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " + - sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + - ChatColor.AQUA + " at the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + - ChatColor.AQUA + ", " + ChatColor.GREEN + paymentsLeft + ChatColor.AQUA + " payments left"); + Messages.sendMessage(seller.getPlayer(), RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentOwner, + buyerPlayer.getName(), + claimType, + location, + RealEstate.econ.format(price), + paymentsLeft + ""); } else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) { User u = RealEstate.ess.getUser(this.owner); - u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + buyerPlayer.getName() + - ChatColor.AQUA + " has paid lease for the " + claimType + " at " + ChatColor.BLUE + "[" + - sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " + - sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + - ChatColor.AQUA + " at the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + - ChatColor.AQUA + ", " + ChatColor.GREEN + paymentsLeft + ChatColor.AQUA + " payments left"); + u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentOwner, + buyerPlayer.getName(), + claimType, + location, + RealEstate.econ.format(price), + paymentsLeft + "")); } } } @@ -178,40 +181,36 @@ else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) { if(buyerPlayer.isOnline() && RealEstate.instance.config.cfgMessageBuyer) { - ((Player)buyerPlayer).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + - "Paid final lease for the " + claimType + " at " + ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() + - ", Y: " + sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + - ChatColor.AQUA + " for the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + - ChatColor.AQUA + ", the " + claimType + " is now yours"); + Messages.sendMessage(buyerPlayer.getPlayer(), RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentBuyerFinal, + claimType, + location, + RealEstate.econ.format(price)); } else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) { User u = RealEstate.ess.getUser(this.buyer); - u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + - "Paid final lease for the " + claimType + " at " + ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() + - ", Y: " + sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + - ChatColor.AQUA + " for the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + - ChatColor.AQUA + ", the " + claimType + " is now yours"); + u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentBuyerFinal, + claimType, + location, + RealEstate.econ.format(price))); } if(seller.isOnline() && RealEstate.instance.config.cfgMessageOwner) { - ((Player)seller).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + buyerPlayer.getName() + - ChatColor.AQUA + " has paid lease for the " + claimType + " at " + ChatColor.BLUE + "[" + - sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " + - sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + - ChatColor.AQUA + "at the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + - ChatColor.AQUA + ", the " + claimType + " is now his property"); + Messages.sendMessage(seller.getPlayer(), RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentOwnerFinal, + buyerPlayer.getName(), + claimType, + location, + RealEstate.econ.format(price)); } else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) { User u = RealEstate.ess.getUser(this.owner); - u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + buyerPlayer.getName() + - ChatColor.AQUA + " has paid lease for the " + claimType + " at " + ChatColor.BLUE + "[" + - sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " + - sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + - ChatColor.AQUA + "at the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + - ChatColor.AQUA + ", the " + claimType + " is now his property"); + u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentOwnerFinal, + buyerPlayer.getName(), + claimType, + location, + RealEstate.econ.format(price))); } Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null); @@ -236,39 +235,44 @@ private void exitLease() Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null); - String claimType = claim.parent == null ? "claim" : "subclaim"; + String claimType = claim.parent == null ? + RealEstate.instance.messages.keywordClaim : + RealEstate.instance.messages.keywordSubclaim; + String location = "[" + sign.getWorld().getName() + ", X: " + + sign.getBlockX() + ", Y: " + + sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]"; if(buyerPlayer.isOnline() && RealEstate.instance.config.cfgMessageBuyer) { - ((Player)buyerPlayer).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + - "Couldn't pay the lease for the " + claimType + " at " + ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " + - sign.getBlockX() + ", Y: " + - sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + ChatColor.RED + ", the transaction has been cancelled."); + Messages.sendMessage(buyerPlayer.getPlayer(), RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentBuyerCancelled, + claimType, + location, + RealEstate.econ.format(price)); } else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) { User u = RealEstate.ess.getUser(this.buyer); - u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.RED + - "Couldn't pay the lease for the " + claimType + " at " + ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " + - sign.getBlockX() + ", Y: " + - sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + ChatColor.RED + ", the transaction has been cancelled."); + u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentBuyerCancelled, + claimType, + location, + RealEstate.econ.format(price))); } if(seller.isOnline() && RealEstate.instance.config.cfgMessageOwner) { - ((Player)seller).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + buyerPlayer.getName() + - ChatColor.AQUA + " couldn't pay lease for the " + claimType + " at " + ChatColor.BLUE + "[" + - sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " + - sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + - ChatColor.AQUA + ", the transaction has been cancelled"); + Messages.sendMessage(seller.getPlayer(), RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentOwnerCancelled, + buyerPlayer.getName(), + claimType, + location, + RealEstate.econ.format(price)); } else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) { User u = RealEstate.ess.getUser(this.owner); - u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + buyerPlayer.getName() + - ChatColor.AQUA + " couldn't pay lease for the " + claimType + " at " + ChatColor.BLUE + "[" + - sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " + - sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + - ChatColor.AQUA + ", the transaction has been cancelled"); + u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentOwnerCancelled, + buyerPlayer.getName(), + claimType, + location, + RealEstate.econ.format(price))); } claim.managers.remove(buyer.toString()); @@ -294,9 +298,13 @@ public boolean tryCancelTransaction(Player p, boolean force) else { Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null); - if(p != null) - p.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "This " + (claim.parent == null ? "claim" : "subclaim") + - " is currently leased, you can't cancel the transaction!"); + if(p != null) { + Messages.sendMessage(p, RealEstate.instance.messages.msgErrorCantCancelAlreadyLeased, + claim.parent == null ? + RealEstate.instance.messages.keywordClaim : + RealEstate.instance.messages.keywordSubclaim + ); + } return false; } } @@ -382,8 +390,7 @@ public void interact(Player player) else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) { User u = RealEstate.ess.getUser(this.owner); - u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + Messages.getMessage( - RealEstate.instance.messages.msgInfoClaimOwnerLeaseStarted, + u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimOwnerLeaseStarted, player.getName(), claimTypeDisplay, RealEstate.econ.format(price), @@ -479,7 +486,7 @@ public void msgInfo(CommandSender cs) "Z: " + claim.getLesserBoundaryCorner().getBlockZ() + "]"; Messages.sendMessage(cs, RealEstate.instance.messages.msgInfoClaimInfoLeaseOneline, - claim.getArea(), + claim.getArea() + "", location, RealEstate.econ.format(price), paymentsLeft + ""); diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java index aca1548..37046a8 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java @@ -81,7 +81,7 @@ public boolean update() if(sign.getBlock().getState() instanceof Sign) { Sign s = (Sign) sign.getBlock().getState(); - s.setLine(0, Messages.getMessage(RealEstate.instance.config.cfgSignsHeader)); + s.setLine(0, Messages.getMessage(RealEstate.instance.config.cfgSignsHeader, false)); s.setLine(1, ChatColor.DARK_GREEN + RealEstate.instance.config.cfgReplaceRent); //s.setLine(2, owner != null ? Bukkit.getOfflinePlayer(owner).getName() : "SERVER"); String price_line = ""; @@ -164,10 +164,15 @@ private void unRent(boolean msgBuyer) GriefPrevention.instance.dataStore.saveClaim(claim); if(msgBuyer && Bukkit.getOfflinePlayer(buyer).isOnline() && RealEstate.instance.config.cfgMessageBuyer) { - Bukkit.getPlayer(buyer).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + - "The rent for the " + (claim.parent == null ? "claim" : "subclaim") + " at " + ChatColor.BLUE + "[" + - sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " + - sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + ChatColor.AQUA + " is now over, your access has been revoked."); + String location = "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " + + sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]"; + String claimType = claim.parent == null ? + RealEstate.instance.messages.keywordClaim : + RealEstate.instance.messages.keywordSubclaim; + + Messages.sendMessage(Bukkit.getPlayer(buyer), RealEstate.instance.messages.msgInfoClaimInfoRentCancelled, + claimType, + location); } buyer = null; RealEstate.transactionsStore.saveData(); @@ -181,7 +186,11 @@ private void payRent() OfflinePlayer buyerPlayer = Bukkit.getOfflinePlayer(this.buyer); OfflinePlayer seller = owner == null ? null : Bukkit.getOfflinePlayer(owner); - String claimType = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null).parent == null ? "claim" : "subclaim"; + String claimType = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null).parent == null ? + RealEstate.instance.messages.keywordClaim : + RealEstate.instance.messages.keywordSubclaim; + String location = "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " + + sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]"; if((autoRenew || periodCount < maxPeriod) && Utils.makePayment(owner, this.buyer, price, false, false)) { @@ -189,38 +198,38 @@ private void payRent() startDate = LocalDateTime.now(); if(buyerPlayer.isOnline() && RealEstate.instance.config.cfgMessageBuyer) { - ((Player)buyerPlayer).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + - "Paid rent for the " + claimType + " at " + ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() + - ", Y: " + sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + - ChatColor.AQUA + "for the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural()); + Messages.sendMessage(buyerPlayer.getPlayer(), RealEstate.instance.messages.msgInfoClaimInfoRentPaymentBuyer, + claimType, + location, + RealEstate.econ.format(price)); } else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) { User u = RealEstate.ess.getUser(this.buyer); - u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + - "Paid rent for the " + claimType + " at " + ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() + - ", Y: " + sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + - ChatColor.AQUA + "for the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural()); + u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoRentPaymentBuyer, + claimType, + location, + RealEstate.econ.format(price))); } if(seller != null) { if(seller.isOnline() && RealEstate.instance.config.cfgMessageOwner) { - ((Player)seller).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + buyerPlayer.getName() + - " has paid rent for the " + claimType + " at " + ChatColor.BLUE + "[" + - sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " + - sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + - ChatColor.AQUA + "at the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural()); + Messages.sendMessage(seller.getPlayer(), RealEstate.instance.messages.msgInfoClaimInfoRentPaymentOwner, + buyerPlayer.getName(), + claimType, + location, + RealEstate.econ.format(price)); } else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) { User u = RealEstate.ess.getUser(this.owner); - u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + buyerPlayer.getName() + - " has paid rent for the " + claimType + " at " + ChatColor.BLUE + "[" + - sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " + - sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + - ChatColor.AQUA + "at the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural()); + u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoRentPaymentOwner, + buyerPlayer.getName(), + claimType, + location, + RealEstate.econ.format(price))); } } @@ -229,18 +238,18 @@ else if (autoRenew) { if(buyerPlayer.isOnline() && RealEstate.instance.config.cfgMessageBuyer) { - ((Player)buyerPlayer).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + - "Couldn't pay the rent for the " + claimType + " at " + ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " + - sign.getBlockX() + ", Y: " + - sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + ChatColor.RED + ", your access has been revoked."); + Messages.sendMessage(buyerPlayer.getPlayer(), RealEstate.instance.messages.msgInfoClaimInfoRentPaymentBuyerCancelled, + claimType, + location, + RealEstate.econ.format(price)); } else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) { User u = RealEstate.ess.getUser(this.buyer); - u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.RED + - "Couldn't pay the rent for the " + claimType + " at " + ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " + - sign.getBlockX() + ", Y: " + - sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + ChatColor.RED + ", your access has been revoked."); + u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoRentPaymentBuyerCancelled, + claimType, + location, + RealEstate.econ.format(price))); } unRent(false); return; @@ -268,9 +277,13 @@ public boolean tryCancelTransaction(Player p, boolean force) else { Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null); - if(p != null) - p.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "This " + (claim.parent == null ? "claim" : "subclaim") + - " is currently rented, you can't cancel the transaction!"); + if(p != null) { + Messages.sendMessage(p, RealEstate.instance.messages.msgErrorCantCancelAlreadyRented, + claim.parent == null ? + RealEstate.instance.messages.keywordClaim : + RealEstate.instance.messages.keywordSubclaim + ); + } return false; } } @@ -477,18 +490,10 @@ public void msgInfo(CommandSender cs) "Z: " + claim.getLesserBoundaryCorner().getBlockZ() + "]"; Messages.sendMessage(cs, RealEstate.instance.messages.msgInfoClaimInfoRentOneline, - claim.getArea(), + claim.getArea() + "", location, RealEstate.econ.format(price), Utils.getTime(duration, Duration.ZERO, false)); - cs.sendMessage(ChatColor.DARK_GREEN + "" + GriefPrevention.instance.dataStore.getClaim(claimId).getArea() + - ChatColor.AQUA + " blocks to " + ChatColor.DARK_GREEN + "Rent " + ChatColor.AQUA + "at " + ChatColor.DARK_GREEN + - "[" + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getWorld().getName() + ", " + - "X: " + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getBlockX() + ", " + - "Y: " + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getBlockY() + ", " + - "Z: " + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getBlockZ() + "] " + ChatColor.AQUA + "for " + - ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + ChatColor.AQUA + " per period of " + ChatColor.GREEN + - Utils.getTime(duration, Duration.ZERO, false)); } } diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimSell.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimSell.java index db06f6c..c948d25 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimSell.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimSell.java @@ -4,6 +4,7 @@ import com.earth2me.essentials.User; +import me.EtienneDx.RealEstate.Messages; import me.EtienneDx.RealEstate.RealEstate; import me.EtienneDx.RealEstate.Utils; import me.ryanhamshire.GriefPrevention.Claim; @@ -37,7 +38,7 @@ public boolean update() if(sign.getBlock().getState() instanceof Sign) { Sign s = (Sign) sign.getBlock().getState(); - s.setLine(0, RealEstate.instance.messages.getMessage(RealEstate.instance.config.cfgSignsHeader)); + s.setLine(0, Messages.getMessage(RealEstate.instance.config.cfgSignsHeader, false)); s.setLine(1, ChatColor.DARK_GREEN + RealEstate.instance.config.cfgReplaceSell); s.setLine(2, owner != null ? Utils.getSignString(Bukkit.getOfflinePlayer(owner).getName()) : "SERVER"); if(RealEstate.instance.config.cfgUseCurrencySymbol) @@ -85,38 +86,40 @@ public void interact(Player player) Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null);// getting by id creates errors for subclaims if(claim == null) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "This claim does not exist!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimDoesNotExist); RealEstate.transactionsStore.cancelTransaction(claim); return; } String claimType = claim.parent == null ? "claim" : "subclaim"; + String claimTypeDisplay = claim.parent == null ? + RealEstate.instance.messages.keywordClaim : RealEstate.instance.messages.keywordSubclaim; if (player.getUniqueId().equals(owner)) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You already own this " + claimType + "!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimAlreadyOwner, claimTypeDisplay); return; } if(claim.parent == null && owner != null && !owner.equals(claim.ownerID)) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + Bukkit.getPlayer(owner).getDisplayName() + - " does not have the right to sell this " + claimType + "!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimNotSoldByOwner, claimTypeDisplay); RealEstate.transactionsStore.cancelTransaction(claim); return; } if(!player.hasPermission("realestate." + claimType + ".buy")) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You do not have the permission to purchase " + - claimType + "s!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimNoBuyPermission, claimTypeDisplay); return; } // for real claims, you may need to have enough claim blocks in reserve to purchase it (if transferClaimBlocks is false) if(claimType.equalsIgnoreCase("claim") && !RealEstate.instance.config.cfgTransferClaimBlocks && GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId()).getRemainingClaimBlocks() < claim.getArea()) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + - "You don't have enough claim blocks to purchase this claim, you need to get " + ChatColor.DARK_GREEN + - (claim.getArea() - GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId()).getRemainingClaimBlocks()) + - ChatColor.RED + " more blocks!"); + int remaining = GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId()).getRemainingClaimBlocks(); + int area = claim.getArea(); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimNoClaimBlocks, + area + "", + remaining + "", + (area - remaining) + ""); return; } // the player has the right to buy, let's make the payment @@ -127,8 +130,15 @@ public void interact(Player player) // normally, this is always the case, so it's not necessary, but until I proven my point, here if(claim.parent != null || claim.ownerID.equals(player.getUniqueId())) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + "You have successfully purchased this " + claimType + - " for " + ChatColor.GREEN + price + RealEstate.econ.currencyNamePlural()); + String location = "[" + player.getLocation().getWorld() + ", " + + "X: " + player.getLocation().getBlockX() + ", " + + "Y: " + player.getLocation().getBlockY() + ", " + + "Z: " + player.getLocation().getBlockZ() + "]"; + + Messages.sendMessage(player, RealEstate.instance.messages.msgInfoClaimBuyerSold, + claimTypeDisplay, + RealEstate.econ.format(price)); + RealEstate.instance.addLogEntry( "[" + RealEstate.transactionsStore.dateFormat.format(RealEstate.transactionsStore.date) + "] " + player.getName() + " has purchased a " + claimType + " at " + @@ -143,30 +153,26 @@ public void interact(Player player) OfflinePlayer oldOwner = Bukkit.getOfflinePlayer(owner); if(oldOwner.isOnline()) { - ((Player) oldOwner).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + player.getDisplayName() + - " has purchased your " + claimType + " at " + ChatColor.BLUE + - "[" + player.getLocation().getWorld().getName() + ", " + - "X: " + player.getLocation().getBlockX() + ", " + - "Y: " + player.getLocation().getBlockY() + ", " + - "Z: " + player.getLocation().getBlockZ() + "] " + ChatColor.AQUA + "for " + ChatColor.GREEN + - price + " " + RealEstate.econ.currencyNamePlural()); + Messages.sendMessage(oldOwner.getPlayer(), RealEstate.instance.messages.msgInfoClaimOwnerSold, + player.getName(), + claimTypeDisplay, + RealEstate.econ.format(price), + location); } else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) { User u = RealEstate.ess.getUser(owner); - u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + player.getDisplayName() + - " has purchased your " + claimType + " at " + ChatColor.BLUE + - "[" + player.getLocation().getWorld().getName() + ", " + - "X: " + player.getLocation().getBlockX() + ", " + - "Y: " + player.getLocation().getBlockY() + ", " + - "Z: " + player.getLocation().getBlockZ() + "] " + ChatColor.AQUA + "for " + ChatColor.GREEN + - price + " " + RealEstate.econ.currencyNamePlural());; + u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimOwnerSold, + player.getName(), + claimTypeDisplay, + RealEstate.econ.format(price), + location)); } } } else { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Cannot purchase claim!"); + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorUnexpected); return; } RealEstate.transactionsStore.cancelTransaction(claim); @@ -177,29 +183,35 @@ else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null) public void preview(Player player) { Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null); - String msg = ""; if(player.hasPermission("realestate.info")) { String claimType = claim.parent == null ? "claim" : "subclaim"; - msg = ChatColor.BLUE + "-----= " + ChatColor.WHITE + "[" + ChatColor.GOLD + "RealEstate Sale Info" + ChatColor.WHITE + "]" + - ChatColor.BLUE + " =-----\n"; - msg += ChatColor.AQUA + "This " + claimType + " is for sale for " + - ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + "\n"; + String claimTypeDisplay = claim.parent == null ? + RealEstate.instance.messages.keywordClaim : RealEstate.instance.messages.keywordSubclaim; + + String msg = Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoSellHeader) + "\n"; + + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoSellGeneral, + claimTypeDisplay, + RealEstate.econ.format(price)) + "\n"; + if(claimType.equalsIgnoreCase("claim")) { - msg += ChatColor.AQUA + "The current owner is: " + ChatColor.GREEN + claim.getOwnerName(); - } - else - { - msg += ChatColor.AQUA + "The main claim owner is: " + ChatColor.GREEN + claim.getOwnerName() + "\n"; - msg += ChatColor.LIGHT_PURPLE + "Note: " + ChatColor.AQUA + "You will only buy access to this subclaim!"; - } + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoOwner, + claim.getOwnerName()) + "\n"; + } + else + { + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoMainOwner, + claim.parent.getOwnerName()) + "\n"; + msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoNote) + "\n"; + } + Messages.sendMessage(player, msg); } else { - msg = RealEstate.instance.config.chatPrefix + ChatColor.RED + "You don't have the permission to view real estate informations!"; + Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimNoInfoPermission); } - player.sendMessage(msg); } @Override @@ -211,12 +223,19 @@ public void setOwner(UUID newOwner) @Override public void msgInfo(CommandSender cs) { - cs.sendMessage(ChatColor.DARK_GREEN + "" + GriefPrevention.instance.dataStore.getClaim(claimId).getArea() + - ChatColor.AQUA + " blocks to " + ChatColor.DARK_GREEN + "Sell " + ChatColor.AQUA + "at " + ChatColor.DARK_GREEN + - "[" + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getWorld().getName() + ", " + - "X: " + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getBlockX() + ", " + - "Y: " + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getBlockY() + ", " + - "Z: " + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getBlockZ() + "] " + ChatColor.AQUA + "for " + - ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural()); + Claim claim = GriefPrevention.instance.dataStore.getClaim(claimId); + if(claim == null) { + tryCancelTransaction(null, true); + return; + } + String location = "[" + claim.getLesserBoundaryCorner().getWorld().getName() + ", " + + "X: " + claim.getLesserBoundaryCorner().getBlockX() + ", " + + "Y: " + claim.getLesserBoundaryCorner().getBlockY() + ", " + + "Z: " + claim.getLesserBoundaryCorner().getBlockZ() + "]"; + + Messages.sendMessage(cs, RealEstate.instance.messages.msgInfoClaimInfoSellOneline, + claim.getArea() + "", + location, + RealEstate.econ.format(price)); } } diff --git a/src/me/EtienneDx/RealEstate/Transactions/TransactionsStore.java b/src/me/EtienneDx/RealEstate/Transactions/TransactionsStore.java index ba99442..4385385 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/TransactionsStore.java +++ b/src/me/EtienneDx/RealEstate/Transactions/TransactionsStore.java @@ -17,10 +17,12 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; + +import me.EtienneDx.RealEstate.Messages; import me.EtienneDx.RealEstate.RealEstate; +import me.EtienneDx.RealEstate.Utils; import me.ryanhamshire.GriefPrevention.Claim; import me.ryanhamshire.GriefPrevention.GriefPrevention; -import net.md_5.bungee.api.ChatColor; public class TransactionsStore { @@ -194,12 +196,18 @@ public void sell(Claim claim, Player player, double price, Location sign) "Y: " + claim.getGreaterBoundaryCorner().getBlockY() + ", " + "Z: " + claim.getGreaterBoundaryCorner().getBlockZ() + "] " + "Price: " + price + " " + RealEstate.econ.currencyNamePlural()); - + + String claimPrefix = claim.isAdminClaim() ? RealEstate.instance.messages.keywordAdminClaimPrefix : + RealEstate.instance.messages.keywordClaimPrefix; + String claimTypeDisplay = claim.parent == null ? RealEstate.instance.messages.keywordClaim : + RealEstate.instance.messages.keywordSubclaim; + if(player != null) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + "You have successfully created " + - (claim.isAdminClaim() ? "an admin" : "a") + " " + (claim.parent == null ? "claim" : "subclaim") + " sale for " + - ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural()); + Messages.sendMessage(player, RealEstate.instance.messages.msgInfoClaimCreatedSell, + claimPrefix, + claimTypeDisplay, + RealEstate.econ.format(price)); } if(RealEstate.instance.config.cfgBroadcastSell) { @@ -207,10 +215,11 @@ public void sell(Claim claim, Player player, double price, Location sign) { if(p != player) { - p.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.DARK_GREEN + (player == null ? "The Server" : player.getDisplayName()) + - ChatColor.AQUA + " has put " + - (claim.isAdminClaim() ? "an admin" : "a") + " " + (claim.parent == null ? "claim" : "subclaim") + " for sale for " + - ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural()); + Messages.sendMessage(p, RealEstate.instance.messages.msgInfoClaimCreatedSellBroadcast, + player == null ? RealEstate.instance.messages.keywordTheServer : player.getDisplayName(), + claimPrefix, + claimTypeDisplay, + RealEstate.econ.format(price)); } } } @@ -230,12 +239,19 @@ public void rent(Claim claim, Player player, double price, Location sign, int du "Y: " + claim.getLesserBoundaryCorner().getBlockY() + ", " + "Z: " + claim.getLesserBoundaryCorner().getBlockZ() + "] " + "Price: " + price + " " + RealEstate.econ.currencyNamePlural()); + + String claimPrefix = claim.isAdminClaim() ? RealEstate.instance.messages.keywordAdminClaimPrefix : + RealEstate.instance.messages.keywordClaimPrefix; + String claimTypeDisplay = claim.parent == null ? RealEstate.instance.messages.keywordClaim : + RealEstate.instance.messages.keywordSubclaim; if(player != null) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + "You have successfully put " + - (claim.isAdminClaim() ? "an admin" : "a") + " " + (claim.parent == null ? "claim" : "subclaim") + " for" + (buildTrust ? "" : " container") + " rent for " + - ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural()); + Messages.sendMessage(player, RealEstate.instance.messages.msgInfoClaimCreatedRent, + claimPrefix, + claimTypeDisplay, + RealEstate.econ.format(price), + Utils.getTime(duration, null, false)); } if(RealEstate.instance.config.cfgBroadcastSell) { @@ -243,10 +259,12 @@ public void rent(Claim claim, Player player, double price, Location sign, int du { if(p != player) { - p.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.DARK_GREEN + (player == null ? "The Server" : player.getDisplayName()) + - ChatColor.AQUA + " has put " + - (claim.isAdminClaim() ? "an admin" : "a") + " " + (claim.parent == null ? "claim" : "subclaim") + " for" + (buildTrust ? "" : " container") + " rent for " + - ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural()); + Messages.sendMessage(p, RealEstate.instance.messages.msgInfoClaimCreatedRentBroadcast, + player == null ? RealEstate.instance.messages.keywordTheServer : player.getDisplayName(), + claimPrefix, + claimTypeDisplay, + RealEstate.econ.format(price), + Utils.getTime(duration, null, false)); } } } @@ -267,13 +285,20 @@ public void lease(Claim claim, Player player, double price, Location sign, int f "Z: " + claim.getLesserBoundaryCorner().getBlockZ() + "] " + "Payments Count : " + paymentsCount + " " + "Price: " + price + " " + RealEstate.econ.currencyNamePlural()); + + String claimPrefix = claim.isAdminClaim() ? RealEstate.instance.messages.keywordAdminClaimPrefix : + RealEstate.instance.messages.keywordClaimPrefix; + String claimTypeDisplay = claim.parent == null ? RealEstate.instance.messages.keywordClaim : + RealEstate.instance.messages.keywordSubclaim; if(player != null) { - player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + "You have successfully put " + - (claim.isAdminClaim() ? "an admin" : "a") + " " + (claim.parent == null ? "claim" : "subclaim") + " for lease for " + - ChatColor.GREEN + paymentsCount + ChatColor.AQUA + " payments of " + - ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural()); + Messages.sendMessage(player, RealEstate.instance.messages.msgInfoClaimCreatedLease, + claimPrefix, + claimTypeDisplay, + RealEstate.econ.format(price), + paymentsCount + "", + Utils.getTime(frequency, null, false)); } if(RealEstate.instance.config.cfgBroadcastSell) { @@ -281,11 +306,13 @@ public void lease(Claim claim, Player player, double price, Location sign, int f { if(p != player) { - p.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.DARK_GREEN + (player == null ? "The Server" : player.getDisplayName()) + - ChatColor.AQUA + " has put " + - (claim.isAdminClaim() ? "an admin" : "a") + " " + (claim.parent == null ? "claim" : "subclaim") + " for lease for " + - ChatColor.GREEN + paymentsCount + ChatColor.AQUA + " payments of " + - ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural()); + Messages.sendMessage(p, RealEstate.instance.messages.msgInfoClaimCreatedLeaseBroadcast, + player == null ? RealEstate.instance.messages.keywordTheServer : player.getDisplayName(), + claimPrefix, + claimTypeDisplay, + RealEstate.econ.format(price), + paymentsCount + "", + Utils.getTime(frequency, null, false)); } } } diff --git a/src/me/EtienneDx/RealEstate/Utils.java b/src/me/EtienneDx/RealEstate/Utils.java index 9e1e94f..3758c8e 100644 --- a/src/me/EtienneDx/RealEstate/Utils.java +++ b/src/me/EtienneDx/RealEstate/Utils.java @@ -5,13 +5,11 @@ import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; import me.ryanhamshire.GriefPrevention.Claim; import me.ryanhamshire.GriefPrevention.ClaimPermission; import me.ryanhamshire.GriefPrevention.GriefPrevention; import me.ryanhamshire.GriefPrevention.PlayerData; -import net.md_5.bungee.api.ChatColor; import net.milkbowl.vault.economy.EconomyResponse; public class Utils @@ -24,13 +22,11 @@ public static boolean makePayment(UUID receiver, UUID giver, double amount, bool { if(b.isOnline() && msgBuyer) { - ((Player)b).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + - "You don't have enough money to make this transaction!"); + Messages.sendMessage(b.getPlayer(), RealEstate.instance.messages.msgErrorNoMoneySelf); } if(s != null && s.isOnline() && msgSeller) { - ((Player)s).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + - b.getName() + " doesn't have enough money to make this transaction!"); + Messages.sendMessage(s.getPlayer(), RealEstate.instance.messages.msgErrorNoMoneyOther, b.getName()); } return false; } @@ -39,13 +35,11 @@ public static boolean makePayment(UUID receiver, UUID giver, double amount, bool { if(b.isOnline() && msgBuyer) { - ((Player)b).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + - "Could not withdraw the money!"); + Messages.sendMessage(b.getPlayer(), RealEstate.instance.messages.msgErrorNoWithdrawSelf); } if(s != null && s.isOnline() && msgSeller) { - ((Player)s).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + - "Could not withdraw the money!"); + Messages.sendMessage(b.getPlayer(), RealEstate.instance.messages.msgErrorNoWithdrawOther); } return false; } @@ -56,13 +50,11 @@ public static boolean makePayment(UUID receiver, UUID giver, double amount, bool { if(b.isOnline() && msgBuyer) { - ((Player)b).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + - "Could not deposit to " + s.getName() + ", refunding Player!"); + Messages.sendMessage(b.getPlayer(), RealEstate.instance.messages.msgErrorNoDepositOther, s.getName()); } if(s != null && s.isOnline() && msgSeller) { - ((Player)s).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + - "Could not deposit to you, refunding" + b.getName() + "!"); + Messages.sendMessage(b.getPlayer(), RealEstate.instance.messages.msgErrorNoDepositSelf, b.getName()); } RealEstate.econ.depositPlayer(b, amount); return false; From 757de574bef5f202bc2f30e7d0c09437feb12520 Mon Sep 17 00:00:00 2001 From: Etienne Dx Date: Tue, 18 Jan 2022 20:06:29 +0100 Subject: [PATCH 11/16] docs: updated readme & changelog --- CHANGELOG.md | 5 +++-- README.md | 10 ++-------- plugin.yml | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 136c406..ebc205c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,11 +7,12 @@ * Error messages to *messages.yml* * List messages to *messages.yml* * Info messages to *messages.yml* -* Support of [GriefPrevention v16.18-RC1](https://github.com/TechFortress/GriefPrevention/releases/tag/16.18-RC1) +* Support of [GriefPrevention v16.18-RC1](https://github.com/TechFortress/GriefPrevention/releases/tag/16.18-RC1) and up +* Disabled resizing of parent claims when subclaims are being rented ### Modified * Changed java version to java 16 -* Changed spigot version to 1.18.1 +* Changed spigot version to 1.18.1 (should still support 1.17) * Removed requirement for custom GP jar file ### Fixed diff --git a/README.md b/README.md index a8ee50d..5e9469e 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,6 @@ Please feel free to report any issue in the [GitHub Issue section](https://githu ## GriefPrevention -This plugin is dependent on GriefPrevention, which since version 1.3.0 will be included directly within the `RealEstate.jar` file. +This plugin is dependent on GriefPrevention version 16.18 and up (this version of GP is still in a pre-release state while I'm writing this). -The original GriefPrevention plugin can be found [here](https://github.com/TechFortress/GriefPrevention). To make RealEstate possible, I had to implement some modifications to GriefPrevention, which I did in this [fork](https://github.com/EtienneDx/GriefPrevention). - -
- Code ownership disclaimer - - **I AM NOT THE AUTHOR OF *GriefPrevention*, I MERELY MADE A FEW MODIFICATIONS TO IT. I DO NOT CLAIM ANY PROPERTY OVER THE *GriefPrevention* CODE.** -
\ No newline at end of file +GriefPrevention plugin can be found [here](https://github.com/TechFortress/GriefPrevention). \ No newline at end of file diff --git a/plugin.yml b/plugin.yml index 4ef629d..dcee6d6 100644 --- a/plugin.yml +++ b/plugin.yml @@ -2,7 +2,7 @@ name: RealEstate main: me.EtienneDx.RealEstate.RealEstate version: ${project.version} authors: [EtienneDx, DmitryRendov] -depend: [Vault] +depend: [Vault, GriefPrevention] api-version: "1.17" commands: From 2e92305aec69641b62351ccc217a5e90982a23a3 Mon Sep 17 00:00:00 2001 From: Etienne Dx Date: Fri, 4 Mar 2022 19:02:31 +0100 Subject: [PATCH 12/16] fix: fixed #42 and removeed a duplicated message --- CHANGELOG.md | 3 ++- src/me/EtienneDx/RealEstate/Messages.java | 13 ++++++++++--- src/me/EtienneDx/RealEstate/REListener.java | 12 ++++++------ .../RealEstate/Transactions/ClaimRent.java | 6 ------ 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebc205c..c24f545 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,4 +16,5 @@ * Removed requirement for custom GP jar file ### Fixed -* Sign header color formatting being lost on server restart \ No newline at end of file +* Sign header color formatting being lost on server restart +* Fixed issue preventing to buy claims due to currencies using $ character \ No newline at end of file diff --git a/src/me/EtienneDx/RealEstate/Messages.java b/src/me/EtienneDx/RealEstate/Messages.java index 7166b28..bc78635 100644 --- a/src/me/EtienneDx/RealEstate/Messages.java +++ b/src/me/EtienneDx/RealEstate/Messages.java @@ -1,5 +1,8 @@ package me.EtienneDx.RealEstate; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import org.bukkit.command.CommandSender; import org.bukkit.plugin.PluginDescriptionFile; @@ -122,7 +125,7 @@ public class Messages extends AnnotationConfig public String msgErrorNonIntegerPrice = "$cThe price must be an integer!"; @ConfigField(name="RealEstate.Errors.InvalidDuration", comment = "0: duration, 1: example of duration format, 2: example, 3: example") - public String msgErrorInvalidDuration = "$c{0} is not a valid duration! Durations must be in the format {1} or {2} or {3}!"; + public String msgErrorInvalidDuration = "$c{0} is not a valid duration! Durations must be in the format $a{1}$c or $a{2}$c or $a{3}$c!"; @ConfigField(name="RealEstate.Errors.NoMoneySelf") public String msgErrorNoMoneySelf = "$cYou don't have enough money to make this transaction!"; @@ -444,12 +447,16 @@ public static String getMessage(String msgTemplate, boolean withPrefix, String.. if (withPrefix) { msgTemplate = RealEstate.instance.config.chatPrefix + msgTemplate; } + + msgTemplate = msgTemplate.replace('$', ChatColor.COLOR_CHAR); + for (int i = 0; i < args.length; i++) { String param = args[i]; - msgTemplate = msgTemplate.replaceAll("\\{" + i + "\\}", param); + Matcher matcher = Pattern.compile("\\{" + i + "\\}").matcher(msgTemplate); + msgTemplate = matcher.replaceAll(Matcher.quoteReplacement(param)); } - return msgTemplate.replace('$', ChatColor.COLOR_CHAR); + return msgTemplate; } //sends a color-coded message to a player public static void sendMessage(CommandSender player, String msgTemplate, String... args) { diff --git a/src/me/EtienneDx/RealEstate/REListener.java b/src/me/EtienneDx/RealEstate/REListener.java index 717bbf0..decec38 100644 --- a/src/me/EtienneDx/RealEstate/REListener.java +++ b/src/me/EtienneDx/RealEstate/REListener.java @@ -203,9 +203,9 @@ else if(RealEstate.instance.config.cfgRentKeywords.contains(event.getLine(0).toL if(duration == 0) { Messages.sendMessage(player, RealEstate.instance.messages.msgErrorInvalidDuration, event.getLine(2), - ChatColor.GREEN + "10 weeks", - ChatColor.GREEN + "3 days", - ChatColor.GREEN + "1 week 3 days"); + "10 weeks", + "3 days", + "1 week 3 days"); event.setCancelled(true); event.getBlock().breakNaturally(); return; @@ -334,9 +334,9 @@ else if(RealEstate.instance.config.cfgLeaseKeywords.contains(event.getLine(0).to if(frequency == 0) { Messages.sendMessage(player, RealEstate.instance.messages.msgErrorInvalidDuration, event.getLine(3), - ChatColor.GREEN + "10 weeks", - ChatColor.GREEN + "3 days", - ChatColor.GREEN + "1 week 3 days"); + "10 weeks", + "3 days", + "1 week 3 days"); event.setCancelled(true); event.getBlock().breakNaturally(); return; diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java index 37046a8..91a2bf1 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java @@ -441,12 +441,6 @@ public void preview(Player player) RealEstate.econ.format(price), Utils.getTime(daysLeft, timeRemaining, true), Utils.getTime(duration, null, true)) + "\n"; - msg += ChatColor.AQUA + "This " + claimType + " is currently rented by " + - ChatColor.GREEN + Bukkit.getOfflinePlayer(buyer).getName() + ChatColor.AQUA + " for " + - ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + ChatColor.AQUA + " for " + - (maxPeriod - periodCount > 1 ? "" + ChatColor.GREEN + (maxPeriod - periodCount) + ChatColor.AQUA + " periods of " + - ChatColor.GREEN + Utils.getTime(duration, null, false) + ChatColor.AQUA + ". The current period will end in " : "another ") + - ChatColor.GREEN + Utils.getTime(daysLeft, timeRemaining, true) + "\n"; if(maxPeriod > 1 && maxPeriod - periodCount > 0) { From ef8b0797d798d3508a91e296b182de366efc449f Mon Sep 17 00:00:00 2001 From: Etienne Dx Date: Fri, 4 Mar 2022 22:18:34 +0100 Subject: [PATCH 13/16] fix: fixed #35 and /re list command, bumped version to 1.4.0-pre2 --- CHANGELOG.md | 4 +++- pom.xml | 2 +- src/me/EtienneDx/RealEstate/Messages.java | 10 ++++------ .../EtienneDx/RealEstate/Transactions/ClaimLease.java | 2 +- .../EtienneDx/RealEstate/Transactions/ClaimRent.java | 5 +++-- .../EtienneDx/RealEstate/Transactions/ClaimSell.java | 2 +- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c24f545..2968883 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,4 +17,6 @@ ### Fixed * Sign header color formatting being lost on server restart -* Fixed issue preventing to buy claims due to currencies using $ character \ No newline at end of file +* Fixed issue preventing to buy claims due to currencies using $ character +* Fixed error with `/re list` +* Fixed error regarding renewrent \ No newline at end of file diff --git a/pom.xml b/pom.xml index 4ced1b0..21b839d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 Me.EtienneDx real-estate - 1.4.0-pre1 + 1.4.0-pre2 RealEstate A spigot plugin for selling, renting and leasing GriefPrevention claims diff --git a/src/me/EtienneDx/RealEstate/Messages.java b/src/me/EtienneDx/RealEstate/Messages.java index bc78635..d75dcc9 100644 --- a/src/me/EtienneDx/RealEstate/Messages.java +++ b/src/me/EtienneDx/RealEstate/Messages.java @@ -1,7 +1,6 @@ package me.EtienneDx.RealEstate; import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.bukkit.command.CommandSender; import org.bukkit.plugin.PluginDescriptionFile; @@ -353,10 +352,10 @@ public class Messages extends AnnotationConfig public String msgInfoClaimInfoRentHeader = "$9-----= $f[$6RealEstate Rent Info$f]$9 =-----"; @ConfigField(name="RealEstate.Info.Claim.Info.Rent.GeneralNoBuyer", comment = "0: claim type, 1: formatted price, 2: duration") - public String msgInfoClaimInfoGeneralRentNoBuyer = "$bThis {0} is for rent for $a{1}$b per $a{2}."; + public String msgInfoClaimInfoGeneralRentNoBuyer = "$bThis {0} is for rent for $a{1}$b per $a{2}$b."; @ConfigField(name="RealEstate.Info.Claim.Info.Rent.GeneralBuyer", comment = "0: claim type, 1: buyer name, 2: formatted price, 3: time left in current period, 4: duration of a period") - public String msgInfoClaimInfoGeneralRentBuyer = "$bThis {0} is currently rented by $a{1}$b for $a{2}$b. The {0} is rented until $a{3}$b. The rent period is $a{4}"; + public String msgInfoClaimInfoGeneralRentBuyer = "$bThis {0} is currently rented by $a{1}$b for $a{2}$b. The {0} is rented for another $a{3}$b. The rent period is $a{4}"; @ConfigField(name="RealEstate.Info.Claim.Info.Rent.MaxPeriod", comment = "0: max periods") public String msgInfoClaimInfoRentMaxPeriod = "$bIt can be rented for a maximum of $a{0}$b periods."; @@ -449,11 +448,10 @@ public static String getMessage(String msgTemplate, boolean withPrefix, String.. } msgTemplate = msgTemplate.replace('$', ChatColor.COLOR_CHAR); - + for (int i = 0; i < args.length; i++) { String param = args[i]; - Matcher matcher = Pattern.compile("\\{" + i + "\\}").matcher(msgTemplate); - msgTemplate = matcher.replaceAll(Matcher.quoteReplacement(param)); + msgTemplate = msgTemplate.replaceAll("\\{" + i + "\\}", Matcher.quoteReplacement(param)); } return msgTemplate; diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java index fe60218..ea98af4 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java @@ -479,7 +479,7 @@ public void preview(Player player) @Override public void msgInfo(CommandSender cs) { - Claim claim = GriefPrevention.instance.dataStore.getClaim(claimId); + Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null); String location = "[" + claim.getLesserBoundaryCorner().getWorld().getName() + ", " + "X: " + claim.getLesserBoundaryCorner().getBlockX() + ", " + "Y: " + claim.getLesserBoundaryCorner().getBlockY() + ", " + diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java index 91a2bf1..1627bda 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java @@ -192,7 +192,7 @@ private void payRent() String location = "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " + sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]"; - if((autoRenew || periodCount < maxPeriod) && Utils.makePayment(owner, this.buyer, price, false, false)) + if((autoRenew || periodCount + 1 < maxPeriod) && Utils.makePayment(owner, this.buyer, price, false, false)) { periodCount = (periodCount + 1) % maxPeriod; startDate = LocalDateTime.now(); @@ -335,6 +335,7 @@ public void interact(Player player) buyer = player.getUniqueId(); startDate = LocalDateTime.now(); autoRenew = false; + periodCount = 0; claim.setPermission(buyer.toString(), buildTrust ? ClaimPermission.Build : ClaimPermission.Inventory); claim.setPermission(player.getUniqueId().toString(), ClaimPermission.Manage); claim.managers.add(player.getUniqueId().toString()); @@ -477,7 +478,7 @@ public void preview(Player player) @Override public void msgInfo(CommandSender cs) { - Claim claim = GriefPrevention.instance.dataStore.getClaim(claimId); + Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null); String location = "[" + claim.getLesserBoundaryCorner().getWorld().getName() + ", " + "X: " + claim.getLesserBoundaryCorner().getBlockX() + ", " + "Y: " + claim.getLesserBoundaryCorner().getBlockY() + ", " + diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimSell.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimSell.java index c948d25..72d21a8 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimSell.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimSell.java @@ -223,7 +223,7 @@ public void setOwner(UUID newOwner) @Override public void msgInfo(CommandSender cs) { - Claim claim = GriefPrevention.instance.dataStore.getClaim(claimId); + Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null); if(claim == null) { tryCancelTransaction(null, true); return; From 15eff804170cec63bfab607116354bd82877da79 Mon Sep 17 00:00:00 2001 From: Etienne Dx Date: Mon, 7 Mar 2022 11:12:44 +0100 Subject: [PATCH 14/16] feat: bumped version to 1.4.0, ready to release --- CHANGELOG.md | 2 +- plugin.yml | 2 +- pom.xml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2968883..c81686b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## 1.4.0 - Unreleased +## 1.4.0 ### Added * Readme and changelog files diff --git a/plugin.yml b/plugin.yml index dcee6d6..6e30645 100644 --- a/plugin.yml +++ b/plugin.yml @@ -3,7 +3,7 @@ main: me.EtienneDx.RealEstate.RealEstate version: ${project.version} authors: [EtienneDx, DmitryRendov] depend: [Vault, GriefPrevention] -api-version: "1.17" +api-version: "1.18" commands: re: diff --git a/pom.xml b/pom.xml index 21b839d..bba792d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 Me.EtienneDx real-estate - 1.4.0-pre2 + 1.4.0 RealEstate A spigot plugin for selling, renting and leasing GriefPrevention claims @@ -150,7 +150,7 @@ com.github.TechFortress GriefPrevention - 16.18-RC1 + 16.18 provided From 3a577bfa895e2b135fdd5b4e30986d64da067f9a Mon Sep 17 00:00:00 2001 From: Etienne Dx Date: Mon, 7 Mar 2022 11:23:20 +0100 Subject: [PATCH 15/16] fix: removed vscode file --- .vscode/settings.json | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index e0f15db..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "java.configuration.updateBuildConfiguration": "automatic" -} \ No newline at end of file From 3cb0895e847c7334460b2d0d72456dc8c73126e0 Mon Sep 17 00:00:00 2001 From: Etienne Dx Date: Mon, 7 Mar 2022 11:26:13 +0100 Subject: [PATCH 16/16] fix: fixed docs --- CHANGELOG.md | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c81686b..d56f4bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ * Error messages to *messages.yml* * List messages to *messages.yml* * Info messages to *messages.yml* -* Support of [GriefPrevention v16.18-RC1](https://github.com/TechFortress/GriefPrevention/releases/tag/16.18-RC1) and up +* Support of [GriefPrevention v16.18](https://github.com/TechFortress/GriefPrevention/releases/tag/16.18) and up * Disabled resizing of parent claims when subclaims are being rented ### Modified diff --git a/README.md b/README.md index 5e9469e..4d7e442 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # RealEstate -RealEstate is a spigot plugin built on top of GriefPrevention to provide players with an ability to sell, rent and lease claims to other players. +RealEstate is a spigot plugin built on top of GriefPrevention to provide players with an ability to sell and rent claims to other players. The plugin is documented in the [GitHub wiki](https://github.com/EtienneDx/RealEstate/wiki). @@ -8,6 +8,6 @@ Please feel free to report any issue in the [GitHub Issue section](https://githu ## GriefPrevention -This plugin is dependent on GriefPrevention version 16.18 and up (this version of GP is still in a pre-release state while I'm writing this). +This plugin is dependent on GriefPrevention version 16.18 and up. GriefPrevention plugin can be found [here](https://github.com/TechFortress/GriefPrevention). \ No newline at end of file