mirror of
https://github.com/JEFF-Media-GbR/ChestSort.git
synced 2024-11-26 12:35:54 +01:00
9.0.0-SNAPSHOT1
This commit is contained in:
parent
083d47431c
commit
efb2388cd8
@ -1,4 +1,8 @@
|
||||
# Changelog
|
||||
## 9.0.0-SNAPSHOT1
|
||||
- Using new universal Update (https://github.com/JEFF-Media-GbR/Spigot-UpdateChecker)
|
||||
- TODO: InvUnload integration (see TODO.md)
|
||||
|
||||
## 8.10.5
|
||||
- Added reload command (/chestsort reload) with permission chestsort.reload
|
||||
- ChestSort checks if Minepacks version is recent enough and, if not, disable the Minepacks hook.
|
||||
|
4
TODO.md
4
TODO.md
@ -1,6 +1,6 @@
|
||||
# Todo
|
||||
## Minepacks API check
|
||||
When using Minepacks, check if version is 2.3.8 or later and otherwise disable the hook
|
||||
## InvUnload integration
|
||||
Use InvUnload API to only put matching stuff into the chest when using left-click hotkey. On second click, everything is put into the chest.
|
||||
|
||||
## StackableItems
|
||||
Make it configurable whether ItemStacks > 64 items will stay unsorted, or sorted and reverted back to stacks of 64 items
|
||||
|
17
pom.xml
17
pom.xml
@ -9,7 +9,7 @@
|
||||
<name>JeffChestSort</name>
|
||||
<url>https://www.chestsort.de</url>
|
||||
<description>Automatically sorts your chests!</description>
|
||||
<version>8.10.5</version>
|
||||
<version>9.0.0-SNAPSHOT1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
@ -87,6 +87,10 @@
|
||||
<id>pcgf-repo</id>
|
||||
<url>https://repo.pcgamingfreaks.at/repository/maven-everything</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jeff-media-gbr</id>
|
||||
<url>https://repo.jeff-media.de/maven2</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
@ -114,6 +118,17 @@
|
||||
<artifactId>Minepacks-API</artifactId>
|
||||
<version>2.3.8</version><!-- Check api-version shield for newest version -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.jeff_media</groupId>
|
||||
<artifactId>PluginUpdateChecker</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.jeff_media</groupId>
|
||||
<artifactId>InvUnload</artifactId>
|
||||
<version>4.2.0-SNAPSHOT3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<distributionManagement>
|
||||
|
@ -42,6 +42,7 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import de.jeff_media.PluginUpdateChecker.PluginUpdateChecker;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@ -60,8 +61,7 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
Map<String, ChestSortPlayerSetting> perPlayerSettings = new HashMap<String, ChestSortPlayerSetting>();
|
||||
ChestSortMessages messages;
|
||||
ChestSortOrganizer organizer;
|
||||
ChestSortUpdateChecker updateChecker;
|
||||
Integer updateCheckerTask;
|
||||
PluginUpdateChecker updateChecker;
|
||||
ChestSortListener listener;
|
||||
ChestSortSettingsGUI settingsGUI;
|
||||
ChestSortPermissionsHandler permissionsHandler;
|
||||
@ -417,8 +417,8 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
if(reload) {
|
||||
unregisterAllPlayers();
|
||||
reloadConfig();
|
||||
if(updateCheckerTask != null) {
|
||||
getServer().getScheduler().cancelTask(updateCheckerTask);
|
||||
if(updateChecker != null) {
|
||||
updateChecker.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@ -448,7 +448,7 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
messages = new ChestSortMessages(this);
|
||||
organizer = new ChestSortOrganizer(this);
|
||||
settingsGUI = new ChestSortSettingsGUI(this);
|
||||
updateChecker = new ChestSortUpdateChecker(this);
|
||||
updateChecker = new PluginUpdateChecker(this, "https://api.jeff-media.de/chestsort/chestsort-latest-version.txt", "https://chestsort.de", "https://chestsort.de/changelog", "https://chestsort.de/donate");
|
||||
listener = new ChestSortListener(this);
|
||||
api = new ChestSortAPI(this);
|
||||
permissionsHandler = new ChestSortPermissionsHandler(this);
|
||||
@ -491,16 +491,10 @@ public class ChestSortPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
if (getConfig().getString("check-for-updates", "true").equalsIgnoreCase("true")) {
|
||||
updateCheckerTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateChecker.checkForUpdate();
|
||||
}
|
||||
}, 0L, updateCheckInterval * 20);
|
||||
|
||||
updateChecker.check(updateCheckInterval);
|
||||
} // When set to on-startup, we check right now (delay 0)
|
||||
else if (getConfig().getString("check-for-updates", "true").equalsIgnoreCase("on-startup")) {
|
||||
updateChecker.checkForUpdate();
|
||||
updateChecker.check();
|
||||
}
|
||||
|
||||
registerMetrics();
|
||||
|
@ -1,122 +0,0 @@
|
||||
package de.jeff_media.ChestSort;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
public class ChestSortUpdateChecker {
|
||||
|
||||
// This checks for updates. A txt file is downloaded. If the txt file contains a
|
||||
// string that is unequal to the currently used plugin's version, a message is
|
||||
// printed in the console.
|
||||
// The listener will also ensure that OPs will be notified on join. When the
|
||||
// update checker could not complete the request, e.g. when the JEFF
|
||||
// Media GbR API server is offline, or if you have no internet connection, a
|
||||
// warning will be printed in the console.
|
||||
|
||||
private ChestSortPlugin plugin;
|
||||
|
||||
ChestSortUpdateChecker(ChestSortPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
// This text file always contains a string with the latest version, e.g. 3.7.1
|
||||
final static String latestVersionLink = "https://api.jeff-media.de/chestsort/chestsort-latest-version.txt";
|
||||
final static String downloadLink = "https://chestsort.de/download";
|
||||
final static String changelogLink = "https://chestsort.de/changelog";
|
||||
final static String donateLink = "https://chestsort.de/donate";
|
||||
|
||||
private String currentVersion = "undefined";
|
||||
private String latestVersion = "undefined";
|
||||
|
||||
private TextComponent createLink(String text, String link, net.md_5.bungee.api.ChatColor color) {
|
||||
// Hover text
|
||||
ComponentBuilder hoverCB = new ComponentBuilder(
|
||||
text+" Link: ").bold(true)
|
||||
.append(link).bold(false);
|
||||
|
||||
TextComponent tc = new TextComponent(text);
|
||||
tc.setBold(true);
|
||||
tc.setColor(color);
|
||||
tc.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL,link));
|
||||
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,hoverCB.create()));
|
||||
return tc;
|
||||
}
|
||||
|
||||
private void sendLinks(Player p) {
|
||||
TextComponent text = new TextComponent("");
|
||||
|
||||
TextComponent download = createLink("Download",downloadLink,net.md_5.bungee.api.ChatColor.GOLD);
|
||||
TextComponent donate = createLink("Donate",donateLink,net.md_5.bungee.api.ChatColor.GOLD);
|
||||
TextComponent changelog = createLink("Changelog",changelogLink,net.md_5.bungee.api.ChatColor.GOLD);
|
||||
|
||||
TextComponent placeholder = new TextComponent(" | ");
|
||||
placeholder.setColor(net.md_5.bungee.api.ChatColor.GRAY);
|
||||
|
||||
text.addExtra(download);
|
||||
text.addExtra(placeholder);
|
||||
text.addExtra(donate);
|
||||
text.addExtra(placeholder);
|
||||
text.addExtra(changelog);
|
||||
|
||||
p.spigot().sendMessage(text);
|
||||
}
|
||||
|
||||
void sendUpdateMessage(Player p) {
|
||||
if (!latestVersion.equals("undefined")) {
|
||||
if (!currentVersion.equals(latestVersion)) {
|
||||
p.sendMessage(ChatColor.GRAY + "There is a new version of " + ChatColor.GOLD + "ChestSort"
|
||||
+ ChatColor.GRAY + " available.");
|
||||
sendLinks(p);
|
||||
p.sendMessage(ChatColor.DARK_GRAY + "Your version: "+currentVersion + " | Latest version: "+ latestVersion);
|
||||
p.sendMessage("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void checkForUpdate() {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
String userAgent = "ChestSort/"+plugin.getDescription().getVersion()+" (MC "+plugin.mcVersion+", "+plugin.getServer().getOnlinePlayers().size()+"/"+plugin.getServer().getOfflinePlayers().length+")";
|
||||
HttpURLConnection httpcon = (HttpURLConnection) new URL(latestVersionLink).openConnection();
|
||||
httpcon.addRequestProperty("User-Agent", userAgent);
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(httpcon.getInputStream()));
|
||||
String inputLine = reader.readLine().trim();
|
||||
latestVersion = inputLine;
|
||||
currentVersion = plugin.getDescription().getVersion().trim();
|
||||
|
||||
if (latestVersion.equals(currentVersion)) {
|
||||
plugin.getLogger().info("You are using the latest version of ChestSort.");
|
||||
} else {
|
||||
plugin.getLogger().warning("=================================================");
|
||||
plugin.getLogger().warning("There is a new version of ChestSort available!");
|
||||
plugin.getLogger().warning("Latest : " + inputLine);
|
||||
plugin.getLogger().warning("Current: " + currentVersion);
|
||||
plugin.getLogger().warning("Please update to the newest version. Download:");
|
||||
plugin.getLogger().warning(downloadLink);
|
||||
plugin.getLogger().warning("=================================================");
|
||||
}
|
||||
reader.close();
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().warning("Could not check for updates.");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
main: de.jeff_media.ChestSort.ChestSortPlugin
|
||||
name: ChestSort
|
||||
version: 8.10.5
|
||||
version: 9.0.0-SNAPSHOT1
|
||||
api-version: 1.13
|
||||
description: Allows automatic chest sorting
|
||||
author: mfnalex
|
||||
|
Loading…
Reference in New Issue
Block a user