Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/docs #812

Merged
merged 23 commits into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions source/about/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ There have also been community implementations due to the flexibility of the API
Where do I get Plugins for Sponge?
----------------------------------

You can find plugins on the `SpongeForums <https://forums.spongepowered.org/c/plugins/plugin-releases>`_ as well as our
almost complete, official plugin repository, called `Ore <https://ore.spongepowered.org/>`_.
You can find plugins on our official plugin repository, called `Ore <https://ore.spongepowered.org/>`_.

What happened to Bukkit?
------------------------
Expand All @@ -79,7 +78,7 @@ For Server Owners
I'm a Server Owner! How Will Switching to Sponge Affect My Server?
------------------------------------------------------------------

For an existing Forge server, you will need to download Sponge and place it into the mods folder. The server can then
For an existing Forge server, you will need to download SpongeForge and place it into the mods folder. The server can then
be started like any other Forge server.

Non-Forge servers may elect to use SpongeVanilla instead, an implementation that does not rely on Forge. There are
Expand Down Expand Up @@ -112,7 +111,7 @@ What can't I do with Sponge? / Limitations of Sponge?
-----------------------------------------------------

Sponge can't be used to create new blocks, textures, mobs on the client-side or any other content which would need
client-side modifications. SpongeAPI won't support sending mods or plugins to the client for now due to security
client-side modifications. SpongeAPI won't support sending mods or plugins to the client due to security
concerns. However, you can make use of the ForgeAPI for clients and create Sponge plugins for the server-side.
It is even possible to use Sponge on the client-side, but for several tasks mods are still required.

Expand Down
2 changes: 1 addition & 1 deletion source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@

javadoc_links = {
'https://jd.spongepowered.org/%s/' % release: ['org.spongepowered.api'],
'http://configurate.aoeu.xyz/apidocs/': ['ninja.leaping.configurate'],
'https://configurate.aoeu.xyz/apidocs/': ['ninja.leaping.configurate'],
'https://docs.oracle.com/javase/8/docs/api/': ['java'],
'https://google.github.io/guava/releases/17.0/api/docs/': ['com.google.common']
}
Expand Down
55 changes: 28 additions & 27 deletions source/contributing/implementation/datamanipulator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The following snippet shows the imports/paths for some classes in SpongeCommon t
import org.spongepowered.common.data.manipulator.mutable.common.AbstractData;
import org.spongepowered.common.data.manipulator.mutable.entity.SpongeHealthData;
import org.spongepowered.common.data.processor.common.AbstractEntityDataProcessor;
import org.spongepowered.common.data.util.DataConstants;
import org.spongepowered.common.util.Constants;
import org.spongepowered.common.data.util.NbtDataUtil;
import org.spongepowered.common.registry.type.data.KeyRegistryModule;

Expand Down Expand Up @@ -94,20 +94,18 @@ The second constructor must

import static com.google.common.base.Preconditions.checkArgument;

import org.spongepowered.common.data.util.DataConstants;

