Skip to content

Commit

Permalink
2.0.0
Browse files Browse the repository at this point in the history
initial release
  • Loading branch information
Wyvest committed Aug 26, 2021
1 parent d600236 commit 33947b2
Show file tree
Hide file tree
Showing 15 changed files with 144 additions and 147 deletions.
50 changes: 21 additions & 29 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ plugins {
id "org.jetbrains.kotlin.jvm" version "1.5.21"
}

version = "1.0.0"
version = "2.0.0"
group = "net.wyvest"
archivesBaseName = "ForgeTemplate"
archivesBaseName = "BehindYouv2"

sourceCompatibility = targetCompatibility = 1.8
compileJava.options.encoding = "UTF-8"
Expand All @@ -17,8 +17,8 @@ minecraft {
runDir = "run"
mappings = "stable_22"
makeObfSourceJar = false
clientJvmArgs += '-Dfml.coreMods.load=net.wyvest.template.tweaker.TemplateLoadingPlugin'
clientRunArgs += '--tweakClass net.wyvest.template.tweaker.RequisiteEssentialTweaker'
clientJvmArgs += '-Dfml.coreMods.load=net.wyvest.behindyou.tweaker.BehindYouLoadingPlugin'
clientRunArgs += '--tweakClass net.wyvest.requisiteessentialloader.RequisiteEssentialTweaker'
}

configurations {
Expand All @@ -32,31 +32,24 @@ repositories {
maven { url 'https://repo.sk1er.club/repository/maven-releases/' }
maven { url 'https://jitpack.io/' }
maven { url 'https://repo.spongepowered.org/repository/maven-public/' }
maven {
url 'http://maven.matthewtgm.xyz/repository/maven-public/'
allowInsecureProtocol = true
}
}

dependencies {
// Libraries
provided 'xyz.matthewtgm:Requisite:1.1.1'
include('xyz.matthewtgm:RequisiteLaunchwrapper:1.1') {
transitive = false
}
include('gg.essential:loader-launchwrapper:1.1.0') {
transitive = false
}
include 'com.github.W-OVERFLOW:RequisiteEssentialLoader:7a4eb4eeb7'
implementation ('xyz.matthewtgm:RequisiteLaunchwrapper:1.1')
implementation ('gg.essential:loader-launchwrapper:1.1.0')
provided 'gg.essential:essential-1.8.9-forge:1300'
}

jar {
manifest.attributes(
'ModSide': 'CLIENT',
'FMLCorePlugin': 'net.wyvest.template.tweaker.TemplateLoadingPlugin',
'FMLCorePlugin': 'net.wyvest.behindyou.tweaker.BehindYouLoadingPlugin',
'FMLCorePluginContainsFMLMod': true,
'ForceLoadAsMod': true,
'TweakClass': 'net.wyvest.template.tweaker.RequisiteEssentialTweaker',
'TweakClass': 'net.wyvest.requisiteessentialloader.RequisiteEssentialTweaker',
'TweakOrder': '0'
)

Expand Down Expand Up @@ -85,19 +78,6 @@ processResources {
}
}

/**
* This task simply moves resources so they can be accessed at runtime, Forge is quite weird isn"t it
*/
task moveResources {
doLast {
ant.move file: "${buildDir}/resources/main",
todir: "${buildDir}/classes/java"
}
}

moveResources.dependsOn processResources
classes.dependsOn moveResources

// This forces the build task to run shadowJar after
tasks.reobfJar.dependsOn(tasks.shadowJar)

Expand Down Expand Up @@ -139,3 +119,15 @@ compileTestKotlin {
jvmTarget = "1.8"
}
}

reobf {
shadowJar {
classpath = sourceSets.main.compileClasspath
}
}

sourceSets {
main {
output.resourcesDir = file("${buildDir}/classes/kotlin/main")
}
}
5 changes: 2 additions & 3 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ pluginManagement {
resolutionStrategy {
eachPlugin {
// If the "net.minecraftforge.gradle.forge" plugin is requested we redirect it to asbyth's ForgeGradle fork
if (requested.id.id == "net.minecraftforge.gradle.forge") {
if (requested.id.id == "net.minecraftforge.gradle.forge")
useModule("com.github.asbyth:ForgeGradle:${requested.version}")
}
}
}
}

rootProject.name = "KotlinForgeTemplate"
rootProject.name = "BehindYouv2"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.wyvest.template.tweaker;
package net.wyvest.behindyou.tweaker;

import kotlin.KotlinVersion;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
Expand All @@ -10,16 +10,15 @@
import java.io.File;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URL;
import java.util.Map;

