1.7.0 rc2 (1.19.3 datawater fix)

This commit is contained in:
Tyler Murphy 2023-01-24 11:50:01 -05:00
parent 6b453dde97
commit 0ea945d84e
12 changed files with 88 additions and 169 deletions

View file

@ -1,33 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug report
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**System Info (please complete the following information):**
- OS: [e.g. Windows/Linux]
- Server Host [e.g. Apex/Custom]
- MC Version [e.g. 1.17/1.18]
- Plugin Version [e.g. 1.3.0/1.3.1 BETA]
**Additional context**
Add any other context about the problem here.

View file

@ -1,20 +0,0 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: new plugin feature
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

View file

@ -1,11 +0,0 @@
**Describe the change**
A clear and concise description of what the changes are.
**Expected behavior**
A clear and concise description of what your changes are going to do.
**Screenshots**
If applicable, add screenshots to help explain your changes.
**Additional context**
Add any other context about the pull request here.

View file

@ -1,37 +0,0 @@
name: Beta
on:
push:
branches-ignore: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: |
mvn -B package --file pom.xml
mkdir staging && cp target/*.jar staging
- name: Set up a cache for maven
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: artifacts-beta
path: staging

View file

@ -1,37 +0,0 @@
name: Release
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: |
mvn -B package --file pom.xml
mkdir staging && cp target/*.jar staging
- name: Set up a cache for maven
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Upload artificats
uses: actions/upload-artifact@v2
with:
name: artifacts-release
path: staging

BIN
lib/ProtocolLib.jar Normal file

Binary file not shown.

14
pom.xml
View file

@ -80,10 +80,10 @@
<id>spigot-repo</id> <id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/public/</url> <url>https://hub.spigotmc.org/nexus/content/repositories/public/</url>
</repository> </repository>
<repository> <!-- <repository>-->
<id>dmulloy2-repo</id> <!-- <id>dmulloy2-repo</id>-->
<url>https://repo.dmulloy2.net/repository/public/</url> <!-- <url>https://repo.dmulloy2.net/repository/public/</url>-->
</repository> <!-- </repository>-->
<repository> <repository>
<id>placeholderapi</id> <id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url> <url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
@ -106,9 +106,9 @@
<dependency> <dependency>
<groupId>com.comphenix.protocol</groupId> <groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId> <artifactId>ProtocolLib</artifactId>
<version>4.4.0</version> <version>4.8.0</version>
<!-- <scope>system</scope>--> <scope>system</scope>
<!-- <systemPath>${project.basedir}/lib/ProtocolLib.jar</systemPath>--> <systemPath>${project.basedir}/lib/ProtocolLib.jar</systemPath>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.xerial</groupId> <groupId>org.xerial</groupId>

View file

@ -17,6 +17,7 @@ public class Disguiser {
public Disguiser(){ public Disguiser(){
this.disguises = new HashMap<>(); this.disguises = new HashMap<>();
} }
public Disguise getDisguise(Player player){ public Disguise getDisguise(Player player){

View file

@ -235,11 +235,7 @@ public class EntityHider implements Listener {
destroyEntity.getIntegerArrays().write(0, new int[]{entity.getEntityId()}); destroyEntity.getIntegerArrays().write(0, new int[]{entity.getEntityId()});
} catch (Exception e){ return false; } } catch (Exception e){ return false; }
// Make the entity disappear // Make the entity disappear
try { manager.sendServerPacket(observer, destroyEntity);
manager.sendServerPacket(observer, destroyEntity);
} catch (InvocationTargetException e) {
throw new RuntimeException("Cannot send server packet.", e);
}
} }
return visibleBefore; return visibleBefore;
} }

View file

@ -6,6 +6,7 @@ import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.WrappedDataWatcher; import com.comphenix.protocol.wrappers.WrappedDataWatcher;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.util.packet.EntityMetadataPacket;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@ -64,22 +65,13 @@ public class Glow {
} }
public void setGlow(Player player, Player target, boolean glowing) { public void setGlow(Player player, Player target, boolean glowing) {
PacketContainer packet = protocolManager.createPacket(PacketType.Play.Server.ENTITY_METADATA);
packet.getIntegers().write(0, target.getEntityId()); EntityMetadataPacket packet = new EntityMetadataPacket();
WrappedDataWatcher watcher = new WrappedDataWatcher(); packet.setEntity(target);
WrappedDataWatcher.Serializer serializer = WrappedDataWatcher.Registry.get(Byte.class); packet.setGlow(glowing);
watcher.setEntity(target); packet.writeMetadata();
if (glowing) { packet.send(player);
watcher.setObject(0, serializer, (byte) (0x40));
} else {
watcher.setObject(0, serializer, (byte) (0x0));
}
packet.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects());
try {
protocolManager.sendServerPacket(player, packet);
} catch (InvocationTargetException e) {
e.printStackTrace();
}
} }
} }

View file

@ -23,9 +23,7 @@ public class AbstractPacket {
} }
public void send(Player player){ public void send(Player player){
try { protocolManager.sendServerPacket(player, packet);
protocolManager.sendServerPacket(player, packet);
} catch (InvocationTargetException ignored) {}
} }
} }

View file

@ -0,0 +1,70 @@
package net.tylermurphy.hideAndSeek.util.packet;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.wrappers.WrappedDataValue;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
import org.bukkit.entity.Entity;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
public class EntityMetadataPacket extends AbstractPacket {
private final WrappedDataWatcher watcher;
private final WrappedDataWatcher.Serializer serializer;
public EntityMetadataPacket(){
super(PacketType.Play.Server.ENTITY_METADATA);
watcher = new WrappedDataWatcher();
serializer = WrappedDataWatcher.Registry.get(Byte.class);
}
public void setEntity(@NotNull Entity target){
super.packet.getIntegers().write(0, target.getEntityId());
watcher.setEntity(target);
}
public void setGlow(boolean glowing){
if (glowing) {
watcher.setObject(0, serializer, (byte) (0x40));
} else {
watcher.setObject(0, serializer, (byte) (0x0));
}
}
public void writeMetadata() {
// thank you to
// https://www.spigotmc.org/threads/unable-to-modify-entity-metadata-packet-using-protocollib-1-19-3.582442/
try {
// 1.19.3 And Up
Class.forName("com.comphenix.protocol.wrappers.WrappedDataValue");
final List<WrappedDataValue> wrappedDataValueList = new ArrayList<>();
for(final WrappedWatchableObject entry : watcher.getWatchableObjects()) {
if(entry == null) continue;
final WrappedDataWatcher.WrappedDataWatcherObject watcherObject = entry.getWatcherObject();
wrappedDataValueList.add(
new WrappedDataValue(
watcherObject.getIndex(),
watcherObject.getSerializer(),
entry.getRawValue()
)
);
}
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
} catch (ClassCastException | ClassNotFoundException ignored) {
// 1.9 to 1.19.2 And Up
packet.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects());
}
}
}