Skip to content

Commit

Permalink
Merge branch 'master' into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwmth committed Apr 16, 2024
2 parents df3a9cb + b2ec38d commit 4ac3953
Show file tree
Hide file tree
Showing 16 changed files with 121 additions and 58 deletions.
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ dependencies {
depend(this, "de.exlll:configlib-spigot:4.2.0")
depend(this, "org.msgpack:msgpack-core:0.9.8")

val liteCommands = "3.3.3"
val liteCommands = "3.4.1"
depend(this, "dev.rollczi:litecommands-bukkit:${liteCommands}")
depend(this, "dev.rollczi:litecommands-adventure-platform:${liteCommands}")

val adventure = "4.14.0"
depend(this, "net.kyori:adventure-platform-bukkit:4.3.0")
val adventure = "4.16.0"
depend(this, "net.kyori:adventure-platform-bukkit:4.3.2")
depend(this, "net.kyori:adventure-api:${adventure}")
depend(this, "net.kyori:adventure-text-minimessage:${adventure}")
depend(this, "net.kyori:adventure-text-serializer-legacy:${adventure}")

val lombok = "org.projectlombok:lombok:1.18.30"
val lombok = "org.projectlombok:lombok:1.18.32"
compileOnly(lombok)
annotationProcessor(lombok)
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ plugin_id=alpineclientapi

version_major=1
version_minor=2
version_patch=0
version_patch=2
version_pre_release=none
10 changes: 3 additions & 7 deletions src/main/java/com/alpineclient/plugin/Plugin.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.alpineclient.plugin;

import com.alpineclient.plugin.command.CommandCheck;
import com.alpineclient.plugin.command.CommandInvalidUsage;
import com.alpineclient.plugin.command.CommandList;
import com.alpineclient.plugin.command.CommandNotify;
import com.alpineclient.plugin.command.*;
import com.alpineclient.plugin.config.ConfigManager;
import com.alpineclient.plugin.config.impl.MessageConfig;
import com.alpineclient.plugin.framework.EventListener;
Expand All @@ -19,7 +16,6 @@
import dev.rollczi.litecommands.message.LiteMessages;
import dev.rollczi.litecommands.schematic.SchematicFormat;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.ApiStatus;
Expand Down Expand Up @@ -113,8 +109,8 @@ else if (PluginListener.class.isAssignableFrom(clazz)) {
Constructor<? extends PluginListener> constructor = ((Class<? extends PluginListener>) clazz).getDeclaredConstructor();
constructor.setAccessible(true);
PluginListener listener = constructor.newInstance();
Bukkit.getMessenger().registerOutgoingPluginChannel(this, listener.getChannelId());
Bukkit.getMessenger().registerIncomingPluginChannel(this, listener.getChannelId(), listener);
this.getServer().getMessenger().registerOutgoingPluginChannel(this, listener.getChannelId());
this.getServer().getMessenger().registerIncomingPluginChannel(this, listener.getChannelId(), listener);
}
}
catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@
import com.alpineclient.plugin.config.impl.GeneralConfig;
import com.alpineclient.plugin.listener.plugin.PlayListener;
import com.alpineclient.plugin.network.Packet;
import com.alpineclient.plugin.network.packet.PacketModules;
import com.alpineclient.plugin.network.packet.PacketNotificationAdd;
import com.alpineclient.plugin.network.packet.PacketWaypointAdd;
import com.alpineclient.plugin.network.packet.PacketWorldUpdate;
import com.alpineclient.plugin.network.packet.*;
import com.alpineclient.plugin.util.object.HandshakeData;
import lombok.Getter;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

import java.util.List;
import java.util.UUID;

/**
* Holds data about an Alpine Client user and provides methods
Expand Down Expand Up @@ -92,6 +90,18 @@ public void sendWaypoint(@NotNull Waypoint waypoint) {
this.sendPacket(packet);
}

/**
* Requests the player delete a waypoint with a given UUID.
*
* @param id the waypoint to delete
*
* @since 1.2.1
*/
public void deleteWaypoint(@NotNull UUID id) {
PacketWaypointRemove packet = new PacketWaypointRemove(id);
this.sendPacket(packet);
}

/**
* Sends the current module settings to this player.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.jetbrains.annotations.NotNull;

import java.awt.*;
import java.util.UUID;

/**
* Represents a location in the world that is highlighted to the user.
Expand Down Expand Up @@ -36,6 +37,7 @@ public final class Waypoint {
*/
public static final long NO_DURATION = -1L;

