Compare commits
10 Commits
36a7b0cf68
...
948efe14fc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
948efe14fc | ||
|
|
bafbd73d3f | ||
|
|
6491b1b154 | ||
|
|
4e1c832645 | ||
|
|
254acc4918 | ||
|
|
4b7fdd3141 | ||
|
|
f15520f6a2 | ||
|
|
4ec85a4079 | ||
|
|
95030d8163 | ||
|
|
75aa05cdf5 |
20
Jenkinsfile
vendored
Normal file
20
Jenkinsfile
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
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.19.2-R0.1-SNAPSHOT")
|
compileOnly("com.alttd:Galaxy-API:1.21-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,13 +58,6 @@ 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) {
|
||||||
|
|
@ -114,7 +107,7 @@ abstract class AbstractConfig {
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void setString(String path, String def) {
|
protected 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);
|
||||||
|
|
@ -123,34 +116,53 @@ abstract class AbstractConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static boolean getBoolean(String prefix, String path, boolean def) {
|
protected 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 static double getDouble(String prefix, String path, double def) {
|
protected 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 static int getInt(String prefix, String path, int def) {
|
protected 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 static String getString(String prefix, String path, String def) {
|
protected 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 static Long getLong(String prefix, String path, Long def) {
|
protected 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static <T> List<String> getList(String prefix, String path, T def) {
|
private void setStringList(String prefix, String path, List<String> def) {
|
||||||
|
path = prefix + path;
|
||||||
|
System.out.println("Setting: " + def);
|
||||||
|
if(config.node(splitPath(path)).virtual()) {
|
||||||
try {
|
try {
|
||||||
set(prefix, path, def);
|
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 {
|
||||||
|
setStringList(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(System.getProperty("user.home") + File.separator + "share" + File.separator + "configs" + File.separator + "Boosters");
|
File CONFIG_PATH = new File(File.separator + "mnt" + 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,14 +123,7 @@ public class BoosterFileStorage {
|
||||||
parser.nextValue();
|
parser.nextValue();
|
||||||
double multiplier = parser.getValueAsDouble();
|
double multiplier = parser.getValueAsDouble();
|
||||||
|
|
||||||
jsonToken = parser.nextToken();
|
return Optional.of(new Booster(boosterUUID, activatorName, boosterType, startingTime, duration, multiplier));
|
||||||
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) {
|
||||||
|
|
@ -160,7 +153,6 @@ 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(System.getProperty("user.home") + File.separator
|
new File(File.separator
|
||||||
+ "share" + File.separator
|
+ "mnt" + 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, null);
|
config.readConfig(Config.class, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
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.getList(prefix, "donor-ranks", DONOR_RANKS);
|
// DONOR_RANKS = config.getStringList(prefix, "donor-ranks", DONOR_RANKS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ 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;
|
||||||
|
|
@ -23,7 +22,6 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -32,14 +30,13 @@ 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, boolean running) {
|
Duration duration, double multiplier) {
|
||||||
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() {
|
||||||
|
|
@ -48,6 +45,10 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
@ -76,10 +77,6 @@ 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)
|
||||||
|
|
@ -114,7 +111,6 @@ public class Booster implements Comparable<Booster> {
|
||||||
", duration=" + duration +
|
", duration=" + duration +
|
||||||
", boosterType=" + boosterType +
|
", boosterType=" + boosterType +
|
||||||
", multiplier=" + multiplier +
|
", multiplier=" + multiplier +
|
||||||
", running=" + running +
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,14 @@ 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) {
|
||||||
|
|
@ -101,6 +108,11 @@ 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,6 +26,9 @@ 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("com.github.johnrengelman.shadow") version "7.1.0"
|
id("io.github.goooler.shadow") version "8.1.8"
|
||||||
}
|
}
|
||||||
|
|
||||||
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(17))
|
languageVersion.set(JavaLanguageVersion.of(21))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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-7.3.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-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("com.github.johnrengelman.shadow")
|
id("io.github.goooler.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.19.2-R0.1-SNAPSHOT")
|
compileOnly("com.alttd:Galaxy-API:1.21-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.1.206") {
|
compileOnly("com.gmail.nossr50.mcMMO:mcMMO:2.2.004") {
|
||||||
exclude("com.sk89q.worldguard")
|
exclude("com.sk89q.worldguard")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
plugins {
|
plugins {
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
id("com.github.johnrengelman.shadow")
|
id("io.github.goooler.shadow")
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user