Changed some things...
- Fixed updateplugin not cancelling on error - Moved javassist to here, so the absence of ButtonChat should no longer cause any errors - Added /updateplugin for simplicity and in case the chat plugin breaks
This commit is contained in:
parent
ab4097c669
commit
908b62217a
5 changed files with 67 additions and 2 deletions
9
pom.xml
9
pom.xml
|
@ -110,18 +110,21 @@
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.9.2-R0.1-SNAPSHOT</version>
|
<version>1.9.2-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io -->
|
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>1.3.2</version>
|
<version>1.3.2</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Change jitpack.yml to set location of Towny JAR -->
|
<!-- Change jitpack.yml to set location of Towny JAR -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.TBMCPlugins.ButtonCore</groupId>
|
<groupId>com.github.TBMCPlugins.ButtonCore</groupId>
|
||||||
<artifactId>Towny</artifactId>
|
<artifactId>Towny</artifactId>
|
||||||
<version>master-SNAPSHOT</version>
|
<version>master-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.milkbowl</groupId> <!-- net.milkbowl.vault -->
|
<groupId>com.github.milkbowl</groupId> <!-- net.milkbowl.vault -->
|
||||||
|
@ -129,6 +132,12 @@
|
||||||
<version>master-SNAPSHOT</version> <!-- 1.6 -->
|
<version>master-SNAPSHOT</version> <!-- 1.6 -->
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.javassist/javassist -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.javassist</groupId>
|
||||||
|
<artifactId>javassist</artifactId>
|
||||||
|
<version>3.20.0-GA</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<organization>
|
<organization>
|
||||||
<name>TBMCPlugins</name>
|
<name>TBMCPlugins</name>
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import buttondevteam.lib.TBMCCoreAPI;
|
import buttondevteam.lib.TBMCCoreAPI;
|
||||||
import buttondevteam.lib.TBMCPlayer;
|
import buttondevteam.lib.TBMCPlayer;
|
||||||
|
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
|
||||||
public class MainPlugin extends JavaPlugin {
|
public class MainPlugin extends JavaPlugin {
|
||||||
|
@ -26,8 +27,9 @@ public class MainPlugin extends JavaPlugin {
|
||||||
pdfFile = getDescription();
|
pdfFile = getDescription();
|
||||||
logger = getLogger();
|
logger = getLogger();
|
||||||
setupPermissions();
|
setupPermissions();
|
||||||
logger.info(pdfFile.getName() + " has been Enabled (V." + pdfFile.getVersion() + ").");
|
TBMCChatAPI.AddCommand(this, UpdatePluginCommand.class);
|
||||||
TBMCCoreAPI.RegisterEventsForExceptions(new PlayerListener(), this);
|
TBMCCoreAPI.RegisterEventsForExceptions(new PlayerListener(), this);
|
||||||
|
logger.info(pdfFile.getName() + " has been Enabled (V." + pdfFile.getVersion() + ").");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
50
src/main/java/buttondevteam/core/UpdatePluginCommand.java
Normal file
50
src/main/java/buttondevteam/core/UpdatePluginCommand.java
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
package buttondevteam.core;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import buttondevteam.lib.TBMCCoreAPI;
|
||||||
|
import buttondevteam.lib.chat.TBMCCommandBase;
|
||||||
|
|
||||||
|
public class UpdatePluginCommand extends TBMCCommandBase {
|
||||||
|
@Override
|
||||||
|
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||||
|
if (args.length == 0) {
|
||||||
|
sender.sendMessage("Downloading plugin names...");
|
||||||
|
boolean first = true;
|
||||||
|
for (String plugin : TBMCCoreAPI.GetPluginNames()) {
|
||||||
|
if (first) {
|
||||||
|
sender.sendMessage("§6---- Plugin names ----");
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
sender.sendMessage("- " + plugin);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(MainPlugin.Instance, () -> {
|
||||||
|
TBMCCoreAPI.UpdatePlugin(args[0], sender, args.length == 1 ? "master" : args[1]);
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] GetHelpText(String alias) {
|
||||||
|
return new String[] { //
|
||||||
|
"§6---- Update plugin ----", //
|
||||||
|
"This command downloads the latest version of a TBMC plugin from GitHub", //
|
||||||
|
"To update a plugin: /" + alias + " <plugin>", //
|
||||||
|
"To list the plugin names: /" + alias //
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean GetPlayerOnly() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean GetModOnly() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -71,6 +71,7 @@ public final class TBMCCoreAPI {
|
||||||
}
|
}
|
||||||
if (correctname == null) {
|
if (correctname == null) {
|
||||||
error(sender, "Can't find plugin: " + name);
|
error(sender, "Can't find plugin: " + name);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
info(sender, "Updating TBMC plugin: " + correctname + " from " + branch);
|
info(sender, "Updating TBMC plugin: " + correctname + " from " + branch);
|
||||||
URL url;
|
URL url;
|
||||||
|
@ -85,6 +86,7 @@ public final class TBMCCoreAPI {
|
||||||
result.delete();
|
result.delete();
|
||||||
error(sender, "The downloaded JAR for " + correctname + " from " + branch
|
error(sender, "The downloaded JAR for " + correctname + " from " + branch
|
||||||
+ " is too small (smnaller than 25 bytes). Am I downloading from the right place?");
|
+ " is too small (smnaller than 25 bytes). Am I downloading from the right place?");
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
finalresult.delete(); // Attempt to support Windows
|
finalresult.delete(); // Attempt to support Windows
|
||||||
Files.move(result.toPath(), finalresult.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
Files.move(result.toPath(), finalresult.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
|
|
@ -2,4 +2,6 @@ name: ButtonCore
|
||||||
main: buttondevteam.core.MainPlugin
|
main: buttondevteam.core.MainPlugin
|
||||||
version: 1.0
|
version: 1.0
|
||||||
author: TBMCPlugins
|
author: TBMCPlugins
|
||||||
database: true
|
commands:
|
||||||
|
updateplugin:
|
||||||
|
description: Update a TBMC plugin
|
||||||
|
|
Loading…
Reference in a new issue