public class SpongeHealthData extends AbstractData<HealthData, ImmutableHealthData> implements HealthData {

private double health;
private double maxHealth;

public SpongeHealthData() {
this(DataConstants.DEFAULT_HEALTH, DataConstants.DEFAULT_HEALTH);
this(20D, 20D);
}

public SpongeHealthData(double health, double maxHealth) {
super(HealthData.class);
checkArgument(maxHealth > DataConstants.MINIMUM_HEALTH);
checkArgument(maxHealth > 0);
this.health = health;
this.maxHealth = maxHealth;
registerGettersAndSetters();
Expand Down Expand Up @@ -136,10 +134,10 @@ The interface we implement specifies some methods to access :javadoc:`Value` obj

public MutableBoundedValue<Double> health() {
return SpongeValueFactory.boundedBuilder(Keys.HEALTH)
.minimum(DataConstants.MINIMUM_HEALTH)
.maximum(this.maximumHealth)
.defaultValue(this.maximumHealth)
.actualValue(this.currentHealth)
.minimum(0)
.maximum(this.maxHealth)
.defaultValue(this.maxHealth)
.actualValue(this.health)
.build();
}

Expand All @@ -164,9 +162,9 @@ contains a corresponding ``DataQuery``, just use those by passing the ``Key`` di
.. code-block:: java

public DataContainer toContainer() {
return DataContainer.createNew()
.set(Keys.HEALTH, this.currentHealth)
.set(Keys.MAX_HEALTH, this.maximumHealth);
return super.toContainer()
.set(Keys.HEALTH, this.health)
.set(Keys.MAX_HEALTH, this.maxHealth);
}

registerGettersAndSetters()
Expand All @@ -184,29 +182,30 @@ by ``AbstractData``, but we must tell it which data it can access and how. There

.. code-block:: java

private void setCurrentHealthIfValid(double value) {
if (value >= DataConstants.MINIMUM_HEALTH && value <= (double) Float.MAX_VALUE) {
this.currentHealth = value;
private SpongeHealthData setCurrentHealthIfValid(double value) {
if (value >= 0 && value <= (double) Float.MAX_VALUE) {
this.health = value;
} else {
throw new IllegalArgumentException("Invalid value for current health");
}
return this;
}

private void setMaximumHealthIfValid(double value) {
if (value >= DataConstants.MINIMUM_HEALTH && value <= (double) Float.MAX_VALUE) {
this.maximumHealth = value;
private SpongeHealthData setMaximumHealthIfValid(double value) {
if (value >= 0 && value <= (double) Float.MAX_VALUE) {
this.maxHealth = value;
} else {
throw new IllegalArgumentException("Invalid value for maximum health");
}

return this;
}

private void registerGettersAndSetters() {
registerFieldGetter(Keys.HEALTH, () -> this.currentHealth);
registerFieldGetter(Keys.HEALTH, () -> this.health);
registerFieldSetter(Keys.HEALTH, this::setCurrentHealthIfValid);
registerKeyValue(Keys.HEALTH, this::health);

registerFieldGetter(Keys.MAX_HEALTH, () -> this.maximumHealth);
registerFieldGetter(Keys.MAX_HEALTH, () -> this.maxHealth);
registerFieldSetter(Keys.MAX_HEALTH, this::setMaximumHealthIfValid);
registerKeyValue(Keys.MAX_HEALTH, this::maxHealth);
}
Expand All @@ -218,7 +217,7 @@ This applies especially for :javadoc:`DataHolder`\s which won't accept negative
.. tip::

The validity criteria for those setters are the same as for the respective ``Value`` object, so you might delegate
the validity check to a call of ``this.health().set()`` and just set ``this.currentHealth = value`` if the first
the validity check to a call of ``this.health().set()`` and just set ``this.health = value`` if the first
line has not thrown an exception yet.

That's it. The ``DataManipulator`` should be done now.
Expand Down Expand Up @@ -253,13 +252,15 @@ There add a line to register (and create) your used keys.

.. code-block:: java

this.register(Key.builder()
import static org.spongepowered.api.data.DataQuery.of;

this.register("health", Key.builder()
.type(TypeTokens.BOUNDED_DOUBLE_VALUE_TOKEN)
.id("health")
.name("Health")
.query(of("Health"))
.build());
this.register(Key.builder()
this.register("max_health", Key.builder()
.type(TypeTokens.BOUNDED_DOUBLE_VALUE_TOKEN)
.id("max_health")
.name("Max Health")
Expand Down Expand Up @@ -511,9 +512,9 @@ a ``Value`` and its immutable counterpart and three methods to get, set and remo
@Override
protected MutableBoundedValue<Double> constructValue(Double health) {
return SpongeValueFactory.boundedBuilder(Keys.HEALTH)
.minimum(DataConstants.MINIMUM_HEALTH)
.minimum(0D)
.maximum(((Float) Float.MAX_VALUE).doubleValue())
.defaultValue(DataConstants.DEFAULT_HEALTH)
.defaultValue(20D)
.actualValue(health)
.build();
}
Expand All @@ -539,7 +540,7 @@ Since it is impossible for an ``EntityLivingBase`` to not have health, this meth

@Override
protected boolean set(EntityLivingBase container, Double value) {
if (value >= DataConstants.MINIMUM_HEALTH && value <= (double) Float.MAX_VALUE) {
if (value >= 0 && value <= (double) Float.MAX_VALUE) {
container.setHealth(value.floatValue());
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion source/contributing/implementation/debugging/mixin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ There are a several ways to view the class files from the mixin process.

Having the fernflower jar on your runtime classpath will cause the class files to be decompiled as they are created.

* `JD-Gui <http://jd.benow.ca/>`_ is a standalone graphical utility that displays Java source codes of class files.
* `JD-Gui <https://java-decompiler.github.io/>`_ is a standalone graphical utility that displays Java source codes of class files.

Phases And Environments
=======================
Expand Down
2 changes: 1 addition & 1 deletion source/contributing/implementation/debugging/more.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ IntelliJ
--------

Learn about `Git Integration <https://www.jetbrains.com/help/idea/using-git-integration.html>`_ and `Project
Structure <http://www.jetbrains.org/intellij/sdk/docs/basics/project_structure.html>`_ on JetBrains'
Structure <https://www.jetbrains.org/intellij/sdk/docs/basics/project_structure.html>`_ on JetBrains'
web site.
4 changes: 2 additions & 2 deletions source/plugin/api-versions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ This page explains which API versions exist, and to which Minecraft version thei
+-------------+--------------+----------------+-------------------------------------------+
| API-Version | Release Date | End of Support | Known Implementations (Minecraft Version) |
+=============+==============+================+===========================================+
| *8.0.0* | TBA | TBA | * *SpongeForge (1.13.x)* |
| | | | * *SpongeVanilla (1.13.x)* |
| *8.0.0* | TBA | TBA | * *SpongeForge* |
| | | | * *SpongeVanilla* |
+-------------+--------------+----------------+-------------------------------------------+
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is leaving the Minecraft version off intentional? Gabizou said to change it to 1.14, but I can agree with leaving it off for now given the amount of change and uncertainty for which Minecraft version will have fully-functional implementations.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Six of one, half a dozen of the other... Leaving the MC version off an as-yet unreleased API is probably OK, as it will definitely have one by release.

Copy link
Contributor Author

@ImMorpheus ImMorpheus Jul 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is leaving the Minecraft version off intentional?

Yeah, this is the docs for api 7. No need to worry about future versions of the api.

| 7.2.0 | TBA | TBA | * SpongeForge (1.12.2) |
| | | | * SpongeVanilla (1.12.2) |
Expand Down
2 changes: 2 additions & 0 deletions source/plugin/assets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Alternatively, you can retrieve assets through the ``AssetManager`` class:

import org.spongepowered.api.Sponge;

PluginContainer plugin = ...;

Asset asset = Sponge.getAssetManager().getAsset(plugin, "myfile.txt").get();

.. tip::
Expand Down
4 changes: 2 additions & 2 deletions source/plugin/buildsystem.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ your plugin. Continue at :doc:`plugin-identifier` for choosing an identifier for

.. _Gradle: https://gradle.org/
.. _Maven: https://maven.apache.org/
.. _Groovy: http://www.groovy-lang.org/
.. _Kotlin: http://kotlinlang.org/
.. _Groovy: https://www.groovy-lang.org/
.. _Kotlin: https://kotlinlang.org/
.. _`Gradle User Guide`: https://docs.gradle.org/current/userguide/userguide.html
.. _`Gradle Java Quickstart`: https://docs.gradle.org/current/userguide/tutorial_java_projects.html
.. _`Project Object Model`: https://maven.apache.org/guides/introduction/introduction-to-the-pom.html
Expand Down
2 changes: 2 additions & 0 deletions source/plugin/commands/arguments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ Example: Building a Command with Multiple Arguments
import org.spongepowered.api.command.spec.CommandExecutor;
import org.spongepowered.api.command.spec.CommandSpec;

PluginContainer plugin = ...;

CommandSpec myCommandSpec = CommandSpec.builder()
.description(Text.of("Send a message to a player"))
.permission("myplugin.command.message")
Expand Down
2 changes: 2 additions & 0 deletions source/plugin/commands/childcommands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ The first alias supplied is the primary one and will appear in the usage message

import org.spongepowered.api.Sponge;

PluginContainer plugin = ...;

CommandSpec mailCommandSpec = CommandSpec.builder()
.permission("myplugin.mail")
.description(Text.of("Send and receive mails"))
Expand Down
3 changes: 2 additions & 1 deletion source/plugin/commands/commandcallable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ The first step is to create a class for the command. The class has to implement
return usage;
}

public List<String> getSuggestions(CommandSource source, String arguments) throws CommandException {
public List<String> getSuggestions(CommandSource source, String arguments, @Nullable Location<World> targetPosition) throws CommandException {
ImMorpheus marked this conversation as resolved.
Show resolved Hide resolved
return Collections.emptyList();
}
}
Expand All @@ -82,6 +82,7 @@ passing your plugin, an instance of the command, and any needed aliases as param
import org.spongepowered.api.command.CommandManager;

CommandManager cmdService = Sponge.getCommandManager();
PluginContainer plugin = ...;
cmdService.register(plugin, new MyBroadcastCommand(), "message", "broadcast");

.. note::
Expand Down
2 changes: 2 additions & 0 deletions source/plugin/commands/creating.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Example: Building a Simple Command
import org.spongepowered.api.text.Text;
import org.spongepowered.api.command.spec.CommandSpec;

PluginContainer plugin = ...;

CommandSpec myCommandSpec = CommandSpec.builder()
.description(Text.of("Hello World Command"))
.permission("myplugin.command.helloworld")
Expand Down
7 changes: 4 additions & 3 deletions source/plugin/commands/service.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ them to the right command handler. To register your command, use the method
:javadoc:`CommandManager#register(Object, CommandCallable, String...)` passing your plugin, an instance of the command,
and any needed aliases as parameters.

Usually you want to register your commands when the :javadoc:`GameInitializationEvent` is called. If you are registering
the commands from the main plugin class, use ``this`` as the ``plugin`` parameter.
Usually you want to register your commands when the :javadoc:`GameInitializationEvent` is called.

.. code-block:: java

import org.spongepowered.api.Sponge;
import org.spongepowered.api.command.CommandManager;

PluginContainer plugin = ...;

CommandManager cmdManager = Sponge.getCommandManager();
cmdManager.register(this, myCommandSpec, "alias1", "alias2", "alias3");
cmdManager.register(plugin, myCommandSpec, "alias1", "alias2", "alias3");

.. note::

Expand Down
2 changes: 1 addition & 1 deletion source/plugin/configuration/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ specific directory or to ``true`` to get the shared configuration directory.

.. note::

The use of YAML format (http://yaml.org/spec/1.1/) and JSON format (https://www.json.org/) is also supported, but
The use of YAML format (https://yaml.org/spec/1.1/) and JSON format (https://www.json.org/) is also supported, but
the preferred config format for Sponge plugins is HOCON. Conversion from YAML (or JSON) to HOCON can be automated by
using a :javadoc:`YAMLConfigurationLoader` (or :javadoc:`GsonConfigurationLoader`) to load the old config and then
saving it using a :javadoc:`HoconConfigurationLoader`.
9 changes: 7 additions & 2 deletions source/plugin/configuration/loaders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,17 @@ You can use :doc:`the Asset API <../assets>` to do this, as shown in the example

.. code-block:: java

Sponge.getAssetManager().getAsset(myplugin, "default.conf").get().copyToFile(path, false, true);
PluginContainer plugin = ...;
Path path = ...;

Sponge.getAssetManager().getAsset(plugin, "default.conf").get().copyToFile(path, false, true);
loader = HoconConfigurationLoader.builder().setPath(path).build();
rootNode = loader.load();

For this example it is important to note that the :javadoc:`AssetManager#getAsset(String)` method works relative to the
plugin's asset folder. So, if in the above example the plugin ID is ``myplugin``, the ``default.conf`` file
must not lie in the jar file root, but instead in the directory ``assets/myplugin``. This example also uses
:javadoc:`Asset#copyToFile(String, boolean, boolean)` which allows an the file creation to override existing
:javadoc:`Asset#copyToFile(Path, boolean, boolean)` which allows an the file creation to override existing
ImMorpheus marked this conversation as resolved.
Show resolved Hide resolved
files only if specified.

.. note::
Expand All @@ -174,6 +177,8 @@ copying to a file as this will automatically place values that were absent while

.. code-block:: java

PluginContainer plugin = ...;

node.mergeValuesFrom(HoconConfigurationLoader.builder()
.setURL(plugin.getAsset("default.conf").get().getUrl())
.build()
Expand Down
7 changes: 4 additions & 3 deletions source/plugin/data/custom/datamanipulators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Custom DataManipulators
org.spongepowered.api.data.key.KeyFactory
org.spongepowered.api.data.manipulator.DataManipulator
org.spongepowered.api.data.manipulator.ImmutableDataManipulator
org.spongepowered.api.data.manipulator.immutable.common.AbstractImmutableData
org.spongepowered.api.data.manipulator.mutable.common.AbstractBoundedComparableData
org.spongepowered.api.data.manipulator.mutable.common.AbstractData
org.spongepowered.api.data.manipulator.mutable.common.AbstractSingleData
Expand Down Expand Up @@ -185,7 +186,7 @@ To register a ``DataManipulator`` Sponge has the :javadoc:`DataRegistration#buil
.builder(new CustomDataBuilder())
.manipulatorId("my-custom")
.dataName("My Custom")
.buildAndRegister(myPluginContainer);
.build();
}

.. warning::
Expand Down Expand Up @@ -321,8 +322,8 @@ Registering Values
------------------

Next, you'll want to register these so that the :doc:`Keys <../keys>`-based system can reference them. To do this,
implement either :javadoc:`DataManipulator#registerGettersAndSetters()` or
:javadoc:`ImmutableDataManipulator#registerGetters()` depending on whether the data is mutable or not.
implement either :javadoc:`AbstractData#registerGettersAndSetters()` or
:javadoc:`AbstractImmutableData#registerGetters()` depending on whether the data is mutable or not.

For each value you must call:

Expand Down
15 changes: 0 additions & 15 deletions source/plugin/event/filters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Event Filters
org.spongepowered.api.data.value.mutable.CompositeValueStore
org.spongepowered.api.util.Tristate
java.lang.Class
java.lang.String

Now that you've spent a bit of time working with events you've probably noticed that there are several preconditions that you
very commonly check while writing an event listener. Event filters are a group of annotations that assist you by allowing you
Expand Down Expand Up @@ -151,20 +150,6 @@ contained no players.**
:javadoc:`Cause#root()`. It also performs an additional check that the type of the root object matches the type of your
parameter.

**@Named** This parameter source annotation tells the event system to find the object with the name specified by the annotation
parameter (This is equivalent to :javadoc:`Cause#get(String, Class)`). Additionally, the found object must match the
type of the parameter. If no object is found meeting these criteria, then your listener is not called.

**In this example your listener will only be called if there is a player associated with the name**
``NamedCause.OWNER``\ **. The** ``player`` **parameter will be set to that player.**

.. code-block:: java

@Listener
public void onInteract(InteractBlockEvent.Secondary event, @Named(NamedCause.OWNER) Player player) {
// do something
}

**@Getter** This parameter source annotation will fetch a getter on the event with the specified name. If the specified
getter returns an ``Optional``, ``@Getter`` will automatically unwrap the ``Optional``.

Expand Down
Loading