mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-30 13:27:37 +00:00
parent
07e0b4e2c8
commit
9f22115b30
@ -12,6 +12,7 @@ import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
|
||||
import me.totalfreedom.totalfreedommod.blocking.EditBlocker;
|
||||
import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
|
||||
import me.totalfreedom.totalfreedommod.blocking.InteractBlocker;
|
||||
import me.totalfreedom.totalfreedommod.blocking.InventoryBlocker;
|
||||
import me.totalfreedom.totalfreedommod.blocking.MobBlocker;
|
||||
import me.totalfreedom.totalfreedommod.blocking.PVPBlocker;
|
||||
import me.totalfreedom.totalfreedommod.blocking.PotionBlocker;
|
||||
@ -87,6 +88,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||
public MobBlocker mb;
|
||||
public InteractBlocker ib;
|
||||
public PotionBlocker pb;
|
||||
public InventoryBlocker inb;
|
||||
public LoginProcess lp;
|
||||
public AntiNuke nu;
|
||||
public AntiSpam as;
|
||||
@ -194,6 +196,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||
mb = services.registerService(MobBlocker.class);
|
||||
ib = services.registerService(InteractBlocker.class);
|
||||
pb = services.registerService(PotionBlocker.class);
|
||||
inb = services.registerService(InventoryBlocker.class);
|
||||
lp = services.registerService(LoginProcess.class);
|
||||
nu = services.registerService(AntiNuke.class);
|
||||
as = services.registerService(AntiSpam.class);
|
||||
|
@ -118,10 +118,12 @@ public class BlockBlocker extends FreedomService
|
||||
break;
|
||||
}
|
||||
case SPAWNER:
|
||||
{
|
||||
player.sendMessage(ChatColor.GRAY + "Spawners are disabled.");
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,63 @@
|
||||
package me.totalfreedom.totalfreedommod.blocking;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import net.minecraft.server.v1_14_R1.NBTTagCompound;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public class InventoryBlocker extends FreedomService
|
||||
{
|
||||
public InventoryBlocker(TotalFreedomMod plugin)
|
||||
{
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
private BukkitTask inventoryChecker;
|
||||
|
||||
@Override
|
||||
protected void onStart()
|
||||
{
|
||||
inventoryChecker = new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
Inventory inv = player.getInventory();
|
||||
for (int i = 0; i < inv.getSize(); i++)
|
||||
{
|
||||
ItemStack item = inv.getItem(i);
|
||||
if (item == null)
|
||||
continue;
|
||||
if (!item.hasItemMeta())
|
||||
continue;
|
||||
if (item.getType() == Material.JUKEBOX)
|
||||
{
|
||||
if (!CraftItemStack.asNMSCopy(item).hasTag())
|
||||
continue;
|
||||
net.minecraft.server.v1_14_R1.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
|
||||
NBTTagCompound compound = nmsItem.getTag();
|
||||
compound.set("BlockEntityTag", null);
|
||||
inv.setItem(i, new ItemStack(CraftItemStack.asBukkitCopy(nmsItem)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(plugin, 0L, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
inventoryChecker.cancel();
|
||||
inventoryChecker = null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user