- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试为 minecraft bukkit 服务器创建一个插件。目标是读取 html 页面第一行的字符串。如果结果为真,它将执行命令。
这是我现在的代码:
import java.net.URLConnection;
import java.util.Scanner;
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.java.JavaPlugin;
public class main extends JavaPlugin{
public final Logger logger = Logger.getLogger("Minecraft");
public void onEnable(){
logger.info("[First] Has Been Enabled.");
}
public void onDisable(){
logger.info("[First] Has Been Disabled.");
}
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
Player player = (Player) sender;
if(commandLabel.equalsIgnoreCase("hello")){
player.sendMessage(ChatColor.GOLD + "Hello");
}
else if(commandLabel.equalsIgnoreCase("world")){
player.sendMessage(ChatColor.GOLD + "World");
}
else if(commandLabel.equalsIgnoreCase("coolman")){
player.setPlayerListName("coolman");
}
else if(commandLabel.equalsIgnoreCase("vote")){
String sourceLine = null;
// The URL address of the page to open.
URL address = new URL("http://www.koolflashgames.com/test.php");
// Open the address and create a BufferedReader with the source code.
InputStreamReader pageInput = new InputStreamReader(address.openStream());
BufferedReader source = new BufferedReader(pageInput);
// Append each new HTML line into one string. Add a tab character.
try {
sourceLine = source.readLine();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(sourceLine == "False"){
player.sendMessage("Thanks for voting!");
}
}
return false;
}
在日志中创建以下错误:
2012-11-02 16:18:30 [SEVERE] null
org.bukkit.command.CommandException: Unhandled exception executing command 'vote' in plugin first v1.0
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:180)
at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:502)
at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.java:915)
at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:828)
at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:810)
at net.minecraft.server.Packet3Chat.handle(Packet3Chat.java:44)
at net.minecraft.server.NetworkManager.b(NetworkManager.java:282)
at net.minecraft.server.NetServerHandler.d(NetServerHandler.java:111)
at net.minecraft.server.ServerConnection.b(SourceFile:35)
at net.minecraft.server.DedicatedServerConnection.b(SourceFile:30)
at net.minecraft.server.MinecraftServer.q(MinecraftServer.java:561)
at net.minecraft.server.DedicatedServer.q(DedicatedServer.java:213)
at net.minecraft.server.MinecraftServer.p(MinecraftServer.java:474)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:406)
at net.minecraft.server.ThreadServerApplication.run(SourceFile:539)
Caused by: java.lang.NullPointerException
at java.io.Reader.<init>(Unknown Source)
at java.io.InputStreamReader.<init>(Unknown Source)
at me.storminmormon30.first.main.onCommand(main.java:43)
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
... 15 more
最佳答案
看起来错误出在其他地方:执行命令“投票”时出现未处理的异常
我在您提供的代码片段中没有看到该命令
关于java - 在 Bukkit 插件中从网页获取 HTML 字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13204577/
我在使用 bukkit 可运行程序时遇到了一些问题。我试图让它工作,但它只会向我抛出错误。这就是我想要的 public class FlyE implements Listener { @Even
今天我正在尝试制作一个插件,它可以生成一匹骷髅马,并且马周围有火焰粒子。我把那部分拿下来了,但是每当有人杀死骨马时,火粒子就会留在那里。有人请帮忙吗? 还有我的代码(2类): package surv
在 Maven 中找不到 groudID、artifactId 和 version 依赖项? 我关注了this设置使用 Maven 的 Minecraft 插件的教程。 但我收到错误 org.bukk
我是 bukkit/spigot 的新手,我正在制作一个插件,玩家可以在其中键入命令“/sign”,然后会在玩家旁边创建一个附在木 block 上的标志。该标志将显示“你好 PlayerName”。但
我有一个玩家,当然能够以矢量形式捕获玩家面对的方向。 使用这个向量,我需要计算玩家是否正在查看 x 内的实体。块,如果“咒语”会击中它。我还需要考虑实体前面是否有任何东西。 到目前为止,我的思考过程是
本文整理了Java中org.bukkit.WorldBorder类的一些代码示例,展示了WorldBorder类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等
我正在尝试制作一个插件来消除 Minecraft 中的饥饿感。但是,我找不到它的事件! 是否有玩家失去饥饿感时调用的事件? 类似 PlayerHungerChangeEvent 的东西? 最佳答案 我
我正在尝试在 bukkit 插件内打开一个套接字,以便我可以使用 php 或 Node 向其发送数据,但套接字在使用一次后不会保持打开状态,而是关闭,并且在发生这种情况之前服务器不会加载,我应该做什么
我有这个可能有错误的代码片段: @EventHandler public void onPlayerInteract(PlayerInteractEvent e) { if (e.getAct
已修复 我正在尝试在我的实体名称旁边添加一个健康栏,例如: 3级骷髅|||| 其中的栏表示生命值,满分 5。我似乎已经尝试了一切,但我无法弄清楚!我认为这很简单,但我就是无法理解...... @Eve
我正在制作一个小游戏。如果有2名玩家在线,则开始倒计时。我正在用我的 2 个帐户进行测试。当1个帐户登录时,我会得到一把钻石剑。没关系。但是当我使用第二个帐户登录时,倒计时不会开始,并且出现错误。我不
我正在尝试同时学习 Java 和 Bukkit(几个月前我已经学习了一些基本的 Java 并制作了一个简单的文本游戏)。 我知道当我使用 1 个类时我在做什么,但是,正如你可能知道的那样,一切都变得困
我正在尝试查看玩家的库存中是否有以下任何元素,如果有,我想删除这些元素并向他们发送一条消息,说明该元素已被删除,但我不知道如何为此,这就是我到目前为止所拥有的: Material[] bann
所以我有这个代码: vector 速度=playerA.getVelocity(); playerB.setVelocity(vel); 这为玩家 B 提供了玩家 A 的速度。问题是玩家 B 经常与玩
首先,我是 Java 新手。这是我的第一个 bukkit 插件,唯一的错误是这个( Click Here )。该插件的目标是,当您右键单击“基岩 splinter 机”时,它会破坏基岩。 packag
所以我正在为我的服务器创建一个踢/禁止命令,格式为/踢名称原因。我一切正常,但 原因 只能是 1 个单词,除此之外的任何内容,例如 /kick BattleDash hello world 会说 Ba
我想创建新项目。我称之为生命 Crystal 。我还为这个新项目创建了新配方。我的问题是,当我尝试制作该元素时,我制作了普通元素,没有新的显示名称和结界。我的代码如下所示。 // Life Crys
如果我在选定的世界中选择了一个位置,并且在该位置周围有一个“安全区”,该区域延伸 500 个街区(创建一个圆圈)(这意味着玩家可以在该位置的 500 个街区内并且是“安全的”) ”)。如何找到从玩家位
我目前正在创建一个利用分配器的插件。我在监听器中有一个 while 循环,应该从分配器的库存中删除一 block 煤炭,直到没有剩余的煤炭可以打破循环。它精细循环并记录用于表示煤炭数量的整数的倒计时。
在 for 循环中,我的目标是伤害其他未被伤害的玩家。因此,我创建了一个新事件,其原因是自杀,这样当它对玩家造成伤害时,就不会再次调用此方法,最终杀死玩家。我进行了研究,发现有关调用新实体损坏事件的信
我是一名优秀的程序员,十分优秀!