Basic Admin Commands

Discussion in 'Archived: Plugin Requests' started by SwankyCactus8, Jul 28, 2014.

  1. Offline

    SwankyCactus8

    Plugin category: Functional

    Suggested name: AdminCommands

    What I want: I just need a simple plugin with very few commands that will help a lot. I know essentials has most of these commands, but essentials isn't what i'm looking forward to use. I need simple commands like /vanish, /see, and more.

    Ideas for commands:
    - /vanish :: Vanishes the player completely from chat and the tab, and gives the player unlimited invisibility, until the player /vanish again. I would like to have the chat say "(Player) has vanished!"
    and "(Player) has unvanished!" only to people with the permission.

    - /see (Player) :: Allows the player to see another players inventory, similar to /invsee from essentials. The player is allowed to take or remove any items from the player as well. I would also like to see what armor the person is wearing in the chest GUI, so that the armor from the player can be placed or removed.

    - /fly (Player) :: Allows the player to fly without taking fall damage.

    - /feed (Player) :: Feeds the player and resets there saturation.

    - /heal (Player) :: Heals the player completely.

    - /time (Day,Night,Afternoon) :: Sets the time to a certain time of day.

    - /spawner (Type) :: When looking at a spawner, using the command will change the spawner type to what was specified in the command.

    - /broadcast (Message) :: Broadcasts a message to the whole server. Have the prefix on the message customizable.
    EX. [Broadcast] (Message)

    - /enchant (enchantment) (level) :: Enchants the item in hand, regardless if the enchant isn't meant to be on the tool (Can put protection on a sword, etc.). Also allow the level to be infinite (Can put sharpness 10 on an item.)

    Ideas for permissions:
    - bam.vanish
    - bam.vanishsee (Allows the people with permission to see when a player vanishes.)
    - bam.see
    - bam.fly
    - bam.feed
    - bam.heal
    - bam.time
    - bam.spawner
    - bam.broadcast
    - bam.enchant

    When I'd like it by: Monday August 4th 2014
     
  2. Offline

    DigitalSniperz

    Easy, I don't have the time today. So I'll start tomoz.
     
  3. Offline

    SwankyCactus8

    Ok, that sounds great. Thanks!
     
  4. Offline

    RRServer

    Decided to work on this.
    I only have to get the /see : /enchant : /spawner commands finished.

    Update 1: Got /see working, almost done with /spawner, and having some trouble with /enchant.

    I can't seem to get past /enchant and /spawner. There's also a small issue with /broadcast that I can't seem to make out.

    I'm going to allow someone else to pick up from where I left off. Most of the plugin is done and works great.
    Here's the source code :
    Code:java
    1. package me.RRServer.AdminCommands;
    2.  
    3. import java.util.ArrayList;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.Location;
    8. import org.bukkit.Material;
    9. import org.bukkit.World;
    10. import org.bukkit.block.Block;
    11. import org.bukkit.block.CreatureSpawner;
    12. import org.bukkit.command.Command;
    13. import org.bukkit.command.CommandSender;
    14. import org.bukkit.entity.EntityType;
    15. import org.bukkit.entity.Player;
    16. import org.bukkit.event.EventHandler;
    17. import org.bukkit.event.Listener;
    18. import org.bukkit.event.entity.EntityDamageEvent;
    19. import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
    20. import org.bukkit.inventory.ItemStack;
    21. import org.bukkit.plugin.java.JavaPlugin;
    22.  
    23. public class Main extends JavaPlugin implements Listener
    24. {
    25.  
    26. public void onEnable()
    27. {
    28. getLogger().info("AdminCommands has been enabled!");
    29. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    30. saveConfig();
    31. }
    32.  
    33. public void onDisable()
    34. {
    35. getLogger().info("AdminCommands has been disabled!");
    36. }
    37.  
    38. ArrayList<Player> vanish = new ArrayList<Player>();
    39. ArrayList<Player> fly = new ArrayList<Player>();
    40.  
    41. @EventHandler
    42. public void PlayerFall(EntityDamageEvent e)
    43. {
    44. if (e.getEntity().getType() == EntityType.PLAYER)
    45. {
    46. if (e.getCause() == DamageCause.FALL)
    47. {
    48. Player p = (Player) e.getEntity();
    49. if (fly.contains(p))
    50. {
    51. e.setCancelled(true);
    52. }
    53. else
    54. {
    55. return;
    56. }
    57. }
    58. }
    59. }
    60.  
    61. @EventHandler
    62. public void hidePlayer(Player p)
    63. {
    64. if (vanish.contains(p))
    65. {
    66. p.hidePlayer(p);
    67. }
    68. else
    69. {
    70. return;
    71. }
    72. }
    73.  
    74. @Override
    75. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
    76. {
    77. Player p = (Player) sender;
    78. if (cmd.getName().equalsIgnoreCase("vanish"))
    79. {
    80. if (p.hasPermission("bam.vanish"))
    81. {
    82. if (args.length == 0)
    83. {
    84. if (!(vanish.contains(p)))
    85. {
    86. vanish.add(p);
    87. p.sendMessage(ChatColor.YELLOW + "You have been vanished!");
    88. }
    89. else
    90. {
    91. vanish.remove(p);
    92. p.sendMessage(ChatColor.YELLOW + "You have been unvanished!");
    93. }
    94. }
    95. else
    96. {
    97. Player target = Bukkit.getPlayer(args[0]);
    98. if (target == null)
    99. {
    100. p.sendMessage(ChatColor.RED + args[0] + " is not currently online!");
    101. }
    102. else
    103. {
    104. if (!(vanish.contains(target)))
    105. {
    106. target.hidePlayer(target);
    107. vanish.add(target);
    108. target.sendMessage(ChatColor.YELLOW + "You have been vanished!");
    109. p.sendMessage(ChatColor.YELLOW + args[0] + " has been vanished!");
    110. }
    111. else
    112. {
    113. vanish.remove(target);
    114. target.sendMessage(ChatColor.YELLOW + "You have been unvanished!");
    115. p.sendMessage(ChatColor.YELLOW + args[0] + " has been unvanished!");
    116. }
    117. }
    118. }
    119. }
    120. else
    121. {
    122. p.sendMessage(ChatColor.RED + "You do not have the proper permission (bam.vanish)!");
    123. }
    124. }
    125. else if (cmd.getName().equalsIgnoreCase("see"))
    126. {
    127. if (p.hasPermission("bam.see"))
    128. {
    129. if (args.length == 0)
    130. {
    131. p.sendMessage(ChatColor.RED + "Incorrect usuage: /see <Player>");
    132. }
    133. else
    134. {
    135. Player target = Bukkit.getPlayer(args[0]);
    136. if (target == null)
    137. {
    138. p.sendMessage(ChatColor.RED + args[0] + " is not currently online!");
    139. }
    140. else
    141. {
    142. p.openInventory(target.getInventory());
    143. p.sendMessage(ChatColor.YELLOW + "You are looking at " + args[0] + "'s inventory!");
    144. }
    145. }
    146. }
    147. else
    148. {
    149. p.sendMessage(ChatColor.RED + "You do not have the proper permission (bam.see)!");
    150. }
    151. }
    152. else if (cmd.getName().equalsIgnoreCase("fly"))
    153. {
    154. if (p.hasPermission("bam.fly"))
    155. {
    156. if (args.length == 0)
    157. {
    158. if (!(fly.contains(p)))
    159. {
    160. fly.add(p);
    161. p.setAllowFlight(true);
    162. p.sendMessage(ChatColor.YELLOW + "You are now able to fly!");
    163. }
    164. else
    165. {
    166. fly.remove(p);
    167. p.setAllowFlight(false);
    168. p.sendMessage(ChatColor.YELLOW + "You are now no longer able to fly!");
    169. }
    170. }
    171. else
    172. {
    173. Player target = Bukkit.getPlayer(args[0]);
    174. if (target == null)
    175. {
    176. p.sendMessage(ChatColor.RED + args[0] + " is not currently online!");
    177. }
    178. else
    179. {
    180. if (!(fly.contains(target)))
    181. {
    182. fly.add(target);
    183. target.setAllowFlight(true);
    184. p.sendMessage(ChatColor.YELLOW + args[0] + " is now able to fly!");
    185. target.sendMessage(ChatColor.YELLOW + "You are now able to fly!");
    186. }
    187. else
    188. {
    189. fly.remove(target);
    190. target.setAllowFlight(false);
    191. p.sendMessage(ChatColor.YELLOW + args[0] + " is no longer able to fly!");
    192. target.sendMessage(ChatColor.YELLOW + "You are now no longer able to fly!");
    193. }
    194. }
    195. }
    196. }
    197. else
    198. {
    199. p.sendMessage(ChatColor.RED + "You do not have the proper permission (bam.fly)!");
    200. }
    201. }
    202. else if (cmd.getName().equalsIgnoreCase("feed"))
    203. {
    204. if (p.hasPermission("bam.feed"))
    205. {
    206. if (args.length == 0)
    207. {
    208. p.setFoodLevel(20);
    209. p.sendMessage(ChatColor.YELLOW + "You have been fed!");
    210. }
    211. else
    212. {
    213. Player target = Bukkit.getPlayer(args[0]);
    214. if (target == null)
    215. {
    216. p.sendMessage(ChatColor.RED + args[0] + " is not currently online!");
    217. }
    218. else
    219. {
    220. target.setFoodLevel(20);
    221. target.sendMessage(ChatColor.YELLOW + "You have been fed!");
    222. p.sendMessage(ChatColor.YELLOW + args[0] + " has been fed!");
    223. }
    224. }
    225. }
    226. else
    227. {
    228. p.sendMessage(ChatColor.RED + "You do not have the proper permission (bam.feed)!");
    229. }
    230. }
    231. else if (cmd.getName().equalsIgnoreCase("heal"))
    232. {
    233. if (p.hasPermission("bam.heal"))
    234. {
    235. if (args.length == 0)
    236. {
    237. p.setHealth(20);
    238. p.sendMessage(ChatColor.YELLOW + "You have been healed!");
    239. }
    240. else
    241. {
    242. Player target = Bukkit.getPlayer(args[0]);
    243. if (target == null)
    244. {
    245. p.sendMessage(ChatColor.RED + args[0] + " is not currently online!");
    246. }
    247. else
    248. {
    249. target.setHealth(20);
    250. target.sendMessage(ChatColor.YELLOW + "You have been healed!");
    251. p.sendMessage(ChatColor.YELLOW + args[0] + " has been healed!");
    252. }
    253. }
    254. }
    255. else
    256. {
    257. p.sendMessage(ChatColor.RED + "You do not have the proper permission (bam.heal)!");
    258. }
    259. }
    260. else if (cmd.getName().equalsIgnoreCase("time"))
    261. {
    262. if (p.hasPermission("bam.time"))
    263. {
    264. if (args.length == 0)
    265. {
    266. p.sendMessage(ChatColor.RED + "Incorrect usage: /day <Day>:<Night>:<Afternoon>");
    267. }
    268. else
    269. {
    270. World world = p.getWorld();
    271. if (args[0].equalsIgnoreCase("day"))
    272. {
    273. world.setTime(0);
    274. p.sendMessage(ChatColor.YELLOW + "You have set the time to day!");
    275. }
    276. else if (args[0].equalsIgnoreCase("night"))
    277. {
    278. world.setTime(18000);
    279. p.sendMessage(ChatColor.YELLOW + "You have set the time to night!");
    280. }
    281. else if (args[0].equalsIgnoreCase("afternoon"))
    282. {
    283. world.setTime(8000);
    284. p.sendMessage(ChatColor.YELLOW + "You have set the time to afternoon!");
    285. }
    286. else
    287. {
    288. p.sendMessage(ChatColor.RED + "Incorrect usage: /day <Day>:<Night>:<Afternoon>");
    289. }
    290. }
    291. }
    292. else
    293. {
    294. p.sendMessage(ChatColor.RED + "You do not have the proper permission (bam.time)!");
    295. }
    296. }
    297. else if (cmd.getName().equalsIgnoreCase("spawner"))
    298. {
    299. if (p.hasPermission("bam.spawner"))
    300. {
    301. if (args.length == 0)
    302. {
    303. p.sendMessage(ChatColor.RED + "Incorrect usage: /spawner <Type>");
    304. }
    305. else
    306. {
    307. Location play = p.getLocation();
    308. Block b = play.getBlock();
    309. CreatureSpawner cs = ((CreatureSpawner) b.getState());
    310. if (b.equals(Material.MOB_SPAWNER))
    311. {
    312. if (args[0].equalsIgnoreCase("zombie"))
    313. {
    314. cs.setSpawnedType(EntityType.ZOMBIE);
    315. cs.update();
    316. }
    317. else if (args[0].equalsIgnoreCase("skeleton"))
    318. {
    319. cs.setSpawnedType(EntityType.SKELETON);
    320. cs.update();
    321. }
    322. else if (args[0].equalsIgnoreCase("creeper"))
    323. {
    324. cs.setSpawnedType(EntityType.CREEPER);
    325. cs.update();
    326. }
    327. else if (args[0].equalsIgnoreCase("enderman"))
    328. {
    329. cs.setSpawnedType(EntityType.ENDERMAN);
    330. cs.update();
    331. }
    332. else if (args[0].equalsIgnoreCase("blaze"))
    333. {
    334. cs.setSpawnedType(EntityType.BLAZE);
    335. cs.update();
    336. }
    337. else if (args[0].equalsIgnoreCase("cavespider"))
    338. {
    339. cs.setSpawnedType(EntityType.CAVE_SPIDER);
    340. cs.update();
    341. }
    342. else if (args[0].equalsIgnoreCase("spider"))
    343. {
    344. cs.setSpawnedType(EntityType.SPIDER);
    345. cs.update();
    346. }
    347. }
    348. }
    349. }
    350. else
    351. {
    352. p.sendMessage(ChatColor.RED + "You do not have the proper permission (bam.spawner)!");
    353. }
    354. }
    355. else if (cmd.getName().equalsIgnoreCase("broadcast"))
    356. {
    357. if (p.hasPermission("bam.broadcast"))
    358. {
    359. if (args.length == 0)
    360. {
    361. p.sendMessage(ChatColor.RED + "Incorrect usage: /broadcast <Message>");
    362. }
    363. else
    364. {
    365. Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("BroadcastPrefix") + args));
    366. }
    367. }
    368. else
    369. {
    370. p.sendMessage(ChatColor.RED + "You do not have the proper permission (bam.broadcast)!");
    371. }
    372. }
    373. else if (cmd.getName().equalsIgnoreCase("enchant"))
    374. {
    375. if (p.hasPermission("bam.enchant"))
    376. {
    377. ItemStack stack = p.getItemInHand();
    378. if (!(stack == null))
    379. {
    380. if (args.length == 0)
    381. {
    382. p.sendMessage(ChatColor.RED + "Incorrect usage: /enchant <Enchantment> <Level>");
    383. }
    384. else if (args.length > 1)
    385. {
    386.  
    387. }
    388. }
    389. else
    390. {
    391. p.sendMessage(ChatColor.RED + "You are not holding anything!");
    392. }
    393. }
    394. else
    395. {
    396. p.sendMessage(ChatColor.RED + "You do not have the proper permission (bam.enchant)!");
    397. }
    398. }
    399. return false;
    400. }
    401. }
    402.  


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  5. Offline

    RRServer

    Bump for OP.
     

Share This Page