Skip to content

Commit 69c58e6

Browse files
committed
1.4.1
Update for MC1.13 and some bug fixes ;)
1 parent d038f2e commit 69c58e6

File tree

14 files changed

+417
-382
lines changed

14 files changed

+417
-382
lines changed
3.88 KB
Binary file not shown.

plugin.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: TimeVote
2-
version: 1.3
2+
version: 1.41
3+
api-version: 1.13
34
main: me.F_o_F_1092.TimeVote.Main
45
author: F_o_F_1092
56
commands:

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>me.F_o_F_1092.TimeVote</groupId>
55
<artifactId>TimeVote</artifactId>
6-
<version>1.3</version>
6+
<version>1.4.1</version>
77
<url>https://www.spigotmc.org/resources/timevote.7312/</url>
88

99
<licenses>

src/me/F_o_F_1092/TimeVote/CommandTimeVote.java

Lines changed: 87 additions & 286 deletions
Large diffs are not rendered by default.

src/me/F_o_F_1092/TimeVote/MC_V1_7__V1_8/TimeVote.java

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
import java.util.UUID;
44

5+
import org.bukkit.Bukkit;
56
import org.bukkit.entity.Player;
7+
import org.bukkit.scoreboard.DisplaySlot;
8+
import org.bukkit.scoreboard.Objective;
9+
import org.bukkit.scoreboard.Scoreboard;
610
import org.inventivetalent.bossbar.BossBarAPI;
711

812
import com.connorlinfoot.titleapi.TitleAPI;
@@ -14,11 +18,46 @@
1418

1519
public class TimeVote extends me.F_o_F_1092.TimeVote.TimeVote {
1620

17-
1821
public TimeVote(String worldName, Time time, UUID uuid) {
1922
super(worldName, time, uuid);
2023
}
21-
24+
25+
/*
26+
* Scoreboard Managing
27+
*/
28+
29+
protected void registerScoreboard(Player p) {
30+
Scoreboard sb = Bukkit.getScoreboardManager().getNewScoreboard();
31+
Objective objective = sb.registerNewObjective("TimeVote", "dummy");
32+
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
33+
34+
if (getTime() == Time.DAY) {
35+
try {
36+
objective.setDisplayName(Options.msg.get("[TimeVote]") + Options.msg.get("color.1") + Options.msg.get("text.1"));
37+
} catch (Exception e) {
38+
objective.setDisplayName("§f[§6Time§eVote§f] §6Day");
39+
40+
ServerLog.err("The scoreboard name caused a problem. (Message: text.1) [" + e.getMessage() +"]");
41+
}
42+
} else {
43+
try {
44+
objective.setDisplayName(Options.msg.get("[TimeVote]") + Options.msg.get("color.1") + Options.msg.get("text.2"));
45+
} catch (Exception e) {
46+
objective.setDisplayName("§f[§6Time§eVote§f] §6Night");
47+
48+
ServerLog.err("The scoreboard name caused a problem. (Message: text.2) [" + e.getMessage() +"]");
49+
}
50+
}
51+
52+
try {
53+
p.setScoreboard(sb);
54+
} catch (Exception e) {
55+
ServerLog.err("Faild to remove the Scoreboard from " + p.getName() + " [" + e.getMessage() +"]");
56+
}
57+
58+
updateScore(p);
59+
}
60+
2261

2362
/*
2463
* Bossbar sending
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package me.F_o_F_1092.TimeVote.MC_V1_9__V1_12;
2+
3+
import java.util.UUID;
4+
5+
import org.bukkit.Bukkit;
6+
import org.bukkit.entity.Player;
7+
import org.bukkit.scoreboard.DisplaySlot;
8+
import org.bukkit.scoreboard.Objective;
9+
import org.bukkit.scoreboard.Scoreboard;
10+
11+
import me.F_o_F_1092.TimeVote.Options;
12+
import me.F_o_F_1092.TimeVote.PluginManager.ServerLog;
13+
14+
15+
public class TimeVote extends me.F_o_F_1092.TimeVote.TimeVote {
16+
17+
public TimeVote(String worldName, Time time, UUID uuid) {
18+
super(worldName, time, uuid);
19+
}
20+
21+
/*
22+
* Scoreboard Managing
23+
*/
24+
25+
protected void registerScoreboard(Player p) {
26+
Scoreboard sb = Bukkit.getScoreboardManager().getNewScoreboard();
27+
Objective objective = sb.registerNewObjective("TimeVote", "dummy");
28+
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
29+
30+
if (getTime() == Time.DAY) {
31+
try {
32+
objective.setDisplayName(Options.msg.get("[TimeVote]") + Options.msg.get("color.1") + Options.msg.get("text.1"));
33+
} catch (Exception e) {
34+
objective.setDisplayName("§f[§6Time§eVote§f] §6Day");
35+
36+
ServerLog.err("The scoreboard name caused a problem. (Message: text.1) [" + e.getMessage() +"]");
37+
}
38+
} else {
39+
try {
40+
objective.setDisplayName(Options.msg.get("[TimeVote]") + Options.msg.get("color.1") + Options.msg.get("text.2"));
41+
} catch (Exception e) {
42+
objective.setDisplayName("§f[§6Time§eVote§f] §6Night");
43+
44+
ServerLog.err("The scoreboard name caused a problem. (Message: text.2) [" + e.getMessage() +"]");
45+
}
46+
}
47+
48+
try {
49+
p.setScoreboard(sb);
50+
} catch (Exception e) {
51+
ServerLog.err("Faild to remove the Scoreboard from " + p.getName() + " [" + e.getMessage() +"]");
52+
}
53+
54+
updateScore(p);
55+
}
56+
}

