From b7c0fee9fdc49359a69869fb368befdd9e09cd3f Mon Sep 17 00:00:00 2001 From: Zeshan Aslam Date: Mon, 20 Mar 2017 01:15:09 -0400 Subject: [PATCH] Completed rewrite --- config.yml | 9 +- .../actionhealth/FileHandler.class | Bin 0 -> 6109 bytes .../actionhealth/HealthCommand.class | Bin 0 -> 3128 bytes .../actionhealth/HealthListeners.class | Bin 0 -> 4165 bytes .../actionhealth/HealthUtil$1.class | Bin 0 -> 932 bytes .../zeshanaslam/actionhealth/HealthUtil.class | Bin 0 -> 7032 bytes .../com/zeshanaslam/actionhealth/Main.class | Bin 0 -> 2149 bytes .../actionhealth/SettingsManager.class | Bin 0 -> 3218 bytes plugin.yml | 2 +- .../zeshanaslam/actionhealth/FileHandler.java | 330 ++++++++++++++++++ .../actionhealth/HealthCommand.java | 70 ++++ .../actionhealth/HealthListeners.java | 120 +++++++ .../zeshanaslam/actionhealth/HealthUtil.java | 83 ++++- src/com/zeshanaslam/actionhealth/Main.java | 30 +- .../actionhealth/SettingsManager.java | 15 +- 15 files changed, 648 insertions(+), 11 deletions(-) create mode 100644 out/production/ActionHealth/com/zeshanaslam/actionhealth/FileHandler.class create mode 100644 out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthCommand.class create mode 100644 out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthListeners.class create mode 100644 out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil$1.class create mode 100644 out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil.class create mode 100644 out/production/ActionHealth/com/zeshanaslam/actionhealth/Main.class create mode 100644 out/production/ActionHealth/com/zeshanaslam/actionhealth/SettingsManager.class create mode 100644 src/com/zeshanaslam/actionhealth/FileHandler.java create mode 100644 src/com/zeshanaslam/actionhealth/HealthCommand.java create mode 100644 src/com/zeshanaslam/actionhealth/HealthListeners.java diff --git a/config.yml b/config.yml index 1965f34..78a4fd6 100644 --- a/config.yml +++ b/config.yml @@ -4,11 +4,11 @@ # {maxhealth} shows the max health of the mob or player. # {usestyle} will use the defined chars. -Health Message: '&6&l{name}: &a&l{health} / {maxhealth}' +Health Message: '&7&l{name}: {usestyle}' # Strip Name. -Strip Name: false +Strip Name: true # If enabled players with the permission 'ActionHealth.Health' will only see the action health message. @@ -48,4 +48,7 @@ Disabled regions: Region PvP: true # When set to true and style health is enabled this will limit the health symbols to 10. -Limit Health: true \ No newline at end of file +Limit Health: true + +# Saves players /actionhealth toggle state. +Remember Toggle: true \ No newline at end of file diff --git a/out/production/ActionHealth/com/zeshanaslam/actionhealth/FileHandler.class b/out/production/ActionHealth/com/zeshanaslam/actionhealth/FileHandler.class new file mode 100644 index 0000000000000000000000000000000000000000..bb807a90daf8cc97b951f8deccc3ba6d28089cd8 GIT binary patch literal 6109 zcmbVPX?Rpu8Gdg!#0z0G$eK#L7{WJk-o#5`wBVTU{tbeFs?i+>@HZ^-3}i5U}D4J)qN@TYgXzVOT?K(`{9qAGJtB)m8&OmN_*vTBUhlN2?EFHI#hwV&4p7l$E z9~OBaefxKvjXM+KT^MG^5|aiZv3Pnsdd`^~vs3nD(jJf6aal3u*vage8_pg(HIj5P zw5c7++VL~{>HA;v}6c zZ-j?R1u`_|cs*hU+Pb9*|S zbnFz_*dx?=RRDRPu_hzAFw(_E;PI>{(807)BgW*;3F<4ZmW(r=o^p0)(&K)BT2EdD z*dD-A7n>`ItYUok&tq8`X&T%hbP*`0tpR9#t`e+_L~4pS>CAN0v!bqM+MVoVwV54#o7>KQ zWlNawP&${1J2L4EG{}!0|7&H0Tj)W|!hKk0AbOiVEUd={3)gYO!cE*@h35B6-^OI& zm*SuwG3t{4E-b|Jb_=`lkcB;R>Bq)AMDd8Xupb*u{K~?c__cw>rCZPTTp~Fl!@6n5 zfz55ZGMRLyjr#$&tj%o}euLjycnc4ic-zA7#O0t6{y6qp_&p8@IQe}TM=cz~aSJE# zj)h0$>!&bmVGIcqf3RTVj}{)2OIqIi$-=w%v%GoF!YA-a3kL=3Nqok_XYn}$o%7v= znUq36YK#`WQk}+fb@X1z&5%1|t=Bm!v-K0)qqz&Q;tpo)xa7J3J2XAXa%AbIb1c`w z0b)?uaITEAQmXBV2`9yEU`=4b`rzF2fR>$xHCa9I^ZDbk$p_6+cF85V&s3|4$Xs7O!!M$T?^LGUdmgz=bKgg%+JSbN3cU|NvjEHds6_J~$JbD!iuAnN?&FAhJRG&u! zf6OBnP_u9K3_@HSzD$HRbfA-G<4W95jI})20*zRJT7*!~18)=VL^D?{;<`JyvK3ue zj5Sz7PD`&vHo>4YaW+@!;R_}_u z&$VmO3P`z_s2DIYASJ>{s9is;!-*DLH(kKW*z0J%i56D;qNdgvEY@Q4ZU%SE;LZZ8 ze3>g&+sSGdS?wT;oh<#`K32=!a+YYKvsgX2oO}j7R;T$Sf;1|>OQgkoYShq6u^M|> zn)~>+9~MCxFyQ&Md}=fn`|WqtXvD)fpw-x<{klmgt&E2~OfUoahOEMnTfBzs3mWFQ z&S$HL$|Np5kE+Ux`eB*Wippdie}UuVeS*W`qz}K5DBf8RpC*`${DnkLOmG})=3&x;G;C;-d={&-GzQtQ{%ZgIN2E1P$!u) z$y$AciCuA?(sy(Aue{7x{-nM@(O+aEyyODQJg145)OxL(yo+Ome5FB|-a2}5m@zf0 z4)B8*Ht4LhufC3s3LFt>4_QRe6gW?b|-q&7LaFo+`~$ zMW(NTl;@&U^;OHRqbop__o&MIKKyd3D|{X%%c!!dRF%KXLzM|q{unYEGGCNoR~6P{ zq)?BlME=TN{hN<$*b^h{i4n#mvP8@=b!t?|n<>6gnRt{w&)$a5ztiVG{x6@?p3igi z`IvX0>18{}zFh1>`&a%MH%irbg^;XF8B{(nc`Se((gvEPmrME;J=v~%71vRn!(yq Uq&+T@>fIV$W(J;ei}C6I0YLMA761SM literal 0 HcmV?d00001 diff --git a/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthCommand.class b/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthCommand.class new file mode 100644 index 0000000000000000000000000000000000000000..dc5bd6c4f4b68e3537c68ef5e66fddcfc04e6daa GIT binary patch literal 3128 zcmbtW+fx%)82_CluuE7Gqag8816B+d6YHf`unHmyEhvI$!QPf|2rHXi$Zk+^x~w9 zhlS`7KOV(n5+3(sCDa1i^vQ_H=$FAI42XkxA%Ykzgoab%F(gBmk&t1C^KNlu$`~%7 z`y&#PGAtRkADfW!V-%;w>Wp}d$v7+F2?-5!j#tC~?y@I9KL*?So(!~X$ab)3Q1WcG807aiMXJT7d^ zPs=5|qTp3rB3IqFBc0A|1+U?fgx3|kfpb)i6xus?Mi;kjDif=n`X{JtpRs)CR4 ziGok@nS#$n^s2Igkaji{Q;m>m=wqQ|$_Q!3mbjYW5$d9xMrD;3L-Bk)9qBv8V>We) zD}+SlZvEynJeIOeYC3ON%%xQ>Xw#r-H<`L4>})&0jM8FWGUqB38`ato}nx+vw zchK%2?LGAGubu*{uDJovR}N+;J&WiY1y~Lricx?SxR-XNX*71>KHAYehm|G@cB3xM z>D@>-BvKR(`fgptiJF`6_DsQd9eI<;4@i@cCs8mBzX$W8LLpM_EL!FgU1Prleco+> zqDd^jf}=Ho;%Th#&_K)cj#p2>Gl_usyNQ)O;(rROZlGjdm19LI@m+_bb+wDyH|{W( z31(JS^DTl`m{fBc!MZ#_HGwt3ylJdun8rE}&D*wxr|Ug95zL$O*imqoqsvjdVP0)$ zR&BWl*U-9M0)%ksoW}pFwZg3>yB%X$dVeX#NY`9*NDMg9us);=u#|0yXhO AMF0Q* literal 0 HcmV?d00001 diff --git a/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthListeners.class b/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthListeners.class new file mode 100644 index 0000000000000000000000000000000000000000..d73ab0a8002c374cd52bebe223a1c49344a569ae GIT binary patch literal 4165 zcma)9X?Gjd8Gf!Tdt_-Gf?_*y7UB>V?`jK$64SJ?osfWJD{<^JX-hh`2Wety#?g!% zOcz2IppybC9qk-&$W@ezEq84u!Q6d!{j(Uh+sc1Vm}eVCuQeTQ9O#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mWEF(qNOq+!~AuUo}g|VQ;-D z)mzj}RBz0nYm#lu%{pg-OM=QHGD|sA97@P0Z0mH!m~mlNC`ig zMrb=%4p_F4D}Pl)UDKW^WA@gCsg$mP?!mfyCCHxIt~NL#g&Cu7Ql@9j7@omosR@qh z*ZA63Q9v}%^G=ysVnGWEX5REaxBTwJ1TyC4XoEt3ZS2Z{s0n9XXQX%P@a0&qgO7Ml zAYw(DlvUAwiSv--Ru3OyGQx`>902rnYmyM)F?gf9e(O`K}Wh$!BB&DCXMqrpy0VHvtST0*D; zY*<8GF!39fu`z^aDU;J1Q?m9t;){4pMpqFZ?O(oyKI~td zkMCH_8tnkz`J!xR=GP zu+R;gI}dZ`EC%p2v*jG)`8@OFMdrwPM*LMq`ZY%OUwA+MjeU3%L--HwQ@}wL!2>Fe zq}qv;>O@-g;;`z>`ZlY7dU9F`Q6oJg6pdQk{n3=g$#DsN*E1?PXrQNoF6w2hm9V z^OQb>21>R3-3Ff9=I@3jm&n7dN(f)YP5_%WW9vs~qfR@o0!m(;(wn}Zlq|F)D zR+iB^MGwqkoUxD!>mi4`>6as1k@`DYww$A3{`migyv2VZh~*Kew=hm4ee;@p^XM>4 zV6tS_<9v&x0ov7Hva3SQudbDh2kID02LKAx>tQR3=*JnKX=fm{!f$~5j`{q$SMuv$ M&F@2$8N%`Z1LNCvZU6uP literal 0 HcmV?d00001 diff --git a/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil$1.class b/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil$1.class new file mode 100644 index 0000000000000000000000000000000000000000..023caf5878f3377346362abc898d2c32541ff234 GIT binary patch literal 932 zcma)5+iuf95Iq}*gc{R?P$-mJp@F6;;8fzRC=ZmPR+x(@RJ?ASC0@E&SN1wm`75ME zARhPtJ_<3riPTC66ic4*?97~*GduqE`^QfJPtaOG1-GoYZN(iQRjm5BfxA`Qt7478 zA92+@R{TU{3@cHZ4Z>b=bR zCiQ^ADkhP6v%|0v#py8oBJzZ5o+~~Kd2D2=6Ty{9!ab)x7^!U1Q>mrtGJI^!o%Qct z|88sJkfFSj_65<1q!zD>VNYc5c~8+vBT8eg4tXZ6Jv%I08Vtd{)*{1h^RBJQf1@ zxDa3w%K_F=qxsG`-sTp=+L?RJ<3#ieC9?3DyXbd?*3&_(&xuHEa-sWE5)9qef3D(8 z;n_k(azr$D-F9t1ceCMfEOJ_!P6w;Brd8TquU@yT0n$X=X&ME2O7t$G28KF)?U7w3 zz0}^EfVCe^P-;J#z-xa)`Kyb*M6yEBz&;uzuR4S!T*ei$DASIZ{ER%yGt@3Tmr-wz w33N=DV|d?j?iA5?C@-mx$e{+)_!+8)YlK|Fb*zvs(+_u(>VTNgu9K$c4_&qAT>t<8 literal 0 HcmV?d00001 diff --git a/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil.class b/out/production/ActionHealth/com/zeshanaslam/actionhealth/HealthUtil.class new file mode 100644 index 0000000000000000000000000000000000000000..047182ee5d2ae93dc1dac3ef93f55a72dbba2e57 GIT binary patch literal 7032 zcmbVQ349#YdH;WVXl7?ehb7r)Z7{|d>$KK4){6L&Y%GvugN#8*LpxrLq_y{AcGlQ9 zlpgd-ozj*Ta7ai>+c-_>feW$?NlIH<(xfGAXj*zDy^l1#(>5g`>i^B`F|uWuU-h%! zzWLtwzWbW_?6+R}G=Qyg#K0l^l!2{yHpbmg$MG}xS+#sjE$3qRIDRgMPvGYbJcnOU zyI(Z$OZa8AJg?!rg8Yh(7YsDwMICeM_kxa#Ixea0OFCX|*u9Rd_@^j-Qp2YVti-cw z`Lw$It7`X(+WneZeqAlUq2W~nYw??E`7OozH65Q(C%>)Zvj#Tfb87h=9lxvNbse8q zN57}z_jP52n3c&768*MJKI85btnYdU_}xbYk)gtrEodIi#iBE@2XXHrna zHgQu_o2_curbsIgl@3jFlL!!~^4OoTvx-HiNGhS6x?`UdEDxaWJDIkND!PfL)+xs&r-J0uk`_*L=CAcOIv!>y0Ofa@h5eb9W(RAUtf!b<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sgt7{G2y=?T5H zIT4*hi??0YeG#qIhqjJ}z*GAimY>DvTUVrFEyi}EqoJLn|3JKZps}N&`^mF-Uw6}! zPvZpnCj=ivF1)>Yd2@^LECxFoJK{4DV*uOZw49te7e!rDLseAYq{8irGZn7!zUeGhC-hY8Wvrd- z=}p8g;AVAZ%wgTV=jiF)gnj{{{2ccD`~+^{z5_Zx-Yvr_T#p;D4r{Q3(KF7EcGG-v zi1RSk?>sp#hJIB$fpP9Cc8)hSb!um(8Nha9Qs$kS$NG`>x9h3BE6K|?`9QNsga4GuG> zZNof?n+w4_;y($8$#TbAh<1JxA$bcu^ORb<0u|_Nph$dS_fspflZ+dgpBr1&_g%y- zW0eqTT_23SPCm4D`Eha)-Qyd2=g^aiRB`!Kk5dn~uZEjyxH{H`I+j+8wf?hs>FQUK z^(*?-u{PGRVvOfakxyasWVp3)Vh&qUMk1Cl5;|d9C&N`5+jv6>-MZbsO3Yi8j`2i8 z)VrLBO-x44V+Rig2;tR4oDi0m6hVWk0zF=NUg*s58{Vuiz0c>5nnl!A79*sgJ3)g#~?*Mf?$l{22!Ld8XH!Os22E zlIw6(b|WoAn34=^ChD|&0yFXkj>(sCT)v8|d>y%vARk(RLZ}lCITb^_cp#Ky^s2`3 zCAN<9_z{$Gf-(FilkP$8Vx)frCvge}xpd53h=!l5?3ok$=WsiJ4vet}^6UNhhD*3Z za27q>+$nekqp3)(42&fra~QvbgCSx>BhQ_iegb&BQw$MHCKl&orR?tTJ4Nx5&t0G_~;lw4V;1rhUYBs4sw;cVYq z2({?!)lXOS+ehy78nm9?zDmFI=b8p0sOd(rT;rqQLzQ_(!-xHTKr=t%IW~lk5HEy} NQd~9f2s@(p_kYh)RXhLy literal 0 HcmV?d00001 diff --git a/out/production/ActionHealth/com/zeshanaslam/actionhealth/Main.class b/out/production/ActionHealth/com/zeshanaslam/actionhealth/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..5f91e20f670c6933ca4219ba9267ebc4eea6329c GIT binary patch literal 2149 zcma)8ZC4vb6n-W|Hd(d;sZd*6p^ZWam9@T9Y7lvCX$`fS0^<9SESqUIyL5Mh)>D6o zKf@1z$T=QA`#1VGdOY5{n?Qn`w1>m&%)QUO^V~ak?&P0;|NINU2k>=VMM1-ijsyy6 zjN%iWhFJ}t>gdHBOXf8!=t#$lMGZ?SEbB0En}<6LU+KeL+|%%xjtu7dP{e8q_gV9~ zh6g$>U{1#u_)a&G13!7bQ@PWSe&vDFu$9~L5!9w{JvJk)&02G-QLCxY z+&G0NAA0P4EmV%cM0W-&5fO%xVQ=W!wqp^C;v=~$%?63hq6$LNrAx|oW!UgZeeINb zrft2pc6X^T%g$z$tHN1C@5?8g5d%3)82E-dR@8|4UY`e;Ap5*fu0nt0T-Tu9XxI_d)YcS z@D|<{xZ0HhpCn;C-)>!(IA>;*$$NCftxGl-$X#p6+LjF`T=d*+MIn#nUZVWCwuf?Y zy*bjg%~I%73n;L>w_d9#pX!*d0JVp-ZG|Pv-{rhKpus}s%UX$#yu zD<$prbZ%T1X3V*1N1R97IG>3T=%Y5f{IgYVgdSybyn}Jer0K8)iwL&ob|LDX)Q?mU zGl)9~-H$U5vw3T4XdJ)|yhmSw_m6!&BMf7I z&F|wC^3}UZPPILxXrAV|zK6ae7@L`M2h>O>_tC#W(1Ak?3LGKBkn{ONyw-z!W@sP7 zN4UVU*Y|Pp4_u01nKuq`If37BDSvFrvMUMvjW_o&!o+*P#PdWQ7$#B|iSA|k8=($4 zN-4-EnPWNyEtyC)w(a R1UK3;C5|(7i=YX7{2#DQK}7%n literal 0 HcmV?d00001 diff --git a/out/production/ActionHealth/com/zeshanaslam/actionhealth/SettingsManager.class b/out/production/ActionHealth/com/zeshanaslam/actionhealth/SettingsManager.class new file mode 100644 index 0000000000000000000000000000000000000000..17bf4d276c566b4ed76cf19b64a0d18f4c845c64 GIT binary patch literal 3218 zcmb7G`EwM<75)Y-%xKl11F($~+l#>1RR<5J5h4;!?4TxKTEIyM zr-Yt%a7O4m9K2KLyBxe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+T zw;7YQ#F1AZw>Z>I28|5G7>gVw}}eAn1dAk?&TE jjR_mtrcX4t getKeys() { + return this.yaml.getKeys(false); + } + + /** + * Gets a boolean at the given path. + * + * @param s Path to the boolean. + * @return Boolean at the given path. + */ + public boolean getBoolean(String s) { + return this.yaml.getBoolean(s); + } + + /** + * If the given path has no variable, it will be given a variable. + * + * @param s Path to look for. + * @param o Variable to be assigned if not existing. + */ + public void add(String s, Object o) { + if (!this.contains(s)) { + this.set(s, o); + } + + } + + /** + * Adds a String to a List of Strings. + * + * @param s Path to given String List. + * @param o String to add to the String List. + */ + public void addToStringList(String s, String o) { + this.yaml.getStringList(s).add(o); + } + + /** + * Removes a String to a List of Strings. + * + * @param s Path to given String List. + * @param o String to remove from the String List. + */ + public void removeFromStringList(String s, String o) { + this.yaml.getStringList(s).remove(o); + } + + /** + * Looks for a String List at given Path. + * + * @param s Path to String List. + * @return String List at given Path. + */ + public java.util.List getStringList(String s) { + return this.yaml.getStringList(s); + } + + /** + * Adds an Integer to a List of Integers. + * + * @param s Path to given Integer List. + * @param o Integer to add to the Integer List. + */ + public void addToIntegerList(String s, int o) { + this.yaml.getIntegerList(s).add(o); + } + + /** + * Removes an Integer to a List of Integers. + * + * @param s Path to given Integer List. + * @param o Integer to remove to the Integer List. + */ + public void removeFromIntegerList(String s, int o) { + this.yaml.getIntegerList(s).remove(o); + } + + /** + * Looks for a Integer List at given Path. + * + * @param s Path to Integer List. + * @return Integer List at given Path. + */ + public java.util.List getIntegerList(String s) { + return this.yaml.getIntegerList(s); + } + + /** + * Creates a new String List at given Path. + * + * @param s Path to create String List at. + * @param list List to add. + */ + public void createNewStringList(String s, java.util.List list) { + this.yaml.set(s, list); + } + + /** + * Creates a new Integer List at given Path. + * + * @param s Path to create Integer List at. + * @param list List to add. + */ + public void createNewIntegerList(String s, java.util.List list) { + this.yaml.set(s, list); + } + + /** + * **Untested/Unstable** Attempts to remove a variable at the given Path. + * + * @param s Path to given variable needing removal. + */ + public void remove(String s) { + this.set(s, null); + } + + /** + * Returns true if the given Path has a value. + * + * @param s Path to value. + * @return True if the given Path has a value. + */ + public boolean contains(String s) { + return this.yaml.contains(s); + } + + /** + * Gets a double at the given Path. + * + * @param s Path to double. + * @return Double at given Path. + */ + public double getDouble(String s) { + return this.yaml.getDouble(s); + } + + /** + * Sets a Object to the given Path. + * + * @param s Path to variable being assigned. + * @param o Variable being assigned. + */ + public void set(String s, Object o) { + this.yaml.set(s, o); + } + + /** + * Increases an Integer by 1. + * + * @param s Path to Integer being incremented. + */ + public void increment(String s) { + this.yaml.set(s, this.getInteger(s) + 1); + } + + /** + * Decreases an Integer by 1. + * + * @param s Path to Integer being decremented. + */ + public void decrement(String s) { + this.yaml.set(s, this.getInteger(s) - 1); + } + + /** + * Increases an Integer by i. + * + * @param s Path to Integer being incremented. + */ + public void increment(String s, int i) { + this.yaml.set(s, this.getInteger(s) + i); + } + + /** + * Decreases an Integer by 1. + * + * @param s Path to Integer being decremented. + */ + public void decrement(String s, int i) { + this.yaml.set(s, this.getInteger(s) - i); + } + + + /** + * Gets Itemstack. + * + * @param s Path to Itemstack. + */ + public ItemStack getItemStack(String s) { + return this.yaml.getItemStack(s); + } + + /** + * Returns the YamlConfiguration's Options. + * + * @return YamlConfiguration's Options. + */ + public YamlConfigurationOptions options() { + return this.yaml.options(); + } +} \ No newline at end of file diff --git a/src/com/zeshanaslam/actionhealth/HealthCommand.java b/src/com/zeshanaslam/actionhealth/HealthCommand.java new file mode 100644 index 0000000..6ec7d09 --- /dev/null +++ b/src/com/zeshanaslam/actionhealth/HealthCommand.java @@ -0,0 +1,70 @@ +package com.zeshanaslam.actionhealth; + +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.io.File; + +public class HealthCommand implements CommandExecutor { + + private final Main plugin; + + public HealthCommand(Main plugin) { + this.plugin = plugin; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (args.length <= 0) { + sender.sendMessage(ChatColor.RED + "ActionHealth Commands:"); + sender.sendMessage(ChatColor.GRAY + "/ActionHealth reload"); + sender.sendMessage(ChatColor.GRAY + "/ActionHealth toggle"); + } else { + if (args[0].equalsIgnoreCase("reload")) { + if (!sender.hasPermission("ActionHealth.Reload")) { + return false; + } + + plugin.reloadConfig(); + plugin.settingsManager = new SettingsManager(plugin); + sender.sendMessage(ChatColor.RED + "ActionHealth " + ChatColor.GRAY + "has been reloaded!"); + return true; + } + + if (args[0].equalsIgnoreCase("toggle")) { + if (sender instanceof Player) { + Player player = (Player) sender; + + if (plugin.toggle.contains(player.getUniqueId())) { + plugin.toggle.remove(player.getUniqueId()); + + player.sendMessage(ChatColor.GRAY + "ActionHealth has been " + ChatColor.RED + "enabled" + ChatColor.GRAY + "."); + } else { + plugin.toggle.add(player.getUniqueId()); + + player.sendMessage(ChatColor.GRAY + "ActionHealth has been " + ChatColor.RED + "disabled" + ChatColor.GRAY + "."); + } + + if (plugin.settingsManager.rememberToggle) { + FileHandler fileHandler = new FileHandler("plugins/ActionHealth/players/" + player.getUniqueId() + ".yml"); + fileHandler.set("toggle", plugin.toggle.contains(player.getUniqueId())); + + fileHandler.save(); + } + } else { + sender.sendMessage("ActionHealth toggle can only run in-game."); + } + return true; + } + + sender.sendMessage(ChatColor.RED + "ActionHealth Commands:"); + sender.sendMessage(ChatColor.GRAY + "/ActionHealth reload"); + sender.sendMessage(ChatColor.GRAY + "/ActionHealth toggle"); + } + + return true; + } +} diff --git a/src/com/zeshanaslam/actionhealth/HealthListeners.java b/src/com/zeshanaslam/actionhealth/HealthListeners.java new file mode 100644 index 0000000..208c6dc --- /dev/null +++ b/src/com/zeshanaslam/actionhealth/HealthListeners.java @@ -0,0 +1,120 @@ +package com.zeshanaslam.actionhealth; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +public class HealthListeners implements Listener { + + private Main plugin; + + public HealthListeners(Main plugin) { + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onDamage(EntityDamageByEntityEvent event) { + if (plugin.settingsManager.checkPvP && event.isCancelled()) { + return; + } + + if (plugin.healthUtil.isDisabled(event.getDamager().getLocation())) { + return; + } + + if (plugin.settingsManager.worlds.contains(event.getDamager().getWorld().getName())) { + return; + } + + if (plugin.settingsManager.usePerms && !event.getDamager().hasPermission("ActionHealth.Health")) { + return; + } + + + Entity damaged = event.getEntity(); + + if (event.getDamager() instanceof Projectile) { + Projectile projectile = (Projectile) event.getDamager(); + + if (projectile.getShooter() instanceof Player) { + Player player = (Player) projectile.getShooter(); + + // Check if the setting 'Show Player' is enabled + if (event.getEntity() instanceof Player) { + if (!plugin.settingsManager.showPlayers) { + return; + } + } + + if (!plugin.settingsManager.showMobs) { + return; + } + + if (plugin.toggle.contains(player.getUniqueId())) { + return; + } + + // Send health + LivingEntity livingEntity = (LivingEntity) damaged; + plugin.healthUtil.sendHealth(player, (LivingEntity) damaged, livingEntity.getHealth() - event.getFinalDamage()); + + } + } + + if (event.getDamager() instanceof Player) { + Player player = (Player) event.getDamager(); + + // Check if the setting 'Show Player' is enabled + if (event.getEntity() instanceof Player) { + if (!plugin.settingsManager.showPlayers) { + return; + } + + if (player.hasMetadata("NPC")) { + return; + } + } + + if (!plugin.settingsManager.showMobs) { + return; + } + + if (plugin.toggle.contains(player.getUniqueId())) { + return; + } + + // Send health + LivingEntity livingEntity = (LivingEntity) damaged; + plugin.healthUtil.sendHealth(player, (LivingEntity) damaged, livingEntity.getHealth() - event.getFinalDamage()); + } + } + + @EventHandler + public void onJoin(PlayerJoinEvent event) { + Player player = event.getPlayer(); + + if (plugin.settingsManager.rememberToggle) { + FileHandler fileHandler = new FileHandler("plugins/ActionHealth/players/" + player.getUniqueId() + ".yml"); + + if (fileHandler.getBoolean("toggle")) { + plugin.toggle.add(player.getUniqueId()); + } + } + } + + @EventHandler + public void onLeave(PlayerQuitEvent event) { + Player player = event.getPlayer(); + + if (plugin.toggle.contains(player.getUniqueId())) { + plugin.toggle.remove(player.getUniqueId()); + } + } +} diff --git a/src/com/zeshanaslam/actionhealth/HealthUtil.java b/src/com/zeshanaslam/actionhealth/HealthUtil.java index 123a4f5..23720ba 100644 --- a/src/com/zeshanaslam/actionhealth/HealthUtil.java +++ b/src/com/zeshanaslam/actionhealth/HealthUtil.java @@ -1,7 +1,12 @@ package com.zeshanaslam.actionhealth; +import com.sk89q.worldguard.protection.ApplicableRegionSet; +import com.sk89q.worldguard.protection.regions.ProtectedRegion; import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -14,11 +19,68 @@ public class HealthUtil { this.plugin = plugin; } - private void sendActionBar(Player player, String message) { - if (player.hasMetadata("NPC")) { - return; + public void sendHealth(Player player, LivingEntity entity, double health) { + String name; + double maxHealth = entity.getMaxHealth(); + + if (entity.getCustomName() == null) { + name = entity.getName(); + } else { + name = entity.getCustomName(); } + if (plugin.settingsManager.stripName) name = ChatColor.stripColor(name); + if (plugin.settingsManager.translate.containsKey(entity.getName())) + name = plugin.settingsManager.translate.get(entity.getName()); + + String output = plugin.settingsManager.healthMessage; + output = output.replace("{name}", name); + output = output.replace("{health}", String.valueOf(health)); + output = output.replace("{maxhealth}", String.valueOf(maxHealth)); + + if (output.contains("{usestyle}")) { + String style = ""; + int left = 10; + double heart = maxHealth / 10; + double tempHealth = health; + + if (maxHealth != health && health >= 0 && !entity.isDead()) { + for (int i = 0; i < 10; i++) { + if (tempHealth - heart > 0) { + tempHealth = tempHealth - heart; + + style = style + plugin.settingsManager.filledHeartIcon; + left--; + } + } + + if (tempHealth >= 0) { + style = style + plugin.settingsManager.halfHeartIcon; + left--; + } + } + + for (int i = 0; i < left; i++) { + style = style + plugin.settingsManager.emptyHeartIcon; + } + + output = output.replace("{usestyle}", style); + } + + if (plugin.settingsManager.delay) { + String finalOutput = output; + + new BukkitRunnable() { + public void run() { + sendActionBar(player, finalOutput); + } + }.runTaskLater(plugin, 1L); + } else { + sendActionBar(player, output); + } + } + + private void sendActionBar(Player player, String message) { message = ChatColor.translateAlternateColorCodes('&', message); try { @@ -51,4 +113,19 @@ public class HealthUtil { ex.printStackTrace(); } } + + public boolean isDisabled(Location location) { + if (plugin.worldGuardPlugin == null) { + return false; + } + + ApplicableRegionSet applicableRegions = plugin.worldGuardPlugin.getRegionManager(location.getWorld()).getApplicableRegions(location); + for (ProtectedRegion region : applicableRegions) { + if (plugin.settingsManager.regions.contains(region.getId())) { + return true; + } + } + + return false; + } } diff --git a/src/com/zeshanaslam/actionhealth/Main.java b/src/com/zeshanaslam/actionhealth/Main.java index 32700c8..9c9e978 100644 --- a/src/com/zeshanaslam/actionhealth/Main.java +++ b/src/com/zeshanaslam/actionhealth/Main.java @@ -1,20 +1,46 @@ package com.zeshanaslam.actionhealth; +import com.sk89q.worldguard.bukkit.WorldGuardPlugin; +import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + public class Main extends JavaPlugin { public SettingsManager settingsManager; + public WorldGuardPlugin worldGuardPlugin; + public HealthUtil healthUtil; + + public List toggle = new ArrayList<>(); @Override - public void onEnable() - { + public void onEnable() { saveDefaultConfig(); + // Register health util + this.healthUtil = new HealthUtil(this); + // Load config settings settingsManager = new SettingsManager(this); + // Create player folder + File file = new File("plugins/ActionHealth/players/"); + file.mkdirs(); + // Register listeners + getServer().getPluginManager().registerEvents(new HealthListeners(this), this); + + + // Register command + getCommand("Actionhealth").setExecutor(new HealthCommand(this)); + + if (Bukkit.getServer().getPluginManager().isPluginEnabled("WorldGuard")) { + this.worldGuardPlugin = ((WorldGuardPlugin) getServer().getPluginManager().getPlugin("WorldGuard")); + } } @Override diff --git a/src/com/zeshanaslam/actionhealth/SettingsManager.java b/src/com/zeshanaslam/actionhealth/SettingsManager.java index af4f36b..0261fe5 100644 --- a/src/com/zeshanaslam/actionhealth/SettingsManager.java +++ b/src/com/zeshanaslam/actionhealth/SettingsManager.java @@ -5,6 +5,7 @@ import org.bukkit.Bukkit; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.UUID; public class SettingsManager { @@ -16,11 +17,13 @@ public class SettingsManager { public boolean checkPvP; public boolean limitHealth; public boolean stripName; + public boolean rememberToggle; public String filledHeartIcon; public String halfHeartIcon; public String emptyHeartIcon; public List worlds = new ArrayList<>(); public HashMap translate = new HashMap<>(); + public List regions = new ArrayList<>(); public String mcVersion; public boolean useOldMethods; @@ -38,13 +41,15 @@ public class SettingsManager { halfHeartIcon = plugin.getConfig().getString("Half Health Icon"); emptyHeartIcon = plugin.getConfig().getString("Empty Health Icon"); if (plugin.getConfig().getBoolean("Name Change")) { - for (String s : plugin.getConfig().getStringList("Name")) - { + for (String s : plugin.getConfig().getStringList("Name")) { String[] split = s.split(" = "); translate.put(split[0], split[1]); } } + // Load disabled regions + regions = plugin.getConfig().getStringList("Disabled regions"); + worlds = plugin.getConfig().getStringList("Disabled worlds"); // Check if using protocol build @@ -52,5 +57,11 @@ public class SettingsManager { mcVersion = mcVersion.substring(mcVersion.lastIndexOf(".") + 1); useOldMethods = mcVersion.equalsIgnoreCase("v1_8_R1") || mcVersion.equalsIgnoreCase("v1_7_"); + + if (plugin.getConfig().contains("Remember Toggle")) { + rememberToggle = plugin.getConfig().getBoolean("Remember Toggle"); + } else { + rememberToggle = false; + } } }