use of fr.neatmonster.nocheatplus.utilities.entity.PassengerUtil in project NoCheatPlus by NoCheatPlus.
the class NoCheatPlus method onEnable.
/* (non-Javadoc)
* @see org.bukkit.plugin.java.JavaPlugin#onEnable()
*/
@Override
public void onEnable() {
// Reset TickTask (just in case).
TickTask.setLocked(true);
TickTask.purge();
TickTask.cancel();
TickTask.reset();
// Allow entries to TickTask.
TickTask.setLocked(false);
// Re-check basic setup (if onLoad gets skipped by some custom thing).
setupBasics();
if (Bugs.shouldEnforceLocation()) {
addFeatureTags("defaults", Arrays.asList("enforceLocation"));
}
if (Bugs.shouldPvpKnockBackVelocity()) {
addFeatureTags("defaults", Arrays.asList("pvpKnockBackVelocity"));
}
if (pDataMan.storesPlayerInstances()) {
addFeatureTags("defaults", Arrays.asList("storePlayers"));
}
// Start logger task(s).
logManager.startTasks();
final ConfigFile config = ConfigManager.getConfigFile();
// Set some instance members.
setInstanceMembers(config);
// Register some generic stuff.
// (Deny change some.)
registerGenericInstance(new Counters());
genericInstanceRegistry.denyChangeExistingRegistration(Counters.class);
registerGenericInstance(new WRPT());
genericInstanceRegistry.denyChangeExistingRegistration(WRPT.class);
// Random number.
registerGenericInstance(new TraceEntryPool(1000));
genericInstanceRegistry.denyChangeExistingRegistration(TraceEntryPool.class);
registerGenericInstance(new PassengerUtil());
genericInstanceRegistry.denyChangeExistingRegistration(PassengerUtil.class);
// (Allow override others.)
registerGenericInstance(new Random(System.currentTimeMillis() ^ ((long) this.hashCode() * (long) eventRegistry.hashCode() * (long) logManager.hashCode())));
addComponent(new BridgeCrossPlugin());
// World data init (basic).
for (final World world : Bukkit.getWorlds()) {
onWorldPresent(world);
}
// Initialize MCAccess.
initMCAccess(config);
// Initialize BlockProperties.
initBlockProperties(config);
// Initialize data manager.
worldDataManager.onEnable();
pDataMan.onEnable();
// Add the "low level" system components first.
for (final Object obj : new Object[] { getCoreListener(), reloadHook, pDataMan, new AuxMoving() }) {
addComponent(obj);
// Register sub-components (allow later added to use registries, if any).
processQueuedSubComponentHolders();
}
updateBlockChangeTracker(config);
// Register "higher level" components (check listeners).
for (final Object obj : new Object[] { new BlockInteractListener(), new BlockBreakListener(), new BlockPlaceListener(), new ChatListener(), new CombinedListener(), // Do mind registration order: Combined must come before Fight.
new FightListener(), new InventoryListener(), new MovingListener() }) {
addComponent(obj);
// Register sub-components (allow later added to use registries, if any).
processQueuedSubComponentHolders();
}
// Ensure net types are registered.
NetStatic.registerTypes();
// Register optional default components.
final DefaultComponentFactory dcf = new DefaultComponentFactory();
for (final Object obj : dcf.getAvailableComponentsOnEnable(this)) {
addComponent(obj);
// Register sub-components to enable registries for optional components.
processQueuedSubComponentHolders();
}
// Register the commands handler.
final PluginCommand command = getCommand("nocheatplus");
final NoCheatPlusCommand commandHandler = new NoCheatPlusCommand(this, notifyReload);
command.setExecutor(commandHandler);
// (CommandHandler is TabExecutor.)
// Tell the permission registry, which permissions should get updated.
// TODO: confine by check enabled flags.
permissionRegistry.preferKeepUpdated(NetConfig.getPreferKeepUpdatedPermissions());
permissionRegistry.preferKeepUpdated(ChatConfig.getPreferKeepUpdatedPermissions());
permissionRegistry.arrangePreferKeepUpdated();
// //////////////////////////////
// Tasks, post-rumble-logging
// //////////////////////////////
// Set up the tick task.
TickTask.start(this);
// dataMan expiration checking.
this.dataManTaskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
pDataMan.checkExpiration();
}
}, 1207, 1207);
// Ensure dataMan is first on disableListeners.
// TODO: Why first ?
Misc.putFirst(pDataMan, disableListeners);
Misc.putFirst(pDataMan, notifyReload);
Misc.putFirst(worldDataManager, notifyReload);
// Put ReloadListener first, because Checks could also listen to it.
Misc.putFirst(reloadHook, notifyReload);
// Set up consistency checking.
scheduleConsistencyCheckers();
// Setup allViolationsHook
allViolationsHook.setConfig(new AllViolationsConfig(config));
// if (config.getBoolean(ConfPaths.MISCELLANEOUS_CHECKFORUPDATES)) {
// // Is a new update available?
// final int timeout = config.getInt(ConfPaths.MISCELLANEOUS_UPDATETIMEOUT, 4) * 1000;
// getServer().getScheduler().scheduleAsyncDelayedTask(this, new Runnable() {
// @Override
// public void run() {
// updateAvailable = Updates.checkForUpdates(getDescription().getVersion(), timeout);
// }
// });
// }
// Log other notes.
logOtherNotes(config);
// Is the version the configuration was created with consistent with the current one?
if (configProblemsFile != null && config.getBoolean(ConfPaths.CONFIGVERSION_NOTIFY)) {
// Could use custom prefix from logging, however ncp should be mentioned then.
logManager.warning(Streams.INIT, "" + configProblemsFile);
}
// Care for already online players.
final Player[] onlinePlayers = BridgeMisc.getOnlinePlayers();
// TODO: re-map ExemptionManager !
// TODO: Disable all checks for these players for one tick ?
// TODO: Prepare check data for players [problem: permissions]?
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new PostEnableTask(onlinePlayers));
// Mid-term cleanup (seconds range).
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
midTermCleanup();
}
}, 83, 83);
// Set StaticLog to more efficient output.
StaticLog.setStreamID(Streams.STATUS);
// Tell the server administrator that we finished loading NoCheatPlus now.
logManager.info(Streams.INIT, "Version " + getDescription().getVersion() + " is enabled.");
}
Aggregations