mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Restrict the owner length to 16 instead of blocking them (#170)
* Restrict the owner length to 16 * no assertion thank u Co-authored-by: super
This commit is contained in:
parent
81c5775150
commit
a2404d1bc6
@ -5,19 +5,14 @@ import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.minecraft.server.v1_15_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_15_R1.NBTTagString;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Skull;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
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
|
||||
@ -149,17 +144,15 @@ public class BlockBlocker extends FreedomService
|
||||
case PLAYER_HEAD:
|
||||
case PLAYER_WALL_HEAD:
|
||||
{
|
||||
SkullMeta meta = (SkullMeta) event.getItemInHand().getItemMeta();
|
||||
if (meta != null)
|
||||
Skull skull = (Skull) event.getBlockPlaced().getState();
|
||||
if (skull.hasOwner() && skull.getOwner().length() > 16)
|
||||
{
|
||||
if (meta.hasOwner())
|
||||
skull.setOwner(skull.getOwner().substring(0, 16));
|
||||
SkullMeta meta = (SkullMeta) event.getItemInHand().getItemMeta();
|
||||
if (meta != null)
|
||||
{
|
||||
if (meta.getOwner().length() > 100)
|
||||
{
|
||||
player.sendMessage(ChatColor.GRAY + "Instead of using Pi to crash a server, how about you use it to impress nerds like yourself?");
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
meta.setOwner(meta.getOwner().substring(0, 16));
|
||||
event.getItemInHand().setItemMeta(meta);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user