Last active
August 29, 2015 14:13
-
-
Save pnlybubbles/c297d30ae91c7f2e8073 to your computer and use it in GitHub Desktop.
Minecarftの中でもupdate_nameしたい。プレーヤーの表示名を変えれるBukkitプラグイン。Puruginを利用。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
class UpdateNamePlugin | |
include Purugin::Plugin | |
description 'UpdateName', 0.1 | |
def on_enable | |
chatcolor = org::bukkit::ChatColor | |
public_command('update_name', 'change displayed name', '/update_name {id} {new_name}') do |sender, *args| | |
if args[0] && args[1] && args[1].length > 0 | |
old_display_name = nil | |
sender.server.worlds.map(&:players).flatten.each { |p| | |
if p.name == args[0] | |
old_display_name = p.display_name | |
p.display_name = args[1] | |
end | |
} | |
if old_display_name | |
puts "[UpdateName] #{sender.name}: #{args[0]} (#{old_display_name} -> #{args[1]})" | |
sender.server.worlds.map(&:players).flatten.each { |p| | |
p.msg("#{chatcolor::GOLD}#{sender.display_name}#{chatcolor::RESET}によって#{chatcolor::GOLD}#{old_display_name}#{chatcolor::RESET}は#{chatcolor::GOLD}#{args[1]}#{chatcolor::RESET}になりました!") | |
} | |
else | |
sender.msg("#{chatcolor::RED}変更に失敗しました#{chatcolor::RESET}") | |
sender.msg("#{chatcolor::RED}\"#{args[0]}\"は存在しません。ヒント:もともとのIDで指定します#{chatcolor::RESET}") | |
end | |
else | |
sender.msg("#{chatcolor::RED}変更に失敗しました#{chatcolor::RESET}") | |
sender.msg("#{chatcolor::RED}/update_name {id} {new_name}#{chatcolor::RESET}") | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment