mirror of
https://github.com/GeyserExtensionists/GeyserUtils.git
synced 2025-12-19 15:09:24 +00:00
clean up
This commit is contained in:
@@ -13,12 +13,9 @@ import java.awt.*;
|
||||
@Setter
|
||||
public class CustomEntityDataPacket extends CustomPayloadPacket {
|
||||
private int entityId;
|
||||
|
||||
private Float height;
|
||||
private Float width;
|
||||
|
||||
private Float scale;
|
||||
|
||||
private Integer color;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package me.zimzaza4.geyserutils.common.packet;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class UpdateEntityScorePacket extends CustomPayloadPacket {
|
||||
private int entityId;
|
||||
private String objective;
|
||||
private int score;
|
||||
}
|
||||
@@ -18,12 +18,10 @@ import me.zimzaza4.geyserutils.geyser.form.NpcDialogueForms;
|
||||
import me.zimzaza4.geyserutils.geyser.form.element.Button;
|
||||
import me.zimzaza4.geyserutils.geyser.mappings.ItemParticlesMappings;
|
||||
import me.zimzaza4.geyserutils.geyser.replace.JavaAddEntityTranslatorReplace;
|
||||
import me.zimzaza4.geyserutils.geyser.scoreboard.EntityScoreboard;
|
||||
import me.zimzaza4.geyserutils.geyser.translator.NPCFormResponseTranslator;
|
||||
import me.zimzaza4.geyserutils.geyser.util.Converter;
|
||||
import me.zimzaza4.geyserutils.geyser.util.DeltaUtils;
|
||||
import me.zimzaza4.geyserutils.geyser.util.ReflectionUtils;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.nbt.NbtMap;
|
||||
import org.cloudburstmc.nbt.NbtType;
|
||||
@@ -66,7 +64,6 @@ import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.Clien
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
@@ -74,7 +71,6 @@ import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
public class GeyserUtils implements Extension {
|
||||
@@ -92,9 +88,6 @@ public class GeyserUtils implements Extension {
|
||||
@Getter
|
||||
public static Map<GeyserConnection, Cache<Integer, String>> CUSTOM_ENTITIES = new ConcurrentHashMap<>();
|
||||
|
||||
@Getter
|
||||
public static Map<GeyserConnection, EntityScoreboard> scoreboards = new ConcurrentHashMap<>();
|
||||
|
||||
public static ItemParticlesMappings particlesMappings = new ItemParticlesMappings();
|
||||
static Cape EMPTY_CAPE = new Cape("", "no-cape", new byte[0], true);
|
||||
|
||||
@@ -117,11 +110,7 @@ public class GeyserUtils implements Extension {
|
||||
CameraPreset.load();
|
||||
|
||||
replaceTranslator();
|
||||
LOADED_ENTITY_DEFINITIONS
|
||||
.forEach((s, entityDefinition) -> {
|
||||
logger().info("DEF ENTITY:" + s);
|
||||
});
|
||||
|
||||
logger().info("Defined " + LOADED_ENTITY_DEFINITIONS.size() + " entities");
|
||||
particlesMappings.read(dataFolder().resolve("item_particles_mappings.json"));
|
||||
}
|
||||
|
||||
@@ -504,19 +493,6 @@ public class GeyserUtils implements Extension {
|
||||
}
|
||||
|
||||
|
||||
} else if (customPacket instanceof CustomEntityPacket customEntityPacket) {
|
||||
if (!LOADED_ENTITY_DEFINITIONS.containsKey(customEntityPacket.getIdentifier())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Cache<Integer, String> cache = CUSTOM_ENTITIES.get(session);
|
||||
cache.put(customEntityPacket.getEntityId(), customEntityPacket.getIdentifier());
|
||||
} else if (customPacket instanceof UpdateEntityScorePacket updateEntityScorePacket) {
|
||||
EntityScoreboard scoreboard = scoreboards.computeIfAbsent(session, k -> new EntityScoreboard(session));
|
||||
Entity entity = (session.getEntityCache().getEntityByJavaId(updateEntityScorePacket.getEntityId()));
|
||||
if (entity != null) {
|
||||
scoreboard.updateScore(updateEntityScorePacket.getObjective(), entity.getGeyserId(), updateEntityScorePacket.getScore());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
package me.zimzaza4.geyserutils.geyser.scoreboard;
|
||||
|
||||
import org.cloudburstmc.protocol.bedrock.data.ScoreInfo;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.SetScorePacket;
|
||||
import org.geysermc.geyser.scoreboard.Scoreboard;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class EntityScoreboard {
|
||||
private final GeyserSession session;
|
||||
|
||||
private final Map<String, Map<Long, ScoreInfo>> objectives = new ConcurrentHashMap();
|
||||
private Scoreboard scoreboard;
|
||||
|
||||
public EntityScoreboard(GeyserSession session) {
|
||||
this.session = session;
|
||||
this.scoreboard = session.getWorldCache().getScoreboard();
|
||||
}
|
||||
|
||||
|
||||
public void updateScore(String objective, long entityId, int score) {
|
||||
Scoreboard scoreboard = session.getWorldCache().getScoreboard();
|
||||
Map<Long, ScoreInfo> scores = objectives.computeIfAbsent(objective, k -> new HashMap<>());
|
||||
ScoreInfo info = scores.get(entityId);
|
||||
if (info == null) {
|
||||
info = new ScoreInfo(scoreboard.getNextId().getAndIncrement(), objective, score, ScoreInfo.ScorerType.ENTITY, entityId);
|
||||
}
|
||||
List<ScoreInfo> infos = new ArrayList<>();
|
||||
infos.add(info);
|
||||
SetScorePacket setScorePacket = new SetScorePacket();
|
||||
setScorePacket.setAction(SetScorePacket.Action.SET);
|
||||
setScorePacket.setInfos(infos);
|
||||
this.session.sendUpstreamPacket(setScorePacket);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -94,13 +94,10 @@ public class PlayerUtils {
|
||||
|
||||
}
|
||||
|
||||
public static void sendEntityScoreUpdate(Player player, Entity entity, String objective, int score) {
|
||||
UpdateEntityScorePacket packet = new UpdateEntityScorePacket(entity.getEntityId(), objective, score);
|
||||
player.sendPluginMessage(GeyserUtils.getInstance(), GeyserUtilsChannels.MAIN, GeyserUtils.getPacketManager().encodePacket(packet));
|
||||
|
||||
}
|
||||
|
||||
// (yes I'm aware it's "horrible" code), also this aint player packets at all lmao
|
||||
// right, so this part needs to be refactored xD
|
||||
// the plugin didn't have this much functionality in its earliest days (it even just have camera shakes),
|
||||
// so I didn't think too much about it
|
||||
|
||||
public static void registerProperty(Player player, Entity entity, String identifier, Class<?> type) {
|
||||
EntityPropertyRegisterPacket packet = new EntityPropertyRegisterPacket();
|
||||
|
||||
Reference in New Issue
Block a user