mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-26 17:05:01 +00:00
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:
parent
c472c5d5ce
commit
073356be49
7
pom.xml
7
pom.xml
@ -100,8 +100,7 @@
|
|||||||
<id>esentialsx-repo</id>
|
<id>esentialsx-repo</id>
|
||||||
<url>https://repo.essentialsx.net/releases/</url>
|
<url>https://repo.essentialsx.net/releases/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
|
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -128,8 +127,8 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.papermc.paper</groupId>
|
<groupId>me.totalfreedom.scissors</groupId>
|
||||||
<artifactId>paper-api</artifactId>
|
<artifactId>scissors-api</artifactId>
|
||||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
<version>1.17.1-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -71,7 +71,7 @@ public class BlockBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
case STRUCTURE_BLOCK:
|
case STRUCTURE_BLOCK:
|
||||||
{
|
{
|
||||||
if (!ConfigEntry.ALLOW_STRUCTURE_BLOCKS.getBoolean())
|
if (!ConfigEntry.ALLOW_MASTERBLOCKS.getBoolean())
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.GRAY + "Structure blocks are disabled.");
|
player.sendMessage(ChatColor.GRAY + "Structure blocks are disabled.");
|
||||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
@ -81,7 +81,7 @@ public class BlockBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
case JIGSAW:
|
case JIGSAW:
|
||||||
{
|
{
|
||||||
if (!ConfigEntry.ALLOW_JIGSAWS.getBoolean())
|
if (!ConfigEntry.ALLOW_MASTERBLOCKS.getBoolean())
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.GRAY + "Jigsaws are disabled.");
|
player.sendMessage(ChatColor.GRAY + "Jigsaws are disabled.");
|
||||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
@ -89,6 +89,16 @@ public class BlockBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case REPEATING_COMMAND_BLOCK:
|
||||||
|
case CHAIN_COMMAND_BLOCK:
|
||||||
|
case COMMAND_BLOCK:
|
||||||
|
if (!ConfigEntry.ALLOW_MASTERBLOCKS.getBoolean())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Command blocks are disabled.");
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case GRINDSTONE:
|
case GRINDSTONE:
|
||||||
{
|
{
|
||||||
if (!ConfigEntry.ALLOW_GRINDSTONES.getBoolean())
|
if (!ConfigEntry.ALLOW_GRINDSTONES.getBoolean())
|
||||||
|
@ -4,7 +4,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
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 io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
@ -108,10 +109,12 @@ public class EventBlocker extends FreedomService
|
|||||||
|
|
||||||
event.setRadius(ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue());
|
event.setRadius(ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onBlockExplode(BlockExplodeEvent event) {
|
public void onBlockExplode(BlockExplodeEvent event)
|
||||||
if(!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()) {
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||||
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -119,6 +122,16 @@ public class EventBlocker extends FreedomService
|
|||||||
event.setYield(ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue());
|
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)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onEntityCombust(EntityCombustEvent event)
|
public void onEntityCombust(EntityCombustEvent event)
|
||||||
{
|
{
|
||||||
@ -152,7 +165,7 @@ public class EventBlocker extends FreedomService
|
|||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
if (entity instanceof Tameable)
|
if (entity instanceof Tameable)
|
||||||
{
|
{
|
||||||
if (((Tameable)entity).isTamed())
|
if (((Tameable) entity).isTamed())
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
@ -69,24 +69,22 @@ public class InteractBlocker extends FreedomService
|
|||||||
private void handleRightClick(PlayerInteractEvent event)
|
private void handleRightClick(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
final Block clickedBlock = event.getClickedBlock();
|
||||||
|
|
||||||
if (event.getClickedBlock() != null)
|
if (clickedBlock == null)
|
||||||
{
|
{
|
||||||
if (event.getClickedBlock().getType().equals(Material.STRUCTURE_BLOCK) || event.getClickedBlock().getType().equals(Material.JIGSAW) || event.getClickedBlock().getType().equals(Material.RESPAWN_ANCHOR))
|
return;
|
||||||
{
|
}
|
||||||
event.setCancelled(true);
|
|
||||||
event.getPlayer().closeInventory();
|
if (clickedBlock.getType() == Material.RESPAWN_ANCHOR && !ConfigEntry.ALLOW_RESPAWN_ANCHORS.getBoolean())
|
||||||
}
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Groups.SPAWN_EGGS.contains(event.getMaterial()))
|
if (Groups.SPAWN_EGGS.contains(event.getMaterial()))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
Block clickedBlock = event.getClickedBlock();
|
|
||||||
if (clickedBlock == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
EntityType eggType = null;
|
EntityType eggType = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ public class Command_toggle extends FreedomCommand
|
|||||||
private final List<String> toggles = Arrays.asList(
|
private final List<String> toggles = Arrays.asList(
|
||||||
"waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk",
|
"waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk",
|
||||||
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke [range] [count]",
|
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke [range] [count]",
|
||||||
"explosives [radius]", "unsafeenchs", "bells", "armorstands", "structureblocks", "jigsaws", "grindstones",
|
"explosives [radius]", "unsafeenchs", "bells", "armorstands", "masterblocks", "grindstones",
|
||||||
"jukeboxes", "spawners", "4chan", "beehives", "respawnanchors", "autotp", "autoclear", "minecarts", "mp44",
|
"jukeboxes", "spawners", "4chan", "beehives", "respawnanchors", "autotp", "autoclear", "minecarts", "mp44",
|
||||||
"landmines", "tossmob", "gravity");
|
"landmines", "tossmob", "gravity");
|
||||||
|
|
||||||
@ -193,15 +193,9 @@ public class Command_toggle extends FreedomCommand
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "structureblocks":
|
case "masterblocks":
|
||||||
{
|
{
|
||||||
toggle("Structure blocks are", ConfigEntry.ALLOW_STRUCTURE_BLOCKS);
|
toggle("Master blocks are", ConfigEntry.ALLOW_MASTERBLOCKS);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "jigsaws":
|
|
||||||
{
|
|
||||||
toggle("Jigsaws are", ConfigEntry.ALLOW_JIGSAWS);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,8 +25,6 @@ public enum ConfigEntry
|
|||||||
ALLOW_BELLS(Boolean.class, "allow.bells"),
|
ALLOW_BELLS(Boolean.class, "allow.bells"),
|
||||||
ALLOW_ARMOR_STANDS(Boolean.class, "allow.armorstands"),
|
ALLOW_ARMOR_STANDS(Boolean.class, "allow.armorstands"),
|
||||||
ALLOW_MINECARTS(Boolean.class, "allow.minecarts"),
|
ALLOW_MINECARTS(Boolean.class, "allow.minecarts"),
|
||||||
ALLOW_STRUCTURE_BLOCKS(Boolean.class, "allow.structureblocks"),
|
|
||||||
ALLOW_JIGSAWS(Boolean.class, "allow.jigsaws"),
|
|
||||||
ALLOW_GRINDSTONES(Boolean.class, "allow.grindstones"),
|
ALLOW_GRINDSTONES(Boolean.class, "allow.grindstones"),
|
||||||
ALLOW_JUKEBOXES(Boolean.class, "allow.jukeboxes"),
|
ALLOW_JUKEBOXES(Boolean.class, "allow.jukeboxes"),
|
||||||
ALLOW_SPAWNERS(Boolean.class, "allow.spawners"),
|
ALLOW_SPAWNERS(Boolean.class, "allow.spawners"),
|
||||||
@ -35,6 +33,7 @@ public enum ConfigEntry
|
|||||||
AUTO_TP(Boolean.class, "allow.auto_tp"),
|
AUTO_TP(Boolean.class, "allow.auto_tp"),
|
||||||
AUTO_CLEAR(Boolean.class, "allow.auto_clear"),
|
AUTO_CLEAR(Boolean.class, "allow.auto_clear"),
|
||||||
ALLOW_GRAVITY(Boolean.class, "allow.gravity"),
|
ALLOW_GRAVITY(Boolean.class, "allow.gravity"),
|
||||||
|
ALLOW_MASTERBLOCKS(Boolean.class, "allow.masterblocks"),
|
||||||
//
|
//
|
||||||
BLOCKED_CHATCODES(String.class, "blocked_chatcodes"),
|
BLOCKED_CHATCODES(String.class, "blocked_chatcodes"),
|
||||||
//
|
//
|
||||||
|
@ -224,8 +224,6 @@ allow:
|
|||||||
minecarts: true
|
minecarts: true
|
||||||
clearonjoin: false
|
clearonjoin: false
|
||||||
tpronjoin: false
|
tpronjoin: false
|
||||||
structureblocks: false
|
|
||||||
jigsaws: false
|
|
||||||
grindstones: true
|
grindstones: true
|
||||||
jukeboxes: true
|
jukeboxes: true
|
||||||
spawners: false
|
spawners: false
|
||||||
@ -234,6 +232,7 @@ allow:
|
|||||||
auto_tp: false
|
auto_tp: false
|
||||||
auto_clear: false
|
auto_clear: false
|
||||||
gravity: false
|
gravity: false
|
||||||
|
masterblocks: false
|
||||||
|
|
||||||
blocked_commands:
|
blocked_commands:
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user