forum Forumsplay_arrow Minecraft fiber_manual_record Mods

1

Bukkit Plugin: An internal error occurred while attempting..

1 emerald2 replies303 views
created 08/30/2015 5:17 am by pieterx12
last reply 08/30/2015 6:01 am
Hi I'm trying to make a Bukkit VIP System but everytime that I want to use the target player it says "An internal error occurred while attempting to perform this command".
package EnvyGames.VIPSystem.com;

import java.util.logging.Logger;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

import EnvyGames.VIPSystem.com.Commands.Goodbye;
import EnvyGames.VIPSystem.com.Commands.Hello;
import EnvyGames.VIPSystem.com.Commands.VipRemoveCommand;
import EnvyGames.VIPSystem.com.event.block.BlockBreak;


public class Main extends JavaPlugin implements CommandExecutor {

public void onEnable() {


getConfig().options().copyDefaults(true);
saveDefaultConfig();
}

public void onDisable() {
getConfig().options().copyDefaults(true);
saveConfig();
}

public void registerCommands(){
getCommand("Hello").setExecutor(new Hello());
getCommand("Goodbye").setExecutor(new Goodbye());


}
public void registerEvents(){
PluginManager pm = getServer().getPluginManager();

pm.registerEvents(new BlockBreak(), this);

}


@SuppressWarnings("deprecation")
public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel, String[] args) {
Player p = (Player) sender;
Player target = Bukkit.getPlayer(args[0]);
if(CommandLabel.equalsIgnoreCase("vip")){

if(args.length == 0){

p.sendMessage(":'D");
}else if(args.length == 2){
if(args[0].equalsIgnoreCase("add")){
if(args[1].equalsIgnoreCase(target.getName())){
if (getConfig().getString("vips." + target.getName()) == null) {
getConfig().addDefault("vips." + target.getName(), 0);
saveConfig();
p.sendMessage("Je bent nu VIP op de server.");
}else {
p.sendMessage("fout");
saveConfig();
}
}
}
}
}







return false;
}












}

Posted by avatar
pieterx12
Level 8 : Apprentice Miner
1

2 replies

1
08/30/2015 6:01 am
Level 8 : Apprentice Miner
pieterx12
avatar
The code gives a a error
if(target = Bukkit.getServer().getPlayer(args[0] == null)) this is wrong
1
08/30/2015 5:34 am
Level 3 : Apprentice Network
weakwizardsucks2
avatar
package EnvyGames.VIPSystem.com;

import java.util.logging.Logger;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

import EnvyGames.VIPSystem.com.Commands.Goodbye;
import EnvyGames.VIPSystem.com.Commands.Hello;
import EnvyGames.VIPSystem.com.Commands.VipRemoveCommand;
import EnvyGames.VIPSystem.com.event.block.BlockBreak;


public class Main extends JavaPlugin implements CommandExecutor {

public void onEnable() {


getConfig().options().copyDefaults(true);
saveDefaultConfig();
}

public void onDisable() {
getConfig().options().copyDefaults(true);
saveConfig();
}

public void registerCommands(){
getCommand("Hello").setExecutor(new Hello());
getCommand("Goodbye").setExecutor(new Goodbye());


}
public void registerEvents(){
PluginManager pm = getServer().getPluginManager();

pm.registerEvents(new BlockBreak(), this);

}


@SuppressWarnings("deprecation")
public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel, String[] args) {
Player p = (Player) sender;
Player target = null;
if(target = Bukkit.getServer().getPlayer(args[0] == null){
sender.sendMessage(ChatColor.RED + "That player doesn't exist or is not online.")
if(CommandLabel.equalsIgnoreCase("vip")){

if(args.length == 0){

p.sendMessage(":'D");
}else if(args.length == 2){
if(args[0].equalsIgnoreCase("add")){
if(args[1].equalsIgnoreCase(target.getName())){
if (getConfig().getString("vips." + target.getName()) == null) {
getConfig().addDefault("vips." + target.getName(), 0);
saveConfig();
p.sendMessage("Je bent nu VIP op de server.");
}else {
p.sendMessage("fout");
saveConfig();
}
}
}
}
}







return false;
}












}

Planet Minecraft

Browse

Site

© 2010 - 2019
planetminecraft.com

Welcome