From d08b240ff9b40c0e04cc9ddd984c3c49aca7d0bc Mon Sep 17 00:00:00 2001 From: Paldiu Date: Sat, 9 Apr 2022 08:38:42 -0500 Subject: [PATCH] RC04 - Patch 0002 Changelog: - Renamed LuckContainer#baseValue() to getValue() - Changed the way files save by using the Map#values() call instead of iterating the kvp's. - Made the actual percentage rng value round to the closest whole number before being checked. - Changed Luck#defaultValue() to getDefaultValue(). --- .gradle/7.3.3/checksums/checksums.lock | Bin 17 -> 17 bytes .../executionHistory/executionHistory.bin | Bin 78800 -> 78800 bytes .../executionHistory/executionHistory.lock | Bin 17 -> 17 bytes .gradle/7.3.3/fileHashes/fileHashes.bin | Bin 22597 -> 22597 bytes .gradle/7.3.3/fileHashes/fileHashes.lock | Bin 17 -> 17 bytes .../7.3.3/fileHashes/resourceHashesCache.bin | Bin 19381 -> 19653 bytes .../buildOutputCleanup.lock | Bin 17 -> 17 bytes .gradle/file-system.probe | Bin 8 -> 8 bytes .../compileJava/previous-compilation-data.bin | Bin 31255 -> 31253 bytes .../io/github/simplex/api/LuckContainer.java | 2 +- .../io/github/simplex/luck/FeelingLucky.java | 2 +- .../java/io/github/simplex/luck/LuckCMD.java | 11 ++++--- .../io/github/simplex/luck/player/Luck.java | 28 +++++++++--------- .../simplex/luck/player/PlayerConfig.java | 2 +- 14 files changed, 22 insertions(+), 23 deletions(-) diff --git a/.gradle/7.3.3/checksums/checksums.lock b/.gradle/7.3.3/checksums/checksums.lock index d20ec9f65f612933c8bcdaeea0a6fa93650dade0..ccab47ba4e893abd757992867534c8a1ddc60b20 100644 GIT binary patch literal 17 UcmZQJ47>Jfmhh~81_&qx05g3AmH+?% literal 17 UcmZQJ47>Jfmhh~81_&qw05f?6k^lez diff --git a/.gradle/7.3.3/executionHistory/executionHistory.bin b/.gradle/7.3.3/executionHistory/executionHistory.bin index 5e007ee2ad95d6a6f37affecc50a897294cf0ca7..d7b065cf9a74b3425cdb7e5e9f55c3feb5c8f53f 100644 GIT binary patch delta 1283 zcmccc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E-X$7sW{=l7R8lTZINWH|<8O!{Rkfu1aX9|8sXK85KQ^ccU_qbJS7 z$3e3D6POtUesjp{GL+x-T;!h7C%aytl5v7hX>zu+uZxPIUUE)iaWMl%qU}8f(mjt2 zq0|Vb6g~OQ1uLC=@VBr8dg9#;mbzd*z0iPBOaeUx-vYbvx61VSAX)Te+;9Zsg4>$Y z&l)g_OQEOZ+hCL1)EMVXHb{`xWxzX=@7xlktIo$#Ls zVVPG89{`2!+1B|y+$?(}c=x(n5A$Si0fj`@Wtu);SvTRj^X+S|UvNeMh0ycQc5Wla iWsLIP&1=*x*EEDrx)B~x*6;Iq;z^K4r$h3N$ut0I-z3)n diff --git a/.gradle/7.3.3/executionHistory/executionHistory.lock b/.gradle/7.3.3/executionHistory/executionHistory.lock index e199d1bb03eaa609134db7b1ed700a09ac5d50fb..efec06353def25577106eb9402822e2efe8a9d5f 100644 GIT binary patch literal 17 UcmZRcB;nt8QAKht0|ZzC04QVwZvX%Q literal 17 UcmZRcB;nt8QAKht0|b}?04QJsYXATM diff --git a/.gradle/7.3.3/fileHashes/fileHashes.bin b/.gradle/7.3.3/fileHashes/fileHashes.bin index 56f6852c0978eb3e253433e14883201215f98743..b2fc35ea6c2a4f68a848feecd50d163814d970b3 100644 GIT binary patch delta 890 zcmX@Qf$``D#tqK{6#TFDyyblr`Sj_WyqgSPLl!eIFgEbDH}^4s0pq608^eSrO9dt? z_?x6mHRX^nEa}c-+qhT%8dPB=L?MUr)`*W730@Z0pm5Z5$uv)kBS42b2T?sfj=WO~>U<`S3Ff zd<06)6(;)Sd$mDzv;tKEbu$RoU}{miwem-b=G&Ofmsk$HUBKE1)iM>R5(u~rfCQQ) z%XQ9{71l)?hdnJR_z-mBBGe;#U=0lHKA1Y@F&KZ935d(up}#@b_h{#ZZ%{3!5G~Bc zlYa-fD16~K#D1er&#UCUgngl;%WH^Bt{FiTF}6>R4-RJqM!>aclXnN}f?0DWzYUgB zIO3h%)qX@ZC8yF+z}cdJ8LIINM5Dl+$@0ExlYK*;c`2)|UhS=7c|T|4|}Dvip(}%eM==ub$8s zhp4&12~i{J3Q|)qQ&jrK-tbh?j}6(-N6si!NS16DgtzfDk#8jh)uTj2M7HP zsmb~NQVKhkMu(;S+03!x(-h|3Wfvu&I-f)AsuG<%+tX!oclb0Fr3ba^udfu?y!W5^ V`|LB{{zDYrya`cQ0n9QCdH_Xo4paaD delta 859 zcmX@Qf$``D#tqK{CYO2{O_mHyQE>hol5irzz_aW4OJ)JT0$&CO#`@<5#$60xz#%qy zZlFv3*~y_Y(MIzFI<%(hH*WhpAF60FM3KUEAgyN%Bs76o5rhT2=LIi_ym*LZdYFo| zPqcy)NXP3%C)ohsuzJ-XaBWr9q5y;!jt zVw!;6WO-k;$-W`aytHE#99iaU%aXaK@?_JGmh}*Y%7-Be4eWt5n%~-$B`&H--I{u! z_?-90&u4(~0Ww;dcXDm0lti6N4~v!R4N=M6-rH_{2{{Utl%2djRI1*~sqC5R>`z5U zX4q@#@Ev#qm9&P~C5Tx4$0C>$lWif4!pZsmQVQP9Yt${*G=xvO5gt+2 z@ADa=TxBBIe1j=jH6mxNAP_W4Z)UsOkY#7z%O;0GY=B Ar2qf` diff --git a/.gradle/7.3.3/fileHashes/fileHashes.lock b/.gradle/7.3.3/fileHashes/fileHashes.lock index 0273a9c2f73f9fe951b73562f443783d67c2248f..f9612037421a243f231258fb45e8272641c56a4d 100644 GIT binary patch literal 17 UcmZQJia%cNU%e)k0Sp+K0WB#5vH$=8 literal 17 UcmZQJia%cNU%e)k0Rrv=04@UrjQ{`u diff --git a/.gradle/7.3.3/fileHashes/resourceHashesCache.bin b/.gradle/7.3.3/fileHashes/resourceHashesCache.bin index 979bc314c7e3dad83829dafd8270d60b0f49e3e3..8247675deb27586e6bc6d426015c6ce0458bc1cc 100644 GIT binary patch delta 487 zcmdlwo$=^Q#tkMCj7pnLB?1^7KDF$b{Jwi@F#{O**#3ut&qbd9KFXJCL&Y0m;!JF< zA0mzFJD}o=C)Y|^Xy_b1sZm)U*bfo(-U?G}z}J?_cF$Q8syKe~T1f=~qw@_W!BNZY zpo)J^J}S9Eqj0(8srUU~-a`ei!%V1Ro;m4|q~}kl3DT2urJR_U9XBfe5Z`EULu9j~ zM+tMiF;G?#hy_7dAZpUFWp-ZP!UoeMiZcbdvw(tfs49LiZv1B$E485J-u)c$s~>nU zRU~A@?mbhi6uvp+YJh3TmM@qp>UQ-!>*bMo9g_2*elfe0mMo@{yW;VSUP+w%J^7j0 zZUO#``J-P46jYg%S87~>FF;$#$D;4D^uxxE#Y}})#az`3d#YJzSSKr?H RCR|Igs(%~R^nVIS2>^`WoACeu delta 48 zcmV-00MGx$nE|zz0kAX}0UEP47*GL|%^5J0EgBe;T^gv9H5)nt0)eq1_!qG-m=&`@ GNOS{`aS$c| diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 51a1807422f054ae8ab68a6d9619618c19662334..148218525016a1d8814f7ce08bc75c39016a9942 100644 GIT binary patch literal 17 UcmZR6D^X+eb%*{#1_&qz05^gJ?EnA( literal 17 UcmZR6D^X+eb%*{#1_&qs05^LC<^TWy diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe index 002d5779a3d2b7d6593bd4f8044915f6505d8ecb..cd4f77c2c4e04ed176c29e810e4fd277c83011a3 100644 GIT binary patch literal 8 PcmZQzU~J%P-}esy2Gs)7 literal 8 PcmZQzV61<=SVRN>2wDO+ diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin index dcb3c8dda8612d7b62c4d05a6ff37d335c94c6f3..1371db3df38365fab1f58db6e0f853a4efa4cf78 100644 GIT binary patch delta 280 zcmV+z0q6dg^Z}Lh0g%BEBPFY=OClt*Be5@?llmlOi(lVAzC#q7 zlMew&LK-`m$+pmCLU~?ENQy?XX);J3GXRHSZe(m_auAiTG(Wb`kZ1QI5|E-pBcwD; zAR`d7o|lpiHcKK)sa0hf`ES&dngJjXNOhzt8E(J&cgkf-L3nNJYiEnOnVQFqbIwcg^UO0(BsCHcengA}IwjZ@8M{li+VoV#lfeS15d}g- g95OTjGyw)V6+#>-H374F0~-MZ1QkLYvzP>Zbp#P@6aWAK diff --git a/src/main/java/io/github/simplex/api/LuckContainer.java b/src/main/java/io/github/simplex/api/LuckContainer.java index 62e847e..dee2cc1 100644 --- a/src/main/java/io/github/simplex/api/LuckContainer.java +++ b/src/main/java/io/github/simplex/api/LuckContainer.java @@ -18,5 +18,5 @@ public interface LuckContainer extends Serializable { Player associatedPlayer(); - double baseValue(); + double getValue(); } diff --git a/src/main/java/io/github/simplex/luck/FeelingLucky.java b/src/main/java/io/github/simplex/luck/FeelingLucky.java index db40b7e..70c188d 100644 --- a/src/main/java/io/github/simplex/luck/FeelingLucky.java +++ b/src/main/java/io/github/simplex/luck/FeelingLucky.java @@ -52,6 +52,6 @@ public final class FeelingLucky extends JavaPlugin { @Override public void onDisable() { Bukkit.getLogger().info("Saving all player configurations..."); - configMap.forEach((u, pc) -> pc.save()); + configMap.values().forEach(PlayerConfig::save); } } diff --git a/src/main/java/io/github/simplex/luck/LuckCMD.java b/src/main/java/io/github/simplex/luck/LuckCMD.java index 7e75854..9bafe1f 100644 --- a/src/main/java/io/github/simplex/luck/LuckCMD.java +++ b/src/main/java/io/github/simplex/luck/LuckCMD.java @@ -3,7 +3,6 @@ package io.github.simplex.luck; import io.github.simplex.lib.Messages; import io.github.simplex.luck.player.Luck; import io.github.simplex.luck.player.PlayerConfig; -import io.github.simplex.luck.player.PlayerHandler; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.format.TextColor; @@ -47,21 +46,21 @@ public class LuckCMD extends Command implements TabCompleter { case "set" -> { luck.setValue(amount); plugin.handler.updatePlayer(player, luck); - config.setLuck(luck.baseValue()); + config.setLuck(luck.getValue()); sender.sendMessage(Component.empty().content("Successfully reset " + args[1] + "'s Luck stat.")); return true; } case "give" -> { luck.addTo(amount); plugin.handler.updatePlayer(player, luck); - config.setLuck(luck.baseValue()); + config.setLuck(luck.getValue()); sender.sendMessage(Component.empty().content("Successfully reset " + args[1] + "'s Luck stat.")); return true; } case "take" -> { luck.takeFrom(amount); plugin.handler.updatePlayer(player, luck); - config.setLuck(luck.baseValue()); + config.setLuck(luck.getValue()); sender.sendMessage(Component.empty().content("Successfully reset " + args[1] + "'s Luck stat.")); return true; } @@ -83,7 +82,7 @@ public class LuckCMD extends Command implements TabCompleter { } Luck luck = plugin.handler.getLuckContainer(player); - sender.sendMessage(Component.empty().content("Luck stat for " + args[1] + ": " + luck.baseValue())); + sender.sendMessage(Component.empty().content("Luck stat for " + args[1] + ": " + luck.getValue())); return true; } @@ -99,7 +98,7 @@ public class LuckCMD extends Command implements TabCompleter { PlayerConfig config = FeelingLucky.getConfigMap().get(player.getUniqueId()); luck.reset(); plugin.handler.updatePlayer(player, luck); - config.setLuck(luck.baseValue()); + config.setLuck(luck.getValue()); sender.sendMessage(Component.empty().content("Successfully reset " + args[1] + "'s Luck stat.")); return true; } diff --git a/src/main/java/io/github/simplex/luck/player/Luck.java b/src/main/java/io/github/simplex/luck/player/Luck.java index d344a9b..3efdb82 100644 --- a/src/main/java/io/github/simplex/luck/player/Luck.java +++ b/src/main/java/io/github/simplex/luck/player/Luck.java @@ -58,7 +58,7 @@ public class Luck implements LuckContainer { rng = RNG().nextDouble(0.0, 1024.0); } - double actual = (rng / 1024.0) * 100; + double actual = Math.round((rng / 1024.0) * 100); return (percentage >= actual); } @@ -101,7 +101,7 @@ public class Luck implements LuckContainer { rng = RNG().nextDouble(0.0, 1024.0); } - double actual = (rng / 1024) * 100; + double actual = Math.round((rng / 1024) * 100); if (multiplier() > 1.0) { return ((percentage * multiplier()) >= actual); @@ -111,15 +111,15 @@ public class Luck implements LuckContainer { } public void reset() { - setValue(defaultValue()); + setValue(getDefaultValue()); } @Override - public double baseValue() { + public double getValue() { return BASE_VALUE; } - public double defaultValue() { + public double getDefaultValue() { return player.getAttribute(Attribute.GENERIC_LUCK).getDefaultValue(); } @@ -130,39 +130,39 @@ public class Luck implements LuckContainer { } public void addTo(double value) { - if (value >= 1024.0 || (baseValue() + value) >= 1024.0) { + if (value >= 1024.0 || (getValue() + value) >= 1024.0) { setValue(1024.0); return; } - setValue(baseValue() + value); + setValue(getValue() + value); } public void takeFrom(double value) { - if (value <= -1024.0 || (baseValue() - value) <= -1024.0) { + if (value <= -1024.0 || (getValue() - value) <= -1024.0) { setValue(-1024.0); return; } - setValue(baseValue() + value); + setValue(getValue() + value); } public double getPercentage() { - return baseValue() - defaultValue(); + return getValue() - getDefaultValue(); } public boolean notDefault() { - return baseValue() != defaultValue(); + return getValue() != getDefaultValue(); } public boolean lessThan(double value) { - return baseValue() < value; + return getValue() < value; } public boolean greaterThan(double value) { - return baseValue() > value; + return getValue() > value; } @Override public String toString() { - return "" + baseValue(); + return "" + getValue(); } } diff --git a/src/main/java/io/github/simplex/luck/player/PlayerConfig.java b/src/main/java/io/github/simplex/luck/player/PlayerConfig.java index dece37a..63c9f69 100644 --- a/src/main/java/io/github/simplex/luck/player/PlayerConfig.java +++ b/src/main/java/io/github/simplex/luck/player/PlayerConfig.java @@ -47,7 +47,7 @@ public class PlayerConfig { if (tempUsername != null && !tempUsername.equalsIgnoreCase(player.getName())) { config.set("username", player.getName()); - config.set("luck", plugin.handler.getLuckContainer(player).defaultValue()); + config.set("luck", plugin.handler.getLuckContainer(player).getDefaultValue()); config.set("multiplier", "1.0"); save(); }