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.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
public class BlockBlocker extends FreedomService
@ -145,16 +146,34 @@ public class BlockBlocker extends FreedomService
case PLAYER_WALL_HEAD:
{
Skull skull = (Skull) event.getBlockPlaced().getState();
if (skull.hasOwner() && skull.getOwner().length() > 16)
if (skull.hasOwner())
{
if (skull.getOwner().contains("§"))
{
skull.setOwner(skull.getOwner().replace("§", ""));
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();
SkullMeta meta = (SkullMeta)event.getItemInHand().getItemMeta();
if (meta != null)
{
meta.setOwner(meta.getOwner().substring(0, 16));
event.getItemInHand().setItemMeta(meta);
}
}
}
break;
}
}