section exploit patch

This commit is contained in:
Super_ 2020-01-02 19:58:52 -05:00
parent ee4bbea340
commit 446f658c13

View File

@ -13,6 +13,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
public class BlockBlocker extends FreedomService public class BlockBlocker extends FreedomService
@ -145,14 +146,32 @@ public class BlockBlocker extends FreedomService
case PLAYER_WALL_HEAD: case PLAYER_WALL_HEAD:
{ {
Skull skull = (Skull) event.getBlockPlaced().getState(); Skull skull = (Skull) event.getBlockPlaced().getState();
if (skull.hasOwner() && skull.getOwner().length() > 16) if (skull.hasOwner())
{ {
skull.setOwner(skull.getOwner().substring(0, 16)); if (skull.getOwner().contains("§"))
SkullMeta meta = (SkullMeta) event.getItemInHand().getItemMeta();
if (meta != null)
{ {
meta.setOwner(meta.getOwner().substring(0, 16)); skull.setOwner(skull.getOwner().replace("§", ""));
event.getItemInHand().setItemMeta(meta); SkullMeta meta = (SkullMeta) event.getItemInHand().getItemMeta();
if (meta != null)
{
ItemStack newHead = new ItemStack(Material.PLAYER_HEAD, 1);
ItemMeta headMeta = newHead.getItemMeta();
headMeta.setDisplayName(ChatColor.YELLOW + "C-sectioned Head");
newHead.setItemMeta(headMeta);
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), newHead);
player.sendMessage(ChatColor.GRAY + "The player head you are attempting to place has a section symbol. Your player head has been C-sectioned.");
event.setCancelled(true);
}
}
if (skull.getOwner().length() > 16)
{
skull.setOwner(skull.getOwner().substring(0, 16));
SkullMeta meta = (SkullMeta)event.getItemInHand().getItemMeta();
if (meta != null)
{
meta.setOwner(meta.getOwner().substring(0, 16));
event.getItemInHand().setItemMeta(meta);
}
} }
} }
break; break;