Permalink
Browse files

Rewrite the RTP system.

There are several things going on here, but the biggest is that I've created a RTP registry module so custom RTP algorithms can be used with Nucleus.

The motivation behind this is that the RTP system for Nucleus has been a little sub par for some time. This is due to the fact that there are a lot of wants and needs for servers, but it usually boils down to wanting specific biome teleportation or some other spread of teleportation, or even location specific teleportation.

As I have no interest in doing all of this, my usual respose is to "go write your own plugin". However, the nucleus RTP handler is often still desired. So, the idea is that plugins can write their own kernels and register them, then server owners can choose the kernel they want to use in the config. Config options would be passed onto the kernel with `/rtp`.

This would expose a service to register and use kernels, as well as create a registry module for RTP.

As a side effect, this will pull out the code to pick a spot to make it more testable for robustness.

This is in order to fix #1223 by ripping the code into its own class and make it more testable, but also to enable customisation by plugin authors.

* Update QSML to 0.11.0
* Bump snapshot version to 1.5.0
  • Loading branch information...
dualspiral committed Jul 27, 2018
1 parent 06d78fa commit 515ea3b5f4a3439d77b9068aa8a71e9571e3f1ba
Showing with 1,146 additions and 271 deletions.
  1. +2 −2 build.gradle
  2. +0 −32 changelogs/templates/1.4.7-S7.0.md
  3. +58 −0 changelogs/templates/1.5.0-S7.0.md
  4. +47 −0 nucleus-api/src/main/java/io/github/nucleuspowered/nucleus/api/rtp/RTPKernel.java
  5. +52 −0 nucleus-api/src/main/java/io/github/nucleuspowered/nucleus/api/rtp/RTPKernels.java
  6. +191 −0 nucleus-api/src/main/java/io/github/nucleuspowered/nucleus/api/service/NucleusRTPService.java
  7. +20 −0 src/main/java/io/github/nucleuspowered/nucleus/internal/CatalogTypeFinalStaticProcessor.java
  8. +1 −0 src/main/java/io/github/nucleuspowered/nucleus/internal/Constants.java
  9. +25 −0 src/main/java/io/github/nucleuspowered/nucleus/internal/annotations/Registry.java
  10. +32 −0 src/main/java/io/github/nucleuspowered/nucleus/internal/qsml/module/StandardModule.java
  11. +74 −0 src/main/java/io/github/nucleuspowered/nucleus/internal/registry/NucleusRegistryModule.java
  12. +4 −0 src/main/java/io/github/nucleuspowered/nucleus/modules/rtp/RTPModule.java
  13. +69 −219 src/main/java/io/github/nucleuspowered/nucleus/modules/rtp/commands/RandomTeleportCommand.java
  14. +82 −18 src/main/java/io/github/nucleuspowered/nucleus/modules/rtp/config/RTPConfig.java
  15. +39 −0 src/main/java/io/github/nucleuspowered/nucleus/modules/rtp/config/RTPConfigAdapter.java
  16. +30 −0 src/main/java/io/github/nucleuspowered/nucleus/modules/rtp/kernels/AroundPlayerAndSurfaceKernel.java
  17. +30 −0 src/main/java/io/github/nucleuspowered/nucleus/modules/rtp/kernels/AroundPlayerKernel.java
  18. +86 −0 src/main/java/io/github/nucleuspowered/nucleus/modules/rtp/kernels/DefaultKernel.java
  19. +34 −0 src/main/java/io/github/nucleuspowered/nucleus/modules/rtp/kernels/KernelHelper.java
  20. +35 −0 src/main/java/io/github/nucleuspowered/nucleus/modules/rtp/kernels/SurfaceKernel.java
  21. +50 −0 src/main/java/io/github/nucleuspowered/nucleus/modules/rtp/registry/RTPRegistryModule.java
  22. +59 −0 src/main/java/io/github/nucleuspowered/nucleus/modules/rtp/service/RTPOptions.java
  23. +72 −0 src/main/java/io/github/nucleuspowered/nucleus/modules/rtp/service/RTPOptionsBuilder.java
  24. +45 −0 src/main/java/io/github/nucleuspowered/nucleus/modules/rtp/service/RTPService.java
  25. +9 −0 src/main/resources/assets/nucleus/messages.properties
