Skip to content

Commit

Permalink
Hot Fix
Browse files Browse the repository at this point in the history
Players in creative should not not loose blocks when they place them, added clickedBlock to OraxenTransparentBlockPlaceEvent.
  • Loading branch information
playajames committed Jul 11, 2021
1 parent c5aa4ad commit ab3c89f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 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>me.playajames</groupId>
<artifactId>OraxenTransparentBlocks</artifactId>
<version>1.1-SNAPSHOT</version>
<version>1.1.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>OraxenTransparentBlocks</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.playajames.oraxentransparentblocks.Events;

import me.playajames.oraxentransparentblocks.OraxenTransparentBlock;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
Expand All @@ -12,12 +13,14 @@ public class OraxenTransparentBlockPlaceEvent extends Event {
private boolean canceled;
private Player player;
private ItemStack item;
private Block clickedBlock;
private OraxenTransparentBlock block;

public OraxenTransparentBlockPlaceEvent(Player player, ItemStack item, OraxenTransparentBlock block) {
public OraxenTransparentBlockPlaceEvent(Player player, ItemStack item, Block clickedBlock, OraxenTransparentBlock block) {
this.player = player;
this.block = block;
this.item = item;
this.clickedBlock = clickedBlock;
this.canceled = false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import me.playajames.oraxentransparentblocks.OraxenMechanics.TransparentBlockMechanic;
import me.playajames.oraxentransparentblocks.Utils.PlayerUtils;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
Expand Down Expand Up @@ -58,11 +59,11 @@ public void onCustomBlockPlace(PlayerInteractEvent event) {

if (prePlaceEvent.isCancelled()) return;

event.getPlayer().getInventory().setItemInMainHand(item.clone().subtract(1));
if (!event.getPlayer().getGameMode().equals(GameMode.CREATIVE))event.getPlayer().getInventory().setItemInMainHand(item.clone().subtract(1));

OraxenTransparentBlock block = new OraxenTransparentBlock(item, location, mechanic.isVisible(), mechanic.isSmall(), mechanic.hasGravity());

Bukkit.getPluginManager().callEvent(new OraxenTransparentBlockPlaceEvent(event.getPlayer(), item, block));
Bukkit.getPluginManager().callEvent(new OraxenTransparentBlockPlaceEvent(event.getPlayer(), item, event.getClickedBlock(), block));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import static me.playajames.oraxentransparentblocks.OraxenTransparentBlocks.CONNECTION;

public class OraxenTransparentBlockManager {
private static HashMap<World, HashMap<Chunk, HashMap<UUID, OraxenTransparentBlock>>> loadedBlocks = new HashMap<>();
private static String dataFolderPath = OraxenTransparentBlocks.getPlugin(OraxenTransparentBlocks.class).getDataFolder().getPath() + "/data/";

public static boolean isBlock(ArmorStand armorStand) {
if (getBlock(armorStand) != null) return true;
Expand Down

0 comments on commit ab3c89f

Please sign in to comment.