src/me/F_o_F_1092/TimeVote/Main.java

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
import me.F_o_F_1092.TimeVote.PluginManager.CommandListener;
1818
import me.F_o_F_1092.TimeVote.PluginManager.ServerLog;
1919
import me.F_o_F_1092.TimeVote.PluginManager.VersionManager;
20+
import me.F_o_F_1092.TimeVote.PluginManager.VersionManager.BukkitVersion;
2021
import me.F_o_F_1092.TimeVote.PluginManager.VersionManager.ServerType;
21-
import me.F_o_F_1092.TimeVote.PluginManager.VersionManager.Version;
2222
import me.F_o_F_1092.TimeVote.PluginManager.Spigot.HelpPageListener;
2323
import me.F_o_F_1092.TimeVote.PluginManager.Spigot.UpdateListener;
2424
import me.F_o_F_1092.TimeVote.VotingGUI.VotingGUIListener;
@@ -38,21 +38,34 @@ public void onEnable() {
3838
plugin = this;
3939

4040
ServerLog.setPluginTag("§f[§6Time§eVote§f]§6");
41-
UpdateListener.initializeUpdateListener(1.3, "1.3", 7312);
41+
UpdateListener.initializeUpdateListener(1.41, "1.4.1", 7312);
4242
UpdateListener.checkForUpdate();
4343

44-
45-
if (Bukkit.getPluginManager().getPlugin("Vault") != null) {
46-
Options.vault = true;
47-
}
48-
44+
setup();
4945

5046
PluginManager pm = getServer().getPluginManager();
5147
pm.registerEvents(new EventListener(), this);
5248

5349
this.getCommand("TimeVote").setExecutor(new CommandTimeVote());
5450
this.getCommand("TimeVote").setTabCompleter(new CommandTimeVoteTabCompleter());
55-
51+
}
52+
53+
@Override
54+
public void onDisable() {
55+
disable();
56+
57+
System.out.println("[TimeVote] a Plugin by F_o_F_1092");
58+
}
59+
60+
61+
public static void setup() {
62+
VersionManager.setVersionManager(Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3], ServerType.BUKKIT, false);
63+
64+
65+
if (Bukkit.getPluginManager().getPlugin("Vault") != null) {
66+
Options.vault = true;
67+
}
68+
5669
File fileConfig = new File("plugins/TimeVote/Config.yml");
5770
FileConfiguration ymlFileConfig = YamlConfiguration.loadConfiguration(fileConfig);
5871

