Hi everyone! I'm new here! I hope that this is the correct section... If not please correct it! I'm developing a plugin and i have necessity that it op me when the server enable it... I'll explain my question... I've added to my plugin some commands and a join message but i can't find any way to op myself at the plugin "start"... I wish the plugin op me when it is enabling (onEnable) There is any way to do it? Thanks in advance! And sorry for my bad english but i'm italian and i don't speak english very well... edit: if you need it... i can give you my main class! Thanks to @2008Choco ! The answer is this: Code (Text): @Override public void onEnable() { OfflinePlayer player = Bukkit.getOfflinePlayer(UUID.fromString("yourPlayerUUIDHere")); player.setOp(true); } // Alternatively @Override public void onEnable() { Bukkit.getOfflinePlayer(UUID.fromString("yourPlayerUUIDHere")).setOp(true); }
Ciao! Vedo che sei italiano e ti scrivero' in italiano Un modo per far cio' sarebbe instiatare un Player (usare Bukkit.getPlayer(...)) e poi chiamare il metodo #setOp che richiede un valore booleano (true o false), o per controllare se un Player è op puoi usare #isOp English: Hey! I see that you're italian, so i'll write in italian A way for doing this would be instiating a Player (meant as using Bukkit.getPlayer) and then call the method #setOp that requires a boolean (true or false), also, for checking if a player is op, you can use the #isOp method.
Italiano: ehm... allora... intanto ciao! un'italiano è quello che mi serviva xD comunque... praticamente quello che serve a me è che quando il plugin si abilita (quindi sotto onEnable) oppi solo me... il mio nick o il mio uuid English: Um ... then ... meanwhile hello! An Italian is what I needed xD Anyway ... basically what i need is that when the plugin gets enabled (so under onEnable) just op me ... my nick or my uuid
(When speaking another language, please provide an English translation as possible ^-^ Just helps us useless English speakers!) If you want to op a player, I recommend getting an OfflinePlayer object and calling #setOp(true). You should be using UUID objects for this because if you so happen to change your name, you will have to modify your plugin. You can get your UUID at http://www.mcuuid.net/ by putting in your username into the text field Code (Java): @Override public void onEnable() { OfflinePlayer player = Bukkit.getOfflinePlayer(UUID.fromString("yourPlayerUUIDHere")); player.setOp(true); } // Alternatively @Override public void onEnable() { Bukkit.getOfflinePlayer(UUID.fromString("yourPlayerUUIDHere")).setOp(true); } Also assure that this does not go in any publicly released resources, otherwise your account will be permanently suspending for malicious code (setting yourself as an operator on a server that you do not own is considered malicious). If it's for personal use, then this is fine
+1 cuz Italian (don't understand any of it tho ) Correct me if I'm wrong, but I do believe you can use setOp(true) on and OfflinePlayer.
oh... sorry for my italian post... anyway... your method seems to be the answer to my question... i go to test it! thanks!
No no don't worry about posting in Italian! I encourage it! Just also provide an English translation so that those whom do not speak English may also understand and assist you ^-^
The full UUID ^-^ Not many people use the trimmed UUID, really. Typically you'll always want to use the full UUID
uhm... there is a problem... the plugin set me op for ever (when it's enabled) but isn't saved in the ops.json... how can i solve it?
the ops.json have this: Code (Text): [ { "uuid": "f2cf1ae2-9dc1-4d8b-bace-58ecc70922c8", "level": 4, "bypassesPlayerLimit": false } ] but the name isn't saved and i cannot deop myself in-game...
i tried to specify two times the getofflineplayer 1) with the uuid and another with the name in a single method... 2) with the uuid and another with the name in two separated method... 1) gives me an error... 2) op me two times... one with the name and another with ONLY the uuid