Skip to content

Commit

Permalink
Merge pull request #20 from NightMirror21/19-console-error-and-update…
Browse files Browse the repository at this point in the history
…-to-1204

19 console error and update to 1204
  • Loading branch information
NightMirror21 authored Jan 16, 2024
2 parents 3fb5ee8 + ac265bc commit 3129b16
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 63 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sourceCompatibility = javaVersion;
targetCompatibility = javaVersion;

group = 'ru.nightmirror'
version = '1.0.0'
version = '1.0.1'
description = 'WhitelistByTime'

repositories {
Expand Down
2 changes: 1 addition & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sourceCompatibility = javaVersion;
targetCompatibility = javaVersion;

group 'ru.nightmirror'
version '1.0.0'
version = rootProject.version

repositories {
mavenCentral()
Expand Down
13 changes: 11 additions & 2 deletions folia/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sourceCompatibility = javaVersion;
targetCompatibility = javaVersion;

group = 'ru.nightmirror'
version = '1.0.0'
version = rootProject.version
description = 'WhitelistByTime-Folia'

compileJava.options.encoding = "UTF-8"
Expand Down Expand Up @@ -36,9 +36,18 @@ repositories {
}
}

processResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
}

dependencies {
shadow project(path: ':core', configuration: 'default')
compileOnly 'dev.folia:folia-api:1.19.4-R0.1-SNAPSHOT'
compileOnly 'dev.folia:folia-api:1.20.2-R0.1-SNAPSHOT'
compileOnly 'net.kyori:adventure-text-minimessage:4.14.0'
implementation 'org.bstats:bstats-bukkit:3.0.1'
compileOnly 'me.clip:placeholderapi:2.11.3'
Expand Down
10 changes: 6 additions & 4 deletions folia/src/main/java/ru/nightmirror/wlbytime/WhitelistByTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import lombok.AccessLevel;
import lombok.experimental.FieldDefaults;
import org.bstats.bukkit.Metrics;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.HandlerList;
Expand All @@ -20,6 +19,7 @@
import ru.nightmirror.wlbytime.common.listeners.WhitelistCmdListener;
import ru.nightmirror.wlbytime.common.placeholder.PlaceholderHook;
import ru.nightmirror.wlbytime.common.utils.ConfigUtils;
import ru.nightmirror.wlbytime.common.utils.MetricsLoader;
import ru.nightmirror.wlbytime.interfaces.IWhitelist;
import ru.nightmirror.wlbytime.interfaces.checker.Checker;

Expand All @@ -42,7 +42,6 @@ public class WhitelistByTime extends JavaPlugin implements IWhitelist {
WLDatabase database;
Checker checker;
PlaceholderHook placeholderHook;
Metrics metrics;

public static void info(String message) {
if (log != null) log.info(message);
Expand Down Expand Up @@ -85,7 +84,6 @@ public void onDisable() {
HandlerList.unregisterAll(this);

if (placeholderHook != null) placeholderHook.unregister();
if (metrics != null) metrics.shutdown();
if (checker != null) checker.stop();
if (database != null) database.close();

Expand Down Expand Up @@ -161,7 +159,11 @@ private void hookPlaceholder() {
}

private void initMetrics() {
new Metrics(this, 13834);
try {
new MetricsLoader(this);
} catch (Exception exception) {
info("Failed to start collecting metrics. The plugin will continue working, but metrics will not be collected.");
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ru.nightmirror.wlbytime.common.utils;


import org.bstats.bukkit.Metrics;
import org.bukkit.plugin.java.JavaPlugin;

public class MetricsLoader {

public MetricsLoader(JavaPlugin plugin) throws ClassNotFoundException {
new Metrics(plugin, 13834);
}
}
2 changes: 1 addition & 1 deletion folia/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: WhitelistByTime
main: ru.nightmirror.wlbytime.WhitelistByTime
version: 1.0.0
version: '${version}'
author: NightMirror
description: Adding a player to the whitelist for a time
api-version: 1.16
Expand Down
24 changes: 16 additions & 8 deletions paper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
}

def javaVersion = JavaVersion.VERSION_16;
def javaVersion = JavaVersion.VERSION_17;
sourceCompatibility = javaVersion;
targetCompatibility = javaVersion;

group = 'ru.nightmirror'
version = '1.0.0'
version = rootProject.version
description = 'WhitelistByTime-Paper'

compileJava.options.encoding = "UTF-8"
Expand All @@ -17,11 +17,6 @@ compileTestJava.options.encoding = "UTF-8"
repositories {
mavenCentral()

maven {
name 'dmulloy2-repo'
url 'https://repo.dmulloy2.net/repository/public/'
}

maven {
name 'papermc-repo'
url 'https://repo.papermc.io/repository/maven-public/'
Expand All @@ -38,7 +33,7 @@ repositories {

dependencies {
shadow project(path: ':core', configuration: 'default')
compileOnly 'com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT'
compileOnly 'io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT'
compileOnly 'net.kyori:adventure-text-minimessage:4.14.0'
implementation 'org.bstats:bstats-bukkit:3.0.1'
compileOnly 'me.clip:placeholderapi:2.11.3'
Expand All @@ -52,4 +47,17 @@ shadowJar {
archiveClassifier.set(null)
configurations = [project.configurations.runtimeClasspath, project.configurations.shadow]
archiveFileName.set(project.description + '-' + project.version + '.jar')
}

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}

processResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
}
40 changes: 19 additions & 21 deletions paper/src/main/java/ru/nightmirror/wlbytime/WhitelistByTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import lombok.AccessLevel;
import lombok.experimental.FieldDefaults;
import org.bstats.bukkit.Metrics;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.HandlerList;
Expand All @@ -21,16 +20,14 @@
import ru.nightmirror.wlbytime.common.placeholder.PlaceholderHook;
import ru.nightmirror.wlbytime.common.utils.BukkitSyncer;
import ru.nightmirror.wlbytime.common.utils.ConfigUtils;
import ru.nightmirror.wlbytime.common.utils.MetricsLoader;
import ru.nightmirror.wlbytime.interfaces.IWhitelist;
import ru.nightmirror.wlbytime.interfaces.checker.Checker;
import ru.nightmirror.wlbytime.interfaces.listener.EventListener;

import java.sql.SQLException;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.logging.Logger;

Expand All @@ -47,7 +44,18 @@ public class WhitelistByTime extends JavaPlugin implements IWhitelist {
WLDatabase database;
Checker checker;
PlaceholderHook placeholderHook;
Metrics metrics;

public static void info(String message) {
if (log != null) log.info(message);
}

public static void warn(String message) {
if (log != null) log.warning(message);
}

public static void error(String message) {
if (log != null) log.severe(message);
}

@Override
public void onEnable() {
Expand Down Expand Up @@ -79,7 +87,6 @@ public void onDisable() {
HandlerList.unregisterAll(this);

if (placeholderHook != null) placeholderHook.unregister();
if (metrics != null) metrics.shutdown();
if (checker != null) checker.stop();
if (database != null) database.close();

Expand Down Expand Up @@ -128,7 +135,7 @@ private void initDatabase() throws SQLException {

private void initCommandsAndListeners() {
getServer().getPluginManager().registerEvents(new WhitelistCmdListener(new CommandsExecutor(database, this, timeConvertor)), this);
getServer().getPluginManager().registerEvents(new PlayerLoginListener(database, getConfig().getBoolean("case-sensitive", false),this), this);
getServer().getPluginManager().registerEvents(new PlayerLoginListener(database, getConfig().getBoolean("case-sensitive", false), this), this);

getCommand("whitelist").setExecutor(new WhitelistCommandExecutor(new CommandsExecutor(database, this, timeConvertor)));
getCommand("whitelist").setTabCompleter(new WhitelistTabCompleter(database, this));
Expand All @@ -155,7 +162,11 @@ private void hookPlaceholder() {
}

private void initMetrics() {
new Metrics(this, 13834);
try {
new MetricsLoader(this);
} catch (Exception exception) {
info("Failed to start collecting metrics. The plugin will continue working, but metrics will not be collected.");
}
}

@Override
Expand All @@ -172,17 +183,4 @@ public void setWhitelistEnabled(boolean mode) {
public FileConfiguration getPluginConfig() {
return getConfig();
}


public static void info(String message) {
if (log != null) log.info(message);
}

public static void warn(String message) {
if (log != null) log.warning(message);
}

public static void error(String message) {
if (log != null) log.severe(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ru.nightmirror.wlbytime.common.utils;


import org.bstats.bukkit.Metrics;
import org.bukkit.plugin.java.JavaPlugin;

public class MetricsLoader {

public MetricsLoader(JavaPlugin plugin) throws ClassNotFoundException {
new Metrics(plugin, 13834);
}
}
2 changes: 1 addition & 1 deletion paper/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: WhitelistByTime
main: ru.nightmirror.wlbytime.WhitelistByTime
version: 1.0.0
version: '${version}'
author: NightMirror
description: Adding a player to the whitelist for a time
api-version: 1.16
Expand Down
13 changes: 11 additions & 2 deletions spigot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sourceCompatibility = javaVersion;
targetCompatibility = javaVersion;

group = 'ru.nightmirror'
version = '1.0.0'
version = rootProject.version
description = 'WhitelistByTime-Spigot'

compileJava.options.encoding = "UTF-8"
Expand All @@ -32,7 +32,7 @@ repositories {

dependencies {
shadow project(path: ':core', configuration: 'default')
compileOnly 'org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT'
compileOnly 'org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT'
implementation 'org.bstats:bstats-bukkit:3.0.1'
compileOnly 'me.clip:placeholderapi:2.11.3'
compileOnly 'org.jetbrains:annotations:24.0.1'
Expand All @@ -45,4 +45,13 @@ shadowJar {
archiveClassifier.set(null)
configurations = [project.configurations.runtimeClasspath, project.configurations.shadow]
archiveFileName.set(project.description + '-' + project.version + '.jar')
}

processResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
}
Loading

0 comments on commit 3129b16

Please sign in to comment.