use of com.gmail.stefvanschiedev.buildinggame.utils.guis.moboptions.ChestMenu in project buildinggame by stefvanschie.
the class EntityOptionsMenu method onEntityInteract.
/**
* Called whenever a player interacts with an entity
*
* @param e the event that is called when a player interacts with an entity
* @since 5.3.0
*/
@EventHandler
public void onEntityInteract(PlayerInteractEntityEvent e) {
SettingsManager settingsManager = SettingsManager.getInstance();
if (e.getHand() != EquipmentSlot.HAND || !settingsManager.getConfig().getBoolean("mobs.options.enable")) {
return;
}
var entity = e.getRightClicked();
EntityType entityType = entity.getType();
Player player = e.getPlayer();
if (SHIFT_CLICK_TYPES.contains(entityType) && !player.isSneaking()) {
return;
}
Plot plot = null;
loop: for (var arena : ArenaManager.getInstance().getArenas()) {
for (Plot p : arena.getUsedPlots()) {
if (p.getEntities().containsKey(entity)) {
plot = p;
break loop;
}
}
}
if (plot == null || plot.getArena().getState() != GameState.BUILDING) {
return;
}
switch(entityType) {
case CHICKEN:
case COW:
case GOAT:
case OCELOT:
case SKELETON_HORSE:
case POLAR_BEAR:
case HUSK:
case ZOMBIE:
case TURTLE:
case PIGLIN:
case HOGLIN:
case STRIDER:
case ZOGLIN:
new BabyMenu(plot, entity).show(player);
break;
case DONKEY:
case MULE:
new ChestMenu(plot, (ChestedHorse) entity).show(player);
break;
case VILLAGER:
case ZOMBIE_VILLAGER:
new VillagerlikeMenu(plot, (Creature) entity).show(player);
break;
case PHANTOM:
case MAGMA_CUBE:
case SLIME:
new SizeMenu(plot, (Mob) entity).show(player);
break;
case AXOLOTL:
new AxolotlMenu(plot, (Axolotl) entity).show(player);
break;
case PIG:
new PigMenu(plot, (Pig) entity).show(player);
break;
case RABBIT:
new RabbitMenu(plot, (Rabbit) entity).show(player);
break;
case SHEEP:
new SheepMenu(plot, (Sheep) entity).show(player);
break;
case CREEPER:
new CreeperMenu(plot, (Creeper) entity).show(player);
break;
case SHULKER:
new ShulkerMenu(plot, (Shulker) entity).show(player);
break;
case HORSE:
new HorseMenu(plot, (Horse) entity).show(player);
break;
case LLAMA:
new LlamaMenu(plot, (Llama) entity).show(player);
break;
case PARROT:
new ParrotMenu(plot, (Parrot) entity).show(player);
break;
case WOLF:
new ColorMenu(plot, (Animals) entity).show(player);
break;
case SNOWMAN:
new SnowGolemMenu(plot, (Snowman) entity).show(player);
break;
case PUFFERFISH:
new PufferfishMenu(plot, (PufferFish) entity).show(player);
break;
case TROPICAL_FISH:
new TropicalFishMenu(plot, (TropicalFish) entity).show(player);
break;
case MUSHROOM_COW:
new MooshroomMenu(plot, (MushroomCow) entity).show(player);
break;
case PANDA:
new PandaMenu(plot, (Panda) entity).show(player);
break;
case CAT:
new CatMenu(plot, (Cat) entity).show(player);
break;
case FOX:
new FoxMenu(plot, (Fox) entity).show(player);
break;
case BEE:
new BeeMenu(plot, (Bee) entity).show(player);
break;
case IRON_GOLEM:
new IronGolemMenu(plot, (IronGolem) entity).show(player);
break;
default:
new RemoveMenu(plot, entity).show(player);
break;
}
e.setCancelled(true);
}
Aggregations