Skip to content

Commit

Permalink
Merge branch '1.21.1' into 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
MATRIX-feather committed Oct 24, 2024
2 parents b660950 + fc4aa60 commit f2ad6dd
Show file tree
Hide file tree
Showing 32 changed files with 685 additions and 258 deletions.
27 changes: 25 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ repositories {
includeGroup("de.themoep")
}
}

maven {
url = uri("https://repo.glaremasters.me/repository/towny")
content {
includeGroup("com.palmergames.bukkit.towny")
}
}
}

paperweight.reobfArtifactConfiguration = ReobfArtifactConfiguration.MOJANG_PRODUCTION
Expand All @@ -66,15 +73,28 @@ dependencies {
paperweight.paperDevBundle("${project.property("minecraft_version")}")

compileOnly("com.comphenix.protocol:ProtocolLib:${project.property("protocollib_version")}")
{
isTransitive = false
}

compileOnly(files("libs/CMILib1.4.3.5.jar"))
compileOnly(files("libs/Residence5.1.4.0.jar"))
compileOnly(files("libs/TAB v4.1.2.jar"))

compileOnly("com.palmergames.bukkit.towny:towny:${project.property("towny_version")}")
{
isTransitive = false
}

compileOnly("com.ticxo.modelengine:ModelEngine:${project.property("me_version")}")
{
isTransitive = false
}

//compileOnly("com.github.Gecolay:GSit:${project.property("gsit_version")}")
compileOnly("me.clip:placeholderapi:${project.property("papi_version")}")
{
isTransitive = false
}

implementation("org.java-websocket:Java-WebSocket:1.5.7")
{
Expand Down Expand Up @@ -112,7 +132,7 @@ bukkit {
apiVersion = "1.19"
authors = listOf("MATRIX-feather")
depend = listOf()
softDepend = listOf("TAB", "Residence", "ModelEngine", "PlaceholderAPI")
softDepend = listOf("Towny", "Residence", "ModelEngine", "PlaceholderAPI")
version = "${project.property("project_version")}"
prefix = "FeatherMorph"
name = "FeatherMorph"
Expand All @@ -127,6 +147,8 @@ bukkit {

register("play-action")

register("toggle-town-morph-flight")

val featherMorphCommand = register("feathermorph").get()
featherMorphCommand.aliases = listOf("fm");
}
Expand All @@ -148,6 +170,7 @@ bukkit {
register(permissionRoot + "request.deny")

register(permissionRoot + "can_fly")
register(permissionRoot + "toggle_town_fly")
}

permissions.forEach {
Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project_version=1.1.11
project_version=1.1.20

# FM Protocols
protocols_version=b15c1841
Expand All @@ -9,10 +9,11 @@ mc_version=1.21
minecraft_version=1.21-R0.1-SNAPSHOT

# Dependencies
protocollib_version=5.1.0
protocollib_version=5.3.0
#ld_version=10.0.33
pluginbase_version=292d5f3a
gsit_version=1.6.0
papi_version=2.11.5
bstats_version=3.0.2
me_version = R4.0.4
towny_version = 0.100.4.0
Binary file removed libs/TAB v4.1.2.jar
Binary file not shown.
Binary file removed libs/TAB-Bridge.v5.0.2.jar
Binary file not shown.
6 changes: 3 additions & 3 deletions src/main/java/xyz/nifeather/morph/MorphManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -946,9 +946,6 @@ private void postBuildDisguise(DisguiseBuildResult result,

// 切换CD
skillHandler.switchCooldown(player.getUniqueId(), cdInfo);

// 调用事件
new PlayerMorphEvent(player, state).callEvent();
}

private boolean applyDisguise(MorphParameters parameters,
Expand Down Expand Up @@ -1032,6 +1029,9 @@ private boolean applyDisguise(MorphParameters parameters,

clientHandler.sendCommand(player, new S2CSetAvailableAnimationsCommand(availableAnimations));

// 调用事件
new PlayerMorphEvent(player, state).callEvent();

return true;
}

Expand Down
12 changes: 4 additions & 8 deletions src/main/java/xyz/nifeather/morph/MorphPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
import xyz.nifeather.morph.messages.vanilla.VanillaMessageStore;
import xyz.nifeather.morph.misc.NetworkingHelper;
import xyz.nifeather.morph.misc.PlayerOperationSimulator;
import xyz.nifeather.morph.misc.integrations.towny.TownyAdapter;
import xyz.nifeather.morph.misc.recipe.RecipeManager;
import xyz.nifeather.morph.misc.disguiseProperty.DisguiseProperties;
import xyz.nifeather.morph.misc.gui.IconLookup;
import xyz.nifeather.morph.misc.integrations.modelengine.ModelEngineHelper;
import xyz.nifeather.morph.misc.integrations.placeholderapi.PlaceholderIntegration;
import xyz.nifeather.morph.misc.integrations.residence.ResidenceEventProcessor;
import xyz.nifeather.morph.misc.integrations.tab.TabAdapter;
import xyz.nifeather.morph.misc.skins.PlayerSkinProvider;
import xyz.nifeather.morph.network.multiInstance.MultiInstanceService;
import xyz.nifeather.morph.network.server.MorphClientHandler;
Expand Down Expand Up @@ -91,8 +91,6 @@ public String getNameSpace()

private InteractionMirrorProcessor mirrorProcessor;

private TabAdapter tabAdapter;

private MultiInstanceService instanceService;

private EntityProcessor entityProcessor;
Expand Down Expand Up @@ -173,10 +171,10 @@ public void onEnable()
this.registerListener(new ResidenceEventProcessor());
}, true);

softDeps.setHandle("TAB", r ->
softDeps.setHandle("Towny", plugin ->
{
logger.info("Applying TAB integrations...");
this.registerListener(tabAdapter = new TabAdapter());
logger.info("Towny detected, applying integrations...");
this.registerListener(new TownyAdapter());
}, true);

softDeps.setHandle("ModelEngine", r ->
Expand Down Expand Up @@ -295,8 +293,6 @@ public void onDisable()
if (instanceService != null)
instanceService.onDisable();

PlayerSkinProvider.getInstance().shutdown();

var messenger = this.getServer().getMessenger();

messenger.unregisterOutgoingPluginChannel(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import java.util.Map;
import java.util.Stack;
import java.util.concurrent.ConcurrentHashMap;

public class FlyAbility extends MorphAbility<FlyOption>
{
Expand Down Expand Up @@ -248,7 +249,7 @@ public void onGameModeChange(PlayerGameModeChangeEvent e)
}
}

private static final Map<Player, Stack<Object>> blockedPlayersMap = new Object2ObjectOpenHashMap<>();
private static final Map<Player, Stack<Object>> blockedPlayersMap = new ConcurrentHashMap<>();

public static boolean playerBlocked(Player player)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public boolean register(ProtocolListener listener)
{
try
{
ProtocolLibrary.getProtocolManager().addPacketListener(listener);
registerListenerToPacketManager(listener);
}
catch (Throwable t)
{
Expand Down Expand Up @@ -95,7 +95,7 @@ public boolean unregister(ProtocolListener listener)

try
{
ProtocolLibrary.getProtocolManager().removePacketListener(listener);
unRegisterListenerFromPacketManager(listener);
}
catch (Throwable t)
{
Expand All @@ -114,13 +114,11 @@ private void load()
{
if (disposed) return;

var protocolMgr = ProtocolLibrary.getProtocolManager();

for (var listener : listeners)
{
try
{
protocolMgr.addPacketListener(listener);
registerListenerToPacketManager(listener);
}
catch (Throwable t)
{
Expand All @@ -133,6 +131,37 @@ private void load()
loadReady = true;
}

private final boolean async = false;

private void registerListenerToPacketManager(ProtocolListener listener)
{
if (async)
{
logger.info("Register async handler " + listener.getIdentifier());
ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(listener).syncStart();
}
else
{
ProtocolLibrary.getProtocolManager().addPacketListener(listener);
}
}

private void unRegisterListenerFromPacketManager(ProtocolListener listener)
{
if (async)
{
var asyncMgr = ProtocolLibrary.getProtocolManager()
.getAsynchronousManager();

asyncMgr.unregisterAsyncHandler(listener);
}
else
{
ProtocolLibrary.getProtocolManager().removePacketListener(listener);
}

}

private boolean disposed;

public boolean disposed()
Expand All @@ -143,13 +172,11 @@ public boolean disposed()
@Override
public void dispose()
{
var protocolMgr = ProtocolLibrary.getProtocolManager();

for (ProtocolListener listener : listeners)
{
try
{
protocolMgr.removePacketListener(listener);
unRegisterListenerFromPacketManager(listener);
}
catch (Throwable t)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package xyz.nifeather.morph.backends.server.renderer.network.datawatcher.watchers.types;

import com.comphenix.protocol.events.PacketContainer;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.packs.repository.Pack;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import xyz.nifeather.morph.backends.server.renderer.network.datawatcher.watchers.SingleWatcher;
Expand Down Expand Up @@ -82,6 +85,12 @@ protected <X> void onEntryWrite(CustomEntry<X> entry, X oldVal, X newVal)
var component = str.isEmpty() ? null : Component.literal(str);
writePersistent(ValueIndex.BASE_ENTITY.CUSTOM_NAME, component == null ? Optional.empty() : Optional.of(component));
}

if (entry.equals(CustomEntries.VANISHED))
{
var packet = new ClientboundRemoveEntitiesPacket(this.readEntryOrThrow(CustomEntries.SPAWN_ID));
this.sendPacketToAffectedPlayers(PacketContainer.fromPacket(packet));
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private void onAnimationPacket(PacketEvent event, ClientboundAnimatePacket clien
return;

var sourceEntityId = clientboundAnimatePacket.getId();
var nmsPlayer = this.getNmsPlayerEntityFrom(event, sourceEntityId);
var nmsPlayer = this.getNmsPlayerFrom(sourceEntityId);

if (nmsPlayer == null) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void onPacketSending(PacketEvent event)
private void onEquipmentPacket(ClientboundSetEquipmentPacket packet, PacketEvent event)
{
//获取此包的来源实体
var sourceNmsEntity = getNmsPlayerEntityFrom(event, packet.getEntity());
var sourceNmsEntity = getNmsPlayerFrom(packet.getEntity());
if (sourceNmsEntity == null)
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void onPacketSending(PacketEvent event)
private void onMetaPacket(ClientboundSetEntityDataPacket packet, PacketEvent packetEvent)
{
//获取此包的来源实体
var sourceNmsEntity = getNmsPlayerEntityFrom(packetEvent, packet.id());
var sourceNmsEntity = getNmsPlayerFrom(packet.id());

// How could this be?!
if (sourceNmsEntity == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import net.minecraft.network.protocol.game.ClientboundMoveEntityPacket;
import net.minecraft.network.protocol.game.ClientboundRotateHeadPacket;
import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket;
import org.bukkit.Bukkit;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import xiamomc.pluginbase.Annotations.Resolved;
import xyz.nifeather.morph.backends.server.renderer.network.registries.RenderRegistry;
import xyz.nifeather.morph.utilities.NmsUtils;

public class PlayerLookPacketListener extends ProtocolListener
{
Expand Down Expand Up @@ -65,7 +65,7 @@ else if (packetType == PacketType.Play.Server.ENTITY_TELEPORT)
private void onTeleport(ClientboundTeleportEntityPacket packet, PacketEvent event)
{
//获取此包的来源实体
var sourceNmsEntity = getNmsPlayerEntityFrom(event, packet.getId());
var sourceNmsEntity = getNmsPlayerFrom(packet.getId());
if (sourceNmsEntity == null)
return;

Expand Down Expand Up @@ -102,17 +102,8 @@ private void onTeleport(ClientboundTeleportEntityPacket packet, PacketEvent even
private void onHeadRotation(ClientboundRotateHeadPacket packet, PacketEvent event)
{
//获取此包的来源实体
var sourceNmsEntity = packet.getEntity(NmsUtils.getNmsLevel(event.getPlayer().getWorld()));
if (sourceNmsEntity == null)
{
if (isDebugEnabled())
{
logger.warn("A packet from a player that doesn't exist in its world?!");
logger.warn("Packet: " + event.getPacketType());
}

return;
}
var sourceNmsEntity = this.getNmsPlayerEntityFromUnreadablePacket(packet);
if (sourceNmsEntity == null) return;

if (!(sourceNmsEntity.getBukkitEntity() instanceof Player sourcePlayer)) return;

Expand All @@ -133,17 +124,9 @@ private void onHeadRotation(ClientboundRotateHeadPacket packet, PacketEvent even
private void onLookPacket(ClientboundMoveEntityPacket packet, PacketEvent event)
{
//获取此包的来源实体
var sourceNmsEntity = packet.getEntity(NmsUtils.getNmsLevel(event.getPlayer().getWorld()));
if (sourceNmsEntity == null)
{
if (isDebugEnabled())
{
logger.warn("A packet from a player that doesn't exist in its world?!");
logger.warn("Packet: " + event.getPacketType());
}
var sourceNmsEntity = this.getNmsPlayerEntityFromUnreadablePacket(packet);

return;
}
if (sourceNmsEntity == null) return;

if (!(sourceNmsEntity.getBukkitEntity() instanceof Player sourcePlayer)) return;

Expand Down
Loading

0 comments on commit f2ad6dd

Please sign in to comment.