1.4.1
This commit is contained in:
parent
91f3eb4f57
commit
8bb3f05d17
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>ru.froggymonitor</groupId>
|
||||
<artifactId>rewardplugin</artifactId>
|
||||
<version>1.4</version>
|
||||
<version>1.4.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>FroggyMonitorReward</name>
|
||||
|
@ -5,6 +5,7 @@ import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.data.type.TripwireHook;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -62,6 +63,11 @@ public final class Main extends JavaPlugin implements Listener {
|
||||
public boolean has_placeholderapi;
|
||||
public boolean has_vault;
|
||||
|
||||
public String bind_host;
|
||||
public int bind_port;
|
||||
|
||||
public ReloadCommand reload_command;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
has_vault = setupEconomy();
|
||||
@ -69,6 +75,8 @@ public final class Main extends JavaPlugin implements Listener {
|
||||
|
||||
me = this;
|
||||
|
||||
reload_command = new ReloadCommand();
|
||||
|
||||
conf = new UnrealConfig(this, "config.yml");
|
||||
|
||||
vote_page = "/api/vote";
|
||||
@ -84,6 +92,9 @@ public final class Main extends JavaPlugin implements Listener {
|
||||
add_comment_reward = new Reward("add_comment", (Map<String, Object>) conf.get("add_comment"));
|
||||
del_comment_reward = new Reward("del_comment", (Map<String, Object>) conf.get("del_comment"));
|
||||
|
||||
bind_host = (String) conf.get("bind_host");
|
||||
bind_port = ((Number) conf.get("bind_port")).intValue();
|
||||
|
||||
httpClient = HttpClient.newHttpClient();
|
||||
|
||||
sendRewardUrls();
|
||||
@ -92,11 +103,7 @@ public final class Main extends JavaPlugin implements Listener {
|
||||
|
||||
loadCache();
|
||||
|
||||
site = new SitePart(
|
||||
(String) conf.get("bind_host"),
|
||||
((Number) conf.get("bind_port")).intValue(),
|
||||
0);
|
||||
|
||||
site = new SitePart(bind_host,bind_port,0);
|
||||
site.start();
|
||||
|
||||
getServer().getPluginManager().registerEvents(this,this);
|
||||
@ -104,8 +111,20 @@ public final class Main extends JavaPlugin implements Listener {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
tryCatchIgnore(() -> {
|
||||
saveCache();
|
||||
site.stop();
|
||||
});
|
||||
}
|
||||
|
||||
public interface tryCatchRunnable {
|
||||
public void run() throws Throwable;
|
||||
}
|
||||
|
||||
public void tryCatchIgnore(tryCatchRunnable r) {
|
||||
try {
|
||||
r.run();
|
||||
} catch (Throwable ignored) {}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -172,7 +191,7 @@ public final class Main extends JavaPlugin implements Listener {
|
||||
public HttpClient httpClient;
|
||||
|
||||
public void sendRewardUrls() {
|
||||
String start_url = "http://"+external_host+":"+site.port;
|
||||
String start_url = "http://"+external_host+":"+bind_port;
|
||||
|
||||
String body = "{\"secret_token\": \""+secret_token+"\", "+
|
||||
"\"vote_url\": \""+start_url+vote_page+"\", "+
|
||||
|
@ -0,0 +1,51 @@
|
||||
package ru.froggymonitor.rewardplugin;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ReloadCommand implements CommandExecutor, TabCompleter {
|
||||
public PluginCommand pluginCommand;
|
||||
|
||||
public ReloadCommand() {
|
||||
pluginCommand = Main.me.getCommand("reload");
|
||||
pluginCommand.setTabCompleter(this);
|
||||
pluginCommand.setExecutor(this);
|
||||
}
|
||||
|
||||
public List<String> onTabComplete(CommandSender sender,
|
||||
Command command,
|
||||
String alias,
|
||||
String[] args) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender,
|
||||
Command command,
|
||||
String alias,
|
||||
String[] args) {
|
||||
try {
|
||||
Main.me.onDisable();
|
||||
Main.me.onEnable();
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
Main.me.onJoin(new PlayerJoinEvent(p, ""));
|
||||
|
||||
sender.sendMessage("Перезагрузка успешно завершена");
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
StringWriter buffer = new StringWriter();
|
||||
PrintWriter writer = new PrintWriter(buffer);
|
||||
e.printStackTrace(writer);
|
||||
sender.sendMessage(buffer.toString());
|
||||
}
|
||||
sender.sendMessage("При выполнении команды возникла неизвестная ошибка");
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user