Releases: CottonMC/CottonScripting
Releases · CottonMC/CottonScripting
Huge API Overhaul
Changelog
-
Huge API overhaul
-
Parchment is now used to parse and compile scripts
-
Deprecated many obsolete methods
-
Improved Javadocs
-
Removed Herobrine
Very Basic Script
var source = cotton.getSource();
var entity = (source.isEntity() ? source.getEntity() : undefined);
var name = source.getName();
var dim = source.getWorld().getDimension();
cotton.runCommand("tellraw @a \"" + name + " is in the world " + dim.getName() + "\"");
API Notes
cotton
is the CottonScript
. It is responsible for holding all necessary objects and is used for accessing ServerSource
. The ServerSource
object is the source (entity, player, console, script, etc.) which ran the script. Documentation will be found in the README section.
World Storage and more
- Consolidate all commands under the
/script
command, now as/script run
,/script engines
, and/script tag
. - Change the
/script
argument types so that a vanilla client can connect to a Cotton Scripting server without being kicked for not having the necessary argument type registered. - Rename ScriptContext to CottonScriptContext to avoid confusion with the javax ScriptContext.
- Pass a copy of CottonScriptContext as
cotton_context
on script evaluation, alongside the fresh copies of the context passed to all functions.- This allows you to mutate the original CottonScriptContext while still retaining the original accessible in functions.
- Add a method to run scripts as the server. It will likely be moved into a class in the API package soon.
- Add a mutative method to CottonScriptContext to change the context's command source.
- Add methods to ScriptTools to obtain command sources for the server and for players.
- Change the internal ScriptCommandExecutor to be passed a World instead of a ServerCommandSource.
- Register default script tags for
cotton:tick
,cotton:load
, andcotton:world_storage_listeners
cotton:tick
andcotton:load
will be changed to theminecraft:
namespace upon next release.- There is currently an unresolved issue preventing script tags from properly loading. This will hopefully be fixed by next release.
- Add a World Storage system for reading and writing persistent data without the use of the Scoreboard.
- WorldStorage comprises of one manager class and two
PersistentState
s. - EntityWorldStorage stores data associated with individual identities similar to the Scoreboard, GlobalWorldStorage stores data associated with the world itself.
- Both EntityWorldStorage and GlobalWorldStorage can have booleans, integers, floats, doubles, and strings written and read, with support for dynamic typing.
- Whenever either WorldStorage is written to, all the scripts in the
cotton:world_storage_listeners
tag will be evaluated.
- WorldStorage comprises of one manager class and two
Tool Adding
- Reorganize classes into API and Impl packages.
- Add a command to list all currently available scripting engines or check if a file extension has an available engine.
- Create a new argument type for
/script
commands for future script tag support (command syntax has not changed) - Convert
ScriptContext#getCommandPosition()
to anint[]
array to prevent the need to call obfuscated code from scripts. - Add
ScriptContext#getCallerUuid()
andScriptContext#getCommandDimension()
so scripts can know more about the circumstances under which they were called. - Add Javadocs to all
ScriptContext
methods, including emphasis on which methods are only usable for passthrough. - Add a new
ScriptTools
class for more efficient methods of common uses. Included:- Methods to get localized text and localized names of registered objects.
- Methods to perform raytraces from either an etity's look vector or an arbitrary position/pitch/yaw.
- Methods to obtain command executors for other entities based on either UUID or vanilla entity target selector arguments.
Initial release
- Provide a first release of the API.