diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d409c815..cac2568a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -17,8 +17,8 @@ jobs: - name: Configure Google Cloud credentials uses: google-github-actions/auth@v1 with: - workload_identity_provider: 'projects/271010089174/locations/global/workloadIdentityPools/github/providers/github-oidc' - service_account: 'github-actions@moonsworth-299m4oir.iam.gserviceaccount.com' + workload_identity_provider: 'projects/266324743316/locations/global/workloadIdentityPools/github/providers/github-oidc' + service_account: 'github-actions@mw-lunarclient-maven-repo.iam.gserviceaccount.com' - name: Setup Java uses: actions/setup-java@v3 diff --git a/api/src/main/java/com/lunarclient/apollo/event/pingmarker/ApolloPlayerRequestMarkerEvent.java b/api/src/main/java/com/lunarclient/apollo/event/pingmarker/ApolloPlayerRequestMarkerEvent.java new file mode 100644 index 00000000..ebaab565 --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/event/pingmarker/ApolloPlayerRequestMarkerEvent.java @@ -0,0 +1,82 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 Moonsworth + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.lunarclient.apollo.event.pingmarker; + +import com.lunarclient.apollo.common.location.ApolloLocation; +import com.lunarclient.apollo.event.EventCancellable; +import com.lunarclient.apollo.module.pingmarker.PingMarkerType; +import com.lunarclient.apollo.player.ApolloPlayer; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.Setter; +import lombok.experimental.FieldDefaults; +import lombok.experimental.NonFinal; +import org.jetbrains.annotations.Nullable; + +/** + * Represents an event that is fired when the player requests a ping marker. + * + * @since 1.1.9 + */ +@Getter +@RequiredArgsConstructor +@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true) +public final class ApolloPlayerRequestMarkerEvent implements EventCancellable { + + /** + * The player sending the ping request. + * + * @return the source player + * @since 1.1.9 + */ + ApolloPlayer player; + + /** + * The {@link PingMarkerType} for this request. + * + * @return the ping marker type + * @since 1.1.9 + */ + @Nullable PingMarkerType type; + + /** + * The source {@link ApolloLocation} for this request. + * + * @return the source location + * @since 1.1.9 + */ + ApolloLocation source; + + /** + * The target {@link ApolloLocation} for this request. + * + * @return the target location + * @since 1.1.9 + */ + ApolloLocation target; + + @NonFinal @Setter boolean cancelled; + +} diff --git a/api/src/main/java/com/lunarclient/apollo/module/glow/GlowModule.java b/api/src/main/java/com/lunarclient/apollo/module/glow/GlowModule.java index e4118a14..aa4b6e79 100644 --- a/api/src/main/java/com/lunarclient/apollo/module/glow/GlowModule.java +++ b/api/src/main/java/com/lunarclient/apollo/module/glow/GlowModule.java @@ -47,6 +47,20 @@ public boolean isClientNotify() { /** * Overrides the glow effect for the glowingPlayer, visible by the viewers. * + *

If no color is specified, the glowing color will match the player's scoreboard team color.

+ * + * + * @param recipients the recipients that are receiving the packet + * @param glowingPlayer the UUID of the player whose glowing effect will be overwrote + * @since 1.1.9 + */ + public abstract void overrideGlow(Recipients recipients, UUID glowingPlayer); + + /** + * Overrides the glow effect for the glowingPlayer, visible by the viewers. + * + *

If the {@code color} parameter is {@code null}, the glowing color will match the player's scoreboard team color.

+ * * @param recipients the recipients that are receiving the packet * @param glowingPlayer the UUID of the player whose glowing effect will be overwrote * @param color the new color glowingPlayer should glow in. diff --git a/api/src/main/java/com/lunarclient/apollo/module/pingmarker/PingMarker.java b/api/src/main/java/com/lunarclient/apollo/module/pingmarker/PingMarker.java new file mode 100644 index 00000000..97b18269 --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/module/pingmarker/PingMarker.java @@ -0,0 +1,103 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 Moonsworth + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.lunarclient.apollo.module.pingmarker; + +import com.lunarclient.apollo.common.icon.Icon; +import com.lunarclient.apollo.common.location.ApolloLocation; +import java.awt.Color; +import java.time.Duration; +import java.util.UUID; +import lombok.Builder; +import lombok.Getter; +import org.jetbrains.annotations.Nullable; + +/** + * Represents a ping marker which can be shown on the client. + * + * @since 1.1.9 + */ +@Getter +@Builder +public final class PingMarker { + + /** + * Returns the marker {@link UUID}. + * + * @return the ping marker id + * @since 1.1.9 + */ + UUID id; + + /** + * Returns the {@link PingMarkerType}. + * + * @return the ping marker type + * @since 1.1.9 + */ + @Nullable PingMarkerType type; + + /** + * Returns the marker {@link ApolloLocation}. + * + * @return the ping marker location + * @since 1.1.9 + */ + ApolloLocation location; + + /** + * Returns the marker {@link Color}. + * + * @return the ping marker color + * @since 1.1.9 + */ + Color color; + + /** + * Returns the marker {@link Duration}. + * + * @return the ping marker duration + * @since 1.1.9 + */ + Duration duration; + + /** + * Returns whether the marker should animate. + * + * @return the ping marker focus state + * @since 1.1.9 + */ + boolean focus; + + /** + * Returns the ping marker {@link Icon}. + * + *

Can be any of the icons found in {@link com.lunarclient.apollo.common.icon} package, + * for the most common use case, use {@link com.lunarclient.apollo.common.icon.ItemStackIcon}.

+ * + * @return the ping marker icon + * @since 1.1.9 + */ + Icon icon; + +} diff --git a/api/src/main/java/com/lunarclient/apollo/module/pingmarker/PingMarkerModule.java b/api/src/main/java/com/lunarclient/apollo/module/pingmarker/PingMarkerModule.java new file mode 100644 index 00000000..6f53984d --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/module/pingmarker/PingMarkerModule.java @@ -0,0 +1,111 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 Moonsworth + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.lunarclient.apollo.module.pingmarker; + +import com.lunarclient.apollo.module.ApolloModule; +import com.lunarclient.apollo.module.ModuleDefinition; +import com.lunarclient.apollo.recipients.Recipients; +import java.util.UUID; +import org.jetbrains.annotations.ApiStatus; + +/** + * Represents the ping marker module. + * + * @since 1.1.9 + */ +@ApiStatus.NonExtendable +@ModuleDefinition(id = "ping_marker", name = "Ping Marker") +public abstract class PingMarkerModule extends ApolloModule { + + /** + * Sends the {@link PingMarkerType} to the {@link Recipients}. + * + * @param recipients the recipients that are receiving the packet + * @param type the marker type + * @since 1.1.9 + */ + public abstract void setMarkerType(Recipients recipients, PingMarkerType type); + + /** + * Removes the {@link PingMarkerType} from the {@link Recipients}. + * + * @param recipients the recipients that are receiving the packet + * @param name the marker type name + * @since 1.1.9 + */ + public abstract void removeMarkerType(Recipients recipients, String name); + + /** + * Removes the {@link PingMarkerType} from the {@link Recipients}. + * + * @param recipients the recipients that are receiving the packet + * @param type the marker type + * @since 1.1.9 + */ + public abstract void removeMarkerType(Recipients recipients, PingMarkerType type); + + /** + * Resets all {@link PingMarkerType}s for the {@link Recipients}. + * + * @param recipients the recipients that are receiving the packet + * @since 1.1.9 + */ + public abstract void resetMarkerType(Recipients recipients); + + /** + * Displays the {@link PingMarker} to the {@link Recipients}. + * + * @param recipients the recipients that are receiving the packet + * @param marker the marker + * @since 1.1.9 + */ + public abstract void displayMarker(Recipients recipients, PingMarker marker); + + /** + * Removes the {@link PingMarker} from the {@link Recipients}. + * + * @param recipients the recipients that are receiving the packet + * @param markerId the marker id + * @since 1.1.9 + */ + public abstract void removeMarker(Recipients recipients, UUID markerId); + + /** + * Removes the {@link PingMarker} from the {@link Recipients}. + * + * @param recipients the recipients that are receiving the packet + * @param marker the marker + * @since 1.1.9 + */ + public abstract void removeMarker(Recipients recipients, PingMarker marker); + + /** + * Resets all {@link PingMarker}s for the {@link Recipients}. + * + * @param recipients the recipients that are receiving the packet + * @since 1.1.9 + */ + public abstract void resetMarkers(Recipients recipients); + +} diff --git a/api/src/main/java/com/lunarclient/apollo/module/pingmarker/PingMarkerType.java b/api/src/main/java/com/lunarclient/apollo/module/pingmarker/PingMarkerType.java new file mode 100644 index 00000000..d088df5b --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/module/pingmarker/PingMarkerType.java @@ -0,0 +1,58 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 Moonsworth + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.lunarclient.apollo.module.pingmarker; + +import com.lunarclient.apollo.common.icon.Icon; +import lombok.Builder; +import lombok.Getter; + +/** + * Represents a ping marker type which can be shown on the client. + * + * @since 1.1.9 + */ +@Getter +@Builder +public final class PingMarkerType { + + /** + * Returns the ping marker type {@link String} name. + * + * @return the ping marker type name + * @since 1.1.9 + */ + String name; + + /** + * Returns the ping marker {@link Icon}. + * + *

Can be any of the icons found in {@link com.lunarclient.apollo.common.icon} package, + * for the most common use case, use {@link com.lunarclient.apollo.common.icon.ItemStackIcon}.

+ * + * @return the ping marker icon + * @since 1.1.9 + */ + Icon icon; + +} diff --git a/api/src/main/java/com/lunarclient/apollo/recipients/Recipients.java b/api/src/main/java/com/lunarclient/apollo/recipients/Recipients.java index dbf3da03..74825cb3 100644 --- a/api/src/main/java/com/lunarclient/apollo/recipients/Recipients.java +++ b/api/src/main/java/com/lunarclient/apollo/recipients/Recipients.java @@ -24,6 +24,8 @@ package com.lunarclient.apollo.recipients; import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.player.ApolloPlayer; +import com.lunarclient.apollo.world.ApolloWorld; import java.util.function.Consumer; /** @@ -56,6 +58,18 @@ static ForwardingRecipients ofEveryone() { return () -> Apollo.getPlayerManager().getPlayers(); } + /** + * Creates a {@link ForwardingRecipients} instance representing apollo + * players in the same world as the provided {@link ApolloPlayer}. + * + * @param player the apollo player + * @return a {@code ForwardingRecipients} instance representing players in the world + * @since 1.1.9 + */ + static ForwardingRecipients ofWorld(ApolloPlayer player) { + return () -> player.getWorld().map(ApolloWorld::getPlayers).orElseGet(() -> Apollo.getPlayerManager().getPlayers()); + } + /** * Performs the given action on recipients. * diff --git a/build-logic/src/main/kotlin/apollo.publish-conventions.gradle.kts b/build-logic/src/main/kotlin/apollo.publish-conventions.gradle.kts index 6a8d3ced..4d8f9582 100644 --- a/build-logic/src/main/kotlin/apollo.publish-conventions.gradle.kts +++ b/build-logic/src/main/kotlin/apollo.publish-conventions.gradle.kts @@ -13,7 +13,7 @@ java { publishing { repositories.maven { - url = uri("artifactregistry://us-maven.pkg.dev/moonsworth-299m4oir/maven-public") + url = uri("artifactregistry://us-maven.pkg.dev/mw-lunarclient-maven-repo/public") } publications.create("mavenJava") { diff --git a/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/ApolloApiExamplePlatform.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/ApolloApiExamplePlatform.java index a078c371..50c37824 100644 --- a/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/ApolloApiExamplePlatform.java +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/ApolloApiExamplePlatform.java @@ -44,6 +44,7 @@ import com.lunarclient.apollo.example.api.module.NametagApiExample; import com.lunarclient.apollo.example.api.module.NickHiderApiExample; import com.lunarclient.apollo.example.api.module.NotificationApiExample; +import com.lunarclient.apollo.example.api.module.PingMarkerApiExample; import com.lunarclient.apollo.example.api.module.RichPresenceApiExample; import com.lunarclient.apollo.example.api.module.ServerRuleApiExample; import com.lunarclient.apollo.example.api.module.StaffModApiExample; @@ -92,6 +93,7 @@ public void registerModuleExamples() { this.setNametagExample(new NametagApiExample()); this.setNickHiderExample(new NickHiderApiExample()); this.setNotificationExample(new NotificationApiExample()); + this.setPingMarkerExample(new PingMarkerApiExample()); this.setRichPresenceExample(new RichPresenceApiExample()); this.setServerRuleExample(new ServerRuleApiExample()); this.setStaffModExample(new StaffModApiExample()); diff --git a/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/PingMarkerApiExample.java b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/PingMarkerApiExample.java new file mode 100644 index 00000000..f5fece62 --- /dev/null +++ b/bukkit-example-api/src/main/java/com/lunarclient/apollo/example/api/module/PingMarkerApiExample.java @@ -0,0 +1,84 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 Moonsworth + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.lunarclient.apollo.example.api.module; + +import com.lunarclient.apollo.Apollo; +import com.lunarclient.apollo.BukkitApollo; +import com.lunarclient.apollo.common.icon.SimpleResourceLocationIcon; +import com.lunarclient.apollo.example.module.impl.PingMarkerExample; +import com.lunarclient.apollo.module.pingmarker.PingMarker; +import com.lunarclient.apollo.module.pingmarker.PingMarkerModule; +import com.lunarclient.apollo.player.ApolloPlayer; +import com.lunarclient.apollo.recipients.Recipients; +import java.awt.Color; +import java.time.Duration; +import java.util.Optional; +import java.util.UUID; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; + +public class PingMarkerApiExample extends PingMarkerExample { + + private final PingMarkerModule pingMarkerModule = Apollo.getModuleManager().getModule(PingMarkerModule.class); + + @Override + public void displayMarkerResourceExample(Player player) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(player.getUniqueId()); + + apolloPlayerOpt.ifPresent(apolloPlayer -> { + Location location = this.findTargetLocation(player); + + if (location == null) { + return; + } + + this.pingMarkerModule.displayMarker(Recipients.ofWorld(apolloPlayer), PingMarker.builder() + .id(UUID.randomUUID()) + .type(null) // TODO: add another example with a specific type + .location(BukkitApollo.toApolloLocation(location)) + .color(Color.WHITE) + .icon(SimpleResourceLocationIcon.builder() + .resourceLocation("lunar:icons/fluent-black-circle-icon.svg") + .size(12) + .build() + ) + .duration(Duration.ofSeconds(5)) + .focus(true) + .build()); + }); + + } + + private Location findTargetLocation(Player player) { + Block targetBlock = player.getTargetBlockExact(30); + + if (targetBlock == null) { + return null; + } + + return targetBlock.getLocation().add(0.5D, 0.5D, 0.5D); + } + +} diff --git a/bukkit-example-api/src/main/resources/plugin.yml b/bukkit-example-api/src/main/resources/plugin.yml index 0c9392a2..48ab36a3 100644 --- a/bukkit-example-api/src/main/resources/plugin.yml +++ b/bukkit-example-api/src/main/resources/plugin.yml @@ -43,6 +43,8 @@ commands: description: "Nick Hider!" notification: description: "Notifications!" + pingmarker: + description: "Ping Marker!" richpresence: description: "Rich Presence!" saturation: diff --git a/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/ApolloExamplePlugin.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/ApolloExamplePlugin.java index 996c9472..02e74fe1 100644 --- a/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/ApolloExamplePlugin.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/ApolloExamplePlugin.java @@ -40,6 +40,7 @@ import com.lunarclient.apollo.example.command.NametagCommand; import com.lunarclient.apollo.example.command.NickHiderCommand; import com.lunarclient.apollo.example.command.NotificationCommand; +import com.lunarclient.apollo.example.command.PingMarkerCommand; import com.lunarclient.apollo.example.command.RichPresenceCommand; import com.lunarclient.apollo.example.command.SaturationCommand; import com.lunarclient.apollo.example.command.ServerRuleCommand; @@ -69,6 +70,7 @@ import com.lunarclient.apollo.example.module.impl.NametagExample; import com.lunarclient.apollo.example.module.impl.NickHiderExample; import com.lunarclient.apollo.example.module.impl.NotificationExample; +import com.lunarclient.apollo.example.module.impl.PingMarkerExample; import com.lunarclient.apollo.example.module.impl.RichPresenceExample; import com.lunarclient.apollo.example.module.impl.SaturationExample; import com.lunarclient.apollo.example.module.impl.ServerRuleExample; @@ -108,6 +110,7 @@ public abstract class ApolloExamplePlugin extends JavaPlugin { private NametagExample nametagExample; private NickHiderExample nickHiderExample; private NotificationExample notificationExample; + private PingMarkerExample pingMarkerExample; private RichPresenceExample richPresenceExample; private SaturationExample saturationExample; private ServerRuleExample serverRuleExample; @@ -157,6 +160,7 @@ private void registerCommonCommands() { this.getCommand("nametag").setExecutor(new NametagCommand()); this.getCommand("nickhider").setExecutor(new NickHiderCommand()); this.getCommand("notification").setExecutor(new NotificationCommand()); + this.getCommand("pingmarker").setExecutor(new PingMarkerCommand()); this.getCommand("richpresence").setExecutor(new RichPresenceCommand()); this.getCommand("saturation").setExecutor(new SaturationCommand()); this.getCommand("serverrule").setExecutor(new ServerRuleCommand()); diff --git a/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/PingMarkerCommand.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/PingMarkerCommand.java new file mode 100644 index 00000000..eb3eda9a --- /dev/null +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/command/PingMarkerCommand.java @@ -0,0 +1,67 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 Moonsworth + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.lunarclient.apollo.example.command; + +import com.lunarclient.apollo.example.ApolloExamplePlugin; +import com.lunarclient.apollo.example.module.impl.PingMarkerExample; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public class PingMarkerCommand implements CommandExecutor { + + @Override + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { + if (!(sender instanceof Player)) { + sender.sendMessage("Player only!"); + return true; + } + + Player player = (Player) sender; + + if (args.length != 1) { + player.sendMessage("Usage: /pingmarker "); + return true; + } + + PingMarkerExample pingMarkerExample = ApolloExamplePlugin.getInstance().getPingMarkerExample(); + + switch (args[0].toLowerCase()) { + case "displayresource": { + pingMarkerExample.displayMarkerResourceExample(player); + player.sendMessage("Displaying a ping marker with a resource...."); + break; + } + + default: { + player.sendMessage("Usage: /pingmarker "); + break; + } + } + + return true; + } +} diff --git a/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/GlintExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/GlintExample.java index 12108c99..1f10cdb7 100644 --- a/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/GlintExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/GlintExample.java @@ -44,11 +44,11 @@ public boolean glintModuleExample(Player player) { } public void glintModuleCommandExample(Player player) { - player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:diamond_helmet\",Count:1b,tag:{lunar:{glint:\"#FF5733\"}}}}"); - player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:diamond_helmet\",Count:1b,tag:{lunar:{glint:\"#33FF57\"}}}}"); - player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:diamond_helmet\",Count:1b,tag:{lunar:{glint:\"#3357FF\"}}}}"); - player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:diamond_helmet\",Count:1b,tag:{lunar:{glint:\"#FFD700\"}}}}"); - player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:diamond_helmet\",Count:1b,tag:{lunar:{glint:\"-16711936\"}}}}"); + player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:diamond_helmet\",Count:1b,components:{\"minecraft:custom_data\":{lunar:{glint:\"#FF5733\"}}}}}"); + player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:diamond_helmet\",Count:1b,components:{\"minecraft:custom_data\":{lunar:{glint:\"#33FF57\"}}}}}"); + player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:diamond_helmet\",Count:1b,components:{\"minecraft:custom_data\":{lunar:{glint:\"#3357FF\"}}}}}"); + player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:diamond_helmet\",Count:1b,components:{\"minecraft:custom_data\":{lunar:{glint:\"#FFD700\"}}}}}"); + player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:diamond_helmet\",Count:1b,components:{\"minecraft:custom_data\":{lunar:{glint:\"-16711936\"}}}}}"); } public void glintModuleNMSExample(Player player) { diff --git a/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/InventoryExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/InventoryExample.java index acc3a923..fa2995ac 100644 --- a/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/InventoryExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/InventoryExample.java @@ -45,11 +45,11 @@ public boolean inventoryModuleExample(Player player) { } public void inventoryModuleCommandExample(Player player) { - player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:stone\",Count:1b,tag:{display:{Name:\"\\\"§c§lUNCLICKABLE\\\"\"},lunar:{unclickable:true}}}}"); - player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:paper\",Count:1b,tag:{display:{Name:\"\\\"§9§lCOPY TO CLIPBOARD\\\"\"},lunar:{unclickable:true,copyToClipboard:\"lunarclient.com\"}}}}"); - player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:torch\",Count:1b,tag:{display:{Name:\"\\\"§6§lOPEN URL\\\"\"},lunar:{unclickable:true,openUrl:\"https://lunarclient.com\"}}}}"); - player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:book\",Count:1b,tag:{display:{Name:\"\\\"§2§lSUGGEST COMMAND\\\"\"},lunar:{unclickable:true,suggestCommand:\"/apollo\"}}}}"); - player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:writable_book\",Count:1b,tag:{display:{Name:\"\\\"§d§lRUN COMMAND\\\"\"},lunar:{unclickable:true,runCommand:\"/apollo\"}}}}"); + player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:stone\",Count:1b,components:{\"minecraft:custom_name\":\"UNCLICKABLE\",\"minecraft:custom_data\":{lunar:{unclickable:true}}}}}"); + player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:paper\",Count:1b,components:{\"minecraft:custom_name\":\"COPY TO CLIPBOARD\",\"minecraft:custom_data\":{lunar:{unclickable:true,copyToClipboard:\"lunarclient.com\"}}}}}"); + player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:torch\",Count:1b,components:{\"minecraft:custom_name\":\"OPEN URL\",\"minecraft:custom_data\":{lunar:{unclickable:true,openUrl:\"https://lunarclient.com\"}}}}}"); + player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:book\",Count:1b,components:{\"minecraft:custom_name\":\"SUGGEST COMMAND\",\"minecraft:custom_data\":{lunar:{unclickable:true,suggestCommand:\"/apollo\"}}}}}"); + player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:writable_book\",Count:1b,components:{\"minecraft:custom_name\":\"RUN COMMAND\",\"minecraft:custom_data\":{lunar:{unclickable:true,runCommand:\"/apollo\"}}}}}"); } public void inventoryModuleNMSExample(Player player) { diff --git a/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/PingMarkerExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/PingMarkerExample.java new file mode 100644 index 00000000..6ddbd97b --- /dev/null +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/PingMarkerExample.java @@ -0,0 +1,35 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 Moonsworth + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.lunarclient.apollo.example.module.impl; + +import com.lunarclient.apollo.example.module.ApolloModuleExample; +import org.bukkit.entity.Player; + +public abstract class PingMarkerExample extends ApolloModuleExample { + + // TODO: displayMarkerItemExample + + public abstract void displayMarkerResourceExample(Player player); + +} diff --git a/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/SaturationExample.java b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/SaturationExample.java index c7f61292..705b1b2e 100644 --- a/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/SaturationExample.java +++ b/bukkit-example-common/src/main/java/com/lunarclient/apollo/example/module/impl/SaturationExample.java @@ -44,9 +44,9 @@ public boolean saturationModuleExample(Player player) { } public void saturationModuleCommandExample(Player player) { - player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:apple\",Count:1b,tag:{lunar:{hunger:22,saturation:3}}}}"); - player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:apple\",Count:1b,tag:{lunar:{hunger:7,saturation:7}}}}"); - player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:apple\",Count:1b,tag:{lunar:{hunger:30,saturation:26}}}}"); + player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:apple\",Count:1b,components:{\"minecraft:custom_data\":{lunar:{hunger:22,saturation:3}}}}}"); + player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:apple\",Count:1b,components:{\"minecraft:custom_data\":{lunar:{hunger:7,saturation:7}}}}}"); + player.performCommand("summon item ~ ~1 ~ {Item:{id:\"minecraft:apple\",Count:1b,components:{\"minecraft:custom_data\":{lunar:{hunger:30,saturation:26}}}}}"); } public void saturationModuleNMSExample(Player player) { diff --git a/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/ApolloJsonExamplePlatform.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/ApolloJsonExamplePlatform.java index e5c90754..df7d7eba 100644 --- a/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/ApolloJsonExamplePlatform.java +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/ApolloJsonExamplePlatform.java @@ -41,6 +41,7 @@ import com.lunarclient.apollo.example.json.module.NametagJsonExample; import com.lunarclient.apollo.example.json.module.NickHiderJsonExample; import com.lunarclient.apollo.example.json.module.NotificationJsonExample; +import com.lunarclient.apollo.example.json.module.PingMarkerJsonExample; import com.lunarclient.apollo.example.json.module.RichPresenceJsonExample; import com.lunarclient.apollo.example.json.module.ServerRuleJsonExample; import com.lunarclient.apollo.example.json.module.StaffModJsonExample; @@ -82,6 +83,7 @@ public void registerModuleExamples() { this.setNametagExample(new NametagJsonExample()); this.setNickHiderExample(new NickHiderJsonExample()); this.setNotificationExample(new NotificationJsonExample()); + this.setPingMarkerExample(new PingMarkerJsonExample()); this.setRichPresenceExample(new RichPresenceJsonExample()); this.setServerRuleExample(new ServerRuleJsonExample()); this.setStaffModExample(new StaffModJsonExample()); diff --git a/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/PingMarkerJsonExample.java b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/PingMarkerJsonExample.java new file mode 100644 index 00000000..e5528cd6 --- /dev/null +++ b/bukkit-example-json/src/main/java/com/lunarclient/apollo/example/json/module/PingMarkerJsonExample.java @@ -0,0 +1,54 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 Moonsworth + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.lunarclient.apollo.example.json.module; + +import com.lunarclient.apollo.example.module.impl.PingMarkerExample; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; + +public class PingMarkerJsonExample extends PingMarkerExample { + + @Override + public void displayMarkerResourceExample(Player player) { + Location location = this.findTargetLocation(player); + + if (location == null) { + return; + } + + // TODO + } + + private Location findTargetLocation(Player player) { + Block targetBlock = player.getTargetBlockExact(30); + + if (targetBlock == null) { + return null; + } + + return targetBlock.getLocation().add(0.5D, 0.5D, 0.5D); + } + +} diff --git a/bukkit-example-json/src/main/resources/plugin.yml b/bukkit-example-json/src/main/resources/plugin.yml index ba7d9d64..c015bc3c 100644 --- a/bukkit-example-json/src/main/resources/plugin.yml +++ b/bukkit-example-json/src/main/resources/plugin.yml @@ -41,6 +41,8 @@ commands: description: "Nick Hider!" notification: description: "Notifications!" + pingmarker: + description: "Ping Marker!" richpresence: description: "Rich Presence!" saturation: diff --git a/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/ApolloProtoExamplePlatform.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/ApolloProtoExamplePlatform.java index 97074a1b..951691f3 100644 --- a/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/ApolloProtoExamplePlatform.java +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/ApolloProtoExamplePlatform.java @@ -41,6 +41,7 @@ import com.lunarclient.apollo.example.proto.module.NametagProtoExample; import com.lunarclient.apollo.example.proto.module.NickHiderProtoExample; import com.lunarclient.apollo.example.proto.module.NotificationProtoExample; +import com.lunarclient.apollo.example.proto.module.PingMarkerProtoExample; import com.lunarclient.apollo.example.proto.module.RichPresenceProtoExample; import com.lunarclient.apollo.example.proto.module.ServerRuleProtoExample; import com.lunarclient.apollo.example.proto.module.StaffModProtoExample; @@ -82,6 +83,7 @@ public void registerModuleExamples() { this.setNametagExample(new NametagProtoExample()); this.setNickHiderExample(new NickHiderProtoExample()); this.setNotificationExample(new NotificationProtoExample()); + this.setPingMarkerExample(new PingMarkerProtoExample()); this.setRichPresenceExample(new RichPresenceProtoExample()); this.setServerRuleExample(new ServerRuleProtoExample()); this.setStaffModExample(new StaffModProtoExample()); diff --git a/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/PingMarkerProtoExample.java b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/PingMarkerProtoExample.java new file mode 100644 index 00000000..a0ff0d99 --- /dev/null +++ b/bukkit-example-proto/src/main/java/com/lunarclient/apollo/example/proto/module/PingMarkerProtoExample.java @@ -0,0 +1,54 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 Moonsworth + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.lunarclient.apollo.example.proto.module; + +import com.lunarclient.apollo.example.module.impl.PingMarkerExample; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; + +public class PingMarkerProtoExample extends PingMarkerExample { + + @Override + public void displayMarkerResourceExample(Player player) { + Location location = this.findTargetLocation(player); + + if (location == null) { + return; + } + + // TODO + } + + private Location findTargetLocation(Player player) { + Block targetBlock = player.getTargetBlockExact(30); + + if (targetBlock == null) { + return null; + } + + return targetBlock.getLocation().add(0.5D, 0.5D, 0.5D); + } + +} diff --git a/bukkit-example-proto/src/main/resources/plugin.yml b/bukkit-example-proto/src/main/resources/plugin.yml index 0ccac43d..79ab284f 100644 --- a/bukkit-example-proto/src/main/resources/plugin.yml +++ b/bukkit-example-proto/src/main/resources/plugin.yml @@ -41,6 +41,8 @@ commands: description: "Nick Hider!" notification: description: "Notifications!" + pingmarker: + description: "Ping Marker!" richpresence: description: "Rich Presence!" saturation: diff --git a/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java b/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java index 117e952d..946b89aa 100644 --- a/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java +++ b/bukkit/src/main/java/com/lunarclient/apollo/ApolloBukkitPlatform.java @@ -60,6 +60,8 @@ import com.lunarclient.apollo.module.notification.NotificationModuleImpl; import com.lunarclient.apollo.module.packetenrichment.PacketEnrichmentImpl; import com.lunarclient.apollo.module.packetenrichment.PacketEnrichmentModule; +import com.lunarclient.apollo.module.pingmarker.PingMarkerModule; +import com.lunarclient.apollo.module.pingmarker.PingMarkerModuleImpl; import com.lunarclient.apollo.module.richpresence.RichPresenceModule; import com.lunarclient.apollo.module.richpresence.RichPresenceModuleImpl; import com.lunarclient.apollo.module.saturation.SaturationModule; @@ -142,6 +144,7 @@ public void onEnable() { .addModule(NickHiderModule.class, new NickHiderModuleImpl()) .addModule(NotificationModule.class, new NotificationModuleImpl()) .addModule(PacketEnrichmentModule.class, new PacketEnrichmentImpl()) + .addModule(PingMarkerModule.class, new PingMarkerModuleImpl()) .addModule(RichPresenceModule.class, new RichPresenceModuleImpl()) .addModule(SaturationModule.class) .addModule(ServerRuleModule.class) diff --git a/common/src/main/java/com/lunarclient/apollo/module/glow/GlowModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/glow/GlowModuleImpl.java index cc832417..e74d9486 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/glow/GlowModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/glow/GlowModuleImpl.java @@ -32,6 +32,7 @@ import java.awt.Color; import java.util.UUID; import lombok.NonNull; +import org.jetbrains.annotations.Nullable; /** * Provides the glow module. @@ -41,12 +42,20 @@ public final class GlowModuleImpl extends GlowModule { @Override - public void overrideGlow(@NonNull Recipients recipients, @NonNull UUID glowingPlayer, @NonNull Color color) { - OverrideGlowEffectMessage message = OverrideGlowEffectMessage.newBuilder() - .setPlayerUuid(NetworkTypes.toProtobuf(glowingPlayer)) - .setColor(NetworkTypes.toProtobuf(color)) - .build(); + public void overrideGlow(@NonNull Recipients recipients, @NonNull UUID glowingPlayer) { + this.overrideGlow(recipients, glowingPlayer, null); + } + + @Override + public void overrideGlow(@NonNull Recipients recipients, @NonNull UUID glowingPlayer, @Nullable Color color) { + OverrideGlowEffectMessage.Builder builder = OverrideGlowEffectMessage.newBuilder() + .setPlayerUuid(NetworkTypes.toProtobuf(glowingPlayer)); + + if (color != null) { + builder.setColor(NetworkTypes.toProtobuf(color)); + } + OverrideGlowEffectMessage message = builder.build(); recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); } diff --git a/common/src/main/java/com/lunarclient/apollo/module/pingmarker/PingMarkerModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/pingmarker/PingMarkerModuleImpl.java new file mode 100644 index 00000000..cbe36a93 --- /dev/null +++ b/common/src/main/java/com/lunarclient/apollo/module/pingmarker/PingMarkerModuleImpl.java @@ -0,0 +1,161 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2023 Moonsworth + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.lunarclient.apollo.module.pingmarker; + +import com.lunarclient.apollo.event.ApolloReceivePacketEvent; +import com.lunarclient.apollo.event.EventBus; +import com.lunarclient.apollo.event.pingmarker.ApolloPlayerRequestMarkerEvent; +import com.lunarclient.apollo.network.NetworkTypes; +import com.lunarclient.apollo.pingmarker.v1.DisplayPlayerPingMessage; +import com.lunarclient.apollo.pingmarker.v1.RemovePingMarkerTypeMessage; +import com.lunarclient.apollo.pingmarker.v1.RemovePlayerPingMessage; +import com.lunarclient.apollo.pingmarker.v1.RequestPlayerPingMessage; +import com.lunarclient.apollo.pingmarker.v1.ResetPingMarkerTypesMessage; +import com.lunarclient.apollo.pingmarker.v1.ResetPlayerPingMessage; +import com.lunarclient.apollo.pingmarker.v1.SetPingMarkerTypeMessage; +import com.lunarclient.apollo.player.AbstractApolloPlayer; +import com.lunarclient.apollo.recipients.Recipients; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; +import lombok.NonNull; + +/** + * Provides the ping marker module. + * + * @since 1.1.9 + */ +public final class PingMarkerModuleImpl extends PingMarkerModule { + + private final Map markerTypes = new ConcurrentHashMap<>(); + + /** + * Creates a new instance of {@link PingMarkerModuleImpl}. + * + * @since 1.1.9 + */ + public PingMarkerModuleImpl() { + super(); + + this.handle(ApolloReceivePacketEvent.class, this::onReceivePacket); + } + + @Override + public void setMarkerType(@NonNull Recipients recipients, @NonNull PingMarkerType type) { + SetPingMarkerTypeMessage message = SetPingMarkerTypeMessage.newBuilder() + .setId(type.getName()) + .setIcon(NetworkTypes.toProtobuf(type.getIcon())) + .build(); + + this.markerTypes.put(type.getName(), type); + + recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + } + + @Override + public void removeMarkerType(@NonNull Recipients recipients, @NonNull PingMarkerType type) { + this.removeMarkerType(recipients, type.getName()); + } + + @Override + public void removeMarkerType(@NonNull Recipients recipients, @NonNull String name) { + RemovePingMarkerTypeMessage message = RemovePingMarkerTypeMessage.newBuilder() + .setId(name) + .build(); + + this.markerTypes.remove(name); + + recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + } + + @Override + public void resetMarkerType(@NonNull Recipients recipients) { + ResetPingMarkerTypesMessage message = ResetPingMarkerTypesMessage.getDefaultInstance(); + + this.markerTypes.clear(); + + recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + } + + @Override + public void displayMarker(@NonNull Recipients recipients, @NonNull PingMarker marker) { + PingMarkerType type = marker.getType(); + + DisplayPlayerPingMessage.Builder messageBuilder = DisplayPlayerPingMessage.newBuilder() + .setId(NetworkTypes.toProtobuf(marker.getId())) + .setLocation(NetworkTypes.toProtobuf(marker.getLocation())) + .setColor(NetworkTypes.toProtobuf(marker.getColor())) + .setIcon(NetworkTypes.toProtobuf(marker.getIcon())) + .setDuration(NetworkTypes.toProtobuf(marker.getDuration())) + .setFocus(marker.isFocus()); + + if (type != null) { + messageBuilder.setType(type.getName()); + } + + recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(messageBuilder.build())); + } + + @Override + public void removeMarker(@NonNull Recipients recipients, @NonNull PingMarker marker) { + this.removeMarker(recipients, marker.getId()); + } + + @Override + public void removeMarker(@NonNull Recipients recipients, @NonNull UUID markerId) { + RemovePlayerPingMessage message = RemovePlayerPingMessage.newBuilder() + .setId(NetworkTypes.toProtobuf(markerId)) + .build(); + + recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + } + + @Override + public void resetMarkers(@NonNull Recipients recipients) { + ResetPlayerPingMessage message = ResetPlayerPingMessage.getDefaultInstance(); + recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message)); + } + + private void onReceivePacket(ApolloReceivePacketEvent event) { + event.unpack(RequestPlayerPingMessage.class).ifPresent(packet -> { + ApolloPlayerRequestMarkerEvent playerRequestPingEvent = new ApolloPlayerRequestMarkerEvent( + event.getPlayer(), + this.markerTypes.get(packet.getType()), + NetworkTypes.fromProtobuf(packet.getSourceLocation()), + NetworkTypes.fromProtobuf(packet.getTargetLocation()) + ); + + EventBus.EventResult result = EventBus.getBus().post(playerRequestPingEvent); + + if (!result.getEvent().isCancelled()) { + // TODO + } + + for (Throwable throwable : result.getThrowing()) { + throwable.printStackTrace(); + } + }); + } + +} diff --git a/docs/developers/lightweight/protobuf/getting-started.mdx b/docs/developers/lightweight/protobuf/getting-started.mdx index c06832c9..3330c63c 100644 --- a/docs/developers/lightweight/protobuf/getting-started.mdx +++ b/docs/developers/lightweight/protobuf/getting-started.mdx @@ -26,7 +26,7 @@ Available fields for each message, including their types, are available on the B com.lunarclient apollo-protos - 1.0-SNAPSHOT + 0.0.2 ``` @@ -41,7 +41,7 @@ Available fields for each message, including their types, are available on the B } dependencies { - api 'com.lunarclient:apollo-protos:1.0-SNAPSHOT' + api 'com.lunarclient:apollo-protos:0.0.2' } ``` @@ -55,7 +55,7 @@ Available fields for each message, including their types, are available on the B } dependencies { - api("com.lunarclient:apollo-protos:1.0-SNAPSHOT") + api("com.lunarclient:apollo-protos:0.0.2") } ``` diff --git a/docs/developers/modules/_meta.json b/docs/developers/modules/_meta.json index 1ee0d74d..7784f20f 100644 --- a/docs/developers/modules/_meta.json +++ b/docs/developers/modules/_meta.json @@ -17,6 +17,7 @@ "nickhider": "Nick Hider", "notification": "Notification", "packetenrichment": "Packet Enrichment", + "pingmarker": "Ping Marker", "richpresence": "Rich Presence", "saturation": "Saturation", "serverrule": "Server Rule", diff --git a/docs/developers/modules/glint.mdx b/docs/developers/modules/glint.mdx index a1af4cfb..eb60f50c 100644 --- a/docs/developers/modules/glint.mdx +++ b/docs/developers/modules/glint.mdx @@ -39,15 +39,15 @@ Explore each integration by cycling through each tab, to find the best fit for y **Custom Glint** -`/summon item ~ ~1 ~ {Item:{id:"minecraft:diamond_helmet",Count:1b,tag:{lunar:{glint:"#FF5733"}}}}` +`/summon item ~ ~1 ~ {Item:{id:"minecraft:diamond_helmet",Count:1b,components:{"minecraft:custom_data":{lunar:{glint:"#FF5733"}}}}}` -`/summon item ~ ~1 ~ {Item:{id:"minecraft:diamond_helmet",Count:1b,tag:{lunar:{glint:"#33FF57"}}}}` +`/summon item ~ ~1 ~ {Item:{id:"minecraft:diamond_helmet",Count:1b,components:{"minecraft:custom_data":{lunar:{glint:"#33FF57"}}}}}` -`/summon item ~ ~1 ~ {Item:{id:"minecraft:diamond_helmet",Count:1b,tag:{lunar:{glint:"#3357FF"}}}}` +`/summon item ~ ~1 ~ {Item:{id:"minecraft:diamond_helmet",Count:1b,components:{"minecraft:custom_data":{lunar:{glint:"#3357FF"}}}}}` -`/summon item ~ ~1 ~ {Item:{id:"minecraft:diamond_helmet",Count:1b,tag:{lunar:{glint:"#FFD700"}}}}` +`/summon item ~ ~1 ~ {Item:{id:"minecraft:diamond_helmet",Count:1b,components:{"minecraft:custom_data":{lunar:{glint:"#FFD700"}}}}}` -`/summon item ~ ~1 ~ {Item:{id:"minecraft:diamond_helmet",Count:1b,tag:{lunar:{glint:"-16711936"}}}}` +`/summon item ~ ~1 ~ {Item:{id:"minecraft:diamond_helmet",Count:1b,components:{"minecraft:custom_data":{lunar:{glint:"-16711936"}}}}}` diff --git a/docs/developers/modules/glow.mdx b/docs/developers/modules/glow.mdx index ec71a80f..c9d9dc7c 100644 --- a/docs/developers/modules/glow.mdx +++ b/docs/developers/modules/glow.mdx @@ -23,6 +23,10 @@ The glow module allows you to take advantage of the vanilla Minecraft Glow Effec ## Integration + + If no color is specified, the glow effect will default to the player's scoreboard team color. + + ### Sample Code Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. @@ -65,6 +69,7 @@ public void resetGlowEffectsExample(Player viewer) { 2. `UUID target` - The player or living entity you want to display the glow effect on. 3. `Color glowColor` + - If `null` is passed (or if no color is specified), the glow effect will default to the target's scoreboard team color. - How you'll dictate the color of the glow effect, see the [colors page](/apollo/developers/utilities/colors) for more. diff --git a/docs/developers/modules/inventory.mdx b/docs/developers/modules/inventory.mdx index 1cbfd74b..10c51b00 100644 --- a/docs/developers/modules/inventory.mdx +++ b/docs/developers/modules/inventory.mdx @@ -28,23 +28,23 @@ Explore each integration by cycling through each tab, to find the best fit for y **Unclickable Item** -`/summon item ~ ~1 ~ {Item:{id:"minecraft:stone",Count:1b,tag:{display:{Name:"§c§lUNCLICKABLE"},lunar:{unclickable:true}}}}` +`/summon item ~ ~1 ~ {Item:{id:"minecraft:stone",Count:1b,components:{"minecraft:custom_name":"UNCLICKABLE","minecraft:custom_data":{lunar:{unclickable:true}}}}}` **Copy To Clipboard Item** -`/summon item ~ ~1 ~ {Item:{id:"minecraft:paper",Count:1b,tag:{display:{Name:"§9§lCOPY TO CLIPBOARD"},lunar:{unclickable:true,copyToClipboard:"lunarclient.com"}}}}` +`/summon item ~ ~1 ~ {Item:{id:"minecraft:paper",Count:1b,components:{"minecraft:custom_name":"COPY TO CLIPBOARD","minecraft:custom_data":{lunar:{unclickable:true,copyToClipboard:"lunarclient.com"}}}}}` **Open URL Item** -`/summon item ~ ~1 ~ {Item:{id:"minecraft:torch",Count:1b,tag:{display:{Name:"§6§lOPEN URL"},lunar:{unclickable:true,openUrl:"https://lunarclient.com"}}}}` +`/summon item ~ ~1 ~ {Item:{id:"minecraft:torch",Count:1b,components:{"minecraft:custom_name":"OPEN URL","minecraft:custom_data":{lunar:{unclickable:true,openUrl:"https://lunarclient.com"}}}}}` **Suggest Command Item** -`/summon item ~ ~1 ~ {Item:{id:"minecraft:book",Count:1b,tag:{display:{Name:"§2§lSUGGEST COMMAND"},lunar:{unclickable:true,suggestCommand:"/apollo"}}}}` +`/summon item ~ ~1 ~ {Item:{id:"minecraft:book",Count:1b,components:{"minecraft:custom_name":"SUGGEST COMMAND","minecraft:custom_data":{lunar:{unclickable:true,suggestCommand:"/apollo"}}}}}` **Run Command Item** -`/summon item ~ ~1 ~ {Item:{id:"minecraft:writable_book",Count:1b,tag:{display:{Name:"§d§lRUN COMMAND"},lunar:{unclickable:true,runCommand:"/apollo"}}}}` +`/summon item ~ ~1 ~ {Item:{id:"minecraft:writable_book",Count:1b,components:{"minecraft:custom_name":"RUN COMMAND","minecraft:custom_data":{lunar:{unclickable:true,runCommand:"/apollo"}}}}}` diff --git a/docs/developers/modules/pingmarker.mdx b/docs/developers/modules/pingmarker.mdx new file mode 100644 index 00000000..b8dc3cbe --- /dev/null +++ b/docs/developers/modules/pingmarker.mdx @@ -0,0 +1,88 @@ +import { Tab, Tabs } from 'nextra-theme-docs' +import { Callout } from 'nextra-theme-docs' + +# Ping Marker Module + +## Overview + +TODO + +![Ping Marker Module Example](https://i.imgur.com) + +## Integration + +### Sample Code +Explore each integration by cycling through each tab, to find the best fit for your requirements and needs. + + + + + +### Display a Ping Marker with a resource + +```java +public void displayMarkerResourceExample(Player player) { + Optional apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(player.getUniqueId()); + + apolloPlayerOpt.ifPresent(apolloPlayer -> { + Location location = this.findTargetLocation(player); + + if (location == null) { + return; + } + + this.pingMarkerModule.displayMarker(Recipients.ofWorld(apolloPlayer), PingMarker.builder() + .id(UUID.randomUUID()) + .type(null) + .location(BukkitApollo.toApolloLocation(location)) + .color(Color.WHITE) + .icon(SimpleResourceLocationIcon.builder() + .resourceLocation("lunar:icons/fluent-black-circle-icon.svg") + .size(12) + .build() + ) + .duration(Duration.ofSeconds(5)) + .focus(true) + .build()); + }); + +} + +private Location findTargetLocation(Player player) { + Block targetBlock = player.getTargetBlockExact(30); + + if (targetBlock == null) { + return null; + } + + return targetBlock.getLocation().add(0.5D, 0.5D, 0.5D); +} +``` + +### `PingMarkerType` Options + +### `PingMarker` Options + + + + + +### Display a Ping Marker with a resource + +```java + +``` + + + + + +### Display a Ping Marker with a resource + +```java + +``` + + + + diff --git a/docs/developers/modules/saturation.mdx b/docs/developers/modules/saturation.mdx index 40e3ccf9..af52e661 100644 --- a/docs/developers/modules/saturation.mdx +++ b/docs/developers/modules/saturation.mdx @@ -40,11 +40,11 @@ Explore each integration by cycling through each tab, to find the best fit for y **Custom Saturation & Hunger** -`/summon item ~ ~1 ~ {Item:{id:"minecraft:apple",Count:1b,tag:{lunar:{hunger:22,saturation:3}}}}` +`/summon item ~ ~1 ~ {Item:{id:"minecraft:apple",Count:1b,components:{"minecraft:custom_data":{lunar:{hunger:22,saturation:3}}}}}` -`/summon item ~ ~1 ~ {Item:{id:"minecraft:apple",Count:1b,tag:{lunar:{hunger:7,saturation:7}}}}` +`/summon item ~ ~1 ~ {Item:{id:"minecraft:apple",Count:1b,components:{"minecraft:custom_data":{lunar:{hunger:7,saturation:7}}}}}` -`/summon item ~ ~1 ~ {Item:{id:"minecraft:apple",Count:1b,tag:{lunar:{hunger:30,saturation:26}}}}` +`/summon item ~ ~1 ~ {Item:{id:"minecraft:apple",Count:1b,components:{"minecraft:custom_data":{lunar:{hunger:30,saturation:26}}}}}` diff --git a/folia/src/main/java/com/lunarclient/apollo/ApolloFoliaPlatform.java b/folia/src/main/java/com/lunarclient/apollo/ApolloFoliaPlatform.java index f0341a7c..5d11c97a 100644 --- a/folia/src/main/java/com/lunarclient/apollo/ApolloFoliaPlatform.java +++ b/folia/src/main/java/com/lunarclient/apollo/ApolloFoliaPlatform.java @@ -57,6 +57,8 @@ import com.lunarclient.apollo.module.notification.NotificationModuleImpl; import com.lunarclient.apollo.module.packetenrichment.PacketEnrichmentImpl; import com.lunarclient.apollo.module.packetenrichment.PacketEnrichmentModule; +import com.lunarclient.apollo.module.pingmarker.PingMarkerModule; +import com.lunarclient.apollo.module.pingmarker.PingMarkerModuleImpl; import com.lunarclient.apollo.module.richpresence.RichPresenceModule; import com.lunarclient.apollo.module.richpresence.RichPresenceModuleImpl; import com.lunarclient.apollo.module.serverrule.ServerRuleModule; @@ -130,6 +132,7 @@ public void onEnable() { .addModule(NickHiderModule.class, new NickHiderModuleImpl()) .addModule(NotificationModule.class, new NotificationModuleImpl()) .addModule(PacketEnrichmentModule.class, new PacketEnrichmentImpl()) + .addModule(PingMarkerModule.class, new PingMarkerModuleImpl()) .addModule(RichPresenceModule.class, new RichPresenceModuleImpl()) .addModule(ServerRuleModule.class) .addModule(StaffModModule.class, new StaffModModuleImpl()) diff --git a/gradle.properties b/gradle.properties index e00f89ab..105b3394 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=com.lunarclient -version=1.1.8 +version=1.1.9-SNAPSHOT description=The API for interacting with Lunar Client players. org.gradle.parallel=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4ac0dc24..60742f48 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,7 +11,7 @@ geantyref = "1.3.11" idea = "1.1.7" jetbrains = "24.0.1" lombok = "1.18.38" -protobuf = "1.0-SNAPSHOT" +protobuf = "0.0.2" gson = "2.10.1" shadow = "8.1.1" spotless = "6.13.0" diff --git a/scripts/deploy.sh b/scripts/deploy.sh index e78c0132..cb44b3e2 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -1,7 +1,7 @@ #!/bin/bash set -eo pipefail -VERSION="1.1.8" +VERSION="1.1.9-SNAPSHOT" REMOTE_USER="ubuntu" REMOTE_HOST="147.135.8.94" diff --git a/settings.gradle.kts b/settings.gradle.kts index 9a815b02..7aa5d2a4 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -19,7 +19,7 @@ dependencyResolutionManagement { repositories { maven("https://repo.papermc.io/repository/maven-public/") maven("https://oss.sonatype.org/content/repositories/snapshots") - maven("https://us-maven.pkg.dev/moonsworth-299m4oir/maven-public") + maven("https://us-maven.pkg.dev/mw-lunarclient-maven-repo/public") mavenCentral() mavenLocal() }