View
@@ -40,7 +40,7 @@ allprojects {
apply plugin: 'java'
}
project.ext.versionno = '1.4.7'
project.ext.versionno = '1.5.0'
project.ext.minecraftversion = '1.12.2'
project.ext.spongeapiversion = '7.0'
project.ext.suffix = '-SNAPSHOT'
@@ -100,7 +100,7 @@ group 'io.github.nucleuspowered'
ext.spongeapi = '7.1.0-SNAPSHOT'
def qsmlDep = "uk.co.drnaylor:quickstart-moduleloader:0.10.1"
def qsmlDep = "uk.co.drnaylor:quickstart-moduleloader:0.11.0"
def geoIpDep = 'com.maxmind.geoip2:geoip2:2.10.0'
def neutrinoDep = 'io.github.nucleuspowered:neutrino:1.1.3'

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,58 @@
## New Features
### Completely rewritten the Random Teleport system
RTP had loads of problems (the code was _awful_), so I have taken the time to rewrite it. It should be a lot faster now (I found surface teleports
were rarely failing with the new system!), and is also a lot more extensible for developers who want to use Nucleus RTP with their own tweaks.
#### IMPORTANT NOTE ABOUT RTP CONFIGURATION
**Please note that the config has changed a bit**. Despite my best efforts, some configs may not migrate properly, particularly if you have
surface only warps enabled.
"surface-only" and "center-on-player" options have been removed and replaced with "default-mode". These are (by default):
* "nucleus:default" - the default RTP behaviour, which selects a point around the spawn location
* "nucleus:surface_only" - which selects a point around the spawn location **that is on the surface**
* "nucleus:around_player" - which selects a point around the player location
* "nucleus:around_player_surface" - which selects a point around the player location **that is on the surface**
Please take a moment to check your settings to ensure you get what you want out of RTP when you upgrade.
### Added `/enderchest` support for offline players
Now you can inspect enderchests of offline players, thanks to recent updates in Sponge. You must have the `nucleus.enderchest.offline`
permission, and you must be using a recent version of Sponge. Nucleus will tell you if the version you are using is too old.
### Updated `/speed` command
You may now reset a users' speed by using the "reset" string in place of a speed. The description for the command
has also been updated.
### Added ability to exempt some worlds from "spawn on login"
You can now mark worlds as exempt from the spawn on login action, that is, if a player logs into an exempt world,
they will not be moved to the spawn point if the spawn on login feature is enabled.
## API updates
### Added `NucleusRTPService`
The `NucleusRTPService` allows developers to use the Nucleus RTP engine for their own random location needs! It also
allows developers to create their own location finding routines for use with the Nucleus RTP command. Developers can
create their own `RTPKernel` and register it using `NucleusRTPService#registerKernel`, and then have users add the ID
as `default-mode`.
### Added `NucleusChangeNicknameEvent.Post`
This occurs after a nickname change. It is a read only event.
### Added `NucleusChangeNicknameEvent.Pre`, deprecated usage of base `NucleusChangeNicknameEvent`
Please use `NucleusChangeNicknameEvent.Pre` instead of `NucleusChangeNicknameEvent` in the future.
`NucleusChangeNicknameEvent` will become the base event for both `Pre` and `Post` in v2.0.
## Bugfixes
* Fix incorrect spawn login exemption permission in config comment
* Fix global spawn settings taking players out of jails on login (players will now always be reset to the jail point on login)
@@ -0,0 +1,47 @@
/*
* This file is part of Nucleus, licensed under the MIT License (MIT). See the LICENSE.txt file
* at the root of this project for more details.
*/
package io.github.nucleuspowered.nucleus.api.rtp;
import io.github.nucleuspowered.nucleus.api.service.NucleusRTPService;
import org.spongepowered.api.CatalogType;
import org.spongepowered.api.registry.util.PluginProvidedRegistryModule;
import org.spongepowered.api.util.annotation.CatalogedBy;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;
import java.util.Optional;
import javax.annotation.Nullable;
/**
* An {@link RTPKernel} provides the instructions for how to select
* a location when using RTP.
*
* <p>RTPKernels can be registered in the appropriate registry.</p>
*
* <p>Kernels <em>can</em> base logic on a supplied location, but
* are expected to handle cases where a {@code null} or invalid
* location is supplied.</p>
*/
@PluginProvidedRegistryModule
@CatalogedBy(RTPKernels.class)
public interface RTPKernel extends CatalogType {
/**
* Gets a new location.
*
* <p>Note that this may fail if the search times out. This does not
* indicate a failing routine.</p>
*
* @param currentLocation The current location of the entity to teleport, if appropriate
* @param target The target world for teleport
* @param options The options to consider when teleporting
* @return The location to teleport to, if any.
*/
Optional<Location<World>> getLocation(
@Nullable Location<World> currentLocation,
World target,
NucleusRTPService.RTPOptions options);
}
@@ -0,0 +1,52 @@
/*
* This file is part of Nucleus, licensed under the MIT License (MIT). See the LICENSE.txt file
* at the root of this project for more details.
*/
package io.github.nucleuspowered.nucleus.api.rtp;
import org.spongepowered.api.util.generator.dummy.DummyObjectProvider;
/**
* Nucleus supplied {@link RTPKernel}s.
*
* <p><strong>A word of warning</strong>, if the RTP module has not been initialised,
* this objects will remain as dummy objects and will not function.</p>
*
* <p>Check that the {@link io.github.nucleuspowered.nucleus.api.service.NucleusRTPService}
* exists first before attempting to use these kernels.</p>
*/
public final class RTPKernels {
private RTPKernels() {} // No instantiation please!
/**
* The default Nucleus RTP kernel, adjusted to centre around the player,
* not the world border centre.
*
* <p>This has an ID of {@code nucleus:around_player}</p>
*/
public final static RTPKernel AROUND_PLAYER = DummyObjectProvider.createFor(RTPKernel.class, "AROUND_PLAYER");
/**
* The default Nucleus RTP kernel, adjusted to centre around the player,
* not the world border centre, and surface only
*
* <p>This has an ID of {@code nucleus:around_player_surface}</p>
*/
public final static RTPKernel AROUND_PLAYER_SURFACE = DummyObjectProvider.createFor(RTPKernel.class, "AROUND_PLAYER_SURFACE");
/**
* The default Nucleus RTP kernel.
*
* <p>This has an ID of {@code nucleus:default}</p>
*/
public final static RTPKernel DEFAULT = DummyObjectProvider.createFor(RTPKernel.class, "DEFAULT");
/**
* The default Nucleus RTP kernel, adjusted to ensure locations are surface only.
*
* <p>This has an ID of {@code nucleus:surface_only}</p>
*/
public final static RTPKernel SURFACE_ONLY = DummyObjectProvider.createFor(RTPKernel.class, "SURFACE_ONLY");
}
Oops, something went wrong.

0 comments on commit 515ea3b

Please sign in to comment.