mirror of
https://github.com/kaboomserver/extras.git
synced 2024-11-30 11:17:14 -05:00
Inventory improvements
This commit is contained in:
parent
2e5eecf936
commit
a0c403207b
2 changed files with 31 additions and 3 deletions
|
@ -7,7 +7,9 @@ import org.bukkit.Material;
|
|||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.block.ShulkerBox;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
@ -30,6 +32,8 @@ import org.bukkit.event.entity.SpawnerSpawnEvent;
|
|||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BannerMeta;
|
||||
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
|
||||
|
@ -49,6 +53,14 @@ class EntitySpawn implements Listener {
|
|||
} catch (Exception exception) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
/*try {
|
||||
BlockStateMeta state = (BlockStateMeta) event.getItem().getItemMeta();
|
||||
state.getBlockState();
|
||||
} catch (UnsupportedOperationException exception) {
|
||||
System.out.println("I caught: " + exception);
|
||||
event.setCancelled(true);
|
||||
}*/
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -320,8 +332,9 @@ class EntitySpawn implements Listener {
|
|||
void onTNTPrime(TNTPrimeEvent event) {
|
||||
final double tps = Bukkit.getTPS()[0];
|
||||
|
||||
if (tps < 10) {
|
||||
/*if (tps < 10) {*/
|
||||
event.setCancelled(true);
|
||||
event.getBlock().setType(Material.AIR, false);
|
||||
}
|
||||
/*}*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ import org.bukkit.ChatColor;
|
|||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -22,6 +24,9 @@ import org.bukkit.event.player.PlayerKickEvent;
|
|||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BannerMeta;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.destroystokyo.paper.event.player.PlayerConnectionCloseEvent;
|
||||
|
@ -122,7 +127,17 @@ class PlayerConnection implements Listener {
|
|||
|
||||
if (player.hasPlayedBefore()) {
|
||||
try {
|
||||
player.getInventory().getContents();
|
||||
for (ItemStack item : player.getInventory().getContents()) {
|
||||
if (item.getItemMeta() instanceof BannerMeta) {
|
||||
final BannerMeta banner = (BannerMeta) item.getItemMeta();
|
||||
|
||||
for (Pattern pattern : banner.getPatterns()) {
|
||||
if (pattern.getColor() == null) {
|
||||
player.getInventory().clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
player.getInventory().clear();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue