Move recent changes into 1 branch

This commit is contained in:
NotMyFault
2020-02-16 15:17:06 +01:00
13 changed files with 98 additions and 336 deletions

View File

@ -22,7 +22,6 @@ dependencies {
implementation("org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT")
compile(group: "com.sk89q.worldedit", name: "worldedit-bukkit", version: "7.0.1")
compile("io.papermc:paperlib:1.0.2")
compile(group: "com.squareup.retrofit2", name: "retrofit", version: "2.4.0")
implementation("net.kyori:text-adapter-bukkit:3.0.3")
compile("com.github.MilkBowl:VaultAPI:1.7") {
exclude(module: "bukkit")
@ -79,12 +78,6 @@ task copyFiles {
shadowJar {
dependencies {
include(dependency(":Core"))
// update notification stuff
include(dependency("com.github.Sauilitired:Jenkins4J:2.0-SNAPSHOT"))
include(dependency("com.squareup.retrofit2:retrofit:2.4.0"))
include(dependency("com.squareup.okhttp3:okhttp:4.2.2"))
include(dependency("com.squareup.okio:okio:2.4.1"))
include(dependency("org.jetbrains.kotlin:kotlin-stdlib:1.3.61"))
include(dependency("io.papermc:paperlib:1.0.2"))
include(dependency("net.kyori:text-adapter-bukkit:3.0.3"))
}

View File

@ -60,7 +60,7 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandlerImplementation;
import com.github.intellectualsites.plotsquared.plot.util.UpdateUtility;
import com.github.intellectualsites.plotsquared.bukkit.util.UpdateUtility;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider;
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
@ -161,37 +161,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
return;
}
// Check for updates
if (PlotSquared.get().getUpdateUtility() != null) {
final UpdateUtility updateUtility = PlotSquared.get().getUpdateUtility();
updateUtility.checkForUpdate(PlotSquared.get().getVersion().versionString(),
((updateDescription, throwable) -> {
Bukkit.getScheduler().runTask(BukkitMain.this, () -> {
getLogger().info("-------- PlotSquared Update Check --------");
if (throwable != null) {
getLogger().severe(String
.format("Could not check for updates. Reason: %s",
throwable.getMessage()));
} else {
if (updateDescription == null) {
getLogger().info(
"You appear to be running the latest version of PlotSquared. Congratulations!");
} else {
getLogger()
.info("There appears to be a PlotSquared update available!");
getLogger().info(String.format(
"You are running version %s, the newest available version is %s",
getPluginVersionString(), updateDescription.getVersion()));
getLogger().info(
String.format("Update URL: %s", updateDescription.getUrl()));
}
}
getLogger().info("-------- PlotSquared Update Check --------");
});
}));
} else {
getLogger().warning("Update checking disabled. Skipping.");
}
new UpdateUtility(this).updateChecker();
this.startMetrics();
if (Settings.Enabled_Components.WORLDS) {

View File

@ -1,25 +1,16 @@
package com.github.intellectualsites.plotsquared.bukkit.listeners;
import com.destroystokyo.paper.MaterialTags;
import com.github.intellectualsites.plotsquared.bukkit.BukkitMain;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitBlockUtil;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
import com.github.intellectualsites.plotsquared.bukkit.util.UpdateUtility;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.listener.PlayerBlockEventType;
import com.github.intellectualsites.plotsquared.plot.listener.PlotListener;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotHandler;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotInventory;
import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.StringWrapper;
import com.github.intellectualsites.plotsquared.plot.object.*;
import com.github.intellectualsites.plotsquared.plot.util.EntityUtil;
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
@ -28,16 +19,13 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.RegExUtil;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.UpdateUtility;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.item.ItemType;
import io.papermc.lib.PaperLib;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.FluidCollisionMode;
import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@ -135,7 +123,12 @@ import org.bukkit.projectiles.BlockProjectileSource;
import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.util.Vector;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Field;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
@ -145,7 +138,6 @@ import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.function.Supplier;
import java.util.regex.Pattern;
/**
@ -159,6 +151,8 @@ import java.util.regex.Pattern;
private boolean tmpTeleport = true;
private Field fieldPlayer;
private PlayerMoveEvent moveTmp;
private String internalVersion;
private String spigotVersion;
{
try {
@ -729,35 +723,24 @@ import java.util.regex.Pattern;
}, 20);
if (pp.hasPermission(Captions.PERMISSION_ADMIN_UPDATE_NOTIFICATION.getTranslated())
&& PlotSquared.get().getUpdateUtility() != null) {
final UpdateUtility updateUtility = PlotSquared.get().getUpdateUtility();
final BukkitMain bukkitMain = BukkitMain.getPlugin(BukkitMain.class);
updateUtility.checkForUpdate(PlotSquared.get().getVersion().versionString(),
((updateDescription, throwable) -> {
if (throwable != null) {
bukkitMain.getLogger().severe(String
.format("Could not check for update. Reason: %s",
throwable.getMessage()));
} else {
if (updateDescription != null) {
new PlotMessage("-------- ").color("$2")
.text("PlotSquared Update Notification").color("$1")
.text(" --------").color("$2").send(pp);
new PlotMessage("There appears to be a PlotSquared update available!")
.color("$1").send(pp);
new PlotMessage(String.format(
"You are running version %s, the newest available version is %s",
bukkitMain.getPluginVersionString(),
updateDescription.getVersion())).color("$1").send(pp);
new PlotMessage("Update URL").color("$1").text(": ").color("$2")
.text(updateDescription.getUrl()).tooltip("Download update")
.send(pp);
new PlotMessage("-------- ").color("$2")
.text("PlotSquared Update Notification").color("$1")
.text(" --------").color("$2").send(pp);
}
}
}));
&& Settings.Enabled_Components.UPDATE_NOTIFICATIONS) {
try {
HttpsURLConnection connection = (HttpsURLConnection) new URL("https://api.spigotmc.org/legacy/update.php?resource=1177").openConnection();
connection.setRequestMethod("GET");
spigotVersion = (new BufferedReader(new InputStreamReader(connection.getInputStream()))).readLine();
} catch (IOException e) {
new PlotMessage(Captions.PREFIX + "Unable to check for updates, check console for further information.").color("$13");
PlotSquared.log(Captions.PREFIX + "&cUnable to check for updates because: " + e);
return;
}
if (!UpdateUtility.internalVersion.equals(UpdateUtility.spigotVersion)) {
new PlotMessage("-----------------------------------").send(pp);
new PlotMessage(Captions.PREFIX + "There appears to be a PlotSquared update available!").color("$1").tooltip("https://www.spigotmc.org/resources/1177/updates").send(pp);
new PlotMessage(Captions.PREFIX + "The latest version is " + spigotVersion).color("$1").tooltip("https://www.spigotmc.org/resources/1177/updates").send(pp);
new PlotMessage(Captions.PREFIX + "https://www.spigotmc.org/resources/1177/updates").color("$1").tooltip("https://www.spigotmc.org/resources/1177/updates").send(pp);
new PlotMessage("-----------------------------------").send(pp);
}
}
}

View File

@ -0,0 +1,56 @@
package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import org.bukkit.Bukkit;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
public class UpdateUtility implements Listener {
public static String internalVersion;
public static String spigotVersion;
public final JavaPlugin javaPlugin;
public UpdateUtility(final JavaPlugin javaPlugin) {
this.javaPlugin = javaPlugin;
internalVersion = javaPlugin.getDescription().getVersion();
}
public void updateChecker() {
new BukkitRunnable() {
public void run() {
Bukkit.getScheduler().runTaskAsynchronously(UpdateUtility.this.javaPlugin, () -> {
if (Settings.Enabled_Components.UPDATE_NOTIFICATIONS) {
try {
HttpsURLConnection connection = (HttpsURLConnection) new URL("https://api.spigotmc.org/legacy/update.php?resource=1177").openConnection();
connection.setRequestMethod("GET");
spigotVersion = (new BufferedReader(new InputStreamReader(connection.getInputStream()))).readLine();
} catch (IOException e) {
PlotSquared.log(Captions.PREFIX + "&cUnable to check for updates because: " + e);
this.cancel();
return;
}
if (!internalVersion.equals(spigotVersion)) {
PlotSquared.log(Captions.PREFIX + "&6There appears to be a PlotSquared update available!");
PlotSquared.log(Captions.PREFIX + "&6You are running version " + internalVersion + ", &6latest version is " + spigotVersion);
PlotSquared.log(Captions.PREFIX + "&6https://www.spigotmc.org/resources/1177/updates");
} else {
PlotSquared.log(Captions.PREFIX + "Congratulations! You are running the latest PlotSquared version.");
}
}
this.cancel();
});
}
}.runTaskTimer(this.javaPlugin, 0L, 12000L);
}
}