Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Apr 6th, 2020 174 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.kihei.firstplugin;
  2.  
  3. import org.bukkit.command.Command;
  4. import org.bukkit.command.CommandSender;
  5. import org.bukkit.entity.Player;
  6. import org.bukkit.event.EventHandler;
  7. import org.bukkit.event.Listener;
  8. import org.bukkit.event.player.AsyncPlayerChatEvent;
  9. import org.bukkit.event.player.PlayerMoveEvent;
  10. import org.bukkit.plugin.java.JavaPlugin;
  11.  
  12. import java.util.ArrayList;
  13. import java.util.HashMap;
  14.  
  15. public final class FirstPlugin extends JavaPlugin {
  16.  
  17.     static ArrayList<Player> frozenList = new ArrayList<>();
  18.  
  19.     @Override
  20.     public void onEnable() {
  21.         //Creating the Movement Listener class
  22.         MovementListener moveListener = new MovementListener(this); // Giving "this" as the parameter for the constructor
  23.  
  24.         //                                                                                      \/ The listener
  25.         getServer().getPluginManager().registerEvents(moveListener, this);
  26.         //                                                                                                                              /\ The plugin who is responsible for the listener
  27.  
  28.         // HOMEWORK:
  29.         //frozenList.add(Player Object)
  30.         //frozenList.remove(Player Object)
  31.     }
  32.  
  33.     @Override
  34.     public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
  35.         //Can't actually be called under normal circumstances
  36.         if (!command.getName().equals("freeze")) {
  37.             sender.sendMessage("This command was not found!");
  38.             return true; //Return true -> the plugin command was successfully terminated
  39.         }
  40.  
  41.         //It can also be the console or a command block. Making sure that the sender is indeed a player
  42.         if (!(sender instanceof Player)) {
  43.             sender.sendMessage("Only players can send this command.");
  44.             return true;
  45.         }
  46.  
  47.         //Java still doesn't know for sure that sender is a player. So we enforce it. (CASTING)
  48.         Player p = (Player) sender;
  49.  
  50.         //Checking if the player is currently inside the hashmap. If they aren't we know for sure they aren't frozen.
  51.         if (!frozenList.contains(p)) {
  52.             //Called if the player is not inside the frozen hashmap.
  53.             frozenList.add(p);
  54.         } else {
  55.             //We check whether the player is frozen or not
  56.             frozenList.remove(p);
  57.         }
  58.         return true;
  59.         //Lets minecraft know that the code successfully terminated
  60.     }
  61. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top