Skip to content

Commit

Permalink
Fixed enderpearl bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Devlrxxh committed Apr 1, 2024
1 parent 7598feb commit 1124e0f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/main/java/me/lrxh/practice/match/MatchListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ public void onProjectileLaunch(ProjectileLaunchEvent event) {

if (projectile instanceof EnderPearl) {
if (match.getState() != MatchState.PLAYING_ROUND) {
shooter.getInventory().addItem(new ItemStack(Material.ENDER_PEARL));
event.setCancelled(true);
return;
}
Expand Down
21 changes: 14 additions & 7 deletions src/main/java/me/lrxh/practice/match/menu/MatchDetailsMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
import org.apache.commons.lang.StringEscapeUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.SkullType;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.potion.PotionEffect;

import java.util.*;
Expand Down Expand Up @@ -78,13 +80,18 @@ public Map<Integer, Button> getButtons(Player player) {
}

@AllArgsConstructor
private static class HealthButton extends Button {
private class HealthButton extends Button {

private double health;

@Override
public ItemStack getButtonItem(Player player) {
return new ItemBuilder(Material.MELON)
ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal());
SkullMeta skullMeta = (SkullMeta) head.getItemMeta();
skullMeta.setOwner(player.getName());
head.setItemMeta(skullMeta);

return new ItemBuilder(head)
.name("&bHealth: &f" + health + "/10 &4" + StringEscapeUtils.unescapeJava("❤"))
.amount((int) (health == 0 ? 1 : health), false)
.clearFlags()
Expand All @@ -94,13 +101,13 @@ public ItemStack getButtonItem(Player player) {
}

@AllArgsConstructor
private static class EffectsButton extends Button {
private class EffectsButton extends Button {

private Collection<PotionEffect> effects;

@Override
public ItemStack getButtonItem(Player player) {
ItemBuilder builder = new ItemBuilder(Material.POTION).name("&bPotion Effects");
ItemBuilder builder = new ItemBuilder(Material.BREWING_STAND_ITEM).name("&bPotion Effects");

if (effects.isEmpty()) {
builder.lore("&bNo potion effects");
Expand All @@ -122,7 +129,7 @@ public ItemStack getButtonItem(Player player) {
}

@AllArgsConstructor
private static class PotionsButton extends Button {
private class PotionsButton extends Button {

private String name;
private int potions;
Expand All @@ -141,7 +148,7 @@ public ItemStack getButtonItem(Player player) {
}

@AllArgsConstructor
private static class StatisticsButton extends Button {
private class StatisticsButton extends Button {

private MatchSnapshot snapshot;

Expand Down Expand Up @@ -174,7 +181,7 @@ public ItemStack getButtonItem(Player player) {
MatchSnapshot snapshot = MatchSnapshot.getByUuid(opponent);

if (snapshot != null) {
return new ItemBuilder(Material.ARROW)
return new ItemBuilder(Material.PAPER)
.name("&7Press to switch to " + Bukkit.getPlayer(opponent).getName() + " inventory.")
.lore("&aClick to Switch")
.clearFlags()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public void clicked(Player player, ClickType clickType) {
Profile profile = Profile.getByUuid(player.getUniqueId());
if(!profile.getFollowing().isEmpty()){
player.sendMessage(CC.translate("&4ERROR - &cYou can't queue while following someone!"));
player.closeInventory();
return;
}
if (player.hasMetadata("frozen")) {
Expand Down

0 comments on commit 1124e0f

Please sign in to comment.