石橋を叩いて壊すページ

不完全だけどV1.6とV1.7のAPIの差分作ってみた

Bukkitプラグイン作るにあたり、毎回APIリファレンスで英語と格闘しているわけだけど
よく考えたら、1度翻訳したらそれをどっかに保存しておけばまた格闘する必要はないわけで
とかいろいろ試行錯誤してたら1ヶ月経ってた。素直に格闘しておけば時間を有意義に使えた気もしてくる。

それはともかく、V1.6.4-R2.0とV1.7.2-R0.4のAPIリファレンスの索引ページの差分を取ってみた。
結構いろいろ違いがあるようだ。
以下に、差分を斜め読みした感想を書いてみる。

なお、本家の索引ページ自体に記載が漏れている項目がいくらかあるので、
このページはあくまで不完全な差分と割り切って眺めていただきたい。

パッケージ

追加
org.bukkit.projectiles
Classes to represent the source of a projectile
削除
なし

これまでは、スケルトンに矢を打たせるにはLivingEntityのlaunchProjectileメソッドを使っていたが、
V1.7ではこのメソッドは削除された。
代わりに、projectilesパッケージ内のProjectileSource(発射元を表すインターフェース)にlaunchProjectileメソッドが用意され、
SkeletonやGhastなどのモンスター(に限らずVillagerやZombieなどあらかたのエンティティ)を表すインターフェースが
ProjectileSourceをそれぞれ継承する仕組みになったようだ。

このため結果的にはすべてのLivingEntityはlaunchProjectileメソッドを実装しているので、
プラグイン開発者はコードを変更する必要性はたぶん無い感じ。

また、このProjectileSourceを継承したBlockProjectileSourceというインターフェースが新登場している。
いままでディスペンサーからの矢の発射はWorld#spawnArrowメソッドを叩く必要があったが、
Dispenser#getBlockProjectileSource()の返り値のlaunchProjectileメソッドを叩けば、
ディスペンサーの座標や向きなどを意識せず発射操作が可能になる。

クラス・インターフェース・列挙型

追加
BanEntry
A single entry from the ban list.
BanList
A ban list, containing bans of type BanList.Type
BanList.Type
Represents the various types a BanList may track.
AchievementCommand
 
SetIdleTimeoutCommand
 
SetWorldSpawnCommand
 
FormattedCommandAlias
 
CommandMinecart
 
PlayerAchievementAwardedEvent
Called when a player earns an achievement.
PlayerStatisticIncrementEvent
Called when a player statistic is incremented.
BlockProjectileSource
 
ProjectileSource
Represents a valid source of a projectile.
Statistic.Type
The type of statistic.
UnsafeValues
Deprecated. Unsupported & internal use only
CachedServerIcon
This is a cached version of a server-icon.
削除
PluginClassLoader
A ClassLoader for plugins, to allow shared classes across multiple plugins

BAN操作関連が拡充されたようだ。
これまではOfflinePlayerインターフェースのsetBannedメソッドでBANにするかどうかを決定していたが、
このメソッドは非推奨になった。かわりに、BanListとBanEntryが追加された。
BanEntryがプレイヤー名やIPアドレスなど個別のBAN事情を保持し、それを一覧にしたものがBanListというかんじ。
BanListはServer#getBanListメソッドで取得できる。

プレイヤーが実績を解除した際にPlayerAchievementAwardedEventが発生するようになった。
サーバーアイコンを動的に変更することができるかもしれない(CachedServerIcon)。

メソッド

追加
Achievement#getParent()
Returns the parent achievement of this achievement, or null if none.
Achievement#hasParent()
Returns whether or not this achievement has a parent achievement.
BanEntry#getCreated()
Gets the date this ban entry was created.
BanEntry#getExpiration()
Gets the date this ban expires on, or null for no defined end date.
BanEntry#getReason()
Gets the reason for this ban.
BanEntry#getSource()
Gets the source of this ban.
A source is considered any String, although this is generally a player name.
BanEntry#getTarget()
Gets the target involved.
BanEntry#save()
Saves the ban entry, overwriting any previous data in the ban list.
Saving the ban entry of an unbanned player will cause the player to be banned once again.
BanEntry#setCreated(Date)
Sets the date this ban entry was created.
Use BanEntry.save() to save the changes.
BanEntry#setExpiration(Date)
Sets the date this ban expires on.
BanEntry#setReason(String)
Sets the reason for this ban.
BanEntry#setSource(String)
Sets the source of this ban.
A source is considered any String, although this is generally a player name.
Use BanEntry.save() to save the changes.
BanList#addBan(String, String, Date, String)
Adds a ban to the ban list.
BanList#getBanEntries()
Gets a set containing every BanEntry in the BanList.
BanList#getBanEntry(String)
Gets a BanEntry by target.
BanList#isBanned(String)
Gets if a BanEntry exists for the target, indicating ban status
BanList#pardon(String)
Removes the specified target from the list, therefore indicating a "not banned" status.
BanList.Type#valueOf(String)
Returns the enum constant of this type with the specified name.
BanList.Type#values()
Returns an array containing the constants of this enum type, in the order they are declared.
Dispenser#getBlockProjectileSource()
Gets the BlockProjectileSource object for this dispenser.
Bukkit#getBanList(BanList.Type)
 
