Skip to content

Commit

Permalink
Added ability to use timeout with midnight reset
Browse files Browse the repository at this point in the history
  • Loading branch information
SkinnyDevi committed Jul 15, 2023
1 parent e5a8164 commit 8960fad
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 46 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,33 @@ Available configurations include:
- Timeout length
- Should the player should be warned X minutes prior to being kicked
- Should the player have their timeout timer reset upon reconnecting
- Should the player timeout timer have the timer reset after midnight
- Should the player timeout timer reset after midnight
- Should the timeout specified run parallel to the midnight reset timeout
- Enable or disable tracking total time played.

On normal circumstances, the default setup has midnight reset and time warnings active.
Default configuration file:
```toml
["Playtime Limiter configuration"]
#The Length (IN SECONDS) which a Player can play on your Server before getting Kicked with a Timeout. Default is 3 Hours
#The length (IN SECONDS) which a player can play on your server before getting kicked with a timeout. Default is 3 hours
#Range: 1 ~ 604800
playtime_length = 10800
#The Length (IN SECONDS) which a Player has to wait, after being kicked from the server to be able to join again. Default is 12 Hours
#The length (IN SECONDS) which a player has to wait, after being kicked from the server to be able to join again. Default is 12 hours.
#Do not leave blank.
#Range: 1 ~ 604800
playtime_timeout = 43200
#If Players should get warned before they get kicked.
#If players should get warned before they get kicked.
#They would get warned: {30, 15, 10, 5, 3, 1} Minute(s) before being Kicked!
playtime_warn_kick = true
#If the Playtime should be reset after the Player Reconnects
#If the playtime should be reset after the Player Reconnects
playtime_reset_reconnect = false
#If the Playtime should be reset after once the Server detects that a new (IRL) Day has started since the last time the Player has joined
#If enabled, omits the timeout set above. If the playtime timeout should be reset once the server detects that a new (IRL) day has started since the last time the player has joined
playtime_reset_midnight = true
#Allow a timeout to occur between the playtime and midnight reset.
#Example: If you have a timeout of 12 hours and Midnight Reset active, activating this option would compare which timeout is smaller and apply the shortest timeout.
#In this case, if we play at 4 am, the shortest timeout would be 4 pm. But if we play at 6 pm, the shortest timeout would be midnight reset.
#Default is false.
allow_timeout_with_midnight = false
#Enable or disable tracking the player's total play time.
track_total_playtime = true
```
Expand Down
41 changes: 2 additions & 39 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ plugins {
}

version = mod_version
group = 'com.skinnydevi.playtimelimiter' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
group = 'com.skinnydevi.playtimelimiter'
archivesBaseName = 'playtimelimiter'

// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
java.toolchain.languageVersion = JavaLanguageVersion.of(17)

println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
Expand All @@ -30,25 +29,14 @@ minecraft {

// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.

// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
client {
workingDirectory project.file('run')

// Recommended logging data for a userdev environment
// The markers can be added/remove as needed separated by commas.
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
property 'forge.logging.markers', 'REGISTRIES'

// Recommended logging level for the console
// You can set various levels here.
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
property 'forge.logging.console.level', 'debug'

// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
property 'forge.enabledGameTestNamespaces', 'playtimelimiter'

mods {
Expand All @@ -74,9 +62,6 @@ minecraft {
}
}

// This run config launches GameTestServer and runs all registered gametests, then exits.
// By default, the server will crash when no gametests are provided.
// The gametest system is also enabled by default for other run configs under the /test command.
gameTestServer {
workingDirectory project.file('run')

Expand All @@ -100,7 +85,6 @@ minecraft {

property 'forge.logging.console.level', 'debug'

// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
args '--mod', 'playtimelimiter', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')

mods {
Expand All @@ -112,7 +96,6 @@ minecraft {
}
}

// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }

repositories {
Expand All @@ -126,25 +109,9 @@ repositories {
}

dependencies {
// Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed
// that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft 'net.minecraftforge:forge:1.19.2-43.2.11'

// Real mod deobf dependency examples - these get remapped to your current mappings
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
// runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency
// implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency

// Examples using mod jars from ./libs
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")

// For more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
}

// Example for how to get properties into the manifest for reading at runtime.
jar {
manifest {
attributes([
Expand All @@ -159,11 +126,7 @@ jar {
}
}

// Example configuration to allow publishing using the maven-publish plugin
// This is the preferred method to reobfuscate your jar file
jar.finalizedBy('reobfJar')
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
// publish.dependsOn('reobfJar')

publishing {
publications {
Expand All @@ -179,5 +142,5 @@ publishing {
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
options.encoding = 'UTF-8'
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

mod_version=1.1.3-1.19.2
mod_version=1.2.0-1.19.2

0 comments on commit 8960fad

Please sign in to comment.