Reputation: 11
Need help on minecraft spigot plugin.
this is the layout (or build path if you want to call it that)
Here is the code for the main file (main.java)
package com.angosa;
import org.bukkit.plugin.java.JavaPlugin;
import com.angosa.listener.Listeners;
public class Main extends JavaPlugin {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(new Listeners(), this);
}
}
Here is the code for the listeners.java (which is in the listener package)
package com.angosa.listener;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
public class Listeners implements Listener {
@EventHandler
public void creatureSpawn(CreatureSpawnEvent event) {
if(event.getEntityType() == EntityType.CREEPER) {
Creeper creeper = (Creeper) event.getEntity();
creeper.setPowered(true);
creeper.setHealth(100);
creeper.setExplosionRadius(200);
}
}
}
and then here is the yml file
main: com.angosa.Main
name: OPCreeper
version: 1.0
author: Claim
also, in case that the version is wrong, here's what it looks like when I upload it onto a server.
[18:06:11 ERROR]: Could not load 'plugins/OPCreeper.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:170) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236] at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:144) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236] at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:383) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236] at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:185) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236] at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:808) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236] at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:164) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236] at java.lang.Thread.run(Thread.java:832) [?:?] Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning for the next token found character '\t(TAB)' that cannot start any token. (Do not use \t(TAB) for indentation) in 'reader', line 7, column 1:
^
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:419) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:227) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingKey.produce(ParserImpl.java:558) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:148) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:235) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:162) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.yaml.snakeyaml.composer.Composer.getNode(Composer.java:95) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:119) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:150) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:472) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.yaml.snakeyaml.Yaml.load(Yaml.java:411) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.bukkit.plugin.PluginDescriptionFile.<init>(PluginDescriptionFile.java:252) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:165) ~[spigot-1.16.4.jar:git-Spigot-37d799b-3eb7236]
... 6 more
Upvotes: 0
Views: 856
Reputation: 77
It's great that you are starting with spigot development!
The problem with your plugin is that you are using the wrong format in your plugin.yml file. It seems that on line 7 you are using a TAB instead of a space. I suggest looking at this help page https://www.spigotmc.org/wiki/plugin-yml/ for help on finding the correct format!
Good luck :)
Upvotes: 1
Reputation: 148
Do not use Tabs in YAML Files like plugin.yml use Spaces instead
Upvotes: 0
Reputation: 91
I see the problem in the first console line:
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
And at the end you can see:
(Do not use \t(TAB) for indentation)
In my opinion, you just have to:
*For me, it looks like your "main" value in the plugin.yml file was:
main: com.angosa.Main.OPCreeper
but as you send in this thread, the proper value is:
com.angosa.Main
so don't forget saving before to export your plugin, i'm not sure at all but it may be the problem.*
To show you, there is an exemple of plugin i'm working in :
https://i.sstatic.net/55JVe.png : Package Explorer & plugin.yml https://i.sstatic.net/TiWpN.png : Main class
(OrbeDisplay.java = Main.java in this case)
If it doesn't works after this, I will search for another solution, so keep me posted.
Sorry for my bad English, I come from France and I just started to learn.
Upvotes: 5