Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for PacketEvents and 1.21.1 Support #138

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,18 @@
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>codemc-releases</id>
<url>https://repo.codemc.io/repository/maven-releases/</url>
</repository>
</repositories>

<dependencies>
<!-- https://hub.spigotmc.org/nexus/content/groups/public/org/spigotmc/spigot-api/ -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.6-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

<!-- https://jitpack.io/com/github/dmulloy2/ProtocolLib/ -->
<dependency>
<groupId>com.github.dmulloy2</groupId>
<artifactId>ProtocolLib</artifactId>
<version>1e3fa2d36e</version>
<version>1.21.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

Expand Down Expand Up @@ -124,6 +120,14 @@
<version>24.1.0</version>
<scope>provided</scope>
</dependency>

<!-- https://docs.packetevents.com/getting-started -->
<dependency>
<groupId>com.github.retrooper</groupId>
<artifactId>packetevents-spigot</artifactId>
<version>2.5.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/io/josemmo/bukkit/plugin/YamipaPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ public void onEnable() {
scheduler = Executors.newScheduledThreadPool(6);

// Warm-up plugin dependencies
LOGGER.fine("Waiting for ProtocolLib to be ready...");
scheduler.execute(() -> {
FakeEntity.waitForProtocolLib();
LOGGER.fine("ProtocolLib is now ready");
});
LOGGER.fine("Triggered map color cache warm-up");
FakeMap.pixelToIndex(Color.RED.getRGB()); // Ask for a color index to force cache generation

Expand All @@ -140,12 +135,15 @@ public void onEnable() {
if (number >= 10) return "10-49";
return "0-9";
};
/*
metrics = new Metrics(this, BSTATS_PLUGIN_ID);
metrics.addCustomChart(new SimplePie("animate_images", () -> animateImages ? "true" : "false"));
metrics.addCustomChart(new SimplePie("number_of_image_files", () -> toStats.apply(storage.size())));
metrics.addCustomChart(new SimplePie("number_of_placed_images", () -> toStats.apply(renderer.size())));
*/
}


@Override
public void onDisable() {
// Stop metrics
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package io.josemmo.bukkit.plugin.packets;

import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
import com.github.retrooper.packetevents.protocol.entity.data.EntityMetadataProvider;
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import io.github.retrooper.packetevents.util.SpigotConversionUtil;
import io.josemmo.bukkit.plugin.utils.Internals;
import org.bukkit.Rotation;
import org.bukkit.inventory.ItemStack;

import java.util.ArrayList;
import java.util.List;

public class FakeImageEntityMetadataProvider implements EntityMetadataProvider {

private final boolean invisible;
private final ItemStack display;
private final Rotation rotation;

public FakeImageEntityMetadataProvider(boolean invisible, ItemStack display, Rotation rotation) {
this.invisible = invisible;
this.display = display;
this.rotation = rotation;
}

@Override
public List<EntityData> entityData(ClientVersion clientVersion) {
int itemIndex = (clientVersion.isOlderThan(ClientVersion.V_1_17)) ? 7 : 8;
int rotationIndex = itemIndex + 1;

List<EntityData> data = new ArrayList<EntityData>();

// Invisible
byte invisibleFlags = (byte) (invisible ? 0x20 : 0x00);
EntityData invisData = new EntityData(0, EntityDataTypes.BYTE, invisibleFlags);
data.add(invisData);

// Item
EntityData itemData = new EntityData(itemIndex, EntityDataTypes.ITEMSTACK, SpigotConversionUtil.fromBukkitItemStack(display));
data.add(itemData);

// Rotation
EntityData rotationData = new EntityData(rotationIndex, EntityDataTypes.INT, rotation.ordinal());
data.add(rotationData);
return data;
}

}
73 changes: 0 additions & 73 deletions src/main/java/io/josemmo/bukkit/plugin/packets/MapDataPacket.java

This file was deleted.

Loading