From 0174d9cb95bdbc7e44a8b7e58f22ebc500c54bc1 Mon Sep 17 00:00:00 2001 From: Fabian Gal Date: Sat, 17 Apr 2021 23:31:57 +0100 Subject: [PATCH 1/4] MAde space for the Rent sign so it will allow the full player name to be displayed underneath --- RealEstate.iml | 36 +++++++++++++++++++ .../RealEstate/Transactions/ClaimRent.java | 4 +-- 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 RealEstate.iml diff --git a/RealEstate.iml b/RealEstate.iml new file mode 100644 index 0000000..7f65c0c --- /dev/null +++ b/RealEstate.iml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java index 49cbab8..68a1965 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java @@ -107,8 +107,8 @@ public class ClaimRent extends BoughtTransaction else if(sign.getBlock().getState() instanceof Sign) { Sign s = (Sign) sign.getBlock().getState(); - s.setLine(0, RealEstate.instance.config.cfgSignsHeader); - s.setLine(1, Utils.getSignString("Rented by " + Bukkit.getOfflinePlayer(buyer).getName())); + s.setLine(0, ChatColor.GOLD + "[Rented]"); //Changed the header to "[Rented]" so that it won't waste space on the next line and allow the name of the player to show underneath. + s.setLine(1, Utils.getSignString(Bukkit.getOfflinePlayer(buyer).getName()));//remove "Rented by" s.setLine(2, "Time remaining : "); int daysLeft = duration - days - 1;// we need to remove the current day From cb35296c2ca7c6bde9b6ab16f9461c8859e6ca4c Mon Sep 17 00:00:00 2001 From: Fabian Gal Date: Sun, 18 Apr 2021 01:42:06 +0100 Subject: [PATCH 2/4] Added the choice of excluding decimal numbers in the config (quick solution) --- src/me/EtienneDx/RealEstate/Config.java | 2 ++ src/me/EtienneDx/RealEstate/REListener.java | 21 +++++++++++++++++++ .../RealEstate/Transactions/ClaimLease.java | 18 ++++++++++++++-- .../RealEstate/Transactions/ClaimRent.java | 19 +++++++++++++++-- .../RealEstate/Transactions/ClaimSell.java | 18 ++++++++++++++-- 5 files changed, 72 insertions(+), 6 deletions(-) diff --git a/src/me/EtienneDx/RealEstate/Config.java b/src/me/EtienneDx/RealEstate/Config.java index 8313120..4aab32b 100644 --- a/src/me/EtienneDx/RealEstate/Config.java +++ b/src/me/EtienneDx/RealEstate/Config.java @@ -61,6 +61,8 @@ public class Config extends AnnotationConfig public boolean cfgUseCurrencySymbol = false; @ConfigField(name="RealEstate.Rules.CurrencySymbol", comment = "In case UseCurrencySymbol is true, what symbol should be used?") public String cfgCurrencySymbol = "$"; + @ConfigField(name="RealEstate.Rules.UseDecimalCurrency", comment = "Allow players to use decimal currency e.g. $10.15") + public boolean cfgUseDecimalCurrency = true; @ConfigField(name="RealEstate.Messaging.MessageOwner", comment = "Should the owner get messaged once one of his claim is rented/leased/bought and on end of contracts?") public boolean cfgMessageOwner = true; diff --git a/src/me/EtienneDx/RealEstate/REListener.java b/src/me/EtienneDx/RealEstate/REListener.java index 7314056..4c73959 100644 --- a/src/me/EtienneDx/RealEstate/REListener.java +++ b/src/me/EtienneDx/RealEstate/REListener.java @@ -114,6 +114,13 @@ public class REListener implements Listener 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!"); + event.setCancelled(true); + event.getBlock().breakNaturally(); + return; + } if(claim.isAdminClaim()) { @@ -175,6 +182,13 @@ public class REListener implements Listener 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!"); + event.setCancelled(true); + event.getBlock().breakNaturally(); + return; + } if(event.getLine(2).isEmpty()) { @@ -279,6 +293,13 @@ public class REListener implements Listener 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!"); + event.setCancelled(true); + event.getBlock().breakNaturally(); + return; + } if(event.getLine(2).isEmpty()) { diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java index f7544b3..2eb7461 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java @@ -71,11 +71,25 @@ public class ClaimLease extends BoughtTransaction //s.setLine(2, paymentsLeft + "x " + price + " " + RealEstate.econ.currencyNamePlural()); if(RealEstate.instance.config.cfgUseCurrencySymbol) { - s.setLine(2, paymentsLeft + "x " + RealEstate.instance.config.cfgCurrencySymbol + " " + price); + if(RealEstate.instance.config.cfgUseDecimalCurrency == false) + { + s.setLine(2, paymentsLeft + "x " + RealEstate.instance.config.cfgCurrencySymbol + " " + (int)Math.round(price)); + } + else + { + s.setLine(2, paymentsLeft + "x " + RealEstate.instance.config.cfgCurrencySymbol + " " + price); + } } else { - s.setLine(2, paymentsLeft + "x " + price + " " + RealEstate.econ.currencyNamePlural()); + if(RealEstate.instance.config.cfgUseDecimalCurrency == false) + { + s.setLine(2, paymentsLeft + "x " + (int)Math.round(price) + " " + RealEstate.econ.currencyNamePlural()); + } + else + { + s.setLine(2, paymentsLeft + "x " + price + " " + RealEstate.econ.currencyNamePlural()); + } } s.setLine(3, Utils.getTime(frequency, null, false)); s.update(true); diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java index 68a1965..2a537d4 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java @@ -76,11 +76,26 @@ public class ClaimRent extends BoughtTransaction //s.setLine(2, owner != null ? Bukkit.getOfflinePlayer(owner).getName() : "SERVER"); if(RealEstate.instance.config.cfgUseCurrencySymbol) { - s.setLine(2, RealEstate.instance.config.cfgCurrencySymbol + " " + price); + if(RealEstate.instance.config.cfgUseDecimalCurrency == false) + { + s.setLine(2, RealEstate.instance.config.cfgCurrencySymbol + " " + (int)Math.round(price)); + } + else + { + s.setLine(2, RealEstate.instance.config.cfgCurrencySymbol + " " + price); + } + } else { - s.setLine(2, price + " " + RealEstate.econ.currencyNamePlural()); + if(RealEstate.instance.config.cfgUseDecimalCurrency == false) + { + s.setLine(2, (int)Math.round(price) + " " + RealEstate.econ.currencyNamePlural()); + } + else + { + s.setLine(2, price + " " + RealEstate.econ.currencyNamePlural()); + } } s.setLine(3, (maxPeriod > 1 ? maxPeriod + "x " : "") + Utils.getTime(duration, null, false)); s.update(true); diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimSell.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimSell.java index 6cbc55d..38d6f94 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimSell.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimSell.java @@ -42,11 +42,25 @@ public class ClaimSell extends ClaimTransaction s.setLine(2, owner != null ? Utils.getSignString(Bukkit.getOfflinePlayer(owner).getName()) : "SERVER"); if(RealEstate.instance.config.cfgUseCurrencySymbol) { - s.setLine(3, RealEstate.instance.config.cfgCurrencySymbol + " " + price); + if(RealEstate.instance.config.cfgUseDecimalCurrency == false) + { + s.setLine(3, RealEstate.instance.config.cfgCurrencySymbol + " " + (int)Math.round(price)); + } + else + { + s.setLine(3, RealEstate.instance.config.cfgCurrencySymbol + " " + price); + } } else { - s.setLine(3, price + " " + RealEstate.econ.currencyNamePlural()); + if(RealEstate.instance.config.cfgUseDecimalCurrency == false) + { + s.setLine(3, (int)Math.round(price) + " " + RealEstate.econ.currencyNamePlural()); + } + else + { + s.setLine(3, price + " " + RealEstate.econ.currencyNamePlural()); + } } s.update(true); } From 1b18797ad567046275d0f93cfcc246be19104e66 Mon Sep 17 00:00:00 2001 From: FabianGal45 Date: Sun, 2 May 2021 22:31:48 +0100 Subject: [PATCH 3/4] Added ongoing rent to Config --- src/me/EtienneDx/RealEstate/Config.java | 2 ++ src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/me/EtienneDx/RealEstate/Config.java b/src/me/EtienneDx/RealEstate/Config.java index 4aab32b..e1c5a9b 100644 --- a/src/me/EtienneDx/RealEstate/Config.java +++ b/src/me/EtienneDx/RealEstate/Config.java @@ -37,6 +37,8 @@ public class Config extends AnnotationConfig public String cfgReplaceRent = "FOR RENT"; @ConfigField(name="RealEstate.Keywords.Replace.Lease", comment = "What is displayed on signs for preoperties to lease") public String cfgReplaceLease = "FOR LEASE"; + @ConfigField(name="RealEstate.Keywords.Replace.Ongoing.Rent", comment = "What is displayed on the first line of the sign once someone rents a claim.") + public String cfgReplaceOngoingRent = "[Rented]"; @ConfigField(name="RealEstate.Rules.Sell", comment = "Is selling claims enabled?") public boolean cfgEnableSell = true; diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java index 2a537d4..e57cfeb 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java @@ -122,7 +122,7 @@ public class ClaimRent extends BoughtTransaction else if(sign.getBlock().getState() instanceof Sign) { Sign s = (Sign) sign.getBlock().getState(); - s.setLine(0, ChatColor.GOLD + "[Rented]"); //Changed the header to "[Rented]" so that it won't waste space on the next line and allow the name of the player to show underneath. + s.setLine(0, ChatColor.GOLD + RealEstate.instance.config.cfgReplaceOngoingRent); //Changed the header to "[Rented]" so that it won't waste space on the next line and allow the name of the player to show underneath. s.setLine(1, Utils.getSignString(Bukkit.getOfflinePlayer(buyer).getName()));//remove "Rented by" s.setLine(2, "Time remaining : "); From 00777b9842ad8712f1922893f0d43a8d63c23f74 Mon Sep 17 00:00:00 2001 From: FabianGal45 Date: Sun, 2 May 2021 23:14:43 +0100 Subject: [PATCH 4/4] Removed the iml file and added the changes --- RealEstate.iml | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 RealEstate.iml diff --git a/RealEstate.iml b/RealEstate.iml deleted file mode 100644 index 7f65c0c..0000000 --- a/RealEstate.iml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file