-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
Make (most of) the examples executable again #695
Conversation
Also make some changes to simplify future code checks.
source/plugin/scheduler.rst
Outdated
| | | could look like "fooplugin-A-12". No two active tasks will have the same | | | ||
| | | serial ID for the same synchronization type. If a task name is specified, | | | ||
| | | it should be descriptive and aid users in debugging your plugin. | | | ||
+-----------------+-------------------------+---------------------------------------------------------------------------+----------------------------------------------------+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Revert this
source/plugin/wgen/customwgen.rst
Outdated
buffer.setBiome(x, y, BiomeTypes.FOREST); | ||
} else if (x * x + y * y < BEACH_RADIUS) { | ||
buffer.setBiome(x, y, BiomeTypes.BEACH); | ||
for (int z = min.getY(); z <= max.getY(); z++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Use Z
838c3da
to
d3fda5d
Compare
There are some "cosmetic" changes such as
|
@@ -214,7 +214,7 @@ There add a line to register (and create) your used keys. | |||
|
|||
.. code-block:: java | |||
|
|||
keyMap.put("health"), makeSingleKey(Double.class, MutableBoundedValue.class, of("Health"))); | |||
keyMap.put("health", makeSingleKey(Double.class, MutableBoundedValue.class, of("Health"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the key stuff needs to be updated to use the register method like so:
this.register(Key.builder().type(TypeTokens.BOUNDED_DOUBLE_VALUE_TOKEN).id("health").name("Health").query(of("Health")).build())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
source/plugin/assets.rst
Outdated
@@ -50,7 +50,10 @@ following code: | |||
import java.nio.file.Files; | |||
|
|||
if (Files.notExists(configPath)) { | |||
plugin.getAsset("default.conf").copyToFile(configPath); | |||
Optional<Asset> asset = plugin.getAsset("default.conf"); | |||
if (asset.isPresent()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can simplify this to
plugin.getAsset("default.conf").ifPresent(asset -> asset.copyToDirectory(configPath));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
source/plugin/entities/spawning.rst
Outdated
@@ -35,8 +32,7 @@ For example, let's try to spawn a Creeper: | |||
World world = spawnLocation.getExtent(); | |||
Entity creeper = world | |||
.createEntity(EntityTypes.CREEPER, spawnLocation.getPosition()); | |||
SpawnCause spawnCause = SpawnCause.builder().type(SpawnTypes.PLUGIN).build(); | |||
world.spawnEntity(creeper, Cause.source(spawnCause).build()); | |||
world.spawnEntity(creeper); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be pushing to the cause stack frame for a SpawnType.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
source/plugin/items/creating.rst
Outdated
} | ||
Entity item = extent.createEntity(EntityTypes.ITEM, spawnLocation.getPosition()); | ||
item.offer(Keys.REPRESENTED_ITEM, superMegaAwesomeSword.createSnapshot()); | ||
extent.spawnEntity(item); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise here, need to add the SpawnType
to the context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can wrap with:
try (CauseStackManager.StackFrame frame = Sponge.getCauseStackManager().pushStackFrame()) {
frame.addContext(EventContextKeys.SPAWN_TYPE, SpawnTypes.PLACEMENT);
extent.spawnEntity(item);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
8c4b8b6
to
85d0aee
Compare
fa82eaa
to
5df4f63
Compare
@gabizou I fixed the issues you pointed out in your comments. Is everything now correct? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor things, but overall functional.
|
||
public SpongeHealthData() { | ||
this(DataConstants.DEFAULT_HEALTH, DataConstants.DEFAULT_HEALTH); | ||
this(DEFAULT_HEALTH, DEFAULT_HEALTH); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather have this not static imported, only because static imports are somewhat evil ambiguous as to where they (the constants) come from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
source/plugin/entities/spawning.rst
Outdated
|
||
Entity creeper = world.createEntity(EntityTypes.CREEPER, spawnLocation.getPosition()); | ||
|
||
try (StackFrame frame = Sponge.getCauseStackManager().pushCauseFrame()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if the cause stack manager is documented, but may want to add a code comment that the context needs to be wrapped in the frame because of the changes.
Likewise, mention that the plugin's PluginContainer
is already pushed to the cause stack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that works.
As mentioned in #437 (comment) I went through all code examples and tried to make sure that they actually compile with API version 7.
I also make some changes to simplify future code checks.
I couldn't verify some parts such as whether the method signature is still correct if only a method is contained in that code example. There are currently 292 Java Code Blocks in there.
Fixes #571.