-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7756d97
commit bcb15b0
Showing
10 changed files
with
119 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// Add any additional repositories for your dependencies here. | ||
|
||
repositories { | ||
|
||
mavenCentral() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
package com.fardragi.gregoriette; | ||
package com.fardragi.gregoriette | ||
|
||
import cpw.mods.fml.common.event.FMLInitializationEvent; | ||
import cpw.mods.fml.common.event.FMLPostInitializationEvent; | ||
import cpw.mods.fml.common.event.FMLPreInitializationEvent; | ||
import cpw.mods.fml.common.event.FMLServerStartingEvent; | ||
import com.fardragi.gregoriette.Config.synchronizeConfiguration | ||
import cpw.mods.fml.common.event.FMLInitializationEvent | ||
import cpw.mods.fml.common.event.FMLPostInitializationEvent | ||
import cpw.mods.fml.common.event.FMLPreInitializationEvent | ||
import cpw.mods.fml.common.event.FMLServerStartingEvent | ||
|
||
public class CommonProxy { | ||
class CommonProxy { | ||
// preInit "Run before anything else. Read your config, create blocks, items, etc, and register | ||
// them with the | ||
// GameRegistry." (Remove if not needed) | ||
fun preInit(event: FMLPreInitializationEvent) { | ||
synchronizeConfiguration(event.suggestedConfigurationFile) | ||
} | ||
|
||
// preInit "Run before anything else. Read your config, create blocks, items, etc, and register them with the | ||
// GameRegistry." (Remove if not needed) | ||
public void preInit(FMLPreInitializationEvent event) { | ||
Config.synchronizeConfiguration(event.getSuggestedConfigurationFile()); | ||
// load "Do your mod setup. Build whatever data structures you care about. Register recipes." | ||
// (Remove if not needed) | ||
fun init(event: FMLInitializationEvent?) {} | ||
|
||
Gregoriette.LOG.info(Config.greeting); | ||
Gregoriette.LOG.info("I am MyMod at version " + Tags.VERSION); | ||
} | ||
// postInit "Handle interaction with other mods, complete your setup based on this." (Remove if | ||
// not needed) | ||
fun postInit(event: FMLPostInitializationEvent?) {} | ||
|
||
// load "Do your mod setup. Build whatever data structures you care about. Register recipes." (Remove if not needed) | ||
public void init(FMLInitializationEvent event) {} | ||
|
||
// postInit "Handle interaction with other mods, complete your setup based on this." (Remove if not needed) | ||
public void postInit(FMLPostInitializationEvent event) {} | ||
|
||
// register server commands in this event handler (Remove if not needed) | ||
public void serverStarting(FMLServerStartingEvent event) {} | ||
// register server commands in this event handler (Remove if not needed) | ||
fun serverStarting(event: FMLServerStartingEvent?) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
package com.fardragi.gregoriette; | ||
package com.fardragi.gregoriette | ||
|
||
import java.io.File; | ||
import java.io.File | ||
import net.minecraftforge.common.config.Configuration | ||
|
||
import net.minecraftforge.common.config.Configuration; | ||
object Config { | ||
var botToken: String = "" | ||
|
||
public class Config { | ||
@JvmStatic | ||
fun synchronizeConfiguration(configFile: File?) { | ||
val configuration = Configuration(configFile) | ||
|
||
public static String greeting = "Hello World"; | ||
botToken = | ||
configuration.getString( | ||
"bot_token", Configuration.CATEGORY_GENERAL, botToken, "Discord bot token") | ||
|
||
public static void synchronizeConfiguration(File configFile) { | ||
Configuration configuration = new Configuration(configFile); | ||
|
||
greeting = configuration.getString("greeting", Configuration.CATEGORY_GENERAL, greeting, "How shall I greet?"); | ||
|
||
if (configuration.hasChanged()) { | ||
configuration.save(); | ||
} | ||
if (configuration.hasChanged()) { | ||
configuration.save() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,57 @@ | ||
package com.fardragi.gregoriette; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
import cpw.mods.fml.common.Mod; | ||
import cpw.mods.fml.common.SidedProxy; | ||
import cpw.mods.fml.common.event.FMLInitializationEvent; | ||
import cpw.mods.fml.common.event.FMLPostInitializationEvent; | ||
import cpw.mods.fml.common.event.FMLPreInitializationEvent; | ||
import cpw.mods.fml.common.event.FMLServerStartingEvent; | ||
package com.fardragi.gregoriette | ||
|
||
import com.fardragi.gregoriette.discord.DiscordBot | ||
import cpw.mods.fml.common.Mod | ||
import cpw.mods.fml.common.SidedProxy | ||
import cpw.mods.fml.common.event.FMLInitializationEvent | ||
import cpw.mods.fml.common.event.FMLPostInitializationEvent | ||
import cpw.mods.fml.common.event.FMLPreInitializationEvent | ||
import cpw.mods.fml.common.event.FMLServerStartingEvent | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
import org.apache.logging.log4j.LogManager | ||
import org.apache.logging.log4j.Logger | ||
|
||
@Mod( | ||
modid = Gregoriette.MODID, | ||
version = Tags.VERSION, | ||
name = "Gregoriette", | ||
acceptedMinecraftVersions = "[1.7.10]", | ||
acceptableRemoteVersions = "*") | ||
public class Gregoriette { | ||
|
||
public static final String MODID = "gregoriette"; | ||
public static final Logger LOG = LogManager.getLogger(MODID); | ||
|
||
@SidedProxy(serverSide = "com.fardragi.gregoriette.CommonProxy") | ||
public static CommonProxy proxy; | ||
|
||
@Mod.EventHandler | ||
// preInit "Run before anything else. Read your config, create blocks, items, etc, and register them with the | ||
// GameRegistry." (Remove if not needed) | ||
public void preInit(FMLPreInitializationEvent event) { | ||
proxy.preInit(event); | ||
} | ||
|
||
@Mod.EventHandler | ||
// load "Do your mod setup. Build whatever data structures you care about. Register recipes." (Remove if not needed) | ||
public void init(FMLInitializationEvent event) { | ||
proxy.init(event); | ||
} | ||
|
||
@Mod.EventHandler | ||
// postInit "Handle interaction with other mods, complete your setup based on this." (Remove if not needed) | ||
public void postInit(FMLPostInitializationEvent event) { | ||
proxy.postInit(event); | ||
} | ||
|
||
@Mod.EventHandler | ||
// register server commands in this event handler (Remove if not needed) | ||
public void serverStarting(FMLServerStartingEvent event) { | ||
proxy.serverStarting(event); | ||
} | ||
class Gregoriette { | ||
private var bot: DiscordBot? = null | ||
|
||
@Mod.EventHandler // preInit "Run before anything else. Read your config, create blocks, items, | ||
// etc, and register them with the | ||
// GameRegistry." (Remove if not needed) | ||
fun preInit(event: FMLPreInitializationEvent) { | ||
proxy!!.preInit(event) | ||
} | ||
|
||
@Mod.EventHandler // load "Do your mod setup. Build whatever data structures you care about. | ||
// Register recipes." (Remove if not needed) | ||
fun init(event: FMLInitializationEvent?) { | ||
proxy!!.init(event) | ||
|
||
CoroutineScope(Dispatchers.IO).launch { bot = DiscordBot() } | ||
} | ||
|
||
@Mod.EventHandler // postInit "Handle interaction with other mods, complete your setup based on | ||
// this." (Remove if not needed) | ||
fun postInit(event: FMLPostInitializationEvent?) { | ||
proxy!!.postInit(event) | ||
} | ||
|
||
@Mod.EventHandler // register server commands in this event handler (Remove if not needed) | ||
fun serverStarting(event: FMLServerStartingEvent?) { | ||
proxy!!.serverStarting(event) | ||
} | ||
|
||
companion object { | ||
const val MODID: String = "gregoriette" | ||
@JvmField val LOG: Logger = LogManager.getLogger(MODID) | ||
|
||
@SidedProxy(serverSide = "com.fardragi.gregoriette.CommonProxy") var proxy: CommonProxy? = null | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/com/fardragi/gregoriette/discord/DiscordBot.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.fardragi.gregoriette.discord | ||
|
||
import com.fardragi.gregoriette.Config | ||
import com.fardragi.gregoriette.Gregoriette | ||
import dev.minn.jda.ktx.events.onCommand | ||
import dev.minn.jda.ktx.interactions.commands.restrict | ||
import dev.minn.jda.ktx.interactions.commands.upsertCommand | ||
import dev.minn.jda.ktx.jdabuilder.light | ||
|
||
class DiscordBot { | ||
private val client = light(Config.botToken, true) | ||
|
||
init { | ||
Gregoriette.LOG.info("Bot starting") | ||
|
||
client.upsertCommand("test", "Test command") { restrict(true) }.queue() | ||
client.onCommand("test") { event -> event.reply("${event.user.asMention} ola").queue() } | ||
} | ||
} |