Skip to content

Commit

Permalink
migrated the new webmap
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticdrew committed Mar 10, 2024
1 parent 912f168 commit d975b51
Show file tree
Hide file tree
Showing 40 changed files with 829 additions and 2,879 deletions.
7 changes: 7 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,11 @@
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
*/
dependencies {
// shadowImplementation("ar.com.hjg:pngj:2.1.0") //TODO: remove the code and use the dependency instead
shadowImplementation("javax.servlet:javax.servlet-api:4.0.1")
shadowImplementation("info.journeymap:webmap-client:0.8.5-SNAPSHOT")
shadowImplementation("io.javalin:javalin:4.6.8")

implementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.8.0-beta4'
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.8.0-beta4'
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ forceEnableMixins = false

# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated into your jar. It is your
# responsibility to check the license and request permission for distribution if required.
usesShadowedDependencies = false
usesShadowedDependencies = true

# If disabled, won't remove unused classes from shadowed dependencies. Some libraries use reflection to access
# their own classes, making the minimization unreliable.
minimizeShadowedDependencies = true
minimizeShadowedDependencies = false

# If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = true
Expand Down
14 changes: 14 additions & 0 deletions repositories.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Add any additional repositories for your dependencies here

repositories {
mavenCentral()

maven {
name = "JourneyMap"
url = "https://jm.gserv.me/repository/maven-snapshots/"
}
maven {
name = "jitpack"
url = "https://jitpack.io"
}
}
9 changes: 8 additions & 1 deletion src/main/java/journeymap/client/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
import org.lwjgl.input.Keyboard;

import java.io.File;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;

// 1.8
//import net.minecraftforge.fml.common.Loader;
Expand Down Expand Up @@ -59,6 +64,8 @@ public class Constants
public static String WAYPOINT_ICON_DIR = path.join(ICON_DIR, "waypoint", END);
public static String THEME_ICON_DIR = path.join(ICON_DIR, "theme", END);

public static String WEB_DIR = path.join(JOURNEYMAP_DIR, "web", END);

// Network Channel IDs

/**
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/journeymap/client/JourneymapClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import journeymap.client.network.WorldInfoHandler;
import journeymap.client.properties.*;
import journeymap.client.render.map.TileDrawStepCache;
import journeymap.client.service.webmap.Webmap;
import journeymap.client.task.main.IMainThreadTask;
import journeymap.client.task.main.MainTaskController;
import journeymap.client.task.main.MappingMonitorTask;
Expand All @@ -38,6 +37,7 @@
import journeymap.client.ui.UIManager;
import journeymap.client.ui.fullscreen.Fullscreen;
import journeymap.client.waypoint.WaypointStore;
import journeymap.client.webmap.WebMap;
import journeymap.common.CommonProxy;
import journeymap.common.Journeymap;
import journeymap.common.version.VersionCheck;
Expand Down Expand Up @@ -309,7 +309,7 @@ public void postInitialize(FMLPostInitializationEvent event)
// Webserver
if (webMapProperties.enabled.get())
{
Webmap.INSTANCE.start();
WebMap.getInstance().start();
}
initialized = true;

Expand Down Expand Up @@ -387,9 +387,9 @@ public Boolean isThreadLogging()
*
* @return
*/
public Webmap getJmServer()
public WebMap getJmServer()
{
return Webmap.INSTANCE;
return WebMap.getInstance();
}

/**
Expand Down
21 changes: 19 additions & 2 deletions src/main/java/journeymap/client/io/FileHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.google.common.io.ByteSource;
import com.google.common.io.Files;
import com.google.gson.GsonBuilder;
import cpw.mods.fml.client.FMLClientHandler;
import journeymap.client.Constants;
import journeymap.client.JourneymapClient;
import journeymap.client.data.WorldData;
Expand Down Expand Up @@ -39,15 +40,29 @@

public class FileHandler
{
public static final String DEV_MINECRAFT_DIR = "run/";
public static final String ASSETS_JOURNEYMAP = "/assets/journeymap";
public static final String ASSETS_WEBMAP = "/assets/journeymap/web";
public static final String ASSETS_JOURNEYMAP_UI = "/assets/journeymap/web/img/ico";
public static final String ASSETS_JOURNEYMAP_UI = "/assets/journeymap/web/img/";
public static final File MinecraftDirectory = ForgeHelper.INSTANCE.getClient().mcDataDir;
public static final File JourneyMapDirectory = new File(MinecraftDirectory, Constants.JOURNEYMAP_DIR);
public static final File StandardConfigDirectory = new File(MinecraftDirectory, Constants.CONFIG_DIR);

private static WorldClient theLastWorld;

public static File getMinecraftDirectory()
{
Minecraft minecraft = FMLClientHandler.instance().getClient();
if (minecraft != null)
{
return minecraft.mcDataDir;
}
else
{
return new File(DEV_MINECRAFT_DIR);
}
}

public static File getMCWorldDir(Minecraft minecraft)
{
if (minecraft.isIntegratedServerRunning())
Expand Down Expand Up @@ -551,7 +566,7 @@ public static void open(File file)
}
}

public static void copyResources(File targetDirectory, String assetsPath, String setName, boolean overwrite)
public static boolean copyResources(File targetDirectory, String assetsPath, String setName, boolean overwrite)
{
String fromPath = null;
File toDir = null;
Expand All @@ -574,11 +589,13 @@ public static void copyResources(File targetDirectory, String assetsPath, String
fromPath = fromDir.getPath();
FileHandler.copyFromDirectory(fromDir, toDir, overwrite);
}
return true;
}
catch (Throwable t)
{
Journeymap.getLogger().error(String.format("Couldn't unzip resource set from %s to %s: %s", fromPath, toDir, t));
}
return false;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/journeymap/client/log/ChatLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import journeymap.client.Constants;
import journeymap.client.JourneymapClient;
import journeymap.client.service.webmap.Webmap;
import journeymap.client.webmap.WebMap;
import journeymap.common.Journeymap;
import journeymap.common.version.VersionCheck;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -156,7 +156,7 @@ public static void announceMod(boolean forced)
{
try
{
Webmap webServer = JourneymapClient.getInstance().getJmServer();
WebMap webServer = JourneymapClient.getInstance().getJmServer();
String keyName = Constants.getKeyName(Constants.KB_MAP);
String port = webServer.getPort() == 80 ? "" : ":" + webServer.getPort();
String message = Constants.getString("jm.common.webserver_and_mapgui_ready", keyName, port); //$NON-NLS-1$
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/journeymap/client/model/EntityDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class EntityDTO implements Serializable
public boolean sneaking;
public boolean passiveAnimal;


private EntityDTO(EntityLivingBase entity)
{
this.entityLivingRef = new WeakReference<EntityLivingBase>(entity);
Expand Down Expand Up @@ -109,11 +110,8 @@ else if (entity instanceof IEntityOwnable)
}
else if (entity instanceof EntityHorse)
{
// TODO: Test this with and without owners
// 1.8
String ownerUuidString = ((EntityHorse) entity).func_152119_ch();
// 1.8.8
// String ownerUuidString = ((EntityHorse) entity).getOwnerId();

if (!Strings.isNullOrEmpty(ownerUuidString))
{
try
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/journeymap/client/ui/dialog/OptionsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import journeymap.client.properties.config.Config;
import journeymap.client.render.draw.DrawUtil;
import journeymap.client.render.map.TileDrawStepCache;
import journeymap.client.service.webmap.Webmap;
import journeymap.client.task.main.SoftResetTask;
import journeymap.client.task.multi.MapPlayerTask;
import journeymap.client.task.multi.RenderSpec;
Expand All @@ -29,6 +28,7 @@
import journeymap.client.ui.option.OptionSlotFactory;
import journeymap.client.ui.option.SlotMetadata;
import journeymap.client.waypoint.WaypointStore;
import journeymap.client.webmap.WebMap;
import journeymap.common.Journeymap;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
Expand Down Expand Up @@ -677,11 +677,11 @@ protected void closeAndReturn()
DataCache.instance().resetRadarCaches();
if (JourneymapClient.getWebMapProperties().enabled.get())
{
Webmap.INSTANCE.start();
WebMap.getInstance().start();
}
else
{
Webmap.INSTANCE.stop();
WebMap.getInstance().stop();
}

ChatLog.announceMod(true);
Expand Down Expand Up @@ -709,11 +709,11 @@ protected void closeAndReturn()
SoftResetTask.queue();
if (JourneymapClient.getWebMapProperties().enabled.get())
{
Webmap.INSTANCE.start();
WebMap.getInstance().start();
}
else
{
Webmap.INSTANCE.stop();
WebMap.getInstance().stop();
}
break;
}
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/journeymap/client/webmap/Resources.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package journeymap.client.webmap;

import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;

import java.io.IOException;
import java.io.InputStream;

public class Resources
{
public static InputStream getResourceAsStream(ResourceLocation resourceLocation) throws IOException
{
return Minecraft.getMinecraft().getResourceManager().getResource(resourceLocation).getInputStream();
}
}
Loading

0 comments on commit d975b51

Please sign in to comment.