Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
MythicCraft
MythicCosmetics
Commits
1d93ef8e
Commit
1d93ef8e
authored
3 years ago
by
Ticxo
Browse files
Options
Download
Email Patches
Plain Diff
Fixed LibDisguise compatibility
parent
ea5c2aaf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
34 deletions
+36
-34
dist-premium/pom.xml
dist-premium/pom.xml
+1
-1
pom.xml
pom.xml
+1
-0
v1_18_R2/src/main/java/io/lumine/cosmetics/nms/v1_18_R2/cosmetic/VolatileHatImpl.java
...mine/cosmetics/nms/v1_18_R2/cosmetic/VolatileHatImpl.java
+21
-21
v1_18_R2/src/main/java/io/lumine/cosmetics/nms/v1_18_R2/cosmetic/VolatileOffhandImpl.java
.../cosmetics/nms/v1_18_R2/cosmetic/VolatileOffhandImpl.java
+13
-12
No files found.
dist-premium/pom.xml
View file @
1d93ef8e
...
...
@@ -60,7 +60,7 @@
<version>
3.1.0
</version>
<configuration>
<finalName>
MCCosmeticsPremium-${project.parent.version}
</finalName>
<outputDirectory>
${ticxo.build.
location
}
</outputDirectory>
<outputDirectory>
${ticxo.build.
premium
}
</outputDirectory>
</configuration>
</plugin>
...
...
This diff is collapsed.
Click to expand it.
pom.xml
View file @
1d93ef8e
...
...
@@ -25,6 +25,7 @@
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<ticxo.build.location>
../target
</ticxo.build.location>
<ticxo.build.premium>
../target
</ticxo.build.premium>
</properties>
<modules>
...
...
This diff is collapsed.
Click to expand it.
v1_18_R2/src/main/java/io/lumine/cosmetics/nms/v1_18_R2/cosmetic/VolatileHatImpl.java
View file @
1d93ef8e
...
...
@@ -3,17 +3,19 @@ package io.lumine.cosmetics.nms.v1_18_R2.cosmetic;
import
com.google.common.collect.Maps
;
import
com.mojang.datafixers.util.Pair
;
import
io.lumine.cosmetics.MCCosmeticsPlugin
;
import
io.lumine.cosmetics.api.cosmetics.Cosmetic
;
import
io.lumine.cosmetics.api.cosmetics.ItemCosmetic
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
io.lumine.cosmetics.managers.gestures.Gesture
;
import
io.lumine.cosmetics.managers.hats.Hat
;
import
io.lumine.cosmetics.nms.VolatileCodeEnabled_v1_18_R2
;
import
io.lumine.cosmetics.nms.cosmetic.VolatileEquipmentHelper
;
import
io.lumine.cosmetics.players.Profile
;
import
io.netty.buffer.Unpooled
;
import
lombok.Getter
;
import
net.minecraft.network.FriendlyByteBuf
;
import
net.minecraft.network.protocol.Packet
;
import
net.minecraft.network.protocol.game.*
;
import
net.minecraft.network.protocol.game.ClientboundAddPlayerPacket
;
import
net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket
;
import
net.minecraft.network.protocol.game.ServerboundAcceptTeleportationPacket
;
import
net.minecraft.world.entity.EquipmentSlot
;
import
org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer
;
import
org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack
;
...
...
@@ -21,7 +23,6 @@ import org.bukkit.entity.Player;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
public
class
VolatileHatImpl
implements
VolatileEquipmentHelper
{
...
...
@@ -74,15 +75,7 @@ public class VolatileHatImpl implements VolatileEquipmentHelper {
final
var
profile
=
MCCosmeticsPlugin
.
inst
().
getProfiles
().
getProfile
(
sender
);
if
(
profile
==
null
||
profile
.
isHidden
(
Hat
.
class
))
return
true
;
final
var
list
=
handleSpawn
(
profile
);
if
(
list
==
null
)
return
true
;
final
var
connection
=
((
CraftPlayer
)
sender
).
getHandle
().
connection
;
for
(
Object
obj
:
list
)
{
connection
.
send
((
Packet
<?>)
obj
);
}
handleSpawn
(
profile
);
}
return
true
;
}
...
...
@@ -92,13 +85,15 @@ public class VolatileHatImpl implements VolatileEquipmentHelper {
if
(
packet
instanceof
ClientboundAddPlayerPacket
playerPacket
)
{
int
id
=
playerPacket
.
getEntityId
();
Profile
profile
=
getProfile
(
receiver
,
id
);
if
(
profile
!=
null
&&
!
profile
.
isHidden
(
Hat
.
class
))
return
handleSpawn
(
profile
);
if
(
profile
!=
null
&&
!
profile
.
isHidden
(
Hat
.
class
))
{
handleSpawn
(
profile
);
}
}
else
if
(
packet
instanceof
ClientboundSetEquipmentPacket
equipmentPacket
)
{
int
id
=
equipmentPacket
.
getEntity
();
Profile
profile
=
getProfile
(
receiver
,
id
);
if
(
profile
!=
null
&&
!
profile
.
isHidden
(
Hat
.
class
))
return
handleSpawn
(
profile
);
if
(
profile
!=
null
&&
!
profile
.
isHidden
(
Hat
.
class
))
{
handleSpawn
(
profile
);
}
}
return
null
;
...
...
@@ -111,22 +106,27 @@ public class VolatileHatImpl implements VolatileEquipmentHelper {
return
plugin
.
getProfiles
().
getProfile
(
player
);
}
public
List
<
Object
>
handleSpawn
(
Profile
profile
)
{
public
void
handleSpawn
(
Profile
profile
)
{
final
var
maybeEquipped
=
profile
.
getEquipped
(
Hat
.
class
);
if
(
maybeEquipped
.
isEmpty
())
{
return
null
;
return
;
}
var
equip
=
maybeEquipped
.
get
();
var
opt
=
equip
.
getCosmetic
();
if
(!(
opt
instanceof
ItemCosmetic
hat
))
return
null
;
return
;
final
var
player
=
profile
.
getPlayer
();
final
var
nmsHat
=
CraftItemStack
.
asNMSCopy
(
hat
.
getCosmetic
(
equip
.
getVariant
()));
ClientboundSetEquipmentPacket
equipmentPacket
=
new
ClientboundSetEquipmentPacket
(
player
.
getEntityId
(),
List
.
of
(
Pair
.
of
(
EquipmentSlot
.
HEAD
,
nmsHat
)));
return
List
.
of
(
equipmentPacket
);
FriendlyByteBuf
byteBuf
=
new
FriendlyByteBuf
(
Unpooled
.
buffer
());
byteBuf
.
writeByte
(
80
);
equipmentPacket
.
write
(
byteBuf
);
final
var
pipeline
=
((
CraftPlayer
)
player
).
getHandle
().
connection
.
getConnection
().
channel
.
pipeline
();
pipeline
.
writeAndFlush
(
byteBuf
);
}
}
This diff is collapsed.
Click to expand it.
v1_18_R2/src/main/java/io/lumine/cosmetics/nms/v1_18_R2/cosmetic/VolatileOffhandImpl.java
View file @
1d93ef8e
...
...
@@ -3,28 +3,24 @@ package io.lumine.cosmetics.nms.v1_18_R2.cosmetic;
import
com.google.common.collect.Maps
;
import
com.mojang.datafixers.util.Pair
;
import
io.lumine.cosmetics.MCCosmeticsPlugin
;
import
io.lumine.cosmetics.api.cosmetics.Cosmetic
;
import
io.lumine.cosmetics.api.cosmetics.ItemCosmetic
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
io.lumine.cosmetics.logging.MCLogger
;
import
io.lumine.cosmetics.managers.hats.Hat
;
import
io.lumine.cosmetics.managers.offhand.Offhand
;
import
io.lumine.cosmetics.nms.VolatileCodeEnabled_v1_18_R2
;
import
io.lumine.cosmetics.nms.cosmetic.VolatileEquipmentHelper
;
import
io.lumine.cosmetics.players.Profile
;
import
io.netty.buffer.Unpooled
;
import
lombok.Getter
;
import
net.minecraft.network.FriendlyByteBuf
;
import
net.minecraft.network.protocol.game.ClientboundAddPlayerPacket
;
import
net.minecraft.network.protocol.game.ClientboundEntityEventPacket
;
import
net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket
;
import
net.minecraft.world.entity.EquipmentSlot
;
import
net.minecraft.world.item.ItemStack
;
import
org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer
;
import
org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack
;
import
org.bukkit.entity.Player
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
public
class
VolatileOffhandImpl
implements
VolatileEquipmentHelper
{
...
...
@@ -79,12 +75,12 @@ public class VolatileOffhandImpl implements VolatileEquipmentHelper {
int
id
=
playerPacket
.
getEntityId
();
Profile
profile
=
getProfile
(
receiver
,
id
);
if
(
profile
!=
null
&&
!
profile
.
isHidden
(
Offhand
.
class
))
return
handleSpawn
(
profile
);
handleSpawn
(
profile
);
}
else
if
(
packet
instanceof
ClientboundSetEquipmentPacket
equipmentPacket
)
{
int
id
=
equipmentPacket
.
getEntity
();
Profile
profile
=
getProfile
(
receiver
,
id
);
if
(
profile
!=
null
&&
!
profile
.
isHidden
(
Offhand
.
class
))
return
handleSpawn
(
profile
);
handleSpawn
(
profile
);
}
return
null
;
...
...
@@ -97,22 +93,27 @@ public class VolatileOffhandImpl implements VolatileEquipmentHelper {
return
plugin
.
getProfiles
().
getProfile
(
player
);
}
public
List
<
Object
>
handleSpawn
(
Profile
profile
)
{
public
void
handleSpawn
(
Profile
profile
)
{
final
var
maybeEquipped
=
profile
.
getEquipped
(
Offhand
.
class
);
if
(
maybeEquipped
.
isEmpty
())
{
return
null
;
return
;
}
var
equip
=
maybeEquipped
.
get
();
var
opt
=
equip
.
getCosmetic
();
if
(!(
opt
instanceof
ItemCosmetic
offhand
))
return
null
;
return
;
final
var
player
=
profile
.
getPlayer
();
final
var
nmsOffhand
=
CraftItemStack
.
asNMSCopy
(
offhand
.
getCosmetic
(
equip
.
getVariant
()));
ClientboundSetEquipmentPacket
equipmentPacket
=
new
ClientboundSetEquipmentPacket
(
player
.
getEntityId
(),
List
.
of
(
Pair
.
of
(
EquipmentSlot
.
OFFHAND
,
nmsOffhand
)));
return
List
.
of
(
equipmentPacket
);
FriendlyByteBuf
byteBuf
=
new
FriendlyByteBuf
(
Unpooled
.
buffer
());
byteBuf
.
writeByte
(
80
);
equipmentPacket
.
write
(
byteBuf
);
final
var
pipeline
=
((
CraftPlayer
)
player
).
getHandle
().
connection
.
getConnection
().
channel
.
pipeline
();
pipeline
.
writeAndFlush
(
byteBuf
);
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment