-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add golden heads, enable crafting in uhc ffa and disable natural rege…
…n in only uhc ffa
- Loading branch information
Showing
6 changed files
with
88 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/java/com/nexia/core/listeners/nexus/LivingEntityHealListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.nexia.core.listeners.nexus; | ||
|
||
import com.nexia.base.player.NexiaPlayer; | ||
import com.nexia.ffa.uhc.utilities.FfaUhcUtil; | ||
import com.nexia.nexus.api.event.entity.LivingEntityHealEvent; | ||
|
||
public class LivingEntityHealListener { | ||
public void registerListener() { | ||
LivingEntityHealEvent.BACKEND.register(livingEntityHealEvent -> { | ||
if (!(livingEntityHealEvent.getEntity() instanceof NexiaPlayer nexiaPlayer)) return; | ||
|
||
if (FfaUhcUtil.INSTANCE.isFfaPlayer(nexiaPlayer) && livingEntityHealEvent.getCause() == LivingEntityHealEvent.HealCause.NATURAL_REGENERATION) { | ||
livingEntityHealEvent.setCancelled(true); | ||
} | ||
}); | ||
} | ||
} |
54 changes: 45 additions & 9 deletions
54
src/main/java/com/nexia/core/listeners/nexus/PlayerUseItemListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,86 @@ | ||
package com.nexia.core.listeners.nexus; | ||
|
||
import com.nexia.base.player.NexiaPlayer; | ||
import com.nexia.base.player.PlayerDataManager; | ||
import com.nexia.core.NexiaCore; | ||
import com.nexia.core.games.util.PlayerGameMode; | ||
import com.nexia.core.utilities.player.CorePlayerData; | ||
import com.nexia.ffa.uhc.utilities.FfaUhcUtil; | ||
import com.nexia.nexus.api.event.player.PlayerPlaceBlockEvent; | ||
import com.nexia.nexus.api.event.player.PlayerUseItemEvent; | ||
import com.nexia.nexus.api.world.item.ItemStack; | ||
import com.nexia.core.games.util.PlayerGameMode; | ||
import com.nexia.base.player.NexiaPlayer; | ||
import net.kyori.adventure.text.Component; | ||
import com.nexia.nexus.api.world.types.Minecraft; | ||
import com.nexia.nexus.builder.implementation.world.effect.WrappedStatusEffectInstance; | ||
import com.nexia.nexus.builder.implementation.world.item.WrappedItemStack; | ||
import net.minecraft.sounds.SoundEvents; | ||
import net.minecraft.sounds.SoundSource; | ||
import net.minecraft.world.effect.MobEffectInstance; | ||
import net.minecraft.world.effect.MobEffects; | ||
|
||
import java.util.Random; | ||
|
||
public class PlayerUseItemListener { | ||
private void eatGoldenHead(NexiaPlayer player, ItemStack itemStack) { | ||
player.addEffectInstance(new WrappedStatusEffectInstance(new MobEffectInstance(MobEffects.MOVEMENT_SPEED, 100))); | ||
player.addEffectInstance(new WrappedStatusEffectInstance(new MobEffectInstance(MobEffects.ABSORPTION, 2400, 1))); | ||
player.addEffectInstance(new WrappedStatusEffectInstance(new MobEffectInstance(MobEffects.REGENERATION, 100, 2))); | ||
player.unwrap().playNotifySound(SoundEvents.PLAYER_BURP, SoundSource.PLAYERS, 0.5F, new Random().nextFloat() * 0.1F + 0.9F); | ||
|
||
player.unwrap().getCooldowns().addCooldown(((WrappedItemStack) itemStack).unwrap().getItem(), 240); | ||
itemStack.decrementCount(); | ||
player.refreshInventory(); | ||
} | ||
|
||
public void registerListener() { | ||
PlayerUseItemEvent.BACKEND.register(playerUseItemEvent -> { | ||
|
||
NexiaPlayer player = new NexiaPlayer(playerUseItemEvent.getPlayer()); | ||
|
||
ItemStack itemStack = playerUseItemEvent.getItemStack(); | ||
|
||
Component name = itemStack.getDisplayName(); | ||
String name = itemStack.getDisplayName().toString().toLowerCase(); | ||
|
||
PlayerGameMode gameMode = ((CorePlayerData)PlayerDataManager.getDataManager(NexiaCore.CORE_DATA_MANAGER).get(player)).gameMode; | ||
String sName = name.toString().toLowerCase(); | ||
|
||
if(gameMode == PlayerGameMode.LOBBY) { | ||
if(sName.contains("gamemode selector")){ | ||
if (name.contains("gamemode selector")) { | ||
//PlayGUI.openMainGUI(minecraftPlayer); | ||
player.runCommand("/play", 0, false); | ||
return; | ||
} | ||
|
||
if(sName.contains("prefix selector")){ | ||
if (name.contains("prefix selector")) { | ||
//PrefixGUI.openRankGUI(minecraftPlayer); | ||
player.runCommand("/prefix", 0, false); | ||
return; | ||
} | ||
|
||
if(sName.contains("duel sword") && !sName.contains("custom duel sword")) { | ||
if (name.contains("duel sword") && !name.contains("custom duel sword")) { | ||
//QueueGUI.openQueueGUI(minecraftPlayer); | ||
player.runCommand("/queue", 0, false); | ||
return; | ||
} | ||
|
||
if(sName.contains("team axe")) { | ||
if (name.contains("team axe")) { | ||
player.runCommand("/party list"); | ||
} | ||
} | ||
|
||
if (name.contains("golden head") && itemStack.getItem() == Minecraft.Item.PLAYER_HEAD && !FfaUhcUtil.INSTANCE.isInFfaSpawn(player)) { | ||
eatGoldenHead(player, itemStack); | ||
playerUseItemEvent.setCancelled(true); | ||
|
||
} | ||
}); | ||
|
||
PlayerPlaceBlockEvent.BACKEND.register(playerPlaceBlockEvent -> { | ||
NexiaPlayer player = new NexiaPlayer(playerPlaceBlockEvent.getPlayer()); | ||
|
||
ItemStack itemStack = playerPlaceBlockEvent.getBlockStack(); | ||
if (itemStack.getDisplayName().toString().toLowerCase().contains("golden head") && itemStack.getItem() == Minecraft.Item.PLAYER_HEAD && !FfaUhcUtil.INSTANCE.isInFfaSpawn(player)) { | ||
eatGoldenHead(player, itemStack); | ||
playerPlaceBlockEvent.setCancelled(true); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters