复制代码
- package com.hxj;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.java.JavaPlugin;
- public class jac extends JavaPlugin
- {
- public void onEnable()//貌似是插件在开启的时候总是要初始化需要用的
- {
- getLogger().info("插件已加载");//向后台发送信息
- }
- public boolean cnCommand(CommandSender sender,Command cmd,String label,String[] args)
- {
- if(label.equalsIgnoreCase("jac"))
- {
- if(args.length==0)
- {
- sender.sendMessage("§a/jac me 信息");
- sender.sendMessage("§a/jac kill 自杀");
- sender.sendMessage("§a/jac m [玩家名] [信息] 发送信息");
- return true;
- }
- }
- if(args [0].equalsIgnoreCase("me"))
- {
- if(sender instanceof Player)//如果sender 是由玩家执行的,则执行
- {
- sender.sendMessage("§a测试.........");//sender 为命令的发送者,可以是玩家也可以是控制台
- return true; //返回值
- }
- sender.sendMessage("§a该命令只能由玩家执行");//否则返回信息
- return true; //返回值
- }
- if(args [0].equalsIgnoreCase("kill")) //判断信息,equalsIgnoreCase忽略大小写
- {
- if(sender instanceof Player) //如果sender 是由玩家执行的,则执行
- {
- Player player=(Player)sender; //Player为玩家变量,player为变量名,(Player)sender 为强制转换
- player.setHealth(0.0); //设置生命值
- player.sendMessage("§a你自杀了!"); //提示信息
- return true; //返回值
- }
- sender.sendMessage("§a该命令只能由玩家执行"); //否则返回信息
- return true; //返回值
- }
- if(args [0].equalsIgnoreCase("m"))
- {
- if(!(sender instanceof Player))//当sender instanceof Player发送者不是player时则继续
- {
- if(args.length>3)
- {
- sender.sendMessage("§a参数过长!");
- return true;
- }
- if(args.length<3)
- {
- sender.sendMessage("§a参数过短!");
- return true;
- }
- Player p=getServer().getPlayer(args[1]);//getServer().getPlayer(args[1])为在服务器中搜索关键词为X名字的玩家
- if(p==null)
- {
- sender.sendMessage("§a玩家不存在,发送消息失败");
- return true;
- }
- p.sendMessage(args[2].replaceAll("&","§"));
- sender.sendMessage("§a给"+p.getName()+"的信息发送成功");
- return true;
- }
- sender.sendMessage("§a该命令只能由玩家进行");
- return true;
- }
- return false;
- }
- }
复制代码
- 22:46:29 [信息] This server is running CraftBukkit version git-Bukkit-1.6.4-R2.0
- -b2918jnks (MC: 1.6.4) (Implementing API version 1.6.4-R2.0)
- 22:46:30 [严重] Could not load 'plugins\jac.jar' in folder 'plugins'
- org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
- at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPlug
- inLoader.java:257)
- at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
- .java:132)
- at org.bukkit.craftbukkit.v1_6_R3.CraftServer.loadPlugins(CraftServer.ja
- va:241)
- at org.bukkit.craftbukkit.v1_6_R3.CraftServer.<init>(CraftServer.java:21
- 9)
- at net.minecraft.server.v1_6_R3.PlayerList.<init>(PlayerList.java:56)
- at net.minecraft.server.v1_6_R3.DedicatedPlayerList.<init>(SourceFile:11
- )
- at net.minecraft.server.v1_6_R3.DedicatedServer.init(DedicatedServer.jav
- a:107)
- at net.minecraft.server.v1_6_R3.MinecraftServer.run(MinecraftServer.java
- :393)
- at net.minecraft.server.v1_6_R3.ThreadServerApplication.run(SourceFile:5
- 83)
- Caused by: while scanning for the next token
- found character '\t' that cannot start any token
- in "<reader>", line 5, column 1:
- jac:
- ^
- at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.ja
- va:358)
- at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:17
- 9)
- at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingValue.produce(P
- arserImpl.java:591)
- at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:161)
- at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:146)
- at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:133)
- at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java
- :237)
- at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:160)
- at org.yaml.snakeyaml.composer.Composer.composeDocument(Composer.java:12
- 3)
- at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:106)
- at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseCons
- tructor.java:121)
- at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:480)
- at org.yaml.snakeyaml.Yaml.load(Yaml.java:411)
- at org.bukkit.plugin.PluginDescriptionFile.<init>(PluginDescriptionFile.
- java:188)
- at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPlug
- inLoader.java:252)
- ... 8 more
2014-06-14 22:48:00
qiu1995 发表于 2014-6-14 22:48
大神你好,这是我写的源码,但是放到服务器中运行弹出这些错误。望过目
源码
2014-06-14 22:49:00
qiu1995 发表于 2014-6-14 22:49
= =惨……本来想折叠的,用错成引用了……见谅……
2014-06-14 22:52:00
810587921 发表于 2014-6-14 22:52
别用TAB的空格,用普通的空格
commands:
jac: (这里2个空格)
2014-06-15 00:25:00
qiu1995 发表于 2014-6-14 22:48
大神你好,这是我写的源码,但是放到服务器中运行弹出这些错误。望过目
源码
2014-08-04 13:45:00
810587921 发表于 2014-8-23 16:23
代码发来看看?
2014-08-23 19:16:00
2014-08-23 19:29:00
ylyangzhe 发表于 2014-8-23 19:29
大神,我想问下传送到一个玩家,然后十秒后又返回原地的代码怎么写,或者有没有什么bukkit句式的百科之类的 ...
2014-08-23 19:34:00
810587921 发表于 2014-8-23 19:34
Location l=player1.getLocation();
player1.teleport(player2);
new X(player1,l).start();
2014-08-24 11:35:00
810587921 发表于 2014-8-23 19:34
Location l=player1.getLocation();
player1.teleport(player2);
new X(player1,l).start();
2014-08-24 11:55:00
ylyangzhe 发表于 2014-8-24 11:55
话说有些player1,player2还有teleport无法解析怎么办?
2014-08-24 16:15:00
ylyangzhe 发表于 2014-8-24 19:33
= = 我怎么想= =
2014-08-24 19:35:00
810587921 发表于 2014-8-24 19:35
onCommand(......)
{
Player player1=(Player)sender;
2014-08-25 09:47:00
2014-10-04 19:49:00
钻石荣耀 发表于 2014-10-4 19:49
player.setHealth(0);
再给玩家设置生命值的时候
需要强制转换类型
2014-10-04 22:28:00
痴醉年华。 发表于 2014-11-5 08:18
楼主,我多次尝试,都无法在游戏内使用命令
直接复制主类,在游戏内都无法使用命令(能够加载插件)
2014-11-05 12:22:00
2015-04-03 18:37:00
2015-07-26 11:10:00
2015-08-06 21:02:00
2015-08-06 21:02:00
2016-02-05 22:04:00
2016-07-08 14:55:00
2892741402 发表于 2016-7-8 14:55
大神,怎么回事啊??
[02:59:11 ERROR]: Could not load 'plugins\JC.jar' in folder 'plugins'
org.bukki ...
2016-07-08 18:22:00
2016-07-09 16:41:00
2892741402 发表于 2016-7-9 16:41
大神,我复习了一下,这又咋了
[04:44:36 ERROR]: Could not load 'plugins\JC.jar' in folder 'plugins'
o ...
2016-07-09 17:56:00
2018-12-11 18:11:00