Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhobbel committed Jul 9, 2018
2 parents 23ce2ab + 0a774a5 commit e37f17b
Show file tree
Hide file tree
Showing 36 changed files with 201 additions and 228 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# DiscordRP
[![Build status](https://ci.appveyor.com/api/projects/status/rw8qx4iejtk10f88?svg=true)](https://ci.appveyor.com/project/ItsDizzy/discordrp)

A Minecraft mod which adds Discord integration into Minecraft
51 changes: 18 additions & 33 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,40 +33,14 @@ compileJava {
minecraft {
version = "${mc_version}-${forge_version}"
runDir = "run"

// the mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD snapshot are built nightly.
// stable_# stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// simply re-run your setup task after changing the mappings to update your workspace.
mappings = "${mcp_version}"
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.

replace "@VERSION@", discordrp_version
replace "@VERSION@", project.version

replaceIn "DiscordRP.java"
}

dependencies {
// you may put jars on which you depend on in ./libs
// or you may define them like so..
//compile "some.group:artifact:version:classifier"
//compile "some.group:artifact:version"

// real examples
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
//compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env

// the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
//provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

// the deobf configurations: 'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided,
// except that these dependencies get remapped to your current MCP mappings
//deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev'
//deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

// for more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html

}

Expand All @@ -80,7 +54,7 @@ processResources {
include 'mcmod.info'

// replace version and mcversion
expand 'version':discordrp_version, 'mcversion':project.minecraft.version
expand 'version':project.version, 'mcversion':project.minecraft.version
}

// copy everything else except the mcmod.info
Expand All @@ -106,10 +80,19 @@ task sourcesJar(type: Jar) {
from sourceSets.api.allJava
}

tasks.build.dependsOn apiJar, sourcesJar
task signJar(type: SignJar, dependsOn: reobfJar) {
onlyIf {
System.getenv("SIGNING_STORE_PASS") != null
}

keyStore = "keystore.jks"
alias = System.getenv("SIGNING_ALIAS")

tasks.withType(JavaCompile) { task ->
task.options.encoding = 'UTF-8'
storePass = System.getenv("SIGNING_STORE_PASS")
keyPass = System.getenv("SIGNING_KEY_PASS") != null ? System.getenv("SIGNING_KEY_PASS") : System.getenv("SIGNING_STORE_PASS")

inputFile = jar.archivePath
outputFile = jar.archivePath
}

curseforge {
Expand All @@ -125,4 +108,6 @@ curseforge {
addArtifact sourcesJar
addArtifact apiJar
}
}
}

tasks.build.dependsOn apiJar, sourcesJar, signJar
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
mc_version=1.12.2
forge_version=14.23.4.2709
forge_version=14.23.4.2729
discordrp_version=1.2.0
mcp_version=snapshot_20180602
mcp_version=snapshot_20180708
Binary file added keystore.jks
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface DiscordRPPlugin {
String value();
String modid();

int priority() default 0;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import net.minecraft.world.World;

import java.util.function.Predicate;
import java.util.Optional;

public interface IDiscordRPRegistry {
void registerDimension(IDiscordRPDimension dimension, Predicate<World> predicate);
void registerDimension(IDiscordRPDimension dimension, String key);

IDiscordRPDimension getDimension(World world);
Optional<IDiscordRPDimension> getDimension(World world);
}
2 changes: 1 addition & 1 deletion src/api/java/me/paulhobbel/discordrp/api/package-info.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@API(apiVersion = "0.0.2", owner = "discordrp", provides = "discordrp-api")
@API(apiVersion = "0.0.3", owner = "discordrp", provides = "discordrp-api")
package me.paulhobbel.discordrp.api;

import net.minecraftforge.fml.common.API;

This file was deleted.

This file was deleted.

17 changes: 12 additions & 5 deletions src/main/java/me/paulhobbel/discordrp/DiscordRP.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
package me.paulhobbel.discordrp;

import me.paulhobbel.discordrp.proxy.IProxy;
import me.paulhobbel.discordrp.common.CommonProxy;

import me.paulhobbel.discordrp.utils.Log;
import me.paulhobbel.discordrp.common.Log;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.discovery.ASMDataTable;
import net.minecraftforge.fml.common.event.*;

import java.util.Set;

@Mod(modid = DiscordRP.MODID, name = DiscordRP.NAME, version = DiscordRP.VERSION, clientSideOnly = true)
@Mod(modid = DiscordRP.MODID, name = DiscordRP.NAME, version = DiscordRP.VERSION, clientSideOnly = true, certificateFingerprint = DiscordRP.FINGERPRINT, updateJSON = DiscordRP.UPDATEJSON)
public class DiscordRP {
public static final String MODID = "discordrp";
public static final String NAME = "Discord Rich Presence";
public static final String VERSION = "@VERSION@";
public static final String FINGERPRINT = "5b6b19557df723bd85d474a32d64e4e191a2b42a";
public static final String UPDATEJSON = "https://raw.githubusercontent.com/ItsDizzy/DiscordRP/master/update.json";

public static Set<ASMDataTable.ASMData> plugins;

@SidedProxy(modId = MODID, clientSide = "me.paulhobbel.discordrp.proxy.ClientProxy")
private static IProxy proxy;
@SidedProxy(modId = MODID, clientSide = "me.paulhobbel.discordrp.client.ClientProxy")
private static CommonProxy proxy;

@Mod.EventHandler
public void onFingerprintViolation(FMLFingerprintViolationEvent event) {
Log.warn("This version was not signed properly, this is probably a development build and will not receive any support, use at own risk!");
}

@Mod.EventHandler
public void onConstruction(FMLConstructionEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
import me.paulhobbel.discordrp.api.IDiscordRPPlugin;
import me.paulhobbel.discordrp.api.IDiscordRPRegistry;
import me.paulhobbel.discordrp.api.impl.Dimension;
import me.paulhobbel.discordrp.api.world.WorldTypePredicate;

@DiscordRPPlugin("aromas1997sdimenion")
@DiscordRPPlugin(modid = "aroma1997sdimension")
public class AromasPlugin implements IDiscordRPPlugin {
@Override
public void register(IDiscordRPRegistry registry) {
registry.registerDimension(new Dimension("miningworld", "In The Mining World"), new WorldTypePredicate("MiningWorld"));
registry.registerDimension(new Dimension("miningworld", "Mining World"),"MiningWorld");
}
}
25 changes: 25 additions & 0 deletions src/main/java/me/paulhobbel/discordrp/addons/ConfigPlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package me.paulhobbel.discordrp.addons;

import me.paulhobbel.discordrp.DiscordRP;
import me.paulhobbel.discordrp.api.DiscordRPPlugin;
import me.paulhobbel.discordrp.api.IDiscordRPPlugin;
import me.paulhobbel.discordrp.api.IDiscordRPRegistry;
import me.paulhobbel.discordrp.api.impl.Dimension;
import me.paulhobbel.discordrp.common.config.DiscordRPConfig;
import me.paulhobbel.discordrp.common.Log;

@DiscordRPPlugin(modid = DiscordRP.MODID, priority = -1)
public class ConfigPlugin implements IDiscordRPPlugin {
@Override
public void register(IDiscordRPRegistry registry) {
for(String stringDimension : DiscordRPConfig.customDimensions) {
String[] parts = stringDimension.split("\\|");
if(parts.length == 2) {
Log.info("Registering config dimension with key '{}' and title '{}'", parts[0], parts[1]);
registry.registerDimension(new Dimension(parts[0], parts[1]), parts[0]);
} else {
Log.error("'{}' is not a correct format for a dimension, use <type>|<title> instead.", stringDimension);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
import me.paulhobbel.discordrp.api.IDiscordRPPlugin;
import me.paulhobbel.discordrp.api.IDiscordRPRegistry;
import me.paulhobbel.discordrp.api.impl.Dimension;
import me.paulhobbel.discordrp.api.world.WorldIdPredicate;

@DiscordRPPlugin(DiscordRP.MODID)
@DiscordRPPlugin(modid = DiscordRP.MODID)
public class MinecraftPlugin implements IDiscordRPPlugin {
@Override
public void register(IDiscordRPRegistry registry) {
registry.registerDimension(new Dimension("overworld", "In The Overworld"), new WorldIdPredicate(0));
registry.registerDimension(new Dimension("nether", "In The Nether"), new WorldIdPredicate(-1));
registry.registerDimension(new Dimension("end", "In The End"), new WorldIdPredicate(1));
registry.registerDimension(new Dimension("overworld", "Overworld"), "overworld");
registry.registerDimension(new Dimension("nether", "Nether"), "the_nether");
registry.registerDimension(new Dimension("end", "End"), "the_end");
}
}
20 changes: 9 additions & 11 deletions src/main/java/me/paulhobbel/discordrp/api/impl/Registry.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,25 @@
import net.minecraft.world.World;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Predicate;
import java.util.Optional;

public class Registry implements IDiscordRPRegistry {

private static Registry instance;

private final LinkedHashMap<Predicate<World>, IDiscordRPDimension> dimensionMap = new LinkedHashMap<>();
private final LinkedHashMap<String, IDiscordRPDimension> dimensionMap = new LinkedHashMap<>();

public static final Dimension DEFAULT_DIMENSION = new Dimension("default", "Unknown Dimension");

@Override
public void registerDimension(IDiscordRPDimension dimension, Predicate<World> predicate) {
dimensionMap.put(predicate, dimension);
public void registerDimension(IDiscordRPDimension dimension, String key) {
dimensionMap.put(key, dimension);
}

@Override
public IDiscordRPDimension getDimension(World world) {
return dimensionMap.entrySet().stream()
.filter(e -> e.getKey().test(world))
.map(Map.Entry::getValue)
.findFirst()
.orElse(null);
public Optional<IDiscordRPDimension> getDimension(World world) {
return Optional.of(dimensionMap.get(world.provider.getDimensionType().getName()));
//return dimensionMap.get(world.provider.getDimensionType().getName());
}

public static Registry getInstance() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package me.paulhobbel.discordrp.proxy;
package me.paulhobbel.discordrp.client;

import me.paulhobbel.discordrp.api.rpc.DiscordEventHandlers;
import me.paulhobbel.discordrp.api.rpc.DiscordRPC;
import me.paulhobbel.discordrp.api.rpc.DiscordRPCHandler;
import me.paulhobbel.discordrp.utils.MinecraftRichPresence;
import me.paulhobbel.discordrp.manager.DiscordAssetManager;
import me.paulhobbel.discordrp.config.DiscordRPConfig;
import me.paulhobbel.discordrp.manager.ManifestManager;
import me.paulhobbel.discordrp.common.CommonProxy;
import me.paulhobbel.discordrp.common.MinecraftRichPresence;
import me.paulhobbel.discordrp.common.manager.DiscordAssetManager;
import me.paulhobbel.discordrp.common.config.DiscordRPConfig;
import me.paulhobbel.discordrp.common.manager.ManifestManager;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.common.event.*;

public class ClientProxy extends CommonProxy {
Expand All @@ -28,22 +30,26 @@ public void onConstruction(FMLConstructionEvent event) {
DiscordRPC.Initialize(!DiscordRPConfig.applicationId.isEmpty() ? DiscordRPConfig.applicationId : "460129247239864330", handlers);
DiscordRPCHandler.start();

presence = new MinecraftRichPresence.Builder()
.state("FML Construction")
.details("Loading Minecraft")
.startTimestamp(System.currentTimeMillis() / 1000)
.manifest(ManifestManager.getManifest())
.build();

presence.setPresence();
// Translations are not loaded yet here it seems
// presence = new MinecraftRichPresence.Builder()
// .state(I18n.format("discordrp.state.construction"))
// .details(I18n.format("discordrp.loading"))
// .startTimestamp(System.currentTimeMillis() / 1000)
// .manifest(ManifestManager.getManifest())
// .build();
//
// presence.setPresence();
}

@Override
public void onPreInit(FMLPreInitializationEvent event) {
super.onPreInit(event);

presence = presence.buildUpon()
.state("FML PreInitialization")
presence = new MinecraftRichPresence.Builder()
.state(I18n.format("discordrp.state.preinit"))
.details(I18n.format("discordrp.loading"))
.startTimestamp(System.currentTimeMillis() / 1000)
.manifest(ManifestManager.getManifest())
.build();

presence.setPresence();
Expand All @@ -54,7 +60,7 @@ public void onInit(FMLInitializationEvent event) {
super.onInit(event);

presence = presence.buildUpon()
.state("FML Initialization")
.state(I18n.format("discordrp.state.init"))
.build();

presence.setPresence();
Expand All @@ -65,7 +71,7 @@ public void onPostInit(FMLPostInitializationEvent event) {
super.onPostInit(event);

presence = presence.buildUpon()
.state("FML PostInitialization")
.state(I18n.format("discordrp.state.postinit"))
.build();

presence.setPresence();
Expand All @@ -76,7 +82,7 @@ public void onLoadComplete(FMLLoadCompleteEvent event) {
super.onLoadComplete(event);

presence = new MinecraftRichPresence.Builder()
.details("In the Main Menu")
.details(I18n.format("discordrp.mainmenu"))
.startTimestamp(System.currentTimeMillis() / 1000)
.manifest(ManifestManager.getManifest())
.build();
Expand Down
Loading

0 comments on commit e37f17b

Please sign in to comment.