Can anyone pls help me with the following pease of code, i can't get it to work Code: http://pastie.org/2657734 plugin.yml http://pastie.org/2657740 the last command /tpto will not register, when i use it in game it returns the usage of it to me, and if any1 can tell me how i can get the name entered with the cammand as a variable i will be very thankfull
nobody's gonna help you if you don't say whats wrong with it, and any errors given to you in the console
i added the return true now; but now nothing happens, it looks to me like i'm doing this wrong.. i'am not getiing the player name as input correctly this is new code http://pastie.org/2659202
Code:java package me.bush.banplayertp;import java.io.File;import java.util.logging.Logger;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;import org.bukkit.util.config.Configuration;public class BanPlayerTP extends JavaPlugin {private Logger log = Logger.getLogger("Minecraft");public Configuration config, Hdata;public File directory;@Overridepublic void onDisable() {this.logMessage("Disabled");Hdata.save();}@Overridepublic void onEnable() {Hdata = getConfiguration();File configs = new File(getDataFolder() + File.separator + "Hdata.yml");Hdata = new Configuration(configs);Hdata.load();Hdata.setHeader("#This is a list of players, if set to false then tping to the is disabled");Hdata.save();this.logMessage("Enabled");}protected void logMessage(String msg) {PluginDescriptionFile pdFile = this.getDescription();this.log.info(pdFile.getName() + " " + pdFile.getVersion() + ": " + msg);}public boolean onCommand(CommandSender sender, Command cmd,String commandLabel, String[] args) {if (sender instanceof Player) {if (cmd.getName().equalsIgnoreCase("tpdisable")) {Player p = (Player) sender;Hdata.getBoolean("Players."+p.getDisplayName()+".enabled", false);Hdata.save();p.sendMessage("Nobody can teleport to you now.");return true;}if (cmd.getName().equalsIgnoreCase("tpenable")) {Player p = (Player) sender;Hdata.getBoolean("Players."+p.getDisplayName()+".enabled", true);Hdata.save();p.sendMessage("Players can teleport to you again");return true;}if (cmd.getName().equalsIgnoreCase("tpto")) {Player p = (Player) sender;Player target = getServer().getPlayer(args[0]);if (Hdata.getBoolean("Players."+target.getDisplayName()+".enabled", true)){p.teleport(target);}else if (Hdata.getBoolean("Players."+target.getDisplayName()+".enabled", false)){p.sendMessage("Teleporting to that player is disabled");}return true;}}return false;}} Well, first off on lines 44 and 51, you are not actually setting a boolean value, you are getting it, so calling Hdata.save(); will not do you any good. In order to set anything in a config file or otherwise, the appropriate usage for setting a boolean value would be: Code:java Hdata.setProperty("Players."+p.getDisplayName()".enabled", true); I'd also recommend changing p.getDisplayName to p.getName(), so if their display name changes you still retrieve the same data for the same person Edit: And I just realized how broken my English was in the previous paragraph.
@Ahniolator i did what you said, but still nothing, it seems like the command isn't registring and so its doing nothing.
Did you register the commands in your plugin.yml? Edit: Also on line 52 in my previous post, you check for a player by name on the server. If the player's name doesn't exist on the server it will return null and you will get a nullpointer exception when you call the code after line 52. I recommend checking if that player is null and if the player is null then sending the player a custom error message and returning null
do you maybe know how the original tp command was coded? where you would say /tp bush Ahniolator?? how did they get the player names entered? @Ahniolator
I need you to post your plugin.yml. Otherwise I can't accurately say whether or not you are doing it right.
@Ribesg @Razorcane i think it works now, just need to test it, but i need some1 willing to test it with me
Just run two minecrafts at the same time, start one offline by logging in with a bad password & then login normally with the other.
haha we'll i tested it and the messages displayed that i put in with the command /tp player player so it works thnx for the help @Celeixen released my plugin here: http://forums.bukkit.org/threads/ad...isable-players-teleporting-to-you-1240.40589/ EDIT by Moderator: merged posts, please use the edit button instead of double posting.