use of simplepets.brainsynder.PetCore in project SimplePets by brainsynder-Dev.
the class ItemLoaders method initiate.
public void initiate() {
PetCore core = PetCore.get();
PetCore.get().debug("Initializing Menu Items...");
if (items != null)
if (!items.isEmpty())
items.clear();
PetCore.get().debug("Loading Customizable Item Files...");
File customFolder = new File(core.getDataFolder().toString() + "/Items/Custom/");
if (!customFolder.exists())
customFolder.mkdirs();
List<File> files = Arrays.asList(customFolder.listFiles());
add(new Air(Item.getLocation(core, Air.class)));
add(new Hat(Item.getLocation(core, Hat.class)));
add(new Name(Item.getLocation(core, Name.class)));
add(new NextPage(Item.getLocation(core, NextPage.class)));
add(new PreviousPage(Item.getLocation(core, PreviousPage.class)));
add(new Remove(Item.getLocation(core, Remove.class)));
add(new Ride(Item.getLocation(core, Ride.class)));
add(new Storage(Item.getLocation(core, Storage.class)));
add(new Placeholder(Item.getLocation(core, Placeholder.class)));
add(new Data(Item.getLocation(core, Data.class)));
add(new SavePet(Item.getLocation(core, SavePet.class)));
add(new Saves(Item.getLocation(core, Saves.class)));
add(new RedPlaceholder(Item.getLocation(core, RedPlaceholder.class)));
add(new Update(Item.getLocation(core, Update.class)));
add(new FlameOn(new File(customFolder, "flameon.json")));
for (Item loader : items.values()) {
loader.save();
}
PetCore.get().debug("Files have been loaded.");
if (!files.isEmpty()) {
for (File file : files) {
if (!file.getName().endsWith(".json"))
continue;
Item item = new Item(file);
if (item.hasKey("namespace") && item.isEnabled()) {
items.putIfAbsent(item.namespace(), item);
}
}
}
AIR = getLoader(Air.class);
PLACEHOLDER = getLoader(Placeholder.class);
RED_PLACEHOLDER = getLoader(RedPlaceholder.class);
DATA = getLoader(Data.class);
}
use of simplepets.brainsynder.PetCore in project SimplePets by brainsynder-Dev.
the class OnPetSpawn method onCreatureSpawnUnBlock.
@EventHandler(priority = EventPriority.HIGHEST)
public void onCreatureSpawnUnBlock(CreatureSpawnEvent event) {
Entity e = event.getEntity();
PetCore core = PetCore.get();
if (ReflectionUtil.getEntityHandle(e) instanceof IImpossaPet && event.isCancelled()) {
if (core.getConfiguration().getBoolean("Complete-Mobspawning-Deny-Bypass") || core.getLinkRetriever().getProtectionLink(IWorldGuardLink.class).allowPetSpawn(event.getLocation()) || core.getLinkRetriever().getProtectionLink(IPlotSquaredLink.class).allowPetSpawn(event.getLocation()) || core.getLinkRetriever().getProtectionLink(IWorldBorderLink.class).allowPetSpawn(event.getLocation())) {
event.setCancelled(false);
}
}
}
use of simplepets.brainsynder.PetCore in project SimplePets by brainsynder-Dev.
the class OnPetSpawn method onMove.
@EventHandler
public void onMove(PetMoveEvent e) {
try {
if (e.getEntity() == null)
return;
if (e.getEntity().getPet() != null && e.getEntity().getOwner() != null) {
IEntityPet entity = e.getEntity();
PetOwner petOwner = PetOwner.getPetOwner(entity.getOwner());
PetCore core = PetCore.get();
if (e.getCause() == PetMoveEvent.Cause.RIDE) {
if (!core.getLinkRetriever().canRidePet(petOwner, entity.getEntity().getLocation())) {
petOwner.getPet().setVehicle(false, false);
entity.getOwner().sendMessage(PetCore.get().getMessages().getString("Pet-No-Enter", true));
}
return;
}
if (!core.getLinkRetriever().canPetEnter(petOwner, entity.getEntity().getLocation())) {
petOwner.removePet();
entity.getOwner().sendMessage(PetCore.get().getMessages().getString("Pet-No-Enter", true));
}
}
} catch (Exception ignored) {
}
}
use of simplepets.brainsynder.PetCore in project SimplePets by brainsynder-Dev.
the class OnPetSpawn method onCreatureSpawnUnBlock.
@EventHandler(priority = EventPriority.HIGHEST)
public void onCreatureSpawnUnBlock(EntitySpawnEvent event) {
Entity e = event.getEntity();
PetCore core = PetCore.get();
if (ReflectionUtil.getEntityHandle(e) instanceof IImpossaPet && event.isCancelled()) {
if (core.getConfiguration().getBoolean("Complete-Mobspawning-Deny-Bypass") || core.getLinkRetriever().getProtectionLink(IWorldGuardLink.class).allowPetSpawn(event.getLocation()) || core.getLinkRetriever().getProtectionLink(IPlotSquaredLink.class).allowPetSpawn(event.getLocation()) || core.getLinkRetriever().getProtectionLink(IWorldBorderLink.class).allowPetSpawn(event.getLocation())) {
event.setCancelled(false);
}
}
}
use of simplepets.brainsynder.PetCore in project SimplePets by brainsynder-Dev.
the class InvLoaders method initiate.
public void initiate() {
PetCore core = PetCore.get();
PetCore.get().debug("Initializing Inventories...");
if (loaders != null)
if (!loaders.isEmpty())
loaders.clear();
PetCore.get().debug("Loading Customizable Inventories Files...");
loaders.add(new SelectionMenu(CustomInventory.getLocation(core, SelectionMenu.class)));
loaders.add(new DataMenu(CustomInventory.getLocation(core, DataMenu.class)));
loaders.add(new SavesMenu(CustomInventory.getLocation(core, SavesMenu.class)));
loaders.add(new ArmorMenu(CustomInventory.getLocation(core, ArmorMenu.class)));
for (CustomInventory loader : loaders) {
loader.save();
loader.load();
}
PetCore.get().debug("Files have been loaded.");
SELECTION = getLoader(SelectionMenu.class);
PET_DATA = getLoader(DataMenu.class);
SAVES = getLoader(SavesMenu.class);
ARMOR = getLoader(ArmorMenu.class);
}
Aggregations