Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 KB | None | 0 0
  1. package me.kihei.firstplugin;
  2.  
  3. import org.bukkit.entity.Player;
  4. import org.bukkit.event.EventHandler;
  5. import org.bukkit.event.Listener;
  6. import org.bukkit.event.player.PlayerMoveEvent;
  7.  
  8. public class MovementListener implements Listener {
  9.  
  10.     // Plugin instance. It starts of as null
  11.     // It gets the value from the constructor
  12.     private FirstPlugin plugin;
  13.  
  14.     // This is the constructor.
  15.     // It is always called when a new instance of the class is created
  16.     // We give the parameter of plugin and set it to the plugin instance above
  17.     // NOTE: The constructor is always "public {nameOfClass}() {}"
  18.     public MovementListener(FirstPlugin plugin) {
  19.         this.plugin = plugin;
  20.     }
  21.  
  22.     @EventHandler //@EventHandler Let's minecraft know that this is a method for events
  23.     public void onMove(PlayerMoveEvent e) {
  24.         //Retrieving the player who tried to move
  25.         Player p = e.getPlayer();
  26.         //Check if the hashmap in side the main class has our player
  27.  
  28.             //Make sure if the player is frozen or not
  29.             if (FirstPlugin.frozenList.contains(p)) {
  30.                 e.setCancelled(true); //This method is available for all events!
  31.                 e.getPlayer().sendMessage("You cannot move while you are frozen!"); //Send a msg to a player.
  32.             }
  33.         }
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement