22 package com.realtime.crossfire.jxclient.scripts;
33 import java.io.IOException;
34 import java.util.Collection;
35 import java.util.HashSet;
37 import java.util.concurrent.CopyOnWriteArraySet;
38 import java.util.stream.Collectors;
39 import org.jetbrains.annotations.NotNull;
99 private final Collection<ScriptProcess>
scriptProcesses =
new CopyOnWriteArraySet<>();
135 scriptProcess =
new DefaultScriptProcess(nextScriptId, command, commandQueue, crossfireServerConnection, stats, floorView, itemSet, spellsManager, mapUpdaterState, skillSet);
136 }
catch (
final IOException ex) {
141 scriptProcesses.add(scriptProcess);
143 scriptProcesses.remove(scriptProcess);
144 if (result == null) {
151 new Thread(scriptProcess,
"JXClient:ScriptProcess:"+scriptProcess).start();
162 public Set<ScriptProcess>
getScripts(@NotNull
final String partialScriptName) {
165 }
catch (
final NumberFormatException ignored) {
177 final Set<ScriptProcess> result =
new HashSet<>();
179 if (scriptProcess.getScriptId() == scriptId) {
180 result.add(scriptProcess);
194 private Set<ScriptProcess>
getScriptsByName(@NotNull
final CharSequence partialScriptName) {
195 return scriptProcesses.stream().filter(scriptProcess -> scriptProcess.getFilename().contains(partialScriptName)).collect(Collectors.toSet());
203 return !scriptProcesses.isEmpty();
int nextScriptId
The script ID for the next created script.
int NDI_RED
A message color.
Interface for listeners interested in drawinfo messages received from the Crossfire server...
final Iterable< Spell > spellsManager
The spells manager instance to use.
final CommandQueue commandQueue
The CommandQueue for sending commands.
final ItemSet itemSet
The ItemSet instance to use.
final Stats stats
The Stats instance to watch.
void newScript(@NotNull final String command)
Creates a new script instance.
Implements the map model which is shown in the map and magic map views.
void addScriptProcessListener(@NotNull final ScriptProcessListener scriptProcessListener)
Adds a ScriptProcessListener to be notified.the listener to add
Default implementation for ScriptProcesses.
void drawInfo(@NotNull String message, int color)
Pretends that a drawinfo message has been received.
boolean hasScripts()
Returns whether at least one script is running.
Maintains currently running script processes.
ScriptManager(@NotNull final CommandQueue commandQueue, @NotNull final CrossfireServerConnection crossfireServerConnection, @NotNull final Stats stats, @NotNull final FloorView floorView, @NotNull final ItemSet itemSet, @NotNull final Iterable< Spell > spellsManager, @NotNull final MapUpdaterState mapUpdaterState, @NotNull final SkillSet skillSet)
Creates a new instance.
Describes a Crossfire spell.
Set< ScriptProcess > getScriptByScriptId(final int scriptId)
Returns all running scripts matching a given script ID.
Set< ScriptProcess > getScripts(@NotNull final String partialScriptName)
Returns all running scripts matching a given (partial) name or a script ID.
Update a CfMap model from protocol commands.
final SkillSet skillSet
The SkillSet for looking up skill names.
final Collection< ScriptProcess > scriptProcesses
All running ScriptProcesses.
final CrossfireServerConnection crossfireServerConnection
The CrossfireServerConnection instance.
final FloorView floorView
The FloorView to use.
An external command executed as a client-sided script.
int NDI_BLACK
A message color.
Adds encoding/decoding of crossfire protocol packets to a ServerConnection.
Model class maintaining the CfItems known to the player.
Maintains the pending (ncom) commands sent to the server.
This is the representation of all the statistics of a player, like its speed or its experience...
Maintain the set of skills as sent by the server.
Set< ScriptProcess > getScriptsByName(@NotNull final CharSequence partialScriptName)
Returns all running scripts matching a given (partial) name.
final MapUpdaterState mapUpdaterState
The MapUpdaterState instance to use.
Provides a view to all items comprising the current floor view.