macOS Mojave Version: 10.14.6
Macbook Pro (15-inch, 2018) Processor: 2.2GHz Intel Core i7 Memory: 16GB 2400MHz DDR4 Boot disk: Macintosh HD Graphics: Radeon Pro 555X 4GB Intel UHD Graphics 630 1536MB
Access the Download Site. Then you should be able to access the following sites. For the time being, I chose the latest version.
Next, install the full Edition
of Java
in this.
It seems that there is no problem with Standard Edition
, but I used full Edition
because there is no reason to select it.
However, for some reason it was played by Mac security, so I solved it by referring to the following site. (Maybe the latest version of Eclipse wasn't authenticated to the Mac?) Mac-Allow all applications to run (https://pc-karuma.net/macos-sierra-allow-apps-from-anywhere/)
First, select File-> New-> Maven Project
.
Then, the following screen will be displayed. Put a chuck in "Create a single project (skip architecture selection)" and click "Next>".
Next is the screen for entering project information. (Qiita is just my typo ...) "Group Id" is the name of the creator. "Artif Id" is the project name = plugin name. You can name it as you like. "Version" is the version number. You can name this as you like. Set these three. Others should not need to be changed.
This completes the project creation!
pon.xml
Next, we will make the settings for setting the plug-in. Here, prepare "what you need (dependency)". I think this is the initial state.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.kubota</groupId>
<artifactId>QiitaSample</artifactId>
<version>1.0.0</version>
</project>
The settings related to spigot are described here.
You can use'Bukkit API'by adding spigot-repository
and Spigot-API
as shown below.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.kubota</groupId>
<artifactId>QiitaSample</artifactId>
<version>1.0.0</version>
<!-- ↓ Spigot-repository -->
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<!-- ↓ Spigot-API -->
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<!-- ↓ (Minecraft version)-R0.1-SNAPSHOT -->
<version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
However, this alone will not work depending on the version of Minecraft, so describe the properties as follows.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.kubota</groupId>
<artifactId>QiitaSample</artifactId>
<version>1.0.0</version>
<!-- ↓ Spigot-repository -->
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<!-- ↓ Spigot-API -->
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<!-- ↓ (Minecraft version)-R0.1-SNAPSHOT -->
<version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<!--↓ Property setting-->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- ↓ Java version 12 -->
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>
</project>
Also, at present, change as follows to facilitate cooperation with plugin.yml
which will be added later.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.kubota</groupId>
<artifactId>QiitaSample</artifactId>
<version>1.0.0</version>
<!-- ↓ Spigot-repository -->
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<!-- ↓ Spigot-API -->
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<!-- ↓ (Minecraft version)-R0.1-SNAPSHOT -->
<version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<!--↓ Property setting-->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- ↓ Java version 12 -->
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>
<!-- plugin.yml pom.Link with xml-->
<build>
<resources>
<resource>
<targetPath>.</targetPath>
<filtering>true</filtering>
<directory>src/main/resources/</directory>
</resource>
</resources>
</build>
</project>
This completes the change of pom.xml
.
The dependency has changed a little due to the change of pom.xml
, so it is necessary to update it.
As a method, right-click the created project (QiitaSample
is applicable on my screen) and select it in the order of Maven-> Update project
.
This will start updating the dependencies (it didn't take long).
Then you will see the following screen. (In the case of the author, there are projects created before, but if it is the first creation, there will be only one) Chuck the project created this time to this and press OK, This completes the update!
Now that the Bukkit API dependencies have been set, you can start creating the Plugin itself.
Right-click on src / main / java
under the created project and select" New "->" Package ".
Next, let's use the package name ** which is the group ID and the plug-in name connected by. (Dot) **.
In the case of the author, the group ID is com.github.kubota
and the plugin name is QiitaSample
, which is com.gtihub.kubota.qiitasample
.
Some changes are due to the fact that this package name cannot be used in uppercase letters, so it is replaced with lowercase letters, and since -
(hyphen) cannot be used, it is replaced with _
(underscore).
Then right-click on the created package and select "New"-> "Class".
Then, the following screen will be displayed, so let's enter the class name that will bloom there.
The name can be anything, but for the sake of clarity, let's use the current project name or Main
.
(It is also my typo that Qiita here is QIita ...)
When you open it, it should look like this:
package com.github.kubota.qiitasample;
public class QIitaPlugin {
}
Let's change this as follows.
package com.github.kubota.qiitasample;
import org.bukkit.plugin.java.JavaPlugin;
public class QIitaPlugin extends JavaPlugin{
//↓ onEnable is a method that is executed when it is loaded
@Override
public void onEnable() {
//↓ Leave a log on the server
getLogger().info("Hello, Qiita!");
}
}
Then, I will explain each changed part one by one.
import org.bukkit.plugin.java.JavaPlugin;
This line imports the functionality needed to create a plugin
.
public class QIitaPlugin extends JavaPlugin{
With ʻexetends JavaPlugin` added at this point, it is possible to create by adding functions to the class in which the basic functions of Minecraft are already implemented.
public class QIitaPlugin extends JavaPlugin{
//↓ onEnable is a method that is executed when it is loaded
@Override
public void onEnable() {
//↓ Leave a log on the server
getLogger().info("Hello, Qiita!");
}
}
Here is a brief explanation of the ʻonEnablemethod. The place called
@Override indicates that the method in the
Javaplugin class is overridden. The overwrite target is the ʻonEnable
method.
The ʻonEnable` method is a method that is automatically executed when the plugin is enabled.
The processing here has no function as long as it is not overwritten.
So, as an overwrite process, add something called "Hello, Qiita!" To the console with the'getLogger (). Info ()' method. By this overwrite process, it became a method with a function called ** that automatically displays "Hello, Qiita!" On the console when the plug-in is enabled.
Right-click on src / main / resources
and select New> File.
Then create a file named plugin.yml
.
If the following four are described.
name: "Main class"
version: "version"
main: "Main class"
api-version: "Bukkit API version""
name
describes the plug-in name.
version
is the version of the plugin. However, this version is OK if you write $ {project.version}
because plugin.yml
is linked with pom.xml
this time.
main
describes the package name of the main class and the class name connected by dots.
ʻApi-version` is not strictly required, but it is almost required, so let's mention it.
This lists the supported Bukkit API version. For example, 1.13 or 1.13.2 is 1.13, 1.14 or 1.14.2 is 1.14, and so on.
name: "QiitaSample"
version: "${project.version}"
main: "com.github.kubota.qiitasample.QiitaSample"
api-version: "1.13"
This almost completes the implementation. All you have to do is compile. To do this, right-click on the project name and select "Run"-> "Maven install".
When you do this, the results will be displayed on the console screen.
If BUILD SUCCESS
is displayed, it is successful.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.762 s
[INFO] Finished at: 2019-08-12T21:15:44+09:00
[INFO] ------------------------------------------------------------------------
Then the Jar
file should be added to terget
.
If you add this Jar
file to Plugins
of the server directory that was originally created and execute it, Plugin will start working.
(The plugin name is QiitaTest
due to various reasons, but I confirmed that it works normally by the above procedure.)
That is the end of this content. I developed the plug-in under the Mac environment, but I think that it will be helpful because the usage of Eclipse itself is the same for Windows. (Although the button layout may be slightly different ...)
Accept the [MineCraft plugin] command and raise an event
name: "SampleProject"
version: "${project.version}"
main: "com.github.kubota.sampleproject.SampleProject"
api-version: "1.13"
Although it is described in plugin.yml
of the main part.
I misunderstood that there is no problem with only the package name in this main
place, and described it as follows.
name: "SampleProject"
version: "${project.version}"
main: "com.github.kubota.sampleproject"
api-version: "1.13"
As a result, the SampleProject
file could not be referenced and the following error was thrown.
[16:11:39 ERROR]: Could not load 'plugins/SampleProject' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: Cannot find main class `com.github.kubota.sampleproject'
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:62) ~[spigot-1.13.2.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:135) ~[spigot-1.13.2.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:332) ~[spigot-1.13.2.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:252) [spigot-1.13.2.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.craftbukkit.v1_13_R2.CraftServer.loadPlugins(CraftServer.java:325) [spigot-1.13.2.jar:git-Spigot-1a3504a-dfa7583]
at net.minecraft.server.v1_13_R2.DedicatedServer.init(DedicatedServer.java:213) [spigot-1.13.2.jar:git-Spigot-1a3504a-dfa7583]
at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:698) [spigot-1.13.2.jar:git-Spigot-1a3504a-dfa7583]
at java.lang.Thread.run(Thread.java:835) [?:?]
Caused by: java.lang.ClassNotFoundException: com.github.kubota.projectsample
at java.net.URLClassLoader.findClass(URLClassLoader.java:436) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:136) ~[spigot-1.13.2.jar:git-Spigot-1a3504a-dfa7583]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:82) ~[spigot-1.13.2.jar:git-Spigot-1a3504a-dfa7583]
at java.lang.ClassLoader.loadClass(ClassLoader.java:588) ~[?:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[?:?]
at java.lang.Class.forName0(Native Method) ~[?:?]
at java.lang.Class.forName(Class.java:415) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:60) ~[spigot-1.13.2.jar:git-Spigot-1a3504a-dfa7583]
... 7 more
-Creating a Bukkit project Eclipse -[Bukkit plug-in production course-No. 2] Main class creation and build -[For super beginners] Maven super introduction -[Minecraft](for Java inexperienced people) Bukkit / Spigot compatible plug-in making course [Preparation] -Set up a multi-server with Minecraft! (Think IT Books)
Recommended Posts