SHARE
TWEET

Untitled

a guest May 19th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package stem.jarvis.Commands;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.Location;
  6. import org.bukkit.command.Command;
  7. import org.bukkit.command.CommandExecutor;
  8. import org.bukkit.command.CommandSender;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.event.EventHandler;
  11. import org.bukkit.event.player.PlayerMoveEvent;
  12.  
  13. import java.util.HashMap;
  14.  
  15. public class Freeze implements CommandExecutor {
  16.  
  17.     Freeze plugin;
  18.  
  19.     public HashMap<Player, Location> FrozenPlayers = new HashMap<>();
  20.     private final String jarTag = ChatColor.DARK_RED + "[" + ChatColor.GOLD + ChatColor.BOLD + "Jarvis" + ChatColor.DARK_RED + "] ";
  21.  
  22.     @EventHandler
  23.     public void onPlayerMoveBlock(PlayerMoveEvent e){
  24.         if(!FrozenPlayers.containsKey(e.getPlayer())){
  25.             return;
  26.         }
  27.         if(e.getFrom().getBlockX() != e.getTo().getBlockX()|| e.getFrom().getBlockZ() != e.getTo().getBlockZ());
  28.         e.getPlayer().teleport(FrozenPlayers.get(e.getPlayer()));
  29.     }
  30.  
  31.     @Override
  32.     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  33.  
  34.         if(sender instanceof Player){
  35.             Player player = (Player) sender;
  36.             if(player.hasPermission("jar.Freeze") || player.isOp()){
  37.                 if(args.length == 1){
  38.                     String targetName = args[0];
  39.                     if(Bukkit.getOfflinePlayer(targetName).getPlayer() != null);
  40.                     Player target = Bukkit.getPlayer(targetName);
  41.                     if(plugin.FrozenPlayers.containsKey(target)){
  42.                         plugin.FrozenPlayers.remove(target);
  43.                     }else{
  44.                         plugin.FrozenPlayers.put(target, target.getLocation().clone());
  45.                     }
  46.                 }
  47.                 return true;
  48.             }
  49.             else{
  50.                 player.sendMessage(jarTag + ChatColor.RED + "Sorry Sir, Mr Stark Hasn't given you Access to that Function.");
  51.                 System.out.println("Freeze Failed" + "/Executed by:"  + (player));
  52.                 return true;
  53.             }
  54.         }
  55.         return false;
  56.     }
  57. }
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