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
0bdf5933
Commit
0bdf5933
authored
3 years ago
by
Ashijin
Browse files
Options
Download
Email Patches
Plain Diff
bwabwabwabwa
parent
ad00a6d2
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
407 additions
and
21 deletions
+407
-21
api/src/main/java/io/lumine/cosmetics/api/cosmetics/Cosmetic.java
...main/java/io/lumine/cosmetics/api/cosmetics/Cosmetic.java
+13
-0
api/src/main/java/io/lumine/cosmetics/api/events/CosmeticPlayerLoadedEvent.java
...umine/cosmetics/api/events/CosmeticPlayerLoadedEvent.java
+42
-0
api/src/main/java/io/lumine/cosmetics/api/players/CosmeticProfile.java
...java/io/lumine/cosmetics/api/players/CosmeticProfile.java
+10
-0
api/src/main/java/io/lumine/cosmetics/api/players/CosmeticProfileManager.java
.../lumine/cosmetics/api/players/CosmeticProfileManager.java
+5
-0
plugin/src/main/java/io/lumine/cosmetics/MCCosmeticsPlugin.java
.../src/main/java/io/lumine/cosmetics/MCCosmeticsPlugin.java
+3
-1
plugin/src/main/java/io/lumine/cosmetics/managers/hats/Hat.java
.../src/main/java/io/lumine/cosmetics/managers/hats/Hat.java
+111
-0
plugin/src/main/java/io/lumine/cosmetics/managers/hats/HatManager.java
...in/java/io/lumine/cosmetics/managers/hats/HatManager.java
+103
-5
plugin/src/main/java/io/lumine/cosmetics/nms/VolatileCodeDisabled.java
...in/java/io/lumine/cosmetics/nms/VolatileCodeDisabled.java
+5
-0
plugin/src/main/java/io/lumine/cosmetics/nms/VolatileCodeHandler.java
...ain/java/io/lumine/cosmetics/nms/VolatileCodeHandler.java
+1
-0
plugin/src/main/java/io/lumine/cosmetics/nms/VolatileHatHelper.java
.../main/java/io/lumine/cosmetics/nms/VolatileHatHelper.java
+9
-0
plugin/src/main/java/io/lumine/cosmetics/players/Profile.java
...in/src/main/java/io/lumine/cosmetics/players/Profile.java
+4
-4
plugin/src/main/java/io/lumine/cosmetics/players/ProfileManager.java
...main/java/io/lumine/cosmetics/players/ProfileManager.java
+9
-6
pom.xml
pom.xml
+3
-4
v1_18/pom.xml
v1_18/pom.xml
+17
-1
v1_18/src/main/java/io/lumine/cosmetics/nms/v1_18_R1/VolatileHatImpl.java
...ava/io/lumine/cosmetics/nms/v1_18_R1/VolatileHatImpl.java
+72
-0
No files found.
api/src/main/java/io/lumine/cosmetics/api/cosmetics/Cosmetic.java
0 → 100644
View file @
0bdf5933
package
io.lumine.cosmetics.api.cosmetics
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
public
interface
Cosmetic
{
public
boolean
has
(
CosmeticProfile
profile
);
public
boolean
equip
(
CosmeticProfile
profile
);
public
boolean
isEquipped
(
CosmeticProfile
profile
);
}
This diff is collapsed.
Click to expand it.
api/src/main/java/io/lumine/cosmetics/api/events/CosmeticPlayerLoadedEvent.java
0 → 100644
View file @
0bdf5933
package
io.lumine.cosmetics.api.events
;
import
org.bukkit.entity.Player
;
import
org.bukkit.event.Event
;
import
org.bukkit.event.HandlerList
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
lombok.Getter
;
public
class
CosmeticPlayerLoadedEvent
extends
Event
{
@Getter
private
final
Player
player
;
@Getter
private
final
CosmeticProfile
profile
;
public
CosmeticPlayerLoadedEvent
(
Player
player
,
CosmeticProfile
profile
)
{
super
(
false
);
this
.
player
=
player
;
this
.
profile
=
profile
;
}
/*
* Standard event stuff
*/
private
static
final
HandlerList
handlers
=
new
HandlerList
();
private
boolean
canceled
=
false
;
public
void
setCancelled
(
boolean
bool
)
{
this
.
canceled
=
bool
;
}
public
boolean
isCancelled
()
{
return
this
.
canceled
;
}
public
HandlerList
getHandlers
()
{
return
handlers
;
}
public
static
HandlerList
getHandlerList
()
{
return
handlers
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
api/src/main/java/io/lumine/cosmetics/api/players/CosmeticProfile.java
0 → 100644
View file @
0bdf5933
package
io.lumine.cosmetics.api.players
;
import
java.util.UUID
;
public
interface
CosmeticProfile
{
public
UUID
getUniqueId
();
public
String
getName
();
}
This diff is collapsed.
Click to expand it.
api/src/main/java/io/lumine/cosmetics/api/players/CosmeticProfileManager.java
0 → 100644
View file @
0bdf5933
package
io.lumine.cosmetics.api.players
;
public
interface
CosmeticProfileManager
{
}
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/MCCosmeticsPlugin.java
View file @
0bdf5933
package
io.lumine.cosmetics
;
import
org.bukkit.Bukkit
;
import
io.lumine.cosmetics.api.MCCosmetics
;
import
io.lumine.cosmetics.commands.BaseCommand
;
import
io.lumine.cosmetics.commands.admin.AdminCommand
;
import
io.lumine.cosmetics.compat.CompatibilityManager
;
...
...
@@ -142,7 +144,7 @@ public class MCCosmeticsPlugin extends LuminePlugin {
try
{
final
Class
<?>
clazz
=
Class
.
forName
(
"io.lumine.cosmetics.nms.VolatileCodeEnabled_"
+
version
);
if
(
VolatileCodeHandler
.
class
.
isAssignableFrom
(
clazz
))
{
VCH
=
(
VolatileCodeHandler
)
clazz
.
getConstructor
().
newInstance
();
VCH
=
(
VolatileCodeHandler
)
clazz
.
getConstructor
(
MCCosmetics
.
class
).
newInstance
(
this
);
}
}
catch
(
final
ClassNotFoundException
e
)
{
MCLogger
.
error
(
ColorString
.
get
(
"&6--====|||| &c&lMCCosmetics &6||||====--"
));
...
...
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/managers/hats/Hat.java
0 → 100644
View file @
0bdf5933
package
io.lumine.cosmetics.managers.hats
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.function.BiConsumer
;
import
org.bukkit.Material
;
import
org.bukkit.block.data.type.Piston
;
import
org.bukkit.block.data.type.TechnicalPiston
;
import
org.bukkit.entity.Player
;
import
org.bukkit.inventory.ItemStack
;
import
com.google.common.collect.Lists
;
import
io.lumine.cosmetics.commands.CommandHelper
;
import
io.lumine.cosmetics.config.Scope
;
import
io.lumine.cosmetics.players.Profile
;
import
io.lumine.utils.config.properties.Property
;
import
io.lumine.utils.config.properties.PropertyHolder
;
import
io.lumine.utils.config.properties.types.BooleanProp
;
import
io.lumine.utils.config.properties.types.EnumProp
;
import
io.lumine.utils.config.properties.types.IntProp
;
import
io.lumine.utils.config.properties.types.LangListProp
;
import
io.lumine.utils.config.properties.types.LangProp
;
import
io.lumine.utils.config.properties.types.StringListProp
;
import
io.lumine.utils.config.properties.types.StringProp
;
import
io.lumine.utils.items.ItemFactory
;
import
io.lumine.utils.menu.Icon
;
import
io.lumine.utils.menu.IconBuilder
;
import
io.lumine.utils.menu.MenuData
;
import
io.lumine.utils.text.Text
;
import
lombok.Data
;
import
lombok.Getter
;
@Data
public
class
Hat
implements
PropertyHolder
,
MenuData
<
Profile
>
{
private
static
final
EnumProp
<
Material
>
MATERIAL
=
Property
.
Enum
(
Scope
.
NONE
,
Material
.
class
,
"Material"
,
Material
.
EMERALD
);
private
static
final
IntProp
MODEL
=
Property
.
Int
(
Scope
.
NONE
,
"Model"
);
private
static
final
LangProp
DISPLAY
=
Property
.
Lang
(
Scope
.
NONE
,
"Display"
);
private
static
final
LangListProp
DESCRIPTION
=
Property
.
LangList
(
Scope
.
NONE
,
"Description"
);
private
static
final
StringProp
TEXTURE
=
Property
.
String
(
Scope
.
NONE
,
"Texture"
);
private
final
String
key
;
@Getter
private
List
<
String
>
sources
=
Lists
.
newArrayList
();
private
Material
material
;
private
int
model
;
@Getter
private
String
display
;
private
List
<
String
>
description
;
@Getter
private
ItemStack
hatItem
;
public
Hat
(
String
key
)
{
this
.
key
=
key
.
toUpperCase
();
this
.
material
=
MATERIAL
.
get
(
this
);
this
.
model
=
MODEL
.
get
(
this
);
this
.
display
=
DISPLAY
.
get
(
this
);
this
.
description
=
DESCRIPTION
.
get
(
this
);
if
(
material
==
Material
.
PLAYER_HEAD
)
{
this
.
hatItem
=
ItemFactory
.
of
(
this
.
material
)
.
name
(
Text
.
colorize
(
this
.
getDisplay
()))
.
model
(
model
)
.
hideAttributes
()
.
lore
(
description
)
.
skullTexture
(
TEXTURE
.
get
(
this
))
.
build
();
}
else
{
this
.
hatItem
=
ItemFactory
.
of
(
this
.
material
)
.
name
(
Text
.
colorize
(
this
.
getDisplay
()))
.
model
(
model
)
.
hideAttributes
()
.
lore
(
description
)
.
build
();
}
}
@Override
public
String
getPropertyNode
()
{
return
"Hats."
+
this
.
key
;
}
@Override
public
Icon
<
Profile
>
getIcon
()
{
return
IconBuilder
.<
Profile
>
create
()
.
name
(
Text
.
colorize
(
this
.
getDisplay
()))
.
item
(
this
.
hatItem
)
.
hideFlags
()
.
lore
(
profile
->
{
//if(profile.getUnlockedHats().contains(this.getKey())) {
// return this.description;
//} else {
List
<
String
>
desc
=
Lists
.
newArrayList
(
description
);
desc
.
add
(
""
);
desc
.
add
(
Text
.
colorizeLegacy
(
"<red>Not Unlocked"
));
return
desc
;
//}
})
.
click
((
prof
,
p
)
->
{
if
(
prof
.
getPlayer
().
isOp
())
{
// || prof.getUnlockedHats().contains(this.getKey())) {
//prof.setHat(this);
CommandHelper
.
sendSuccess
(
p
,
"Set your hat to "
+
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/hats/HatManager.java
View file @
0bdf5933
package
io.lumine.cosmetics.managers.hats
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.concurrent.ConcurrentHashMap
;
import
org.bukkit.entity.Entity
;
import
org.bukkit.entity.Player
;
import
org.bukkit.event.inventory.InventoryClickEvent
;
import
org.bukkit.event.inventory.InventoryCloseEvent
;
import
org.bukkit.inventory.ItemStack
;
import
com.comphenix.protocol.PacketType
;
import
com.comphenix.protocol.events.PacketContainer
;
import
io.lumine.utils.Events
;
import
io.lumine.utils.Schedulers
;
import
io.lumine.utils.config.properties.types.NodeListProp
;
import
io.lumine.utils.logging.Log
;
import
io.lumine.utils.protocol.Protocol
;
import
io.lumine.cosmetics.MCCosmeticsPlugin
;
import
io.lumine.cosmetics.api.events.CosmeticPlayerLoadedEvent
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
io.lumine.cosmetics.managers.MCCosmeticsManager
;
import
io.lumine.
u
ti
l
s.pl
ugin.ReloadableModu
le
;
import
io.lumine.
cosme
ti
c
s.pl
ayers.Profi
le
;
public
class
HatManager
extends
MCCosmeticsManager
{
private
final
Map
<
String
,
Hat
>
hats
=
new
ConcurrentHashMap
<>();
public
HatManager
(
MCCosmeticsPlugin
plugin
)
{
super
(
plugin
);
}
@Override
public
void
load
(
MCCosmeticsPlugin
plugin
)
{
// TODO Auto-generated method stub
//
// TODO: Load Hats
//
Log
.
info
(
"Loaded "
+
hats
.
size
()
+
" hats"
);
Events
.
subscribe
(
CosmeticPlayerLoadedEvent
.
class
)
.
handler
(
event
->
{
final
CosmeticProfile
profile
=
event
.
getProfile
();
//if(profile.getHat().isPresent()) {
// equipHat(profile);
//}
}).
bindWith
(
this
);
Events
.
subscribe
(
InventoryCloseEvent
.
class
)
.
handler
(
event
->
{
final
Player
player
=
(
Player
)
event
.
getPlayer
();
getProfiles
().
awaitProfile
(
player
).
thenAcceptAsync
(
maybeProfile
->
{
if
(!
maybeProfile
.
isPresent
())
{
return
;
}
final
Profile
profile
=
maybeProfile
.
get
();
//if(profile.getHat().isPresent()) {
// profile.setHatIsActive(true);
// Schedulers.async().runLater(() -> this.equipHat(profile), 1);
// }
});
}).
bindWith
(
this
);
Protocol
.
subscribe
(
PacketType
.
Play
.
Server
.
ENTITY_EQUIPMENT
)
.
handler
(
event
->
{
final
PacketContainer
packet
=
event
.
getPacket
();
final
Entity
entity
=
packet
.
getEntityModifier
(
event
.
getPlayer
().
getWorld
()).
read
(
0
);
if
(!(
entity
instanceof
Player
))
{
return
;
}
final
Player
player
=
(
Player
)
entity
;
final
Profile
profile
=
getProfiles
().
getProfile
(
player
);
if
(
profile
==
null
)
{
return
;
}
//if(profile.getHat().isPresent()) {
// writeHeadItem(packet, profile.getEquippedHat());
//}
}).
bindWith
(
this
);
Events
.
subscribe
(
InventoryClickEvent
.
class
)
.
handler
(
event
->
{
if
(
event
.
getRawSlot
()
==
5
)
{
final
Player
player
=
(
Player
)
event
.
getWhoClicked
();
final
Profile
profile
=
getProfiles
().
getProfile
(
player
);
//if(profile.getHat().isPresent() && profile.getHatIsActive()) {
// player.updateInventory();
// profile.setHatIsActive(false);
//}
}
}).
bindWith
(
this
);
}
@Override
public
void
unload
()
{
// TODO Auto-generated method stub
hats
.
clear
();
}
public
Collection
<
Hat
>
getHats
()
{
return
hats
.
values
();
}
public
Optional
<
Hat
>
getHat
(
String
key
)
{
return
Optional
.
ofNullable
(
hats
.
getOrDefault
(
key
,
null
));
}
public
void
equipHat
(
Player
player
)
{
equipHat
(
getProfiles
().
getProfile
(
player
));
}
public
void
equipHat
(
Profile
profile
)
{
getPlugin
().
getVolatileCodeHandler
().
getHatHelper
().
applyHatPacket
(
profile
);
}
}
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/nms/VolatileCodeDisabled.java
View file @
0bdf5933
...
...
@@ -2,4 +2,9 @@ package io.lumine.cosmetics.nms;
public
class
VolatileCodeDisabled
implements
VolatileCodeHandler
{
@Override
public
VolatileHatHelper
getHatHelper
()
{
return
null
;
}
}
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/nms/VolatileCodeHandler.java
View file @
0bdf5933
...
...
@@ -2,4 +2,5 @@ package io.lumine.cosmetics.nms;
public
interface
VolatileCodeHandler
{
public
VolatileHatHelper
getHatHelper
();
}
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/nms/VolatileHatHelper.java
0 → 100644
View file @
0bdf5933
package
io.lumine.cosmetics.nms
;
import
io.lumine.cosmetics.players.Profile
;
public
interface
VolatileHatHelper
{
public
void
applyHatPacket
(
Profile
profile
);
}
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/players/
Cosmetic
Profile.java
→
plugin/src/main/java/io/lumine/cosmetics/players/Profile.java
View file @
0bdf5933
...
...
@@ -4,10 +4,10 @@ import java.util.UUID;
import
org.bukkit.entity.Player
;
import
io.lumine.
u
ti
l
s.
storage
.players.Profile
;
import
io.lumine.
cosme
ti
c
s.
api
.players.
Cosmetic
Profile
;
import
lombok.Getter
;
public
class
Cosmetic
Profile
implements
Profile
{
public
class
Profile
implements
CosmeticProfile
,
io
.
lumine
.
utils
.
storage
.
players
.
Profile
{
@Getter
private
UUID
uniqueId
;
@Getter
private
String
name
;
...
...
@@ -15,9 +15,9 @@ public class CosmeticProfile implements Profile {
@Getter
private
transient
Player
player
;
public
Cosmetic
Profile
()
{}
public
Profile
()
{}
public
Cosmetic
Profile
(
UUID
id
,
String
name
)
{
public
Profile
(
UUID
id
,
String
name
)
{
this
.
uniqueId
=
id
;
this
.
name
=
name
;
}
...
...
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/players/ProfileManager.java
View file @
0bdf5933
...
...
@@ -5,26 +5,29 @@ import java.util.UUID;
import
org.bukkit.entity.Player
;
import
io.lumine.cosmetics.MCCosmeticsPlugin
;
import
io.lumine.cosmetics.api.events.CosmeticPlayerLoadedEvent
;
import
io.lumine.utils.storage.players.adapters.file.JsonPlayerStorageAdapter
;
import
io.lumine.utils.Events
;
import
io.lumine.utils.storage.players.PlayerRepository
;
public
class
ProfileManager
extends
PlayerRepository
<
MCCosmeticsPlugin
,
Cosmetic
Profile
>
{
public
class
ProfileManager
extends
PlayerRepository
<
MCCosmeticsPlugin
,
Profile
>
{
public
ProfileManager
(
MCCosmeticsPlugin
plugin
)
{
super
(
plugin
,
Cosmetic
Profile
.
class
,
new
JsonPlayerStorageAdapter
<>(
plugin
,
Cosmetic
Profile
.
class
));
super
(
plugin
,
Profile
.
class
,
new
JsonPlayerStorageAdapter
<>(
plugin
,
Profile
.
class
));
}
@Override
public
Cosmetic
Profile
createProfile
(
UUID
id
,
String
name
)
{
return
new
Cosmetic
Profile
(
id
,
name
);
public
Profile
createProfile
(
UUID
id
,
String
name
)
{
return
new
Profile
(
id
,
name
);
}
@Override
public
void
initProfile
(
Cosmetic
Profile
profile
,
Player
player
)
{
public
void
initProfile
(
Profile
profile
,
Player
player
)
{
profile
.
initialize
(
player
);
Events
.
call
(
new
CosmeticPlayerLoadedEvent
(
player
,
profile
));
}
@Override
public
void
unloadProfile
(
Cosmetic
Profile
profile
,
Player
player
)
{}
public
void
unloadProfile
(
Profile
profile
,
Player
player
)
{}
}
This diff is collapsed.
Click to expand it.
pom.xml
View file @
0bdf5933
...
...
@@ -52,10 +52,9 @@
<plugin>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
3.8.0
</version>
<configuration>
<source>
1.8
</source>
<target>
1.8
</target>
</configuration>
<configuration>
<release>
16
</release>
</configuration>
</plugin>
</plugins>
</build>
...
...
This diff is collapsed.
Click to expand it.
v1_18/pom.xml
View file @
0bdf5933
...
...
@@ -66,6 +66,11 @@
<id>
lumine-test
</id>
<url>
https://mvn.lumine.io/repository/maven-test/
</url>
</repository>
<repository>
<id>
minecraft-libraries
</id>
<name>
Minecraft Libraries
</name>
<url>
https://libraries.minecraft.net
</url>
</repository>
</repositories>
<dependencies>
...
...
@@ -113,8 +118,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
com.mojang
</groupId>
<artifactId>
datafixerupper
</artifactId>
<version>
1.0.20
</version>
</dependency>
<!-- Other -->
<!-- Other -->
<dependency>
<groupId>
com.comphenix.protocol
</groupId>
<artifactId>
ProtocolLib
</artifactId>
<version>
4.6.0-SNAPSHOT
</version>
<scope>
provided
</scope>
</dependency>
</dependencies>
...
...
This diff is collapsed.
Click to expand it.
v1_18/src/main/java/io/lumine/cosmetics/nms/v1_18_R1/VolatileHatImpl.java
0 → 100644
View file @
0bdf5933
package
io.lumine.cosmetics.nms.v1_18_R1
;
import
java.util.List
;
import
org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack
;
import
org.bukkit.entity.Player
;
import
org.bukkit.inventory.ItemStack
;
import
com.comphenix.protocol.PacketType
;
import
com.comphenix.protocol.events.PacketContainer
;
import
com.google.common.collect.Lists
;
import
com.mojang.datafixers.util.Pair
;
import
io.lumine.cosmetics.MCCosmeticsPlugin
;
import
io.lumine.cosmetics.nms.VolatileHatHelper
;
import
io.lumine.cosmetics.players.Profile
;
import
io.lumine.utils.protocol.Protocol
;
import
lombok.Getter
;
import
net.minecraft.world.entity.EquipmentSlot
;
public
class
VolatileHatImpl
implements
VolatileHatHelper
{
@Getter
private
final
MCCosmeticsPlugin
plugin
;
public
VolatileHatImpl
(
MCCosmeticsPlugin
plugin
)
{
this
.
plugin
=
plugin
;
}
@Override
public
void
applyHatPacket
(
Profile
profile
)
{
if
(
profile
==
null
)
{
return
;
}
final
var
player
=
profile
.
getPlayer
();
final
var
packet
=
Protocol
.
manager
().
createPacket
(
PacketType
.
Play
.
Server
.
ENTITY_EQUIPMENT
);
packet
.
getEntityModifier
(
player
.
getWorld
()).
write
(
0
,
player
);
/*
if(profile.getHat().isPresent()) {
profile.setHatIsActive(true);
writeHeadItem(packet, profile.getEquippedHat());
Protocol.broadcastPacket(packet);
} else if(profile.getHatIsActive()) {
writeHeadItem(packet, player.getInventory().getHelmet());
Protocol.broadcastPacket(packet);
}*/
}
public
boolean
writeHeadItem
(
PacketContainer
packet
,
ItemStack
item
)
{
List
<
Pair
<
EquipmentSlot
,
net
.
minecraft
.
world
.
item
.
ItemStack
>>
slots
=
(
List
<
Pair
<
EquipmentSlot
,
net
.
minecraft
.
world
.
item
.
ItemStack
>>)
packet
.
getModifier
().
read
(
1
);
List
<
Pair
<
EquipmentSlot
,
net
.
minecraft
.
world
.
item
.
ItemStack
>>
newSlots
=
Lists
.
newArrayList
();
boolean
foundHead
=
false
;
for
(
Pair
<
EquipmentSlot
,
net
.
minecraft
.
world
.
item
.
ItemStack
>
pair
:
slots
)
{
final
EquipmentSlot
slot
=
pair
.
getFirst
();
if
(
slot
==
EquipmentSlot
.
HEAD
)
{
foundHead
=
true
;
newSlots
.
add
(
Pair
.
of
(
pair
.
getFirst
(),
CraftItemStack
.
asNMSCopy
(
item
)));
}
else
{
newSlots
.
add
(
pair
);
}
}
if
(!
foundHead
)
{
newSlots
.
add
(
Pair
.
of
(
EquipmentSlot
.
HEAD
,
CraftItemStack
.
asNMSCopy
(
item
)));
}
packet
.
getModifier
().
write
(
1
,
newSlots
);
return
true
;
}
}
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