flyingscot5 flyingscot5 - 6 months ago 10
Java Question

How to repair the code for a custom craftbukkit 1.9.4 plugin?

What did I do wrong it download the plugin using crackbukkit 1.9.4.
Expected Plugin should load up actual plugin does not seem to load or nore does the command go through.

Expected: plugin load and a command available such as /isbammadyet also a help for isbammadyet

Actual: plugin does not load in at all

plugin.yml file

main:is.bamboo0w.mad.yet
version: 6.9
name: Bam Mad Yet

commands:
isbammadyet:
description: Tells you how mad Bamboo0w is Right NOW!.
Also helps with luck! <br>
XD


classfile

package is.bamboo0w.mad.yet;

import java.util.logging.Logger;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;

public class mad extends JavaPlugin {

public void onEnable() {
PluginDescriptionFile pdfFile = getDescription();
Logger logger = getLogger();

logger.info(pdfFile.getName() + " has been Enabled! (V." + pdfFile.getVersion() + ")");
}

public void onDisable() {
PluginDescriptionFile pdfFile = getDescription();
Logger logger = getLogger();

logger.info(pdfFile.getName() + " has been Disabled! (V." + pdfFile.getVersion() + ")");
}

public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("You must be a player to use this command");
return false;
}

int score = 0;

score = score + 1;

if (score <= 1) {
Player player = (Player) sender;
player.sendMessage(ChatColor.AQUA + "Gimme A Kiss, " + player.getName() + "!");
}
else if (score <= 2) {
Player player = (Player) sender;
player.sendMessage(ChatColor.AQUA + "Want Some Burick, " + player.getName() + "!");
}
else if (score <= 3) {
Player player = (Player) sender;
player.sendMessage(ChatColor.AQUA + "Stop Scamming, " + player.getName() + "!");
}
else if (score <= 4) {
Player player = (Player) sender;
player.sendMessage(ChatColor.AQUA + "Are You Duping There " + player.getName() + "!");
}
else if (score <= 5) {
Player player = (Player) sender;
player.sendMessage(ChatColor.AQUA + "I'm Watching You, " + player.getName() + "!");
}
else if (score <= 6) {
Player player = (Player) sender;
player.sendMessage(ChatColor.AQUA + "Coming For You, " + player.getName() + "!");
}
else if (score <= 7) {
Player player = (Player) sender;
player.sendMessage(ChatColor.AQUA + "I'm Gonna PK You, " + player.getName() + "!");
}
else if (score <= 8) {
Player player = (Player) sender;
player.sendMessage(ChatColor.AQUA + "Your Gonna Get Banned, " + player.getName() + "!");
}
else {
score = 0;
}
return true;
}
}

Answer

Okay I think this should work:

plugin.yml

main: is.bamboo0w.mad.yet.mad
version: 6.9
author: flyingscot5
name: Bam Mad Yet

commands:
  isbammadyet:
    description: Tells you how mad Bamboo0w is Right NOW!. Also helps with luck! XD

mad.java

package is.bamboo0w.mad.yet;

import java.util.logging.Logger;

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 mad extends JavaPlugin {

@Override
public void onEnable() {
    PluginDescriptionFile pdfFile = getDescription();
    Logger logger = getLogger();

    logger.info(pdfFile.getName() + " has been Enabled! (V." + pdfFile.getVersion() + ")");
}

@Override
public void onDisable() {
    PluginDescriptionFile pdfFile = getDescription();
    Logger logger = getLogger();

    logger.info(pdfFile.getName() + " has been Disabled! (V." + pdfFile.getVersion() + ")");
}


public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!(sender instanceof Player)) {
        sender.sendMessage("You must be a player to use this command");
        return false;
    }
    int score = 0;
    score++;
    Player player = (Player) sender;
    if (score <= 1) {
        player.sendMessage(ChatColor.AQUA + "Gimme A Kiss, " + player.getName() + "!");
    } else if (score <= 2) {
        player.sendMessage(ChatColor.AQUA + "Want Some Burick, " + player.getName() + "!");
    } else if (score <= 3) {
        player.sendMessage(ChatColor.AQUA + "Stop Scamming, " + player.getName() + "!");
    } else if (score <= 4) {
        player.sendMessage(ChatColor.AQUA + "Are You Duping There " + player.getName() + "!");
    } else if (score <= 5) {
        player.sendMessage(ChatColor.AQUA + "I'm Watching You, " + player.getName() + "!");
    } else if (score <= 6) {
        player.sendMessage(ChatColor.AQUA + "Coming For You, " + player.getName() + "!");
    } else if (score <= 7) {
        player.sendMessage(ChatColor.AQUA + "I'm Gonna PK You, " + player.getName() + "!");
    } else if (score <= 8) {
        player.sendMessage(ChatColor.AQUA + "Your Gonna Get Banned, " + player.getName() + "!");
    } else {
        score = 0;
    }
    return true;
}

