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
835d14ad
Commit
835d14ad
authored
2 years ago
by
Ashijin
Browse files
Options
Download
Email Patches
Plain Diff
Fixed several issues with gestures
parent
2880853f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
20 deletions
+41
-20
plugin/src/main/java/io/lumine/cosmetics/commands/EmotesCommand.java
...main/java/io/lumine/cosmetics/commands/EmotesCommand.java
+12
-5
plugin/src/main/java/io/lumine/cosmetics/managers/gestures/Gesture.java
...n/java/io/lumine/cosmetics/managers/gestures/Gesture.java
+1
-0
plugin/src/main/java/io/lumine/cosmetics/managers/gestures/GestureManager.java
...io/lumine/cosmetics/managers/gestures/GestureManager.java
+28
-15
No files found.
plugin/src/main/java/io/lumine/cosmetics/commands/EmotesCommand.java
View file @
835d14ad
...
...
@@ -4,6 +4,7 @@ import io.lumine.cosmetics.MCCosmeticsPlugin;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
io.lumine.cosmetics.constants.Permissions
;
import
io.lumine.cosmetics.managers.gestures.Gesture
;
import
io.lumine.cosmetics.managers.gestures.GestureManager
;
import
io.lumine.cosmetics.players.Profile
;
import
io.lumine.utils.commands.Command
;
import
org.bukkit.command.CommandSender
;
...
...
@@ -22,16 +23,22 @@ public class EmotesCommand extends Command<MCCosmeticsPlugin> {
@Override
public
boolean
onCommand
(
CommandSender
commandSender
,
String
[]
strings
)
{
if
(
strings
.
length
==
0
){
if
(
strings
.
length
==
0
)
{
CommandHelper
.
sendError
(
commandSender
,
"Syntax: /emote [emote_name]"
);
return
false
;
}
Optional
<
Profile
>
p
rofile
=
plugin
.
getProfiles
().
getProfile
(((
Player
)
commandSender
).
getName
());
Optional
<
Profile
>
maybeP
rofile
=
plugin
.
getProfiles
().
getProfile
(((
Player
)
commandSender
).
getName
());
var
cosmetic
=
getPlugin
().
getGestureManager
().
getCosmetic
(
strings
[
0
]);
maybeProfile
.
ifPresent
(
profile
->
{
var
maybeCosmetic
=
getPlugin
().
getGestureManager
().
getCosmetic
(
strings
[
0
]);
maybeCosmetic
.
ifPresent
(
gesture
->
{
gesture
.
equip
(
profile
);
((
GestureManager
)
gesture
.
getManager
()).
playGesture
(
profile
);
});
});
profile
.
ifPresent
(
value
->
cosmetic
.
ifPresent
(
gesture
->
gesture
.
equip
(
value
)));
/**TODO: Make it silently tell you if you only typed /emote instead of erroring **/
return
true
;
}
...
...
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/managers/gestures/Gesture.java
View file @
835d14ad
...
...
@@ -70,6 +70,7 @@ public class Gesture extends AbstractCosmetic {
.
click
((
prof
,
p
)
->
{
if
(
prof
.
getPlayer
().
isOp
()
||
prof
.
has
(
this
))
{
prof
.
equip
(
this
);
((
GestureManager
)
getManager
()).
playGesture
(
prof
);
CommandHelper
.
sendSuccess
(
p
,
"Now playing gesture: "
+
getDisplay
());
p
.
closeInventory
();
}
else
{
...
...
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/managers/gestures/GestureManager.java
View file @
835d14ad
...
...
@@ -58,7 +58,21 @@ public class GestureManager extends MCCosmeticsManager<Gesture> {
@Override
public
void
equip
(
CosmeticProfile
profile
)
{
// Gestures aren't really equipped
}
@Override
public
void
unequip
(
CosmeticProfile
profile
)
{
stopGesture
(
profile
);
}
public
void
playGesture
(
CosmeticProfile
profile
)
{
if
(
ticking
.
containsKey
(
profile
.
getPlayer
()))
{
return
;
}
final
var
maybeEquipped
=
profile
.
getEquipped
(
Gesture
.
class
);
if
(
maybeEquipped
.
isEmpty
())
{
return
;
}
...
...
@@ -68,26 +82,25 @@ public class GestureManager extends MCCosmeticsManager<Gesture> {
return
;
}
final
var
player
=
profile
.
getPlayer
();
CustomPlayerModel
model
=
new
CustomPlayerModel
(
player
,
gesture
.
getQuitMethod
(),
gesture
.
isCanLook
(),
()
->
profile
.
unequip
(
gesture
));
ticking
.
put
(
player
,
model
);
final
var
animation
=
model
.
getTexture
().
isSlim
()
?
gesture
.
getSlimGesture
()
:
gesture
.
getDefaultGesture
();
model
.
playAnimation
(
animation
);
final
var
player
=
profile
.
getPlayer
();
CustomPlayerModel
model
=
new
CustomPlayerModel
(
player
,
gesture
.
getQuitMethod
(),
gesture
.
isCanLook
(),
()
->
profile
.
unequip
(
gesture
));
ticking
.
put
(
player
,
model
);
final
var
animation
=
model
.
getTexture
().
isSlim
()
?
gesture
.
getSlimGesture
()
:
gesture
.
getDefaultGesture
();
model
.
playAnimation
(
animation
);
((
VolatileEquipmentHelper
)
getNMSHelper
()).
apply
(
profile
);
((
VolatileEquipmentHelper
)
getNMSHelper
()).
apply
(
profile
);
}
@Override
public
void
unequip
(
CosmeticProfile
profile
)
{
CustomPlayerModel
model
=
ticking
.
remove
(
profile
.
getPlayer
());
if
(
model
==
null
)
return
;
model
.
despawn
();
((
VolatileEquipmentHelper
)
getNMSHelper
()).
unapply
(
profile
);
public
void
stopGesture
(
CosmeticProfile
profile
)
{
CustomPlayerModel
model
=
ticking
.
remove
(
profile
.
getPlayer
());
if
(
model
==
null
)
{
return
;
}
model
.
despawn
();
((
VolatileEquipmentHelper
)
getNMSHelper
()).
unapply
(
profile
);
}
private
void
loadGestures
()
{
PlayerAnimator
.
api
.
getAnimationManager
().
clearRegistry
();
final
String
type
=
CosmeticType
.
folder
(
cosmeticClass
);
...
...
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