mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-26 18:39:07 +00:00
Bug with hat being removed on death should be fixed
This commit is contained in:
6
.idea/hotswap_agent.xml
generated
Normal file
6
.idea/hotswap_agent.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="HotSwapAgentPluginSettingsProvider">
|
||||
<option name="agentPath" value="C:\Users\barry\AppData\Roaming\JetBrains\IdeaIC2021.2\plugins\hotswap-agent-intellij-plugin\lib\agent\hotswap-agent-1.4.1.jar" />
|
||||
</component>
|
||||
</project>
|
||||
3
.idea/modules/HMCCosmetics.test.iml
generated
3
.idea/modules/HMCCosmetics.test.iml
generated
@@ -9,4 +9,7 @@
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="McpModuleSettings">
|
||||
<option name="srgType" value="SRG" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -12,9 +12,7 @@ repositories {
|
||||
maven { url = 'https://papermc.io/repo/repository/maven-public/' }
|
||||
maven { url = 'https://repo.mattstudios.me/artifactory/public/' }
|
||||
maven { url = 'https://jitpack.io' }
|
||||
maven { url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/' }
|
||||
maven { url = 'https://repo.leonardobishop.com/releases/' }
|
||||
maven { url = 'https://jitpack.io' }
|
||||
maven { url = 'https://repo.dmulloy2.net/repository/public/' }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package io.github.fisher2911.hmccosmetics;
|
||||
|
||||
import com.comphenix.protocol.ProtocolLib;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.ProtocolManager;
|
||||
|
||||
import io.github.fisher2911.hmccosmetics.command.CosmeticsCommand;
|
||||
import io.github.fisher2911.hmccosmetics.gui.ArmorItem;
|
||||
import io.github.fisher2911.hmccosmetics.gui.CosmeticsMenu;
|
||||
import io.github.fisher2911.hmccosmetics.listener.ClickListener;
|
||||
import io.github.fisher2911.hmccosmetics.listener.JoinListener;
|
||||
import io.github.fisher2911.hmccosmetics.listener.RespawnListener;
|
||||
import io.github.fisher2911.hmccosmetics.listener.TeleportListener;
|
||||
import io.github.fisher2911.hmccosmetics.message.MessageHandler;
|
||||
import io.github.fisher2911.hmccosmetics.message.Messages;
|
||||
@@ -51,7 +52,8 @@ public class HMCCosmetics extends JavaPlugin {
|
||||
private void registerListeners() {
|
||||
List.of(new JoinListener(this),
|
||||
new ClickListener(this),
|
||||
new TeleportListener(this)).
|
||||
new TeleportListener(this),
|
||||
new RespawnListener(this)).
|
||||
forEach(listener ->
|
||||
this.getServer().getPluginManager().registerEvents(listener, this)
|
||||
);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package io.github.fisher2911.hmccosmetics.listener;
|
||||
|
||||
import io.github.fisher2911.hmccosmetics.HMCCosmetics;
|
||||
import io.github.fisher2911.hmccosmetics.user.User;
|
||||
import io.github.fisher2911.hmccosmetics.user.UserManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class RespawnListener implements Listener {
|
||||
|
||||
private final HMCCosmetics plugin;
|
||||
private final UserManager userManager;
|
||||
|
||||
public RespawnListener(final HMCCosmetics plugin) {
|
||||
this.plugin = plugin;
|
||||
this.userManager = this.plugin.getUserManager();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerRespawn(final PlayerRespawnEvent event) {
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
|
||||
final Player player = event.getPlayer();
|
||||
final Optional<User> optionalUser = this.userManager.get(player.getUniqueId());
|
||||
|
||||
optionalUser.ifPresent(user -> user.setHat(user.getPlayerArmor().getHat(), this.userManager));
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
@@ -20,5 +20,4 @@ public class Adventure {
|
||||
TransformationType.COLOR
|
||||
).build())
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
@@ -102,12 +102,12 @@ public class User {
|
||||
|
||||
if (hat.getId().equals(this.playerArmor.getHat().getId())) {
|
||||
this.setHat(new ArmorItem(
|
||||
new ItemStack(Material.AIR),
|
||||
"",
|
||||
new ArrayList<>(),
|
||||
"",
|
||||
ArmorItem.Type.HAT
|
||||
),
|
||||
new ItemStack(Material.AIR),
|
||||
"",
|
||||
new ArrayList<>(),
|
||||
"",
|
||||
ArmorItem.Type.HAT
|
||||
),
|
||||
userManager);
|
||||
|
||||
messageHandler.sendMessage(
|
||||
@@ -136,7 +136,7 @@ public class User {
|
||||
// teleports armor stand to the correct position
|
||||
public void updateArmorStand() {
|
||||
final ArmorItem backpackArmorItem = this.playerArmor.getBackpack();
|
||||
if (backpackArmorItem == null ) {
|
||||
if (backpackArmorItem == null) {
|
||||
this.despawnAttached();
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user