Skip to content

Commit

Permalink
Merge pull request #16 from MrLittleKitty/featureUpdates
Browse files Browse the repository at this point in the history
Merge Feature updates branch for completed version 1.0.8
  • Loading branch information
MrLittleKitty authored Dec 31, 2016
2 parents 053bd76 + d858cd3 commit f814766
Show file tree
Hide file tree
Showing 20 changed files with 497 additions and 202 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/build
/classes
/out
/run
/libs
/.gradle

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ Minecraft 1.10.2 --- [Release v1.0.3](https://github.com/MrLittleKitty/Snitch-Ma
#Building the mod yourself
1. Setup MinecraftForge
2. Setup Gradle
3. Run the build.gradle file from this repository
4. Put the compiled .jar file into your mods folder
3. Create the `libs` directory and place the JourneyMap Jar in there
4. Run the build.gradle file from this repository
5. The result can be found at `build/libs/*.jar`

#Credits
Thanks to all the contributors over at the [Snitch Visualizer Mod](https://github.com/Scuwr/Snitch-Visualizer) who started the idea of a mod to render snitches in-game.
Expand Down
31 changes: 2 additions & 29 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ plugins {
id "net.minecraftforge.gradle.forge" version "2.0.2"
}
*/
version = "1.10.2-1.0.7"
version = "1.10.2-1.0.8"
group= "com.gmail.nuclearcat1337.snitch_master" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "SnitchMaster"

sourceCompatibility = 1.7
targetCompatibility = 1.7

minecraft {
version = "1.10.2-12.18.1.2079"
version = "1.10.2-12.18.3.2185"
runDir = "run"

// the mappings can be changed at any time, and must be in the following format.
Expand All @@ -40,33 +40,6 @@ minecraft {
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
}

dependencies {

compile files("journeymap-api-1.9.4-1.2.jar")

// 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

}

processResources
{
// this will ensure that this task is redone when the versions change.
Expand Down
20 changes: 13 additions & 7 deletions src/main/java/com/gmail/nuclearcat1337/snitch_master/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,24 @@
*/
public class Settings
{
private final String filePath;
public enum ChatSpamState
{
ON,
OFF,
PAGENUMBERS;
}

public static final String QUIET_TIME_KEY = "quiet-time";
public static final String CHAT_SPAM_KEY = "chat-spam";

private final File file;
private final ValueParser parser;

private final HashMap<String,Object> values;

public Settings(String filePath, ValueParser parser)
public Settings(File file, ValueParser parser)
{
this.filePath = filePath;
this.file = file;
this.parser = parser;
values = new HashMap<>();
}
Expand All @@ -41,8 +51,6 @@ public Object getValue(String key)

public void loadSettings()
{
values.clear();
File file = new File(filePath);
if(file.exists())
{
try
Expand Down Expand Up @@ -70,8 +78,6 @@ public void loadSettings()

public void saveSettings()
{
//TODO---Need to create the folder path before the file can be created
File file = new File(filePath);
BufferedWriter writer = null;
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,33 @@

import com.gmail.nuclearcat1337.snitch_master.handlers.*;
import com.gmail.nuclearcat1337.snitch_master.journeymap.JourneyMapInterface;
import com.gmail.nuclearcat1337.snitch_master.locatableobjectlist.IReadOnlyLocatableObjectList;
import com.gmail.nuclearcat1337.snitch_master.locatableobjectlist.LocatableObjectList;
import com.gmail.nuclearcat1337.snitch_master.snitches.Snitch;
import com.gmail.nuclearcat1337.snitch_master.snitches.SnitchList;
import com.gmail.nuclearcat1337.snitch_master.snitches.SnitchLists;
import com.gmail.nuclearcat1337.snitch_master.util.IOHandler;
import io.netty.buffer.ByteBuf;
import com.gmail.nuclearcat1337.snitch_master.util.ValueParser;
import net.minecraft.client.Minecraft;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.ByteBufUtils;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Set;
import java.util.logging.Logger;

/**
* Created by Mr_Little_Kitty on 6/25/2016.
* The main class for the SnitchMaster mod.
*/
@Mod(modid = SnitchMaster.MODID, name = SnitchMaster.MODNAME, version = SnitchMaster.MODVERSION)
public class SnitchMaster// implements SnitchMasterAPI
@Mod(modid = SnitchMaster.MODID, name = SnitchMaster.MODNAME, version = SnitchMaster.MODVERSION, guiFactory = "com.gmail.nuclearcat1337.snitch_master.gui.ConfigGuiFactory")
public class SnitchMaster
{
public static final String MODID = "snitchmaster";
public static final String MODNAME = "Snitch Master";
public static final String MODVERSION = "1.0.7";
public static final String MODVERSION = "1.0.8";

private static final Minecraft mc = Minecraft.getMinecraft();
/**
Expand All @@ -50,15 +47,14 @@ public class SnitchMaster// implements SnitchMasterAPI
*/
public static SnitchMaster instance;

private Settings settings;

private ChatSnitchParser chatSnitchParser;
private WorldInfoListener worldInfoListener;

private SnitchLists snitchLists;
private LocatableObjectList<Snitch> snitches;

//private static final String settingsPath = mc.mcDataDir.getAbsolutePath()+"/mods/Snitch-Master/settings.txt";
//private Settings snitchMasterSettings = null;

@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
Expand Down Expand Up @@ -87,6 +83,8 @@ public void init(FMLInitializationEvent event)

FMLCommonHandler.instance().bus().register(new KeyHandler(this));

chatSnitchParser.addAlertRecipient(new QuietTimeHandler(getSettings()));

try
{
IOHandler.loadSnitchLists(this);
Expand All @@ -102,10 +100,18 @@ public void init(FMLInitializationEvent event)

private void initializeSettings()
{
//snitchMasterSettings = new Settings(settingsPath,new ObjectParser());
//snitchMasterSettings.loadSettings();
settings = new Settings(IOHandler.getSettingsFile(),new ObjectParser());
settings.loadSettings();

settings.setValueIfNotSet(Settings.QUIET_TIME_KEY, Boolean.FALSE);
settings.setValueIfNotSet(Settings.CHAT_SPAM_KEY, Settings.ChatSpamState.ON);

//TODO---Make sure we set all the defaults for the settings here
settings.saveSettings();
}

public Settings getSettings()
{
return settings;
}

/**
Expand Down Expand Up @@ -189,8 +195,6 @@ public void submitSnitch(Snitch snitch)
//send it to journey map if that is enabled
if(jmInterface != null)
jmInterface.displaySnitch(contains);

IOHandler.asyncSaveSnitches(snitches);
}

/**
Expand All @@ -202,12 +206,20 @@ public void refreshSnitchListPriorities()
snitch.sortSnitchLists();
}

// private static class ObjectParser implements ValueParser
// {
// @Override
// public Object parse(String key, String value)
// {
// return null;
// }
// }
private static class ObjectParser implements ValueParser
{
// settings.setValueIfNotSet("quiet-time", Boolean.FALSE.toString());
// settings.setValueIfNotSet("chat-spam", 1);

@Override
public Object parse(String key, String value)
{
if(key.equalsIgnoreCase(Settings.QUIET_TIME_KEY))
return Boolean.parseBoolean(value);
else if(key.equalsIgnoreCase(Settings.CHAT_SPAM_KEY))
return Settings.ChatSpamState.valueOf(value);

return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ public class SnitchAlert
{
private final String playerName;
private final ILocation point;
private final String snitchName;
private final String activity;
private final String world;
private ITextComponent rawMessage;

public SnitchAlert(String player, int x, int y, int z, String world, ITextComponent rawMessage)
public SnitchAlert(String player, int x, int y, int z, String activity, String snitchName, String world, ITextComponent rawMessage)
{
this.playerName = player;
this.point = new Location(x,y,z,world);
this.activity = activity;
this.snitchName = snitchName;
this.world = world;
this.rawMessage = rawMessage;
}
Expand All @@ -34,11 +38,27 @@ public String getPlayerName()
/**
* Returns the location of the Snitch that was triggered.
*/
public ILocation getLocations()
public ILocation getLocation()
{
return point;
}

/**
* Returns the player activity that triggered the Snitch.
*/
public String getActivity()
{
return activity;
}

/**
* Returns the name of the Snitch that was triggered.
*/
public String getSnitchName()
{
return snitchName;
}

/**
* Returns the name of the world that the triggered Snitch is in.
*/
Expand Down
Loading

0 comments on commit f814766

Please sign in to comment.