Bukkit#getIdleTimeout()
 
Bukkit#getServerIcon()
 
Bukkit#getUnsafe()
Deprecated. 
Bukkit#loadServerIcon(BufferedImage)
 
Bukkit#loadServerIcon(File)
 
Bukkit#setIdleTimeout(int)
 
AchievementCommand#AchievementCommand()
 
AchievementCommand#execute(CommandSender, String, String[])
 
AchievementCommand#tabComplete(CommandSender, String, String[])
 
SetIdleTimeoutCommand#execute(CommandSender, String, String[])
 
SetIdleTimeoutCommand#SetIdleTimeoutCommand()
 
SetIdleTimeoutCommand#tabComplete(CommandSender, String, String[])
 
SetWorldSpawnCommand#execute(CommandSender, String, String[])
 
SetWorldSpawnCommand#SetWorldSpawnCommand()
 
SetWorldSpawnCommand#tabComplete(CommandSender, String, String[])
 
FormattedCommandAlias#execute(CommandSender, String, String[])
 
FormattedCommandAlias#FormattedCommandAlias(String, String[])
 
SimpleCommandMap#setFallbackCommands()
 
Arrow#getKnockbackStrength()
Gets the knockback strength for an arrow, which is the KnockBack level of the bow that shot it.
Arrow#isCritical()
Gets whether this arrow is critical.
Arrow#setCritical(boolean)
Sets whether or not this arrow should be critical.
Arrow#setKnockbackStrength(int)
Sets the knockback strength for an arrow.
Firework#detonate()
Cause this firework to explode at earliest opportunity, as if it has no remaining fuse.
CommandMinecart#getCommand()
Gets the command that this CommandMinecart will run when activated.
CommandMinecart#setCommand(String)
Sets the command that this CommandMinecart will run when activated.
CommandMinecart#setName(String)
Sets the name of this CommandMinecart.
Player#decrementStatistic(Statistic)
Decrements the given statistic for this player.
Player#decrementStatistic(Statistic, int)
Decrements the given statistic for this player.
Player#decrementStatistic(Statistic, EntityType)
Decrements the given statistic for this player for the given entity.
Player#decrementStatistic(Statistic, EntityType, int)
Decrements the given statistic for this player for the given entity.
Player#decrementStatistic(Statistic, Material)
Decrements the given statistic for this player for the given material.
Player#decrementStatistic(Statistic, Material, int)
Decrements the given statistic for this player for the given material.
Player#getStatistic(Statistic)
Gets the value of the given statistic for this player.
Player#getStatistic(Statistic, EntityType)
Gets the value of the given statistic for this player.
Player#getStatistic(Statistic, Material)
Gets the value of the given statistic for this player.
Player#hasAchievement(Achievement)
Gets whether this player has the given achievement.
Player#incrementStatistic(Statistic, EntityType)
Increments the given statistic for this player for the given entity.
Player#incrementStatistic(Statistic, EntityType, int)
Increments the given statistic for this player for the given entity.
Player#removeAchievement(Achievement)
Removes the given achievement and any children achievements that the player has.
Player#setResourcePack(String)
Request that the player's client download and switch resource packs.
Player#setStatistic(Statistic, int)
Sets the given statistic for this player.
Player#setStatistic(Statistic, EntityType, int)
Sets the given statistic for this player for the given entity.
Player#setStatistic(Statistic, Material, int)
Sets the given statistic for this player for the given material.
Projectile#_INVALID_getShooter()
Deprecated. 
Projectile#_INVALID_setShooter(LivingEntity)
Deprecated. 
Projectile#setShooter(ProjectileSource)
Set the shooter of this projectile.
WitherSkull#isCharged()
Gets whether or not the wither skull is charged.
WitherSkull#setCharged(boolean)
Sets the charged status of the wither skull.
PlayerAchievementAwardedEvent#getAchievement()
Gets the Achievement being awarded.
PlayerAchievementAwardedEvent#getHandlerList()
 
