Skip to content

Commit

Permalink
Merge branch 'v4.0.0-1.19.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen3H committed Apr 10, 2023
2 parents e18b7ae + a0c60ff commit 532a574
Show file tree
Hide file tree
Showing 38 changed files with 711 additions and 882 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ A fabric mod designed for EarthMC that provides info on people, places and more.
- `/townless inviteAll/revokeAll` - Automatically invite/revoke all townless players to/from your town!
- `/nether <x> <z>` - Quickly convert overworld coordinates into their nether counterpart.
#### On-Screen Info
- Townless - All online townless players are shown on your screen.
- Townless - Show a list of online townless players and their (optional) coords.
- Nearby - See anyone whose close to you without checking the dynmap! Configurable options include: radius, rank and distance.
- News - Sometimes it's hard to keep up with the news. EMCE sends news to your action bar (or chat) as soon as it is reported.
#### Config screen (F4)
- API Intervals - Set the rate at which you want data to be updated.
- Data - Toggle on/off, screen x/y position, text colors, radius and more.
Expand All @@ -30,7 +29,7 @@ A fabric mod designed for EarthMC that provides info on people, places and more.
>*I recommend you use the [latest](https://github.com/EarthMC-Toolkit/EarthMCEssentials/releases/latest) EMCE version, with `Fabric API 0.72.0` and `Fabric Loader 0.14.12`, delete the file `emc-essentials.json` in your config folder and reboot MC. It is also worth checking the output log since some mods may conflict with EMCE.*
**How is data obtained?**
>*All data is acquired from our [API](https://emc-toolkit.vercel.app/api) in conjuction with info from the Minecraft client.*
>*Most data comes from the purpose-made [EMC-Wrapper](https://github.com/EarthMC-Toolkit/EarthMC-Wrapper) library, while custom data is acquired from the [API](https://emc-toolkit.vercel.app/api).*
**Is there a Forge version?**
>*Not right now. There may be a re-write using the Architectuary API, but this won't be any time soon.*
Expand Down
51 changes: 36 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
plugins {
id 'fabric-loom' version '1.0-SNAPSHOT'
id 'fabric-loom' version '1.1-SNAPSHOT'
}

version = "${project.mod_version}-${project.minecraft_version}+" as Object
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

version = "v${project.mod_version}-${project.minecraft_version}" as Object
group = project.maven_group

def localProps = new Properties()
localProps.load(new FileInputStream(rootProject.file("local.properties")))

repositories {
mavenCentral()

maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/earthmc-toolkit/earthmc-wrapper")
credentials {
username = project.findProperty("gpr.user")
password = System.getenv("GITHUB_TOKEN")
username = localProps.getProperty("USERNAME")
password = localProps.getProperty("GITHUB_TOKEN")
}
}

Expand All @@ -25,27 +31,46 @@ dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"

modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "com.terraformersmc:modmenu:${project.mod_menu_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modImplementation include("net.kyori:adventure-platform-fabric:${project.adventure_fabric_version}")
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude(group: "com.google.code.gson")
exclude(group: "net.fabricmc.fabric-api")
}

// Libraries to include in remapJar
include "me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}"

//implementation "io.github.emcw:emc-wrapper:${project.wrapper_version}"
modImplementation("com.terraformersmc:modmenu:${project.mod_menu_version}") {
exclude(group: "net.fabricmc", module: "fabric-loader")
}

modImplementation include("net.kyori:adventure-platform-fabric:${project.adventure_fabric_version}") {
exclude(group: "net.fabricmc", module: "fabric-loader")
}

api include("io.github.emcw:emc-wrapper:${project.wrapper_version}") {
exclude(group: "org.jetbrains")
exclude(group: "com.google.code.gson")
exclude(group: "org.apache.commons", module: "commons-lang3")
}

include 'org.apache.commons:commons-lang3:3.12.0'
include 'com.google.code.gson:gson:2.10.1'

compileOnly 'org.jetbrains:annotations:24.0.1'
annotationProcessor 'org.jetbrains:annotations:24.0.1'

compileOnly 'org.projectlombok:lombok:1.18.26'
annotationProcessor 'org.projectlombok:lombok:1.18.26'
}

processResources {
inputs.property "version", version
inputs.property "version", project.version

filesMatching("fabric.mod.json") {
expand "version": version
expand("version": project.version)
}
}

Expand All @@ -54,9 +79,5 @@ tasks.withType(JavaCompile).configureEach {
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}

withSourcesJar()
}
16 changes: 7 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
org.gradle.parallel=true
org.gradle.jvmargs=-Xms256m -Xmx1G -Dfile.encoding=UTF-8 -XX:+UseG1GC
org.gradle.workers.max=4
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.workers.max=4

# Fabric properties
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.5
loader_version=0.14.12
fabric_version=0.72.0+1.19.3
wrapper_version=1.0.0

# Mod Properties
name = EarthMCEssentials
mod_version = 3.6.0
mod_version = 4.0.0
maven_group = net.emc.emce

# Library versions
cloth_config_version = 9.0.94
mod_menu_version = 5.0.2
adventure_fabric_version = 5.6.1

gpr.user = "Owen3H"
cloth_config_version=9.0.94
mod_menu_version=5.0.2
adventure_fabric_version=5.6.1
wrapper_version=0.10.2
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
16 changes: 11 additions & 5 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

#
# Copyright © 2015-2021 the original authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,10 +32,10 @@
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
Expand Down Expand Up @@ -205,6 +205,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
14 changes: 8 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,7 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ pluginManagement {
}
}

rootProject.name = 'EarthMCEssentials'
rootProject.name = 'EMCEssentials'
73 changes: 38 additions & 35 deletions src/main/java/net/emc/emce/EarthMCEssentials.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package net.emc.emce;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import io.github.emcw.core.EMCWrapper;
import io.github.emcw.entities.BaseEntity;
import io.github.emcw.entities.Player;
import io.github.emcw.utils.GsonUtil;
import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.serializer.GsonConfigSerializer;
import net.emc.emce.config.ModConfig;
import net.emc.emce.modules.EventRegistry;
import net.emc.emce.modules.OverlayRenderer;
import net.emc.emce.modules.TaskScheduler;
import net.emc.emce.objects.Resident;
import net.emc.emce.utils.Messaging;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
Expand All @@ -21,32 +23,36 @@
import org.lwjgl.glfw.GLFW;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;

public class EarthMCEssentials implements ModInitializer {
private static EarthMCEssentials instance;
public EMCWrapper wrapper;

private final Logger logger = LogManager.getLogger(EarthMCEssentials.class);

private Resident clientResident = null;
private ModConfig config = null;
private Player clientPlayer = null;
private boolean shouldRender = false;
private boolean debugModeEnabled = false;

private final List<String> townlessResidents = new CopyOnWriteArrayList<>();
private JsonArray nearbyPlayers = new JsonArray();
//private NewsData newsData = new NewsData(null);

public static KeyBinding configKeybinding;
private List<String> townlessNames = new CopyOnWriteArrayList<>();
private Map<String, Player> nearbyPlayers = new ConcurrentHashMap<>();

private final TaskScheduler scheduler = new TaskScheduler();
public String mapName = "aurora";

public String mapName = "aurora";
public int sessionCounter = 0;

public static KeyBinding configKeybinding;
private ModConfig config = null;
private boolean debugModeEnabled = false;

@Override
public void onInitialize() {
instance = this;
wrapper = new EMCWrapper();

AutoConfig.register(ModConfig.class, GsonConfigSerializer::new);
initConfig();
Expand All @@ -72,19 +78,16 @@ public TaskScheduler scheduler() {
return scheduler;
}

public Resident getClientResident() {
return clientResident;
public Player getClientPlayer() {
return clientPlayer;
}

public void setClientResident(Resident res) {
clientResident = res;
public void setClientPlayer(Player res) {
clientPlayer = res;
}

private void initConfig() { config = AutoConfig.getConfigHolder(ModConfig.class).getConfig(); }
public ModConfig getConfig() {
if (config == null) initConfig();
return config;
}
public ModConfig config() { return config; }
public void initConfig() { config = AutoConfig.getConfigHolder(ModConfig.class).getConfig(); }

public boolean shouldRender() {
MinecraftClient client = MinecraftClient.getInstance();
Expand All @@ -94,23 +97,26 @@ public boolean shouldRender() {
return shouldRender;
}

public void setDebugEnabled(boolean debugModeEnabled) {
this.debugModeEnabled = debugModeEnabled;
public void setDebugEnabled(boolean enabled) {
this.debugModeEnabled = enabled;

if (enabled) Messaging.sendPrefixed("msg_debug_enabled");
else Messaging.sendPrefixed("msg_debug_disabled");
}

public boolean debugEnabled() {
return debugModeEnabled;
return this.debugModeEnabled;
}

public List<String> getTownless() {
return townlessResidents;
return townlessNames;
}

public JsonArray getNearbyPlayers() {
public Map<String, Player> getNearbyPlayers() {
return nearbyPlayers;
}

public void setNearbyPlayers(JsonArray nearbyPlayers) {
public void setNearbyPlayers(Map<String, Player> nearbyPlayers) {
this.nearbyPlayers = nearbyPlayers;
OverlayRenderer.UpdateStates(false, true);
}
Expand All @@ -119,17 +125,14 @@ public void setShouldRender(boolean shouldRender) {
this.shouldRender = shouldRender;
}

public void setTownlessResidents(@NotNull JsonArray array) {
public void setTownless(@NotNull Map<String, Player> map) {
// Make sure there is data to add.
if (array.size() < 1) return;

townlessResidents.clear();
if (map.size() < 1) return;

for (JsonElement res : array) {
townlessResidents.add(res.getAsJsonObject().get("name").getAsString());
}
townlessNames.clear();
townlessNames = GsonUtil.streamValues(map).map(BaseEntity::getName).collect(Collectors.toList());

OverlayRenderer.SetTownless(townlessResidents);
OverlayRenderer.SetTownless(townlessNames);
OverlayRenderer.UpdateStates(true, false);
}
}
Loading

0 comments on commit 532a574

Please sign in to comment.