Skip to content
  •  
  •  
  •  
101 changes: 47 additions & 54 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,78 +1,71 @@
buildscript {
repositories {
jcenter()
maven {
name = "forge"
url = "https://files.minecraftforge.net/maven"
}
}
dependencies {
classpath "net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT"
}
plugins {
id "maven-publish"
id "idea"
id "net.minecraftforge.gradle" version "5.+"
}

apply plugin: "net.minecraftforge.gradle.forge"
minecraft {
mappings channel: "stable", version: "39-1.12"

version = modVersion
group= modGroup
archivesBaseName = modBaseName
runs {
server {
workingDirectory project.file("run")
property "forge.logging.markers", "REGISTRIES"
property "forge.logging.console.level", "debug"
}

minecraft {
version = project.forgeVersion
runDir = "run"
client {
workingDirectory project.file("run")
property "forge.logging.markers", "REGISTRIES"
property "forge.logging.console.level", "debug"
}
}
}

replace "@VERSION@", project.version
replaceIn project.modBaseClass
group "betterquesting"

// 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 = project.mcpVersion
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}

repositories {
mavenCentral()
mavenCentral()
}

dependencies {
minecraft "net.minecraftforge:forge:${minecraftVersion}-${forgeVersion}"
}

processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version

// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include "mcmod.info"

// replace version and mcversion
expand "version":project.version, "mcversion":project.minecraft.version
filesMatching("mcmod.info") {
expand "version": project.version, "mcversion": project.minecraftVersion
}
}

// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude "mcmod.info"
}
jar {
finalizedBy "reobfJar"
}