/**
* Adapted from Skytils under AGPLv3
* https://github.com/Skytils/SkytilsMod/blob/1.x/LICENSE.md
*/
public class TemplateLoadingPlugin implements IFMLLoadingPlugin {
public class BehindYouLoadingPlugin implements IFMLLoadingPlugin {

public TemplateLoadingPlugin() {
public BehindYouLoadingPlugin() {
if (!KotlinVersion.CURRENT.isAtLeast(1, 5, 0)) {
showMessage(new File(new File(KotlinVersion.class.getProtectionDomain().getCodeSource().getLocation().toString()).getParentFile().getParentFile().getName()));
}
Expand Down Expand Up @@ -76,16 +75,6 @@ public void mouseClicked(MouseEvent event) {
}
});

Icon icon = null;
try {
URL url = TemplateLoadingPlugin.class.getResource("/assets/template/wyvest.png");
if (url != null) {
icon = new ImageIcon(Toolkit.getDefaultToolkit().createImage(url).getScaledInstance(50, 50, Image.SCALE_DEFAULT));
}
} catch (Exception e) {
e.printStackTrace();
}

JButton close = new JButton("Close");
close.addMouseListener(new MouseAdapter() {
@Override
Expand All @@ -101,7 +90,7 @@ public void mouseClicked(MouseEvent e) {
"Template Error",
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
icon,
null,
options,
options[0]
);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
package net.wyvest.template
package net.wyvest.behindyou

import net.minecraft.client.Minecraft
import net.minecraft.util.EnumChatFormatting
import net.minecraftforge.fml.common.Mod
import net.minecraftforge.fml.common.event.FMLInitializationEvent
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent
import net.wyvest.template.commands.TemplateCommand
import net.wyvest.template.config.TemplateConfig
import net.wyvest.template.utils.Updater
import net.wyvest.behindyou.commands.BehindYouCommand
import net.wyvest.behindyou.config.BehindYouConfig
import net.wyvest.behindyou.utils.Updater
import xyz.matthewtgm.requisite.util.ChatHelper
import xyz.matthewtgm.requisite.util.ForgeHelper
import java.io.File

@Mod(name = ForgeTemplate.NAME, modid = ForgeTemplate.ID, version = ForgeTemplate.VERSION, modLanguageAdapter = "gg.essential.api.utils.KotlinAdapter")
object ForgeTemplate {
const val NAME = "ForgeTemplate"
const val VERSION = "1.0.0"
const val ID = "forgetemplate"
@Mod(name = BehindYou.NAME, modid = BehindYou.ID, version = BehindYou.VERSION, modLanguageAdapter = "gg.essential.api.utils.KotlinAdapter")
object BehindYou {
const val NAME = "BehindYouv2"
const val VERSION = "2.0.0"
const val ID = "behindyouv2"
val mc: Minecraft
get() = Minecraft.getMinecraft()
fun sendMessage(message: String?) {
fun sendMessage(message: String) {
ChatHelper.sendMessage(EnumChatFormatting.DARK_PURPLE.toString() + "[$NAME] ", message)
}
lateinit var jarFile: File
private val modDir = File(File(File(mc.mcDataDir, "config"), "Wyvest"), NAME)
val modDir = File(File(File(mc.mcDataDir, "config"), "Wyvest"), NAME)

@Mod.EventHandler
private fun onFMLPreInitialization(event: FMLPreInitializationEvent) {
Expand All @@ -32,8 +33,9 @@ object ForgeTemplate {

@Mod.EventHandler
fun onFMLInitialization(event: FMLInitializationEvent) {
TemplateConfig.initialize()
TemplateCommand.register()
BehindYouConfig.initialize()
BehindYouCommand.register()
Updater.update()
ForgeHelper.registerEventListener(Listener)
}
}
20 changes: 20 additions & 0 deletions src/main/kotlin/net/wyvest/behindyou/Listener.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package net.wyvest.behindyou

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
import net.wyvest.behindyou.config.BehindYouConfig

object Listener {

@SubscribeEvent
fun listen(e : TickEvent.ClientTickEvent) {
if (e.phase == TickEvent.Phase.END) {
if (BehindYouConfig.toggled) {
if (BehindYou.mc.gameSettings.thirdPersonView == 1) {
++BehindYou.mc.gameSettings.thirdPersonView
}
}
}
}

}
26 changes: 26 additions & 0 deletions src/main/kotlin/net/wyvest/behindyou/commands/BehindYouCommand.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package net.wyvest.behindyou.commands

import gg.essential.api.EssentialAPI
import gg.essential.api.commands.Command
import gg.essential.api.commands.DefaultHandler
import gg.essential.api.commands.SubCommand
import net.wyvest.behindyou.BehindYou
import net.wyvest.behindyou.config.BehindYouConfig

@Suppress("unused")
object BehindYouCommand : Command(BehindYou.ID, true) {

override val commandAliases = setOf(
Alias("behind")
)

@DefaultHandler
fun handle() {
EssentialAPI.getGuiUtil().openScreen(BehindYouConfig.gui())
}

@SubCommand("config", description = "Opens the config GUI for " + BehindYou.NAME)
fun config() {
EssentialAPI.getGuiUtil().openScreen(BehindYouConfig.gui())
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
package net.wyvest.template.config
package net.wyvest.behindyou.config

import gg.essential.api.EssentialAPI
import gg.essential.vigilance.Vigilant
import gg.essential.vigilance.data.Property
import gg.essential.vigilance.data.PropertyType
import net.wyvest.template.ForgeTemplate
import net.wyvest.template.ForgeTemplate.NAME
import net.wyvest.template.ForgeTemplate.mc
import net.wyvest.template.gui.DownloadConfirmGui
import net.wyvest.template.utils.Updater
import net.wyvest.behindyou.BehindYou
import net.wyvest.behindyou.BehindYou.NAME
import net.wyvest.behindyou.BehindYou.mc
import net.wyvest.behindyou.gui.DownloadConfirmGui
import net.wyvest.behindyou.utils.Updater
import java.io.File

object TemplateConfig : Vigilant(File("config/Wyvest/$NAME/${ForgeTemplate.ID}.toml"), NAME) {
object BehindYouConfig : Vigilant(File(BehindYou.modDir, "${BehindYou.ID}.toml"), NAME) {

@Property(
type = PropertyType.SWITCH,
name = "Toggle Mod",
description = "Toggle the mod.",
category = "General"
)
var toggled = true

@Property(
type = PropertyType.SWITCH,
name = "Show Update Notification",
description = "Show a notification when you start Minecraft informing you of new updates.",
category = "Updater"
category = "General"
)
var showUpdateNotification = true

@Property(
type = PropertyType.BUTTON,
name = "Update Now",
description = "Update $NAME by clicking the button.",
category = "Updater"
category = "General"
)
fun update() {
if (Updater.shouldUpdate) EssentialAPI.getGuiUtil()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.wyvest.template.gui
package net.wyvest.behindyou.gui

import gg.essential.api.EssentialAPI
import gg.essential.api.utils.Multithreading
Expand All @@ -7,10 +7,10 @@ import net.minecraft.client.gui.GuiMainMenu
import net.minecraft.client.gui.GuiScreen
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.util.EnumChatFormatting
import net.wyvest.template.ForgeTemplate
import net.wyvest.template.utils.Updater
import net.wyvest.template.utils.Updater.shouldUpdate
import net.wyvest.template.utils.Updater.updateUrl
import net.wyvest.behindyou.BehindYou
import net.wyvest.behindyou.utils.Updater
import net.wyvest.behindyou.utils.Updater.shouldUpdate
import net.wyvest.behindyou.utils.Updater.updateUrl
import java.io.File
import kotlin.math.max

Expand All @@ -29,19 +29,19 @@ class DownloadConfirmGui(private val parent: GuiScreen?) : GuiScreen() {
Multithreading.runAsync {
if (Updater.download(
updateUrl,
File("mods/${ForgeTemplate.NAME}-${Updater.latestTag.substringAfter("v")}.jar")
File("mods/${BehindYou.NAME}-${Updater.latestTag.substringAfter("v")}.jar")
) && Updater.download(
"https://github.com/Wyvest/Deleter/releases/download/v1.2/Deleter-1.2.jar",
File("config/Wyvest/Deleter-1.2.jar")
)
) {
EssentialAPI.getNotifications()
.push(ForgeTemplate.NAME, "The ingame updater has successfully installed the newest version.")
.push(BehindYou.NAME, "The ingame updater has successfully installed the newest version.")
Updater.addShutdownHook()
shouldUpdate = false
} else {
EssentialAPI.getNotifications().push(
ForgeTemplate.NAME,
BehindYou.NAME,
"The ingame updater has NOT installed the newest version as something went wrong."
)
}
Expand All @@ -63,7 +63,7 @@ class DownloadConfirmGui(private val parent: GuiScreen?) : GuiScreen() {
GlStateManager.scale(2f, 2f, 0f)
drawCenteredString(
fontRendererObj,
EnumChatFormatting.DARK_PURPLE.toString() + ForgeTemplate.NAME,
EnumChatFormatting.DARK_PURPLE.toString() + BehindYou.NAME,
width / 4,
3,
-1
Expand All @@ -74,7 +74,7 @@ class DownloadConfirmGui(private val parent: GuiScreen?) : GuiScreen() {
val lines = listOf(
"Are you sure you want to update?",
"You can download it ingame at any time via the configuration screen.",
"(This will update from v${ForgeTemplate.VERSION} to ${Updater.latestTag})"
"(This will update from v${BehindYou.VERSION} to ${Updater.latestTag})"
)
var offset = max(85 - lines.size * 10, 10)

Expand Down
Loading

0 comments on commit 33947b2

Please sign in to comment.