Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.Ahmet094.DrugsFTW;
- import org.bukkit.event.block.*;
- import org.bukkit.potion.*;
- import org.bukkit.inventory.*;
- import org.bukkit.entity.*;
- import org.bukkit.event.*;
- import org.bukkit.event.entity.*;
- import org.bukkit.event.player.*;
- import org.bukkit.*;
- public class DrugsListener implements Listener
- {
- private DrugsFTW plugin;
- public DrugsListener(final DrugsFTW instance) {
- this.plugin = instance;
- }
- @EventHandler
- public void DrogenNehmen(final PlayerInteractEvent event) {
- final Player spieler = event.getPlayer();
- final ItemStack item = spieler.getItemInHand();
- final int duration = this.plugin.getConfig().getInt("options.EffectDuration") * 20;
- final String prefix = this.plugin.getConfig().getString("messages.ChatPrefix").replaceAll("&", "§");
- final int amountNeeded = this.plugin.getConfig().getInt("options.amountNeeded");
- if (spieler.hasPermission("drugsftw.takeDrugs") || spieler.isOp()) {
- final Action action = event.getAction();
- event.getAction();
- if (action == Action.RIGHT_CLICK_AIR && item.getType() == Material.RED_MUSHROOM && item.getAmount() >= amountNeeded) {
- if (spieler.hasPotionEffect(PotionEffectType.CONFUSION)) {
- spieler.sendMessage(prefix + this.plugin.getConfig().getString("messages.MyselfAlreadyOnDrugs").replaceAll("&", "§"));
- }
- else {
- spieler.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, duration, 3));
- if (item.getAmount() == amountNeeded) {
- spieler.setItemInHand((ItemStack)null);
- spieler.sendMessage(prefix + this.plugin.getConfig().getString("messages.MyselfNowOnDrugs").replaceAll("&", "§"));
- }
- else {
- item.setAmount(item.getAmount() - amountNeeded);
- spieler.sendMessage(prefix + this.plugin.getConfig().getString("messages.MyselfNowOnDrugs").replaceAll("&", "§"));
- }
- }
- }
- final Action action2 = event.getAction();
- event.getAction();
- if (action2 == Action.RIGHT_CLICK_AIR && item.getType() == Material.SUGAR && item.getAmount() >= amountNeeded) {
- if (spieler.hasPotionEffect(PotionEffectType.BLINDNESS)) {
- spieler.sendMessage(prefix + this.plugin.getConfig().getString("messages.MyselfAlreadyOnDrugs").replaceAll("&", "§"));
- }
- else {
- spieler.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, duration, 5));
- if (item.getAmount() == amountNeeded) {
- spieler.setItemInHand((ItemStack)null);
- spieler.sendMessage(prefix + this.plugin.getConfig().getString("messages.MyselfNowOnDrugs").replaceAll("&", "§"));
- }
- else {
- item.setAmount(item.getAmount() - amountNeeded);
- spieler.sendMessage(prefix + this.plugin.getConfig().getString("messages.MyselfNowOnDrugs").replaceAll("&", "§"));
- }
- }
- }
- final Action action3 = event.getAction();
- event.getAction();
- if (action3 == Action.RIGHT_CLICK_AIR && item.getType() == Material.WHEAT && item.getAmount() >= amountNeeded && this.plugin.getConfig().getBoolean("options.enableWheat")) {
- if (spieler.hasPotionEffect(PotionEffectType.WEAKNESS)) {
- spieler.sendMessage(prefix + this.plugin.getConfig().getString("messages.MyselfAlreadyOnDrugs").replaceAll("&", "§"));
- }
- else {
- spieler.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, duration, amountNeeded));
- if (item.getAmount() == amountNeeded) {
- spieler.setItemInHand((ItemStack)null);
- spieler.sendMessage(prefix + this.plugin.getConfig().getString("messages.MyselfNowOnDrugs").replaceAll("&", "§"));
- }
- else {
- item.setAmount(item.getAmount() - amountNeeded);
- spieler.sendMessage(prefix + this.plugin.getConfig().getString("messages.MyselfNowOnDrugs").replaceAll("&", "§"));
- }
- }
- }
- final Action action4 = event.getAction();
- event.getAction();
- if (action4 == Action.RIGHT_CLICK_AIR && item.getType() == Material.BROWN_MUSHROOM && item.getAmount() >= amountNeeded) {
- if (spieler.hasPotionEffect(PotionEffectType.POISON)) {
- spieler.sendMessage(prefix + this.plugin.getConfig().getString("messages.MyselfAlreadyOnDrugs").replaceAll("&", "§"));
- }
- else {
- spieler.addPotionEffect(new PotionEffect(PotionEffectType.POISON, duration, amountNeeded));
- if (item.getAmount() == amountNeeded) {
- spieler.setItemInHand((ItemStack)null);
- spieler.sendMessage(prefix + this.plugin.getConfig().getString("messages.MyselfNowOnDrugs").replaceAll("&", "§"));
- }
- else {
- item.setAmount(item.getAmount() - amountNeeded);
- spieler.sendMessage(prefix + this.plugin.getConfig().getString("messages.MyselfNowOnDrugs").replaceAll("&", "§"));
- }
- }
- }
- final Action action5 = event.getAction();
- event.getAction();
- if (action5 == Action.RIGHT_CLICK_AIR && item.getType() == Material.SULPHUR && item.getAmount() >= amountNeeded) {
- if (spieler.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
- spieler.sendMessage(prefix + this.plugin.getConfig().getString("messages.MyselfAlreadyOnDrugs").replaceAll("&", "§"));
- }
- else {
- spieler.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, duration, amountNeeded));
- spieler.addPotionEffect(new PotionEffect(PotionEffectType.HUNGER, duration, amountNeeded));
- if (item.getAmount() == amountNeeded) {
- spieler.setItemInHand((ItemStack)null);
- spieler.sendMessage(prefix + this.plugin.getConfig().getString("messages.MyselfNowOnDrugs").replaceAll("&", "§"));
- }
- else {
- item.setAmount(item.getAmount() - amountNeeded);
- spieler.sendMessage(prefix + this.plugin.getConfig().getString("messages.MyselfNowOnDrugs").replaceAll("&", "§"));
- }
- }
- }
- }
- }
- @EventHandler
- public void OpferAufDrogenSetzen(final EntityDamageByEntityEvent event) {
- if (event.getEntity() instanceof Player && event.getDamager() instanceof Player) {
- final Player opfer = (Player)event.getEntity();
- final Player schlingel = (Player)event.getDamager();
- final ItemStack item = schlingel.getItemInHand();
- final int duration = this.plugin.getConfig().getInt("options.EffectDuration") * 20;
- final String prefix = this.plugin.getConfig().getString("messages.ChatPrefix").replaceAll("&", "§");
- final int amountNeeded = this.plugin.getConfig().getInt("options.amountNeeded");
- if (schlingel.hasPermission("drugsftw.setonDrugs") || schlingel.isOp()) {
- if (!opfer.hasPermission("drugsftw.immune") && item.getType() == Material.RED_MUSHROOM && item.getAmount() >= amountNeeded) {
- if (opfer.hasPotionEffect(PotionEffectType.CONFUSION)) {
- schlingel.sendMessage(prefix + this.plugin.getConfig().getString("messages.VictimAlreadyOnDrugs").replaceAll("&", "§").replaceAll("<target>", opfer.getDisplayName()));
- }
- else {
- opfer.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, duration, 1));
- opfer.sendMessage(prefix + this.plugin.getConfig().getString("messages.GotSetOnDrugs").replaceAll("&", "§").replaceAll("<player>", schlingel.getDisplayName()));
- schlingel.sendMessage(prefix + this.plugin.getConfig().getString("messages.VictimNowOnDrugs").replaceAll("&", "§").replaceAll("<target>", opfer.getDisplayName()));
- if (item.getAmount() == amountNeeded) {
- schlingel.setItemInHand((ItemStack)null);
- }
- else {
- item.setAmount(item.getAmount() - amountNeeded);
- }
- }
- }
- if (item.getType() == Material.SUGAR && item.getAmount() >= amountNeeded) {
- if (opfer.hasPotionEffect(PotionEffectType.BLINDNESS)) {
- schlingel.sendMessage(prefix + this.plugin.getConfig().getString("messages.VictimAlreadyOnDrugs").replaceAll("&", "§").replaceAll("<target>", opfer.getDisplayName()));
- }
- else {
- opfer.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, duration, 1));
- opfer.sendMessage(prefix + this.plugin.getConfig().getString("messages.GotSetOnDrugs").replaceAll("&", "§").replaceAll("<player>", schlingel.getDisplayName()));
- schlingel.sendMessage(prefix + this.plugin.getConfig().getString("messages.VictimNowOnDrugs").replaceAll("&", "§").replaceAll("<target>", opfer.getDisplayName()));
- if (item.getAmount() == amountNeeded) {
- schlingel.setItemInHand((ItemStack)null);
- }
- else {
- item.setAmount(item.getAmount() - amountNeeded);
- }
- }
- }
- if (item.getType() == Material.WHEAT && item.getAmount() >= amountNeeded) {
- if (opfer.hasPotionEffect(PotionEffectType.WEAKNESS)) {
- schlingel.sendMessage(prefix + this.plugin.getConfig().getString("messages.VictimAlreadyOnDrugs").replaceAll("&", "§").replaceAll("<target>", opfer.getDisplayName()));
- }
- else {
- opfer.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, duration, 1));
- opfer.sendMessage(prefix + this.plugin.getConfig().getString("messages.GotSetOnDrugs").replaceAll("&", "§").replaceAll("<player>", schlingel.getDisplayName()));
- schlingel.sendMessage(prefix + this.plugin.getConfig().getString("messages.VictimNowOnDrugs").replaceAll("&", "§").replaceAll("<target>", opfer.getDisplayName()));
- if (item.getAmount() == amountNeeded) {
- schlingel.setItemInHand((ItemStack)null);
- }
- else {
- item.setAmount(item.getAmount() - amountNeeded);
- }
- }
- }
- if (item.getType() == Material.BROWN_MUSHROOM && item.getAmount() >= amountNeeded) {
- if (opfer.hasPotionEffect(PotionEffectType.POISON)) {
- schlingel.sendMessage(prefix + this.plugin.getConfig().getString("messages.VictimAlreadyOnDrugs").replaceAll("&", "§").replaceAll("<target>", opfer.getDisplayName()));
- }
- else {
- opfer.addPotionEffect(new PotionEffect(PotionEffectType.POISON, duration, 1));
- opfer.sendMessage(prefix + this.plugin.getConfig().getString("messages.GotSetOnDrugs").replaceAll("&", "§").replaceAll("<player>", schlingel.getDisplayName()));
- schlingel.sendMessage(prefix + this.plugin.getConfig().getString("messages.VictimNowOnDrugs").replaceAll("&", "§").replaceAll("<target>", opfer.getDisplayName()));
- if (item.getAmount() == amountNeeded) {
- schlingel.setItemInHand((ItemStack)null);
- }
- else {
- item.setAmount(item.getAmount() - amountNeeded);
- }
- }
- }
- }
- }
- }
- @EventHandler
- public void onPlayerChat(final AsyncPlayerChatEvent event) {
- if (event.getPlayer().hasPermission("drugsftw.chatcolor")) {
- final String nachricht = ChatColor.translateAlternateColorCodes('&', event.getMessage());
- event.setMessage(nachricht);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement