Skip to content

Commit

Permalink
Update to 1.19
Browse files Browse the repository at this point in the history
Co-authored-by: RacoonDog <[email protected]>
  • Loading branch information
SIMULATAN and RacoonDog authored Mar 9, 2023
1 parent 2a85aba commit 498156d
Show file tree
Hide file tree
Showing 17 changed files with 795 additions and 796 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[*]
charset = utf-8
indent_style = space
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true
indent_size = 4
Expand Down
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.10-SNAPSHOT'
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'maven-publish'
}

Expand All @@ -10,6 +10,7 @@ version = project.mod_version
group = project.maven_group

repositories {
mavenCentral()
maven {
name = "meteor-maven"
url = "https://maven.meteordev.org/releases"
Expand All @@ -18,6 +19,7 @@ repositories {
name = "meteor-maven-snapshots"
url = "https://maven.meteordev.org/snapshots"
}
maven { url 'https://jitpack.io' }
}

dependencies {
Expand Down Expand Up @@ -49,4 +51,4 @@ processResources {
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release = 17
}
}
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
org.gradle.jvmargs=-Xmx2G

# Fabric (https://fabricmc.net/versions.html)
minecraft_version=1.18.2
yarn_mappings=1.18.2+build.1
loader_version=0.12.12
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.8
loader_version=0.14.9

# Mod Properties
mod_version=1.0.2
mod_version=1.1.0
maven_group=com.github.simulatan
archives_base_name=notifications-addon

# Dependency Versions

# Meteor (https://maven.meteordev.org/)
meteor_version=SNAPSHOT
meteor_version=0.5.1-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,30 @@

import com.github.simulatan.meteornotificationsaddon.commands.NotificationsCommand;
import com.github.simulatan.meteornotificationsaddon.hud.NotificationsHudElement;
import meteordevelopment.meteorclient.MeteorClient;
import com.mojang.logging.LogUtils;
import meteordevelopment.meteorclient.addons.MeteorAddon;
import meteordevelopment.meteorclient.systems.Systems;
import meteordevelopment.meteorclient.systems.commands.Commands;
import meteordevelopment.meteorclient.systems.hud.HUD;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.lang.invoke.MethodHandles;
import meteordevelopment.meteorclient.systems.hud.Hud;
import meteordevelopment.meteorclient.systems.hud.HudGroup;
import org.slf4j.Logger;

public class NotificationsAddon extends MeteorAddon {

public static final Logger LOG = LogManager.getLogger();
public static final Logger LOG = LogUtils.getLogger();
public static final HudGroup HUD_GROUP = new HudGroup("Notifications");

@Override
public void onInitialize() {
LOG.info("Initializing Meteor Notifications Addon by SIMULATAN");

// Required when using @EventHandler
MeteorClient.EVENT_BUS.registerLambdaFactory("com.github.simulatan.meteornotificationsaddon", (lookupInMethod, clazz) -> (MethodHandles.Lookup) lookupInMethod.invoke(null, clazz, MethodHandles.lookup()));

Commands.get().add(new NotificationsCommand());
Commands.get().add(new NotificationsCommand());

// HUD
HUD hud = Systems.get(HUD.class);
hud.elements.add(new NotificationsHudElement(hud));
Hud.get().register(NotificationsHudElement.INFO);
}

@Override
public String getPackage() {
return this.getClass().getPackageName();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.simulatan.meteornotificationsaddon.notifications.Notification;
import com.github.simulatan.meteornotificationsaddon.notifications.NotificationsManager;
import com.mojang.brigadier.LiteralMessage;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.arguments.ArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
Expand All @@ -13,7 +14,6 @@
import meteordevelopment.meteorclient.systems.commands.Command;
import meteordevelopment.meteorclient.utils.player.ChatUtils;
import net.minecraft.command.CommandSource;
import net.minecraft.text.LiteralText;

import java.awt.*;
import java.util.Arrays;
Expand All @@ -26,54 +26,54 @@

public class NotificationsCommand extends Command {

public NotificationsCommand() {
super("notifications", "Sends a dummy notification");
}
public NotificationsCommand() {
super("notifications", "Sends a dummy notification");
}

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(argument("mode", new NotificationsArgumentType()).executes(context -> {
NotificationCommandType arg = context.getArgument("mode", NotificationCommandType.class);
if (arg == NotificationCommandType.SEND) {
NotificationsManager.add(new Notification("hey, this is a test!", "very cool indeed yes", new Color((int) (Math.random() * 0x1000000))));
ChatUtils.info("Notifications", "Successfully triggered notification!");
} else if (arg == NotificationCommandType.CLEAR) {
NotificationsManager.clearNotifications();
ChatUtils.warning("Notifications", "Successfully cleared notifications!");
}
return SINGLE_SUCCESS;
}));
}
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(argument("mode", new NotificationsArgumentType()).executes(context -> {
NotificationCommandType arg = context.getArgument("mode", NotificationCommandType.class);
if (arg == NotificationCommandType.SEND) {
NotificationsManager.add(new Notification("hey, this is a test!", "very cool indeed yes", new Color((int) (Math.random() * 0x1000000))));
ChatUtils.info("Notifications", "Successfully triggered notification!");
} else if (arg == NotificationCommandType.CLEAR) {
NotificationsManager.clearNotifications();
ChatUtils.warning("Notifications", "Successfully cleared notifications!");
}
return SINGLE_SUCCESS;
}));
}

private enum NotificationCommandType {
SEND,
CLEAR;
private enum NotificationCommandType {
SEND,
CLEAR
}

private static class NotificationsArgumentType implements ArgumentType<NotificationCommandType> {
private static class NotificationsArgumentType implements ArgumentType<NotificationCommandType> {

private static final DynamicCommandExceptionType NO_SUCH_MODULE = new DynamicCommandExceptionType(o -> new LiteralText("Type " + o + " doesn't exist."));
private static final DynamicCommandExceptionType NO_SUCH_MODULE = new DynamicCommandExceptionType(o -> new LiteralMessage("Type " + o + " doesn't exist."));

@Override
public NotificationCommandType parse(StringReader reader) throws CommandSyntaxException {
String argument = reader.readString();
try {
return NotificationCommandType.valueOf(argument.toUpperCase());
} catch (Exception ignored){
throw NO_SUCH_MODULE.create(argument);
}
}
@Override
public NotificationCommandType parse(StringReader reader) throws CommandSyntaxException {
String argument = reader.readString();
try {
return NotificationCommandType.valueOf(argument.toUpperCase());
} catch (Exception ignored) {
throw NO_SUCH_MODULE.create(argument);
}
}

@Override
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
return CommandSource.suggestMatching(Arrays.stream(NotificationCommandType.values()).map(NotificationCommandType::name), builder);
}
@Override
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
return CommandSource.suggestMatching(Arrays.stream(NotificationCommandType.values()).map(NotificationCommandType::name), builder);
}

private static final List<String> EXAMPLES = Arrays.stream(NotificationCommandType.values()).map(Enum::name).collect(Collectors.toList());
private static final List<String> EXAMPLES = Arrays.stream(NotificationCommandType.values()).map(Enum::name).collect(Collectors.toList());

@Override
public Collection<String> getExamples() {
return EXAMPLES;
}
}
}
@Override
public Collection<String> getExamples() {
return EXAMPLES;
}
}
}
Loading

0 comments on commit 498156d

Please sign in to comment.