If it still doesn't work just tell me ;)

EDIT: Now I wrote it for you and uploaded it to my Server: >>Klick>>

I don't know how Long I will let the file on the Server, so be fast ;D You can run the plugin direkt but I also put the resources in the .jar so you only have to extract it (7ZIP or WinRAR?!) if you want to edit it.

EDIT #2: plugin.yml

name: Bam Mad Yet
author: flyingscot5
version: 6.9
description: Tells you how mad Bamboo0w is Right NOW!. Also helps with luck! XD
main: me.flyingscot5.bam_mad_yet.Main

commands:
  isbammadyet:

main.java

package me.flyingscot5.bam_mad_yet;

import java.util.HashMap;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public class main extends JavaPlugin{

public static main getPlugin() {
    return plugin;
}

private static main plugin;
public static HashMap<Player, Integer> scores;

@Override
public void onEnable() {
    plugin = this;
    scores = new HashMap<Player, Integer>();
    new L_PlayerQuit(this);
    getCommand("isbammadyet").setExecutor(new C_isbammadyet());
    Bukkit.getConsoleSender().sendMessage("\2476Bam Mad Yet \247awas loaded!!!");
}

@Override
public void onDisable() {
    Bukkit.getConsoleSender().sendMessage("\2476Bam Mad Yet \247awas unloaded!!!");
}
}

C_isbammadyet.java

package me.flyingscot5.bam_mad_yet;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;

public class C_isbammadyet implements TabExecutor {

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player)) {
        sender.sendMessage("You must be a player to use this command");
    }
    Player player = (Player) sender;
    if (!main.scores.containsKey(player)) {
        main.scores.put(player, 0);
    }
    int score = main.scores.get(player);
    score += new Random().nextInt(3);
    if (score <= 1) {
        player.sendMessage(ChatColor.AQUA + "Gimme A Kiss, " + player.getName() + "!");
    } else if (score <= 2) {
        player.sendMessage(ChatColor.AQUA + "Want Some Burick, " + player.getName() + "!");
    } else if (score <= 3) {
        player.sendMessage(ChatColor.AQUA + "Stop Scamming, " + player.getName() + "!");
    } else if (score <= 4) {
        player.sendMessage(ChatColor.AQUA + "Are You Duping There " + player.getName() + "!");
    } else if (score <= 5) {
        player.sendMessage(ChatColor.AQUA + "I'm Watching You, " + player.getName() + "!");
    } else if (score <= 6) {
        player.sendMessage(ChatColor.AQUA + "Coming For You, " + player.getName() + "!");
    } else if (score <= 7) {
        player.sendMessage(ChatColor.AQUA + "I'm Gonna PK You, " + player.getName() + "!");
    } else if (score <= 8) {
        player.sendMessage(ChatColor.AQUA + "Your Gonna Get Banned, " + player.getName() + "!");
    } else {
        score = 0;
    }
    main.scores.replace(player, score);
    return true;
}

@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
    List<String> nothing = new ArrayList<String>();
    nothing.add("");
    return nothing;
}
}

L_PlayerQuit.java

package me.flyingscot5.bam_mad_yet;

import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;

public class L_PlayerQuit implements Listener {
public L_PlayerQuit(main main) {
    plugin = main;
    plugin.getServer().getPluginManager().registerEvents(this, main);
}

@EventHandler
public static void onPlayerQuit(PlayerQuitEvent ev) {
    if (main.scores.containsKey(ev.getPlayer())) {
        main.scores.remove(ev.getPlayer());
    }
}

main plugin = main.getPlugin();
}

Watch out! I've edited the packages but the Code itself should work!