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
cb3f5667
Commit
cb3f5667
authored
3 years ago
by
Ticxo
Browse files
Options
Download
Email Patches
Plain Diff
Somemore
parent
97b42c7c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
107 additions
and
8 deletions
+107
-8
api/src/main/java/io/lumine/cosmetics/api/players/CosmeticProfile.java
...java/io/lumine/cosmetics/api/players/CosmeticProfile.java
+2
-0
plugin/src/main/java/io/lumine/cosmetics/managers/gestures/CustomPlayerModel.java
...lumine/cosmetics/managers/gestures/CustomPlayerModel.java
+40
-0
plugin/src/main/java/io/lumine/cosmetics/managers/gestures/Gesture.java
...n/java/io/lumine/cosmetics/managers/gestures/Gesture.java
+29
-5
plugin/src/main/java/io/lumine/cosmetics/managers/gestures/GestureManager.java
...io/lumine/cosmetics/managers/gestures/GestureManager.java
+26
-3
plugin/src/main/java/io/lumine/cosmetics/managers/gestures/QuitMethod.java
...ava/io/lumine/cosmetics/managers/gestures/QuitMethod.java
+5
-0
plugin/src/main/java/io/lumine/cosmetics/players/Profile.java
...in/src/main/java/io/lumine/cosmetics/players/Profile.java
+5
-0
No files found.
api/src/main/java/io/lumine/cosmetics/api/players/CosmeticProfile.java
View file @
cb3f5667
...
...
@@ -18,6 +18,8 @@ public interface CosmeticProfile {
public
boolean
has
(
Cosmetic
cosmetic
);
public
void
equip
(
Cosmetic
cosmetic
);
public
void
unequip
(
Cosmetic
cosmetic
);
public
boolean
isEquipped
(
Cosmetic
cosmetic
);
...
...
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/managers/gestures/CustomPlayerModel.java
0 → 100644
View file @
cb3f5667
package
io.lumine.cosmetics.managers.gestures
;
import
com.ticxo.playeranimator.api.model.player.PlayerModel
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
lombok.Getter
;
import
org.bukkit.entity.Player
;
public
class
CustomPlayerModel
extends
PlayerModel
{
@Getter
private
final
QuitMethod
quitMethod
;
private
final
Runnable
onEnd
;
private
boolean
isPlaying
;
public
CustomPlayerModel
(
Player
player
,
QuitMethod
quitMethod
,
Runnable
onEnd
)
{
super
(
player
);
this
.
quitMethod
=
quitMethod
;
this
.
onEnd
=
onEnd
;
}
public
void
stopAnimation
(
QuitMethod
method
)
{
isPlaying
=
method
==
null
||
quitMethod
!=
method
;
}
@Override
public
void
playAnimation
(
String
name
)
{
super
.
playAnimation
(
name
);
isPlaying
=
true
;
}
@Override
public
boolean
update
()
{
boolean
update
=
super
.
update
();
if
(!
update
||
!
isPlaying
)
{
onEnd
.
run
();
return
false
;
}
return
true
;
}
}
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/managers/gestures/Gesture.java
View file @
cb3f5667
package
io.lumine.cosmetics.managers.gestures
;
import
com.google.common.collect.Lists
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
io.lumine.cosmetics.commands.CommandHelper
;
import
io.lumine.cosmetics.config.Scope
;
import
io.lumine.cosmetics.constants.CosmeticType
;
import
io.lumine.cosmetics.managers.AbstractCosmetic
;
...
...
@@ -9,9 +11,12 @@ import io.lumine.utils.config.properties.types.BooleanProp;
import
io.lumine.utils.config.properties.types.EnumProp
;
import
io.lumine.utils.config.properties.types.StringProp
;
import
io.lumine.utils.menu.Icon
;
import
io.lumine.utils.menu.IconBuilder
;
import
io.lumine.utils.text.Text
;
import
lombok.Getter
;
import
java.io.File
;
import
java.util.List
;
public
class
Gesture
extends
AbstractCosmetic
{
...
...
@@ -21,14 +26,14 @@ public class Gesture extends AbstractCosmetic {
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
FORCE_LOOP
=
Property
.
Boolean
(
Scope
.
NONE
,
"CanLook"
,
false
);
private
static
final
EnumProp
<
Quit
Control
>
QUIT_CONTROL
=
Property
.
Enum
(
Scope
.
NONE
,
Quit
Control
.
class
,
"QuitControl"
,
Quit
Control
.
SNEAK
);
private
static
final
EnumProp
<
Quit
Method
>
QUIT_CONTROL
=
Property
.
Enum
(
Scope
.
NONE
,
Quit
Method
.
class
,
"QuitControl"
,
Quit
Method
.
SNEAK
);
@Getter
private
final
String
defaultGesture
;
@Getter
private
final
String
slimGesture
;
@Getter
private
final
boolean
canMove
;
@Getter
private
final
boolean
canLook
;
@Getter
private
final
boolean
forceLoop
;
@Getter
private
final
Quit
Control
quitControl
;
@Getter
private
final
Quit
Method
quitMethod
;
public
Gesture
(
GestureManager
manager
,
File
file
,
String
key
)
{
super
(
manager
,
file
,
CosmeticType
.
type
(
Gesture
.
class
),
key
);
...
...
@@ -43,7 +48,7 @@ public class Gesture extends AbstractCosmetic {
canMove
=
CAN_MOVE
.
fget
(
file
,
this
);
canLook
=
CAN_LOOK
.
fget
(
file
,
this
);
forceLoop
=
FORCE_LOOP
.
fget
(
file
,
this
);
quit
Control
=
QUIT_CONTROL
.
fget
(
file
,
this
);
quit
Method
=
QUIT_CONTROL
.
fget
(
file
,
this
);
}
@Override
...
...
@@ -53,7 +58,26 @@ public class Gesture extends AbstractCosmetic {
@Override
public
Icon
<
CosmeticProfile
>
getIcon
()
{
return
buildIcon
(
"gesture"
);
return
IconBuilder
.<
CosmeticProfile
>
create
()
.
name
(
Text
.
colorize
(
this
.
getDisplay
()))
.
item
(
this
.
menuItem
)
.
hideFlags
()
.
lore
(
prof
->
{
List
<
String
>
desc
=
Lists
.
newArrayList
(
description
);
if
(!
prof
.
has
(
this
))
{
desc
.
add
(
""
);
desc
.
add
(
Text
.
colorizeLegacy
(
"<red>Not Unlocked"
));
}
return
desc
;
})
.
click
((
prof
,
p
)
->
{
if
(
prof
.
getPlayer
().
isOp
()
||
prof
.
has
(
this
))
{
prof
.
equip
(
this
);
CommandHelper
.
sendSuccess
(
p
,
"Now playing gesture: "
+
getDisplay
());
p
.
closeInventory
();
}
else
{
CommandHelper
.
sendError
(
p
,
"You haven't unlocked that hat yet!"
);
}
}).
build
();
}
}
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/managers/gestures/GestureManager.java
View file @
cb3f5667
package
io.lumine.cosmetics.managers.gestures
;
import
com.destroystokyo.paper.event.player.PlayerJumpEvent
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.ticxo.playeranimator.api.PlayerAnimator
;
import
com.ticxo.playeranimator.api.model.player.PlayerModel
;
import
io.lumine.cosmetics.MCCosmeticsPlugin
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
io.lumine.cosmetics.constants.CosmeticType
;
import
io.lumine.cosmetics.managers.MCCosmeticsManager
;
import
io.lumine.utils.Events
;
import
io.lumine.utils.files.Files
;
import
org.bukkit.entity.Player
;
import
org.bukkit.event.player.PlayerQuitEvent
;
import
org.bukkit.event.player.PlayerToggleSneakEvent
;
import
java.io.File
;
import
java.util.Map
;
public
class
GestureManager
extends
MCCosmeticsManager
<
Gesture
>
{
private
final
Map
<
Player
,
CustomPlayerModel
>
ticking
=
Maps
.
newConcurrentMap
();
public
GestureManager
(
MCCosmeticsPlugin
plugin
)
{
super
(
plugin
,
Gesture
.
class
);
...
...
@@ -23,6 +31,18 @@ public class GestureManager extends MCCosmeticsManager<Gesture> {
public
void
load
(
MCCosmeticsPlugin
plugin
)
{
loadGestures
();
super
.
load
(
plugin
);
Events
.
subscribe
(
PlayerToggleSneakEvent
.
class
).
handler
(
event
->
quit
(
event
.
getPlayer
(),
QuitMethod
.
SNEAK
)).
bindWith
(
this
);
Events
.
subscribe
(
PlayerJumpEvent
.
class
).
handler
(
event
->
quit
(
event
.
getPlayer
(),
QuitMethod
.
JUMP
)).
bindWith
(
this
);
Events
.
subscribe
(
PlayerQuitEvent
.
class
).
handler
(
event
->
quit
(
event
.
getPlayer
(),
null
)).
bindWith
(
this
);
}
public
void
quit
(
Player
player
,
QuitMethod
method
)
{
if
(!
ticking
.
containsKey
(
player
))
return
;
final
var
model
=
ticking
.
get
(
player
);
model
.
stopAnimation
(
method
);
}
@Override
...
...
@@ -37,14 +57,17 @@ public class GestureManager extends MCCosmeticsManager<Gesture> {
return
;
final
var
player
=
profile
.
getPlayer
();
PlayerModel
model
=
new
PlayerModel
(
player
);
CustomPlayerModel
model
=
new
CustomPlayerModel
(
player
,
gesture
.
getQuitMethod
(),
()
->
{
profile
.
unequip
(
gesture
);
});
ticking
.
put
(
player
,
model
);
final
var
animation
=
model
.
getTexture
().
isSlim
()
?
gesture
.
getSlimGesture
()
:
gesture
.
getDefaultGesture
();
model
.
playAnimation
(
animation
);
}
@Override
public
void
unequip
(
CosmeticProfile
profile
)
{
ticking
.
remove
(
profile
.
getPlayer
());
}
private
void
loadGestures
()
{
...
...
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/managers/gestures/Quit
Control
.java
→
plugin/src/main/java/io/lumine/cosmetics/managers/gestures/Quit
Method
.java
View file @
cb3f5667
package
io.lumine.cosmetics.managers.gestures
;
public
enum
Quit
Control
{
SNEAK
,
JUMP
,
LEFT_CLICK
,
RIGHT_CLICK
public
enum
Quit
Method
{
SNEAK
,
JUMP
}
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/players/Profile.java
View file @
cb3f5667
...
...
@@ -39,6 +39,11 @@ public class Profile implements CosmeticProfile,io.lumine.utils.storage.players.
cosmeticInventory
.
equip
(
cosmetic
);
}
@Override
public
void
unequip
(
Cosmetic
cosmetic
)
{
cosmeticInventory
.
unequip
(
cosmetic
.
getClass
());
}
@Override
public
boolean
isEquipped
(
Cosmetic
cosmetic
)
{
return
cosmeticInventory
.
isEquipped
(
cosmetic
);
...
...
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