task deobfJar(type: Jar) {
from sourceSets.main.output
appendix = 'deobf'
sourceSets.main {
output.resourcesDir = output.classesDirs.singleFile
}

task apiJar(type: Jar) {
from(sourceSets.main.output) {
include 'betterquesting/api/**'
include 'betterquesting/api2/**'
}
appendix = 'api'
tasks.register('deobfJar', Jar) {
from sourceSets.main.output
archiveClassifier = "deobf"
}


tasks.register('apiJar', Jar) {
from(sourceSets.main.output) {
include 'betterquesting/api/**'
include 'betterquesting/api2/**'
}
archiveClassifier = "api"
}

artifacts {
archives deobfJar
archives apiJar
archives deobfJar
archives apiJar
}
10 changes: 3 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
modGroup = betterquesting
modVersion = 3.5.327
modBaseName = BetterQuesting
modBaseClass = BetterQuesting.java

forgeVersion = 1.12.2-14.23.5.2768
mcpVersion = stable_39
version=3.6.6
minecraftVersion=1.12.2
forgeVersion=14.23.5.2860
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
8 changes: 8 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pluginManagement {
repositories {
gradlePluginPortal()
maven { url "https://maven.minecraftforge.net/" }
}
}

rootProject.name = "BetterQuesting"
4 changes: 1 addition & 3 deletions src/main/java/betterquesting/api/api/ApiKey.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package betterquesting.api.api;

public class ApiKey<T>
{
}
public class ApiKey<T> { }
40 changes: 20 additions & 20 deletions src/main/java/betterquesting/api/api/ApiReference.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@

public class ApiReference // Note to self: Don't make these client side only. It'll just crash servers regardless of which are used
{
public static final ApiKey<IQuestDatabase> QUEST_DB = new ApiKey<>();
public static final ApiKey<IQuestLineDatabase> LINE_DB = new ApiKey<>();
public static final ApiKey<IPartyDatabase> PARTY_DB = new ApiKey<>();
public static final ApiKey<ILifeDatabase> LIFE_DB = new ApiKey<>();
public static final ApiKey<IRegistry<IFactoryData<ITask, NBTTagCompound>, ITask>> TASK_REG = new ApiKey<>();
public static final ApiKey<IRegistry<IFactoryData<IReward, NBTTagCompound>, IReward>> REWARD_REG = new ApiKey<>();
public static final ApiKey<IPacketSender> PACKET_SENDER = new ApiKey<>();
public static final ApiKey<IPacketRegistry> PACKET_REG = new ApiKey<>();
public static final ApiKey<IQuestSettings> SETTINGS = new ApiKey<>();
public static final ApiKey<INameCache> NAME_CACHE = new ApiKey<>();
public static final ApiKey<IThemeRegistry> THEME_REG = new ApiKey<>();
public static final ApiKey<IResourceReg> RESOURCE_REG = new ApiKey<>();
public static final ApiKey<IToolRegistry> TOOL_REG = new ApiKey<>();
public static final ApiKey<IImportRegistry> IMPORT_REG = new ApiKey<>();
public static final ApiKey<CreativeTabs> CREATIVE_TAB = new ApiKey<>();
public static final ApiKey<IQuestDatabase> QUEST_DB = new ApiKey<>();
public static final ApiKey<IQuestLineDatabase> LINE_DB = new ApiKey<>();
public static final ApiKey<IPartyDatabase> PARTY_DB = new ApiKey<>();
public static final ApiKey<ILifeDatabase> LIFE_DB = new ApiKey<>();

public static final ApiKey<IRegistry<IFactoryData<ITask, NBTTagCompound>, ITask>> TASK_REG = new ApiKey<>();
public static final ApiKey<IRegistry<IFactoryData<IReward, NBTTagCompound>, IReward>> REWARD_REG = new ApiKey<>();

public static final ApiKey<IPacketSender> PACKET_SENDER = new ApiKey<>();
public static final ApiKey<IPacketRegistry> PACKET_REG = new ApiKey<>();

public static final ApiKey<IQuestSettings> SETTINGS = new ApiKey<>();
public static final ApiKey<INameCache> NAME_CACHE = new ApiKey<>();

public static final ApiKey<IThemeRegistry> THEME_REG = new ApiKey<>();
public static final ApiKey<IResourceReg> RESOURCE_REG = new ApiKey<>();
public static final ApiKey<IToolRegistry> TOOL_REG = new ApiKey<>();
public static final ApiKey<IImportRegistry> IMPORT_REG = new ApiKey<>();

public static final ApiKey<CreativeTabs> CREATIVE_TAB = new ApiKey<>();
}
112 changes: 50 additions & 62 deletions src/main/java/betterquesting/api/api/QuestingAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,66 +10,54 @@
/**
* Storage for all the questing API hooks. Includes built-in and custom APIs
*/
public class QuestingAPI
{
private static final HashMap<ApiKey<?>, Object> apis = new HashMap<>();

public static <T> void registerAPI(ApiKey<T> key, T api)
{
if(key == null)
{
throw new NullPointerException("API key can not be NULL");
} else if(api == null)
{
throw new NullPointerException("Tried to registed NULL API");
} else if(apis.containsKey(key))
{
throw new IllegalArgumentException("Key cannot be registered twice");
}

apis.put(key, api);
}

@SuppressWarnings("unchecked")
public static <T> T getAPI(ApiKey<T> key)
{
Object obj = apis.get(key);
return obj == null ? null : (T)obj;
}

/**
* This should be used over the vanilla method of obtaining the player's UUID.
* This is because offline servers do not sync UUIDs properly to the client
*/
public static UUID getQuestingUUID(EntityPlayer player)
{
if(player == null)
{
return null;
}

if(player.world.isRemote)
{
UUID uuid = getAPI(ApiReference.NAME_CACHE).getUUID(player.getGameProfile().getName());

if(uuid != null)
{
return uuid;
}
}

return player.getGameProfile().getId();
}

private static Logger logger = null;

public static Logger getLogger()
{
if(logger == null)
{
logger = LogManager.getLogger("betterquesting");
}

return logger;
}
public class QuestingAPI {
private static final HashMap<ApiKey<?>, Object> apis = new HashMap<>();

public static <T> void registerAPI(ApiKey<T> key, T api) {
if (key == null) {
throw new NullPointerException("API key can not be NULL");
} else if (api == null) {
throw new NullPointerException("Tried to registed NULL API");
} else if (apis.containsKey(key)) {
throw new IllegalArgumentException("Key cannot be registered twice");
}

apis.put(key, api);
}

@SuppressWarnings("unchecked")
public static <T> T getAPI(ApiKey<T> key) {
Object obj = apis.get(key);
return obj == null ? null : (T) obj;
}

/**
* This should be used over the vanilla method of obtaining the player's UUID.
* This is because offline servers do not sync UUIDs properly to the client
*/
public static UUID getQuestingUUID(EntityPlayer player) {
if (player == null) {
return null;
}

if (player.world.isRemote) {
UUID uuid = getAPI(ApiReference.NAME_CACHE).getUUID(player.getGameProfile().getName());

if (uuid != null) {
return uuid;
}
}

return player.getGameProfile().getId();
}

private static Logger logger = null;

public static Logger getLogger() {
if (logger == null) {
logger = LogManager.getLogger("betterquesting");
}

return logger;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package betterquesting.api.client.gui.misc;

@Deprecated
public interface INeedsRefresh
{
void refreshGui();
public interface INeedsRefresh {
void refreshGui();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* Marks questing UIs as volatile requiring confirmation to escape
*/
@Deprecated
public interface IVolatileScreen{}
public interface IVolatileScreen { }
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import java.util.List;

public interface IImportRegistry
{
void registerImporter(IImporter importer);
List<IImporter> getImporters();
public interface IImportRegistry {
void registerImporter(IImporter importer);

List<IImporter> getImporters();
}
16 changes: 8 additions & 8 deletions src/main/java/betterquesting/api/client/importers/IImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
/**
* Used as a basis for quest importers
*/
public interface IImporter
{
String getUnlocalisedName();
String getUnlocalisedDescription();
FileFilter getFileFilter();
void loadFiles(IQuestDatabase questDB, IQuestLineDatabase lineDB, File[] files);
public interface IImporter {
String getUnlocalisedName();

String getUnlocalisedDescription();

FileFilter getFileFilter();

void loadFiles(IQuestDatabase questDB, IQuestLineDatabase lineDB, File[] files);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

import java.util.Collection;

public interface IToolRegistry
{
void registerToolTab(ResourceLocation tabID, IToolTab tab);
IToolTab getTabByID(ResourceLocation tabID);
Collection<IToolTab> getAllTabs();
public interface IToolRegistry {
void registerToolTab(ResourceLocation tabID, IToolTab tab);

IToolTab getTabByID(ResourceLocation tabID);

Collection<IToolTab> getAllTabs();
}
Loading