提供: Minecraft Modding Wiki
この編集を取り消せます。
下記の差分を確認して、本当に取り消していいか検証してください。よろしければ変更を保存して取り消しを完了してください。
最新版 | 編集中の文章 | ||
36行目: | 36行目: | ||
Pleiadesを利用する場合、「開発対象用 JDK」と、ビルドツールMavenが実行できるプラグイン「m2e」が同梱されているものを選択してください。<br/> | Pleiadesを利用する場合、「開発対象用 JDK」と、ビルドツールMavenが実行できるプラグイン「m2e」が同梱されているものを選択してください。<br/> | ||
− | (Eclipseを既に利用している場合でも、m2eを後から追加インストールすることは可能です。) | + | (Eclipseを既に利用している場合でも、m2eを後から追加インストールすることは可能です。)<br/> |
− | + | 以下、m2eが既に導入されている前提で説明します。 | |
− | |||
− | |||
− | |||
− | |||
− | |||
== Plugin用プロジェクトを始めるために == | == Plugin用プロジェクトを始めるために == | ||
100行目: | 95行目: | ||
[[Image:create_project4.png]] | [[Image:create_project4.png]] | ||
− | + | まず、Java実行環境(JRE)の参照設定をします。<br/> | |
一番最後の行に '''</project>''' というタグがありますが、その1行上に、次の内容を挿入してください。<br/> | 一番最後の行に '''</project>''' というタグがありますが、その1行上に、次の内容を挿入してください。<br/> | ||
− | (なお、これは Java 7 を参照してビルドするための設定です。もし Java 6 を参照してビルドしたい場合は、sourceタグとtargetタグに書かれている 1.7 のところを 1.6 | + | (なお、これは Java 7 を参照してビルドするための設定です。もし Java 6 を参照してビルドしたい場合は、sourceタグとtargetタグに書かれている 1.7 のところを 1.6 に変更してください。) |
− | < | + | <code> |
<build> | <build> | ||
<plugins> | <plugins> | ||
111行目: | 106行目: | ||
<artifactId>maven-compiler-plugin</artifactId> | <artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | <configuration> | ||
− | <source>1.7</source> | + | <nowiki><</nowiki>source>1.7</source> |
<target>1.7</target> | <target>1.7</target> | ||
</configuration> | </configuration> | ||
117行目: | 112行目: | ||
</plugins> | </plugins> | ||
</build> | </build> | ||
− | </ | + | </code> |
− | + | 次に、BukkitリポジトリのURL設定を追加します。<br/> | |
下記の内容を追記してください。 | 下記の内容を追記してください。 | ||
− | < | + | <code> |
<repositories> | <repositories> | ||
<repository> | <repository> | ||
− | <id> | + | <id>bukkit-repo</id> |
− | <url> | + | <url>http://repo.bukkit.org/content/groups/public/</url> |
</repository> | </repository> | ||
</repositories> | </repositories> | ||
− | </ | + | </code> |
最後に、Bukkit API の参照設定を追加します。<br/> | 最後に、Bukkit API の参照設定を追加します。<br/> | ||
下記の内容を追記してください。 | 下記の内容を追記してください。 | ||
− | < | + | <code> |
<dependencies> | <dependencies> | ||
<dependency> | <dependency> | ||
<groupId>org.bukkit</groupId> | <groupId>org.bukkit</groupId> | ||
<artifactId>bukkit</artifactId> | <artifactId>bukkit</artifactId> | ||
− | <version>1. | + | <version>1.7.9-R0.2</version> |
</dependency> | </dependency> | ||
</dependencies> | </dependencies> | ||
− | </ | + | </code> |
− | この設定では、Bukkit API 1. | + | この設定では、Bukkit API 1.7.9-R0.2 が参照されます。<br/> |
別のバージョンを参照したい場合は、versionタグの中を変更してください。<br/> | 別のバージョンを参照したい場合は、versionタグの中を変更してください。<br/> | ||
− | 設定が可能なバージョン番号の一覧は、[ | + | 設定が可能なバージョン番号の一覧は、[http://repo.bukkit.org/content/groups/public/org/bukkit/bukkit/ こちら] を参照してください。 |
ここまで編集をすると、pom.xmlは次のようになっているはずです。確認してみてください。 | ここまで編集をすると、pom.xmlは次のようになっているはずです。確認してみてください。 | ||
− | <pre | + | <pre> |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | <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"> | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
163行目: | 158行目: | ||
<artifactId>maven-compiler-plugin</artifactId> | <artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | <configuration> | ||
− | <source>1.7</source> | + | <nowiki><</nowiki>source>1.7</source> |
<target>1.7</target> | <target>1.7</target> | ||
</configuration> | </configuration> | ||
171行目: | 166行目: | ||
<repositories> | <repositories> | ||
<repository> | <repository> | ||
− | <id> | + | <id>bukkit-repo</id> |
− | <url> | + | <url>http://repo.bukkit.org/content/groups/public/</url> |
</repository> | </repository> | ||
</repositories> | </repositories> | ||
179行目: | 174行目: | ||
<groupId>org.bukkit</groupId> | <groupId>org.bukkit</groupId> | ||
<artifactId>bukkit</artifactId> | <artifactId>bukkit</artifactId> | ||
− | <version>1. | + | <version>1.7.9-R0.2</version> |
+ | <type>jar</type> | ||
+ | <scope>provided</scope> | ||
</dependency> | </dependency> | ||
</dependencies> | </dependencies> | ||
202行目: | 199行目: | ||
:'''訳者補記''': ダウンロードされた bukkit-x.x.x-Rxx.jar を右クリックし、Maven > Javadoc のダウンロード を実行しておくとよいでしょう。 | :'''訳者補記''': ダウンロードされた bukkit-x.x.x-Rxx.jar を右クリックし、Maven > Javadoc のダウンロード を実行しておくとよいでしょう。 | ||
+ | |||
+ | :'''訳者補記''': 上記のリポジトリ設定(CraftBukkit公式)は、Bukkit 1.7.9 で開発が停止したため、それ以降のリリースは行われていません。spigot由来の、CraftBukkit 1.8 以降のバージョンを使用したい場合は、下記のリポジトリ設定を追加してください。設定が可能なバージョン番号の一覧は、[https://hub.spigotmc.org/nexus/content/groups/public/org/bukkit/bukkit/ こちら] を参照してください。 | ||
+ | |||
+ | <code> | ||
+ | <repository> | ||
+ | <id>spigot-repo</id> | ||
+ | <url>https://hub.spigotmc.org/nexus/content/groups/public</url> | ||
+ | </repository> | ||
+ | </code> | ||
=== パッケージの作成 === | === パッケージの作成 === | ||
232行目: | 238行目: | ||
完了 を押して、新規クラスが作成されたことを確認して下さい。ソースコードは次のようになっているはずです。 | 完了 を押して、新規クラスが作成されたことを確認して下さい。ソースコードは次のようになっているはずです。 | ||
− | < | + | <source lang="java"> |
package my.test.plugin.tutorialplugin; | package my.test.plugin.tutorialplugin; | ||
240行目: | 246行目: | ||
} | } | ||
− | </ | + | </source> |
{{warning}} メインクラスは、コンストラクタを実行したり、新しいインスタンスを作成したりしないでください。 | {{warning}} メインクラスは、コンストラクタを実行したり、新しいインスタンスを作成したりしないでください。 | ||
264行目: | 270行目: | ||
''plugin.yml'' に、下記の3行を書いてください。 | ''plugin.yml'' に、下記の3行を書いてください。 | ||
− | < | + | <source lang="yaml"> |
name: (あなたのプラグイン名) | name: (あなたのプラグイン名) | ||
main: (作成したパッケージ名).(作成したメインクラス) | main: (作成したパッケージ名).(作成したメインクラス) | ||
version: (あなたのプラグインのバージョン) | version: (あなたのプラグインのバージョン) | ||
− | </ | + | </source> |
このチュートリアルでは、次のように作成します。 | このチュートリアルでは、次のように作成します。 | ||
− | < | + | <source lang="yaml"> |
name: TutorialPlugin | name: TutorialPlugin | ||
main: my.test.plugin.tutorialplugin.TutorialPlugin | main: my.test.plugin.tutorialplugin.TutorialPlugin | ||
version: 0.0.1 | version: 0.0.1 | ||
− | </ | + | </source> |
{{note}} メインクラスの設定は、大文字小文字が区別されるので、大文字小文字に注意して設定してください。 | {{note}} メインクラスの設定は、大文字小文字が区別されるので、大文字小文字に注意して設定してください。 | ||
373行目: | 379行目: | ||
具体的には、"give"コマンドは既にいくつかのプラグインで利用されています。 | 具体的には、"give"コマンドは既にいくつかのプラグインで利用されています。 | ||
もし独自に"give"コマンドを実装した場合は、 | もし独自に"give"コマンドを実装した場合は、 | ||
− | "give"コマンドを実装している他のプラグインとの互換性は無くなります。 | + | "give"コマンドを実装している他のプラグインとの互換性は無くなります。 |
− | onCommand() | + | onCommand()は、常にboolean型の値としてtrue,falseのどちらかを戻り値として返さねばなりません。 |
trueを返した場合は、情報表示のためのイベントは発生しません。 | trueを返した場合は、情報表示のためのイベントは発生しません。 | ||
falseを返した場合は、プラグインファイルを"usage: property"に戻し、コマンドを実行したプレイヤーに、コマンドの利用方法を通知するメッセージを表示します。 | falseを返した場合は、プラグインファイルを"usage: property"に戻し、コマンドを実行したプレイヤーに、コマンドの利用方法を通知するメッセージを表示します。 | ||
384行目: | 390行目: | ||
* Command cmd - 実行されたコマンドの内容 | * Command cmd - 実行されたコマンドの内容 | ||
* String commandLabel - 利用されたコマンドエイリアス | * String commandLabel - 利用されたコマンドエイリアス | ||
− | * String[] args - コマンドの引数を格納した配列(例:/hello abc defコマンドが入力された場合の内容は、args[0]がabc、args[1]がdefとなる) | + | * String[] args - コマンドの引数を格納した配列(例:/hello abc defコマンドが入力された場合の内容は、args[0]がabc、args[1]がdefとなる) |
=== コマンドの設定 === | === コマンドの設定 === | ||
529行目: | 535行目: | ||
Player player = (Player) sender; | Player player = (Player) sender; | ||
// ここに、処理を実装する。 | // ここに、処理を実装する。 | ||
− | + | reutnr true; | |
} else { | } else { | ||
sender.sendMessage(ChatColor.RED + "ゲーム内から実行してください!"); | sender.sendMessage(ChatColor.RED + "ゲーム内から実行してください!"); | ||
586行目: | 592行目: | ||
== 権限 == | == 権限 == | ||
− | |||
− | |||
Bukkitにおける権限の利用は、とっても簡単です! | Bukkitにおける権限の利用は、とっても簡単です! | ||
603行目: | 607行目: | ||
}</source></blockquote> | }</source></blockquote> | ||
− | 2メソッドの違いは、権限がセットされていなくてもデフォルトで与えられていれば権限を持っているという扱いになるかどうかです。<br> | + | (2メソッドの違いは、権限がセットされていなくてもデフォルトで与えられていれば権限を持っているという扱いになるかどうかです。<br> |
− | hasPermissionでは デフォルトで与えられていればtrueが返ります。 | + | hasPermissionでは デフォルトで与えられていればtrueが返ります。) |
− | PermissionsExなどで 権限はグループとして扱われることが多いですが、Bukkitには権限をグループとして扱う機能はありません。<br/> | + | (PermissionsExなどで 権限はグループとして扱われることが多いですが、Bukkitには権限をグループとして扱う機能はありません。<br/> |
− | グループとして扱う場合は、別途 上記のようなプラグインを使うか、自分で作る必要があります。 | + | グループとして扱う場合は、別途 上記のようなプラグインを使うか、自分で作る必要があります。) |
=== 権限の設定 === | === 権限の設定 === | ||
615行目: | 619行目: | ||
下記は、''plugin.yml''の最後に追加する形で設定する権限です: | 下記は、''plugin.yml''の最後に追加する形で設定する権限です: | ||
− | <blockquote> | + | <blockquote><code><source lang="yaml">permissions: |
− | < | ||
− | permissions: | ||
doorman.*: | doorman.*: | ||
description: Gives access to all doorman commands | description: Gives access to all doorman commands | ||
635行目: | 637行目: | ||
default: true | default: true | ||
doorman.denied: | doorman.denied: | ||
− | description: Prevents this user from entering the door | + | description: Prevents this user from entering the door</source> |
− | </ | + | </code></blockquote> |
− | </blockquote> | ||
659行目: | 660行目: | ||
高い柔軟性を提供しています。<br/> | 高い柔軟性を提供しています。<br/> | ||
下記はその実装例です: | 下記はその実装例です: | ||
− | <blockquote> | + | <blockquote><source lang="yaml">permissions: |
− | < | ||
− | permissions: | ||
doorman.*: | doorman.*: | ||
description: Gives access to all doorman commands | description: Gives access to all doorman commands | ||
669行目: | 668行目: | ||
doorman.knock: true | doorman.knock: true | ||
doorman.denied: false</source> | doorman.denied: false</source> | ||
− | + | ||
''doorman.*''権限は、いくつかの子権限を含んでいます。 | ''doorman.*''権限は、いくつかの子権限を含んでいます。 | ||
''doorman.*''権限がtrueである場合に、 | ''doorman.*''権限がtrueである場合に、 | ||
1,177行目: | 1,176行目: | ||
この内容について質問がある場合、遠慮なく[http://forums.bukkit.org/members/adamki11s.42417/ Adamki11s]か[http://wiki.bukkit.org/IRC BukkitDevのIRCチャンネル](当Wikiの原文を掲載しているサイトのIRCチャンネルです)で聞いてください。 | この内容について質問がある場合、遠慮なく[http://forums.bukkit.org/members/adamki11s.42417/ Adamki11s]か[http://wiki.bukkit.org/IRC BukkitDevのIRCチャンネル](当Wikiの原文を掲載しているサイトのIRCチャンネルです)で聞いてください。 | ||
:'''Note''': 当ページは訳文であるため、訳文自体に対する文責は原著者にありません。その点を考慮して必ず原文にも目を通してから質問して下さい。 | :'''Note''': 当ページは訳文であるため、訳文自体に対する文責は原著者にありません。その点を考慮して必ず原文にも目を通してから質問して下さい。 | ||
− | |||
− |