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
f595537f
Commit
f595537f
authored
3 years ago
by
Ticxo
Browse files
Options
Download
Email Patches
Plain Diff
yupituasf
parent
cb3f5667
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
266 additions
and
52 deletions
+266
-52
api/src/main/java/io/lumine/cosmetics/api/cosmetics/Cosmetic.java
...main/java/io/lumine/cosmetics/api/cosmetics/Cosmetic.java
+1
-0
api/src/main/java/io/lumine/cosmetics/api/cosmetics/manager/CosmeticManager.java
...mine/cosmetics/api/cosmetics/manager/CosmeticManager.java
+10
-10
api/src/main/java/io/lumine/cosmetics/api/cosmetics/manager/HideableCosmetic.java
...ine/cosmetics/api/cosmetics/manager/HideableCosmetic.java
+11
-0
api/src/main/java/io/lumine/cosmetics/api/players/CosmeticInventory.java
...va/io/lumine/cosmetics/api/players/CosmeticInventory.java
+3
-0
plugin/src/main/java/io/lumine/cosmetics/managers/MCCosmeticsManager.java
...java/io/lumine/cosmetics/managers/MCCosmeticsManager.java
+1
-1
plugin/src/main/java/io/lumine/cosmetics/managers/back/BackManager.java
...n/java/io/lumine/cosmetics/managers/back/BackManager.java
+23
-5
plugin/src/main/java/io/lumine/cosmetics/managers/gestures/Gesture.java
...n/java/io/lumine/cosmetics/managers/gestures/Gesture.java
+0
-3
plugin/src/main/java/io/lumine/cosmetics/managers/gestures/GestureManager.java
...io/lumine/cosmetics/managers/gestures/GestureManager.java
+4
-0
plugin/src/main/java/io/lumine/cosmetics/managers/hats/HatManager.java
...in/java/io/lumine/cosmetics/managers/hats/HatManager.java
+22
-6
plugin/src/main/java/io/lumine/cosmetics/managers/offhand/OffhandManager.java
.../io/lumine/cosmetics/managers/offhand/OffhandManager.java
+22
-5
plugin/src/main/java/io/lumine/cosmetics/players/ProfileInventory.java
...in/java/io/lumine/cosmetics/players/ProfileInventory.java
+1
-1
v1_18_R2/src/main/java/io/lumine/cosmetics/nms/VolatileCodeEnabled_v1_18_R2.java
...io/lumine/cosmetics/nms/VolatileCodeEnabled_v1_18_R2.java
+17
-6
v1_18_R2/src/main/java/io/lumine/cosmetics/nms/v1_18_R2/cosmetic/VolatileBackImpl.java
...ine/cosmetics/nms/v1_18_R2/cosmetic/VolatileBackImpl.java
+6
-7
v1_18_R2/src/main/java/io/lumine/cosmetics/nms/v1_18_R2/cosmetic/VolatileGestureImpl.java
.../cosmetics/nms/v1_18_R2/cosmetic/VolatileGestureImpl.java
+141
-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
+2
-4
v1_18_R2/src/main/java/io/lumine/cosmetics/nms/v1_18_R2/cosmetic/VolatileOffhandImpl.java
.../cosmetics/nms/v1_18_R2/cosmetic/VolatileOffhandImpl.java
+2
-4
No files found.
api/src/main/java/io/lumine/cosmetics/api/cosmetics/Cosmetic.java
View file @
f595537f
package
io.lumine.cosmetics.api.cosmetics
;
package
io.lumine.cosmetics.api.cosmetics
;
import
io.lumine.cosmetics.api.cosmetics.manager.CosmeticManager
;
import
io.lumine.cosmetics.api.players.CosmeticInventory
;
import
io.lumine.cosmetics.api.players.CosmeticInventory
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
io.lumine.utils.config.properties.PropertyHolder
;
import
io.lumine.utils.config.properties.PropertyHolder
;
...
...
This diff is collapsed.
Click to expand it.
api/src/main/java/io/lumine/cosmetics/api/cosmetics/CosmeticManager.java
→
api/src/main/java/io/lumine/cosmetics/api/cosmetics/
manager/
CosmeticManager.java
View file @
f595537f
package
io.lumine.cosmetics.api.cosmetics
;
package
io.lumine.cosmetics.api.cosmetics
.manager
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
public
interface
CosmeticManager
{
public
interface
CosmeticManager
{
void
equip
(
CosmeticProfile
profile
);
void
equip
(
CosmeticProfile
profile
);
void
unequip
(
CosmeticProfile
profile
);
void
unequip
(
CosmeticProfile
profile
);
}
}
This diff is collapsed.
Click to expand it.
api/src/main/java/io/lumine/cosmetics/api/cosmetics/manager/HideableCosmetic.java
0 → 100644
View file @
f595537f
package
io.lumine.cosmetics.api.cosmetics.manager
;
import
io.lumine.cosmetics.api.cosmetics.Cosmetic
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
public
interface
HideableCosmetic
{
void
hide
(
CosmeticProfile
profile
,
Cosmetic
request
);
void
show
(
CosmeticProfile
profile
);
}
This diff is collapsed.
Click to expand it.
api/src/main/java/io/lumine/cosmetics/api/players/CosmeticInventory.java
View file @
f595537f
...
@@ -3,6 +3,7 @@ package io.lumine.cosmetics.api.players;
...
@@ -3,6 +3,7 @@ package io.lumine.cosmetics.api.players;
import
io.lumine.cosmetics.api.cosmetics.Cosmetic
;
import
io.lumine.cosmetics.api.cosmetics.Cosmetic
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.Optional
;
public
interface
CosmeticInventory
{
public
interface
CosmeticInventory
{
...
@@ -12,6 +13,8 @@ public interface CosmeticInventory {
...
@@ -12,6 +13,8 @@ public interface CosmeticInventory {
Collection
<
String
>
getUnlocked
(
String
type
);
Collection
<
String
>
getUnlocked
(
String
type
);
Optional
<
Cosmetic
>
getEquipped
(
Class
<?
extends
Cosmetic
>
tClass
);
Optional
<
Cosmetic
>
getEquipped
(
Class
<?
extends
Cosmetic
>
tClass
);
Map
<
Class
<?
extends
Cosmetic
>,
Cosmetic
>
getEquipped
();
void
equip
(
Cosmetic
cosmetic
);
void
equip
(
Cosmetic
cosmetic
);
...
...
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/managers/MCCosmeticsManager.java
View file @
f595537f
...
@@ -4,7 +4,7 @@ import com.google.common.collect.Lists;
...
@@ -4,7 +4,7 @@ import com.google.common.collect.Lists;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Maps
;
import
io.lumine.cosmetics.MCCosmeticsPlugin
;
import
io.lumine.cosmetics.MCCosmeticsPlugin
;
import
io.lumine.cosmetics.api.cosmetics.Cosmetic
;
import
io.lumine.cosmetics.api.cosmetics.Cosmetic
;
import
io.lumine.cosmetics.api.cosmetics.CosmeticManager
;
import
io.lumine.cosmetics.api.cosmetics.
manager.
CosmeticManager
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
io.lumine.cosmetics.config.Scope
;
import
io.lumine.cosmetics.config.Scope
;
import
io.lumine.cosmetics.constants.CosmeticType
;
import
io.lumine.cosmetics.constants.CosmeticType
;
...
...
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/managers/back/BackManager.java
View file @
f595537f
package
io.lumine.cosmetics.managers.back
;
package
io.lumine.cosmetics.managers.back
;
import
io.lumine.cosmetics.MCCosmeticsPlugin
;
import
io.lumine.cosmetics.MCCosmeticsPlugin
;
import
io.lumine.cosmetics.api.events.CosmeticPlayerLoadedEvent
;
import
io.lumine.cosmetics.api.cosmetics.Cosmetic
;
import
io.lumine.cosmetics.api.cosmetics.manager.HideableCosmetic
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
io.lumine.cosmetics.managers.MCCosmeticsManager
;
import
io.lumine.cosmetics.managers.MCCosmeticsManager
;
import
io.lumine.cosmetics.managers.gestures.Gesture
;
import
io.lumine.cosmetics.nms.cosmetic.VolatileEquipmentHelper
;
import
io.lumine.cosmetics.nms.cosmetic.VolatileEquipmentHelper
;
import
io.lumine.utils.Events
;
import
java.io.File
;
import
java.io.File
;
public
class
BackManager
extends
MCCosmeticsManager
<
BackAccessory
>
{
public
class
BackManager
extends
MCCosmeticsManager
<
BackAccessory
>
implements
HideableCosmetic
{
public
BackManager
(
MCCosmeticsPlugin
plugin
)
{
public
BackManager
(
MCCosmeticsPlugin
plugin
)
{
super
(
plugin
,
BackAccessory
.
class
);
super
(
plugin
,
BackAccessory
.
class
);
...
@@ -24,11 +25,28 @@ public class BackManager extends MCCosmeticsManager<BackAccessory> {
...
@@ -24,11 +25,28 @@ public class BackManager extends MCCosmeticsManager<BackAccessory> {
@Override
@Override
public
void
equip
(
CosmeticProfile
profile
)
{
public
void
equip
(
CosmeticProfile
profile
)
{
((
VolatileEquipmentHelper
)
getPlugin
().
getVolatileCodeHandler
().
getCosmeticHelper
(
BackAccessory
.
class
)
).
apply
(
profile
);
getHelper
(
).
apply
(
profile
);
}
}
@Override
@Override
public
void
unequip
(
CosmeticProfile
profile
)
{
public
void
unequip
(
CosmeticProfile
profile
)
{
((
VolatileEquipmentHelper
)
getPlugin
().
getVolatileCodeHandler
().
getCosmeticHelper
(
BackAccessory
.
class
)
).
unapply
(
profile
);
getHelper
(
).
unapply
(
profile
);
}
}
@Override
public
void
hide
(
CosmeticProfile
profile
,
Cosmetic
request
)
{
if
(!(
request
instanceof
Gesture
))
return
;
getHelper
().
unapply
(
profile
);
}
@Override
public
void
show
(
CosmeticProfile
profile
)
{
getHelper
().
apply
(
profile
);
}
protected
VolatileEquipmentHelper
getHelper
()
{
return
(
VolatileEquipmentHelper
)
getNMSHelper
();
}
}
}
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/managers/gestures/Gesture.java
View file @
f595537f
...
@@ -25,14 +25,12 @@ public class Gesture extends AbstractCosmetic {
...
@@ -25,14 +25,12 @@ public class Gesture extends AbstractCosmetic {
private
static
final
StringProp
SLIM
=
Property
.
String
(
Scope
.
NONE
,
"Slim"
);
private
static
final
StringProp
SLIM
=
Property
.
String
(
Scope
.
NONE
,
"Slim"
);
private
static
final
BooleanProp
CAN_MOVE
=
Property
.
Boolean
(
Scope
.
NONE
,
"CanMove"
,
false
);
private
static
final
BooleanProp
CAN_MOVE
=
Property
.
Boolean
(
Scope
.
NONE
,
"CanMove"
,
false
);
private
static
final
BooleanProp
CAN_LOOK
=
Property
.
Boolean
(
Scope
.
NONE
,
"CanLook"
,
false
);
private
static
final
BooleanProp
CAN_LOOK
=
Property
.
Boolean
(
Scope
.
NONE
,
"CanLook"
,
false
);
private
static
final
BooleanProp
FORCE_LOOP
=
Property
.
Boolean
(
Scope
.
NONE
,
"CanLook"
,
false
);
private
static
final
EnumProp
<
QuitMethod
>
QUIT_CONTROL
=
Property
.
Enum
(
Scope
.
NONE
,
QuitMethod
.
class
,
"QuitControl"
,
QuitMethod
.
SNEAK
);
private
static
final
EnumProp
<
QuitMethod
>
QUIT_CONTROL
=
Property
.
Enum
(
Scope
.
NONE
,
QuitMethod
.
class
,
"QuitControl"
,
QuitMethod
.
SNEAK
);
@Getter
private
final
String
defaultGesture
;
@Getter
private
final
String
defaultGesture
;
@Getter
private
final
String
slimGesture
;
@Getter
private
final
String
slimGesture
;
@Getter
private
final
boolean
canMove
;
@Getter
private
final
boolean
canMove
;
@Getter
private
final
boolean
canLook
;
@Getter
private
final
boolean
canLook
;
@Getter
private
final
boolean
forceLoop
;
@Getter
private
final
QuitMethod
quitMethod
;
@Getter
private
final
QuitMethod
quitMethod
;
public
Gesture
(
GestureManager
manager
,
File
file
,
String
key
)
{
public
Gesture
(
GestureManager
manager
,
File
file
,
String
key
)
{
...
@@ -47,7 +45,6 @@ public class Gesture extends AbstractCosmetic {
...
@@ -47,7 +45,6 @@ public class Gesture extends AbstractCosmetic {
canMove
=
CAN_MOVE
.
fget
(
file
,
this
);
canMove
=
CAN_MOVE
.
fget
(
file
,
this
);
canLook
=
CAN_LOOK
.
fget
(
file
,
this
);
canLook
=
CAN_LOOK
.
fget
(
file
,
this
);
forceLoop
=
FORCE_LOOP
.
fget
(
file
,
this
);
quitMethod
=
QUIT_CONTROL
.
fget
(
file
,
this
);
quitMethod
=
QUIT_CONTROL
.
fget
(
file
,
this
);
}
}
...
...
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/managers/gestures/GestureManager.java
View file @
f595537f
...
@@ -8,6 +8,7 @@ import io.lumine.cosmetics.MCCosmeticsPlugin;
...
@@ -8,6 +8,7 @@ import io.lumine.cosmetics.MCCosmeticsPlugin;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
io.lumine.cosmetics.constants.CosmeticType
;
import
io.lumine.cosmetics.constants.CosmeticType
;
import
io.lumine.cosmetics.managers.MCCosmeticsManager
;
import
io.lumine.cosmetics.managers.MCCosmeticsManager
;
import
io.lumine.cosmetics.nms.cosmetic.VolatileEquipmentHelper
;
import
io.lumine.utils.Events
;
import
io.lumine.utils.Events
;
import
io.lumine.utils.files.Files
;
import
io.lumine.utils.files.Files
;
import
org.bukkit.entity.Player
;
import
org.bukkit.entity.Player
;
...
@@ -63,11 +64,14 @@ public class GestureManager extends MCCosmeticsManager<Gesture> {
...
@@ -63,11 +64,14 @@ public class GestureManager extends MCCosmeticsManager<Gesture> {
ticking
.
put
(
player
,
model
);
ticking
.
put
(
player
,
model
);
final
var
animation
=
model
.
getTexture
().
isSlim
()
?
gesture
.
getSlimGesture
()
:
gesture
.
getDefaultGesture
();
final
var
animation
=
model
.
getTexture
().
isSlim
()
?
gesture
.
getSlimGesture
()
:
gesture
.
getDefaultGesture
();
model
.
playAnimation
(
animation
);
model
.
playAnimation
(
animation
);
((
VolatileEquipmentHelper
)
getPlugin
().
getVolatileCodeHandler
().
getCosmeticHelper
(
Gesture
.
class
)).
apply
(
profile
);
}
}
@Override
@Override
public
void
unequip
(
CosmeticProfile
profile
)
{
public
void
unequip
(
CosmeticProfile
profile
)
{
ticking
.
remove
(
profile
.
getPlayer
());
ticking
.
remove
(
profile
.
getPlayer
());
((
VolatileEquipmentHelper
)
getPlugin
().
getVolatileCodeHandler
().
getCosmeticHelper
(
Gesture
.
class
)).
unapply
(
profile
);
}
}
private
void
loadGestures
()
{
private
void
loadGestures
()
{
...
...
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/managers/hats/HatManager.java
View file @
f595537f
package
io.lumine.cosmetics.managers.hats
;
package
io.lumine.cosmetics.managers.hats
;
import
io.lumine.cosmetics.MCCosmeticsPlugin
;
import
io.lumine.cosmetics.MCCosmeticsPlugin
;
import
io.lumine.cosmetics.api.events.CosmeticPlayerLoadedEvent
;
import
io.lumine.cosmetics.api.cosmetics.Cosmetic
;
import
io.lumine.cosmetics.api.cosmetics.manager.HideableCosmetic
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
io.lumine.cosmetics.managers.MCCosmeticsManager
;
import
io.lumine.cosmetics.managers.MCCosmeticsManager
;
import
io.lumine.cosmetics.managers.gestures.Gesture
;
import
io.lumine.cosmetics.nms.cosmetic.VolatileEquipmentHelper
;
import
io.lumine.cosmetics.nms.cosmetic.VolatileEquipmentHelper
;
import
io.lumine.cosmetics.players.Profile
;
import
io.lumine.cosmetics.players.Profile
;
import
io.lumine.utils.Events
;
import
io.lumine.utils.Events
;
import
io.lumine.utils.events.extra.ArmorEquipEvent
;
import
io.lumine.utils.events.extra.ArmorEquipEvent
;
import
org.bukkit.entity.Player
;
import
org.bukkit.entity.Player
;
import
org.bukkit.event.inventory.InventoryCloseEvent
;
import
org.bukkit.event.inventory.InventoryCloseEvent
;
import
org.bukkit.event.player.PlayerRespawnEvent
;
import
java.io.File
;
import
java.io.File
;
import
java.util.logging.Level
;
public
class
HatManager
extends
MCCosmeticsManager
<
Hat
>
{
public
class
HatManager
extends
MCCosmeticsManager
<
Hat
>
implements
HideableCosmetic
{
public
HatManager
(
MCCosmeticsPlugin
plugin
)
{
public
HatManager
(
MCCosmeticsPlugin
plugin
)
{
super
(
plugin
,
Hat
.
class
);
super
(
plugin
,
Hat
.
class
);
...
@@ -58,11 +58,27 @@ public class HatManager extends MCCosmeticsManager<Hat> {
...
@@ -58,11 +58,27 @@ public class HatManager extends MCCosmeticsManager<Hat> {
@Override
@Override
public
void
equip
(
CosmeticProfile
profile
)
{
public
void
equip
(
CosmeticProfile
profile
)
{
((
VolatileEquipmentHelper
)
getPlugin
().
getVolatileCodeHandler
().
getCosmeticHelper
(
Hat
.
class
)
).
apply
(
profile
);
getHelper
(
).
apply
(
profile
);
}
}
@Override
@Override
public
void
unequip
(
CosmeticProfile
profile
)
{
public
void
unequip
(
CosmeticProfile
profile
)
{
((
VolatileEquipmentHelper
)
getPlugin
().
getVolatileCodeHandler
().
getCosmeticHelper
(
Hat
.
class
)).
unapply
(
profile
);
getHelper
().
unapply
(
profile
);
}
@Override
public
void
hide
(
CosmeticProfile
profile
,
Cosmetic
request
)
{
if
(!(
request
instanceof
Gesture
))
return
;
getHelper
().
unapply
(
profile
);
}
@Override
public
void
show
(
CosmeticProfile
profile
)
{
getHelper
().
apply
(
profile
);
}
protected
VolatileEquipmentHelper
getHelper
()
{
return
(
VolatileEquipmentHelper
)
getNMSHelper
();
}
}
}
}
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/managers/offhand/OffhandManager.java
View file @
f595537f
package
io.lumine.cosmetics.managers.offhand
;
package
io.lumine.cosmetics.managers.offhand
;
import
io.lumine.cosmetics.MCCosmeticsPlugin
;
import
io.lumine.cosmetics.MCCosmeticsPlugin
;
import
io.lumine.cosmetics.api.events.CosmeticPlayerLoadedEvent
;
import
io.lumine.cosmetics.api.cosmetics.Cosmetic
;
import
io.lumine.cosmetics.api.cosmetics.manager.HideableCosmetic
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
io.lumine.cosmetics.managers.MCCosmeticsManager
;
import
io.lumine.cosmetics.managers.MCCosmeticsManager
;
import
io.lumine.cosmetics.managers.gestures.Gesture
;
import
io.lumine.cosmetics.nms.cosmetic.VolatileEquipmentHelper
;
import
io.lumine.cosmetics.nms.cosmetic.VolatileEquipmentHelper
;
import
io.lumine.cosmetics.players.Profile
;
import
io.lumine.cosmetics.players.Profile
;
import
io.lumine.utils.Events
;
import
io.lumine.utils.Events
;
import
io.lumine.utils.events.extra.ArmorEquipEvent
;
import
org.bukkit.entity.Player
;
import
org.bukkit.entity.Player
;
import
org.bukkit.event.inventory.InventoryCloseEvent
;
import
org.bukkit.event.inventory.InventoryCloseEvent
;
import
org.bukkit.event.player.PlayerRespawnEvent
;
import
org.bukkit.event.player.PlayerRespawnEvent
;
...
@@ -15,7 +16,7 @@ import org.bukkit.event.player.PlayerSwapHandItemsEvent;
...
@@ -15,7 +16,7 @@ import org.bukkit.event.player.PlayerSwapHandItemsEvent;
import
java.io.File
;
import
java.io.File
;
public
class
OffhandManager
extends
MCCosmeticsManager
<
Offhand
>
{
public
class
OffhandManager
extends
MCCosmeticsManager
<
Offhand
>
implements
HideableCosmetic
{
public
OffhandManager
(
MCCosmeticsPlugin
plugin
)
{
public
OffhandManager
(
MCCosmeticsPlugin
plugin
)
{
super
(
plugin
,
Offhand
.
class
);
super
(
plugin
,
Offhand
.
class
);
...
@@ -69,11 +70,27 @@ public class OffhandManager extends MCCosmeticsManager<Offhand> {
...
@@ -69,11 +70,27 @@ public class OffhandManager extends MCCosmeticsManager<Offhand> {
@Override
@Override
public
void
equip
(
CosmeticProfile
profile
)
{
public
void
equip
(
CosmeticProfile
profile
)
{
((
VolatileEquipmentHelper
)
getPlugin
().
getVolatileCodeHandler
().
getCosmeticHelper
(
Offhand
.
class
)
).
apply
(
profile
);
getHelper
(
).
apply
(
profile
);
}
}
@Override
@Override
public
void
unequip
(
CosmeticProfile
profile
)
{
public
void
unequip
(
CosmeticProfile
profile
)
{
((
VolatileEquipmentHelper
)
getPlugin
().
getVolatileCodeHandler
().
getCosmeticHelper
(
Offhand
.
class
)).
unapply
(
profile
);
getHelper
().
unapply
(
profile
);
}
@Override
public
void
hide
(
CosmeticProfile
profile
,
Cosmetic
request
)
{
if
(!(
request
instanceof
Gesture
))
return
;
getHelper
().
unapply
(
profile
);
}
@Override
public
void
show
(
CosmeticProfile
profile
)
{
getHelper
().
apply
(
profile
);
}
protected
VolatileEquipmentHelper
getHelper
()
{
return
(
VolatileEquipmentHelper
)
getNMSHelper
();
}
}
}
}
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/players/ProfileInventory.java
View file @
f595537f
...
@@ -22,7 +22,7 @@ public class ProfileInventory implements CosmeticInventory {
...
@@ -22,7 +22,7 @@ public class ProfileInventory implements CosmeticInventory {
@Getter
private
transient
CosmeticProfile
profile
;
@Getter
private
transient
CosmeticProfile
profile
;
private
transient
final
Map
<
Class
<?
extends
Cosmetic
>,
Cosmetic
>
equipped
=
Maps
.
newConcurrentMap
();
@Getter
private
transient
final
Map
<
Class
<?
extends
Cosmetic
>,
Cosmetic
>
equipped
=
Maps
.
newConcurrentMap
();
@Getter
private
final
Map
<
String
,
List
<
String
>>
unlockedCosmetics
=
Maps
.
newConcurrentMap
();
@Getter
private
final
Map
<
String
,
List
<
String
>>
unlockedCosmetics
=
Maps
.
newConcurrentMap
();
@Getter
private
final
Map
<
String
,
String
>
equippedCosmetics
=
Maps
.
newConcurrentMap
();
@Getter
private
final
Map
<
String
,
String
>
equippedCosmetics
=
Maps
.
newConcurrentMap
();
...
...
This diff is collapsed.
Click to expand it.
v1_18_R2/src/main/java/io/lumine/cosmetics/nms/VolatileCodeEnabled_v1_18_R2.java
View file @
f595537f
...
@@ -4,14 +4,12 @@ import com.google.common.collect.Maps;
...
@@ -4,14 +4,12 @@ import com.google.common.collect.Maps;
import
io.lumine.cosmetics.MCCosmeticsPlugin
;
import
io.lumine.cosmetics.MCCosmeticsPlugin
;
import
io.lumine.cosmetics.api.cosmetics.Cosmetic
;
import
io.lumine.cosmetics.api.cosmetics.Cosmetic
;
import
io.lumine.cosmetics.managers.back.BackAccessory
;
import
io.lumine.cosmetics.managers.back.BackAccessory
;
import
io.lumine.cosmetics.managers.gestures.Gesture
;
import
io.lumine.cosmetics.managers.hats.Hat
;
import
io.lumine.cosmetics.managers.hats.Hat
;
import
io.lumine.cosmetics.managers.offhand.Offhand
;
import
io.lumine.cosmetics.managers.offhand.Offhand
;
import
io.lumine.cosmetics.managers.sprays.Spray
;
import
io.lumine.cosmetics.managers.sprays.Spray
;
import
io.lumine.cosmetics.nms.cosmetic.VolatileCosmeticHelper
;
import
io.lumine.cosmetics.nms.cosmetic.VolatileCosmeticHelper
;
import
io.lumine.cosmetics.nms.v1_18_R2.cosmetic.VolatileBackImpl
;
import
io.lumine.cosmetics.nms.v1_18_R2.cosmetic.*
;
import
io.lumine.cosmetics.nms.v1_18_R2.cosmetic.VolatileHatImpl
;
import
io.lumine.cosmetics.nms.v1_18_R2.cosmetic.VolatileOffhandImpl
;
import
io.lumine.cosmetics.nms.v1_18_R2.cosmetic.VolatileSprayImpl
;
import
io.lumine.cosmetics.nms.v1_18_R2.network.VolatileChannelHandler
;
import
io.lumine.cosmetics.nms.v1_18_R2.network.VolatileChannelHandler
;
import
io.lumine.utils.reflection.Reflector
;
import
io.lumine.utils.reflection.Reflector
;
import
io.netty.channel.Channel
;
import
io.netty.channel.Channel
;
...
@@ -25,7 +23,6 @@ import net.minecraft.world.level.entity.PersistentEntitySectionManager;
...
@@ -25,7 +23,6 @@ import net.minecraft.world.level.entity.PersistentEntitySectionManager;
import
org.bukkit.Bukkit
;
import
org.bukkit.Bukkit
;
import
org.bukkit.World
;
import
org.bukkit.World
;
import
org.bukkit.craftbukkit.v1_18_R2.CraftWorld
;
import
org.bukkit.craftbukkit.v1_18_R2.CraftWorld
;
import
org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity
;
import
org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity
;
import
org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity
;
import
org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer
;
import
org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer
;
import
org.bukkit.entity.Entity
;
import
org.bukkit.entity.Entity
;
...
@@ -48,6 +45,7 @@ public class VolatileCodeEnabled_v1_18_R2 implements VolatileCodeHandler {
...
@@ -48,6 +45,7 @@ public class VolatileCodeEnabled_v1_18_R2 implements VolatileCodeHandler {
cosmeticHelpers
.
put
(
BackAccessory
.
class
,
new
VolatileBackImpl
(
plugin
,
this
));
cosmeticHelpers
.
put
(
BackAccessory
.
class
,
new
VolatileBackImpl
(
plugin
,
this
));
cosmeticHelpers
.
put
(
Spray
.
class
,
new
VolatileSprayImpl
(
plugin
,
this
));
cosmeticHelpers
.
put
(
Spray
.
class
,
new
VolatileSprayImpl
(
plugin
,
this
));
cosmeticHelpers
.
put
(
Offhand
.
class
,
new
VolatileOffhandImpl
(
plugin
,
this
));
cosmeticHelpers
.
put
(
Offhand
.
class
,
new
VolatileOffhandImpl
(
plugin
,
this
));
cosmeticHelpers
.
put
(
Gesture
.
class
,
new
VolatileGestureImpl
(
plugin
,
this
));
}
}
@Override
@Override
...
@@ -99,7 +97,7 @@ public class VolatileCodeEnabled_v1_18_R2 implements VolatileCodeHandler {
...
@@ -99,7 +97,7 @@ public class VolatileCodeEnabled_v1_18_R2 implements VolatileCodeHandler {
}
}
}
}
public
void
broadcastAround
(
Player
wearer
,
Packet
<?>...
packets
)
{
public
void
broadcastAround
AndSelf
(
Player
wearer
,
Packet
<?>...
packets
)
{
final
var
level
=
((
CraftWorld
)
wearer
.
getWorld
()).
getHandle
();
final
var
level
=
((
CraftWorld
)
wearer
.
getWorld
()).
getHandle
();
final
var
trackedEntity
=
level
.
getChunkSource
().
chunkMap
.
entityMap
.
get
(
wearer
.
getEntityId
());
final
var
trackedEntity
=
level
.
getChunkSource
().
chunkMap
.
entityMap
.
get
(
wearer
.
getEntityId
());
...
@@ -112,6 +110,19 @@ public class VolatileCodeEnabled_v1_18_R2 implements VolatileCodeHandler {
...
@@ -112,6 +110,19 @@ public class VolatileCodeEnabled_v1_18_R2 implements VolatileCodeHandler {
trackedEntity
.
broadcastAndSend
(
packet
);
trackedEntity
.
broadcastAndSend
(
packet
);
}
}
public
void
broadcastAround
(
Player
wearer
,
Packet
<?>...
packets
)
{
final
var
level
=
((
CraftWorld
)
wearer
.
getWorld
()).
getHandle
();
final
var
trackedEntity
=
level
.
getChunkSource
().
chunkMap
.
entityMap
.
get
(
wearer
.
getEntityId
());
if
(
trackedEntity
==
null
)
{
broadcast
(
wearer
.
getWorld
(),
packets
);
return
;
}
for
(
Packet
<?>
packet
:
packets
)
trackedEntity
.
broadcast
(
packet
);
}
public
void
broadcast
(
World
world
,
Packet
<?>...
packets
)
{
public
void
broadcast
(
World
world
,
Packet
<?>...
packets
)
{
for
(
Player
player
:
world
.
getPlayers
())
{
for
(
Player
player
:
world
.
getPlayers
())
{
var
connection
=
((
CraftPlayer
)
player
).
getHandle
().
connection
;
var
connection
=
((
CraftPlayer
)
player
).
getHandle
().
connection
;
...
...
This diff is collapsed.
Click to expand it.
v1_18_R2/src/main/java/io/lumine/cosmetics/nms/v1_18_R2/cosmetic/VolatileBackImpl.java
View file @
f595537f
...
@@ -26,7 +26,6 @@ import org.bukkit.entity.Player;
...
@@ -26,7 +26,6 @@ import org.bukkit.entity.Player;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.Optional
;
import
java.util.logging.Level
;
public
class
VolatileBackImpl
implements
VolatileEquipmentHelper
{
public
class
VolatileBackImpl
implements
VolatileEquipmentHelper
{
...
@@ -67,14 +66,14 @@ public class VolatileBackImpl implements VolatileEquipmentHelper {
...
@@ -67,14 +66,14 @@ public class VolatileBackImpl implements VolatileEquipmentHelper {
ClientboundSetEntityDataPacket
dataPacket
=
new
ClientboundSetEntityDataPacket
(
stand
.
getId
(),
stand
.
getEntityData
(),
true
);
ClientboundSetEntityDataPacket
dataPacket
=
new
ClientboundSetEntityDataPacket
(
stand
.
getId
(),
stand
.
getEntityData
(),
true
);
ClientboundSetPassengersPacket
passengersPacket
=
createPassengerPacket
(
player
.
getEntityId
(),
stand
.
getId
());
ClientboundSetPassengersPacket
passengersPacket
=
createPassengerPacket
(
player
.
getEntityId
(),
stand
.
getId
());
nmsHandler
.
broadcastAround
(
player
,
mobPacket
,
dataPacket
,
passengersPacket
);
nmsHandler
.
broadcastAround
AndSelf
(
player
,
mobPacket
,
dataPacket
,
passengersPacket
);
}
}
stand
.
setItemSlot
(
EquipmentSlot
.
HEAD
,
nmsBack
);
stand
.
setItemSlot
(
EquipmentSlot
.
HEAD
,
nmsBack
);
ClientboundSetEquipmentPacket
equipmentPacket
=
new
ClientboundSetEquipmentPacket
(
stand
.
getId
(),
List
.
of
(
Pair
.
of
(
EquipmentSlot
.
HEAD
,
nmsBack
)));
ClientboundSetEquipmentPacket
equipmentPacket
=
new
ClientboundSetEquipmentPacket
(
stand
.
getId
(),
List
.
of
(
Pair
.
of
(
EquipmentSlot
.
HEAD
,
nmsBack
)));
nmsHandler
.
broadcastAround
(
player
,
equipmentPacket
);
nmsHandler
.
broadcastAround
AndSelf
(
player
,
equipmentPacket
);
}
}
@Override
@Override
...
@@ -84,16 +83,16 @@ public class VolatileBackImpl implements VolatileEquipmentHelper {
...
@@ -84,16 +83,16 @@ public class VolatileBackImpl implements VolatileEquipmentHelper {
if
(
stand
==
null
)
if
(
stand
==
null
)
return
;
return
;
ClientboundRemoveEntitiesPacket
removePacket
=
new
ClientboundRemoveEntitiesPacket
(
stand
.
getId
());
ClientboundRemoveEntitiesPacket
removePacket
=
new
ClientboundRemoveEntitiesPacket
(
stand
.
getId
());
nmsHandler
.
broadcastAround
(
player
,
removePacket
);
nmsHandler
.
broadcastAround
AndSelf
(
player
,
removePacket
);
}
}
@Override
@Override
public
void
read
(
Player
sender
,
Object
packet
)
{
public
void
read
(
Player
sender
,
Object
packet
)
{
final
var
profile
=
MCCosmeticsPlugin
.
inst
().
getProfiles
().
getProfile
(
sender
);
if
(
packet
instanceof
ServerboundMovePlayerPacket
)
{
if
(
packet
instanceof
ServerboundMovePlayerPacket
)
{
final
var
profile
=
MCCosmeticsPlugin
.
inst
().
getProfiles
().
getProfile
(
sender
);
handleRotate
(
profile
);
handleRotate
(
profile
);
}
else
if
(
packet
instanceof
ServerboundAcceptTeleportationPacket
)
{
}
else
if
(
packet
instanceof
ServerboundAcceptTeleportationPacket
)
{
final
var
profile
=
MCCosmeticsPlugin
.
inst
().
getProfiles
().
getProfile
(
sender
);
final
var
list
=
handleSpawn
(
profile
);
final
var
list
=
handleSpawn
(
profile
);
if
(
list
==
null
)
if
(
list
==
null
)
return
;
return
;
...
@@ -133,7 +132,7 @@ public class VolatileBackImpl implements VolatileEquipmentHelper {
...
@@ -133,7 +132,7 @@ public class VolatileBackImpl implements VolatileEquipmentHelper {
final
var
stand
=
activeProfile
.
get
(
wearer
);
final
var
stand
=
activeProfile
.
get
(
wearer
);
ClientboundRotateHeadPacket
packet
=
new
ClientboundRotateHeadPacket
(
stand
,
VolatileEquipmentHelper
.
toByte
(
nmsPlayer
.
getYRot
()));
ClientboundRotateHeadPacket
packet
=
new
ClientboundRotateHeadPacket
(
stand
,
VolatileEquipmentHelper
.
toByte
(
nmsPlayer
.
getYRot
()));
nmsHandler
.
broadcastAround
(
wearer
,
packet
);
nmsHandler
.
broadcastAround
AndSelf
(
wearer
,
packet
);
}
}
private
List
<
Object
>
handleSpawn
(
Profile
profile
)
{
private
List
<
Object
>
handleSpawn
(
Profile
profile
)
{
...
...
This diff is collapsed.
Click to expand it.
v1_18_R2/src/main/java/io/lumine/cosmetics/nms/v1_18_R2/cosmetic/VolatileGestureImpl.java
0 → 100644
View file @
f595537f
package
io.lumine.cosmetics.nms.v1_18_R2.cosmetic
;
import
com.google.common.collect.Sets
;
import
com.mojang.datafixers.util.Pair
;
import
io.lumine.cosmetics.MCCosmeticsPlugin
;
import
io.lumine.cosmetics.api.cosmetics.Cosmetic
;
import
io.lumine.cosmetics.api.cosmetics.manager.HideableCosmetic
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
io.lumine.cosmetics.managers.gestures.Gesture
;
import
io.lumine.cosmetics.managers.gestures.GestureManager
;
import
io.lumine.cosmetics.managers.gestures.QuitMethod
;
import
io.lumine.cosmetics.nms.VolatileCodeEnabled_v1_18_R2
;
import
io.lumine.cosmetics.nms.cosmetic.VolatileEquipmentHelper
;
import
io.netty.buffer.Unpooled
;
import
lombok.Getter
;
import
net.minecraft.network.FriendlyByteBuf
;
import
net.minecraft.network.protocol.game.*
;
import
net.minecraft.world.entity.EntityType
;
import
net.minecraft.world.entity.EquipmentSlot
;
import
net.minecraft.world.entity.animal.horse.Horse
;
import
net.minecraft.world.item.ItemStack
;
import
org.bukkit.attribute.Attribute
;
import
org.bukkit.craftbukkit.v1_18_R2.CraftWorld
;
import
org.bukkit.craftbukkit.v1_18_R2.attribute.CraftAttributeMap
;
import
org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer
;
import
org.bukkit.entity.Player
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Set
;
public
class
VolatileGestureImpl
implements
VolatileEquipmentHelper
{
private
static
final
List
<
Pair
<
EquipmentSlot
,
ItemStack
>>
empty
=
new
ArrayList
<>();
static
{
for
(
final
var
slot
:
EquipmentSlot
.
values
())
empty
.
add
(
Pair
.
of
(
slot
,
ItemStack
.
EMPTY
));
}
@Getter
private
final
MCCosmeticsPlugin
plugin
;
private
final
VolatileCodeEnabled_v1_18_R2
nmsHandler
;
private
final
Set
<
Player
>
activeProfile
=
Sets
.
newConcurrentHashSet
();
private
Horse
horse
;
public
VolatileGestureImpl
(
MCCosmeticsPlugin
plugin
,
VolatileCodeEnabled_v1_18_R2
nmsHandler
)
{
this
.
plugin
=
plugin
;
this
.
nmsHandler
=
nmsHandler
;
}
@Override
public
void
apply
(
CosmeticProfile
profile
)
{
if
(
profile
==
null
)
return
;
Player
player
=
profile
.
getPlayer
();
if
(
activeProfile
.
contains
(
player
))
return
;
Optional
<
Cosmetic
>
cosmetic
=
profile
.
getCosmeticInventory
().
getEquipped
(
Gesture
.
class
);
if
(
cosmetic
.
isEmpty
()
||
!(
cosmetic
.
get
()
instanceof
Gesture
gesture
))
return
;
getHorsed
(
player
);
player
.
setInvisible
(
true
);
for
(
final
var
value
:
profile
.
getCosmeticInventory
().
getEquipped
().
values
())
{
final
var
manager
=
value
.
getManager
();
if
(!(
manager
instanceof
HideableCosmetic
hide
))
continue
;
hide
.
hide
(
profile
,
gesture
);
}
}
@Override
public
void
unapply
(
CosmeticProfile
profile
)
{
if
(
profile
==
null
)
return
;
Player
player
=
profile
.
getPlayer
();
if
(!
activeProfile
.
contains
(
player
))
return
;
activeProfile
.
remove
(
player
);
nmsHandler
.
broadcast
(
player
,
new
ClientboundRemoveEntitiesPacket
(
horse
.
getId
()));
player
.
setInvisible
(
false
);
for
(
final
var
value
:
profile
.
getCosmeticInventory
().
getEquipped
().
values
())
{
final
var
manager
=
value
.
getManager
();
if
(!(
manager
instanceof
HideableCosmetic
hide
))
continue
;
hide
.
show
(
profile
);
}
}
private
ClientboundSetPassengersPacket
createPassengerPacket
(
int
mount
,
int
...
driver
)
{
FriendlyByteBuf
bb
=
new
FriendlyByteBuf
(
Unpooled
.
buffer
());
bb
.
writeVarInt
(
mount
);
bb
.
writeVarIntArray
(
driver
);
return
new
ClientboundSetPassengersPacket
(
bb
);
}
private
void
getHorsed
(
Player
player
)
{
final
var
nmsPlayer
=
((
CraftPlayer
)
player
).
getHandle
();
if
(
horse
==
null
)
{
horse
=
new
Horse
(
EntityType
.
HORSE
,
((
CraftWorld
)
player
.
getWorld
()).
getHandle
());
horse
.
setInvisible
(
true
);
horse
.
setHealth
(
0
);
horse
.
getAttribute
(
CraftAttributeMap
.
toMinecraft
(
Attribute
.
GENERIC_MAX_HEALTH
)).
setBaseValue
(
0
);
}
horse
.
setPos
(
nmsPlayer
.
getX
(),
nmsPlayer
.
getY
()
-
horse
.
getPassengersRidingOffset
()
-
nmsPlayer
.
getMyRidingOffset
(),
nmsPlayer
.
getZ
());
activeProfile
.
add
(
player
);
ClientboundAddMobPacket
mobPacket
=
new
ClientboundAddMobPacket
(
horse
);
ClientboundSetEntityDataPacket
dataPacket
=
new
ClientboundSetEntityDataPacket
(
horse
.
getId
(),
horse
.
getEntityData
(),
true
);
ClientboundUpdateAttributesPacket
attributesPacket
=
new
ClientboundUpdateAttributesPacket
(
horse
.
getId
(),
horse
.
getAttributes
().
getSyncableAttributes
());
ClientboundSetPassengersPacket
passengersPacket
=
createPassengerPacket
(
horse
.
getId
(),
nmsPlayer
.
getId
());
nmsHandler
.
broadcast
(
player
,
mobPacket
,
dataPacket
,
attributesPacket
,
passengersPacket
);
}
@Override
public
void
read
(
Player
sender
,
Object
packet
)
{
final
var
profile
=
MCCosmeticsPlugin
.
inst
().
getProfiles
().
getProfile
(
sender
);
if
(
profile
==
null
)
return
;
final
var
opt
=
profile
.
getCosmeticInventory
().
getEquipped
(
Gesture
.
class
);
if
(
opt
.
isEmpty
()
||
!(
opt
.
get
()
instanceof
Gesture
gesture
))
return
;
if
(
packet
instanceof
ServerboundPlayerInputPacket
inputPacket
)
{
final
var
manager
=
(
GestureManager
)
gesture
.
getManager
();
if
(
inputPacket
.
isShiftKeyDown
())
manager
.
quit
(
sender
,
QuitMethod
.
SNEAK
);
if
(
inputPacket
.
isJumping
())
manager
.
quit
(
sender
,
QuitMethod
.
JUMP
);
}
}
}
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 @
f595537f
...
@@ -52,7 +52,7 @@ public class VolatileHatImpl implements VolatileEquipmentHelper {
...
@@ -52,7 +52,7 @@ public class VolatileHatImpl implements VolatileEquipmentHelper {
ClientboundSetEquipmentPacket
equipmentPacket
=
new
ClientboundSetEquipmentPacket
(
player
.
getEntityId
(),
List
.
of
(
Pair
.
of
(
EquipmentSlot
.
HEAD
,
nmsHat
)));
ClientboundSetEquipmentPacket
equipmentPacket
=
new
ClientboundSetEquipmentPacket
(
player
.
getEntityId
(),
List
.
of
(
Pair
.
of
(
EquipmentSlot
.
HEAD
,
nmsHat
)));
nmsHandler
.
broadcastAround
(
player
,
equipmentPacket
);
nmsHandler
.
broadcastAround
AndSelf
(
player
,
equipmentPacket
);
}
}
...
@@ -60,10 +60,8 @@ public class VolatileHatImpl implements VolatileEquipmentHelper {
...
@@ -60,10 +60,8 @@ public class VolatileHatImpl implements VolatileEquipmentHelper {
public
void
unapply
(
CosmeticProfile
profile
)
{
public
void
unapply
(
CosmeticProfile
profile
)
{
final
var
nmsPlayer
=
((
CraftPlayer
)
profile
.
getPlayer
()).
getHandle
();
final
var
nmsPlayer
=
((
CraftPlayer
)
profile
.
getPlayer
()).
getHandle
();
final
var
item
=
nmsPlayer
.
getItemBySlot
(
EquipmentSlot
.
HEAD
);
final
var
item
=
nmsPlayer
.
getItemBySlot
(
EquipmentSlot
.
HEAD
);
if
(
item
==
ItemStack
.
EMPTY
)
return
;
ClientboundSetEquipmentPacket
equipmentPacket
=
new
ClientboundSetEquipmentPacket
(
nmsPlayer
.
getId
(),
List
.
of
(
Pair
.
of
(
EquipmentSlot
.
HEAD
,
item
)));
ClientboundSetEquipmentPacket
equipmentPacket
=
new
ClientboundSetEquipmentPacket
(
nmsPlayer
.
getId
(),
List
.
of
(
Pair
.
of
(
EquipmentSlot
.
HEAD
,
item
)));
nmsHandler
.
broadcastAround
(
nmsPlayer
.
getBukkitEntity
(),
equipmentPacket
);
nmsHandler
.
broadcastAround
AndSelf
(
nmsPlayer
.
getBukkitEntity
(),
equipmentPacket
);
}
}
@Override
@Override
...
...
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 @
f595537f
...
@@ -53,7 +53,7 @@ public class VolatileOffhandImpl implements VolatileEquipmentHelper {
...
@@ -53,7 +53,7 @@ public class VolatileOffhandImpl implements VolatileEquipmentHelper {
ClientboundSetEquipmentPacket
equipmentPacket
=
new
ClientboundSetEquipmentPacket
(
player
.
getEntityId
(),
List
.
of
(
Pair
.
of
(
EquipmentSlot
.
OFFHAND
,
nmsOffhand
)));
ClientboundSetEquipmentPacket
equipmentPacket
=
new
ClientboundSetEquipmentPacket
(
player
.
getEntityId
(),
List
.
of
(
Pair
.
of
(
EquipmentSlot
.
OFFHAND
,
nmsOffhand
)));
nmsHandler
.
broadcastAround
(
player
,
equipmentPacket
);
nmsHandler
.
broadcastAround
AndSelf
(
player
,
equipmentPacket
);
}
}
...
@@ -61,10 +61,8 @@ public class VolatileOffhandImpl implements VolatileEquipmentHelper {
...
@@ -61,10 +61,8 @@ public class VolatileOffhandImpl implements VolatileEquipmentHelper {
public
void
unapply
(
CosmeticProfile
profile
)
{
public
void
unapply
(
CosmeticProfile
profile
)
{
final
var
nmsPlayer
=
((
CraftPlayer
)
profile
.
getPlayer
()).
getHandle
();
final
var
nmsPlayer
=
((
CraftPlayer
)
profile
.
getPlayer
()).
getHandle
();
final
var
item
=
nmsPlayer
.
getItemBySlot
(
EquipmentSlot
.
OFFHAND
);
final
var
item
=
nmsPlayer
.
getItemBySlot
(
EquipmentSlot
.
OFFHAND
);
if
(
item
==
ItemStack
.
EMPTY
)
return
;
ClientboundSetEquipmentPacket
equipmentPacket
=
new
ClientboundSetEquipmentPacket
(
nmsPlayer
.
getId
(),
List
.
of
(
Pair
.
of
(
EquipmentSlot
.
OFFHAND
,
item
)));
ClientboundSetEquipmentPacket
equipmentPacket
=
new
ClientboundSetEquipmentPacket
(
nmsPlayer
.
getId
(),
List
.
of
(
Pair
.
of
(
EquipmentSlot
.
OFFHAND
,
item
)));
nmsHandler
.
broadcastAround
(
nmsPlayer
.
getBukkitEntity
(),
equipmentPacket
);
nmsHandler
.
broadcastAround
AndSelf
(
nmsPlayer
.
getBukkitEntity
(),
equipmentPacket
);
}
}
@Override
@Override
...
...
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