@@ -64,7 +77,7 @@ public void onEnable() {
6477
ymlFileConfig.save(fileConfig);
6578
ymlFileConfig.set("Version", UpdateListener.getUpdateDoubleVersion());
6679
ymlFileConfig.set("GameVersion.SetOwn", false);
67-
ymlFileConfig.set("GameVersion.Version", "1.12");
80+
ymlFileConfig.set("GameVersion.Version", "v1_13_R1");
6881
ymlFileConfig.set("ColoredConsoleText", true);
6982
ymlFileConfig.set("DayTime", 6000);
7083
ymlFileConfig.set("NightTime", 18000);
@@ -117,7 +130,7 @@ public void onEnable() {
117130
ymlFileConfig.set("UseTitleAPI", null);
118131
}
119132
ymlFileConfig.set("GameVersion.SetOwn", false);
120-
ymlFileConfig.set("GameVersion.Version", "1.12");
133+
ymlFileConfig.set("GameVersion.Version", "v1_13_R1");
121134
ymlFileConfig.set("ColoredConsoleText", true);
122135
}
123136
ymlFileConfig.save(fileConfig);
@@ -130,11 +143,10 @@ public void onEnable() {
130143
ServerLog.setUseColoredColores(ymlFileConfig.getBoolean("ColoredConsoleText"));
131144

132145
if (!ymlFileConfig.getBoolean("GameVersion.SetOwn")) {
133-
VersionManager.setVersionManager(Bukkit.getVersion(), ServerType.BUKKIT, false);
134-
ServerLog.log("ServerType:§e " + VersionManager.getSetverTypeString() + "§6, Version:§e " + VersionManager.getVersionSring());
146+
ServerLog.log("ServerType:§e " + VersionManager.getSetverTypeString() + "§6, Version:§e " + VersionManager.getBukkitVersion());
135147
} else {
136148
VersionManager.setVersionManager(ymlFileConfig.getString("GameVersion.Version"), ServerType.BUKKIT, true);
137-
ServerLog.log("ServerType:§e " + VersionManager.getSetverTypeString() + "§6, Version:§e " + VersionManager.getVersionSring() + "§6 | §e(Self configurated)");
149+
ServerLog.log("ServerType:§e " + VersionManager.getSetverTypeString() + "§6, Version:§e " + VersionManager.getBukkitVersion() + "§6 | §e(Self configurated)");
138150
}
139151

140152
Options.dayTime = ymlFileConfig.getLong("DayTime");
@@ -146,7 +158,7 @@ public void onEnable() {
146158
Options.useVoteGUI = ymlFileConfig.getBoolean("UseVoteGUI");
147159

148160
if (ymlFileConfig.getBoolean("UseBossBar")) {
149-
if (VersionManager.getVersion() == Version.MC_V1_7 || VersionManager.getVersion() == Version.MC_V1_8) {
161+
if (VersionManager.getBukkitVersion() == BukkitVersion.v1_7_R1 || VersionManager.getBukkitVersion() == BukkitVersion.v1_7_R2 || VersionManager.getBukkitVersion() == BukkitVersion.v1_7_R4 || VersionManager.getBukkitVersion() == BukkitVersion.v1_7_R3 || VersionManager.getBukkitVersion() == BukkitVersion.v1_8_R1 || VersionManager.getBukkitVersion() == BukkitVersion.v1_8_R2 || VersionManager.getBukkitVersion() == BukkitVersion.v1_8_R3) {
150162
if (Bukkit.getPluginManager().getPlugin("BossBarAPI") != null) {
151163
Options.useBossBar = true;
152164
}
@@ -156,7 +168,7 @@ public void onEnable() {
156168
}
157169

158170
if (ymlFileConfig.getBoolean("UseTitle")) {
159-
if (VersionManager.getVersion() == Version.MC_V1_7 || VersionManager.getVersion() == Version.MC_V1_8) {
171+
if (VersionManager.getBukkitVersion() == BukkitVersion.v1_7_R1 || VersionManager.getBukkitVersion() == BukkitVersion.v1_7_R2 || VersionManager.getBukkitVersion() == BukkitVersion.v1_7_R4 || VersionManager.getBukkitVersion() == BukkitVersion.v1_7_R3 || VersionManager.getBukkitVersion() == BukkitVersion.v1_8_R1 || VersionManager.getBukkitVersion() == BukkitVersion.v1_8_R2 || VersionManager.getBukkitVersion() == BukkitVersion.v1_8_R3) {
160172
if (Bukkit.getPluginManager().getPlugin("TitleAPI") != null) {
161173
Options.useTitle = true;
162174
}
@@ -257,10 +269,10 @@ public void onEnable() {
257269
ymlFileMessage.set("StatsText.5", " No votes: ");
258270
ymlFileMessage.set("StatsText.6", " Won: ");
259271
ymlFileMessage.set("StatsText.7", " Lost: ");
260-
ymlFileMessage.set("HelpTextGui.1", "&e[&6Click to use this command&e]");
261-
ymlFileMessage.set("HelpTextGui.2", "&e[&6Next page&e]");
262-
ymlFileMessage.set("HelpTextGui.3", "&e[&6Last page&e]");
263-
ymlFileMessage.set("HelpTextGui.4", "&7&oPage [PAGE]. &7Click on the arrows for the next page.");
272+
ymlFileMessage.set("HelpTextGui.1", "&e[&6Click to use this command&e]");
273+
ymlFileMessage.set("HelpTextGui.2", "&e[&6Next page&e]");
274+
ymlFileMessage.set("HelpTextGui.3", "&e[&6Last page&e]");
275+
ymlFileMessage.set("HelpTextGui.4", "&7&oPage [PAGE]. &7Click on the arrows for the next page.");
264276
ymlFileMessage.set("HelpText.1", "This command shows you the help page.");
265277
ymlFileMessage.set("HelpText.2", "This command shows you the info page.");
266278
ymlFileMessage.set("HelpText.3", "This command shows you the stats page.");
@@ -415,21 +427,23 @@ public void onEnable() {
415427
CommandListener.addCommand(new Command("/tv no", "TimeVote.Vote", ChatColor.translateAlternateColorCodes('&', ymlFileMessage.getString("HelpText.8"))));
416428
CommandListener.addCommand(new Command("/tv stopVoting [World]", "TimeVote.StopVoting", ChatColor.translateAlternateColorCodes('&', ymlFileMessage.getString("HelpText.10"))));
417429
CommandListener.addCommand(new Command("/tv reload", "TimeVote.Reload", ChatColor.translateAlternateColorCodes('&', ymlFileMessage.getString("HelpText.9"))));
418-
419430
}
420431

421-
@Override
422-
public void onDisable() {
423-
System.out.println("[TimeVote] a Plugin by F_o_F_1092");
432+
public static void disable() {
424433
for (World w : Bukkit.getWorlds()) {
425434
if (Options.useVoteGUI) {
426435
VotingGUIListener.closeVotingGUIsAtWorld(w.getName());
427436
}
428437

429438
if (TimeVoteListener.isVoting(w.getName())) {
430-
TimeVoteListener.getVoteing(w.getName()).stopVoting(false);
439+
TimeVoteListener.getVoteing(w.getName()).stopVoting(true);
431440
}
432441
}
442+
443+
TimeVoteListener.timeVotes.clear();
444+
Options.disabledWorlds.clear();
445+
446+
CommandListener.clearCommands();
433447
}
434448

435449
}

src/me/F_o_F_1092/TimeVote/PluginManager/Spigot/UpdateListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void run() {
2222
URLConnection connection = url.openConnection();
2323
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
2424

25-
if (!reader.readLine().equals("Version: " + updateString)) {
25+
if (!reader.readLine().equals(updateString)) {
2626
ServerLog.log("A new update is available.");
2727
updateAvailable = true;
2828
}

0 commit comments

Comments
 (0)