use of cc.hyperium.event.InvokeEvent in project Hyperium by HyperiumClient.
the class ReachDisplay method onAttack.
@InvokeEvent
public void onAttack(PlayerAttackEntityEvent event) {
if (mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mc.objectMouseOver.entityHit.getEntityId() == event.getEntity().getEntityId()) {
Vec3 vec = mc.getRenderViewEntity().getPositionEyes(1.0f);
double range = mc.objectMouseOver.hitVec.distanceTo(vec);
rangeText = new DecimalFormat(".##").format(range) + " blocks";
} else {
rangeText = "Not on target?";
}
lastAttack = System.currentTimeMillis();
}
use of cc.hyperium.event.InvokeEvent in project Hyperium by HyperiumClient.
the class CompactChat method onChat.
/**
* Check for when a message comes through
*
* @param event called whenever a message is sent through chat
*/
@InvokeEvent(priority = Priority.LOW)
public void onChat(ChatEvent event) {
// Check for the if the user has it enabled and if the message wasn't cancelled
if (Settings.COMPACT_CHAT && !event.isCancelled()) {
// Get the chat instance
GuiNewChat guiNewChat = Minecraft.getMinecraft().ingameGUI.getChatGUI();
// If the last message sent is the same as the newly posted message
if (lastMessage.equals(event.getChat().getUnformattedText())) {
// Delete the message
guiNewChat.deleteChatLine(line);
// Increase the amount of times it's been sent
amount++;
// Set the last message to be the newly posted message
lastMessage = event.getChat().getUnformattedText();
// Append (amount of times it's been sent) to the last message
event.getChat().appendText(ChatColor.GRAY + " (" + amount + ")");
} else {
// Otherwise it's never been sent
amount = 1;
// Set the last message to be the newly posted message
lastMessage = event.getChat().getUnformattedText();
}
// Increase the line the message was on
line++;
// Check if the event wasn't cancelled
if (!event.isCancelled()) {
// Print the chat message and allow it to be deleted
guiNewChat.printChatMessageWithOptionalDeletion(event.getChat(), line);
}
// If the message has been sent 256 times
if (line > 256) {
// Set it to 0 again
line = 0;
}
// Cancel the message
event.setCancelled(true);
}
}
use of cc.hyperium.event.InvokeEvent in project Hyperium by HyperiumClient.
the class PurchaseApi method worldSwitch.
@InvokeEvent
public void worldSwitch(SpawnpointChangeEvent event) {
Multithreading.runAsync(() -> {
synchronized (instance) {
UUID id = UUIDUtil.getClientUUID();
if (id == null)
return;
HyperiumPurchase purchase = purchasePlayers.get(id);
purchasePlayers.clear();
if (purchase != null)
purchasePlayers.put(id, purchase);
nameToUuid.clear();
}
});
}
use of cc.hyperium.event.InvokeEvent in project Hyperium by HyperiumClient.
the class Hyperium method init.
/**
* Initialize all local variables
* <p>
* Create / check for important things that need to be loaded
* before the client officially allows the player to use it.
*
* @param event Fired on startup, after screen is displayed {@link InitializationEvent}
*/
@InvokeEvent(priority = Priority.HIGH)
public void init(InitializationEvent event) {
try {
// Create the network handler, register it in config, then check for a LoginReply
Multithreading.runAsync(() -> {
networkHandler = new NetworkHandler();
CONFIG.register(networkHandler);
this.client = new NettyClient(networkHandler);
UniversalNetty.getInstance().getPacketManager().register(new LoginReplyHandler());
});
// Initialize notifications
notification = new NotificationCenter();
// Get the build id
createBuildId();
Hyperium.LOGGER.info("Hyperium Build ID: {}", BUILD_ID);
// Check for if the user is in a developers environment
checkForDevEnvironment();
// Initialize cosmetics
cosmetics = new HyperiumCosmetics();
// If it's the users first launch, create a folder to store their lock file in
firstLaunch = new File(folder.getAbsolutePath() + "/accounts").mkdirs();
// Determine if the users ever charge backed, if they have, they won't be allowed to launch
new ChargebackStopper();
// Create a lock file if the user accepts the TOS
this.acceptedTos = new File(folder.getAbsolutePath() + "/accounts/" + Minecraft.getMinecraft().getSession().getPlayerID() + ".lck").exists();
SplashProgress.setProgress(5, I18n.format("splashprogress.loadinghandlers"));
// Initialize handlers
handlers = new HyperiumHandlers();
handlers.postInit();
SplashProgress.setProgress(6, I18n.format("splashprogress.registeringlisteners"));
// Register events
EventBus.INSTANCE.register(new ToggleSprintContainer());
EventBus.INSTANCE.register(notification);
EventBus.INSTANCE.register(CompactChat.getInstance());
EventBus.INSTANCE.register(CONFIG.register(FPSLimiter.getInstance()));
EventBus.INSTANCE.register(confirmation);
EventBus.INSTANCE.register(statTrack);
CONFIG.register(statTrack);
CONFIG.register(new ToggleSprintContainer());
SplashProgress.setProgress(7, I18n.format("splashprogress.startinghyperium"));
LOGGER.info("[Hyperium] Started!");
// Set the window title
Display.setTitle("Hyperium " + Metadata.getVersion());
SplashProgress.setProgress(8, I18n.format("splashprogress.registeringconfiguration"));
// Register the settings
Settings.register();
CONFIG.register(new ColourOptions());
SplashProgress.setProgress(9, I18n.format("splashprogress.registeringcommands"));
// Register all the default commands
registerCommands();
// Initialize the Purchase API
EventBus.INSTANCE.register(PurchaseApi.getInstance());
SplashProgress.setProgress(10, I18n.format("splashprogress.loadingintegrations"));
// Register mods & addons
modIntegration = new HyperiumModIntegration();
internalAddons = new InternalAddons();
// Fetch Hyperium staff members
fetchStaffMembers();
// Add a thread for shutdowns
Runtime.getRuntime().addShutdownHook(new Thread(this::shutdown));
// Load
richPresenceManager.load();
// Check if the user has accepted the TOS, if they have, check the Hyperium status
if (acceptedTos) {
sk1erMod = new Sk1erMod("hyperium", Metadata.getVersion(), object -> {
if (object.has("enabled") && !object.optBoolean("enabled")) {
handlers.getHyperiumCommandHandler().clear();
}
});
sk1erMod.checkStatus();
}
SplashProgress.setProgress(11, I18n.format("splashprogress.finishing"));
// Load the previous chat session
loadPreviousChatFile();
// Fetch the current version
fetchVersion();
// Check if the user is running Optifine
if (AddonCheckerUtil.isUsingOptifine()) {
// 🦀
optifineInstalled = true;
}
// Print every loaded addon
collectAddons();
LOGGER.info("Hyperium loaded in {} seconds", (System.currentTimeMillis() - launchTime) / 1000F);
} catch (Throwable t) {
// If an issue is caught, crash the game
Minecraft.getMinecraft().crashed(new CrashReport("Hyperium Startup Failure", t));
}
}
use of cc.hyperium.event.InvokeEvent in project Hyperium by HyperiumClient.
the class Hyperium method preinit.
/**
* Register things such as Languages to be used throughout the game.
*
* @param event Fired on startup, before screen is displayed {@link PreInitializationEvent}
*/
@InvokeEvent
public void preinit(PreInitializationEvent event) {
EventBus.INSTANCE.register(new AutoGG());
HyperiumLocale.registerHyperiumLang("af_ZA");
HyperiumLocale.registerHyperiumLang("ar_SA");
HyperiumLocale.registerHyperiumLang("bs_BA");
HyperiumLocale.registerHyperiumLang("de_DE");
HyperiumLocale.registerHyperiumLang("en_US");
HyperiumLocale.registerHyperiumLang("ga_IE");
HyperiumLocale.registerHyperiumLang("ja_JP");
}
Aggregations