Archived
0
This repository has been archived on 2024-08-30. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Modules/src/main/java/com/redstoner/modules/blockplacemods/mods/ModSlab.java
2019-01-03 23:24:31 +01:00

40 lines
1.1 KiB
Java

package com.redstoner.modules.blockplacemods.mods;
import com.redstoner.modules.blockplacemods.BlockPlaceMod;
import com.redstoner.modules.blockplacemods.ModType;
import org.bukkit.GameMode;
import org.bukkit.block.Block;
import org.bukkit.block.data.type.Slab;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockPlaceEvent;
public class ModSlab extends BlockPlaceMod {
public ModSlab() {
super(
"Slab",
"With this mod enabled Slabs are placed on the top half of the block unless you are sneaking.",
ModType.STATELESS,
null,
true,
"Step", "AutoSlab", "AutoStep", "SlabRotation", "StepRotation"
);
}
@EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
if (
event.getBlock().getBlockData() instanceof Slab
&& !event.getPlayer().isSneaking()
&& hasEnabled(event.getPlayer())
&& event.getPlayer().getGameMode() == GameMode.CREATIVE
) {
Block block = event.getBlock();
Slab data = (Slab) block.getBlockData();
data.setType(Slab.Type.TOP);
block.setBlockData(data);
}
}
}