本文整理汇总了Java中com.dsh105.echopet.listeners.PetEntityListener类的典型用法代码示例。如果您正苦于以下问题:Java PetEntityListener类的具体用法?Java PetEntityListener怎么用?Java PetEntityListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PetEntityListener类属于com.dsh105.echopet.listeners包,在下文中一共展示了PetEntityListener类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEnable
import com.dsh105.echopet.listeners.PetEntityListener; //导入依赖的package包/类
@Override
@SneakyThrows(IOException.class)
public void onEnable() {
EchoPet.setPlugin(this);
isUsingNetty = CommonReflection.isUsingNetty();
this.configManager = new YAMLConfigManager(this);
COMMAND_MANAGER = new CommandManager(this);
// Make sure that the plugin is running under the correct version to prevent errors
if (NmsVersion.current() == null || !INMS.isSupported()) {
EchoPet.LOG.log(ChatColor.RED + "SonarPet " + ChatColor.GOLD
+ this.getDescription().getVersion() + ChatColor.RED
+ " is not compatible with this version of CraftBukkit");
EchoPet.LOG.log(ChatColor.RED + "Initialisation failed. Please update the plugin.");
DynamicPluginCommand cmd = new DynamicPluginCommand(this.cmdString, new String[0], "", "",
new VersionIncompatibleCommand(this, this.cmdString, ChatColor.YELLOW +
"SonarPet " + ChatColor.GOLD + this.getDescription().getVersion() + ChatColor.YELLOW + " is not compatible with this version of CraftBukkit. Please update the plugin.",
"echopet.pet", ChatColor.YELLOW + "You are not allowed to do that."),
null, this);
COMMAND_MANAGER.register(cmd);
return;
}
EntityRegistry entityRegistry;
if (CitizensEntityRegistryHack.isNeeded()) {
getLogger().warning("Attempting to inject citizens compatibility hack....");
entityRegistry = CitizensEntityRegistryHack.createInstance();
getLogger().warning("Successfully injected citizens compatibility hack!");
} else {
//noinspection deprecation // We check for citizens first ;)
entityRegistry = INMS.getInstance().createDefaultEntityRegistry();
}
this.entityRegistry = Objects.requireNonNull(entityRegistry);
this.loadConfiguration();
PluginManager manager = getServer().getPluginManager();
MANAGER = new PetManager();
SQL_MANAGER = new SqlPetManager();
if (OPTIONS.useSql()) {
this.prepareSqlDatabase();
}
// Register custom commands
// Command string based off the string defined in config.yml
// By default, set to 'pet'
// PetAdmin command draws from the original, with 'admin' on the end
this.cmdString = OPTIONS.getCommandString();
this.adminCmdString = OPTIONS.getCommandString() + "admin";
DynamicPluginCommand petCmd = new DynamicPluginCommand(this.cmdString, new String[0], "Create and manage your own custom pets.", "Use /" + this.cmdString + " help to see the command list.", new PetCommand(this.cmdString), null, this);
petCmd.setTabCompleter(new CommandComplete());
COMMAND_MANAGER.register(petCmd);
COMMAND_MANAGER.register(new DynamicPluginCommand(this.adminCmdString, new String[0], "Create and manage the pets of other players.", "Use /" + this.adminCmdString + " help to see the command list.", new PetAdminCommand(this.adminCmdString), null, this));
// Initialize hook classes
for (ClassPath.ClassInfo hookType : ClassPath.from(getClass().getClassLoader()).getTopLevelClasses("net.techcable.sonarpet.nms.entity.type")) {
if (!hookType.load().isAnnotationPresent(EntityHook.class)) continue;
for (EntityHookType type : hookType.load().getAnnotation(EntityHook.class).value()) {
if (!type.isActive()) continue;
hookRegistry.registerHookClass(type, hookType.load().asSubclass(IEntityPet.class));
}
}
// Register listeners
manager.registerEvents(new MenuListener(), this);
manager.registerEvents(new PetEntityListener(this), this);
manager.registerEvents(new PetOwnerListener(), this);
if (VersionNotificationListener.isNeeded()) {
manager.registerEvents(new VersionNotificationListener(), this);
PluginVersioning.INSTANCE.sendOutdatedVersionNotification(Bukkit.getConsoleSender());
}
//manager.registerEvents(new ChunkListener(), this);
this.vanishProvider = new VanishProvider(this);
this.worldGuardProvider = new WorldGuardProvider(this);
}