ChorusLimiter

This commit is contained in:
Erik Bročko 2018-09-13 22:54:37 +02:00
parent 4a2f9dd496
commit e103195300
2 changed files with 32 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import cz.marwland.mc.core.features.Base;
import cz.marwland.mc.core.features.Feature; import cz.marwland.mc.core.features.Feature;
import cz.marwland.mc.essentials.features.Borders; import cz.marwland.mc.essentials.features.Borders;
import cz.marwland.mc.essentials.features.ChatNotifier; import cz.marwland.mc.essentials.features.ChatNotifier;
import cz.marwland.mc.essentials.features.ChorusLimiter;
import cz.marwland.mc.essentials.features.RandomTeleport; import cz.marwland.mc.essentials.features.RandomTeleport;
public class MarwCore extends JavaPlugin { public class MarwCore extends JavaPlugin {
@ -27,6 +28,7 @@ public class MarwCore extends JavaPlugin {
this.addFeature(new Base()); this.addFeature(new Base());
this.addFeature(new Borders()); this.addFeature(new Borders());
this.addFeature(new ChatNotifier()); this.addFeature(new ChatNotifier());
this.addFeature(new ChorusLimiter());
this.addFeature(new RandomTeleport()); this.addFeature(new RandomTeleport());
configManager.load(); configManager.load();

View File

@ -0,0 +1,30 @@
package cz.marwland.mc.essentials.features;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import com.connorlinfoot.bountifulapi.BountifulAPI;
import cz.marwland.mc.core.features.Feature;
import cz.marwland.mc.core.util.Cooldown;
import net.md_5.bungee.api.ChatColor;
public class ChorusLimiter extends Feature {
private Cooldown chorusCooldown = new Cooldown(this);
@EventHandler
public void onPlayerItemConsume(PlayerItemConsumeEvent e) {
if (e.getItem().getType() != Material.CHORUS_FRUIT)
return;
long left = chorusCooldown.timeLeftSeconds(e.getPlayer());
if (left > 0) {
BountifulAPI.sendActionBar(e.getPlayer(), ChatColor.RED + "Musis pockat jeste " + left + " sekund pro pouziti Chrois Fruitu!");
e.setCancelled(true);
return;
}
}
}