Properly patch Game Master Blocks (#245)

* Break cancelled blocks on interact

* Cancel master blocks

* Add Scissors maven repository

* Remove Scissors repo (it is already included in the AMG repo)

* Remove unused import & add TODO for the 1.19 port
This commit is contained in:
Allink
2022-07-16 23:03:23 +01:00
committed by GitHub
parent c472c5d5ce
commit 073356be49
7 changed files with 47 additions and 35 deletions

View File

@ -4,7 +4,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
/* TODO This will have to be changed from com.github.atlasmediagroup.scissors to me.totalfreedom.scissors when we migrate to 1.19 */
import com.github.atlasmediagroup.scissors.event.block.MasterBlockFireEvent;
import io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
@ -108,10 +109,12 @@ public class EventBlocker extends FreedomService
event.setRadius(ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue());
}
@EventHandler(priority = EventPriority.HIGH)
public void onBlockExplode(BlockExplodeEvent event) {
if(!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()) {
public void onBlockExplode(BlockExplodeEvent event)
{
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{
event.setCancelled(true);
return;
}
@ -119,6 +122,16 @@ public class EventBlocker extends FreedomService
event.setYield(ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue());
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onMasterBlockFire(MasterBlockFireEvent event)
{
if (!ConfigEntry.ALLOW_MASTERBLOCKS.getBoolean())
{
event.setCancelled(true);
event.getAt().getBlock().setType(Material.CAKE);
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onEntityCombust(EntityCombustEvent event)
{
@ -152,7 +165,7 @@ public class EventBlocker extends FreedomService
Entity entity = event.getEntity();
if (entity instanceof Tameable)
{
if (((Tameable)entity).isTamed())
if (((Tameable) entity).isTamed())
{
event.setCancelled(true);
}