mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 22:17:17 +00:00
Merge remote-tracking branch 'origin/big-refactor' into big-refactor
This commit is contained in:
61 files changed
+1113
-733
No files matched your search
@@ -13,12 +13,12 @@ import net.william278.huskhomes.database.Database;
|
||||
import net.william278.huskhomes.event.EventDispatcher;
|
||||
import net.william278.huskhomes.hook.EconomyHook;
|
||||
import net.william278.huskhomes.hook.MapHook;
|
||||
import net.william278.huskhomes.hook.PluginHook;
|
||||
import net.william278.huskhomes.hook.Hook;
|
||||
import net.william278.huskhomes.manager.Manager;
|
||||
import net.william278.huskhomes.network.Broker;
|
||||
import net.william278.huskhomes.position.Location;
|
||||
import net.william278.huskhomes.position.Position;
|
||||
import net.william278.huskhomes.position.Server;
|
||||
import net.william278.huskhomes.config.Server;
|
||||
import net.william278.huskhomes.position.World;
|
||||
import net.william278.huskhomes.random.RandomTeleportEngine;
|
||||
import net.william278.huskhomes.user.ConsoleUser;
|
||||
@@ -161,43 +161,26 @@ public interface HuskHomes extends TaskRunner, EventDispatcher {
|
||||
void setServerSpawn(@NotNull Location location);
|
||||
|
||||
/**
|
||||
* Set of active {@link PluginHook}s running on the server
|
||||
* Set of active {@link Hook}s running on the server
|
||||
*
|
||||
* @return the {@link Set} of active {@link PluginHook}s
|
||||
* @return the {@link Set} of active {@link Hook}s
|
||||
*/
|
||||
@NotNull
|
||||
Set<PluginHook> getPluginHooks();
|
||||
List<Hook> getHooks();
|
||||
|
||||
/**
|
||||
* Finds the {@link PluginHook} of the given class instance from the set of active {@link PluginHook}s
|
||||
*
|
||||
* @param hookClass the class of the {@link PluginHook} to get
|
||||
* @param <H> the type of the {@link PluginHook}
|
||||
* @return the {@link PluginHook} instance, or an empty {@link Optional} if not found
|
||||
*/
|
||||
default <H extends PluginHook> Optional<H> getHook(@NotNull Class<H> hookClass) {
|
||||
return getPluginHooks().stream()
|
||||
.filter(hook -> hook.getClass().isInstance(hookClass))
|
||||
.findFirst()
|
||||
.map(hookClass::cast);
|
||||
default <T extends Hook> Optional<T> getHook(@NotNull Class<T> hookClass) {
|
||||
return getHooks().stream()
|
||||
.filter(hook -> hookClass.isAssignableFrom(hook.getClass()))
|
||||
.map(hookClass::cast)
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link MapHook} being used to display public homes and warps on a web map, if there is one, and it is enabled
|
||||
*
|
||||
* @return the {@link MapHook} optionally being used
|
||||
*/
|
||||
default Optional<MapHook> getMapHook() {
|
||||
return getSettings().doMapHook() ? getHook(MapHook.class) : Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link EconomyHook} being used to charge players for commands, if there is one, and it is enabled
|
||||
*
|
||||
* @return the {@link EconomyHook} optionally being used
|
||||
*/
|
||||
default Optional<EconomyHook> getEconomyHook() {
|
||||
return getSettings().doEconomy() ? getHook(EconomyHook.class) : Optional.empty();
|
||||
return getHook(EconomyHook.class);
|
||||
}
|
||||
|
||||
default Optional<MapHook> getMapHook() {
|
||||
return getHook(MapHook.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -123,6 +124,40 @@ public abstract class BaseHuskHomesAPI {
|
||||
plugin.runAsync(() -> plugin.getDatabase().updateUserData(savedUser));
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit {@link SavedUser} data for a given player by username, if they exist.
|
||||
*
|
||||
* @param username The username of the user to edit data for.
|
||||
* @param editor A {@link Consumer} that will be passed the {@link SavedUser} to edit
|
||||
* @since 4.0
|
||||
*/
|
||||
public final void editUserData(@NotNull String username, @NotNull Consumer<SavedUser> editor) {
|
||||
plugin.runAsync(() -> {
|
||||
Optional<SavedUser> savedUser = plugin.getDatabase().getUserDataByName(username);
|
||||
if (savedUser.isPresent()) {
|
||||
editor.accept(savedUser.get());
|
||||
plugin.getDatabase().updateUserData(savedUser.get());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit {@link SavedUser} data for the given player's account {@link UUID}, if they exist.
|
||||
*
|
||||
* @param uuid The {@link UUID} of the user to edit data for.
|
||||
* @param editor A {@link Consumer} that will be passed the {@link SavedUser} to edit
|
||||
* @since 4.0
|
||||
*/
|
||||
public final void editUserData(@NotNull UUID uuid, @NotNull Consumer<SavedUser> editor) {
|
||||
plugin.runAsync(() -> {
|
||||
Optional<SavedUser> savedUser = plugin.getDatabase().getUserData(uuid);
|
||||
if (savedUser.isPresent()) {
|
||||
editor.accept(savedUser.get());
|
||||
plugin.getDatabase().updateUserData(savedUser.get());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of {@link Home}s set by the given user.
|
||||
*
|
||||
@@ -142,11 +177,22 @@ public abstract class BaseHuskHomesAPI {
|
||||
* @since 3.0
|
||||
*/
|
||||
public final CompletableFuture<List<Home>> getUserPublicHomes(@NotNull User user) {
|
||||
return getUserHomes(user).thenApply(homes -> homes.stream()
|
||||
return plugin.supplyAsync(() -> plugin.getDatabase().getHomes(user).stream()
|
||||
.filter(Home::isPublic)
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of public homes local to this server
|
||||
*
|
||||
* @param user The {@link User} to get the local public homes of
|
||||
* @return A {@link CompletableFuture} that will complete with a list of public {@link Home}s local to the server
|
||||
* @since 4.0
|
||||
*/
|
||||
public final CompletableFuture<List<Home>> getLocalPublicHomes(@NotNull User user) {
|
||||
return plugin.supplyAsync(() -> plugin.getDatabase().getLocalPublicHomes(plugin));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of homes that have been made public ("public homes")
|
||||
*
|
||||
@@ -169,6 +215,7 @@ public abstract class BaseHuskHomesAPI {
|
||||
return plugin.supplyAsync(() -> plugin.getDatabase().getHome(user, homeName));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a {@link Home} from the database by its' unique id
|
||||
*
|
||||
@@ -179,6 +226,141 @@ public abstract class BaseHuskHomesAPI {
|
||||
return plugin.supplyAsync(() -> plugin.getDatabase().getHome(homeUuid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a home for a given user with the specified name and position
|
||||
*
|
||||
* @param owner The {@link User} to create the home for
|
||||
* @param name The name of the home
|
||||
* @param position The {@link Position} of the home
|
||||
* @since 4.0
|
||||
*/
|
||||
public void createHome(@NotNull User owner, @NotNull String name, @NotNull Position position) {
|
||||
plugin.runAsync(() -> plugin.getManager().homes().createHome(owner, name, position, false, false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a home for a given user with the specified name
|
||||
*
|
||||
* @param owner The {@link User} to delete the home for
|
||||
* @param name The name of the home
|
||||
* @since 4.0
|
||||
*/
|
||||
public final void deleteHome(@NotNull User owner, @NotNull String name) {
|
||||
plugin.runAsync(() -> plugin.getManager().homes().deleteHome(owner, name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a home
|
||||
*
|
||||
* @param home The {@link Home} to delete
|
||||
* @since 4.0
|
||||
*/
|
||||
public final void deleteHome(@NotNull Home home) {
|
||||
plugin.runAsync(() -> plugin.getManager().homes().deleteHome(home));
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename a home for a given user
|
||||
*
|
||||
* @param owner The {@link User} to rename the home for
|
||||
* @param oldName The name of the home to rename
|
||||
* @param newName The new name of the home
|
||||
* @since 4.0
|
||||
*/
|
||||
public final void renameHome(@NotNull User owner, @NotNull String oldName, @NotNull String newName) {
|
||||
plugin.runAsync(() -> plugin.getManager().homes().setHomeName(owner, oldName, newName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename a home
|
||||
*
|
||||
* @param home The {@link Home} to rename
|
||||
* @param newName The new name of the home
|
||||
* @since 4.0
|
||||
*/
|
||||
public final void renameHome(@NotNull Home home, @NotNull String newName) {
|
||||
plugin.runAsync(() -> plugin.getManager().homes().setHomeName(home, newName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the privacy of a home
|
||||
*
|
||||
* @param owner The {@link User} to set the privacy of the home for
|
||||
* @param name The name of the home
|
||||
* @param isPublic Whether the home should be public or not
|
||||
* @since 4.0
|
||||
*/
|
||||
public final void setHomePrivacy(@NotNull User owner, @NotNull String name, boolean isPublic) {
|
||||
plugin.runAsync(() -> plugin.getManager().homes().setHomePrivacy(owner, name, isPublic));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the privacy of a home
|
||||
*
|
||||
* @param home The {@link Home} to set the privacy of
|
||||
* @param isPublic Whether the home should be public or not
|
||||
* @since 4.0
|
||||
*/
|
||||
public final void setHomePrivacy(@NotNull Home home, boolean isPublic) {
|
||||
plugin.runAsync(() -> plugin.getManager().homes().setHomePrivacy(home, isPublic));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the description of a home
|
||||
*
|
||||
* @param owner The {@link User} to set the description of the home for
|
||||
* @param name The name of the home
|
||||
* @param description The description of the home
|
||||
* @since 4.0
|
||||
*/
|
||||
public final void setHomeDescription(@NotNull User owner, @NotNull String name, @NotNull String description) {
|
||||
plugin.runAsync(() -> plugin.getManager().homes().setHomeDescription(owner, name, description));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the description of a home
|
||||
*
|
||||
* @param home The {@link Home} to set the description of
|
||||
* @param description The description of the home
|
||||
* @since 4.0
|
||||
*/
|
||||
public final void setHomeDescription(@NotNull Home home, @NotNull String description) {
|
||||
plugin.runAsync(() -> plugin.getManager().homes().setHomeDescription(home, description));
|
||||
}
|
||||
|
||||
/**
|
||||
* Relocate a home for a given user
|
||||
*
|
||||
* @param owner The {@link User} to relocate the home for
|
||||
* @param name The name of the home
|
||||
* @param position The new {@link Position} of the home
|
||||
* @since 4.0
|
||||
*/
|
||||
public final void relocateHome(@NotNull User owner, @NotNull String name, @NotNull Position position) {
|
||||
plugin.runAsync(() -> plugin.getManager().homes().setHomePosition(owner, name, position));
|
||||
}
|
||||
|
||||
/**
|
||||
* Relocate a home
|
||||
*
|
||||
* @param home The {@link Home} to relocate
|
||||
* @param position The new {@link Position} of the home
|
||||
* @since 4.0
|
||||
*/
|
||||
public final void relocateHome(@NotNull Home home, @NotNull Position position) {
|
||||
plugin.runAsync(() -> plugin.getManager().homes().setHomePosition(home, position));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of {@link Warp}s local to this server
|
||||
*
|
||||
* @return A {@link CompletableFuture} that will complete with a list of {@link Warp}s local to the server
|
||||
* @since 4.0
|
||||
*/
|
||||
public final CompletableFuture<List<Warp>> getLocalWarps() {
|
||||
return plugin.supplyAsync(() -> plugin.getDatabase().getLocalWarps(plugin));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of {@link Warp}s
|
||||
*
|
||||
@@ -210,6 +392,95 @@ public abstract class BaseHuskHomesAPI {
|
||||
return plugin.supplyAsync(() -> plugin.getDatabase().getWarp(warpUuid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Warp} with the given name and {@link Position}
|
||||
*
|
||||
* @param name The name of the warp
|
||||
* @param position The {@link Position} of the warp
|
||||
* @since 4.0
|
||||
*/
|
||||
public final void createWarp(@NotNull String name, @NotNull Position position) {
|
||||
plugin.runAsync(() -> plugin.getManager().warps().createWarp(name, position));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a {@link Warp} with the given name
|
||||
*
|
||||
* @param name The name of the warp to delete
|
||||
*/
|
||||
public final void deleteWarp(@NotNull String name) {
|
||||
plugin.runAsync(() -> plugin.getManager().warps().deleteWarp(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a {@link Warp}
|
||||
*
|
||||
* @param warp The {@link Warp} to delete
|
||||
*/
|
||||
public final void deleteWarp(@NotNull Warp warp) {
|
||||
plugin.runAsync(() -> plugin.getManager().warps().deleteWarp(warp));
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename a {@link Warp} by name
|
||||
*
|
||||
* @param oldName The name of the warp to rename
|
||||
* @param newName The new name of the warp
|
||||
*/
|
||||
public final void renameWarp(@NotNull String oldName, @NotNull String newName) {
|
||||
plugin.runAsync(() -> plugin.getManager().warps().setWarpName(oldName, newName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename a {@link Warp}
|
||||
*
|
||||
* @param warp The {@link Warp} to rename
|
||||
* @param newName The new name of the warp
|
||||
*/
|
||||
public final void renameWarp(@NotNull Warp warp, @NotNull String newName) {
|
||||
plugin.runAsync(() -> plugin.getManager().warps().setWarpName(warp, newName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the description of a {@link Warp} by name
|
||||
*
|
||||
* @param name The name of the warp to set the description of
|
||||
* @param description The new description of the warp
|
||||
*/
|
||||
public final void setWarpDescription(@NotNull String name, @NotNull String description) {
|
||||
plugin.runAsync(() -> plugin.getManager().warps().setWarpDescription(name, description));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the description of a {@link Warp}
|
||||
*
|
||||
* @param warp The {@link Warp} to set the description of
|
||||
* @param description The new description of the warp
|
||||
*/
|
||||
public final void setWarpDescription(@NotNull Warp warp, @NotNull String description) {
|
||||
plugin.runAsync(() -> plugin.getManager().warps().setWarpDescription(warp, description));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the {@link Position} of a {@link Warp} by name
|
||||
*
|
||||
* @param name The name of the warp to set the {@link Position} of
|
||||
* @param position The new {@link Position} of the warp
|
||||
*/
|
||||
public final void relocateWarp(@NotNull String name, @NotNull Position position) {
|
||||
plugin.runAsync(() -> plugin.getManager().warps().setWarpPosition(name, position));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the {@link Position} of a {@link Warp}
|
||||
*
|
||||
* @param warp The {@link Warp} to set the {@link Position} of
|
||||
* @param position The new {@link Position} of the warp
|
||||
*/
|
||||
public final void relocateWarp(@NotNull Warp warp, @NotNull Position position) {
|
||||
plugin.runAsync(() -> plugin.getManager().warps().setWarpPosition(warp, position));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the canonical {@link Position} of the spawn point. Note that if cross-server and global spawn
|
||||
* are enabled in the config, this may not return a position on this server.
|
||||
@@ -278,7 +549,7 @@ public abstract class BaseHuskHomesAPI {
|
||||
* @param rtpArgs Arguments that will be passed to the implementing {@link RandomTeleportEngine}
|
||||
* @since 3.0
|
||||
*/
|
||||
public final void randomlyTeleportPlayer(@NotNull OnlineUser user, final boolean timedTeleport, @NotNull String... rtpArgs) {
|
||||
public final void randomlyTeleportPlayer(@NotNull OnlineUser user, boolean timedTeleport, @NotNull String... rtpArgs) {
|
||||
plugin.runAsync(() -> {
|
||||
final Optional<Position> position = plugin.getRandomTeleportEngine()
|
||||
.getRandomPosition(user.getPosition().getWorld(), rtpArgs);
|
||||
|
||||
@@ -11,8 +11,8 @@ import java.util.List;
|
||||
|
||||
public class DelHomeCommand extends SavedPositionCommand<Home> {
|
||||
|
||||
public DelHomeCommand(@NotNull HuskHomes implementor) {
|
||||
super("delhome", List.of(), Home.class, List.of(), implementor);
|
||||
public DelHomeCommand(@NotNull HuskHomes plugin) {
|
||||
super("delhome", List.of(), Home.class, List.of(), plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,8 +10,8 @@ import java.util.List;
|
||||
|
||||
public class DelWarpCommand extends SavedPositionCommand<Warp> {
|
||||
|
||||
public DelWarpCommand(@NotNull HuskHomes implementor) {
|
||||
super("delwarp", List.of(), Warp.class, List.of(), implementor);
|
||||
public DelWarpCommand(@NotNull HuskHomes plugin) {
|
||||
super("delwarp", List.of(), Warp.class, List.of(), plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -88,7 +88,7 @@ public class EditHomeCommand extends SavedPositionCommand<Home> {
|
||||
|
||||
private void setHomeDescription(@NotNull CommandUser executor, @NotNull Home home, boolean ownerEditing, @NotNull String[] args) {
|
||||
final String oldDescription = home.getMeta().getDescription();
|
||||
final Optional<String> optionalDescription = parseGreedyString(args, 1);
|
||||
final Optional<String> optionalDescription = parseGreedyArguments(args);
|
||||
if (optionalDescription.isEmpty()) {
|
||||
plugin.getLocales().getLocale("error_invalid_syntax",
|
||||
"/edithome " + home.getName() + " description <text>")
|
||||
@@ -166,7 +166,7 @@ public class EditHomeCommand extends SavedPositionCommand<Home> {
|
||||
home.setPublic(privacyArg.get().equals("public"));
|
||||
plugin.fireEvent(plugin.getHomeEditEvent(home, executor), (event) -> {
|
||||
try {
|
||||
plugin.getManager().homes().setHomePrivacy(home, home.isPublic());
|
||||
plugin.getManager().homes().setHomePrivacy(event.getHome(), home.isPublic());
|
||||
} catch (ValidationException e) {
|
||||
int maxHomes = executor instanceof OnlineUser user ?
|
||||
user.getMaxPublicHomes(plugin.getSettings().getMaxPublicHomes(),
|
||||
|
||||
@@ -67,7 +67,7 @@ public class EditWarpCommand extends SavedPositionCommand<Warp> {
|
||||
}
|
||||
|
||||
private void setWarpDescription(@NotNull CommandUser executor, @NotNull Warp warp, @NotNull String[] args) {
|
||||
final Optional<String> optionalDescription = parseGreedyString(args, 1);
|
||||
final Optional<String> optionalDescription = parseGreedyArguments(args);
|
||||
if (optionalDescription.isEmpty()) {
|
||||
plugin.getLocales().getLocale("error_invalid_syntax",
|
||||
"/editwarp " + warp.getName() + " description <text>")
|
||||
@@ -99,7 +99,7 @@ public class EditWarpCommand extends SavedPositionCommand<Warp> {
|
||||
warp.update(user.getPosition());
|
||||
plugin.fireEvent(plugin.getWarpEditEvent(warp, executor), (event) -> {
|
||||
try {
|
||||
plugin.getManager().warps().relocateWarp(warp, warp);
|
||||
plugin.getManager().warps().setWarpPosition(warp, warp);
|
||||
} catch (ValidationException e) {
|
||||
e.dispatchWarpError(executor, plugin, warp.getName());
|
||||
return;
|
||||
|
||||
@@ -114,15 +114,15 @@ public abstract class Node implements Executable {
|
||||
return Optional.of(plugin.getWorlds().stream()
|
||||
.filter(world -> world.getName().equalsIgnoreCase(worldName))
|
||||
.findFirst()
|
||||
.orElse(new World(worldName, new UUID(0, 0), environment)));
|
||||
.orElse(World.from(worldName, new UUID(0, 0), environment)));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
protected Optional<String> parseGreedyString(@NotNull String[] args, int startIndex) {
|
||||
if (args.length > startIndex) {
|
||||
protected Optional<String> parseGreedyArguments(@NotNull String[] args) {
|
||||
if (args.length > 1) {
|
||||
final StringJoiner sentence = new StringJoiner(" ");
|
||||
for (int i = startIndex; i < args.length; i++) {
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
sentence.add(args[i]);
|
||||
}
|
||||
return Optional.of(sentence.toString().trim());
|
||||
@@ -132,7 +132,7 @@ public abstract class Node implements Executable {
|
||||
|
||||
protected Position getBasePosition(@NotNull CommandUser executor) {
|
||||
return executor instanceof OnlineUser user ? user.getPosition() : plugin.getSpawn()
|
||||
.orElse(new Position(0, 0, 0, 0, 0, plugin.getWorlds().get(0), plugin.getServerName()));
|
||||
.orElse(Position.at(0, 0, 0, 0, 0, plugin.getWorlds().get(0), plugin.getServerName()));
|
||||
}
|
||||
|
||||
protected Optional<Position> parsePositionArgs(@NotNull Position basePosition, @NotNull String[] args, int startIndex) {
|
||||
@@ -153,7 +153,7 @@ public abstract class Node implements Executable {
|
||||
final Optional<Float> yaw = parseFloatArg(args, startIndex + angleStartIndex);
|
||||
final Optional<Float> pitch = parseFloatArg(args, startIndex + angleStartIndex + 1);
|
||||
|
||||
return Optional.of(new Position(x.get(), y.get(), z.get(),
|
||||
return Optional.of(Position.at(x.get(), y.get(), z.get(),
|
||||
yaw.orElse(basePosition.getYaw()), pitch.orElse(basePosition.getPitch()),
|
||||
world.orElse(basePosition.getWorld()), server.orElse(basePosition.getServer())));
|
||||
}
|
||||
|
||||
@@ -64,13 +64,14 @@ public class RtpCommand extends Command {
|
||||
.orElseThrow(() -> new IllegalStateException("No user data found for " + teleporter.getUsername()));
|
||||
final Instant currentTime = Instant.now();
|
||||
if (executor.equals(teleporter) && !currentTime.isAfter(user.getRtpCooldown()) &&
|
||||
!executor.hasPermission(getPermission("bypass_cooldown"))) {
|
||||
!executor.hasPermission(getPermission("bypass_cooldown"))) {
|
||||
plugin.getLocales().getLocale("error_rtp_cooldown",
|
||||
Long.toString(currentTime.until(user.getRtpCooldown(), ChronoUnit.MINUTES) + 1))
|
||||
.ifPresent(executor::sendMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate a random position
|
||||
plugin.getLocales().getLocale("teleporting_random_generation")
|
||||
.ifPresent(teleporter::sendMessage);
|
||||
final Optional<Position> position = plugin.getRandomTeleportEngine()
|
||||
|
||||
@@ -14,8 +14,8 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class TpCommand extends Command implements TabProvider {
|
||||
|
||||
protected TpCommand(@NotNull HuskHomes implementor) {
|
||||
super("tp", List.of("tpo"), "[<player|position>] [target]", implementor);
|
||||
protected TpCommand(@NotNull HuskHomes plugin) {
|
||||
super("tp", List.of("tpo"), "[<player|position>] [target]", plugin);
|
||||
setOperatorCommand(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -172,4 +172,14 @@ public class Locales {
|
||||
.setSpaceBeforeFooter(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents where a locale should be displayed
|
||||
*/
|
||||
public enum DisplaySlot {
|
||||
CHAT,
|
||||
ACTION_BAR,
|
||||
SUBTITLE,
|
||||
TITLE
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package net.william278.huskhomes.position;
|
||||
package net.william278.huskhomes.config;
|
||||
|
||||
import net.william278.annotaml.YamlFile;
|
||||
import net.william278.annotaml.YamlKey;
|
||||
@@ -100,7 +100,7 @@ public class Settings {
|
||||
private int maxPublicHomes = 10;
|
||||
|
||||
@YamlKey("general.stack_permission_limits")
|
||||
private boolean stackPermissionLimits = true;
|
||||
private boolean stackPermissionLimits = false;
|
||||
|
||||
@YamlKey("general.permission_restrict_warps")
|
||||
private boolean permissionRestrictWarps = false;
|
||||
@@ -112,7 +112,7 @@ public class Settings {
|
||||
private int teleportWarmupTime = 5;
|
||||
|
||||
@YamlKey("general.teleport_warmup_display")
|
||||
private MessageDisplayType teleportWarmupDisplay = MessageDisplayType.ACTION_BAR;
|
||||
private Locales.DisplaySlot teleportWarmupDisplay = Locales.DisplaySlot.ACTION_BAR;
|
||||
|
||||
@YamlKey("general.teleport_request_expiry_time")
|
||||
private int teleportRequestExpiryTime = 60;
|
||||
@@ -249,7 +249,7 @@ public class Settings {
|
||||
private boolean doMapHook = false;
|
||||
|
||||
@YamlKey("map_hook.map_plugin")
|
||||
private MapHook.MappingPlugin mappingPlugin = MapHook.MappingPlugin.DYNMAP;
|
||||
private MapHook.Plugin type = MapHook.Plugin.DYNMAP;
|
||||
|
||||
@YamlKey("map_hook.show_public_homes")
|
||||
private boolean publicHomesOnMap = true;
|
||||
@@ -351,7 +351,7 @@ public class Settings {
|
||||
return teleportWarmupTime;
|
||||
}
|
||||
|
||||
public MessageDisplayType getTeleportWarmupDisplay() {
|
||||
public Locales.DisplaySlot getTeleportWarmupDisplay() {
|
||||
return teleportWarmupDisplay;
|
||||
}
|
||||
|
||||
@@ -479,15 +479,15 @@ public class Settings {
|
||||
return doMapHook;
|
||||
}
|
||||
|
||||
public MapHook.MappingPlugin getMappingPlugin() {
|
||||
return mappingPlugin;
|
||||
public MapHook.Plugin getMappingPlugin() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public boolean isPublicHomesOnMap() {
|
||||
public boolean doPublicHomesOnMap() {
|
||||
return publicHomesOnMap;
|
||||
}
|
||||
|
||||
public boolean isWarpsOnMap() {
|
||||
public boolean doWarpsOnMap() {
|
||||
return warpsOnMap;
|
||||
}
|
||||
|
||||
@@ -503,16 +503,6 @@ public class Settings {
|
||||
return brigadierTabCompletion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents where a chat message should display
|
||||
*/
|
||||
public enum MessageDisplayType {
|
||||
MESSAGE,
|
||||
ACTION_BAR,
|
||||
SUBTITLE,
|
||||
TITLE
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the sound effect to play when an action happens
|
||||
*/
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Spawn {
|
||||
*/
|
||||
@NotNull
|
||||
public Position getPosition(@NotNull String server) {
|
||||
return new Position(x, y, z, yaw, pitch, new World(worldName, UUID.fromString(worldUuid)), server);
|
||||
return Position.at(x, y, z, yaw, pitch, World.from(worldName, UUID.fromString(worldUuid)), server);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.william278.huskhomes.database;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.config.Server;
|
||||
import net.william278.huskhomes.position.*;
|
||||
import net.william278.huskhomes.teleport.Teleport;
|
||||
import net.william278.huskhomes.user.OnlineUser;
|
||||
@@ -86,7 +87,7 @@ public abstract class Database {
|
||||
* <b>(Internal use only)</b> - Updates position data
|
||||
*
|
||||
* @param positionId ID of the position to update
|
||||
* @param position the new position
|
||||
* @param position the Position.at
|
||||
* @param connection SQL connection
|
||||
* @throws SQLException if an SQL exception occurs doing this
|
||||
*/
|
||||
|
||||
@@ -302,15 +302,15 @@ public class MySqlDatabase extends Database {
|
||||
|
||||
final ResultSet resultSet = statement.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
userHomes.add(new Home(resultSet.getDouble("x"),
|
||||
userHomes.add(Home.from(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
World.from(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
resultSet.getString("server_name"),
|
||||
new PositionMeta(resultSet.getString("name"),
|
||||
PositionMeta.from(resultSet.getString("name"),
|
||||
resultSet.getString("description"),
|
||||
resultSet.getTimestamp("timestamp").toInstant(),
|
||||
resultSet.getString("tags")),
|
||||
@@ -338,15 +338,15 @@ public class MySqlDatabase extends Database {
|
||||
|
||||
final ResultSet resultSet = statement.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
warps.add(new Warp(resultSet.getDouble("x"),
|
||||
warps.add(Warp.from(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
World.from(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
resultSet.getString("server_name"),
|
||||
new PositionMeta(resultSet.getString("name"),
|
||||
PositionMeta.from(resultSet.getString("name"),
|
||||
resultSet.getString("description"),
|
||||
resultSet.getTimestamp("timestamp").toInstant(),
|
||||
resultSet.getString("tags")),
|
||||
@@ -374,15 +374,15 @@ public class MySqlDatabase extends Database {
|
||||
|
||||
final ResultSet resultSet = statement.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
userHomes.add(new Home(resultSet.getDouble("x"),
|
||||
userHomes.add(Home.from(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
World.from(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
resultSet.getString("server_name"),
|
||||
new PositionMeta(resultSet.getString("name"),
|
||||
PositionMeta.from(resultSet.getString("name"),
|
||||
resultSet.getString("description"),
|
||||
resultSet.getTimestamp("timestamp").toInstant(),
|
||||
resultSet.getString("tags")),
|
||||
@@ -414,15 +414,15 @@ public class MySqlDatabase extends Database {
|
||||
|
||||
final ResultSet resultSet = statement.executeQuery();
|
||||
if (resultSet.next()) {
|
||||
return Optional.of(new Home(resultSet.getDouble("x"),
|
||||
return Optional.of(Home.from(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
World.from(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
resultSet.getString("server_name"),
|
||||
new PositionMeta(resultSet.getString("name"),
|
||||
PositionMeta.from(resultSet.getString("name"),
|
||||
resultSet.getString("description"),
|
||||
resultSet.getTimestamp("timestamp").toInstant(),
|
||||
resultSet.getString("tags")),
|
||||
@@ -451,15 +451,15 @@ public class MySqlDatabase extends Database {
|
||||
|
||||
final ResultSet resultSet = statement.executeQuery();
|
||||
if (resultSet.next()) {
|
||||
return Optional.of(new Home(resultSet.getDouble("x"),
|
||||
return Optional.of(Home.from(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
World.from(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
resultSet.getString("server_name"),
|
||||
new PositionMeta(resultSet.getString("name"),
|
||||
PositionMeta.from(resultSet.getString("name"),
|
||||
resultSet.getString("description"),
|
||||
resultSet.getTimestamp("timestamp").toInstant(),
|
||||
resultSet.getString("tags")),
|
||||
@@ -488,15 +488,15 @@ public class MySqlDatabase extends Database {
|
||||
|
||||
final ResultSet resultSet = statement.executeQuery();
|
||||
if (resultSet.next()) {
|
||||
return Optional.of(new Warp(resultSet.getDouble("x"),
|
||||
return Optional.of(Warp.from(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
World.from(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
resultSet.getString("server_name"),
|
||||
new PositionMeta(resultSet.getString("name"),
|
||||
PositionMeta.from(resultSet.getString("name"),
|
||||
resultSet.getString("description"),
|
||||
resultSet.getTimestamp("timestamp").toInstant(),
|
||||
resultSet.getString("tags")),
|
||||
@@ -522,15 +522,15 @@ public class MySqlDatabase extends Database {
|
||||
|
||||
final ResultSet resultSet = statement.executeQuery();
|
||||
if (resultSet.next()) {
|
||||
return Optional.of(new Warp(resultSet.getDouble("x"),
|
||||
return Optional.of(Warp.from(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
World.from(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
resultSet.getString("server_name"),
|
||||
new PositionMeta(resultSet.getString("name"),
|
||||
PositionMeta.from(resultSet.getString("name"),
|
||||
resultSet.getString("description"),
|
||||
resultSet.getTimestamp("timestamp").toInstant(),
|
||||
resultSet.getString("tags")),
|
||||
@@ -557,12 +557,12 @@ public class MySqlDatabase extends Database {
|
||||
if (resultSet.next()) {
|
||||
return Optional.of(Teleport.builder(plugin)
|
||||
.teleporter(onlineUser)
|
||||
.target(new Position(resultSet.getDouble("x"),
|
||||
.target(Position.at(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
World.from(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
resultSet.getString("server_name")))
|
||||
.type(Teleport.Type.getTeleportType(resultSet.getInt("type"))
|
||||
@@ -640,12 +640,12 @@ public class MySqlDatabase extends Database {
|
||||
|
||||
final ResultSet resultSet = statement.executeQuery();
|
||||
if (resultSet.next()) {
|
||||
return Optional.of(new Position(resultSet.getDouble("x"),
|
||||
return Optional.of(Position.at(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
World.from(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
resultSet.getString("server_name")));
|
||||
}
|
||||
@@ -699,12 +699,12 @@ public class MySqlDatabase extends Database {
|
||||
|
||||
final ResultSet resultSet = statement.executeQuery();
|
||||
if (resultSet.next()) {
|
||||
return Optional.of(new Position(resultSet.getDouble("x"),
|
||||
return Optional.of(Position.at(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
World.from(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
resultSet.getString("server_name")));
|
||||
}
|
||||
@@ -757,12 +757,12 @@ public class MySqlDatabase extends Database {
|
||||
|
||||
final ResultSet resultSet = statement.executeQuery();
|
||||
if (resultSet.next()) {
|
||||
return Optional.of(new Position(resultSet.getDouble("x"),
|
||||
return Optional.of(Position.at(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
World.from(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
resultSet.getString("server_name")));
|
||||
}
|
||||
|
||||
@@ -38,9 +38,9 @@ public class SqLiteDatabase extends Database {
|
||||
private Connection connection;
|
||||
|
||||
|
||||
public SqLiteDatabase(@NotNull HuskHomes implementor) {
|
||||
super(implementor);
|
||||
this.databaseFile = new File(implementor.getDataFolder(), DATABASE_FILE_NAME);
|
||||
public SqLiteDatabase(@NotNull HuskHomes plugin) {
|
||||
super(plugin);
|
||||
this.databaseFile = new File(plugin.getDataFolder(), DATABASE_FILE_NAME);
|
||||
}
|
||||
|
||||
private Connection getConnection() throws SQLException {
|
||||
@@ -310,15 +310,15 @@ public class SqLiteDatabase extends Database {
|
||||
|
||||
final ResultSet resultSet = statement.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
userHomes.add(new Home(resultSet.getDouble("x"),
|
||||
userHomes.add(Home.from(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
World.from(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
resultSet.getString("server_name"),
|
||||
new PositionMeta(resultSet.getString("name"),
|
||||
PositionMeta.from(resultSet.getString("name"),
|
||||
resultSet.getString("description"),
|
||||
resultSet.getTimestamp("timestamp").toInstant(),
|
||||
resultSet.getString("tags")),
|
||||
@@ -346,15 +346,15 @@ public class SqLiteDatabase extends Database {
|
||||
|
||||
final ResultSet resultSet = statement.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
warps.add(new Warp(resultSet.getDouble("x"),
|
||||
warps.add(Warp.from(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
World.from(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
resultSet.getString("server_name"),
|
||||
new PositionMeta(resultSet.getString("name"),
|
||||
PositionMeta.from(resultSet.getString("name"),
|
||||
resultSet.getString("description"),
|
||||
resultSet.getTimestamp("timestamp").toInstant(),
|
||||
resultSet.getString("tags")),
|
||||
@@ -382,15 +382,15 @@ public class SqLiteDatabase extends Database {
|
||||
|
||||
final ResultSet resultSet = statement.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
userHomes.add(new Home(resultSet.getDouble("x"),
|
||||
userHomes.add(Home.from(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
World.from(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
resultSet.getString("server_name"),
|
||||
new PositionMeta(resultSet.getString("name"),
|
||||
PositionMeta.from(resultSet.getString("name"),
|
||||
resultSet.getString("description"),
|
||||
resultSet.getTimestamp("timestamp").toInstant(),
|
||||
resultSet.getString("tags")),
|
||||
@@ -422,15 +422,15 @@ public class SqLiteDatabase extends Database {
|
||||
|
||||
final ResultSet resultSet = statement.executeQuery();
|
||||
if (resultSet.next()) {
|
||||
return Optional.of(new Home(resultSet.getDouble("x"),
|
||||
return Optional.of(Home.from(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
World.from(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
resultSet.getString("server_name"),
|
||||
new PositionMeta(resultSet.getString("name"),
|
||||
PositionMeta.from(resultSet.getString("name"),
|
||||
resultSet.getString("description"),
|
||||
resultSet.getTimestamp("timestamp").toInstant(),
|
||||
resultSet.getString("tags")),
|
||||
@@ -459,15 +459,15 @@ public class SqLiteDatabase extends Database {
|
||||
|
||||
final ResultSet resultSet = statement.executeQuery();
|
||||
if (resultSet.next()) {
|
||||
return Optional.of(new Home(resultSet.getDouble("x"),
|
||||
return Optional.of(Home.from(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
World.from(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
resultSet.getString("server_name"),
|
||||
new PositionMeta(resultSet.getString("name"),
|
||||
PositionMeta.from(resultSet.getString("name"),
|
||||
resultSet.getString("description"),
|
||||
resultSet.getTimestamp("timestamp").toInstant(),
|
||||
resultSet.getString("tags")),
|
||||
@@ -496,15 +496,15 @@ public class SqLiteDatabase extends Database {
|
||||
|
||||
final ResultSet resultSet = statement.executeQuery();
|
||||
if (resultSet.next()) {
|
||||
return Optional.of(new Warp(resultSet.getDouble("x"),
|
||||
return Optional.of(Warp.from(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
World.from(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
resultSet.getString("server_name"),
|
||||
new PositionMeta(resultSet.getString("name"),
|
||||
PositionMeta.from(resultSet.getString("name"),
|
||||
resultSet.getString("description"),
|
||||
resultSet.getTimestamp("timestamp").toInstant(),
|
||||
resultSet.getString("tags")),
|
||||
@@ -530,15 +530,15 @@ public class SqLiteDatabase extends Database {
|
||||
|
||||
final ResultSet resultSet = statement.executeQuery();
|
||||
if (resultSet.next()) {
|
||||
return Optional.of(new Warp(resultSet.getDouble("x"),
|
||||
return Optional.of(Warp.from(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
World.from(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
resultSet.getString("server_name"),
|
||||
new PositionMeta(resultSet.getString("name"),
|
||||
PositionMeta.from(resultSet.getString("name"),
|
||||
resultSet.getString("description"),
|
||||
resultSet.getTimestamp("timestamp").toInstant(),
|
||||
resultSet.getString("tags")),
|
||||
@@ -565,12 +565,12 @@ public class SqLiteDatabase extends Database {
|
||||
if (resultSet.next()) {
|
||||
return Optional.of(Teleport.builder(plugin)
|
||||
.teleporter(onlineUser)
|
||||
.target(new Position(resultSet.getDouble("x"),
|
||||
.target(Position.at(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
World.from(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
resultSet.getString("server_name")))
|
||||
.type(Teleport.Type.getTeleportType(resultSet.getInt("type"))
|
||||
@@ -648,12 +648,12 @@ public class SqLiteDatabase extends Database {
|
||||
|
||||
final ResultSet resultSet = statement.executeQuery();
|
||||
if (resultSet.next()) {
|
||||
return Optional.of(new Position(resultSet.getDouble("x"),
|
||||
return Optional.of(Position.at(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
World.from(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
resultSet.getString("server_name")));
|
||||
}
|
||||
@@ -705,12 +705,12 @@ public class SqLiteDatabase extends Database {
|
||||
|
||||
final ResultSet resultSet = statement.executeQuery();
|
||||
if (resultSet.next()) {
|
||||
return Optional.of(new Position(resultSet.getDouble("x"),
|
||||
return Optional.of(Position.at(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
World.from(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
resultSet.getString("server_name")));
|
||||
}
|
||||
@@ -760,12 +760,12 @@ public class SqLiteDatabase extends Database {
|
||||
|
||||
final ResultSet resultSet = statement.executeQuery();
|
||||
if (resultSet.next()) {
|
||||
return Optional.of(new Position(resultSet.getDouble("x"),
|
||||
return Optional.of(Position.at(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
World.from(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
resultSet.getString("server_name")));
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.william278.huskhomes.hook;
|
||||
|
||||
import com.flowpowered.math.vector.Vector2i;
|
||||
import de.bluecolored.bluemap.api.BlueMapAPI;
|
||||
import de.bluecolored.bluemap.api.BlueMapMap;
|
||||
import de.bluecolored.bluemap.api.BlueMapWorld;
|
||||
import de.bluecolored.bluemap.api.markers.MarkerSet;
|
||||
import de.bluecolored.bluemap.api.markers.POIMarker;
|
||||
@@ -10,14 +10,18 @@ import net.william278.huskhomes.position.Home;
|
||||
import net.william278.huskhomes.position.Warp;
|
||||
import net.william278.huskhomes.position.World;
|
||||
import net.william278.huskhomes.user.User;
|
||||
import net.william278.huskhomes.util.ThrowingConsumer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
@@ -25,148 +29,144 @@ import java.util.logging.Level;
|
||||
*/
|
||||
public class BlueMapHook extends MapHook {
|
||||
|
||||
private String publicHomeMarkerIconPath;
|
||||
private String warpMarkerIconPath;
|
||||
private Map<String, MarkerSet> publicHomesMarkerSets;
|
||||
private Map<String, MarkerSet> warpsMarkerSets;
|
||||
|
||||
public BlueMapHook(@NotNull HuskHomes implementor) {
|
||||
super(implementor, "BlueMap");
|
||||
public BlueMapHook(@NotNull HuskHomes plugin) {
|
||||
super(plugin, Plugin.BLUEMAP);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CompletableFuture<Void> initializeMap() {
|
||||
final CompletableFuture<Void> initializedFuture = new CompletableFuture<>();
|
||||
plugin.runAsync(() -> BlueMapAPI.onEnable(blueMapAPI -> {
|
||||
// Create marker sets
|
||||
plugin.getWorlds().forEach(world -> blueMapAPI.getWorld(world.getUuid())
|
||||
.ifPresent(blueMapWorld -> blueMapWorld.getMaps().forEach(map -> {
|
||||
if (plugin.getSettings().isPublicHomesOnMap()) {
|
||||
map.getMarkerSets().put(blueMapWorld.getId() + ":" + PUBLIC_HOMES_MARKER_SET_ID,
|
||||
MarkerSet.builder().label("Public Homes").build());
|
||||
}
|
||||
if (plugin.getSettings().isWarpsOnMap()) {
|
||||
map.getMarkerSets().put(blueMapWorld.getId() + ":" + WARPS_MARKER_SET_ID,
|
||||
MarkerSet.builder().label("Warps").build());
|
||||
}
|
||||
})));
|
||||
public void initialize() {
|
||||
BlueMapAPI.onEnable(api -> {
|
||||
this.publicHomesMarkerSets = new HashMap<>();
|
||||
this.warpsMarkerSets = new HashMap<>();
|
||||
|
||||
// Create marker icons
|
||||
try {
|
||||
publicHomeMarkerIconPath = blueMapAPI.getWebApp().createImage(
|
||||
ImageIO.read(Objects.requireNonNull(plugin.getResource("markers/50x/" + PUBLIC_HOME_MARKER_IMAGE_NAME + ".png"))),
|
||||
"huskhomes/" + PUBLIC_HOMES_MARKER_SET_ID + ".png");
|
||||
warpMarkerIconPath = blueMapAPI.getWebApp().createImage(
|
||||
ImageIO.read(Objects.requireNonNull(plugin.getResource("markers/50x/" + WARP_MARKER_IMAGE_NAME + ".png"))),
|
||||
"huskhomes/" + WARP_MARKER_IMAGE_NAME + ".png");
|
||||
} catch (IOException e) {
|
||||
plugin.log(Level.SEVERE, "Failed to create warp marker image", e);
|
||||
for (World world : plugin.getWorlds()) {
|
||||
this.editMapWorld(world, (mapWorld -> {
|
||||
final MarkerSet publicHomeMarkers = MarkerSet.builder().label(getPublicHomesMarkerSetName()).build();
|
||||
final MarkerSet warpsMarkers = MarkerSet.builder().label(getWarpsMarkerSetName()).build();
|
||||
|
||||
for (BlueMapMap map : mapWorld.getMaps()) {
|
||||
map.getMarkerSets().put(getPublicHomesKey(), publicHomeMarkers);
|
||||
map.getMarkerSets().put(getWarpsKey(), warpsMarkers);
|
||||
}
|
||||
|
||||
publicHomesMarkerSets.put(world.getName(), publicHomeMarkers);
|
||||
warpsMarkerSets.put(world.getName(), warpsMarkers);
|
||||
}));
|
||||
}
|
||||
|
||||
initializedFuture.complete(null);
|
||||
this.populateMap();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateHome(@NotNull Home home) {
|
||||
if (!isValidPosition(home)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.editPublicHomesMarkerSet(home.getWorld(), (markerSet -> {
|
||||
final String markerId = home.getOwner().getUuid() + ":" + home.getUuid();
|
||||
markerSet.remove(markerId);
|
||||
markerSet.put(markerId, POIMarker.builder()
|
||||
.label("/phome " + home.getOwner().getUsername() + "." + home.getName())
|
||||
.position(home.getX(), home.getY(), home.getZ())
|
||||
.maxDistance(5000)
|
||||
.icon(getIcon(PUBLIC_HOME_MARKER_IMAGE_NAME), 25, 25)
|
||||
.build());
|
||||
}));
|
||||
return initializedFuture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> updateHome(@NotNull Home home) {
|
||||
if (!isValidPosition(home)) return CompletableFuture.completedFuture(null);
|
||||
public void removeHome(@NotNull Home home) {
|
||||
this.editPublicHomesMarkerSet(home.getWorld(), markerSet -> markerSet
|
||||
.remove(home.getOwner().getUuid() + ":" + home.getUuid()));
|
||||
|
||||
return removeHome(home).thenRun(() -> BlueMapAPI.getInstance().flatMap(
|
||||
blueMapAPI -> getBlueMapWorld(blueMapAPI, home.getWorld())).ifPresent(blueMapWorld -> blueMapWorld.getMaps()
|
||||
.forEach(blueMapMap -> blueMapMap.getMarkerSets()
|
||||
.computeIfPresent(blueMapWorld.getId() + ":" + PUBLIC_HOMES_MARKER_SET_ID, (s, markerSet) -> {
|
||||
markerSet.getMarkers().put(home.getOwner().getUuid() + ":" + home.getUuid(),
|
||||
POIMarker.toBuilder()
|
||||
.label("/phome" + home.getOwner().getUsername() + "." + home.getMeta().getName())
|
||||
.position((int) home.getX(), (int) home.getY(), (int) home.getZ())
|
||||
.icon(publicHomeMarkerIconPath, Vector2i.from(25, 25))
|
||||
.maxDistance(5000)
|
||||
.build());
|
||||
return markerSet;
|
||||
}))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> removeHome(@NotNull Home home) {
|
||||
if (!isValidPosition(home)) return CompletableFuture.completedFuture(null);
|
||||
|
||||
BlueMapAPI.getInstance().flatMap(blueMapAPI -> getBlueMapWorld(blueMapAPI, home.getWorld()))
|
||||
.ifPresent(blueMapWorld -> blueMapWorld.getMaps().forEach(blueMapMap -> blueMapMap.getMarkerSets()
|
||||
.computeIfPresent(blueMapWorld.getId() + ":" + PUBLIC_HOMES_MARKER_SET_ID, (s, markerSet) -> {
|
||||
markerSet.getMarkers().remove(home.getOwner().getUuid() + ":" + home.getUuid());
|
||||
return markerSet;
|
||||
})));
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearHomes(@NotNull User user) {
|
||||
BlueMapAPI.getInstance().ifPresent((BlueMapAPI blueMapAPI) -> blueMapAPI.getWorlds()
|
||||
.forEach(blueMapWorld -> blueMapWorld.getMaps()
|
||||
.forEach(blueMapMap -> blueMapMap.getMarkerSets()
|
||||
.computeIfPresent(blueMapWorld.getId() + ":" + PUBLIC_HOMES_MARKER_SET_ID, (s, markerSet) -> {
|
||||
markerSet.getMarkers().keySet().removeIf(key -> key.startsWith(user.getUuid().toString()));
|
||||
return markerSet;
|
||||
}))));
|
||||
|
||||
CompletableFuture.completedFuture(null);
|
||||
if (publicHomesMarkerSets != null) {
|
||||
publicHomesMarkerSets.values().forEach(markerSet -> markerSet.getMarkers().keySet()
|
||||
.removeIf(markerId -> markerId.startsWith(user.getUuid().toString())));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> updateWarp(@NotNull Warp warp) {
|
||||
if (!isValidPosition(warp)) return CompletableFuture.completedFuture(null);
|
||||
public void updateWarp(@NotNull Warp warp) {
|
||||
if (!isValidPosition(warp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return removeWarp(warp).thenRun(() -> BlueMapAPI.getInstance().flatMap(blueMapAPI -> getBlueMapWorld(blueMapAPI, warp.getWorld()))
|
||||
.ifPresent(blueMapWorld -> blueMapWorld.getMaps().forEach(blueMapMap -> blueMapMap.getMarkerSets()
|
||||
.computeIfPresent(blueMapWorld.getId() + ":" + WARPS_MARKER_SET_ID, (s, markerSet) -> {
|
||||
markerSet.getMarkers().put(warp.getUuid().toString(),
|
||||
POIMarker.toBuilder()
|
||||
.label("/warp " + warp.getMeta().getName())
|
||||
.position((int) warp.getX(), (int) warp.getY(), (int) warp.getZ())
|
||||
.icon(warpMarkerIconPath, Vector2i.from(25, 25))
|
||||
.maxDistance(10000)
|
||||
.build());
|
||||
return markerSet;
|
||||
}))));
|
||||
this.editWarpsMarkerSet(warp.getWorld(), (markerSet -> {
|
||||
final String markerId = warp.getUuid().toString();
|
||||
markerSet.remove(markerId);
|
||||
markerSet.put(markerId, POIMarker.builder()
|
||||
.label("/warp " + warp.getName())
|
||||
.position(warp.getX(), warp.getY(), warp.getZ())
|
||||
.maxDistance(5000)
|
||||
.icon(getIcon(WARP_MARKER_IMAGE_NAME), 25, 25)
|
||||
.build());
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> removeWarp(@NotNull Warp warp) {
|
||||
if (!isValidPosition(warp)) return CompletableFuture.completedFuture(null);
|
||||
|
||||
BlueMapAPI.getInstance().flatMap(blueMapAPI -> getBlueMapWorld(blueMapAPI, warp.getWorld()))
|
||||
.ifPresent(blueMapWorld -> blueMapWorld.getMaps().forEach(blueMapMap -> blueMapMap.getMarkerSets()
|
||||
.computeIfPresent(blueMapWorld.getId() + ":" + WARPS_MARKER_SET_ID, (s, markerSet) -> {
|
||||
markerSet.getMarkers().remove(warp.getUuid().toString());
|
||||
return markerSet;
|
||||
})));
|
||||
return CompletableFuture.completedFuture(null);
|
||||
public void removeWarp(@NotNull Warp warp) {
|
||||
editWarpsMarkerSet(warp.getWorld(), markerSet -> markerSet.remove(warp.getUuid().toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearWarps() {
|
||||
BlueMapAPI.getInstance().ifPresent((BlueMapAPI blueMapAPI) -> blueMapAPI.getWorlds()
|
||||
.forEach(blueMapWorld -> blueMapWorld.getMaps()
|
||||
.forEach(blueMapMap -> blueMapMap.getMarkerSets()
|
||||
.computeIfPresent(blueMapWorld.getId() + ":" + WARPS_MARKER_SET_ID, (s, markerSet) -> {
|
||||
markerSet.getMarkers().clear();
|
||||
return markerSet;
|
||||
}))));
|
||||
|
||||
CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link BlueMapWorld} for a world
|
||||
*
|
||||
* @param world The {@link World} to get the {@link BlueMapWorld} for
|
||||
* @return The {@link BlueMapWorld} of the world
|
||||
*/
|
||||
@NotNull
|
||||
private Optional<BlueMapWorld> getBlueMapWorld(@NotNull BlueMapAPI blueMapAPI, @NotNull World world) {
|
||||
if (world.getUuid().equals(new UUID(0, 0))) {
|
||||
return blueMapAPI.getWorld(world.getName());
|
||||
} else {
|
||||
return blueMapAPI.getWorld(world.getUuid());
|
||||
if (warpsMarkerSets != null) {
|
||||
warpsMarkerSets.values().forEach(markerSet -> markerSet.getMarkers().clear());
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getIcon(@NotNull String iconName) {
|
||||
return BlueMapAPI.getInstance().map(api -> {
|
||||
final Path icons = api.getWebApp().getWebRoot().resolve("icons").resolve("huskhomes");
|
||||
if (!icons.toFile().exists() && !icons.toFile().mkdirs()) {
|
||||
plugin.log(Level.WARNING, "Failed to create BlueMap icons directory");
|
||||
}
|
||||
|
||||
final String iconFileName = iconName + ".png";
|
||||
final File iconFile = icons.resolve(iconFileName).toFile();
|
||||
if (!iconFile.exists()) {
|
||||
try (InputStream readIcon = plugin.getResource("markers/50x/" + iconFileName)) {
|
||||
if (readIcon == null) {
|
||||
throw new FileNotFoundException("Could not find icon resource: " + iconFileName);
|
||||
}
|
||||
Files.copy(readIcon, iconFile.toPath());
|
||||
} catch (IOException e) {
|
||||
plugin.log(Level.WARNING, "Failed to load icon for BlueMap hook", e);
|
||||
}
|
||||
}
|
||||
|
||||
return "icons/huskhomes/" + iconFileName;
|
||||
}).orElse(null);
|
||||
}
|
||||
|
||||
private void editPublicHomesMarkerSet(@NotNull World world, @NotNull ThrowingConsumer<MarkerSet> editor) {
|
||||
editMapWorld(world, (mapWorld -> {
|
||||
if (publicHomesMarkerSets != null) {
|
||||
editor.accept(publicHomesMarkerSets.get(world.getName()));
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private void editWarpsMarkerSet(@NotNull World world, @NotNull ThrowingConsumer<MarkerSet> editor) {
|
||||
editMapWorld(world, (mapWorld -> {
|
||||
if (warpsMarkerSets != null) {
|
||||
editor.accept(warpsMarkerSets.get(world.getName()));
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private void editMapWorld(@NotNull World world, @NotNull ThrowingConsumer<BlueMapWorld> editor) {
|
||||
BlueMapAPI.getInstance().flatMap(api -> api.getWorld(world.getName())).ifPresent(editor);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
package net.william278.huskhomes.hook;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.position.Home;
|
||||
import net.william278.huskhomes.position.Warp;
|
||||
import net.william278.huskhomes.user.User;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
import org.dynmap.DynmapCommonAPI;
|
||||
import org.dynmap.DynmapCommonAPIListener;
|
||||
import org.dynmap.markers.Marker;
|
||||
import org.dynmap.markers.MarkerIcon;
|
||||
import org.dynmap.markers.MarkerSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Hook to display warps and public homes on Dynmap
|
||||
*/
|
||||
public class DynmapHook extends MapHook {
|
||||
|
||||
@Nullable
|
||||
private DynmapCommonAPI dynmapApi;
|
||||
@Nullable
|
||||
private MarkerSet publicHomesMarkers;
|
||||
@Nullable
|
||||
private MarkerSet warpsMarkers;
|
||||
|
||||
public DynmapHook(@NotNull HuskHomes plugin) {
|
||||
super(plugin, Plugin.DYNMAP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
DynmapCommonAPIListener.register(new DynmapCommonAPIListener() {
|
||||
@Override
|
||||
public void apiEnabled(@NotNull DynmapCommonAPI dynmapCommonAPI) {
|
||||
dynmapApi = dynmapCommonAPI;
|
||||
|
||||
if (plugin.getSettings().doPublicHomesOnMap()) {
|
||||
getMarkerIcon(PUBLIC_HOME_MARKER_IMAGE_NAME).orElseThrow();
|
||||
dynmapApi.getMarkerAPI().createMarkerSet(getPublicHomesKey(),
|
||||
getPublicHomesMarkerSetName(), dynmapApi.getMarkerAPI().getMarkerIcons(), false);
|
||||
}
|
||||
if (plugin.getSettings().doWarpsOnMap()) {
|
||||
getMarkerIcon(WARP_MARKER_IMAGE_NAME).orElseThrow();
|
||||
dynmapApi.getMarkerAPI().createMarkerSet(getWarpsKey(),
|
||||
getWarpsMarkerSetName(), dynmapApi.getMarkerAPI().getMarkerIcons(), false);
|
||||
}
|
||||
|
||||
populateMap();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateHome(@NotNull Home home) {
|
||||
if (!isValidPosition(home)) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.runSync(() -> {
|
||||
final String markerId = home.getOwner().getUuid() + ":" + home.getUuid();
|
||||
getPublicHomesMarkerSet().ifPresent(markerSet -> {
|
||||
markerSet.getMarkers().stream()
|
||||
.filter(marker -> marker.getMarkerID().equals(markerId))
|
||||
.forEach(Marker::deleteMarker);
|
||||
markerSet.createMarker(markerId, home.getName(), home.getWorld().getName(),
|
||||
home.getX(), home.getY(), home.getZ(),
|
||||
getMarkerIcon(PUBLIC_HOME_MARKER_IMAGE_NAME).orElseThrow(), false)
|
||||
.setDescription(MarkerInformationPopup.create(home.getName())
|
||||
.thumbnail(PUBLIC_HOME_MARKER_IMAGE_NAME)
|
||||
.field("Owner", home.getOwner().getUsername())
|
||||
.field("Description", plugin.getLocales().wrapText(home.getMeta().getDescription(), 60))
|
||||
.field("Command", "/phome " + home.getName())
|
||||
.toHtml());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeHome(@NotNull Home home) {
|
||||
plugin.runSync(() -> {
|
||||
final String markerId = home.getOwner().getUuid() + ":" + home.getUuid();
|
||||
getPublicHomesMarkerSet().ifPresent(markerSet -> markerSet.getMarkers().stream()
|
||||
.filter(marker -> marker.getMarkerID().equals(markerId))
|
||||
.forEach(Marker::deleteMarker));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearHomes(@NotNull User user) {
|
||||
plugin.runSync(() -> getPublicHomesMarkerSet().ifPresent(markerSet -> markerSet.getMarkers().stream()
|
||||
.filter(marker -> marker.getMarkerID().startsWith(user.getUuid().toString()))
|
||||
.forEach(Marker::deleteMarker)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWarp(@NotNull Warp warp) {
|
||||
if (!isValidPosition(warp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.runSync(() -> {
|
||||
final String markerId = warp.getUuid().toString();
|
||||
getWarpsMarkerSet().ifPresent(markerSet -> {
|
||||
markerSet.getMarkers().stream()
|
||||
.filter(marker -> marker.getMarkerID().equals(markerId))
|
||||
.forEach(Marker::deleteMarker);
|
||||
markerSet.createMarker(markerId, warp.getName(), warp.getWorld().getName(),
|
||||
warp.getX(), warp.getY(), warp.getZ(),
|
||||
getMarkerIcon(WARP_MARKER_IMAGE_NAME).orElseThrow(), false)
|
||||
.setDescription(MarkerInformationPopup.create(warp.getName())
|
||||
.thumbnail(WARP_MARKER_IMAGE_NAME)
|
||||
.field("Description", plugin.getLocales().wrapText(warp.getMeta().getDescription(), 60))
|
||||
.field("Command", "/phome " + warp.getName())
|
||||
.toHtml());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeWarp(@NotNull Warp warp) {
|
||||
plugin.runSync(() -> {
|
||||
final String markerId = warp.getUuid().toString();
|
||||
getWarpsMarkerSet().ifPresent(markerSet -> markerSet.getMarkers().stream()
|
||||
.filter(marker -> marker.getMarkerID().equals(markerId))
|
||||
.forEach(Marker::deleteMarker));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearWarps() {
|
||||
plugin.runSync(() -> getWarpsMarkerSet().ifPresent(markerSet -> markerSet.getMarkers()
|
||||
.forEach(Marker::deleteMarker)));
|
||||
}
|
||||
|
||||
private Optional<DynmapCommonAPI> getDynmap() {
|
||||
return Optional.ofNullable(dynmapApi);
|
||||
}
|
||||
|
||||
private Optional<MarkerSet> getWarpsMarkerSet() {
|
||||
return getDynmap().map(api -> {
|
||||
warpsMarkers = api.getMarkerAPI().getMarkerSet(getWarpsKey());
|
||||
if (warpsMarkers == null) {
|
||||
warpsMarkers = api.getMarkerAPI().createMarkerSet(getWarpsKey(), getWarpsMarkerSetName(),
|
||||
api.getMarkerAPI().getMarkerIcons(), false);
|
||||
} else {
|
||||
warpsMarkers.setMarkerSetLabel(getWarpsMarkerSetName());
|
||||
}
|
||||
return warpsMarkers;
|
||||
});
|
||||
}
|
||||
|
||||
private Optional<MarkerSet> getPublicHomesMarkerSet() {
|
||||
return getDynmap().map(api -> {
|
||||
publicHomesMarkers = api.getMarkerAPI().getMarkerSet(getPublicHomesKey());
|
||||
if (publicHomesMarkers == null) {
|
||||
publicHomesMarkers = api.getMarkerAPI().createMarkerSet(getPublicHomesKey(), getPublicHomesMarkerSetName(),
|
||||
api.getMarkerAPI().getMarkerIcons(), false);
|
||||
} else {
|
||||
publicHomesMarkers.setMarkerSetLabel(getPublicHomesMarkerSetName());
|
||||
}
|
||||
return publicHomesMarkers;
|
||||
});
|
||||
}
|
||||
|
||||
private Optional<MarkerIcon> getMarkerIcon(@NotNull String imageName) {
|
||||
return getDynmap().map(api -> {
|
||||
MarkerIcon icon = api.getMarkerAPI().getMarkerIcon(imageName);
|
||||
if (icon == null) {
|
||||
icon = api.getMarkerAPI().createMarkerIcon(imageName, imageName,
|
||||
plugin.getResource("markers/16x/" + imageName + ".png"));
|
||||
}
|
||||
return icon;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML Dynmap marker information popup widget
|
||||
*/
|
||||
private static class MarkerInformationPopup {
|
||||
@NotNull
|
||||
private final String title;
|
||||
|
||||
@Nullable
|
||||
private String thumbnailMarkerId;
|
||||
|
||||
@NotNull
|
||||
private final Map<String, String> fields;
|
||||
|
||||
private MarkerInformationPopup(@NotNull String title) {
|
||||
this.title = title;
|
||||
this.fields = new HashMap<>();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static DynmapHook.MarkerInformationPopup create(@NotNull String title) {
|
||||
return new MarkerInformationPopup(title);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private DynmapHook.MarkerInformationPopup thumbnail(@NotNull String thumbnailMarkerId) {
|
||||
this.thumbnailMarkerId = thumbnailMarkerId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private DynmapHook.MarkerInformationPopup field(@NotNull String key, @NotNull String value) {
|
||||
fields.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String toHtml() {
|
||||
final StringBuilder html = new StringBuilder();
|
||||
html.append("<div class=\"infowindow\">");
|
||||
if (thumbnailMarkerId != null) {
|
||||
html.append("<img src=\"/tiles/_markers_/")
|
||||
.append(thumbnailMarkerId)
|
||||
.append(".png\" class=\"thumbnail\"/>")
|
||||
.append(" ");
|
||||
}
|
||||
html.append("<span style=\"font-weight: bold;\">")
|
||||
.append(StringEscapeUtils.escapeHtml4(title))
|
||||
.append("</span><br/>");
|
||||
fields.forEach((key, value) -> html.append("<span style=\"font-weight: bold;\">")
|
||||
.append(StringEscapeUtils.escapeHtml4(key))
|
||||
.append(": </span><span>")
|
||||
.append(StringEscapeUtils.escapeHtml4(value))
|
||||
.append("</span><br/>"));
|
||||
return html.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,10 +7,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* A hook that provides economy features
|
||||
*/
|
||||
public abstract class EconomyHook extends PluginHook {
|
||||
public abstract class EconomyHook extends Hook {
|
||||
|
||||
protected EconomyHook(@NotNull HuskHomes implementor, @NotNull String hookName) {
|
||||
super(implementor, hookName);
|
||||
protected EconomyHook(@NotNull HuskHomes plugin, @NotNull String hookName) {
|
||||
super(plugin, hookName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package net.william278.huskhomes.hook;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A plugin hook, where HuskHomes hooks into another plugin
|
||||
*/
|
||||
public abstract class Hook {
|
||||
|
||||
/**
|
||||
* The plugin that this hook is for
|
||||
*/
|
||||
protected final HuskHomes plugin;
|
||||
|
||||
/**
|
||||
* The name of the hook
|
||||
*/
|
||||
protected final String name;
|
||||
|
||||
/**
|
||||
* Construct a new {@link Hook}
|
||||
*
|
||||
* @param plugin the {@link HuskHomes} instance
|
||||
*/
|
||||
protected Hook(@NotNull HuskHomes plugin, @NotNull String name) {
|
||||
this.plugin = plugin;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the hook and return {@code true} if it could be enabled
|
||||
*/
|
||||
public abstract void initialize() ;
|
||||
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -4,64 +4,50 @@ import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.position.Home;
|
||||
import net.william278.huskhomes.position.SavedPosition;
|
||||
import net.william278.huskhomes.position.Warp;
|
||||
import net.william278.huskhomes.position.World;
|
||||
import net.william278.huskhomes.user.User;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* A hook for a mapping plugin, such as Dynmap
|
||||
*/
|
||||
public abstract class MapHook extends PluginHook {
|
||||
public abstract class MapHook extends Hook {
|
||||
|
||||
protected static final String PUBLIC_HOMES_MARKER_SET_ID = "huskhomes-public-homes";
|
||||
protected static final String WARPS_MARKER_SET_ID = "huskhomes-warps";
|
||||
protected static final String WARP_MARKER_IMAGE_NAME = "warp";
|
||||
protected static final String PUBLIC_HOME_MARKER_IMAGE_NAME = "public-home";
|
||||
|
||||
protected MapHook(@NotNull HuskHomes implementor, @NotNull String hookName) {
|
||||
super(implementor, hookName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean initialize() {
|
||||
initializeMap().thenRun(() -> {
|
||||
if (plugin.getSettings().isPublicHomesOnMap()) {
|
||||
plugin.getDatabase()
|
||||
.getLocalPublicHomes(plugin)
|
||||
.forEach(this::updateHome);
|
||||
}
|
||||
if (plugin.getSettings().isWarpsOnMap()) {
|
||||
plugin.getDatabase()
|
||||
.getLocalWarps(plugin)
|
||||
.forEach(this::updateWarp);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
protected MapHook(@NotNull HuskHomes plugin, @NotNull MapHook.Plugin type) {
|
||||
super(plugin, type.getDisplayName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the map plugin for adding homes to
|
||||
*
|
||||
* @return a {@link CompletableFuture} that completes when the map plugin is ready
|
||||
* Populate the map with public homes and warps
|
||||
*/
|
||||
protected abstract CompletableFuture<Void> initializeMap();
|
||||
protected void populateMap() {
|
||||
if (plugin.getSettings().doPublicHomesOnMap()) {
|
||||
plugin.getDatabase()
|
||||
.getLocalPublicHomes(plugin)
|
||||
.forEach(this::updateHome);
|
||||
}
|
||||
if (plugin.getSettings().doWarpsOnMap()) {
|
||||
plugin.getDatabase()
|
||||
.getLocalWarps(plugin)
|
||||
.forEach(this::updateWarp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a home, adding it to the map if it exists, or updating it on the map if it doesn't
|
||||
*
|
||||
* @param home the home to update
|
||||
*/
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public abstract CompletableFuture<Void> updateHome(@NotNull Home home);
|
||||
public abstract void updateHome(@NotNull Home home);
|
||||
|
||||
/**
|
||||
* Removes a home from the map
|
||||
*
|
||||
* @param home the home to remove
|
||||
*/
|
||||
public abstract CompletableFuture<Void> removeHome(@NotNull Home home);
|
||||
public abstract void removeHome(@NotNull Home home);
|
||||
|
||||
/**
|
||||
* Clears homes owned by a player from the map
|
||||
@@ -75,15 +61,14 @@ public abstract class MapHook extends PluginHook {
|
||||
*
|
||||
* @param warp the warp to update
|
||||
*/
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public abstract CompletableFuture<Void> updateWarp(@NotNull Warp warp);
|
||||
public abstract void updateWarp(@NotNull Warp warp);
|
||||
|
||||
/**
|
||||
* Removes a warp from the map
|
||||
*
|
||||
* @param warp the warp to remove
|
||||
*/
|
||||
public abstract CompletableFuture<Void> removeWarp(@NotNull Warp warp);
|
||||
public abstract void removeWarp(@NotNull Warp warp);
|
||||
|
||||
/**
|
||||
* Clears all warps from the map
|
||||
@@ -98,30 +83,55 @@ public abstract class MapHook extends PluginHook {
|
||||
*/
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
protected final boolean isValidPosition(@NotNull SavedPosition position) {
|
||||
if (position instanceof Warp && !plugin.getSettings().isWarpsOnMap()) return false;
|
||||
if (position instanceof Home && !plugin.getSettings().isPublicHomesOnMap()) return false;
|
||||
|
||||
try {
|
||||
return position.getServer().equals(plugin.getServerName());
|
||||
} catch (IllegalStateException e) {
|
||||
return plugin.getWorlds().stream()
|
||||
.map(World::getUuid)
|
||||
.anyMatch(uuid -> uuid.equals(position.getWorld().getUuid()));
|
||||
if (position instanceof Warp && !plugin.getSettings().doWarpsOnMap()) {
|
||||
return false;
|
||||
}
|
||||
if (position instanceof Home && !plugin.getSettings().doPublicHomesOnMap()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !plugin.getSettings().isCrossServer() || position.getServer().equals(plugin.getServerName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected final String getPublicHomesKey() {
|
||||
return plugin.getKey(getName().toLowerCase(), "public_home_markers").toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected final String getWarpsKey() {
|
||||
return plugin.getKey(getName().toLowerCase(), "warp_markers").toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected final String getPublicHomesMarkerSetName() {
|
||||
return plugin.getLocales().getRawLocale("map_hook_public_homes_marker_set_name")
|
||||
.orElse("Public Homes");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected final String getWarpsMarkerSetName() {
|
||||
return plugin.getLocales().getRawLocale("map_hook_warps_marker_set_name")
|
||||
.orElse("Warps");
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifies types of supported Map plugins
|
||||
*/
|
||||
public enum MappingPlugin {
|
||||
public enum Plugin {
|
||||
DYNMAP("Dynmap"),
|
||||
BLUEMAP("BlueMap");
|
||||
|
||||
@NotNull
|
||||
public final String displayName;
|
||||
private final String displayName;
|
||||
|
||||
MappingPlugin(@NotNull String displayName) {
|
||||
Plugin(@NotNull String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,7 +20,7 @@ import java.util.logging.Level;
|
||||
/**
|
||||
* Hooks into Plan to provide the {@link PlanDataExtension} with stats on the web panel
|
||||
*/
|
||||
public class PlanHook extends PluginHook {
|
||||
public class PlanHook extends Hook {
|
||||
|
||||
private final HuskHomes plugin;
|
||||
|
||||
@@ -30,13 +30,12 @@ public class PlanHook extends PluginHook {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean initialize() {
|
||||
public void initialize() {
|
||||
if (!areAllCapabilitiesAvailable()) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
registerDataExtension();
|
||||
handlePlanReload();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
package net.william278.huskhomes.hook;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A plugin hook, where HuskHomes hooks into another plugin
|
||||
*/
|
||||
public abstract class PluginHook {
|
||||
|
||||
/**
|
||||
* The plugin that this hook is for
|
||||
*/
|
||||
protected final HuskHomes plugin;
|
||||
|
||||
/**
|
||||
* The name of the hook
|
||||
*/
|
||||
protected final String hookName;
|
||||
|
||||
/**
|
||||
* Construct a new {@link PluginHook}
|
||||
*
|
||||
* @param implementor the {@link HuskHomes} instance
|
||||
*/
|
||||
protected PluginHook(@NotNull HuskHomes implementor, @NotNull String hookName) {
|
||||
this.plugin = implementor;
|
||||
this.hookName = hookName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the hook and return {@code true} if it could be enabled
|
||||
*
|
||||
* @return {@code true} if the hook could be enabled
|
||||
*/
|
||||
public abstract boolean initialize() ;
|
||||
|
||||
@NotNull
|
||||
public String getHookName() {
|
||||
return hookName;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -22,8 +22,8 @@ public class EventListener {
|
||||
@NotNull
|
||||
protected final HuskHomes plugin;
|
||||
|
||||
protected EventListener(@NotNull HuskHomes implementor) {
|
||||
this.plugin = implementor;
|
||||
protected EventListener(@NotNull HuskHomes plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,11 +89,18 @@ public class EventListener {
|
||||
if (teleport.getType() == Teleport.Type.RESPAWN) {
|
||||
final Optional<Position> bedPosition = teleporter.getBedSpawnPosition();
|
||||
if (bedPosition.isEmpty()) {
|
||||
plugin.getLocalCachedSpawn()
|
||||
.map(spawn -> spawn.getPosition(plugin.getServerName()))
|
||||
.ifPresent(position -> teleporter.teleportLocally(position,
|
||||
plugin.getSettings().isAsynchronousTeleports()));
|
||||
teleporter.sendTranslatableMessage("block.minecraft.spawn.not_valid");
|
||||
plugin.getSpawn().ifPresent(spawn -> {
|
||||
if (plugin.getSettings().isCrossServer() && !spawn.getServer().equals(plugin.getServerName())) {
|
||||
plugin.runLater(() -> Teleport.builder(plugin)
|
||||
.teleporter(teleporter)
|
||||
.target(spawn)
|
||||
.updateLastPosition(false)
|
||||
.toTeleport().execute(), 40L);
|
||||
} else {
|
||||
teleporter.teleportLocally(spawn, plugin.getSettings().isAsynchronousTeleports());
|
||||
}
|
||||
teleporter.sendTranslatableMessage("block.minecraft.spawn.not_valid");
|
||||
});
|
||||
} else {
|
||||
teleporter.teleportLocally(bedPosition.get(), plugin.getSettings().isAsynchronousTeleports());
|
||||
}
|
||||
@@ -104,8 +111,7 @@ public class EventListener {
|
||||
|
||||
teleporter.teleportLocally((Position) teleport.getTarget(), plugin.getSettings().isAsynchronousTeleports());
|
||||
plugin.getDatabase().setCurrentTeleport(teleporter, null);
|
||||
plugin.getLocales().getLocale("teleporting_complete")
|
||||
.ifPresent(teleporter::sendMessage);
|
||||
teleport.displayTeleportingComplete(teleporter);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -146,7 +152,7 @@ public class EventListener {
|
||||
protected final void handlePlayerDeath(@NotNull OnlineUser onlineUser) {
|
||||
// Set the player's last position to where they died
|
||||
if (plugin.getSettings().isBackCommandReturnByDeath()
|
||||
&& onlineUser.hasPermission(Permission.COMMAND_BACK_RETURN_BY_DEATH.node)) {
|
||||
&& onlineUser.hasPermission(Permission.COMMAND_BACK_RETURN_BY_DEATH.node)) {
|
||||
plugin.getDatabase().setLastPosition(onlineUser, onlineUser.getPosition());
|
||||
}
|
||||
}
|
||||
@@ -160,8 +166,8 @@ public class EventListener {
|
||||
plugin.runAsync(() -> {
|
||||
// Display the return by death via /back notification
|
||||
if (plugin.getSettings().isBackCommandReturnByDeath()
|
||||
&& onlineUser.hasPermission(Permission.COMMAND_BACK.node)
|
||||
&& onlineUser.hasPermission(Permission.COMMAND_BACK_RETURN_BY_DEATH.node)) {
|
||||
&& onlineUser.hasPermission(Permission.COMMAND_BACK.node)
|
||||
&& onlineUser.hasPermission(Permission.COMMAND_BACK_RETURN_BY_DEATH.node)) {
|
||||
plugin.getLocales().getLocale("return_by_death_notification")
|
||||
.ifPresent(onlineUser::sendMessage);
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ public class HomesManager {
|
||||
existing.update(position);
|
||||
return existing;
|
||||
})
|
||||
.orElse(new Home(position, new PositionMeta(name, ""), owner));
|
||||
.orElse(Home.from(position, PositionMeta.create(name, ""), owner));
|
||||
plugin.getDatabase().saveHome(home);
|
||||
this.cacheHome(home, true);
|
||||
}
|
||||
@@ -248,10 +248,6 @@ public class HomesManager {
|
||||
}
|
||||
|
||||
public void setHomePrivacy(@NotNull Home home, boolean isPublic) {
|
||||
if (isPublic == home.isPublic()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isPublic && home.getOwner() instanceof OnlineUser online) {
|
||||
final int publicHomes = plugin.getDatabase().getHomes(home.getOwner()).stream()
|
||||
.filter(Home::isPublic)
|
||||
|
||||
@@ -91,7 +91,7 @@ public class WarpsManager {
|
||||
existing.setPitch(position.getPitch());
|
||||
return existing;
|
||||
})
|
||||
.orElse(new Warp(position, new PositionMeta(name, "")));
|
||||
.orElse(Warp.from(position, PositionMeta.create(name, "")));
|
||||
plugin.getDatabase().saveWarp(warp);
|
||||
this.cacheWarp(warp, true);
|
||||
}
|
||||
@@ -122,16 +122,16 @@ public class WarpsManager {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public void relocateWarp(@NotNull String name, @NotNull Position position) throws ValidationException {
|
||||
public void setWarpPosition(@NotNull String name, @NotNull Position position) throws ValidationException {
|
||||
final Optional<Warp> optionalWarp = plugin.getDatabase().getWarp(name);
|
||||
if (optionalWarp.isEmpty()) {
|
||||
throw new ValidationException(ValidationException.Type.NOT_FOUND);
|
||||
}
|
||||
|
||||
this.relocateWarp(optionalWarp.get(), position);
|
||||
this.setWarpPosition(optionalWarp.get(), position);
|
||||
}
|
||||
|
||||
public void relocateWarp(@NotNull Warp warp, @NotNull Position position) {
|
||||
public void setWarpPosition(@NotNull Warp warp, @NotNull Position position) {
|
||||
warp.update(position);
|
||||
plugin.getDatabase().saveWarp(warp);
|
||||
this.cacheWarp(warp, true);
|
||||
|
||||
@@ -13,19 +13,30 @@ public class Home extends SavedPosition {
|
||||
private final User owner;
|
||||
private boolean isPublic;
|
||||
|
||||
public Home(double x, double y, double z, float yaw, float pitch, @NotNull World world, @NotNull String server,
|
||||
@NotNull PositionMeta positionMeta, @NotNull UUID uuid, @NotNull User owner, boolean isPublic) {
|
||||
private Home(double x, double y, double z, float yaw, float pitch, @NotNull World world, @NotNull String server,
|
||||
@NotNull PositionMeta positionMeta, @NotNull UUID uuid, @NotNull User owner, boolean isPublic) {
|
||||
super(x, y, z, yaw, pitch, world, server, positionMeta, uuid);
|
||||
this.owner = owner;
|
||||
this.setPublic(isPublic);
|
||||
}
|
||||
|
||||
public Home(@NotNull Position position, @NotNull PositionMeta meta, @NotNull User owner) {
|
||||
private Home(@NotNull Position position, @NotNull PositionMeta meta, @NotNull User owner) {
|
||||
super(position, meta);
|
||||
this.owner = owner;
|
||||
this.setPublic(false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Home from(double x, double y, double z, float yaw, float pitch, @NotNull World world, @NotNull String server,
|
||||
@NotNull PositionMeta positionMeta, @NotNull UUID uuid, @NotNull User owner, boolean isPublic) {
|
||||
return new Home(x, y, z, yaw, pitch, world, server, positionMeta, uuid, owner, isPublic);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Home from(@NotNull Position position, @NotNull PositionMeta meta, @NotNull User owner) {
|
||||
return new Home(position, meta, owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link User} who owns this home
|
||||
*/
|
||||
|
||||
@@ -1,30 +1,26 @@
|
||||
package net.william278.huskhomes.position;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a local position on this server
|
||||
*/
|
||||
public class Location {
|
||||
|
||||
@Expose
|
||||
private double x;
|
||||
@Expose
|
||||
private double y;
|
||||
@Expose
|
||||
private double z;
|
||||
@Expose
|
||||
private float yaw;
|
||||
@Expose
|
||||
private float pitch;
|
||||
@Expose
|
||||
private World world;
|
||||
|
||||
public Location(double x, double y, double z, @NotNull World world) {
|
||||
this.setX(x);
|
||||
this.setY(y);
|
||||
this.setZ(z);
|
||||
this.setYaw(0);
|
||||
this.setPitch(0);
|
||||
this.setWorld(world);
|
||||
}
|
||||
|
||||
public Location(double x, double y, double z, float yaw, float pitch,
|
||||
@NotNull World world) {
|
||||
protected Location(double x, double y, double z, float yaw, float pitch, @NotNull World world) {
|
||||
this.setX(x);
|
||||
this.setY(y);
|
||||
this.setZ(z);
|
||||
@@ -36,6 +32,16 @@ public class Location {
|
||||
public Location() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Location at(double x, double y, double z, float yaw, float pitch, @NotNull World world) {
|
||||
return new Location(x, y, z, yaw, pitch, world);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Location at(double x, double y, double z, @NotNull World world) {
|
||||
return Location.at(x, y, z, 0, 0, world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the position to match that of another position
|
||||
*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.william278.huskhomes.position;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import net.william278.huskhomes.teleport.Target;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -8,15 +9,15 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public class Position extends Location implements Target {
|
||||
|
||||
@Expose
|
||||
private String server;
|
||||
|
||||
public Position(double x, double y, double z, float yaw, float pitch,
|
||||
@NotNull World world, @NotNull String server) {
|
||||
protected Position(double x, double y, double z, float yaw, float pitch, @NotNull World world, @NotNull String server) {
|
||||
super(x, y, z, yaw, pitch, world);
|
||||
this.setServer(server);
|
||||
}
|
||||
|
||||
public Position(@NotNull Location location, @NotNull String server) {
|
||||
protected Position(@NotNull Location location, @NotNull String server) {
|
||||
super(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch(), location.getWorld());
|
||||
this.setServer(server);
|
||||
}
|
||||
@@ -25,6 +26,21 @@ public class Position extends Location implements Target {
|
||||
private Position() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Position at(double x, double y, double z, float yaw, float pitch, @NotNull World world, @NotNull String server) {
|
||||
return new Position(x, y, z, yaw, pitch, world, server);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Position at(double x, double y, double z, @NotNull World world, @NotNull String server) {
|
||||
return Position.at(x, y, z, 0, 0, world, server);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Position at(@NotNull Location location, @NotNull String server) {
|
||||
return new Position(location, server);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull Position newPosition) {
|
||||
super.update(newPosition);
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Represents metadata about a {@link Position}, used in {@link SavedPosition} implementations
|
||||
@@ -16,24 +15,27 @@ import java.util.Optional;
|
||||
public class PositionMeta {
|
||||
|
||||
private String name;
|
||||
@Nullable
|
||||
private String description;
|
||||
private Map<String, String> tags;
|
||||
private Instant creationTime;
|
||||
|
||||
public PositionMeta(@NotNull String name, @NotNull String description, @NotNull Instant creationTime,
|
||||
@Nullable String serializedTags) {
|
||||
private PositionMeta(@NotNull String name, @NotNull String description,
|
||||
@NotNull Instant creationTime, @Nullable String serializedTags) {
|
||||
this.setName(name);
|
||||
this.setDescription(description);
|
||||
this.setCreationTime(creationTime);
|
||||
this.setTags(deserializeTags(serializedTags));
|
||||
}
|
||||
|
||||
public PositionMeta(@NotNull String name, @NotNull String description) {
|
||||
this.setName(name);
|
||||
this.setDescription(description);
|
||||
this.setCreationTime(Instant.now());
|
||||
this.setTags(new HashMap<>());
|
||||
@NotNull
|
||||
public static PositionMeta from(@NotNull String name, @NotNull String description,
|
||||
@NotNull Instant creationTime, @Nullable String serializedTags) {
|
||||
return new PositionMeta(name, description, creationTime, serializedTags);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PositionMeta create(@NotNull String name, @NotNull String description) {
|
||||
return PositionMeta.from(name, description, Instant.now(), "");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,6 +44,7 @@ public class PositionMeta {
|
||||
* @param serializedTags The JSON string to deserialize
|
||||
* @return The deserialized {@link Map}
|
||||
*/
|
||||
@NotNull
|
||||
private static Map<String, String> deserializeTags(@Nullable String serializedTags) {
|
||||
try {
|
||||
if (serializedTags == null || serializedTags.isBlank()) {
|
||||
@@ -89,7 +92,7 @@ public class PositionMeta {
|
||||
*/
|
||||
@NotNull
|
||||
public String getDescription() {
|
||||
return Optional.ofNullable(description).orElse("");
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(@Nullable String description) {
|
||||
|
||||
@@ -12,9 +12,8 @@ public abstract class SavedPosition extends Position implements Comparable<Saved
|
||||
private PositionMeta meta;
|
||||
private final UUID uuid;
|
||||
|
||||
protected SavedPosition(double x, double y, double z, float yaw, float pitch,
|
||||
@NotNull World world, @NotNull String server,
|
||||
@NotNull PositionMeta meta, @NotNull UUID uuid) {
|
||||
protected SavedPosition(double x, double y, double z, float yaw, float pitch, @NotNull World world,
|
||||
@NotNull String server, @NotNull PositionMeta meta, @NotNull UUID uuid) {
|
||||
super(x, y, z, yaw, pitch, world, server);
|
||||
this.setMeta(meta);
|
||||
this.uuid = uuid;
|
||||
|
||||
@@ -11,9 +11,8 @@ public class Warp extends SavedPosition {
|
||||
|
||||
private static final String PERMISSION_PREFIX = "huskhomes.command.warp.";
|
||||
|
||||
public Warp(double x, double y, double z, float yaw, float pitch,
|
||||
@NotNull World world, @NotNull String server,
|
||||
@NotNull PositionMeta positionMeta, @NotNull UUID uuid) {
|
||||
private Warp(double x, double y, double z, float yaw, float pitch, @NotNull World world, @NotNull String server,
|
||||
@NotNull PositionMeta positionMeta, @NotNull UUID uuid) {
|
||||
super(x, y, z, yaw, pitch, world, server, positionMeta, uuid);
|
||||
}
|
||||
|
||||
@@ -23,10 +22,19 @@ public class Warp extends SavedPosition {
|
||||
* @param position The {@link Position} to save as a warp
|
||||
* @param meta {@link PositionMeta} information about this position
|
||||
*/
|
||||
public Warp(@NotNull Position position, @NotNull PositionMeta meta) {
|
||||
private Warp(@NotNull Position position, @NotNull PositionMeta meta) {
|
||||
super(position, meta);
|
||||
}
|
||||
|
||||
public static Warp from(double x, double y, double z, float yaw, float pitch, @NotNull World world,
|
||||
@NotNull String server, @NotNull PositionMeta positionMeta, @NotNull UUID uuid) {
|
||||
return new Warp(x, y, z, yaw, pitch, world, server, positionMeta, uuid);
|
||||
}
|
||||
|
||||
public static Warp from(@NotNull Position position, @NotNull PositionMeta meta) {
|
||||
return new Warp(position, meta);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getPermission(@NotNull String warpName) {
|
||||
return PERMISSION_PREFIX + warpName.toLowerCase();
|
||||
|
||||
@@ -16,12 +16,7 @@ public class World {
|
||||
@Nullable
|
||||
private Environment environment;
|
||||
|
||||
public World(@NotNull String name, @NotNull UUID uuid) {
|
||||
this.setName(name);
|
||||
this.setUuid(uuid);
|
||||
}
|
||||
|
||||
public World(@NotNull String name, @NotNull UUID uuid, @Nullable Environment environment) {
|
||||
private World(@NotNull String name, @NotNull UUID uuid, @Nullable Environment environment) {
|
||||
this.setName(name);
|
||||
this.setUuid(uuid);
|
||||
this.setEnvironment(environment);
|
||||
@@ -31,14 +26,25 @@ public class World {
|
||||
public World() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static World from(@NotNull String name, @NotNull UUID uuid, @NotNull Environment environment) {
|
||||
return new World(name, uuid, environment);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static World from(@NotNull String name, @NotNull UUID uuid) {
|
||||
return new World(name, uuid, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of this world, as defined by the world directory name
|
||||
*/
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
public void setName(@NotNull String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@@ -50,13 +56,15 @@ public class World {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(UUID uuid) {
|
||||
public void setUuid(@NotNull UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Environment of the world ({@link Environment#OVERWORLD}, {@link Environment#NETHER}, {@link Environment#THE_END},
|
||||
* or {@link Environment#CUSTOM})
|
||||
* <p>
|
||||
* Will return {@link Environment#OVERWORLD} if the environment is null
|
||||
*/
|
||||
@NotNull
|
||||
public Environment getEnvironment() {
|
||||
|
||||
+20
-14
@@ -13,19 +13,19 @@ import java.util.concurrent.CompletableFuture;
|
||||
/**
|
||||
* A random teleport engine that uses a Gaussian normal distribution to generate random positions.
|
||||
*/
|
||||
public class NormalDistributionEngine extends RandomTeleportEngine {
|
||||
public final class NormalDistributionEngine extends RandomTeleportEngine {
|
||||
|
||||
protected final int radius;
|
||||
protected final int spawnRadius;
|
||||
private final int radius;
|
||||
private final int spawnRadius;
|
||||
private final float mean;
|
||||
private final float standardDeviation;
|
||||
|
||||
public NormalDistributionEngine(@NotNull HuskHomes implementor) {
|
||||
super(implementor, "Normal Distribution");
|
||||
this.radius = implementor.getSettings().getRtpRadius();
|
||||
this.spawnRadius = implementor.getSettings().getRtpSpawnRadius();
|
||||
this.mean = implementor.getSettings().getRtpDistributionMean();
|
||||
this.standardDeviation = implementor.getSettings().getRtpDistributionStandardDeviation();
|
||||
public NormalDistributionEngine(@NotNull HuskHomes plugin) {
|
||||
super(plugin, "Normal Distribution");
|
||||
this.radius = plugin.getSettings().getRtpRadius();
|
||||
this.spawnRadius = plugin.getSettings().getRtpSpawnRadius();
|
||||
this.mean = plugin.getSettings().getRtpDistributionMean();
|
||||
this.standardDeviation = plugin.getSettings().getRtpDistributionStandardDeviation();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ public class NormalDistributionEngine extends RandomTeleportEngine {
|
||||
* @return A generated location
|
||||
*/
|
||||
@NotNull
|
||||
protected static Location generateLocation(@NotNull Location origin, float mean, float standardDeviation,
|
||||
public static Location generateLocation(@NotNull Location origin, float mean, float standardDeviation,
|
||||
float spawnRadius, float maxRadius) {
|
||||
// Generate random values
|
||||
final float radius = getDistributedRadius(mean, standardDeviation, spawnRadius, maxRadius);
|
||||
@@ -46,7 +46,12 @@ public class NormalDistributionEngine extends RandomTeleportEngine {
|
||||
final float z = (float) (radius * Math.cos(angle));
|
||||
final float x = (float) (radius * Math.sin(angle));
|
||||
|
||||
return new Location(Math.round(origin.getX()) + x, 128d, Math.round(origin.getZ()) + z, origin.getWorld());
|
||||
return Location.at(
|
||||
Math.round(origin.getX()) + x,
|
||||
128d,
|
||||
Math.round(origin.getZ()) + z,
|
||||
origin.getWorld()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,7 +62,7 @@ public class NormalDistributionEngine extends RandomTeleportEngine {
|
||||
*/
|
||||
private CompletableFuture<Optional<Location>> generateSafeLocation(@NotNull World world) {
|
||||
return plugin.resolveSafeGroundLocation(generateLocation(
|
||||
getOrigin(world), mean, standardDeviation, spawnRadius, radius));
|
||||
getCenterPoint(world), mean, standardDeviation, spawnRadius, radius));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,10 +95,11 @@ public class NormalDistributionEngine extends RandomTeleportEngine {
|
||||
int attempts = 0;
|
||||
while (location.isEmpty()) {
|
||||
location = generateSafeLocation(world).join();
|
||||
if (attempts > randomTimeout) {
|
||||
if (attempts >= maxAttempts) {
|
||||
return Optional.empty();
|
||||
}
|
||||
attempts++;
|
||||
}
|
||||
return location.map(resolved -> new Position(resolved, plugin.getServerName()));
|
||||
return location.map(resolved -> Position.at(resolved, plugin.getServerName()));
|
||||
}
|
||||
}
|
||||
@@ -12,19 +12,9 @@ import java.util.Optional;
|
||||
*/
|
||||
public abstract class RandomTeleportEngine {
|
||||
|
||||
@NotNull
|
||||
protected final HuskHomes plugin;
|
||||
|
||||
/**
|
||||
* The name of the random teleport engine
|
||||
*/
|
||||
@NotNull
|
||||
public final String name;
|
||||
|
||||
/**
|
||||
* How many attempts to allow {@link #getRandomPosition} lookups before timing out
|
||||
*/
|
||||
public long randomTimeout = 8;
|
||||
public long maxAttempts = 12;
|
||||
|
||||
/**
|
||||
* Constructor for a random teleport engine
|
||||
@@ -37,15 +27,21 @@ public abstract class RandomTeleportEngine {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public final String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the origin position (spawn) of this server
|
||||
*
|
||||
* @return The origin position
|
||||
*/
|
||||
protected final Position getOrigin(@NotNull World world) {
|
||||
@NotNull
|
||||
protected Position getCenterPoint(@NotNull World world) {
|
||||
return plugin.getLocalCachedSpawn()
|
||||
.map(s -> s.getPosition(plugin.getServerName()))
|
||||
.orElse(new Position(0d, 128d, 0d, 0f, 0f,
|
||||
.orElse(Position.at(0d, 128d, 0d, 0f, 0f,
|
||||
world, plugin.getServerName()));
|
||||
}
|
||||
|
||||
@@ -56,7 +52,7 @@ public abstract class RandomTeleportEngine {
|
||||
* @param world The world to find a random position in
|
||||
* @param args The arguments to pass to the random teleport engine
|
||||
* @return The position, optionally, which will be empty if the random teleport engine timed out after a
|
||||
* {@link #randomTimeout configured number of attempts}
|
||||
* {@link #maxAttempts configured number of attempts}
|
||||
*/
|
||||
public abstract Optional<Position> getRandomPosition(@NotNull World world, @NotNull String[] args);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.william278.huskhomes.teleport;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.config.Settings;
|
||||
import net.william278.huskhomes.event.ITeleportEvent;
|
||||
import net.william278.huskhomes.hook.EconomyHook;
|
||||
import net.william278.huskhomes.network.Message;
|
||||
@@ -85,8 +86,7 @@ public class Teleport {
|
||||
fireEvent((event) -> {
|
||||
executeEconomyActions();
|
||||
teleporter.teleportLocally(localTarget.get().getPosition(), async);
|
||||
plugin.getLocales().getLocale("teleporting_complete")
|
||||
.ifPresent(teleporter::sendMessage);
|
||||
this.displayTeleportingComplete(teleporter);
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -98,8 +98,7 @@ public class Teleport {
|
||||
.type(Message.Type.TELEPORT_TO_NETWORKED_POSITION)
|
||||
.target(username.name())
|
||||
.build().send(plugin.getMessenger(), executor);
|
||||
plugin.getLocales().getLocale("teleporting_complete")
|
||||
.ifPresent(teleporter::sendMessage);
|
||||
this.displayTeleportingComplete(teleporter);
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -111,10 +110,9 @@ public class Teleport {
|
||||
executeEconomyActions();
|
||||
|
||||
final Position target = (Position) this.target;
|
||||
if (plugin.getSettings().isCrossServer() && target.getServer().equals(plugin.getServerName())) {
|
||||
if (!plugin.getSettings().isCrossServer() || target.getServer().equals(plugin.getServerName())) {
|
||||
teleporter.teleportLocally(target, async);
|
||||
plugin.getLocales().getLocale("teleporting_complete")
|
||||
.ifPresent(teleporter::sendMessage);
|
||||
this.displayTeleportingComplete(teleporter);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -123,10 +121,6 @@ public class Teleport {
|
||||
});
|
||||
}
|
||||
|
||||
private void teleport(@NotNull OnlineUser teleporter, @NotNull Position target) {
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Optional<OnlineUser> resolveLocalTeleporter() throws TeleportationException {
|
||||
if (this.teleporter instanceof Username username) {
|
||||
@@ -135,6 +129,13 @@ public class Teleport {
|
||||
return Optional.of((OnlineUser) this.teleporter);
|
||||
}
|
||||
|
||||
public void displayTeleportingComplete(@NotNull OnlineUser teleporter) {
|
||||
plugin.getLocales().getLocale("teleporting_complete")
|
||||
.ifPresent(teleporter::sendMessage);
|
||||
plugin.getSettings().getSoundEffect(Settings.SoundEffectAction.TELEPORTATION_CANCELLED)
|
||||
.ifPresent(teleporter::playSound);
|
||||
}
|
||||
|
||||
// Fire the teleport event
|
||||
private void fireEvent(@NotNull Consumer<ITeleportEvent> afterFired) {
|
||||
plugin.fireEvent(plugin.getTeleportEvent(this), afterFired);
|
||||
|
||||
@@ -132,12 +132,7 @@ public class TimedTeleport extends Teleport {
|
||||
}
|
||||
|
||||
private void sendStatusMessage(@NotNull MineDown message) {
|
||||
switch (plugin.getSettings().getTeleportWarmupDisplay()) {
|
||||
case ACTION_BAR -> teleporter.sendActionBar(message);
|
||||
case SUBTITLE -> teleporter.sendTitle(message, true);
|
||||
case TITLE -> teleporter.sendTitle(message, false);
|
||||
case MESSAGE -> teleporter.sendMessage(message);
|
||||
}
|
||||
teleporter.sendMessage(message, plugin.getSettings().getTeleportWarmupDisplay());
|
||||
}
|
||||
|
||||
private boolean hasTeleporterMoved() {
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.title.TitlePart;
|
||||
import net.william278.huskhomes.config.Locales;
|
||||
import net.william278.huskhomes.position.Location;
|
||||
import net.william278.huskhomes.position.Position;
|
||||
import net.william278.huskhomes.teleport.Teleportable;
|
||||
@@ -98,6 +99,24 @@ public abstract class OnlineUser extends User implements Teleportable, CommandUs
|
||||
.replace().toComponent());
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch a MineDown-formatted message to this player
|
||||
*
|
||||
* @param mineDown the parsed {@link MineDown} to send
|
||||
* @param slot the {@link Locales.DisplaySlot} to send the message to
|
||||
*/
|
||||
public final void sendMessage(@NotNull MineDown mineDown, @NotNull Locales.DisplaySlot slot) {
|
||||
if (slot == Locales.DisplaySlot.CHAT) {
|
||||
sendMessage(mineDown);
|
||||
} else if (slot == Locales.DisplaySlot.ACTION_BAR) {
|
||||
sendActionBar(mineDown);
|
||||
} else if (slot == Locales.DisplaySlot.TITLE) {
|
||||
sendTitle(mineDown, false);
|
||||
} else if (slot == Locales.DisplaySlot.SUBTITLE) {
|
||||
sendTitle(mineDown, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch a Minecraft translatable keyed-message to this player
|
||||
*
|
||||
@@ -144,6 +163,7 @@ public abstract class OnlineUser extends User implements Teleportable, CommandUs
|
||||
|
||||
/**
|
||||
* Send a plugin message to the user
|
||||
*
|
||||
* @param channel channel to send it on
|
||||
* @param message byte array of message data
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user