Skip to content

Releases: CottonMC/CottonScripting

Huge API Overhaul

05 Jun 21:45
Compare
Choose a tag to compare
Huge API Overhaul Pre-release
Pre-release

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

12 May 10:35
Compare
Choose a tag to compare
  • 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, and cotton:world_storage_listeners
    • cotton:tick and cotton:load will be changed to the minecraft: 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 PersistentStates.
    • 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.

Tool Adding

11 May 03:21
Compare
Choose a tag to compare
  • 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 an int[] array to prevent the need to call obfuscated code from scripts.
  • Add ScriptContext#getCallerUuid() and ScriptContext#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

09 May 22:26
Compare
Choose a tag to compare
  • Provide a first release of the API.