Merge branch 'master' into vertical-stargates
All checks were successful
EpicKnarvik97/Stargate/pipeline/head This commit looks good
All checks were successful
EpicKnarvik97/Stargate/pipeline/head This commit looks good
This commit is contained in:
commit
a1f25a794e
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@ -1,7 +1,7 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
tools {
|
tools {
|
||||||
jdk 'JDK16'
|
jdk 'JDK17'
|
||||||
}
|
}
|
||||||
stages {
|
stages {
|
||||||
stage('Build') {
|
stage('Build') {
|
||||||
|
17
README.md
17
README.md
@ -405,6 +405,23 @@ portalInfoServer=Server: %server%
|
|||||||
|
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
#### \[Version 0.9.4.2] EpicKnarvik97 fork
|
||||||
|
|
||||||
|
- Avoids a NullPointerException if Dynmap is present, but isn't properly loaded.
|
||||||
|
- Avoids some potential NullPointerExceptions related to Dynmap integration
|
||||||
|
- Fixes end portals hijacking BungeeCord teleportation
|
||||||
|
- Fixes a problem where a player might not be properly teleported from an end portal Stargate in the end to the
|
||||||
|
over-world.
|
||||||
|
|
||||||
|
#### \[Version 0.9.4.1] EpicKnarvik97 fork
|
||||||
|
|
||||||
|
- Reverts to Spigot API 1.18
|
||||||
|
- Adds Dynmap integration
|
||||||
|
|
||||||
|
#### \[Version 0.9.4.0] EpicKnarvik97 fork
|
||||||
|
|
||||||
|
- Updates Stargate to 1.19
|
||||||
|
|
||||||
#### \[Version 0.9.3.7] EpicKnarvik97 fork
|
#### \[Version 0.9.3.7] EpicKnarvik97 fork
|
||||||
|
|
||||||
- Adds the Japanese language file provided by spigot user furplag
|
- Adds the Japanese language file provided by spigot user furplag
|
||||||
|
77
pom.xml
77
pom.xml
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<groupId>net.knarcraft</groupId>
|
<groupId>net.knarcraft</groupId>
|
||||||
<artifactId>Stargate</artifactId>
|
<artifactId>Stargate</artifactId>
|
||||||
<version>0.9.4.1</version>
|
<version>0.9.4.2</version>
|
||||||
|
|
||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
@ -15,53 +15,62 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<java.version>16</java.version>
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>gitea</id>
|
||||||
|
<url>https://git.knarcraft.net/api/packages/EpicKnarvik97/maven</url>
|
||||||
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>vault-repo</id>
|
<id>vault-repo</id>
|
||||||
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
|
<url>https://nexus.hc.to/content/repositories/pub_releases</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>dynmap</id>
|
<id>dynmap</id>
|
||||||
<url>https://repo.mikeprimm.com/</url>
|
<url>https://repo.mikeprimm.com/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>papermc</id>
|
||||||
|
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.19-R0.1-SNAPSHOT</version>
|
<version>1.19.2-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.milkbowl.vault</groupId>
|
<groupId>net.milkbowl.vault</groupId>
|
||||||
<artifactId>VaultAPI</artifactId>
|
<artifactId>VaultAPI</artifactId>
|
||||||
<version>1.7</version>
|
<version>1.7</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter-api</artifactId>
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
<version>5.8.2</version>
|
<version>5.9.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.seeseemelk</groupId>
|
<groupId>com.github.seeseemelk</groupId>
|
||||||
<artifactId>MockBukkit-v1.18</artifactId>
|
<artifactId>MockBukkit-v1.18</artifactId>
|
||||||
<version>1.15.5</version>
|
<version>2.85.2</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains</groupId>
|
<groupId>org.jetbrains</groupId>
|
||||||
<artifactId>annotations</artifactId>
|
<artifactId>annotations</artifactId>
|
||||||
<version>22.0.0</version>
|
<version>23.0.0</version>
|
||||||
<scope>compile</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
@ -73,21 +82,63 @@
|
|||||||
<groupId>us.dynmap</groupId>
|
<groupId>us.dynmap</groupId>
|
||||||
<artifactId>dynmap-api</artifactId>
|
<artifactId>dynmap-api</artifactId>
|
||||||
<version>3.1-beta-2</version>
|
<version>3.1-beta-2</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.knarcraft</groupId>
|
||||||
|
<artifactId>knarlib</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src/main/java</sourceDirectory>
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.6.1</version>
|
<version>3.8.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>17</source>
|
<source>${java.version}</source>
|
||||||
<target>17</target>
|
<target>${java.version}</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.2.4</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||||
|
<filters>
|
||||||
|
<filter>
|
||||||
|
<artifact>net.knarcraft:knarlib</artifact>
|
||||||
|
<includes>
|
||||||
|
<include>net/knarcraft/knarlib/**</include>
|
||||||
|
</includes>
|
||||||
|
</filter>
|
||||||
|
<filter>
|
||||||
|
<excludes>
|
||||||
|
<exclude>*.MF</exclude>
|
||||||
|
<exclude>*.yml</exclude>
|
||||||
|
</excludes>
|
||||||
|
</filter>
|
||||||
|
</filters>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
@ -1,5 +1,6 @@
|
|||||||
package net.knarcraft.stargate;
|
package net.knarcraft.stargate;
|
||||||
|
|
||||||
|
import net.knarcraft.knarlib.util.UpdateChecker;
|
||||||
import net.knarcraft.stargate.command.CommandStarGate;
|
import net.knarcraft.stargate.command.CommandStarGate;
|
||||||
import net.knarcraft.stargate.command.StarGateTabCompleter;
|
import net.knarcraft.stargate.command.StarGateTabCompleter;
|
||||||
import net.knarcraft.stargate.config.EconomyConfig;
|
import net.knarcraft.stargate.config.EconomyConfig;
|
||||||
@ -22,7 +23,6 @@ import net.knarcraft.stargate.portal.PortalRegistry;
|
|||||||
import net.knarcraft.stargate.thread.BlockChangeThread;
|
import net.knarcraft.stargate.thread.BlockChangeThread;
|
||||||
import net.knarcraft.stargate.thread.ChunkUnloadThread;
|
import net.knarcraft.stargate.thread.ChunkUnloadThread;
|
||||||
import net.knarcraft.stargate.thread.StarGateThread;
|
import net.knarcraft.stargate.thread.StarGateThread;
|
||||||
import net.knarcraft.stargate.utility.UpdateChecker;
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
@ -299,24 +299,6 @@ public class Stargate extends JavaPlugin {
|
|||||||
return stargateConfig.getLanguageLoader().getBackupString(name);
|
return stargateConfig.getLanguageLoader().getBackupString(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Replaces a list of variables in a string in the order they are given
|
|
||||||
*
|
|
||||||
* @param input <p>The input containing the variables</p>
|
|
||||||
* @param search <p>The variables to replace</p>
|
|
||||||
* @param values <p>The replacement values</p>
|
|
||||||
* @return <p>The input string with the search values replaced with the given values</p>
|
|
||||||
*/
|
|
||||||
public static String replaceVars(String input, String[] search, String[] values) {
|
|
||||||
if (search.length != values.length) {
|
|
||||||
throw new IllegalArgumentException("The number of search values and replace values do not match.");
|
|
||||||
}
|
|
||||||
for (int i = 0; i < search.length; i++) {
|
|
||||||
input = replaceVars(input, search[i], values[i]);
|
|
||||||
}
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replaces a variable in a string
|
* Replaces a variable in a string
|
||||||
*
|
*
|
||||||
@ -383,7 +365,8 @@ public class Stargate extends JavaPlugin {
|
|||||||
this.registerCommands();
|
this.registerCommands();
|
||||||
|
|
||||||
//Check for any available updates
|
//Check for any available updates
|
||||||
UpdateChecker.checkForUpdate();
|
UpdateChecker.checkForUpdate(this, "https://api.spigotmc.org/legacy/update.php?resource=97784",
|
||||||
|
Stargate::getPluginVersion, Stargate::setUpdateAvailable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,6 +14,8 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static net.knarcraft.knarlib.util.TabCompletionHelper.filterMatchingStartsWith;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the completer for stargates config sub-command (/sg config)
|
* This is the completer for stargates config sub-command (/sg config)
|
||||||
*/
|
*/
|
||||||
@ -48,27 +50,10 @@ public class ConfigTabCompleter implements TabCompleter {
|
|||||||
for (ConfigOption option : ConfigOption.values()) {
|
for (ConfigOption option : ConfigOption.values()) {
|
||||||
configOptionNames.add(option.getName());
|
configOptionNames.add(option.getName());
|
||||||
}
|
}
|
||||||
return filterMatching(configOptionNames, args[0]);
|
return filterMatchingStartsWith(configOptionNames, args[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Find completable strings which match the text typed by the command's sender
|
|
||||||
*
|
|
||||||
* @param values <p>The values to filter</p>
|
|
||||||
* @param typedText <p>The text the player has started typing</p>
|
|
||||||
* @return <p>The given string values which start with the player's typed text</p>
|
|
||||||
*/
|
|
||||||
private List<String> filterMatching(List<String> values, String typedText) {
|
|
||||||
List<String> configValues = new ArrayList<>();
|
|
||||||
for (String value : values) {
|
|
||||||
if (value.toLowerCase().startsWith(typedText.toLowerCase())) {
|
|
||||||
configValues.add(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return configValues;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get possible values for the selected option
|
* Get possible values for the selected option
|
||||||
*
|
*
|
||||||
@ -80,7 +65,7 @@ public class ConfigTabCompleter implements TabCompleter {
|
|||||||
switch (selectedOption) {
|
switch (selectedOption) {
|
||||||
case LANGUAGE:
|
case LANGUAGE:
|
||||||
//Return available languages
|
//Return available languages
|
||||||
return filterMatching(languages, typedText);
|
return filterMatchingStartsWith(languages, typedText);
|
||||||
case GATE_FOLDER:
|
case GATE_FOLDER:
|
||||||
case PORTAL_FOLDER:
|
case PORTAL_FOLDER:
|
||||||
case DEFAULT_GATE_NETWORK:
|
case DEFAULT_GATE_NETWORK:
|
||||||
@ -94,12 +79,12 @@ public class ConfigTabCompleter implements TabCompleter {
|
|||||||
case HIGHLIGHT_SIGN_COLOR:
|
case HIGHLIGHT_SIGN_COLOR:
|
||||||
case FREE_GATES_COLOR:
|
case FREE_GATES_COLOR:
|
||||||
//Return all colors
|
//Return all colors
|
||||||
return filterMatching(chatColors, typedText);
|
return filterMatchingStartsWith(chatColors, typedText);
|
||||||
}
|
}
|
||||||
|
|
||||||
//If the config value is a boolean, show the two boolean values
|
//If the config value is a boolean, show the two boolean values
|
||||||
if (selectedOption.getDataType() == OptionDataType.BOOLEAN) {
|
if (selectedOption.getDataType() == OptionDataType.BOOLEAN) {
|
||||||
return filterMatching(booleans, typedText);
|
return filterMatchingStartsWith(booleans, typedText);
|
||||||
}
|
}
|
||||||
|
|
||||||
//If the config value is an integer, display some valid numbers
|
//If the config value is an integer, display some valid numbers
|
||||||
@ -145,11 +130,11 @@ public class ConfigTabCompleter implements TabCompleter {
|
|||||||
*/
|
*/
|
||||||
private List<String> getPerSignColorCompletion(String[] args) {
|
private List<String> getPerSignColorCompletion(String[] args) {
|
||||||
if (args.length < 3) {
|
if (args.length < 3) {
|
||||||
return filterMatching(signTypes, args[1]);
|
return filterMatchingStartsWith(signTypes, args[1]);
|
||||||
} else if (args.length < 4) {
|
} else if (args.length < 4) {
|
||||||
return filterMatching(extendedColors, args[2]);
|
return filterMatchingStartsWith(extendedColors, args[2]);
|
||||||
} else if (args.length < 5) {
|
} else if (args.length < 5) {
|
||||||
return filterMatching(extendedColors, args[3]);
|
return filterMatchingStartsWith(extendedColors, args[3]);
|
||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package net.knarcraft.stargate.config;
|
package net.knarcraft.stargate.config;
|
||||||
|
|
||||||
|
import net.knarcraft.knarlib.property.ColorConversion;
|
||||||
|
import net.knarcraft.knarlib.util.FileHelper;
|
||||||
import net.knarcraft.stargate.Stargate;
|
import net.knarcraft.stargate.Stargate;
|
||||||
import net.knarcraft.stargate.utility.FileHelper;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
@ -136,7 +137,8 @@ public final class LanguageLoader {
|
|||||||
String> currentLanguageValues) throws IOException {
|
String> currentLanguageValues) throws IOException {
|
||||||
//Get language values
|
//Get language values
|
||||||
BufferedReader bufferedReader = FileHelper.getBufferedReaderFromInputStream(inputStream);
|
BufferedReader bufferedReader = FileHelper.getBufferedReaderFromInputStream(inputStream);
|
||||||
Map<String, String> internalLanguageValues = FileHelper.readKeyValuePairs(bufferedReader);
|
Map<String, String> internalLanguageValues = FileHelper.readKeyValuePairs(bufferedReader, "=",
|
||||||
|
ColorConversion.NORMAL);
|
||||||
|
|
||||||
//If currentLanguageValues is null; the chosen language has not been used before
|
//If currentLanguageValues is null; the chosen language has not been used before
|
||||||
if (currentLanguageValues == null) {
|
if (currentLanguageValues == null) {
|
||||||
@ -221,7 +223,7 @@ public final class LanguageLoader {
|
|||||||
} else {
|
} else {
|
||||||
bufferedReader = FileHelper.getBufferedReaderFromInputStream(inputStream);
|
bufferedReader = FileHelper.getBufferedReaderFromInputStream(inputStream);
|
||||||
}
|
}
|
||||||
strings = FileHelper.readKeyValuePairs(bufferedReader);
|
strings = FileHelper.readKeyValuePairs(bufferedReader, "=", ColorConversion.NORMAL);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (Stargate.getStargateConfig().isDebuggingEnabled()) {
|
if (Stargate.getStargateConfig().isDebuggingEnabled()) {
|
||||||
Stargate.getConsoleLogger().info("[Stargate] Unable to load language " + lang);
|
Stargate.getConsoleLogger().info("[Stargate] Unable to load language " + lang);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package net.knarcraft.stargate.config;
|
package net.knarcraft.stargate.config;
|
||||||
|
|
||||||
|
import net.knarcraft.knarlib.property.ColorConversion;
|
||||||
|
import net.knarcraft.knarlib.util.FileHelper;
|
||||||
import net.knarcraft.stargate.Stargate;
|
import net.knarcraft.stargate.Stargate;
|
||||||
import net.knarcraft.stargate.container.BlockChangeRequest;
|
import net.knarcraft.stargate.container.BlockChangeRequest;
|
||||||
import net.knarcraft.stargate.listener.BungeeCordListener;
|
import net.knarcraft.stargate.listener.BungeeCordListener;
|
||||||
@ -8,7 +10,6 @@ import net.knarcraft.stargate.portal.PortalHandler;
|
|||||||
import net.knarcraft.stargate.portal.PortalRegistry;
|
import net.knarcraft.stargate.portal.PortalRegistry;
|
||||||
import net.knarcraft.stargate.portal.property.gate.GateHandler;
|
import net.knarcraft.stargate.portal.property.gate.GateHandler;
|
||||||
import net.knarcraft.stargate.thread.BlockChangeThread;
|
import net.knarcraft.stargate.thread.BlockChangeThread;
|
||||||
import net.knarcraft.stargate.utility.FileHelper;
|
|
||||||
import net.knarcraft.stargate.utility.PortalFileHelper;
|
import net.knarcraft.stargate.utility.PortalFileHelper;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -448,7 +449,8 @@ public final class StargateConfig {
|
|||||||
Map<String, String> migrationFields;
|
Map<String, String> migrationFields;
|
||||||
try {
|
try {
|
||||||
migrationFields = FileHelper.readKeyValuePairs(FileHelper.getBufferedReaderFromInputStream(
|
migrationFields = FileHelper.readKeyValuePairs(FileHelper.getBufferedReaderFromInputStream(
|
||||||
FileHelper.getInputStreamForInternalFile("/config-migrations.txt")));
|
FileHelper.getInputStreamForInternalFile("/config-migrations.txt")), "=",
|
||||||
|
ColorConversion.NORMAL);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Stargate.debug("Stargate::migrateConfig", "Unable to load config migration file");
|
Stargate.debug("Stargate::migrateConfig", "Unable to load config migration file");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package net.knarcraft.stargate.config;
|
package net.knarcraft.stargate.config;
|
||||||
|
|
||||||
|
import net.knarcraft.knarlib.util.ColorHelper;
|
||||||
import net.knarcraft.stargate.Stargate;
|
import net.knarcraft.stargate.Stargate;
|
||||||
import net.knarcraft.stargate.portal.PortalSignDrawer;
|
import net.knarcraft.stargate.portal.PortalSignDrawer;
|
||||||
import net.knarcraft.stargate.utility.ColorHelper;
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package net.knarcraft.stargate.container;
|
package net.knarcraft.stargate.container;
|
||||||
|
|
||||||
import net.knarcraft.stargate.utility.ColorHelper;
|
import net.knarcraft.knarlib.util.ColorHelper;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.knarcraft.stargate.listener;
|
package net.knarcraft.stargate.listener;
|
||||||
|
|
||||||
|
import net.knarcraft.knarlib.util.UpdateChecker;
|
||||||
import net.knarcraft.stargate.Stargate;
|
import net.knarcraft.stargate.Stargate;
|
||||||
import net.knarcraft.stargate.config.MessageSender;
|
import net.knarcraft.stargate.config.MessageSender;
|
||||||
import net.knarcraft.stargate.container.BlockLocation;
|
import net.knarcraft.stargate.container.BlockLocation;
|
||||||
@ -13,7 +14,6 @@ import net.knarcraft.stargate.utility.MaterialHelper;
|
|||||||
import net.knarcraft.stargate.utility.PermissionHelper;
|
import net.knarcraft.stargate.utility.PermissionHelper;
|
||||||
import net.knarcraft.stargate.utility.TeleportHelper;
|
import net.knarcraft.stargate.utility.TeleportHelper;
|
||||||
import net.knarcraft.stargate.utility.UUIDMigrationHelper;
|
import net.knarcraft.stargate.utility.UUIDMigrationHelper;
|
||||||
import net.knarcraft.stargate.utility.UpdateChecker;
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package net.knarcraft.stargate.portal;
|
package net.knarcraft.stargate.portal;
|
||||||
|
|
||||||
|
import net.knarcraft.knarlib.property.ColorConversion;
|
||||||
|
import net.knarcraft.knarlib.util.ColorHelper;
|
||||||
import net.knarcraft.stargate.Stargate;
|
import net.knarcraft.stargate.Stargate;
|
||||||
import net.knarcraft.stargate.container.SignData;
|
import net.knarcraft.stargate.container.SignData;
|
||||||
import net.knarcraft.stargate.portal.property.PortalLocation;
|
import net.knarcraft.stargate.portal.property.PortalLocation;
|
||||||
@ -12,8 +14,6 @@ import org.bukkit.block.Sign;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static net.knarcraft.stargate.utility.ColorHelper.translateAllColorCodes;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The portal sign drawer draws the sing of a given portal
|
* The portal sign drawer draws the sing of a given portal
|
||||||
*/
|
*/
|
||||||
@ -393,4 +393,14 @@ public class PortalSignDrawer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Translates all normal and RGB color codes in the given input
|
||||||
|
*
|
||||||
|
* @param input <p>The input to translate color codes for</p>
|
||||||
|
* @return <p>The input with color codes converted translated from & to §</p>
|
||||||
|
*/
|
||||||
|
private String translateAllColorCodes(String input) {
|
||||||
|
return ColorHelper.translateColorCodes(input, ColorConversion.RGB);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ public class VehicleTeleporter extends EntityTeleporter {
|
|||||||
//Spawn a new vehicle
|
//Spawn a new vehicle
|
||||||
Vehicle newVehicle = vehicleWorld.spawn(exit, teleportingVehicle.getClass());
|
Vehicle newVehicle = vehicleWorld.spawn(exit, teleportingVehicle.getClass());
|
||||||
if (teleportingVehicle instanceof Boat boat) {
|
if (teleportingVehicle instanceof Boat boat) {
|
||||||
((Boat) newVehicle).setWoodType(boat.getWoodType());
|
((Boat) newVehicle).setBoatType(boat.getBoatType());
|
||||||
}
|
}
|
||||||
//Remove the old vehicle
|
//Remove the old vehicle
|
||||||
if (teleportingVehicle.eject()) {
|
if (teleportingVehicle.eject()) {
|
||||||
|
@ -1,54 +0,0 @@
|
|||||||
package net.knarcraft.stargate.utility;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import org.bukkit.Color;
|
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A helper class for dealing with colors
|
|
||||||
*/
|
|
||||||
public final class ColorHelper {
|
|
||||||
|
|
||||||
private ColorHelper() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Inverts the given color
|
|
||||||
*
|
|
||||||
* @param color <p>The color to invert</p>
|
|
||||||
* @return <p>The inverted color</p>
|
|
||||||
*/
|
|
||||||
public static Color invert(Color color) {
|
|
||||||
return color.setRed(255 - color.getRed()).setGreen(255 - color.getGreen()).setBlue(255 - color.getBlue());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the chat color corresponding to the given color
|
|
||||||
*
|
|
||||||
* @param color <p>The color to convert into a chat color</p>
|
|
||||||
* @return <p>The resulting chat color</p>
|
|
||||||
*/
|
|
||||||
public static ChatColor fromColor(Color color) {
|
|
||||||
return ChatColor.of(String.format("#%02X%02X%02X", color.getRed(), color.getGreen(), color.getBlue()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Translates all found color codes to formatting in a string
|
|
||||||
*
|
|
||||||
* @param message <p>The string to search for color codes</p>
|
|
||||||
* @return <p>The message with color codes translated</p>
|
|
||||||
*/
|
|
||||||
public static String translateAllColorCodes(String message) {
|
|
||||||
message = ChatColor.translateAlternateColorCodes('&', message);
|
|
||||||
Pattern pattern = Pattern.compile("(#[a-fA-F0-9]{6})");
|
|
||||||
Matcher matcher = pattern.matcher(message);
|
|
||||||
while (matcher.find()) {
|
|
||||||
message = message.replace(matcher.group(), "" + ChatColor.of(matcher.group()));
|
|
||||||
}
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,5 +1,6 @@
|
|||||||
package net.knarcraft.stargate.utility;
|
package net.knarcraft.stargate.utility;
|
||||||
|
|
||||||
|
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||||
import net.knarcraft.stargate.Stargate;
|
import net.knarcraft.stargate.Stargate;
|
||||||
import net.knarcraft.stargate.config.EconomyConfig;
|
import net.knarcraft.stargate.config.EconomyConfig;
|
||||||
import net.knarcraft.stargate.portal.Portal;
|
import net.knarcraft.stargate.portal.Portal;
|
||||||
@ -78,7 +79,7 @@ public final class EconomyHelper {
|
|||||||
*/
|
*/
|
||||||
public static void sendObtainMessage(String portalName, Player portalOwner, int earnings) {
|
public static void sendObtainMessage(String portalName, Player portalOwner, int earnings) {
|
||||||
String obtainedMsg = Stargate.getString("ecoObtain");
|
String obtainedMsg = Stargate.getString("ecoObtain");
|
||||||
obtainedMsg = replaceVars(obtainedMsg, portalName, earnings);
|
obtainedMsg = replacePlaceholders(obtainedMsg, portalName, earnings);
|
||||||
Stargate.getMessageSender().sendSuccessMessage(portalOwner, obtainedMsg);
|
Stargate.getMessageSender().sendSuccessMessage(portalOwner, obtainedMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +92,7 @@ public final class EconomyHelper {
|
|||||||
*/
|
*/
|
||||||
public static void sendDeductMessage(String portalName, Player player, int cost) {
|
public static void sendDeductMessage(String portalName, Player player, int cost) {
|
||||||
String deductMsg = Stargate.getString("ecoDeduct");
|
String deductMsg = Stargate.getString("ecoDeduct");
|
||||||
deductMsg = replaceVars(deductMsg, portalName, cost);
|
deductMsg = replacePlaceholders(deductMsg, portalName, cost);
|
||||||
Stargate.getMessageSender().sendSuccessMessage(player, deductMsg);
|
Stargate.getMessageSender().sendSuccessMessage(player, deductMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +105,7 @@ public final class EconomyHelper {
|
|||||||
*/
|
*/
|
||||||
public static void sendInsufficientFundsMessage(String portalName, Player player, int cost) {
|
public static void sendInsufficientFundsMessage(String portalName, Player player, int cost) {
|
||||||
String inFundMsg = Stargate.getString("ecoInFunds");
|
String inFundMsg = Stargate.getString("ecoInFunds");
|
||||||
inFundMsg = replaceVars(inFundMsg, portalName, cost);
|
inFundMsg = replacePlaceholders(inFundMsg, portalName, cost);
|
||||||
Stargate.getMessageSender().sendErrorMessage(player, inFundMsg);
|
Stargate.getMessageSender().sendErrorMessage(player, inFundMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +118,7 @@ public final class EconomyHelper {
|
|||||||
*/
|
*/
|
||||||
public static void sendRefundMessage(String portalName, Player player, int cost) {
|
public static void sendRefundMessage(String portalName, Player player, int cost) {
|
||||||
String refundMsg = Stargate.getString("ecoRefund");
|
String refundMsg = Stargate.getString("ecoRefund");
|
||||||
refundMsg = replaceVars(refundMsg, portalName, -cost);
|
refundMsg = replacePlaceholders(refundMsg, portalName, -cost);
|
||||||
Stargate.getMessageSender().sendSuccessMessage(player, refundMsg);
|
Stargate.getMessageSender().sendSuccessMessage(player, refundMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,8 +240,8 @@ public final class EconomyHelper {
|
|||||||
* @param cost <p>The cost for a given interaction</p>
|
* @param cost <p>The cost for a given interaction</p>
|
||||||
* @return <p>The same string with cost and portal variables replaced</p>
|
* @return <p>The same string with cost and portal variables replaced</p>
|
||||||
*/
|
*/
|
||||||
private static String replaceVars(String message, String portalName, int cost) {
|
private static String replacePlaceholders(String message, String portalName, int cost) {
|
||||||
return Stargate.replaceVars(message, new String[]{"%cost%", "%portal%"},
|
return StringFormatter.replacePlaceholders(message, new String[]{"%cost%", "%portal%"},
|
||||||
new String[]{Stargate.getEconomyConfig().format(cost), portalName});
|
new String[]{Stargate.getEconomyConfig().format(cost), portalName});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,127 +0,0 @@
|
|||||||
package net.knarcraft.stargate.utility;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper class for reading files
|
|
||||||
*/
|
|
||||||
public final class FileHelper {
|
|
||||||
|
|
||||||
private FileHelper() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets an input stream from a string pointing to an internal file
|
|
||||||
*
|
|
||||||
* <p>This is used for getting an input stream for reading a file contained within the compiled .jar file. The file
|
|
||||||
* should be in the resources directory, and the file path should start with a forward slash ("/") character.</p>
|
|
||||||
*
|
|
||||||
* @param file <p>The file to read</p>
|
|
||||||
* @return <p>An input stream for the file</p>
|
|
||||||
*/
|
|
||||||
public static InputStream getInputStreamForInternalFile(String file) {
|
|
||||||
return FileHelper.class.getResourceAsStream(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a buffered reader from a string pointing to a file
|
|
||||||
*
|
|
||||||
* @param file <p>The file to read</p>
|
|
||||||
* @return <p>A buffered reader reading the file</p>
|
|
||||||
* @throws FileNotFoundException <p>If the given file does not exist</p>
|
|
||||||
*/
|
|
||||||
public static BufferedReader getBufferedReaderFromString(String file) throws FileNotFoundException {
|
|
||||||
FileInputStream fileInputStream = new FileInputStream(file);
|
|
||||||
return getBufferedReaderFromInputStream(fileInputStream);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a buffered reader given an input stream
|
|
||||||
*
|
|
||||||
* @param inputStream <p>The input stream to read</p>
|
|
||||||
* @return <p>A buffered reader reading the input stream</p>
|
|
||||||
*/
|
|
||||||
public static BufferedReader getBufferedReaderFromInputStream(InputStream inputStream) {
|
|
||||||
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
|
|
||||||
return new BufferedReader(inputStreamReader);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a buffered writer from a string pointing to a file
|
|
||||||
*
|
|
||||||
* @param file <p>The file to write to</p>
|
|
||||||
* @return <p>A buffered writer writing to the file</p>
|
|
||||||
* @throws FileNotFoundException <p>If the file does not exist</p>
|
|
||||||
*/
|
|
||||||
public static BufferedWriter getBufferedWriterFromString(String file) throws FileNotFoundException {
|
|
||||||
FileOutputStream fileOutputStream = new FileOutputStream(file);
|
|
||||||
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, StandardCharsets.UTF_8);
|
|
||||||
return new BufferedWriter(outputStreamWriter);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads key/value pairs from an input stream
|
|
||||||
*
|
|
||||||
* @param bufferedReader <p>The buffered reader to read</p>
|
|
||||||
* @return <p>A map containing the read pairs</p>
|
|
||||||
* @throws IOException <p>If unable to read from the stream</p>
|
|
||||||
*/
|
|
||||||
public static Map<String, String> readKeyValuePairs(BufferedReader bufferedReader) throws IOException {
|
|
||||||
Map<String, String> readPairs = new HashMap<>();
|
|
||||||
|
|
||||||
String line = bufferedReader.readLine();
|
|
||||||
boolean firstLine = true;
|
|
||||||
while (line != null) {
|
|
||||||
//Strip UTF BOM from the first line
|
|
||||||
if (firstLine) {
|
|
||||||
line = removeUTF8BOM(line);
|
|
||||||
firstLine = false;
|
|
||||||
}
|
|
||||||
//Split at first "="
|
|
||||||
int equalSignIndex = line.indexOf('=');
|
|
||||||
if (equalSignIndex == -1) {
|
|
||||||
line = bufferedReader.readLine();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Read the line
|
|
||||||
String key = line.substring(0, equalSignIndex);
|
|
||||||
String value = ChatColor.translateAlternateColorCodes('&', line.substring(equalSignIndex + 1));
|
|
||||||
readPairs.put(key, value);
|
|
||||||
|
|
||||||
line = bufferedReader.readLine();
|
|
||||||
}
|
|
||||||
bufferedReader.close();
|
|
||||||
|
|
||||||
return readPairs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the UTF-8 Byte Order Mark if present
|
|
||||||
*
|
|
||||||
* @param string <p>The string to remove the BOM from</p>
|
|
||||||
* @return <p>A string guaranteed without a BOM</p>
|
|
||||||
*/
|
|
||||||
private static String removeUTF8BOM(String string) {
|
|
||||||
String UTF8_BOM = "\uFEFF";
|
|
||||||
if (string.startsWith(UTF8_BOM)) {
|
|
||||||
string = string.substring(1);
|
|
||||||
}
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,87 +0,0 @@
|
|||||||
package net.knarcraft.stargate.utility;
|
|
||||||
|
|
||||||
import net.knarcraft.stargate.Stargate;
|
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The update checker is responsible for looking for new updates
|
|
||||||
*/
|
|
||||||
public final class UpdateChecker {
|
|
||||||
|
|
||||||
private final static String APIResourceURL = "https://api.spigotmc.org/legacy/update.php?resource=97784";
|
|
||||||
private final static String updateNotice = "A new update is available: %s (You are still on %s)";
|
|
||||||
|
|
||||||
private UpdateChecker() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if there's a new update available, and alerts the user if necessary
|
|
||||||
*/
|
|
||||||
public static void checkForUpdate() {
|
|
||||||
BukkitScheduler scheduler = Stargate.getInstance().getServer().getScheduler();
|
|
||||||
scheduler.runTaskAsynchronously(Stargate.getInstance(), UpdateChecker::queryAPI);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Queries the spigot API to check for a newer version, and informs the user
|
|
||||||
*/
|
|
||||||
private static void queryAPI() {
|
|
||||||
try {
|
|
||||||
InputStream inputStream = new URL(APIResourceURL).openStream();
|
|
||||||
BufferedReader reader = FileHelper.getBufferedReaderFromInputStream(inputStream);
|
|
||||||
//There should only be one line of output
|
|
||||||
String newVersion = reader.readLine();
|
|
||||||
reader.close();
|
|
||||||
|
|
||||||
String oldVersion = Stargate.getPluginVersion();
|
|
||||||
//If there is a newer version, notify the user
|
|
||||||
if (isVersionHigher(oldVersion, newVersion)) {
|
|
||||||
Stargate.getConsoleLogger().log(Level.INFO, Stargate.getBackupString("prefix") +
|
|
||||||
getUpdateAvailableString(newVersion, oldVersion));
|
|
||||||
Stargate.setUpdateAvailable(newVersion);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
Stargate.debug("UpdateChecker", "Unable to get newest version.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the string to display to a user to alert about a new update
|
|
||||||
*
|
|
||||||
* @param newVersion <p>The new available plugin version</p>
|
|
||||||
* @param oldVersion <p>The old (current) plugin version</p>
|
|
||||||
* @return <p>The string to display</p>
|
|
||||||
*/
|
|
||||||
public static String getUpdateAvailableString(String newVersion, String oldVersion) {
|
|
||||||
return String.format(updateNotice, newVersion, oldVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decides whether one version number is higher than another
|
|
||||||
*
|
|
||||||
* @param oldVersion <p>The old version to check</p>
|
|
||||||
* @param newVersion <p>The new version to check</p>
|
|
||||||
* @return <p>True if the new version is higher than the old one</p>
|
|
||||||
*/
|
|
||||||
public static boolean isVersionHigher(String oldVersion, String newVersion) {
|
|
||||||
String[] oldVersionParts = oldVersion.split("\\.");
|
|
||||||
String[] newVersionParts = newVersion.split("\\.");
|
|
||||||
int versionLength = Math.max(oldVersionParts.length, newVersionParts.length);
|
|
||||||
for (int i = 0; i < versionLength; i++) {
|
|
||||||
int oldVersionNumber = oldVersionParts.length > i ? Integer.parseInt(oldVersionParts[i]) : 0;
|
|
||||||
int newVersionNumber = newVersionParts.length > i ? Integer.parseInt(newVersionParts[i]) : 0;
|
|
||||||
if (newVersionNumber != oldVersionNumber) {
|
|
||||||
return newVersionNumber > oldVersionNumber;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
name: Stargate
|
name: Stargate
|
||||||
main: net.knarcraft.stargate.Stargate
|
main: net.knarcraft.stargate.Stargate
|
||||||
version: 0.9.4.1
|
version: '${project.version}'
|
||||||
description: Stargate mod for Bukkit Revived
|
description: Stargate mod for Bukkit Revived
|
||||||
author: EpicKnarvik97
|
author: EpicKnarvik97
|
||||||
authors: [ Drakia, PseudoKnight, EpicKnarvik97 ]
|
authors: [ Drakia, PseudoKnight, EpicKnarvik97 ]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user