PlayerAchievementAwardedEvent#getHandlers()
 
PlayerAchievementAwardedEvent#isCancelled()
 
PlayerAchievementAwardedEvent#PlayerAchievementAwardedEvent(Player, Achievement)
 
PlayerAchievementAwardedEvent#setCancelled(boolean)
 
PlayerStatisticIncrementEvent#getEntityType()
Gets the EntityType if getStatistic() is an entity statistic otherwise returns null.
PlayerStatisticIncrementEvent#getHandlerList()
 
PlayerStatisticIncrementEvent#getHandlers()
 
PlayerStatisticIncrementEvent#getMaterial()
Gets the Material if getStatistic() is a block or item statistic otherwise returns null.
PlayerStatisticIncrementEvent#getNewValue()
Gets the new value of the statistic.
PlayerStatisticIncrementEvent#getPreviousValue()
Gets the previous value of the statistic.
PlayerStatisticIncrementEvent#getStatistic()
Gets the statistic that is being incremented.
PlayerStatisticIncrementEvent#isCancelled()
 
PlayerStatisticIncrementEvent#PlayerStatisticIncrementEvent(Player, Statistic, int, int)
 
PlayerStatisticIncrementEvent#PlayerStatisticIncrementEvent(Player, Statistic, int, int, EntityType)
 
PlayerStatisticIncrementEvent#PlayerStatisticIncrementEvent(Player, Statistic, int, int, Material)
 
PlayerStatisticIncrementEvent#setCancelled(boolean)
 
ServerListPingEvent#iterator()
ServerListPingEvent#ServerListPingEvent(InetAddress, String, int)
This constructor is intended for implementations that provide the ServerListPingEvent.iterator() method, thus provided the ServerListPingEvent.getNumPlayers() count.
ServerListPingEvent#setServerIcon(CachedServerIcon)
Sets the server-icon sent to the client.
Location#setDirection(Vector)
Sets the yaw and pitch to point in the direction of the vector.
JavaPlugin#getPlugin(Class<T>)
This method provides fast access to the plugin that has provided the given plugin class, which is usually the plugin that implemented it.
JavaPlugin#getProvidingPlugin(Class<?>)
This method provides fast access to the plugin that has provided the given class.
JavaPlugin#JavaPlugin(JavaPluginLoader, PluginDescriptionFile, File, File)
 
JavaPlugin#JavaPlugin(PluginLoader, Server, PluginDescriptionFile, File, File)
Deprecated. This method is intended for unit testing purposes when the other constructor cannot be used.

Its existence may be temporary.

PluginDescriptionFile#getRawName()
Deprecated. Internal use
BlockProjectileSource#getBlock()
Gets the block this projectile source belongs to.
ProjectileSource#launchProjectile(Class<? extends T>)
Launches a Projectile from the ProjectileSource.
ProjectileSource#launchProjectile(Class<? extends T>, Vector)
Launches a Projectile from the ProjectileSource with an initial velocity.
Server#getBanList(BanList.Type)
Gets a BanList for the supplied BanList Type
Server#getIdleTimeout()
Gets the idle kick timeout.
Server#getServerIcon()
Gets an instance of the server's default server-icon.
Server#getUnsafe()
Deprecated. 
Server#loadServerIcon(BufferedImage)
Creates a cached server-icon for the specific image.
Server#loadServerIcon(File)
Loads an image from a file, and returns a cached image for the specific server-icon.
Server#setIdleTimeout(int)
Set the idle kick timeout.
Statistic#getType()
Gets the type of this statistic.
Statistic.Type#valueOf(String)
Returns the enum constant of this type with the specified name.
Statistic.Type#values()
Returns an array containing the constants of this enum type, in the order they are declared.
UnsafeValues#getAchievementFromInternalName(String)
Deprecated.  
UnsafeValues#getMaterialFromInternalName(String)
Deprecated.  
UnsafeValues#getStatisticFromInternalName(String)
Deprecated.  
UnsafeValues#modifyItemStack(ItemStack, String)
Deprecated.  
UnsafeValues#tabCompleteInternalMaterialName(String, List<String>)
Deprecated.  
UnsafeValues#tabCompleteInternalStatisticOrAchievementName(String, List<String>)
Deprecated.  
削除
Achievement#getById(int)
Deprecated. Magic value
Achievement#getId()
Deprecated. Magic value
HelpCommand#matches(String)
 
