java - What is @SuppressWarnings("deprecation") and how do I fix it? -
i following youtube tutorial , came across error.
at line, @suppresswarnings("deprecation")
comes up.
player targerplayer = bukkit.getserver().getplayer(args[0]);
here simple healing plugin.
package me.roofer.youtube; import java.util.logging.logger; import org.bukkit.bukkit; import org.bukkit.chatcolor; import org.bukkit.command.command; import org.bukkit.command.commandsender; import org.bukkit.entity.player; import org.bukkit.plugin.plugindescriptionfile; import org.bukkit.plugin.java.javaplugin; public class youtube extends javaplugin { public static logger logger = logger.getlogger("minecraft"); public static youtube plugin; @override public void ondisable() { plugindescriptionfile pdffile = this.getdescription(); youtube.logger.info(pdffile.getname() + " has been disabled!"); } @override public void onenable() { plugindescriptionfile pdffile = this.getdescription(); youtube.logger.info(pdffile.getname() + " version" + pdffile.getversion() + " has been enabled!"); public boolean oncommand(commandsender sender, command cmd, string commandlabel, string[] args){ @suppresswarnings("unused") player player = (player) sender; if(commandlabel.equalsignorecase("heal") || commandlabel.equalsignorecase("h")) { // heal >> 0 args | heal roofer777 >> 1 arg if (args.length == 0){ player.sethealth(20); player.sendmessage(chatcolor.red + "healed!"); }else if(args.length == 1){ @suppresswarnings({"unused", "deprecation"}) player targerplayer = bukkit.getserver().getplayer(args[0]); targetplayer.sethealth(20); } } return false; } }
that not error. should read on the definition of deprecation.
a program element annotated @deprecated 1 programmers discouraged using, typically because dangerous, or because better alternative exists. compilers warn when deprecated program element used or overridden in non-deprecated code.
the reason why specific method deprecated because bukkit moving on new uuid system, using names not best way player
object.
Comments
Post a Comment