Skip to content

Commit

Permalink
Merge pull request #25 from Grzybol/fixes
Browse files Browse the repository at this point in the history
added check if player is on the ground before applying firework effect
  • Loading branch information
Grzybol authored Mar 17, 2024
2 parents 02f0421 + 626890c commit 046c5ac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>betterbox.mine.game</groupId>
<artifactId>BetterElo</artifactId>
<version>3.2.46-SNAPSHOT</version>
<version>3.2.48-SNAPSHOT</version>
<packaging>jar</packaging>

<name>BetterElo</name>
Expand Down
24 changes: 17 additions & 7 deletions src/main/java/betterbox/mine/game/betterelo/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -508,18 +508,28 @@ public void onPlayerInteract(PlayerInteractEvent event) {
}
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"Event.onPlayerInteract checking if its infinite firework");
ItemStack item = event.getItem();
Location location = player.getLocation();
Location blockBelowLocation = location.clone().subtract(0, 1, 0);
boolean isNotOnGround = blockBelowLocation.getBlock().isPassable();
if (item != null && item.getType() == Material.FIREWORK_ROCKET) {
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"Event.onPlayerInteract firework item check passed");
ItemMeta meta = item.getItemMeta();
if (meta != null && meta.hasLore()) {
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"Event.onPlayerInteract firework has lore check passed");
if (meta.getLore().contains("§6§lInfinite usage")) { // Gold bold "Infinite usage"
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"Event.onPlayerInteract firework has formatted lore check passed");
event.setCancelled(true); // Cancel the event so the firework isn't consumed
FireworkMeta fireworkMeta = (FireworkMeta) item.getItemMeta();
int power = fireworkMeta.getPower();
launchFireworkEffect(event.getPlayer());
applyBoosterEffect(event.getPlayer(),power);
if (meta.getLore().contains("§6§lInfinite usage")) {// Gold bold "Infinite usage"
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3, "Event.onPlayerInteract firework has formatted lore check passed");
if(isNotOnGround) {
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3, "Event.onPlayerInteract isNotOnGround check passed");
event.setCancelled(true); // Cancel the event so the firework isn't consumed
FireworkMeta fireworkMeta = (FireworkMeta) item.getItemMeta();
int power = fireworkMeta.getPower();
launchFireworkEffect(event.getPlayer());
applyBoosterEffect(event.getPlayer(), power);
}
else {
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3, "Event.onPlayerInteract isNotOnGround check failed");
event.setCancelled(true);
}
}
}
}
Expand Down

0 comments on commit 046c5ac

Please sign in to comment.