Advertisement
Guest User

Untitled

a guest
Jul 28th, 2014
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. package me.jaybirdpontiac69.jail;
  2.  
  3. import java.io.File;
  4. import java.util.ArrayList;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.ChatColor;
  8. import org.bukkit.Location;
  9. import org.bukkit.World;
  10. import org.bukkit.command.Command;
  11. import org.bukkit.command.CommandSender;
  12. import org.bukkit.configuration.file.FileConfiguration;
  13. import org.bukkit.entity.Player;
  14. import org.bukkit.plugin.java.JavaPlugin;
  15. import org.bukkit.scheduler.BukkitScheduler;
  16.  
  17. public class Jail extends JavaPlugin {
  18.  
  19. ArrayList<String> jailed = new ArrayList<String>();
  20.  
  21. FileConfiguration config;
  22. File cfile;
  23.  
  24. public void onEnable() {
  25. getConfig().options().copyDefaults(true);
  26. config = getConfig();
  27. config.options().copyDefaults(true);
  28. saveConfig();
  29. cfile = new File(getDataFolder(), "config.yml");
  30. }
  31.  
  32. @SuppressWarnings("unused")
  33. public boolean onCommand(CommandSender sender, final Command cmd, String commandLabel, final String[] args) {
  34.  
  35.  
  36.  
  37. if (!(sender instanceof Player)) {
  38. sender.sendMessage(ChatColor.RED + "This plugin is for players only!");
  39. return true;
  40. }
  41.  
  42. final Player p = (Player) sender;
  43.  
  44. // Set A Jail. V
  45. if (cmd.getName().equalsIgnoreCase("setjail")){
  46. getConfig().set("jail.world", p.getLocation().getWorld().getName());
  47. getConfig().set("jail.x", p.getLocation().getX());
  48. getConfig().set("jail.y", p.getLocation().getY());
  49. getConfig().set("jail.z", p.getLocation().getZ());
  50. saveConfig();
  51. p.sendMessage(ChatColor.GRAY +"[" + ChatColor.AQUA + "Jails" + ChatColor.GRAY + "]" + ChatColor.RED + "Jail Has Been Set.");
  52. return true;
  53. }
  54.  
  55. String targetPlayerName = args[0];
  56.  
  57. // Cant Find Player. V
  58. @SuppressWarnings("deprecation")
  59. final Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
  60. if (targetPlayer == null) {
  61. p.sendMessage(ChatColor.GRAY + "[" + ChatColor.AQUA + "Jails" + ChatColor.GRAY + "]" + ChatColor.DARK_PURPLE + "Could Not Find Player " + ChatColor.LIGHT_PURPLE + args[0] + ChatColor.DARK_PURPLE + "!");
  62. return true;
  63. }
  64. // Teleports You To Jail. V
  65.  
  66. {
  67.  
  68. getServer().getScheduler().scheduleSyncRepeatingTask(plugin, x, 0, 40);
  69.  
  70.  
  71. World w = Bukkit.getServer().getWorld(getConfig().getString("jail.world"));
  72. double x = getConfig().getDouble("jail.x");
  73. double y = getConfig().getDouble("jail.y");
  74. double z = getConfig().getDouble("jail.z");
  75. targetPlayer.teleport(new Location(w, x, y, z));
  76. targetPlayer.sendMessage(ChatColor.GRAY + "[" + ChatColor.AQUA + "Jails" + ChatColor.GRAY + "]" + ChatColor.RED + "You Have Been Jailed For Being Naughty! Bad Boy!");
  77. if (jailed.add(targetPlayer.getName()));
  78. return true;
  79. }
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement