Skip to content

Commit

Permalink
1.3, adding option to disable respawn anchors in the over world and end.
Browse files Browse the repository at this point in the history
  • Loading branch information
KRYMZ0N committed Oct 11, 2021
1 parent 2f8158b commit 11f747d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 66 deletions.
5 changes: 3 additions & 2 deletions src/main/java/me/krymz0n/simpleexploitfixer/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Objects;

public final class Main extends JavaPlugin implements Listener {

@Override
Expand All @@ -20,12 +22,11 @@ public void onEnable() {
pm.registerEvents(this, this);
pm.registerEvents(new Bees(this), this);
pm.registerEvents(new CreatureSpawn(this), this);
pm.registerEvents(new ChunkLoad(this), this);
pm.registerEvents(new ChunkBan(this), this);
pm.registerEvents(new WitherSkulls(this), this);
pm.registerEvents(new InteractEvent(this), this);

getCommand("sef").setExecutor(new Reload(this));
Objects.requireNonNull(getCommand("sef")).setExecutor(new Reload(this));

if (getConfig().getBoolean("DisableAllProtocolLib")) {
getLogger().info("You specified to disable all ProtocolLib patches.");
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package me.krymz0n.simpleexploitfixer.listener;

import me.krymz0n.simpleexploitfixer.Main;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.type.RespawnAnchor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockExplodeEvent;
import org.bukkit.event.player.PlayerInteractEvent;

import static com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type.Int;

public class InteractEvent implements Listener {
private final Main plugin;

Expand All @@ -23,13 +25,21 @@ public InteractEvent(Main plugin) {

@EventHandler
public void onInteract(PlayerInteractEvent evt) {
Player p = evt.getPlayer();
if (evt.getAction() == Action.RIGHT_CLICK_BLOCK) {
Block block = evt.getClickedBlock();
if (block.equals(Material.RESPAWN_ANCHOR) && p.getInventory().getItemInOffHand().getType().equals(Material.GLOWSTONE) || p.getInventory().getItemInMainHand().getType().equals(Material.GLOWSTONE)) {
p.sendMessage(ChatColor.RED + "sorry");
evt.setCancelled(true);
if (plugin.getConfig().getBoolean("DisableRespawnAnchorExplosions")) {
Player p = evt.getPlayer();
if (evt.getAction() == Action.RIGHT_CLICK_BLOCK) {
System.out.println("Right click");
Block block = evt.getClickedBlock();
assert block != null;
if (block.getType().equals(Material.RESPAWN_ANCHOR)) {
System.out.println("anchor");
final RespawnAnchor ra = (RespawnAnchor) block.getBlockData();
if (evt.getMaterial().equals(Material.GLOWSTONE) && ra.getCharges() >= ra.getMaximumCharges() && !p.getWorld().getEnvironment().equals(World.Environment.NETHER)) {
evt.setCancelled(true);
Audience.audience(p).sendActionBar(Component.text(ChatColor.RED + "Due to a poll in the discord, respawn anchor explosions have been disabled"));
}
}
}
}
}
}
}
4 changes: 4 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# SimpleExploitFixer

# Respawn Anchor
DisableRespawnAnchorExplosions: false

# Chunk Ban
PreventChunkBan: true
MaxItemFramePerChunk: 5
Expand Down Expand Up @@ -36,6 +39,7 @@ Enderman: false
Phantom: false
Wither: false

# Wither Lag
RemoveWitherHeadsAutomatically: true

# ProtocolLib
Expand Down

0 comments on commit 11f747d

Please sign in to comment.