mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 00:38:21 +00:00
Plugin cleanup.
This commit is contained in:
@@ -41,7 +41,7 @@ class ProcCommandListener < CommandListener
|
||||
end
|
||||
|
||||
def execute(player, command)
|
||||
@block.call( player, command)
|
||||
@block.call(player, command)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,7 +61,7 @@ end
|
||||
# A ScheduledTask which executes a Proc object with one argument (itself).
|
||||
class ProcScheduledTask < ScheduledTask
|
||||
def initialize(delay, immediate, block)
|
||||
super delay, immediate
|
||||
super(delay, immediate)
|
||||
@block = block
|
||||
end
|
||||
|
||||
@@ -127,7 +127,7 @@ def on_button(args, proc)
|
||||
id = args[0].to_i
|
||||
|
||||
on :event, :button do |ctx, player, event|
|
||||
proc.call player if event.widget_id == id
|
||||
proc.call(player) if event.widget_id == id
|
||||
end
|
||||
end
|
||||
|
||||
@@ -137,13 +137,13 @@ end
|
||||
def on_event(args, proc)
|
||||
raise "event must have one argument" unless args.length == 1
|
||||
|
||||
evt = args[0]
|
||||
if evt.is_a? Symbol
|
||||
class_name = evt.to_s.camelize.concat("Event")
|
||||
evt = Java::JavaClass.for_name("org.apollo.game.event.impl.".concat(class_name))
|
||||
event = args[0]
|
||||
if event.is_a? Symbol
|
||||
class_name = event.to_s.camelize.concat("Event")
|
||||
event = Java::JavaClass.for_name("org.apollo.game.event.impl.".concat(class_name))
|
||||
end
|
||||
|
||||
$ctx.add_last_event_handler(evt, ProcEventHandler.new(proc))
|
||||
$ctx.add_last_event_handler(event, ProcEventHandler.new(proc))
|
||||
end
|
||||
|
||||
# Defines an action to be taken upon a command.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.model.def.NpcDefinition'
|
||||
java_import 'org.apollo.game.model.Npc'
|
||||
java_import 'org.apollo.game.model.World'
|
||||
java_import 'org.apollo.game.model.Position'
|
||||
@@ -9,8 +8,7 @@ blacklist = []
|
||||
|
||||
on :command, :spawn, RIGHTS_ADMIN do |player, command|
|
||||
args = command.arguments
|
||||
id = args[0].to_i
|
||||
unless [1, 3].include? args.length and id > -1
|
||||
unless [1, 3].include? args.length and (id = args[0].to_i) > -1
|
||||
player.send_message("Invalid syntax - ::spawn [npc id] [x] [y]")
|
||||
return
|
||||
end
|
||||
@@ -20,27 +18,19 @@ on :command, :spawn, RIGHTS_ADMIN do |player, command|
|
||||
return
|
||||
end
|
||||
|
||||
definition = NpcDefinition.lookup(id)
|
||||
position = args.length == 1 ? player.position : Position.new(args[1].to_i, args[2].to_i, player.position.height)
|
||||
|
||||
World.world.register(Npc.new(definition, position))
|
||||
World.world.register(Npc.new(id, position))
|
||||
end
|
||||
|
||||
|
||||
on :command, :mass, RIGHTS_ADMIN do |player, command|
|
||||
args = command.arguments
|
||||
unless args.length == 2
|
||||
unless args.length == 2 and (id = args[0].to_i) > -1 and (1..5).include? (range = args[1].to_i)
|
||||
player.send_message("Invalid syntax - ::spawn [npc id] [range (1-5)]")
|
||||
return
|
||||
end
|
||||
|
||||
id = args[0].to_i
|
||||
range = args[1].to_i
|
||||
|
||||
unless (id > -1 and (1..5).include? range)
|
||||
return player.send_message("Invalid syntax - ::spawn [npc id] [range (1-5)]")
|
||||
end
|
||||
|
||||
if blacklist.include? id
|
||||
player.send_message("Sorry, that npc is blacklisted!")
|
||||
return
|
||||
@@ -55,7 +45,7 @@ on :command, :mass, RIGHTS_ADMIN do |player, command|
|
||||
|
||||
for x in minX..maxX do
|
||||
for y in minY..maxY do
|
||||
World.world.register(Npc.new(NpcDefinition.lookup(id), Position.new(x, y, center_position.height)))
|
||||
World.world.register(Npc.new(id, Position.new(x, y, center_position.height)))
|
||||
end
|
||||
end
|
||||
player.send_message("Mass spawning npcs with id #{id}.")
|
||||
|
||||
@@ -11,37 +11,23 @@ end
|
||||
|
||||
on :command, :level, RIGHTS_ADMIN do |player, command|
|
||||
args = command.arguments
|
||||
unless args.length == 2
|
||||
unless args.length == 2 and (0..20).include? (skill = args[0].to_i) and (1..99).include? (level = args[1].to_i)
|
||||
player.send_message("Invalid syntax - ::level [skill id] [level]")
|
||||
return
|
||||
end
|
||||
|
||||
skill = args[0].to_i
|
||||
level = args[1].to_i
|
||||
|
||||
unless (0..20).include? skill and (1..99).include? level
|
||||
player.send_message("Invalid syntax - ::level [skill id] [level]")
|
||||
return
|
||||
end
|
||||
|
||||
experience = SkillSet.experience_for_level(level)
|
||||
player.skill_set.set_skill(skill, Skill.new(experience, level, level))
|
||||
end
|
||||
|
||||
on :command, :xp, RIGHTS_ADMIN do |player, command|
|
||||
args = command.arguments
|
||||
unless args.length == 2
|
||||
unless args.length == 2 and (0..20).include? (skill = args[0].to_i)
|
||||
player.send_message("Invalid syntax - ::xp [skill id] [experience]")
|
||||
return
|
||||
end
|
||||
|
||||
skill = args[0].to_i
|
||||
experience = args[1].to_i
|
||||
|
||||
unless (0..20).include? skill
|
||||
player.send_message("Invalid syntax - ::xp [skill id] [experience]")
|
||||
return
|
||||
end
|
||||
|
||||
player.skill_set.add_experience(skill, experience)
|
||||
end
|
||||
@@ -2,19 +2,19 @@ require 'java'
|
||||
java_import 'org.apollo.game.model.Position'
|
||||
|
||||
on :command, :pos, RIGHTS_MOD do |player, command|
|
||||
player.send_message "You are at: " + player.position.to_s
|
||||
player.send_message("You are at: #{player.position}")
|
||||
end
|
||||
|
||||
on :command, :tele, RIGHTS_ADMIN do |player, command|
|
||||
args = command.arguments
|
||||
unless (2..3).include? args.length
|
||||
player.send_message "Invalid syntax - ::tele [x] [y] [optional-z]"
|
||||
player.send_message("Invalid syntax - ::tele [x] [y] [optional-z]")
|
||||
return
|
||||
end
|
||||
|
||||
x = args[0].to_i
|
||||
y = args[1].to_i
|
||||
z = args.length == 3 ? args[2].to_i : 0
|
||||
z = args.length == 3 ? args[2].to_i : player.position.height
|
||||
|
||||
player.teleport Position.new(x, y, z)
|
||||
end
|
||||
@@ -78,7 +78,6 @@ public final class World {
|
||||
/**
|
||||
* The command dispatcher.
|
||||
*/
|
||||
// TODO: better place than here?
|
||||
private final CommandDispatcher dispatcher = new CommandDispatcher();
|
||||
|
||||
/**
|
||||
@@ -92,20 +91,21 @@ public final class World {
|
||||
private final CharacterRepository<Player> playerRepository = new CharacterRepository<Player>(
|
||||
WorldConstants.MAXIMUM_PLAYERS);
|
||||
|
||||
/**
|
||||
* The {@link PluginManager}.
|
||||
*/
|
||||
// TODO: better place than here!!
|
||||
private PluginManager pluginManager;
|
||||
|
||||
/**
|
||||
* The scheduler.
|
||||
*/
|
||||
// TODO: better place than here?
|
||||
private final Scheduler scheduler = new Scheduler();
|
||||
|
||||
/**
|
||||
* Creates the world.
|
||||
*/
|
||||
private World() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -246,11 +246,10 @@ public final class World {
|
||||
if (success) {
|
||||
logger.info("Registered player: " + player + " [online=" + playerRepository.size() + "]");
|
||||
return RegistrationStatus.OK;
|
||||
} else {
|
||||
logger.warning("Failed to register player (server full): " + player + " [online=" + playerRepository.size()
|
||||
+ "]");
|
||||
return RegistrationStatus.WORLD_FULL;
|
||||
}
|
||||
logger.warning("Failed to register player (server full): " + player + " [online=" + playerRepository.size()
|
||||
+ "]");
|
||||
return RegistrationStatus.WORLD_FULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -288,4 +287,4 @@ public final class World {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -414,7 +414,7 @@ public final class ItemDefinition {
|
||||
description = "Swap this note at any bank for " + prefix + " " + name + ".";
|
||||
stackable = true;
|
||||
} else {
|
||||
throw new IllegalStateException();
|
||||
throw new IllegalStateException("Item cannot be noted.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user