mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-04 08:39:27 +00:00
Update all plugins to conform to Rubocop.
This commit is contained in:
@@ -3,14 +3,13 @@ require 'java'
|
||||
java_import 'org.apollo.game.message.impl.SetPlayerActionMessage'
|
||||
java_import 'org.apollo.game.model.entity.Player'
|
||||
|
||||
|
||||
|
||||
# A right-click action for a Player.
|
||||
class PlayerAction
|
||||
attr_reader :slot, :primary, :name
|
||||
|
||||
def initialize(slot, primary, name)
|
||||
index = [ :first, :second, :third, :fourth, :fifth ].find_index(slot)
|
||||
raise "Unsupported action slot #{slot}." if index.nil?
|
||||
index = [:first, :second, :third, :fourth, :fifth].find_index(slot)
|
||||
fail "Unsupported action slot #{slot}." if index.nil?
|
||||
|
||||
@slot = index
|
||||
@primary = primary
|
||||
@@ -26,7 +25,7 @@ FOLLOW_ACTION = PlayerAction.new(:fifth, true, 'Follow')
|
||||
|
||||
# Shows multiple context menu action for the specified player
|
||||
def show_actions(player, *actions)
|
||||
raise 'Must specify at least one action' if actions.nil?
|
||||
fail 'Must specify at least one action.' if actions.nil?
|
||||
|
||||
actions.each do |action|
|
||||
player.add_action(action)
|
||||
@@ -44,6 +43,7 @@ def hide_action(player, action)
|
||||
show_action(player, PlayerAction.new(action.slot, action.primary, 'null'))
|
||||
end
|
||||
|
||||
# Monkey-patch Player to provide action utility methods.
|
||||
class Player
|
||||
|
||||
def actions
|
||||
@@ -54,8 +54,8 @@ class Player
|
||||
actions[action.slot] = action.name
|
||||
end
|
||||
|
||||
def has_action(action)
|
||||
def action?(action)
|
||||
actions[action.slot] == action.name
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
java_import 'org.apollo.game.model.entity.Player'
|
||||
|
||||
on :login do |event, player|
|
||||
on :login do |_event, player|
|
||||
show_action(player, TRADE_ACTION)
|
||||
show_action(player, FOLLOW_ACTION)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
<author>Ryley</author>
|
||||
</authors>
|
||||
<scripts>
|
||||
<script>player-action.rb</script>
|
||||
<script>action.rb</script>
|
||||
<script>login.rb</script>
|
||||
</scripts>
|
||||
<dependencies />
|
||||
</plugin>
|
||||
</plugin>
|
||||
|
||||
Reference in New Issue
Block a user