mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-12-28 03:17:47 +01:00
Added updater.
This commit is contained in:
parent
2fdd6ee7ac
commit
edc0a48e3d
42
pom.xml
42
pom.xml
@ -17,26 +17,37 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>replacer</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>1.5.3</version>
|
<version>3.1.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>prepare-package</phase>
|
<id>shaded</id>
|
||||||
|
<phase>package</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>replace</goal>
|
<goal>shade</goal>
|
||||||
</goals>
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||||
|
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||||
|
<artifactSet>
|
||||||
|
<includes>
|
||||||
|
<include>com.songoda:songodaupdater</include>
|
||||||
|
</includes>
|
||||||
|
</artifactSet>
|
||||||
|
<filters>
|
||||||
|
<filter>
|
||||||
|
<artifact>*:*</artifact>
|
||||||
|
<excludes>
|
||||||
|
<exclude>META-INF/*.SF</exclude>
|
||||||
|
<exclude>META-INF/*.DSA</exclude>
|
||||||
|
<exclude>META-INF/*.RSA</exclude>
|
||||||
|
</excludes>
|
||||||
|
</filter>
|
||||||
|
</filters>
|
||||||
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
<configuration>
|
|
||||||
<file>${project.build.directory}/classes/plugin.yml</file>
|
|
||||||
<replacements>
|
|
||||||
<replacement>
|
|
||||||
<token>maven-version-number</token>
|
|
||||||
<value>${project.version}</value>
|
|
||||||
</replacement>
|
|
||||||
</replacements>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
@ -56,6 +67,9 @@
|
|||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.12.2</version>
|
<version>1.12.2</version>
|
||||||
|
<groupId>com.songoda</groupId>
|
||||||
|
<artifactId>songodaupdater</artifactId>
|
||||||
|
<version>1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.songoda</groupId>
|
<groupId>com.songoda</groupId>
|
||||||
|
@ -16,6 +16,9 @@ import com.songoda.ultimatestacker.storage.types.StorageYaml;
|
|||||||
import com.songoda.ultimatestacker.tasks.StackingTask;
|
import com.songoda.ultimatestacker.tasks.StackingTask;
|
||||||
import com.songoda.ultimatestacker.utils.*;
|
import com.songoda.ultimatestacker.utils.*;
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
|
import com.songoda.ultimatestacker.utils.updateModules.LocaleModule;
|
||||||
|
import com.songoda.update.Plugin;
|
||||||
|
import com.songoda.update.SongodaUpdate;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
@ -138,9 +141,10 @@ public class UltimateStacker extends JavaPlugin {
|
|||||||
Locale.saveDefaultLocale("en_US");
|
Locale.saveDefaultLocale("en_US");
|
||||||
this.locale = Locale.getLocale(getConfig().getString("System.Language Mode", langMode));
|
this.locale = Locale.getLocale(getConfig().getString("System.Language Mode", langMode));
|
||||||
|
|
||||||
if (getConfig().getBoolean("System.Download Needed Data Files")) {
|
//Running Songoda Updater
|
||||||
this.update();
|
Plugin plugin = new Plugin(this, 16);
|
||||||
}
|
plugin.addModule(new LocaleModule());
|
||||||
|
SongodaUpdate.load(plugin);
|
||||||
|
|
||||||
this.references = new References();
|
this.references = new References();
|
||||||
this.spawnerStackManager = new SpawnerStackManager();
|
this.spawnerStackManager = new SpawnerStackManager();
|
||||||
@ -212,39 +216,6 @@ public class UltimateStacker extends JavaPlugin {
|
|||||||
console.sendMessage(Methods.formatText("&a============================="));
|
console.sendMessage(Methods.formatText("&a============================="));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void update() {
|
|
||||||
try {
|
|
||||||
URL url = new URL("http://update.songoda.com/index.php?plugin=" + getDescription().getName() + "&version=" + getDescription().getVersion());
|
|
||||||
URLConnection urlConnection = url.openConnection();
|
|
||||||
InputStream is = urlConnection.getInputStream();
|
|
||||||
InputStreamReader isr = new InputStreamReader(is);
|
|
||||||
|
|
||||||
int numCharsRead;
|
|
||||||
char[] charArray = new char[1024];
|
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
while ((numCharsRead = isr.read(charArray)) > 0) {
|
|
||||||
sb.append(charArray, 0, numCharsRead);
|
|
||||||
}
|
|
||||||
String jsonString = sb.toString();
|
|
||||||
JSONObject json = (JSONObject) new JSONParser().parse(jsonString);
|
|
||||||
|
|
||||||
JSONArray files = (JSONArray) json.get("neededFiles");
|
|
||||||
for (Object o : files) {
|
|
||||||
JSONObject file = (JSONObject) o;
|
|
||||||
|
|
||||||
switch ((String) file.get("type")) {
|
|
||||||
case "locale":
|
|
||||||
InputStream in = new URL((String) file.get("link")).openStream();
|
|
||||||
Locale.saveDefaultLocale(in, (String) file.get("name"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.out.println("Failed to update.");
|
|
||||||
//e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkStorage() {
|
private void checkStorage() {
|
||||||
if (getConfig().getBoolean("Database.Activate Mysql Support")) {
|
if (getConfig().getBoolean("Database.Activate Mysql Support")) {
|
||||||
this.storage = new StorageMysql(this);
|
this.storage = new StorageMysql(this);
|
||||||
|
@ -190,7 +190,6 @@ public class SettingsManager implements Listener {
|
|||||||
DATABASE_USERNAME("Database.Username", "PUT_USERNAME_HERE"),
|
DATABASE_USERNAME("Database.Username", "PUT_USERNAME_HERE"),
|
||||||
DATABASE_PASSWORD("Database.Password", "PUT_PASSWORD_HERE"),
|
DATABASE_PASSWORD("Database.Password", "PUT_PASSWORD_HERE"),
|
||||||
|
|
||||||
DOWNLOAD_FILES("System.Download Needed Data Files", true),
|
|
||||||
LANGUGE_MODE("System.Language Mode", "en_US");
|
LANGUGE_MODE("System.Language Mode", "en_US");
|
||||||
|
|
||||||
private String setting;
|
private String setting;
|
||||||
|
Loading…
Reference in New Issue
Block a user