From 38d59884a22e3d4f13c7617e1b7024f19bf36e84 Mon Sep 17 00:00:00 2001 From: Boos Date: Sun, 19 Aug 2012 21:21:28 +0200 Subject: [PATCH] Added possibility to charge players for using ChatManager globachat. --- .../boosCooldown/boosCoolDownListener.java | 41 ++++++++++++++----- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/src/cz/boosik/boosCooldown/boosCoolDownListener.java b/src/cz/boosik/boosCooldown/boosCoolDownListener.java index f84381b..ecda2c8 100644 --- a/src/cz/boosik/boosCooldown/boosCoolDownListener.java +++ b/src/cz/boosik/boosCooldown/boosCoolDownListener.java @@ -330,7 +330,7 @@ public class boosCoolDownListener implements Listener { } } if (!event.isCancelled()) { - payForCommand(event, player, pre, message, price); + payForCommand(event, player, pre, price); } } else { event.setCancelled(true); @@ -346,8 +346,27 @@ public class boosCoolDownListener implements Listener { } } - private void payForCommand(PlayerCommandPreprocessEvent event, - Player player, String pre, String message, int price) { + public void payForCommand(PlayerCommandPreprocessEvent event, + Player player, String pre, int price) { + String name = player.getName(); + if (price > 0) { + if (!player.hasPermission( + "booscooldowns.noprice") + && !player.hasPermission( + "booscooldowns.noprice." + pre)) { + if (boosPriceManager.payForCommand(player, pre, price, name)) { + return; + } else { + boosCoolDownManager.cancelCooldown(player, pre); + event.setCancelled(true); + return; + } + } + } + } + + public void payForCommand2(AsyncPlayerChatEvent event, + Player player, String pre, int price) { String name = player.getName(); if (price > 0) { if (!player.hasPermission( @@ -597,20 +616,22 @@ public class boosCoolDownListener implements Listener { @EventHandler(priority = EventPriority.LOW) public void onPlayerChat(AsyncPlayerChatEvent event) { String chatMessage = event.getMessage(); + String temp = "globalchat"; + int price = 0; + Player player = event.getPlayer(); if (chatMessage.startsWith("!")) { - String temp = "globalchat"; - if (!boosCoolDownManager.checkCoolDownOK(event.getPlayer(), temp, + if (!boosCoolDownManager.checkCoolDownOK(player, temp, chatMessage)) { event.setCancelled(true); return; } else { - if (boosCoolDownManager.coolDown(event.getPlayer(), temp)) { + if (boosCoolDownManager.coolDown(player, temp)) { event.setCancelled(true); return; - } else { - return; } } + price = prePriceCheck(player, temp); + payForCommand2(event, player, temp, price); + } } - } -} \ No newline at end of file + } \ No newline at end of file