TellCommand#matches(String)
 
SimpleCommandMap#getFallback(String)
 
SimpleCommandMap#getFallbackCommands()
 
LivingEntity#launchProjectile(Class<? extends T>)
Launches a Projectile from the living entity.
Projectile#setShooter(LivingEntity)
Set the shooter of this projectile
JavaPluginLoader#getClassByName(String)
Deprecated. Internal method that wasn't intended to be exposed
JavaPluginLoader#getDataFolder(File)
Deprecated. Internal method that wasn't intended to be exposed
JavaPluginLoader#loadPlugin(File, boolean)
Deprecated. Relic method from PluginLoader that didn't get purged
JavaPluginLoader#removeClass(String)
Deprecated. Internal method that wasn't intended to be exposed
JavaPluginLoader#setClass(String, Class<?>)
Deprecated. Internal method that wasn't intended to be exposed
PluginClassLoader#addURL(URL)
 
PluginClassLoader#findClass(String)
 
PluginClassLoader#findClass(String, boolean)
Deprecated. Internal method that wasn't intended to be exposed
PluginClassLoader#getClasses()
Deprecated. Internal method that wasn't intended to be exposed
PluginClassLoader#PluginClassLoader(JavaPluginLoader, URL[], ClassLoader)
Deprecated. 
Statistic#getById(int)
Deprecated. Magic value
Statistic#getId()
Deprecated. Magic value

実績(アチーブメント)に関して、ある実績を解除する前に解除しておく必要がある実績
(たとえば「木を手に入れる」実績を解除するには事前に「所持品の確認」を解除しておく必要がある)
を得られるようになった(Achievement#getParent())。
プレイヤーが実績を解除しているかを得られるようにもなった(Player#hasAchievement(Achievement))。

矢に対してクリティカル(Arrow#setCritical(boolean))やノックバック効果をつけられるようになった。
一定時間動きが無いプレイヤーを自動でキックできるようになった(Server#setIdleTimeout(int))。
プレイヤーに特定のURLにあるリソースパックの使用を促し、承諾されれば自動的に
リソースパックをダウンロード・切り替えまで行わせたり(Player#setResourcePack(String))、
プレイヤーの統計情報を得る(Player#getStatistic(Statistic))こともできるようだ。

削除されたメソッドのなかで使用頻度がありそうなのは、矢など投射物の発射者を特定するProjectile#setShooter(LivingEntity)メソッドかな?
ただ、代わりにProjectile#setShooter(ProjectileSource)メソッドが新登場しているので、コードの変更は型の変更くらいで大きい違いはなさそう。
それ以外は、もともと非推奨だったり生のIDをゲットしちゃうようなものだったり、気をつけていれば使うことのないメソッドが多そう。

定数(列挙子)

追加
Enchantment#LUCK
Decreases odds of catching worthless junk
Enchantment#LURE
Increases rate of fish biting your hook
PlayerStatisticIncrementEvent#statistic
 
削除
Achievement#STATISTIC_OFFSET
The offset used to distinguish Achievements and Statistics
SimpleCommandMap#aliases
 
SimpleCommandMap#fallbackCommands
 
JavaPluginLoader#classes
Deprecated. Internal field that wasn't intended to be exposed
JavaPluginLoader#fileFilters
Deprecated. Internal field that wasn't intended to be exposed
JavaPluginLoader#loaders
Deprecated. Internal field that wasn't intended to be exposed

追加されたLUCKとLUREは、それぞれ釣竿につける「海の幸」と「ルアー」に対応するもので、
宝の釣れる確率が上がったり魚以外の釣れる確率が下がったりする

で、ここを見てふと思ったんだけどV1.7で追加されたバイオーム関連(メサとか)の定数がない。
どうも、本家のAPIリファレンスの索引には、載ってる定数(Color.AQUA - 水色)と載ってない定数(Biome.MESA - メサ)があるようだ。なぜだ?
せっかく差分をわざわざ作ったのに、ここに来てなんという重大なミス発見…。
まあ、せっかく書いた記事をそのまま捨てるのもどうかと思うので、不完全という前置きを入れた上でブログに載せたいと思う。

この記事を評価

この記事にコメント

  1. ...

【この記事にコメント】
お名前:
コメント:

Menu