Compare commits
No commits in common. "948efe14fc420115ee92299ea60701b14d72018f" and "36a7b0cf68f91e9438809b91fb0f505f3b308e8b" have entirely different histories.
948efe14fc
...
36a7b0cf68
20
Jenkinsfile
vendored
20
Jenkinsfile
vendored
|
|
@ -1,20 +0,0 @@
|
||||||
pipeline {
|
|
||||||
agent any
|
|
||||||
stages {
|
|
||||||
stage('Gradle') {
|
|
||||||
steps {
|
|
||||||
sh './gradlew build'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Archive') {
|
|
||||||
steps {
|
|
||||||
archiveArtifacts artifacts: 'build/libs/', followSymlinks: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('discord') {
|
|
||||||
steps {
|
|
||||||
discordSend description: "Build: ${BUILD_NUMBER}", showChangeset: true, result: currentBuild.currentResult, title: currentBuild.fullProjectName, webhookURL: env.discordwebhook
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -3,7 +3,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("com.alttd:Galaxy-API:1.21-R0.1-SNAPSHOT")
|
compileOnly("com.alttd:Galaxy-API:1.19.2-R0.1-SNAPSHOT")
|
||||||
compileOnly("org.spongepowered:configurate-yaml:4.1.2") // Configurate
|
compileOnly("org.spongepowered:configurate-yaml:4.1.2") // Configurate
|
||||||
compileOnly("net.luckperms:api:5.3") // Luckperms
|
compileOnly("net.luckperms:api:5.3") // Luckperms
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,13 @@ abstract class AbstractConfig {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readConfig(clazz, null);
|
||||||
|
try {
|
||||||
|
configLoader.save(config);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void readConfig(Class<?> clazz, Object instance) {
|
protected void readConfig(Class<?> clazz, Object instance) {
|
||||||
|
|
@ -107,7 +114,7 @@ abstract class AbstractConfig {
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setString(String path, String def) {
|
protected static void setString(String path, String def) {
|
||||||
try {
|
try {
|
||||||
if(config.node(splitPath(path)).virtual())
|
if(config.node(splitPath(path)).virtual())
|
||||||
config.node(splitPath(path)).set(io.leangen.geantyref.TypeToken.get(String.class), def);
|
config.node(splitPath(path)).set(io.leangen.geantyref.TypeToken.get(String.class), def);
|
||||||
|
|
@ -116,53 +123,34 @@ abstract class AbstractConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean getBoolean(String prefix, String path, boolean def) {
|
protected static boolean getBoolean(String prefix, String path, boolean def) {
|
||||||
set(prefix, path, def);
|
set(prefix, path, def);
|
||||||
return config.node(splitPath(path)).getBoolean(def);
|
return config.node(splitPath(path)).getBoolean(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected double getDouble(String prefix, String path, double def) {
|
protected static double getDouble(String prefix, String path, double def) {
|
||||||
set(prefix, path, def);
|
set(prefix, path, def);
|
||||||
return config.node(splitPath(path)).getDouble(def);
|
return config.node(splitPath(path)).getDouble(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getInt(String prefix, String path, int def) {
|
protected static int getInt(String prefix, String path, int def) {
|
||||||
set(prefix, path, def);
|
set(prefix, path, def);
|
||||||
return config.node(splitPath(path)).getInt(def);
|
return config.node(splitPath(path)).getInt(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getString(String prefix, String path, String def) {
|
protected static String getString(String prefix, String path, String def) {
|
||||||
setString(path, def);
|
setString(path, def);
|
||||||
return config.node(splitPath(path)).getString(def);
|
return config.node(splitPath(path)).getString(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Long getLong(String prefix, String path, Long def) {
|
protected static Long getLong(String prefix, String path, Long def) {
|
||||||
set(prefix, path, def);
|
set(prefix, path, def);
|
||||||
return config.node(splitPath(path)).getLong(def);
|
return config.node(splitPath(path)).getLong(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setStringList(String prefix, String path, List<String> def) {
|
protected static <T> List<String> getList(String prefix, String path, T def) {
|
||||||
path = prefix + path;
|
|
||||||
System.out.println("Setting: " + def);
|
|
||||||
if(config.node(splitPath(path)).virtual()) {
|
|
||||||
try {
|
|
||||||
config.node(splitPath(path)).setList(TypeToken.get(String.class), def);
|
|
||||||
} catch (SerializationException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
config.node(splitPath(path)).setList(TypeToken.get(String.class), def);
|
|
||||||
} catch (SerializationException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
saveConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected List<String> getStringList(String prefix, String path, List<String> def) {
|
|
||||||
try {
|
try {
|
||||||
setStringList(prefix, path, def);
|
set(prefix, path, def);
|
||||||
return config.node(splitPath(path)).getList(TypeToken.get(String.class));
|
return config.node(splitPath(path)).getList(TypeToken.get(String.class));
|
||||||
} catch(SerializationException ex) {
|
} catch(SerializationException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ public class BoosterFileStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
File CONFIG_PATH = new File(File.separator + "mnt" + File.separator + "configs" + File.separator + "Boosters");
|
File CONFIG_PATH = new File(System.getProperty("user.home") + File.separator + "share" + File.separator + "configs" + File.separator + "Boosters");
|
||||||
if (!CONFIG_PATH.exists()) {
|
if (!CONFIG_PATH.exists()) {
|
||||||
if (!CONFIG_PATH.mkdir())
|
if (!CONFIG_PATH.mkdir())
|
||||||
logger.severe("Unable to create json storage directory");
|
logger.severe("Unable to create json storage directory");
|
||||||
|
|
@ -123,7 +123,14 @@ public class BoosterFileStorage {
|
||||||
parser.nextValue();
|
parser.nextValue();
|
||||||
double multiplier = parser.getValueAsDouble();
|
double multiplier = parser.getValueAsDouble();
|
||||||
|
|
||||||
return Optional.of(new Booster(boosterUUID, activatorName, boosterType, startingTime, duration, multiplier));
|
jsonToken = parser.nextToken();
|
||||||
|
if (jsonToken != JsonToken.FIELD_NAME || !"running".equals(parser.getCurrentName()))
|
||||||
|
return error("Didn't find running at expected location");
|
||||||
|
parser.nextValue();
|
||||||
|
boolean running = parser.getValueAsBoolean();
|
||||||
|
parser.nextValue();
|
||||||
|
|
||||||
|
return Optional.of(new Booster(boosterUUID, activatorName, boosterType, startingTime, duration, multiplier, running));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<Booster> error(String error) {
|
private Optional<Booster> error(String error) {
|
||||||
|
|
@ -153,6 +160,7 @@ public class BoosterFileStorage {
|
||||||
generator.writeNumberField("startingTime", booster.getStartingTime().toEpochMilli());
|
generator.writeNumberField("startingTime", booster.getStartingTime().toEpochMilli());
|
||||||
generator.writeNumberField("duration", booster.getDuration().toMillis());
|
generator.writeNumberField("duration", booster.getDuration().toMillis());
|
||||||
generator.writeNumberField("multiplier", booster.getMultiplier());
|
generator.writeNumberField("multiplier", booster.getMultiplier());
|
||||||
|
generator.writeBooleanField("running", booster.getRunning());
|
||||||
|
|
||||||
generator.writeEndObject();
|
generator.writeEndObject();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@ public final class Config extends AbstractConfig {
|
||||||
|
|
||||||
Config(Logger logger) {
|
Config(Logger logger) {
|
||||||
super(
|
super(
|
||||||
new File(File.separator
|
new File(System.getProperty("user.home") + File.separator
|
||||||
+ "mnt" + File.separator
|
+ "share" + File.separator
|
||||||
+ "configs" + File.separator
|
+ "configs" + File.separator
|
||||||
+ "Boosters"),
|
+ "Boosters"),
|
||||||
"config.yml", logger, Config.class);
|
"config.yml", logger, Config.class);
|
||||||
|
|
@ -20,7 +20,7 @@ public final class Config extends AbstractConfig {
|
||||||
|
|
||||||
public static void reload(Logger logger) {
|
public static void reload(Logger logger) {
|
||||||
config = new Config(logger);
|
config = new Config(logger);
|
||||||
config.readConfig(Config.class, config);
|
config.readConfig(Config.class, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class LOGGING {
|
public static class LOGGING {
|
||||||
|
|
@ -47,7 +47,7 @@ public final class Config extends AbstractConfig {
|
||||||
UPDATE_FREQUENCY_MINUTES = config.getInt(prefix, "update-frequency-minutes", UPDATE_FREQUENCY_MINUTES);
|
UPDATE_FREQUENCY_MINUTES = config.getInt(prefix, "update-frequency-minutes", UPDATE_FREQUENCY_MINUTES);
|
||||||
BOOST_ANNOUNCE_CHANNEL = config.getLong(prefix, "boost-announce-channel", BOOST_ANNOUNCE_CHANNEL);
|
BOOST_ANNOUNCE_CHANNEL = config.getLong(prefix, "boost-announce-channel", BOOST_ANNOUNCE_CHANNEL);
|
||||||
PLUGIN_MESSAGE_CHANNEL = config.getString(prefix, "plugin-message-channel", PLUGIN_MESSAGE_CHANNEL);
|
PLUGIN_MESSAGE_CHANNEL = config.getString(prefix, "plugin-message-channel", PLUGIN_MESSAGE_CHANNEL);
|
||||||
// DONOR_RANKS = config.getStringList(prefix, "donor-ranks", DONOR_RANKS);
|
DONOR_RANKS = config.getList(prefix, "donor-ranks", DONOR_RANKS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ public class Booster implements Comparable<Booster> {
|
||||||
private Duration duration;
|
private Duration duration;
|
||||||
private final BoosterType boosterType;
|
private final BoosterType boosterType;
|
||||||
private final Double multiplier;
|
private final Double multiplier;
|
||||||
|
private Boolean running;
|
||||||
|
|
||||||
public Booster(UUID boosterUUID, BoosterType boosterType, String reason, Duration duration, double multiplier) {
|
public Booster(UUID boosterUUID, BoosterType boosterType, String reason, Duration duration, double multiplier) {
|
||||||
this.boosterUUID = boosterUUID;
|
this.boosterUUID = boosterUUID;
|
||||||
|
|
@ -22,6 +23,7 @@ public class Booster implements Comparable<Booster> {
|
||||||
this.activatorName = reason;
|
this.activatorName = reason;
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
this.multiplier = multiplier;
|
this.multiplier = multiplier;
|
||||||
|
this.running = false;
|
||||||
this.startingTime = Instant.now();
|
this.startingTime = Instant.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,13 +32,14 @@ public class Booster implements Comparable<Booster> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Booster(UUID boosterUUID, String activatorName, BoosterType boosterType, Instant startingTime,
|
public Booster(UUID boosterUUID, String activatorName, BoosterType boosterType, Instant startingTime,
|
||||||
Duration duration, double multiplier) {
|
Duration duration, double multiplier, boolean running) {
|
||||||
this.boosterUUID = boosterUUID;
|
this.boosterUUID = boosterUUID;
|
||||||
this.activatorName = activatorName;
|
this.activatorName = activatorName;
|
||||||
this.boosterType = boosterType;
|
this.boosterType = boosterType;
|
||||||
this.startingTime = startingTime;
|
this.startingTime = startingTime;
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
this.multiplier = multiplier;
|
this.multiplier = multiplier;
|
||||||
|
this.running = running;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateDuration() {
|
public void updateDuration() {
|
||||||
|
|
@ -45,10 +48,6 @@ public class Booster implements Comparable<Booster> {
|
||||||
duration = duration.minus(elapsedTime);
|
duration = duration.minus(elapsedTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateTimeAfterReActivate() {
|
|
||||||
startingTime = Instant.now();
|
|
||||||
}
|
|
||||||
|
|
||||||
public double useMultiplier(double exp) {
|
public double useMultiplier(double exp) {
|
||||||
return exp * (multiplier + 1);
|
return exp * (multiplier + 1);
|
||||||
}
|
}
|
||||||
|
|
@ -77,6 +76,10 @@ public class Booster implements Comparable<Booster> {
|
||||||
return multiplier;
|
return multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getRunning() {
|
||||||
|
return running;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o)
|
if (this == o)
|
||||||
|
|
@ -111,6 +114,7 @@ public class Booster implements Comparable<Booster> {
|
||||||
", duration=" + duration +
|
", duration=" + duration +
|
||||||
", boosterType=" + boosterType +
|
", boosterType=" + boosterType +
|
||||||
", multiplier=" + multiplier +
|
", multiplier=" + multiplier +
|
||||||
|
", running=" + running +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,14 +41,7 @@ public class BoosterCache {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LinkedList<Booster> list = boosters.get(boosterType);
|
LinkedList<Booster> list = boosters.get(boosterType);
|
||||||
Booster oldActive = null;
|
|
||||||
if (list.size() > 1) {
|
|
||||||
oldActive = list.get(0);
|
|
||||||
}
|
|
||||||
list.sort(Booster::compareTo);
|
list.sort(Booster::compareTo);
|
||||||
if (oldActive != null && !list.get(0).getBoosterUUID().equals(oldActive.getBoosterUUID())) {
|
|
||||||
oldActive.updateDuration();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized Optional<Booster> getActiveBooster(BoosterType boosterType) {
|
public synchronized Optional<Booster> getActiveBooster(BoosterType boosterType) {
|
||||||
|
|
@ -108,11 +101,6 @@ public class BoosterCache {
|
||||||
list.removeIf(filterBooster -> filterBooster.getBoosterUUID().equals(booster.getBoosterUUID()));
|
list.removeIf(filterBooster -> filterBooster.getBoosterUUID().equals(booster.getBoosterUUID()));
|
||||||
boosters.put(boosterType, list);
|
boosters.put(boosterType, list);
|
||||||
updateOrder(boosterType);
|
updateOrder(boosterType);
|
||||||
LinkedList<Booster> updatedBoosterList = boosters.get(boosterType);
|
|
||||||
if (updatedBoosterList.size() > 0) {
|
|
||||||
Booster nextBooster = updatedBoosterList.get(0);
|
|
||||||
nextBooster.updateTimeAfterReActivate();
|
|
||||||
}
|
|
||||||
boosterFileStorage.saveBoosters(boosters.values().stream().flatMap(List::stream).collect(Collectors.toList()));
|
boosterFileStorage.saveBoosters(boosters.values().stream().flatMap(List::stream).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,6 @@ public enum BoosterType {
|
||||||
TAMING("taming", MCMMO),
|
TAMING("taming", MCMMO),
|
||||||
UNARMED("unarmed", MCMMO),
|
UNARMED("unarmed", MCMMO),
|
||||||
WOODCUTTING("woodcutting", MCMMO),
|
WOODCUTTING("woodcutting", MCMMO),
|
||||||
CROSSBOWS("crossbows", MCMMO),
|
|
||||||
MACES("maces", MCMMO),
|
|
||||||
TRIDENTS("tridents", MCMMO),
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MYPET - Boosts MyPet exp gains
|
* MYPET - Boosts MyPet exp gains
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,25 @@
|
||||||
plugins {
|
plugins {
|
||||||
`java-library`
|
`java-library`
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
id("io.github.goooler.shadow") version "8.1.8"
|
id("com.github.johnrengelman.shadow") version "7.1.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
group = "com.alttd.boosters"
|
group = "com.alttd.boosters"
|
||||||
version = "1.0.0-BETA-SNAPSHOT"
|
version = "1.0.0-BETA-SNAPSHOT"
|
||||||
description = "Easily manage all boosters on the Altitude Minecraft Server Network."
|
description = "Easily manage all boosters on the Altitude Minecraft Server Network."
|
||||||
|
}
|
||||||
|
|
||||||
|
subprojects {
|
||||||
apply<JavaLibraryPlugin>()
|
apply<JavaLibraryPlugin>()
|
||||||
apply(plugin = "maven-publish")
|
apply(plugin = "maven-publish")
|
||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain {
|
toolchain {
|
||||||
languageVersion.set(JavaLanguageVersion.of(21))
|
languageVersion.set(JavaLanguageVersion.of(17))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
subprojects {
|
|
||||||
tasks {
|
tasks {
|
||||||
withType<JavaCompile> {
|
withType<JavaCompile> {
|
||||||
options.encoding = Charsets.UTF_8.name()
|
options.encoding = Charsets.UTF_8.name()
|
||||||
|
|
|
||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
|
@ -1,5 +1,5 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
plugins {
|
plugins {
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
id("io.github.goooler.shadow")
|
id("com.github.johnrengelman.shadow")
|
||||||
id("net.minecrell.plugin-yml.bukkit") version "0.5.1"
|
id("net.minecrell.plugin-yml.bukkit") version "0.5.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -8,11 +8,11 @@ dependencies {
|
||||||
// API
|
// API
|
||||||
implementation(project(":boosters-api"))
|
implementation(project(":boosters-api"))
|
||||||
// Galaxy
|
// Galaxy
|
||||||
compileOnly("com.alttd:Galaxy-API:1.21-R0.1-SNAPSHOT")
|
compileOnly("com.alttd:Galaxy-API:1.19.2-R0.1-SNAPSHOT")
|
||||||
// MyPet
|
// MyPet
|
||||||
compileOnly("de.keyle:mypet:3.12-SNAPSHOT")
|
compileOnly("de.keyle:mypet:3.12-SNAPSHOT")
|
||||||
// mcMMO
|
// mcMMO
|
||||||
compileOnly("com.gmail.nossr50.mcMMO:mcMMO:2.2.004") {
|
compileOnly("com.gmail.nossr50.mcMMO:mcMMO:2.1.206") {
|
||||||
exclude("com.sk89q.worldguard")
|
exclude("com.sk89q.worldguard")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
plugins {
|
plugins {
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
id("io.github.goooler.shadow")
|
id("com.github.johnrengelman.shadow")
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user