commit message
This commit is contained in:
parent
854e66073e
commit
620be20c10
15
README.md
15
README.md
@ -8,7 +8,7 @@
|
||||
bind_host: 0.0.0.0 # Локальный IP адрес сервера (обычно такой же как и в server.properties)
|
||||
bind_port: 8080 # Свободный порт для сайта (потребуется открыть его на хостинге)
|
||||
|
||||
external_host: example.com # Внешний IP адрес / домен сервера
|
||||
external_host: example.com # Внешний IP адрес или домен сервера
|
||||
|
||||
secret_token: "ваш_секретный_токен" # Секретный токен с FroggyMonitor
|
||||
|
||||
@ -19,14 +19,21 @@ vote: # Награда за голос
|
||||
commands: # Исполнить команды
|
||||
- "/title {player_name} subtitle на FroggyMonitor"
|
||||
- "/title {player_name} title Спасибо за отзыв!"
|
||||
# Каждый параметр наград не обязателен
|
||||
as_player: # Исполнить команды или написать сообщение в чат от лица игрока
|
||||
- "Я проголосовал за сервер и получил награду"
|
||||
- "/me купит себе ламборгини на 10$ с награды"
|
||||
|
||||
# Каждый параметр наград не обязателен, но не должен использоваться больше 1 раза
|
||||
# Указывать предмет вот так: "{название_предмета} {кол_во}"
|
||||
|
||||
add_comment: # Награда за удаление отзыва
|
||||
vault: 10
|
||||
message: "Спасибо за отзыв!"
|
||||
# Тут могут использоваться все параметры из наград за голоса
|
||||
|
||||
del_comment: # Награда за удаление отзыва
|
||||
vault: -10 # Снять валюту
|
||||
vault: -10
|
||||
# Тут могут использоваться все параметры из наград за голоса
|
||||
|
||||
enable_logs: true # Включить логи плагина (true/false); true - вкл; false - выкл
|
||||
|
||||
@ -35,7 +42,7 @@ message_formatting: "ampersand" # Изменить тип форматирова
|
||||
# ampersand: &cСообщение
|
||||
# section: §cСообщение
|
||||
# minimessage: <red>Сообщение</red>
|
||||
# json: {"text": "Сообщение", "color": "red"}
|
||||
# json: {"text": "Сообщение", "color": "red"}
|
||||
```
|
||||
|
||||
## Как это работает
|
||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>ru.froggymonitor</groupId>
|
||||
<artifactId>rewardplugin</artifactId>
|
||||
<version>1.3</version>
|
||||
<version>1.4</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>FroggyMonitorReward</name>
|
||||
|
@ -1,5 +1,7 @@
|
||||
package ru.froggymonitor.rewardplugin;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -57,19 +59,13 @@ public final class Main extends JavaPlugin implements Listener {
|
||||
|
||||
public File cache_file;
|
||||
|
||||
public boolean has_placeholderapi;
|
||||
public boolean has_vault;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (!setupEconomy()) {
|
||||
getLogger().severe("[FroggyMonitorReward] - Disabled due to no Vault dependency found!");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") == null) {
|
||||
getLogger().severe("[FroggyMonitorReward] - Disabled due to no PlaceholderAPI dependency found!");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
has_vault = setupEconomy();
|
||||
has_placeholderapi = Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null;
|
||||
|
||||
me = this;
|
||||
|
||||
@ -108,8 +104,8 @@ public final class Main extends JavaPlugin implements Listener {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
site.stop();
|
||||
saveCache();
|
||||
site.stop();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -193,4 +189,12 @@ public final class Main extends JavaPlugin implements Listener {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public BaseComponent[] formatMessage(Player player, String text) {
|
||||
return Main.me.message_formatting.format(has_placeholderapi ? PlaceholderAPI.setPlaceholders(player, text) : text);
|
||||
}
|
||||
|
||||
public void giveVault(OfflinePlayer player, double amount) {
|
||||
if (has_vault) econ.depositPlayer(player, amount);
|
||||
}
|
||||
}
|
||||
|
@ -26,14 +26,8 @@ public class Reward {
|
||||
Player player = Bukkit.getPlayer(nickname);
|
||||
|
||||
if (player != null) {
|
||||
if (data.containsKey("item")) {
|
||||
String[] ss = ((String)data.get("item")).split(" ");
|
||||
ItemStack item = new ItemStack(Material.valueOf(ss[0].toUpperCase()), ss.length == 1 ? 1 : Integer.parseInt(ss[1]));
|
||||
player.getInventory().addItem(item);
|
||||
}
|
||||
if (data.containsKey("message")) {
|
||||
player.spigot().sendMessage(Main.me.message_formatting.format(PlaceholderAPI.setPlaceholders(player, (String) data.get("message"))));
|
||||
}
|
||||
later(player);
|
||||
} else {
|
||||
Main.me.cache.put(nickname, name);
|
||||
}
|
||||
|
||||
@ -41,7 +35,7 @@ public class Reward {
|
||||
|
||||
if (offlinePlayer != null) {
|
||||
if (data.containsKey("vault")) {
|
||||
Main.me.econ.depositPlayer(offlinePlayer,
|
||||
Main.me.giveVault(offlinePlayer,
|
||||
((Number) data.get("vault")).doubleValue());
|
||||
}
|
||||
if (data.containsKey("commands")) {
|
||||
@ -62,5 +56,10 @@ public class Reward {
|
||||
if (data.containsKey("message")) {
|
||||
player.spigot().sendMessage(Main.me.message_formatting.format(PlaceholderAPI.setPlaceholders(player, (String) data.get("message"))));
|
||||
}
|
||||
if (data.containsKey("as_player")) {
|
||||
for (String c : new ArrayList<>((List<String>) data.get("as_player"))) {
|
||||
player.chat(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
bind_host: 0.0.0.0 # Локальный IP адрес сервера (обычно такой же как и в server.properties)
|
||||
bind_port: 8080 # Свободный порт для сайта (потребуется открыть его на хостинге)
|
||||
|
||||
external_host: example.com # Внешний IP адрес / домен сервера
|
||||
external_host: example.com # Внешний IP адрес или домен сервера
|
||||
|
||||
secret_token: "ваш_секретный_токен" # Секретный токен с FroggyMonitor
|
||||
|
||||
@ -12,14 +12,21 @@ vote: # Награда за голос
|
||||
commands: # Исполнить команды
|
||||
- "/title {player_name} subtitle на FroggyMonitor"
|
||||
- "/title {player_name} title Спасибо за отзыв!"
|
||||
# Каждый параметр наград не обязателен
|
||||
as_player: # Исполнить команды или написать сообщение в чат от лица игрока
|
||||
- "Я проголосовал за сервер и получил награду"
|
||||
- "/me купит себе ламборгини на 10$ с награды"
|
||||
|
||||
# Каждый параметр наград не обязателен, но не должен использоваться больше 1 раза
|
||||
# Указывать предмет вот так: "{название_предмета} {кол_во}"
|
||||
|
||||
add_comment: # Награда за удаление отзыва
|
||||
vault: 10
|
||||
message: "Спасибо за отзыв!"
|
||||
# Тут могут использоваться все параметры из наград за голоса
|
||||
|
||||
del_comment: # Награда за удаление отзыва
|
||||
vault: -10 # Снять валюту
|
||||
vault: -10
|
||||
# Тут могут использоваться все параметры из наград за голоса
|
||||
|
||||
enable_logs: true # Включить логи плагина (true/false); true - вкл; false - выкл
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user