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:
Norbi Peti 2016-12-17 12:48:19 +01:00
parent ab4097c669
commit 908b62217a
5 changed files with 67 additions and 2 deletions

View file

@ -110,18 +110,21 @@
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.9.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
<scope>provided</scope>
</dependency>
<!-- Change jitpack.yml to set location of Towny JAR -->
<dependency>
<groupId>com.github.TBMCPlugins.ButtonCore</groupId>
<artifactId>Towny</artifactId>
<version>master-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.milkbowl</groupId> <!-- net.milkbowl.vault -->
@ -129,6 +132,12 @@
<version>master-SNAPSHOT</version> <!-- 1.6 -->
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.javassist/javassist -->
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.20.0-GA</version>
</dependency>
</dependencies>
<organization>
<name>TBMCPlugins</name>

View file

@ -10,6 +10,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.TBMCPlayer;
import buttondevteam.lib.chat.TBMCChatAPI;
import net.milkbowl.vault.permission.Permission;
public class MainPlugin extends JavaPlugin {
@ -26,8 +27,9 @@ public class MainPlugin extends JavaPlugin {
pdfFile = getDescription();
logger = getLogger();
setupPermissions();
logger.info(pdfFile.getName() + " has been Enabled (V." + pdfFile.getVersion() + ").");
TBMCChatAPI.AddCommand(this, UpdatePluginCommand.class);
TBMCCoreAPI.RegisterEventsForExceptions(new PlayerListener(), this);
logger.info(pdfFile.getName() + " has been Enabled (V." + pdfFile.getVersion() + ").");
}
@Override

View 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;
}
}

View file

@ -71,6 +71,7 @@ public final class TBMCCoreAPI {
}
if (correctname == null) {
error(sender, "Can't find plugin: " + name);
return;
}
info(sender, "Updating TBMC plugin: " + correctname + " from " + branch);
URL url;
@ -85,6 +86,7 @@ public final class TBMCCoreAPI {
result.delete();
error(sender, "The downloaded JAR for " + correctname + " from " + branch
+ " is too small (smnaller than 25 bytes). Am I downloading from the right place?");
return;
} else {
finalresult.delete(); // Attempt to support Windows
Files.move(result.toPath(), finalresult.toPath(), StandardCopyOption.REPLACE_EXISTING);

View file

@ -2,4 +2,6 @@ name: ButtonCore
main: buttondevteam.core.MainPlugin
version: 1.0
author: TBMCPlugins
database: true
commands:
updateplugin:
description: Update a TBMC plugin