Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.kihei.firstplugin;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.player.PlayerMoveEvent;
- public class MovementListener implements Listener {
- // Plugin instance. It starts of as null
- // It gets the value from the constructor
- private FirstPlugin plugin;
- // This is the constructor.
- // It is always called when a new instance of the class is created
- // We give the parameter of plugin and set it to the plugin instance above
- // NOTE: The constructor is always "public {nameOfClass}() {}"
- public MovementListener(FirstPlugin plugin) {
- this.plugin = plugin;
- }
- @EventHandler //@EventHandler Let's minecraft know that this is a method for events
- public void onMove(PlayerMoveEvent e) {
- //Retrieving the player who tried to move
- Player p = e.getPlayer();
- //Check if the hashmap in side the main class has our player
- //Make sure if the player is frozen or not
- if (FirstPlugin.frozenList.contains(p)) {
- e.setCancelled(true); //This method is available for all events!
- e.getPlayer().sendMessage("You cannot move while you are frozen!"); //Send a msg to a player.
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement