commit b827bdd7593beea09c1e3dea07a8b1e623b97283
parent 8bf20c5402ea3141983b8064244ea401198a6867
Author: luca-luca <reisingerluca@gmail.com>
Date: Mon, 11 Jan 2021 16:02:24 +0100
Removed ChestLockListener
Added Snowball functionality
Added ArmorStand Arms functionality
Diffstat:
2 files changed, 47 insertions(+), 5 deletions(-)
diff --git a/src/de/typable/minecrafthub/Main.java b/src/de/typable/minecrafthub/Main.java
@@ -21,7 +21,6 @@ import org.bukkit.plugin.java.JavaPlugin;
import de.typable.minecrafthub.constant.DefaultConstants;
import de.typable.minecrafthub.event.AutoWorkbenchListener;
import de.typable.minecrafthub.event.ChairListener;
-import de.typable.minecrafthub.event.ChestLockListener;
import de.typable.minecrafthub.event.DoubleDoorListener;
import de.typable.minecrafthub.event.EventListener;
import de.typable.minecrafthub.event.StandbyListener;
@@ -35,7 +34,6 @@ public class Main extends JavaPlugin
private DoubleDoorListener doubleDoorListener;
private ChairListener chairListener;
private AutoWorkbenchListener autoWorkbenchListener;
- private ChestLockListener chestLockListener;
private EventListener eventListener;
private Plugin plugin;
@@ -58,9 +56,6 @@ public class Main extends JavaPlugin
autoWorkbenchListener = new AutoWorkbenchListener();
pluginManager.registerEvents(autoWorkbenchListener, this);
-
- chestLockListener = new ChestLockListener();
- pluginManager.registerEvents(chestLockListener, this);
eventListener = new EventListener();
pluginManager.registerEvents(eventListener, this);
diff --git a/src/de/typable/minecrafthub/event/EventListener.java b/src/de/typable/minecrafthub/event/EventListener.java
@@ -2,13 +2,20 @@ package de.typable.minecrafthub.event;
import org.bukkit.ChatColor;
import org.bukkit.Material;
+import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
+import org.bukkit.entity.Player;
+import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
+import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
+import org.bukkit.potion.PotionEffect;
+import org.bukkit.potion.PotionEffectType;
public class EventListener implements Listener
@@ -46,4 +53,44 @@ public class EventListener implements Listener
+ event.getMessage();
event.setFormat(format);
}
+
+ @EventHandler
+ public void onEntityHit(EntityDamageByEntityEvent event)
+ {
+ if(event.getDamager() instanceof Snowball)
+ {
+ Snowball snowball = (Snowball) event.getDamager();
+
+ if(snowball.getShooter() instanceof Player)
+ {
+ Player player = (Player) event.getEntity();
+
+ player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20 * 2, 1));
+
+ event.setDamage(1);
+ }
+ }
+ }
+
+ @EventHandler
+ public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event)
+ {
+
+ Player player = event.getPlayer();
+
+ if (event.getRightClicked().getType().equals(EntityType.ARMOR_STAND))
+ {
+
+ if(player.getInventory().getItemInMainHand().getType() == Material.STICK && player.getInventory().getItemInMainHand().getAmount() > 1 && player.isSneaking())
+ {
+ ArmorStand armorstand = (ArmorStand) event.getRightClicked();
+
+ armorstand.setArms(true);
+ event.setCancelled(true);
+
+ player.getInventory().getItemInMainHand().setAmount(player.getInventory().getItemInMainHand().getAmount() - 2);
+ }
+ }
+ }
}
+