Attempts to resolve FS-311 and mitigates FS-396

This commit is contained in:
Video
2022-11-13 20:53:50 -07:00
parent 3d67c83ea4
commit 94d6f0a872
3 changed files with 58 additions and 27 deletions

View File

@ -21,6 +21,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
@ -411,6 +412,25 @@ public class Shop extends FreedomService
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
String message = event.getMessage();
Player player = event.getPlayer();
if (ConfigEntry.SHOP_ENABLED.getBoolean() && ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean()
&& !plugin.sh.reactionString.isEmpty() && message.equals(plugin.sh.reactionString))
{
event.setCancelled(true);
PlayerData data = plugin.pl.getData(player);
data.setCoins(data.getCoins() + plugin.sh.coinsPerReactionWin);
plugin.pl.save(data);
plugin.sh.endReaction(player.getName());
player.sendMessage(ChatColor.GREEN + "You have been given " + ChatColor.GOLD
+ plugin.sh.coinsPerReactionWin + ChatColor.GREEN + " coins!");
}
}
public ShopItem getShopItem(int slot)
{
for (ShopItem shopItem : ShopItem.values())