Skip to content

Commit 3fb60cb

Browse files
committed
UpToDate v1.2
1 parent 8ec5399 commit 3fb60cb

File tree

3 files changed

+48
-43
lines changed

3 files changed

+48
-43
lines changed

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>me.telesphoreo</groupId>
77
<artifactId>UpToDate</artifactId>
8-
<version>1.1</version>
8+
<version>1.2</version>
99

1010
<properties>
1111
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -36,7 +36,7 @@
3636
<dependency>
3737
<groupId>org.bukkit</groupId>
3838
<artifactId>bukkit</artifactId>
39-
<version>1.14.2-R0.1-SNAPSHOT</version>
39+
<version>1.14.4-R0.1-SNAPSHOT</version>
4040
<scope>provided</scope>
4141
</dependency>
4242
<dependency>
@@ -60,7 +60,7 @@
6060
<plugin>
6161
<groupId>org.apache.maven.plugins</groupId>
6262
<artifactId>maven-compiler-plugin</artifactId>
63-
<version>3.8.0</version>
63+
<version>3.8.1</version>
6464
<configuration>
6565
<outputFileName>UpToDate.jar</outputFileName>
6666
<source>1.8</source>
@@ -95,7 +95,7 @@
9595
<plugin>
9696
<groupId>pl.project13.maven</groupId>
9797
<artifactId>git-commit-id-plugin</artifactId>
98-
<version>2.2.6</version>
98+
<version>4.0.0</version>
9999
<executions>
100100
<execution>
101101
<id>get-the-git-infos</id>

src/main/java/me/telesphoreo/UpToDate.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ public class UpToDate extends JavaPlugin
2828
@Override
2929
public void onLoad()
3030
{
31-
UpToDate.plugin = this;
32-
UpToDate.server = plugin.getServer();
31+
plugin = this;
32+
server = plugin.getServer();
3333
NLog.setPluginLogger(plugin.getLogger());
3434
NLog.setServerLogger(server.getLogger());
35-
UpToDate.pluginName = plugin.getDescription().getName();
36-
UpToDate.pluginVersion = plugin.getDescription().getVersion();
35+
pluginName = plugin.getDescription().getName();
36+
pluginVersion = plugin.getDescription().getVersion();
3737
}
3838

3939
@Override

src/main/java/me/telesphoreo/commands/UpdateCommand.java

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,62 +13,67 @@
1313

1414
public class UpdateCommand implements CommandExecutor
1515
{
16-
private static final String[] FILES =
16+
private final String[] FILES =
1717
{
1818
UpToDate.getPlugin("Aero"),
1919
UpToDate.getPlugin("BukkitTelnet"),
20-
UpToDate.getPlugin("Discord"),
20+
UpToDate.getPlugin("JDA"),
2121
UpToDate.getPlugin("EssentialsX"),
2222
UpToDate.getPlugin("EssentialsXSpawn"),
2323
UpToDate.getPlugin("LibsDisguises"),
24+
UpToDate.getPlugin("ProtocolLib"),
2425
UpToDate.getPlugin("WorldEdit"),
2526
UpToDate.getPlugin("WorldGuard"),
2627
};
2728

2829
@Override
29-
public boolean onCommand(CommandSender sender, Command command, String s, String[] strings)
30-
{
31-
if (!TFMBridge.isAdmin(Bukkit.getPlayer(sender.getName())))
30+
public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) {
31+
boolean noTFM = false;
32+
if (TFMBridge.getTFM() == null)
3233
{
33-
sender.sendMessage(Messages.MSG_NO_PERMS);
34-
return true;
34+
noTFM = true;
3535
}
36-
37-
sender.sendMessage(ChatColor.GRAY + "Updating server plugins.");
38-
39-
new BukkitRunnable()
36+
if (noTFM || TFMBridge.isAdmin(Bukkit.getPlayer(sender.getName())))
4037
{
41-
@Override
42-
public void run()
38+
sender.sendMessage(ChatColor.GRAY + "Updating server plugins.");
39+
40+
new BukkitRunnable()
4341
{
44-
try
42+
@Override
43+
public void run()
4544
{
46-
for (final String url : FILES)
45+
try
4746
{
48-
NLog.info("Downloading: " + url);
49-
50-
File file = new File("./plugins/" + url.substring(url.lastIndexOf("/") + 1));
51-
if (file.exists())
52-
{
53-
file.delete();
54-
}
55-
if (!file.getParentFile().exists())
47+
for (final String url : FILES)
5648
{
57-
file.getParentFile().mkdirs();
58-
}
49+
NLog.info("Downloading: " + url);
5950

60-
UpToDate.downloadFile(url, file, true);
51+
File file = new File("./plugins/" + url.substring(url.lastIndexOf("/") + 1));
52+
if (file.exists())
53+
{
54+
file.delete();
55+
}
56+
if (!file.getParentFile().exists())
57+
{
58+
file.getParentFile().mkdirs();
59+
}
60+
61+
UpToDate.downloadFile(url, file, true);
62+
}
63+
sender.sendMessage(ChatColor.GRAY + "Successfully updated. Restarting server.");
64+
Bukkit.broadcastMessage(ChatColor.LIGHT_PURPLE + sender.getName() + " updated the plugins, restarting the server.");
65+
Bukkit.getServer().shutdown();
66+
}
67+
catch (Exception ex)
68+
{
69+
NLog.severe(ex);
6170
}
62-
sender.sendMessage(ChatColor.GRAY + "Successfully updated. Restarting server.");
63-
Bukkit.broadcastMessage(ChatColor.LIGHT_PURPLE + sender.getName() + " updated the plugins, restarting the server.");
64-
Bukkit.getServer().shutdown();
65-
}
66-
catch (Exception ex)
67-
{
68-
NLog.severe(ex);
6971
}
70-
}
71-
}.runTaskAsynchronously(UpToDate.plugin);
72+
}.runTaskAsynchronously(UpToDate.plugin);
73+
} else {
74+
sender.sendMessage(Messages.MSG_NO_PERMS);
75+
return true;
76+
}
7277
return true;
7378
}
7479
}

0 commit comments

Comments
 (0)