如何修复自定义craftbukkit 1.9.4插件的代码?

时间:2016-05-13 00:33:47

标签: java plugins minecraft bukkit

使用crackbukkit 1.9.4下载插件我做错了什么。 预期的插件应该加载实际的插件似乎没有加载或nore命令通过。

预期:插件加载和/ isbammadyet等可用命令也是isbammadyet的帮助

实际:插件根本没有加载

plugin.yml文件

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

类文件

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;
}
}

1 个答案:

答案 0 :(得分:1)

好的,我认为这应该有效:

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;
}

如果仍然无效,请告诉我;)

编辑: 现在我为你写了它并将其上传到我的服务器: >>Klick>>

我不知道我将文件放在服务器上有多长,所以要快; D 您可以运行插件direkt,但我也将资源放在.jar中,这样您只需要提取它(7ZIP或WinRAR?!),如果您想编辑它。

编辑#2:编辑#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();
}

小心!我编辑了包,但代码本身应该可以工作!