├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── src └── main ├── java └── dev │ └── hause │ └── squeakerbot │ ├── SqueakerBot.java │ ├── command │ ├── Command.java │ ├── CommandManager.java │ └── commands │ │ ├── About.java │ │ ├── AskGod.java │ │ ├── CoinFlip.java │ │ ├── GapDisease.java │ │ ├── Geolocate.java │ │ ├── Help.java │ │ ├── TallyHall.java │ │ └── Toggle.java │ ├── listener │ └── ChatListener.java │ └── util │ ├── ChatUtil.java │ └── QueryUtil.java └── resources ├── mcmod.info └── pack.mcmeta /README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | ███████╗ ██████╗ ██╗ ██╗███████╗ █████╗ ██╗ ██╗███████╗██████╗ ██████╗ ██████╗ ████████╗ 3 | ██╔════╝██╔═══██╗██║ ██║██╔════╝██╔══██╗██║ ██╔╝██╔════╝██╔══██╗██╔══██╗██╔═══██╗╚══██╔══╝ 4 | ███████╗██║ ██║██║ ██║█████╗ ███████║█████╔╝ █████╗ ██████╔╝██████╔╝██║ ██║ ██║ 5 | ╚════██║██║▄▄ ██║██║ ██║██╔══╝ ██╔══██║██╔═██╗ ██╔══╝ ██╔══██╗██╔══██╗██║ ██║ ██║ 6 | ███████║╚██████╔╝╚██████╔╝███████╗██║ ██║██║ ██╗███████╗██║ ██║██████╔╝╚██████╔╝ ██║ 7 | ╚══════╝ ╚══▀▀═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚═╝ 8 | 9 | ``` 10 | A Minecraft anarchy server chatbot made by yours truly, HausemasterIssue. It is pretty bare-bones at the moment but I plan to add more and improve it later. 11 | 12 | This is just a little project of mine to get more comfortable with forge and coding without skidding. Not some kind of super advanced chat bot that everyone will use. 13 | 14 | **Almost no code is skidded/stolen in this project (for the first time)!** 15 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | maven { url = "https://files.minecraftforge.net/maven" } 5 | } 6 | dependencies { 7 | classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' 8 | } 9 | } 10 | apply plugin: 'net.minecraftforge.gradle.forge' 11 | //Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. 12 | 13 | 14 | version = "b3" 15 | group = "dev.hause" // https://maven.apache.org/guides/mini/guide-naming-conventions.html 16 | archivesBaseName = "squeakerbot" 17 | 18 | sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. 19 | compileJava { 20 | sourceCompatibility = targetCompatibility = '1.8' 21 | } 22 | 23 | minecraft { 24 | version = "1.12.2-14.23.0.2491" 25 | runDir = "run" 26 | mappings = "snapshot_20170624" 27 | makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. 28 | } 29 | 30 | dependencies { 31 | 32 | } 33 | 34 | processResources { 35 | 36 | inputs.property "version", project.version 37 | inputs.property "mcversion", project.minecraft.version 38 | 39 | // replace stuff in mcmod.info, nothing else 40 | from(sourceSets.main.resources.srcDirs) { 41 | include 'mcmod.info' 42 | 43 | // replace version and mcversion 44 | expand 'version':project.version, 'mcversion':project.minecraft.version 45 | } 46 | 47 | // copy everything else except the mcmod.info 48 | from(sourceSets.main.resources.srcDirs) { 49 | exclude 'mcmod.info' 50 | } 51 | } 52 | 53 | idea { module { inheritOutputDirs = true } } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Sets default memory used for gradle commands. Can be overridden by user or command line properties. 2 | # This is required to provide enough memory for the Minecraft decompilation process. 3 | org.gradle.jvmargs=-Xmx3G 4 | org.gradle.daemon=false -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HausemasterIssue/SqueakerBot/3a723fd6aae2cf86218eb30d05b29fb41f294b86/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /src/main/java/dev/hause/squeakerbot/SqueakerBot.java: -------------------------------------------------------------------------------- 1 | package dev.hause.squeakerbot; 2 | 3 | import net.minecraftforge.common.MinecraftForge; 4 | import net.minecraftforge.fml.common.Mod; 5 | import net.minecraftforge.fml.common.Mod.EventHandler; 6 | import net.minecraftforge.fml.common.event.FMLInitializationEvent; 7 | import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; 8 | import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; 9 | import org.apache.logging.log4j.LogManager; 10 | import org.apache.logging.log4j.Logger; 11 | import dev.hause.squeakerbot.command.CommandManager; 12 | import dev.hause.squeakerbot.listener.ChatListener; 13 | 14 | @Mod(modid = SqueakerBot.MODID, name = SqueakerBot.NAME, version = SqueakerBot.VERSION) 15 | public class SqueakerBot 16 | { 17 | public static final String MODID = "squeakerbot"; 18 | public static final String NAME = "SqueakerBot"; 19 | public static final String VERSION = "b2"; 20 | public static CommandManager cm = new CommandManager(); 21 | public static Logger LOGGER = LogManager.getLogger("SqueakerBot"); 22 | 23 | @EventHandler 24 | public void preInit(FMLPreInitializationEvent event) 25 | { 26 | LOGGER.info("Initializing SqueakerBot..."); 27 | MinecraftForge.EVENT_BUS.register(new ChatListener()); 28 | LOGGER.info("Initializing Commands..."); 29 | cm.registerCommands(); 30 | } 31 | 32 | @EventHandler 33 | public void init(FMLInitializationEvent event) 34 | { 35 | 36 | } 37 | 38 | @EventHandler 39 | public void postInit(FMLPostInitializationEvent event) { 40 | LOGGER.info("SqueakerBot successfully initialized!"); 41 | LOGGER.info("the bidding by tally hall is a good song, go listen to it - hause"); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/dev/hause/squeakerbot/command/Command.java: -------------------------------------------------------------------------------- 1 | package dev.hause.squeakerbot.command; 2 | 3 | import java.lang.annotation.*; 4 | import net.minecraft.client.Minecraft; 5 | 6 | public class Command { 7 | 8 | public Minecraft mc = Minecraft.getMinecraft(); 9 | 10 | String command = getRegister().name(); 11 | String[] aliases = getRegister().aliases(); 12 | 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Target(ElementType.TYPE) 15 | public @interface Register { 16 | 17 | String name(); 18 | 19 | String[] aliases(); 20 | 21 | } 22 | 23 | private Register getRegister() { 24 | return getClass().getAnnotation(Register.class); 25 | } 26 | 27 | 28 | public void onRun() { 29 | 30 | } 31 | 32 | public String getCommand() { 33 | return command; 34 | } 35 | 36 | public void setCommand(String command) { 37 | this.command = command; 38 | } 39 | 40 | public String[] getAliases() { 41 | return aliases; 42 | } 43 | 44 | public void setAliases(String[] aliases) { 45 | this.aliases = aliases; 46 | } 47 | 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/dev/hause/squeakerbot/command/CommandManager.java: -------------------------------------------------------------------------------- 1 | package dev.hause.squeakerbot.command; 2 | 3 | import java.util.ArrayList; 4 | import dev.hause.squeakerbot.command.commands.*; 5 | 6 | public class CommandManager { 7 | 8 | public static ArrayList commands = new ArrayList<>(); 9 | 10 | public void registerCommands() { 11 | commands.add(new Help()); 12 | commands.add(new CoinFlip()); 13 | commands.add(new AskGod()); 14 | commands.add(new TallyHall()); 15 | commands.add(new Toggle()); 16 | commands.add(new About()); 17 | commands.add(new Geolocate()); 18 | commands.add(new GapDisease()); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/dev/hause/squeakerbot/command/commands/About.java: -------------------------------------------------------------------------------- 1 | package dev.hause.squeakerbot.command.commands; 2 | 3 | import dev.hause.squeakerbot.SqueakerBot; 4 | import dev.hause.squeakerbot.command.Command; 5 | import dev.hause.squeakerbot.util.ChatUtil; 6 | 7 | @Command.Register(name = "About", aliases = {"About", "Credits"}) 8 | public class About extends Command { 9 | 10 | @Override 11 | public void onRun() { 12 | ChatUtil.sendChatMessage("SqueakerBot " + SqueakerBot.VERSION + " by HausemasterIssue. GitHub: https://github.com/HausemasterIssue/SqueakerBot."); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/dev/hause/squeakerbot/command/commands/AskGod.java: -------------------------------------------------------------------------------- 1 | package dev.hause.squeakerbot.command.commands; 2 | 3 | import java.util.Random; 4 | import dev.hause.squeakerbot.command.Command; 5 | import dev.hause.squeakerbot.util.ChatUtil; 6 | 7 | @Command.Register(name = "AskGod", aliases = {"AskGod", "Ask", "God"}) 8 | public class AskGod extends Command { 9 | 10 | private static String[] replies = {"It is certain.", "My sources say no.", "Absolutley.", 11 | "Never.", "Perhaps.", "Reply hazy. Ask again later.", "Based off your tone, no.", 12 | "In the future, yes.", "Better not tell you now.", "It is highly unlikely.", 13 | "Do not ask that question ever again.", "Yes.", "Not in a trillion years.", "I do not know.", 14 | "For sure.", "No."}; 15 | 16 | 17 | @Override 18 | public void onRun() { 19 | Random random = new Random(); 20 | ChatUtil.sendChatMessage((replies[random.nextInt(14)])); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/dev/hause/squeakerbot/command/commands/CoinFlip.java: -------------------------------------------------------------------------------- 1 | package dev.hause.squeakerbot.command.commands; 2 | 3 | import java.util.Random; 4 | import dev.hause.squeakerbot.command.Command; 5 | import dev.hause.squeakerbot.util.ChatUtil; 6 | 7 | @Command.Register(name = "CoinFlip", aliases = {"Coin", "Flip", "Tails", "Heads"}) 8 | public class CoinFlip extends Command { 9 | 10 | private static String[] outcomes = {"The coin flip results in Heads!", "The coin flip results in Tails!"}; 11 | 12 | @Override 13 | public void onRun() { 14 | Random random = new Random(); 15 | ChatUtil.sendChatMessage(outcomes[random.nextInt(2)]); 16 | } 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/dev/hause/squeakerbot/command/commands/GapDisease.java: -------------------------------------------------------------------------------- 1 | package dev.hause.squeakerbot.command.commands; 2 | 3 | import dev.hause.squeakerbot.SqueakerBot; 4 | import dev.hause.squeakerbot.command.Command; 5 | import dev.hause.squeakerbot.util.ChatUtil; 6 | import java.util.ArrayList; 7 | import java.util.Arrays; 8 | 9 | @Command.Register(name = "GapDisease", aliases = {"GapDis", "Gap", "Disease", "LagGap", "GapLag", "AntiGap"}) 10 | public class GapDisease extends Command { 11 | 12 | private static ArrayList serverIps = new ArrayList<>(Arrays.asList("constantiam.net", "5b5t.org", "2b2t.org", "crystalpvp.cc", "us.crystalpvp.cc", "2b2tpvp.net", "2b2tpvp.org")); 13 | private static String[] diseaseServer = {"Expect some gapple disease while in combat and little while out of it, reccomended to use eating resync.", "Expect significant gapple disease while in combat.", 14 | "Expect mild to moderate gap disease in general, but somewhat more in combat.", "Expect no gap disease at all, in or out of combat.", "Expect no gap disease at all, in or out of combat.", 15 | "Expect virtually no gap disease at all times.", "Expect virtually no gap disease at all times."}; 16 | 17 | @Override 18 | public void onRun() { 19 | String server; 20 | int diseaseIndex = 0; 21 | if(!mc.isSingleplayer()) { 22 | server = mc.getCurrentServerData().serverIP; 23 | } else { 24 | server = "Singleplayer"; 25 | return; 26 | } 27 | SqueakerBot.LOGGER.info(server); 28 | 29 | for(String s : serverIps) { 30 | if(s.equalsIgnoreCase(server)) { 31 | diseaseIndex = serverIps.indexOf(s); 32 | } 33 | } 34 | 35 | ChatUtil.sendChatMessage(diseaseServer[diseaseIndex]); 36 | 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/dev/hause/squeakerbot/command/commands/Geolocate.java: -------------------------------------------------------------------------------- 1 | package dev.hause.squeakerbot.command.commands; 2 | 3 | import java.util.Random; 4 | import dev.hause.squeakerbot.command.Command; 5 | import dev.hause.squeakerbot.listener.ChatListener; 6 | import dev.hause.squeakerbot.util.ChatUtil; 7 | import dev.hause.squeakerbot.util.QueryUtil; 8 | 9 | @Command.Register(name = "Geolocate", aliases = {"Find", "Locate"}) 10 | public class Geolocate extends Command { 11 | 12 | private static QueryUtil queryUtil = new QueryUtil(); 13 | 14 | @Override 15 | public void onRun() { 16 | String name = queryUtil.getQuery(ChatListener.parsedCommand); 17 | Random random = new Random(); 18 | if(name.equalsIgnoreCase("null") ) { 19 | ChatUtil.sendChatMessage("You didn't enter a person to geolocate!"); 20 | return; 21 | } 22 | ChatUtil.sendChatMessage(name + "'s exact coordinates are " + "X: " + 1 + (20 - 1) * + random.nextDouble() + " Y: " + + 1 + (20 - 1) * + random.nextDouble()); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/dev/hause/squeakerbot/command/commands/Help.java: -------------------------------------------------------------------------------- 1 | package dev.hause.squeakerbot.command.commands; 2 | 3 | import dev.hause.squeakerbot.command.Command; 4 | import dev.hause.squeakerbot.util.ChatUtil; 5 | 6 | @Command.Register(name = "Help", aliases = {"Commands"}) 7 | public class Help extends Command { 8 | 9 | @Override 10 | public void onRun() { 11 | ChatUtil.sendChatMessage("Commands (7): Help, CoinFlip, AskGod, TallyHall, About, Geolocate, GapDisease"); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/dev/hause/squeakerbot/command/commands/TallyHall.java: -------------------------------------------------------------------------------- 1 | package dev.hause.squeakerbot.command.commands; 2 | 3 | import java.util.Random; 4 | import dev.hause.squeakerbot.command.Command; 5 | import dev.hause.squeakerbot.util.ChatUtil; 6 | 7 | @Command.Register(name = "TallyHall", aliases = {"Based", "Music", "Songs", "TheHall", "Hall", "Tally"}) 8 | public class TallyHall extends Command { 9 | 10 | private static String[] links = {"https://www.youtube.com/watch?v=ipYafcHd0jA", "https://www.youtube.com/watch?v=I8sUC-dsW8A", 11 | "https://www.youtube.com/watch?v=A-ZUo62N7Kc", "https://www.youtube.com/watch?v=-krA-ubCQqg", "https://www.youtube.com/watch?v=TIt4i8AmryQ", 12 | "https://www.youtube.com/watch?v=HnwemKW9H3s", "https://www.youtube.com/watch?v=xLirITfSCVY", "https://www.youtube.com/watch?v=Q-4IXcKkK1U", 13 | "https://www.youtube.com/watch?v=nHjaNDGgYEA", "https://www.youtube.com/watch?v=KrXJu-6ZcAQ", "https://www.youtube.com/watch?v=OFi8748c9Ew", 14 | "https://www.youtube.com/watch?v=1RliQKR6jXM", "https://www.youtube.com/watch?v=CgcTf6JYxsE", "https://www.youtube.com/watch?v=IawfoCuBV3c", 15 | "https://www.youtube.com/watch?v=OjGzOJ5IiSM", "https://www.youtube.com/watch?v=tRnMWzz44gA", "https://www.youtube.com/watch?v=5_QwMRE-BKc", 16 | "https://www.youtube.com/watch?v=7Q0ge00LmwM", "https://www.youtube.com/watch?v=rfUeWe7u364"}; 17 | 18 | private static String[] applause = {"You have great music taste: ", "Here's your vibes: ", "Enjoy!: ", "Listen, you'll love it: ", 19 | "Your tunes, sir: ", "Tally Hall!: ", "Go that extra mile: ", "Depression is gone: ", "A gem: ", "This one's a banger", 20 | "Poggers song: ", "Le tunes have arrived: ", "Amazing choice: ", "Have a great day friend: ", "The Tally Hall: ", "Epic vibe: ", 21 | "A cool band: ", "Mega based tune: ", "Great choice!: "}; 22 | 23 | @Override 24 | public void onRun() { 25 | Random random = new Random(); 26 | ChatUtil.sendChatMessage((applause[random.nextInt(18)]) + (links[random.nextInt(18)])); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/dev/hause/squeakerbot/command/commands/Toggle.java: -------------------------------------------------------------------------------- 1 | package dev.hause.squeakerbot.command.commands; 2 | 3 | import dev.hause.squeakerbot.command.Command; 4 | import dev.hause.squeakerbot.listener.ChatListener; 5 | 6 | @Command.Register(name = "Toggle", aliases = {"Enable", "Disable"}) 7 | public class Toggle extends Command { 8 | 9 | @Override 10 | public void onRun() { 11 | if(ChatListener.isToggled) { 12 | ChatListener.isToggled = false; 13 | } else { 14 | ChatListener.isToggled = true; 15 | } 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/dev/hause/squeakerbot/listener/ChatListener.java: -------------------------------------------------------------------------------- 1 | package dev.hause.squeakerbot.listener; 2 | 3 | import java.util.Random; 4 | import java.util.Timer; 5 | import java.util.TimerTask; 6 | import org.apache.commons.lang3.StringUtils; 7 | import dev.hause.squeakerbot.command.Command; 8 | import dev.hause.squeakerbot.command.CommandManager; 9 | import net.minecraftforge.client.event.ClientChatReceivedEvent; 10 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 11 | 12 | public class ChatListener { 13 | 14 | public static boolean isToggled = false; 15 | public static String parsedCommand; 16 | 17 | @SubscribeEvent 18 | public void onChat(ClientChatReceivedEvent event) { 19 | String rawCommand = event.getMessage().getUnformattedText(); 20 | if(unicodeCheck(rawCommand)) { 21 | event.setCanceled(true); 22 | } 23 | int parseIndex = rawCommand.indexOf(">") + 1; 24 | parsedCommand = rawCommand.substring(parseIndex).trim(); 25 | if(parsedCommand.startsWith("~")) { 26 | calcCommand(parsedCommand); 27 | } 28 | } 29 | 30 | public void calcCommand(String input) { 31 | if(StringUtils.containsIgnoreCase(input, "toggle")) { 32 | if(!isAdmin(input)) { 33 | return; 34 | } 35 | } 36 | 37 | if(!StringUtils.containsIgnoreCase(input, "toggle") && isToggled) { 38 | return; 39 | } 40 | 41 | Random random = new Random(); 42 | int waitTime = random.nextInt(3000); 43 | for(Command c : CommandManager.commands) { 44 | if(StringUtils.containsIgnoreCase(input, c.getCommand())) { 45 | Timer timer = new Timer(); 46 | timer.schedule(new TimerTask() { 47 | @Override 48 | public void run() { 49 | c.onRun(); 50 | 51 | } 52 | }, waitTime); 53 | break; 54 | } 55 | } 56 | } 57 | 58 | public boolean isAdmin(String command) { 59 | if(command.indexOf("HausemasterIssue") == 1) { 60 | return true; 61 | } 62 | return false; 63 | } 64 | 65 | public static boolean unicodeCheck(String input) { 66 | for(char c : input.toCharArray()) { 67 | if(isUnicode(c)) { 68 | return true; 69 | } 70 | } 71 | return false; 72 | } 73 | 74 | public static boolean isUnicode(char c) { 75 | if(c > 128) { 76 | return true; 77 | } 78 | return false; 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/dev/hause/squeakerbot/util/ChatUtil.java: -------------------------------------------------------------------------------- 1 | package dev.hause.squeakerbot.util; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.network.play.client.CPacketChatMessage; 5 | 6 | public class ChatUtil { 7 | 8 | static Minecraft mc = Minecraft.getMinecraft(); 9 | 10 | public static void sendChatMessage(String message) { 11 | mc.player.connection.sendPacket(new CPacketChatMessage("> [SqueakerBot] " + message)); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/dev/hause/squeakerbot/util/QueryUtil.java: -------------------------------------------------------------------------------- 1 | package dev.hause.squeakerbot.util; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | import dev.hause.squeakerbot.command.Command; 5 | import dev.hause.squeakerbot.command.CommandManager; 6 | 7 | public class QueryUtil { 8 | 9 | public String getQuery(String message) { 10 | String[] query = null; 11 | for(Command c : CommandManager.commands) { 12 | if(StringUtils.containsIgnoreCase(message, c.getCommand())) { 13 | query = message.split("(?<=" + c.getCommand().toLowerCase() + ")"); 14 | System.out.println(query[0]); 15 | } 16 | } 17 | 18 | if(query.length == 2) { 19 | return query[1]; 20 | } 21 | return "null"; 22 | 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/resources/mcmod.info: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "modid": "squeakerbot", 4 | "name": "SqueakerBot", 5 | "description": "Minecraft 1.12.2 Chat bot.", 6 | "version": "b3", 7 | "mcversion": "1.12.2", 8 | "url": "https://github.com/HausemasterIssue/SqueakerBot", 9 | "updateUrl": "", 10 | "authorList": ["HausemasterIssue"], 11 | "credits": "CraftyChaos, EmotionalLove for examples on 1.12.2 ChatBots (Didn't Skid!). Minecraft Forge, Bukkit and Spigot fourms, and StackOverflow for help.", 12 | "logoFile": "", 13 | "screenshots": [], 14 | "dependencies": [] 15 | } 16 | ] 17 | -------------------------------------------------------------------------------- /src/main/resources/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "description": "examplemod resources", 4 | "pack_format": 3, 5 | "_comment": "A pack_format of 3 should be used starting with Minecraft 1.11. All resources, including language files, should be lowercase (eg: en_us.lang). A pack_format of 2 will load your mod resources with LegacyV2Adapter, which requires language files to have uppercase letters (eg: en_US.lang)." 6 | } 7 | } 8 | --------------------------------------------------------------------------------