Skip to content
This repository was archived by the owner on Dec 31, 2024. It is now read-only.

Commit 6ca99f5

Browse files
authored
Merge pull request #48 from frafol/patch-4
All future versions auto support.
2 parents a77c66d + 2c02ee6 commit 6ca99f5

File tree

8 files changed

+474
-510
lines changed

8 files changed

+474
-510
lines changed
Lines changed: 90 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,90 @@
1-
/*
2-
* This file is part of BungeeBlockVersion.
3-
*
4-
* BungeeBlockVersion is free software: you can redistribute it and/or modify
5-
* it under the terms of the GNU General Public License as published by
6-
* the Free Software Foundation, either version 3 of the License, or
7-
* (at your option) any later version.
8-
*
9-
* BungeeBlockVersion is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
* GNU General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU General Public License
15-
* along with BungeeBlockVersion. If not, see <https://www.gnu.org/licenses/>.
16-
*/
17-
18-
package lol.hyper.bungeeblockversion;
19-
20-
import lol.hyper.bungeeblockversion.commands.CommandReload;
21-
import lol.hyper.bungeeblockversion.events.JoinEvent;
22-
import lol.hyper.bungeeblockversion.tools.ConfigHandler;
23-
import lol.hyper.githubreleaseapi.GitHubRelease;
24-
import lol.hyper.githubreleaseapi.GitHubReleaseAPI;
25-
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
26-
import net.kyori.adventure.text.minimessage.MiniMessage;
27-
import net.md_5.bungee.api.ProxyServer;
28-
import net.md_5.bungee.api.plugin.Listener;
29-
import net.md_5.bungee.api.plugin.Plugin;
30-
import org.bstats.bungeecord.Metrics;
31-
32-
import java.io.IOException;
33-
import java.util.HashMap;
34-
import java.util.Map;
35-
import java.util.logging.Logger;
36-
37-
public final class BungeeBlockVersion extends Plugin implements Listener {
38-
39-
public final Logger logger = this.getLogger();
40-
41-
public ConfigHandler configHandler;
42-
public JoinEvent joinEvent;
43-
public final MiniMessage miniMessage = MiniMessage.miniMessage();
44-
private BungeeAudiences adventure;
45-
46-
public Map<Integer, String> versions = new HashMap<>();
47-
48-
@Override
49-
public void onEnable() {
50-
this.adventure = BungeeAudiences.create(this);
51-
joinEvent = new JoinEvent(this);
52-
configHandler = new ConfigHandler(this);
53-
configHandler.loadConfig();
54-
getProxy().getPluginManager().registerCommand(this, new CommandReload("bbvreload", this));
55-
ProxyServer.getInstance().getPluginManager().registerListener(this, joinEvent);
56-
57-
new Metrics(this, 9392);
58-
ProxyServer.getInstance().getScheduler().runAsync(this, this::checkForUpdates);
59-
}
60-
61-
public void checkForUpdates() {
62-
GitHubReleaseAPI api;
63-
try {
64-
api = new GitHubReleaseAPI("BungeeBlockVersion", "hyperdefined");
65-
} catch (IOException e) {
66-
logger.warning("Unable to check updates!");
67-
e.printStackTrace();
68-
return;
69-
}
70-
GitHubRelease current = api.getReleaseByTag(this.getDescription().getVersion());
71-
GitHubRelease latest = api.getLatestVersion();
72-
if (current == null) {
73-
logger.warning("You are running a version that does not exist on GitHub. If you are in a dev environment, you can ignore this. Otherwise, this is a bug!");
74-
return;
75-
}
76-
int buildsBehind = api.getBuildsBehind(current);
77-
if (buildsBehind == 0) {
78-
logger.info("You are running the latest version.");
79-
} else {
80-
logger.warning("A new version is available (" + latest.getTagVersion() + ")! You are running version " + current.getTagVersion() + ". You are " + buildsBehind + " version(s) behind.");
81-
}
82-
}
83-
84-
public BungeeAudiences getAdventure() {
85-
if (this.adventure == null) {
86-
throw new IllegalStateException("Tried to access Adventure when the plugin was disabled!");
87-
}
88-
return this.adventure;
89-
}
90-
}
1+
/*
2+
* This file is part of BungeeBlockVersion.
3+
*
4+
* BungeeBlockVersion is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* BungeeBlockVersion is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with BungeeBlockVersion. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
package lol.hyper.bungeeblockversion;
19+
20+
import lol.hyper.bungeeblockversion.commands.CommandReload;
21+
import lol.hyper.bungeeblockversion.events.JoinEvent;
22+
import lol.hyper.bungeeblockversion.tools.ConfigHandler;
23+
import lol.hyper.githubreleaseapi.GitHubRelease;
24+
import lol.hyper.githubreleaseapi.GitHubReleaseAPI;
25+
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
26+
import net.kyori.adventure.text.minimessage.MiniMessage;
27+
import net.md_5.bungee.api.ProxyServer;
28+
import net.md_5.bungee.api.plugin.Listener;
29+
import net.md_5.bungee.api.plugin.Plugin;
30+
import org.bstats.bungeecord.Metrics;
31+
32+
import java.io.IOException;
33+
import java.util.HashMap;
34+
import java.util.Map;
35+
import java.util.logging.Logger;
36+
37+
public final class BungeeBlockVersion extends Plugin implements Listener {
38+
39+
public final Logger logger = this.getLogger();
40+
41+
public ConfigHandler configHandler;
42+
public JoinEvent joinEvent;
43+
public final MiniMessage miniMessage = MiniMessage.miniMessage();
44+
private BungeeAudiences adventure;
45+
46+
public Map<Integer, String> versions = new HashMap<>();
47+
48+
@Override
49+
public void onEnable() {
50+
this.adventure = BungeeAudiences.create(this);
51+
joinEvent = new JoinEvent(this);
52+
configHandler = new ConfigHandler(this);
53+
configHandler.loadConfig();
54+
getProxy().getPluginManager().registerCommand(this, new CommandReload("bbvreload", this));
55+
ProxyServer.getInstance().getPluginManager().registerListener(this, joinEvent);
56+
57+
new Metrics(this, 9392);
58+
ProxyServer.getInstance().getScheduler().runAsync(this, this::checkForUpdates);
59+
}
60+
61+
public void checkForUpdates() {
62+
GitHubReleaseAPI api;
63+
try {
64+
api = new GitHubReleaseAPI("BungeeBlockVersion", "hyperdefined");
65+
} catch (IOException e) {
66+
logger.warning("Unable to check updates!");
67+
e.printStackTrace();
68+
return;
69+
}
70+
GitHubRelease current = api.getReleaseByTag(this.getDescription().getVersion());
71+
GitHubRelease latest = api.getLatestVersion();
72+
if (current == null) {
73+
logger.warning("You are running a version that does not exist on GitHub. If you are in a dev environment, you can ignore this. Otherwise, this is a bug!");
74+
return;
75+
}
76+
int buildsBehind = api.getBuildsBehind(current);
77+
if (buildsBehind == 0) {
78+
logger.info("You are running the latest version.");
79+
} else {
80+
logger.warning("A new version is available (" + latest.getTagVersion() + ")! You are running version " + current.getTagVersion() + ". You are " + buildsBehind + " version(s) behind.");
81+
}
82+
}
83+
84+
public BungeeAudiences getAdventure() {
85+
if (this.adventure == null) {
86+
throw new IllegalStateException("Tried to access Adventure when the plugin was disabled!");
87+
}
88+
return this.adventure;
89+
}
90+
}
Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
/*
2-
* This file is part of BungeeBlockVersion.
3-
*
4-
* BungeeBlockVersion is free software: you can redistribute it and/or modify
5-
* it under the terms of the GNU General Public License as published by
6-
* the Free Software Foundation, either version 3 of the License, or
7-
* (at your option) any later version.
8-
*
9-
* BungeeBlockVersion is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
* GNU General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU General Public License
15-
* along with BungeeBlockVersion. If not, see <https://www.gnu.org/licenses/>.
16-
*/
17-
18-
package lol.hyper.bungeeblockversion.commands;
19-
20-
import lol.hyper.bungeeblockversion.BungeeBlockVersion;
21-
import net.kyori.adventure.text.Component;
22-
import net.kyori.adventure.text.format.NamedTextColor;
23-
import net.md_5.bungee.api.CommandSender;
24-
import net.md_5.bungee.api.plugin.Command;
25-
26-
public class CommandReload extends Command {
27-
28-
private final BungeeBlockVersion bungeeBlockVersion;
29-
30-
public CommandReload(String name, BungeeBlockVersion bungeeBlockVersion) {
31-
super(name);
32-
this.bungeeBlockVersion = bungeeBlockVersion;
33-
}
34-
35-
@Override
36-
public void execute(CommandSender sender, String[] args) {
37-
if (sender.hasPermission("bbv.reload")) {
38-
bungeeBlockVersion.getAdventure().sender(sender).sendMessage(Component.text("Config reloaded!").color(NamedTextColor.GREEN));
39-
bungeeBlockVersion.configHandler.loadConfig();
40-
} else {
41-
bungeeBlockVersion.getAdventure().sender(sender).sendMessage(Component.text("You do not have permission for this command.").color(NamedTextColor.RED));
42-
}
43-
}
44-
}
1+
/*
2+
* This file is part of BungeeBlockVersion.
3+
*
4+
* BungeeBlockVersion is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* BungeeBlockVersion is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with BungeeBlockVersion. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
package lol.hyper.bungeeblockversion.commands;
19+
20+
import lol.hyper.bungeeblockversion.BungeeBlockVersion;
21+
import net.kyori.adventure.text.Component;
22+
import net.kyori.adventure.text.format.NamedTextColor;
23+
import net.md_5.bungee.api.CommandSender;
24+
import net.md_5.bungee.api.plugin.Command;
25+
26+
public class CommandReload extends Command {
27+
28+
private final BungeeBlockVersion bungeeBlockVersion;
29+
30+
public CommandReload(String name, BungeeBlockVersion bungeeBlockVersion) {
31+
super(name);
32+
this.bungeeBlockVersion = bungeeBlockVersion;
33+
}
34+
35+
@Override
36+
public void execute(CommandSender sender, String[] args) {
37+
if (sender.hasPermission("bbv.reload")) {
38+
bungeeBlockVersion.getAdventure().sender(sender).sendMessage(Component.text("Config reloaded!").color(NamedTextColor.GREEN));
39+
bungeeBlockVersion.configHandler.loadConfig();
40+
} else {
41+
bungeeBlockVersion.getAdventure().sender(sender).sendMessage(Component.text("You do not have permission for this command.").color(NamedTextColor.RED));
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)