22
33import org .bukkit .Bukkit ;
44import org .bukkit .Location ;
5- import org .bukkit .Material ;
65import org .bukkit .entity .Item ;
76import org .bukkit .entity .Player ;
87import org .bukkit .event .EventHandler ;
@@ -21,7 +20,6 @@ public class PlayerFishEventListener implements Listener {
2120 @ EventHandler
2221 public void onFish (PlayerFishEvent e ) {
2322 Player player = e .getPlayer ();
24-
2523 if (!(e .getState ().equals (PlayerFishEvent .State .CAUGHT_FISH ))) return ;
2624 if (!(e .getCaught () instanceof Item )) return ;
2725
@@ -47,36 +45,38 @@ public void run() {
4745 return ;
4846 }
4947
50- Item caught = (Item ) e .getCaught ();
48+ Bukkit .getScheduler ().runTask (PLUGIN , () -> {
49+ Item caught = (Item ) e .getCaught ();
5150
52- if (PLUGIN .getBlacklistConf ().contains ("BlacklistedFishing" , true )) {
53- boolean doBlacklist = PLUGIN .getBlacklistConf ().getBoolean ("BlacklistedFishing" );
54- List <String > blacklist = PLUGIN .getBlacklistConf ().getStringList ("BlacklistedFishing" );
51+ if (PLUGIN .getBlacklistConf ().contains ("BlacklistedFishing" , true )) {
52+ boolean doBlacklist = PLUGIN .getBlacklistConf ().getBoolean ("BlacklistedFishing" );
53+ List <String > blacklist = PLUGIN .getBlacklistConf ().getStringList ("BlacklistedFishing" );
5554
56- if (doBlacklist && blacklist .contains (caught .getItemStack ().getType ().toString ())) {
57- return ;
55+ if (doBlacklist && blacklist .contains (caught .getItemStack ().getType ().toString ())) {
56+ return ;
57+ }
5858 }
59- }
6059
61- HashMap <Integer , ItemStack > leftOver = player .getInventory ().addItem (caught .getItemStack ());
62- caught .setItemStack (new ItemStack (Material .AIR ));
63- if (!leftOver .isEmpty ()) {
64- for (ItemStack item : leftOver .values ()) {
65- player .getWorld ().dropItemNaturally (loc , item );
66- }
67- if (doFullInvMSG ) {
68- long secondsLeft ;
69- long cooldown = 15000 ; // 15 sec
70- if (AutoPickup .lastInvFullNotification .containsKey (player .getUniqueId ())) {
71- secondsLeft = (AutoPickup .lastInvFullNotification .get (player .getUniqueId ())/1000 )+ cooldown /1000 - (System .currentTimeMillis ()/1000 );
72- } else {
73- secondsLeft = 0 ;
60+ HashMap <Integer , ItemStack > leftOver = player .getInventory ().addItem (caught .getItemStack ());
61+ caught .remove ();
62+ if (!leftOver .isEmpty ()) {
63+ for (ItemStack item : leftOver .values ()) {
64+ player .getWorld ().dropItemNaturally (loc , item );
7465 }
75- if (secondsLeft <=0 ) {
76- player .sendMessage (PLUGIN .getMsg ().getPrefix () + " " + PLUGIN .getMsg ().getFullInventory ());
77- AutoPickup .lastInvFullNotification .put (player .getUniqueId (), System .currentTimeMillis ());
66+ if (doFullInvMSG ) {
67+ long secondsLeft ;
68+ long cooldown = 15000 ; // 15 sec
69+ if (AutoPickup .lastInvFullNotification .containsKey (player .getUniqueId ())) {
70+ secondsLeft = (AutoPickup .lastInvFullNotification .get (player .getUniqueId ()) / 1000 ) + cooldown / 1000 - (System .currentTimeMillis () / 1000 );
71+ } else {
72+ secondsLeft = 0 ;
73+ }
74+ if (secondsLeft <= 0 ) {
75+ player .sendMessage (PLUGIN .getMsg ().getPrefix () + " " + PLUGIN .getMsg ().getFullInventory ());
76+ AutoPickup .lastInvFullNotification .put (player .getUniqueId (), System .currentTimeMillis ());
77+ }
7878 }
7979 }
80- }
80+ });
8181 }
8282}
0 commit comments