Skip to content

Commit

Permalink
Remove unnecessary Messenger class
Browse files Browse the repository at this point in the history
  • Loading branch information
Chew committed Jul 29, 2020
1 parent 5a642b2 commit a406860
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 47 deletions.
30 changes: 0 additions & 30 deletions src/main/java/me/puyttre/svl/Messager.java

This file was deleted.

13 changes: 5 additions & 8 deletions src/main/java/me/puyttre/svl/SimpleVoteListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
Expand All @@ -16,28 +15,26 @@
public class SimpleVoteListener extends JavaPlugin implements Listener {

public FileConfiguration config;
public Messager messager;
private TimedCommand timer;

@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(this, this);
Bukkit.getPluginManager().registerEvents(new JoinEvent(this), this);
this.messager = new Messager(this);
this.timer = new TimedCommand(this);

getCommand("svl").setExecutor(new Commands(this));

if (!new File(getDataFolder(), "config.yml").exists()) {
saveResource("config.yml", false);
loadConfig();
messager.log("Config file not found. Generating a new one for you!");
getLogger().info("Config file not found. Generating a new one for you!");
} else {
loadConfig();
messager.log("Config file found. Using it!");
getLogger().info("Config file found. Using it!");
}
messager.log("SimpleVoteListener 2.4 successfully enabled.");

getLogger().info("SimpleVoteListener 2.4 successfully enabled.");
}

@Override
Expand All @@ -61,7 +58,7 @@ public void vote(VotifierEvent e) {
}
}

public Set<String> offline = new HashSet();
public Set<String> offline = new HashSet<>();

public void initOfflineVote(Vote v) {
offline.add(v.getUsername().toLowerCase());
Expand Down
15 changes: 6 additions & 9 deletions src/main/java/me/puyttre/svl/TimedCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@

public class TimedCommand {

private SimpleVoteListener plugin;
private final SimpleVoteListener plugin;

public Set<String> commands = new HashSet();
public Set<String> commands = new HashSet<>();

public TimedCommand(SimpleVoteListener plugin) {
this.plugin = plugin;
}

public void startTimer(final Vote v, String s) {
if (!s.contains(";")) {
plugin.messager.error("You did not specify a time for the commands to dispatch. eg. 'tell %name% Its been 10 seconds since you voted!;10s'");
plugin.getLogger().warning("You did not specify a time for the commands to dispatch. eg. 'tell %name% It's been 10 seconds since you voted!;10s'");
return;
}
final String[] split = s.split(";");
Expand All @@ -29,12 +29,9 @@ public void startTimer(final Vote v, String s) {
} else if (split[1].toLowerCase().endsWith("h")) {
time = ((time * 20) * 60) * 60;
}
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
Bukkit.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), plugin.replaceColor(plugin.replace(split[0], v)));
commands.remove(split[0]);
}
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
Bukkit.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), plugin.replaceColor(plugin.replace(split[0], v)));
commands.remove(split[0]);
}, time);
commands.add(split[0]);
}
Expand Down

0 comments on commit a406860

Please sign in to comment.