private final UUID id = UUID.randomUUID();
private final String name;
private final Location pos;
private final int color;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
public final class MessageConfig extends AbstractConfig {

{
Components.setMessageConfig(this);
ConfigMessage.setConfig(this);
}

Expand Down
6 changes: 2 additions & 4 deletions src/main/java/com/alpineclient/plugin/network/Packet.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.alpineclient.plugin.network;

import com.alpineclient.plugin.Reference;
import com.alpineclient.plugin.network.packet.PacketModules;
import com.alpineclient.plugin.network.packet.PacketNotificationAdd;
import com.alpineclient.plugin.network.packet.PacketWaypointAdd;
import com.alpineclient.plugin.network.packet.PacketWorldUpdate;
import com.alpineclient.plugin.network.packet.*;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -100,6 +97,7 @@ protected static void addPacket(int id, Class<? extends Packet> clazz) {
/* Shared */
addPacket(0xA7, PacketNotificationAdd.class);
addPacket(0xA9, PacketWaypointAdd.class);
addPacket(0xA10, PacketWaypointRemove.class);

/* Plugin API */
addPacket(0xB0, PacketModules.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.alpineclient.plugin.network.Packet;
import com.alpineclient.plugin.network.WriteOnly;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.msgpack.core.MessagePacker;
Expand All @@ -17,9 +15,12 @@
* Created on 26/06/2023
*/
@WriteOnly
@AllArgsConstructor @NoArgsConstructor
public final class PacketModules extends Packet {
private Map<String, Boolean> modules;
private final Map<String, Boolean> modules;

public PacketModules(@NotNull Map<String, Boolean> modules) {
this.modules = modules;
}

@Override
public void write(@NotNull MessagePacker packer) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import com.alpineclient.plugin.api.objects.Notification;
import com.alpineclient.plugin.network.Packet;
import com.alpineclient.plugin.network.WriteOnly;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.msgpack.core.MessagePacker;
Expand All @@ -18,9 +16,12 @@
* Created on 13/06/23
*/
@WriteOnly
@AllArgsConstructor @NoArgsConstructor
public final class PacketNotificationAdd extends Packet {
private Notification notification;
private final Notification notification;

public PacketNotificationAdd(@NotNull Notification notification) {
this.notification = notification;
}

@Override
public void write(@NotNull MessagePacker packer) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import com.alpineclient.plugin.api.objects.Waypoint;
import com.alpineclient.plugin.network.Packet;
import com.alpineclient.plugin.network.WriteOnly;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import com.alpineclient.plugin.util.MsgPackUtils;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.msgpack.core.MessagePacker;
Expand All @@ -17,12 +16,16 @@
* Created on 26/06/2023
*/
@WriteOnly
@AllArgsConstructor @NoArgsConstructor
public final class PacketWaypointAdd extends Packet {
private Waypoint waypoint;
private final Waypoint waypoint;

public PacketWaypointAdd(@NotNull Waypoint waypoint) {
this.waypoint = waypoint;
}

@Override
public void write(@NotNull MessagePacker packer) throws IOException {
MsgPackUtils.packUuid(packer, this.waypoint.getId());
packer.packString(this.waypoint.getName());
packer.packInt(this.waypoint.getPos().getBlockX());
packer.packInt(this.waypoint.getPos().getBlockY());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.alpineclient.plugin.network.packet;

import com.alpineclient.plugin.network.Packet;
import com.alpineclient.plugin.network.WriteOnly;
import com.alpineclient.plugin.util.MsgPackUtils;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.msgpack.core.MessagePacker;
import org.msgpack.core.MessageUnpacker;

import java.io.IOException;
import java.util.UUID;

/**
* @author Thomas Wearmouth <[email protected]>
* Created on 7/02/2024
*/
@WriteOnly
public final class PacketWaypointRemove extends Packet {
private final UUID id;

public PacketWaypointRemove(@NotNull UUID id) {
this.id = id;
}

@Override
public void write(@NotNull MessagePacker packer) throws IOException {
MsgPackUtils.packUuid(packer, this.id);
}

@Override
public void read(@NotNull MessageUnpacker unpacker) {
// NO-OP
}

@Override
public void process(@NotNull Player player) {
// NO-OP
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.alpineclient.plugin.network.Packet;
import com.alpineclient.plugin.network.WriteOnly;
import lombok.AllArgsConstructor;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.msgpack.core.MessagePacker;
Expand All @@ -15,14 +14,16 @@
* Created on 24/06/2023
*/
@WriteOnly
@AllArgsConstructor
public final class PacketWorldUpdate extends Packet {
private final String world;

public PacketWorldUpdate(@NotNull String world) {
this.world = world;
}

@Override
public void write(@NotNull MessagePacker packer) throws IOException {
if (this.world != null)
packer.packString(this.world);
packer.packString(this.world);
}

@Override
Expand Down
13 changes: 2 additions & 11 deletions src/main/java/com/alpineclient/plugin/util/Components.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
package com.alpineclient.plugin.util;

import com.alpineclient.plugin.Reference;
import com.alpineclient.plugin.config.AbstractConfig;
import com.alpineclient.plugin.config.impl.MessageConfig;
import lombok.Setter;
import lombok.experimental.UtilityClass;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.JoinConfiguration;
import net.kyori.adventure.text.format.Style;
import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.format.TextDecoration;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
* @author BestBearr
* Created on 06/06/23
*/
@UtilityClass
@ApiStatus.Internal
public final class Components {

@Setter
private static MessageConfig messageConfig;

@NotNull
public static Component reset() {
Style.Builder style = Style.style().color(TextColor.color(-1));
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/alpineclient/plugin/util/Formatting.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.experimental.UtilityClass;
import net.kyori.adventure.text.Component;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -14,6 +15,7 @@
* Created on 07/06/23
*/
@UtilityClass
@ApiStatus.Internal
public final class Formatting {

private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.##");
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/com/alpineclient/plugin/util/MsgPackUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.alpineclient.plugin.util;

import lombok.experimental.UtilityClass;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.msgpack.core.MessagePacker;
import org.msgpack.core.MessageUnpacker;

import java.io.IOException;
import java.util.UUID;

/**
* @author Thomas Wearmouth <[email protected]>
* Created on 7/02/2024
*/
@UtilityClass
@ApiStatus.Internal
public final class MsgPackUtils {
public static @NotNull UUID unpackUuid(@NotNull MessageUnpacker unpacker) throws IOException {
long msb = unpacker.unpackLong();
long lsb = unpacker.unpackLong();
return new UUID(msb, lsb);
}

public static void packUuid(@NotNull MessagePacker packer, @NotNull UUID id) throws IOException {
packer.packLong(id.getMostSignificantBits());
packer.packLong(id.getLeastSignificantBits());
}
}

0 comments on commit 4ac3953

Please sign in to comment.