Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
Etzelia | d9a1a0fbe9 |
36
.drone.yml
36
.drone.yml
|
@ -1,36 +0,0 @@
|
|||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: compliance
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: maven:3-openjdk-16
|
||||
commands:
|
||||
- mvn install
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: release
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
event:
|
||||
- push
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: maven:3-openjdk-16
|
||||
commands:
|
||||
- mvn install
|
||||
- name: gitea-release
|
||||
pull: always
|
||||
image: jolheiser/drone-gitea-main:latest
|
||||
settings:
|
||||
token:
|
||||
from_secret: gitea_token
|
||||
base: https://git.canopymc.net
|
||||
files:
|
||||
- "target/QoL-*.jar"
|
59
pom.xml
59
pom.xml
|
@ -3,7 +3,7 @@
|
|||
<groupId>xyz.etztech</groupId>
|
||||
<artifactId>QoL</artifactId>
|
||||
<!-- Version is used in plugin.yml -->
|
||||
<version>1.17</version>
|
||||
<version>1.9</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<!-- Plugin Information -->
|
||||
|
@ -31,43 +31,30 @@
|
|||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.16.3-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xyz.etztech</groupId>
|
||||
<artifactId>plugin-api</artifactId>
|
||||
<version>1.0.7</version>
|
||||
<artifactId>EtzCore</artifactId>
|
||||
<version>1.0.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>EssentialsX</artifactId>
|
||||
<version>2.17.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>us.dynmap</groupId>
|
||||
<artifactId>dynmap-api</artifactId>
|
||||
<version>3.5</version>
|
||||
<scope>provided</scope>
|
||||
<version>1.9.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.discordsrv</groupId>
|
||||
<artifactId>discordsrv</artifactId>
|
||||
<version>1.27.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.lucko</groupId>
|
||||
<artifactId>spark-api</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nisovin.shopkeepers</groupId>
|
||||
<artifactId>ShopkeepersAPI</artifactId>
|
||||
<version>2.13.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
|
@ -76,16 +63,16 @@
|
|||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>Scarsz-Nexus</id>
|
||||
<url>https://nexus.scarsz.me/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>birbmc-repo</id>
|
||||
<url>https://mvn.jojodev.com</url>
|
||||
<id>etztech-repo</id>
|
||||
<url>http://repo.etztech.xyz</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>dynmap-repo</id>
|
||||
<url>https://repo.mikeprimm.com/</url>
|
||||
<url>http://repo.mikeprimm.com/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>ess-repo</id>
|
||||
<url>https://ci.ender.zone/plugin/repository/everything/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>mvn-repo</id>
|
||||
|
@ -93,20 +80,12 @@
|
|||
</repository>
|
||||
<repository> <!-- This repo fixes issues with transitive dependencies -->
|
||||
<id>jcenter</id>
|
||||
<url>https://jcenter.bintray.com</url>
|
||||
<url>http://jcenter.bintray.com</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sonatype-snapshots</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>shopkeepers-repo</id>
|
||||
<url>https://repo.projectshard.dev/repository/releases/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
package xyz.etztech.qol;
|
||||
|
||||
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
|
||||
import github.scarsz.discordsrv.DiscordSRV;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.dynmap.DynmapAPI;
|
||||
import org.dynmap.markers.Marker;
|
||||
|
@ -17,9 +15,7 @@ import org.dynmap.markers.MarkerSet;
|
|||
import xyz.etztech.qol.commands.*;
|
||||
import xyz.etztech.qol.listeners.*;
|
||||
import xyz.etztech.qol.other.LinkCommand;
|
||||
import xyz.etztech.qol.other.Reminder;
|
||||
import xyz.etztech.qol.other.TPSRunnable;
|
||||
import me.lucko.spark.api.Spark;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -32,7 +28,7 @@ public class QoL extends JavaPlugin {
|
|||
private String qolMarkerIcon = null;
|
||||
|
||||
private static QoL instance;
|
||||
private Spark spark = null;
|
||||
private IEssentials essentials = null;
|
||||
private DynmapAPI dynmap = null;
|
||||
private MarkerAPI markerAPI = null;
|
||||
private MarkerSet playerMarkerSet = null;
|
||||
|
@ -49,19 +45,16 @@ public class QoL extends JavaPlugin {
|
|||
private static List<String> audits = new ArrayList<>();
|
||||
private static List<LinkCommand> links = new ArrayList<>();
|
||||
|
||||
private Reminder reminder = null;
|
||||
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
saveDefaultConfig();
|
||||
reloadConfig();
|
||||
saveResource("qol.png", true);
|
||||
|
||||
//Spark hook
|
||||
RegisteredServiceProvider<Spark> sparkProvider = Bukkit.getServicesManager().getRegistration(Spark.class);
|
||||
if (sparkProvider != null) {
|
||||
log("Hooked into Spark for TPS alert.");
|
||||
spark = sparkProvider.getProvider();
|
||||
//Essentials hook
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("Essentials")) {
|
||||
log("Hooked into Essentials for TPS alert.");
|
||||
essentials = (IEssentials) Bukkit.getPluginManager().getPlugin("Essentials");
|
||||
}
|
||||
|
||||
//Dynmap hook
|
||||
|
@ -91,17 +84,6 @@ public class QoL extends JavaPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
// DiscordSRV Hook
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("DiscordSRV")) {
|
||||
new DiscordSRVListener(this);
|
||||
}
|
||||
|
||||
// Shopkeepers Hook
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("Shopkeepers")) {
|
||||
new HeadShopListener(this);
|
||||
log("Hooked in Shopkeepers for the head shop");
|
||||
}
|
||||
|
||||
if( isEnabled() ) {
|
||||
|
||||
// Add listeners
|
||||
|
@ -112,7 +94,6 @@ public class QoL extends JavaPlugin {
|
|||
new BlockIgniteListener(this);
|
||||
new CommandPreprocessListener(this);
|
||||
new DeathListener(this);
|
||||
new EntityChangeBlockListener(this);
|
||||
|
||||
// Add commands
|
||||
new MainCommand(this);
|
||||
|
@ -129,12 +110,6 @@ public class QoL extends JavaPlugin {
|
|||
new DeathMuteCommand(this);
|
||||
new CheckupCommand(this);
|
||||
new DynmapLinkCommand(this);
|
||||
new WikiCommand(this);
|
||||
new MoonCommand(this);
|
||||
|
||||
if (DiscordSRV.api.isAnyHooked()) {
|
||||
new DiscordIgnoreCommand(this);
|
||||
}
|
||||
|
||||
if (dynmap != null) {
|
||||
new MarkerCommand(this);
|
||||
|
@ -157,17 +132,25 @@ public class QoL extends JavaPlugin {
|
|||
}, 0, EtzTechUtil.minutesToTicks(schedule));
|
||||
}
|
||||
|
||||
if (reminder != null && reminder.getFrequency() != 0) {
|
||||
// Reminders
|
||||
int frequency = config.getInt("reminders.frequency");
|
||||
if (frequency > 0) {
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(QoL.getInstance(), new Runnable() {
|
||||
int idx = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
BaseComponent [] msg = reminder.nextReminder();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
player.spigot().sendMessage(msg);
|
||||
List<String> reminders = config.getStringList("reminders.messages");
|
||||
ChatColor color = ChatColor.getByChar(config.getString("reminders.color").replace("&", ""));
|
||||
if (idx >= reminders.size()) {
|
||||
idx = 0;
|
||||
}
|
||||
Bukkit.getConsoleSender().spigot().sendMessage(msg);
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
EtzTechUtil.sms(player, color + reminders.get(idx));
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
}, 0, EtzTechUtil.minutesToTicks(reminder.getFrequency()));
|
||||
}, 0, EtzTechUtil.minutesToTicks(frequency));
|
||||
}
|
||||
|
||||
// TPS Check
|
||||
|
@ -199,8 +182,6 @@ public class QoL extends JavaPlugin {
|
|||
qolMarkerIcon = config.getString("dynmap.marker_icon", "blueflag");
|
||||
qolMarkerLayerShow = config.getBoolean("dynmap.marker_set_show", false);
|
||||
qolMarkerSetLabel = config.getString("dynmap.marker_set_label", "QoL Markers");
|
||||
|
||||
reminder = Reminder.fromConfig(config.getConfigurationSection("reminders"));
|
||||
}
|
||||
|
||||
|
||||
|
@ -297,6 +278,8 @@ public class QoL extends JavaPlugin {
|
|||
return links;
|
||||
}
|
||||
|
||||
public IEssentials getEssentials() { return essentials; }
|
||||
|
||||
public DynmapAPI getDynmap() { return dynmap; }
|
||||
|
||||
public void runTask(final String command) {
|
||||
|
@ -349,9 +332,5 @@ public class QoL extends JavaPlugin {
|
|||
return marker;
|
||||
}
|
||||
}
|
||||
|
||||
public Spark getSpark() {
|
||||
return spark;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
package xyz.etztech.qol.commands;
|
||||
|
||||
import github.scarsz.discordsrv.DiscordSRV;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import xyz.etztech.qol.EtzTechUtil;
|
||||
import xyz.etztech.qol.Lang;
|
||||
import xyz.etztech.qol.QoL;
|
||||
|
||||
public class DiscordIgnoreCommand implements CommandExecutor {
|
||||
public static final String DISCORD_IGNORE_METADATA = "qol.discord_ignore";
|
||||
QoL plugin;
|
||||
|
||||
public DiscordIgnoreCommand(QoL plugin) {
|
||||
this.plugin = plugin;
|
||||
plugin.getCommand("discordignore").setExecutor(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
|
||||
if (!( commandSender instanceof Player)) {
|
||||
EtzTechUtil.sms(commandSender, Lang.NO_CONSOLE.getDef());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!commandSender.hasPermission("qol.discordignore")) {
|
||||
EtzTechUtil.sms(commandSender, Lang.NO_PERMISSION.getDef());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!DiscordSRV.api.isAnyHooked()) {
|
||||
EtzTechUtil.sms(commandSender, "Command not enabled!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) commandSender;
|
||||
|
||||
boolean ignoreState = player.hasMetadata(DISCORD_IGNORE_METADATA);
|
||||
String msg;
|
||||
if (ignoreState) {
|
||||
player.removeMetadata(DISCORD_IGNORE_METADATA, plugin);
|
||||
msg = "Discord messages will now appear.";
|
||||
}
|
||||
else {
|
||||
player.setMetadata(DISCORD_IGNORE_METADATA, new FixedMetadataValue(plugin, DISCORD_IGNORE_METADATA));
|
||||
msg = "Ignoring Discord messages.";
|
||||
}
|
||||
|
||||
EtzTechUtil.sms(commandSender, org.bukkit.ChatColor.GREEN + msg);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package xyz.etztech.qol.commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import xyz.etztech.qol.QoL;
|
||||
import xyz.etztech.qol.EtzTechUtil;
|
||||
import xyz.etztech.qol.Lang;
|
||||
|
||||
import java.util.Map;
|
||||
import java.lang.*;
|
||||
|
||||
public class MoonCommand implements CommandExecutor {
|
||||
QoL plugin;
|
||||
|
||||
private final Map<Integer, String> moonPhases = Map.of(
|
||||
0, "Full moon",
|
||||
1, "Waning gibbous",
|
||||
2, "Third quarter",
|
||||
3, "Waning crescent",
|
||||
4, "New moon",
|
||||
5, "Waxing crescent",
|
||||
6, "First quarter",
|
||||
7, "Waxing gibbous"
|
||||
);
|
||||
|
||||
public MoonCommand(QoL paramQoL) {
|
||||
this.plugin = paramQoL;
|
||||
plugin.getCommand("moon").setExecutor(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
|
||||
if (!commandSender.hasPermission("qol.moon")) {
|
||||
EtzTechUtil.sms(commandSender, Lang.NO_PERMISSION.getDef());
|
||||
return true;
|
||||
}
|
||||
|
||||
String playername = commandSender.getName();
|
||||
long time = commandSender.getServer().getPlayer(playername).getWorld().getFullTime();
|
||||
double day = Math.floor(time / 24000);
|
||||
int moonPhase = (int)(day % 8);
|
||||
|
||||
StringBuilder message = new StringBuilder(ChatColor.GOLD + "===== Moon Phase Utility =====");
|
||||
message.append("\n" + ChatColor.GREEN + "Current moon phase: " + moonPhases.get(moonPhase) + ".");
|
||||
message.append("\n" + ChatColor.GREEN + "Full moon is " + (moonPhase == 0 ? "tonight." : "in " + (8 - moonPhase) + ((moonPhase == 7) ? " day." : " days.")));
|
||||
EtzTechUtil.sms(commandSender, message.toString());
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -9,9 +9,7 @@ import org.bukkit.entity.Player;
|
|||
import xyz.etztech.qol.EtzTechUtil;
|
||||
import xyz.etztech.qol.Lang;
|
||||
import xyz.etztech.qol.QoL;
|
||||
import xyz.etztech.core.command.TickDuration;
|
||||
|
||||
import java.time.Duration;
|
||||
import xyz.etztech.qol.other.ShadowMuteTime;
|
||||
|
||||
public class ShadowMuteCommand implements CommandExecutor {
|
||||
|
||||
|
@ -45,16 +43,16 @@ public class ShadowMuteCommand implements CommandExecutor {
|
|||
|
||||
final Player player = argPlayer;
|
||||
|
||||
TickDuration duration;
|
||||
ShadowMuteTime smt;
|
||||
try {
|
||||
duration = TickDuration.parse(args[1]);
|
||||
smt = ShadowMuteTime.parse(args[1]);
|
||||
} catch (Exception ex) {
|
||||
duration = new TickDuration(Duration.ofMinutes(5));
|
||||
smt = new ShadowMuteTime();
|
||||
commandSender.sendMessage(ChatColor.RED + ex.getMessage());
|
||||
}
|
||||
|
||||
EtzTechUtil.sms(commandSender, ChatColor.GREEN + "Shadow Muting " + ChatColor.YELLOW +
|
||||
player.getName() + ChatColor.GREEN + " for " + ChatColor.YELLOW + duration.getDuration().toMinutes() + "minutes.");
|
||||
player.getName() + ChatColor.GREEN + " for " + ChatColor.YELLOW + smt.toString());
|
||||
QoL.addSM(player);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
|
@ -63,7 +61,7 @@ public class ShadowMuteCommand implements CommandExecutor {
|
|||
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "Removing Shadow Mute for " + ChatColor.YELLOW + player.getName());
|
||||
QoL.removeSM(player);
|
||||
}
|
||||
}, duration.toTicks());
|
||||
}, smt.toTicks());
|
||||
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
package xyz.etztech.qol.commands;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import xyz.etztech.qol.QoL;
|
||||
import xyz.etztech.qol.EtzTechUtil;
|
||||
import xyz.etztech.qol.Lang;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class WikiCommand implements TabExecutor {
|
||||
QoL plugin;
|
||||
|
||||
public WikiCommand(QoL paramQoL) {
|
||||
this.plugin = paramQoL;
|
||||
plugin.getCommand("wiki").setExecutor(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
|
||||
if (!commandSender.hasPermission("qol.wiki")) {
|
||||
EtzTechUtil.sms(commandSender, Lang.NO_PERMISSION.getDef());
|
||||
return true;
|
||||
}
|
||||
if (args.length < 1) {
|
||||
EtzTechUtil.sms(commandSender, ChatColor.RED + "Please give a search argument.");
|
||||
return true;
|
||||
}
|
||||
|
||||
String query = String.join(" ", args);
|
||||
List<List<String>> result = getWikiResults(query, 1);
|
||||
|
||||
if (result.isEmpty())
|
||||
{
|
||||
EtzTechUtil.sms(commandSender, ChatColor.RED + String.format("Nothing was found on the wiki using: %s", query));
|
||||
return true;
|
||||
}
|
||||
|
||||
String message = ChatColor.GREEN + result.get(0).get(0) + ": " + ChatColor.WHITE + result.get(0).get(1);
|
||||
EtzTechUtil.sms(commandSender, message);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender commandSender, Command command, String label, String[] args) {
|
||||
String query = String.join(" ", args);
|
||||
|
||||
if (query.isEmpty()) return null;
|
||||
|
||||
List<List<String>> results = getWikiResults(query, 10);
|
||||
|
||||
if (results.isEmpty()) return null;
|
||||
|
||||
List<String> completions = new ArrayList<>();
|
||||
results.forEach((result) -> completions.add(result.get(0)));
|
||||
return completions;
|
||||
}
|
||||
|
||||
private List<List<String>> getWikiResults(String query, Integer numOfResults) {
|
||||
try {
|
||||
InputStream response = new URL(String.format(plugin.getConfig().getString("wiki-base-url", "https://minecraft.wiki:") + "/api.php?action=opensearch&format=json&formatversion=2&search=%s&namespace=0&limit=%d", query, numOfResults)).openStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(response));
|
||||
JsonArray jsonArray = new JsonParser().parse(reader.readLine()).getAsJsonArray();
|
||||
|
||||
JsonArray names = jsonArray.get(1).getAsJsonArray();
|
||||
JsonArray links = jsonArray.get(3).getAsJsonArray();
|
||||
|
||||
// Check if we got any result
|
||||
if (names.size() < 1)
|
||||
return Collections.emptyList();
|
||||
|
||||
List<List<String>> results = new ArrayList<>();
|
||||
for (int i = 0; i < names.size(); i++)
|
||||
{
|
||||
List<String> e = new ArrayList<>();
|
||||
e.add(names.get(i).getAsString());
|
||||
e.add(links.get(i).getAsString());
|
||||
results.add(e);
|
||||
}
|
||||
|
||||
return results;
|
||||
} catch(Exception e) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.server.ServerCommandEvent;
|
||||
import org.dynmap.DynmapAPI;
|
||||
import xyz.etztech.core.web.Http;
|
||||
import xyz.etztech.core.web.CoreWeb;
|
||||
import xyz.etztech.qol.QoL;
|
||||
import xyz.etztech.qol.other.LinkCommand;
|
||||
|
||||
|
@ -163,7 +163,7 @@ public class CommandPreprocessListener implements Listener {
|
|||
Map<String, String> post = new HashMap<>();
|
||||
post.put("username", username);
|
||||
post.put("content", content);
|
||||
Http.asyncPost(plugin, webhook, post);
|
||||
CoreWeb.asyncPost(plugin, webhook, post);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
package xyz.etztech.qol.listeners;
|
||||
|
||||
import github.scarsz.discordsrv.DiscordSRV;
|
||||
import github.scarsz.discordsrv.api.events.DiscordGuildMessagePreBroadcastEvent;
|
||||
import github.scarsz.discordsrv.api.events.GameChatMessagePreProcessEvent;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import xyz.etztech.qol.EtzTechUtil;
|
||||
import xyz.etztech.qol.Lang;
|
||||
import xyz.etztech.qol.QoL;
|
||||
import github.scarsz.discordsrv.api.Subscribe;
|
||||
import xyz.etztech.qol.commands.DiscordIgnoreCommand;
|
||||
|
||||
public class DiscordSRVListener {
|
||||
private final QoL plugin;
|
||||
|
||||
public DiscordSRVListener(QoL plugin) {
|
||||
this.plugin = plugin;
|
||||
DiscordSRV.api.subscribe(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void gameChatMessagePreProcess(GameChatMessagePreProcessEvent event) {
|
||||
if (QoL.hasSM(event.getPlayer())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void discordGuildMessagePreBroadcastEvent(DiscordGuildMessagePreBroadcastEvent event) {
|
||||
event.getRecipients().removeIf(recipient -> {
|
||||
if (recipient instanceof Player) {
|
||||
Player player = (Player) recipient;
|
||||
|
||||
return player.hasMetadata(DiscordIgnoreCommand.DISCORD_IGNORE_METADATA);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package xyz.etztech.qol.listeners;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import xyz.etztech.qol.QoL;
|
||||
|
||||
public class EntityChangeBlockListener implements Listener {
|
||||
QoL plugin;
|
||||
|
||||
public EntityChangeBlockListener(QoL plugin) {
|
||||
this.plugin = plugin;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
|
||||
if (e.getEntity().getType() == EntityType.ENDERMAN) {
|
||||
if(plugin.getConfig().getBoolean("disable-mob-grief.enderman", false)){
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
package xyz.etztech.qol.listeners;
|
||||
|
||||
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
|
||||
import com.nisovin.shopkeepers.api.shopkeeper.ShopkeeperRegistry;
|
||||
import com.nisovin.shopkeepers.api.shopkeeper.admin.regular.RegularAdminShopkeeper;
|
||||
import com.nisovin.shopkeepers.api.shopkeeper.offers.TradeOffer;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import xyz.etztech.qol.QoL;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HeadShopListener implements Listener{
|
||||
|
||||
private final QoL plugin;
|
||||
private final ShopkeepersPlugin shopkeepersAPI;
|
||||
|
||||
public HeadShopListener(QoL plugin) {
|
||||
this.plugin = plugin;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
|
||||
this.shopkeepersAPI = ShopkeepersPlugin.getInstance();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
if (shopkeepersAPI != null && player.hasPermission("qol.head_shop")) {
|
||||
int shopKeeperID = plugin.getConfig().getInt("head_shop.id", -1);
|
||||
|
||||
if (shopKeeperID != -1) {
|
||||
ShopkeeperRegistry shopkeeperRegistry = shopkeepersAPI.getShopkeeperRegistry();
|
||||
RegularAdminShopkeeper donorHeadShop = (RegularAdminShopkeeper) shopkeeperRegistry.getShopkeeperById(shopKeeperID);
|
||||
|
||||
if (donorHeadShop != null) {
|
||||
// Remove the head if it already exists. This is done to refresh the skin of the head.
|
||||
List<? extends TradeOffer> tradeOffers = new ArrayList<>(donorHeadShop.getOffers());
|
||||
tradeOffers.removeIf(tradeOffer -> {
|
||||
SkullMeta itemOfferMeta = (SkullMeta)tradeOffer.getResultItem().getItemMeta();
|
||||
return itemOfferMeta.getOwningPlayer().getUniqueId() == player.getUniqueId();
|
||||
});
|
||||
|
||||
donorHeadShop.setOffers(tradeOffers);
|
||||
|
||||
// Add the head to the shop
|
||||
int diamondPrice = plugin.getConfig().getInt("head_shop.price", 2);
|
||||
ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD);
|
||||
SkullMeta skullMeta = (SkullMeta) playerHead.getItemMeta();
|
||||
|
||||
skullMeta.setOwningPlayer(player);
|
||||
skullMeta.setDisplayName(player.getDisplayName());
|
||||
playerHead.setItemMeta(skullMeta);
|
||||
|
||||
TradeOffer donorHeadTrade = TradeOffer.create(playerHead, new ItemStack(Material.DIAMOND, diamondPrice), null);
|
||||
|
||||
donorHeadShop.addOffer(donorHeadTrade);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,10 +2,13 @@ package xyz.etztech.qol.listeners;
|
|||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.dynmap.markers.Marker;
|
||||
import xyz.etztech.qol.QoL;
|
||||
import xyz.etztech.qol.commands.CheckupCommand;
|
||||
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
package xyz.etztech.qol.other;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Reminder {
|
||||
private final int frequency;
|
||||
private final List<ReminderList> reminderLists;
|
||||
|
||||
public Reminder(int frequency, List<ReminderList> reminderLists) {
|
||||
this.frequency = frequency;
|
||||
this.reminderLists = reminderLists;
|
||||
Collections.sort(reminderLists);
|
||||
}
|
||||
|
||||
public static Reminder fromConfig(ConfigurationSection config) {
|
||||
int frequency = config.getInt("frequency");
|
||||
List<ReminderList> reminderLists = new ArrayList();
|
||||
ConfigurationSection reminderGroups = config.getConfigurationSection("reminder_groups");
|
||||
|
||||
for (String groupName: reminderGroups.getKeys(false)) {
|
||||
ConfigurationSection group = reminderGroups.getConfigurationSection(groupName);
|
||||
|
||||
int period = group.getInt("period", 0);
|
||||
ChatColor color = ChatColor.of(group.getString("color", "#3273DC"));
|
||||
List<String> reminders = group.getStringList("reminders");
|
||||
|
||||
reminderLists.add(new ReminderList(reminders, period, color));
|
||||
}
|
||||
|
||||
return new Reminder(frequency, reminderLists);
|
||||
}
|
||||
|
||||
public BaseComponent[] nextReminder() {
|
||||
BaseComponent[] msg = null;
|
||||
boolean reminderFound = false;
|
||||
for (ReminderList reminderList: reminderLists) {
|
||||
if (!reminderFound && reminderList.isReady()) {
|
||||
msg = new ComponentBuilder().
|
||||
color(reminderList.getColor())
|
||||
.append(reminderList.nextReminder())
|
||||
.create();
|
||||
|
||||
reminderFound = true;
|
||||
|
||||
}
|
||||
|
||||
reminderList.incCount();
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
public int getFrequency() {
|
||||
return frequency;
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package xyz.etztech.qol.other;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReminderList implements Comparable<ReminderList>{
|
||||
private final List<String> reminders;
|
||||
private final int period;
|
||||
private final ChatColor color;
|
||||
private int ndx;
|
||||
private int count;
|
||||
|
||||
public ReminderList(List<String> reminders, int period, ChatColor color) {
|
||||
this.reminders = reminders;
|
||||
this.period = period;
|
||||
this.color = color;
|
||||
this.ndx = 0;
|
||||
this.count = 0;
|
||||
}
|
||||
|
||||
public void incCount() {
|
||||
count = (count + 1) % (period + 1);
|
||||
}
|
||||
|
||||
public boolean isReady() {
|
||||
return count == period;
|
||||
}
|
||||
|
||||
public String nextReminder() {
|
||||
String nextReminder = reminders.get(ndx);
|
||||
ndx = (ndx + 1) % reminders.size();
|
||||
|
||||
return nextReminder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull ReminderList o) {
|
||||
return Integer.compare(o.period, this.period);
|
||||
}
|
||||
|
||||
public ChatColor getColor() {
|
||||
return color;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
package xyz.etztech.qol.other;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ShadowMuteTime {
|
||||
|
||||
private int hours;
|
||||
private int minutes;
|
||||
private int seconds;
|
||||
|
||||
public ShadowMuteTime() {
|
||||
hours = 1;
|
||||
minutes = 0;
|
||||
seconds = 0;
|
||||
}
|
||||
|
||||
public int getHours() {
|
||||
return hours;
|
||||
}
|
||||
|
||||
public void setHours(int hours) {
|
||||
this.hours = hours;
|
||||
}
|
||||
|
||||
public void addHours(int hours) {
|
||||
this.hours += hours;
|
||||
}
|
||||
|
||||
public int getMinutes() {
|
||||
return minutes;
|
||||
}
|
||||
|
||||
public void setMinutes(int minutes) {
|
||||
this.minutes = minutes;
|
||||
}
|
||||
|
||||
public void addMinutes(int minutes) {
|
||||
this.minutes += minutes;
|
||||
}
|
||||
|
||||
public int getSeconds() {
|
||||
return seconds;
|
||||
}
|
||||
|
||||
public void setSeconds(int seconds) {
|
||||
this.seconds = seconds;
|
||||
}
|
||||
|
||||
public void addSeconds(int seconds) {
|
||||
this.seconds += seconds;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getHours() + " hours, " + getMinutes() + " minutes, and " + getSeconds() + " seconds";
|
||||
}
|
||||
|
||||
public long toTicks() {
|
||||
int seconds = getSeconds();
|
||||
seconds += getMinutes()*60;
|
||||
seconds += getHours()*60*60;
|
||||
return seconds*20;
|
||||
}
|
||||
|
||||
public static ShadowMuteTime parse(String time) throws Exception {
|
||||
ShadowMuteTime smt = new ShadowMuteTime();
|
||||
smt.setHours(0); // Defaults to 1 hour
|
||||
String timePattern = "(?:(?<hours>\\d+)h)?(?:(?<minutes>\\d+)m)?(?:(?<seconds>\\d+)s)?";
|
||||
Pattern pattern = Pattern.compile(timePattern);
|
||||
Matcher match = pattern.matcher(time);
|
||||
|
||||
if (!match.matches()) {
|
||||
throw new Exception("Time format does not match, defaulting to 1 hour.");
|
||||
}
|
||||
|
||||
String hourString = match.group("hours");
|
||||
if (hourString != null) {
|
||||
int hours = Integer.parseInt(hourString);
|
||||
smt.addHours(hours);
|
||||
}
|
||||
|
||||
String minuteString = match.group("minutes");
|
||||
if (minuteString != null) {
|
||||
int minutes = Integer.parseInt(minuteString);
|
||||
if (minutes >= 60) {
|
||||
int toHours = minutes / 60;
|
||||
minutes %= 60;
|
||||
smt.addHours(toHours);
|
||||
}
|
||||
smt.addMinutes(minutes);
|
||||
}
|
||||
|
||||
String secondString = match.group("seconds");
|
||||
if (secondString != null) {
|
||||
int seconds = Integer.parseInt(secondString);
|
||||
if (seconds >= 60) {
|
||||
int toMinutes = seconds / 60;
|
||||
seconds %= 60;
|
||||
int minutes = smt.getMinutes() + toMinutes;
|
||||
if (minutes >= 60) {
|
||||
int toHours = minutes / 60;
|
||||
minutes %= 60;
|
||||
smt.addHours(toHours);
|
||||
}
|
||||
smt.addMinutes(minutes);
|
||||
}
|
||||
smt.addSeconds(seconds);
|
||||
}
|
||||
|
||||
return smt;
|
||||
}
|
||||
}
|
|
@ -1,11 +1,9 @@
|
|||
package xyz.etztech.qol.other;
|
||||
|
||||
import me.lucko.spark.api.statistic.StatisticWindow;
|
||||
import me.lucko.spark.api.statistic.types.DoubleStatistic;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import xyz.etztech.core.web.Http;
|
||||
import xyz.etztech.core.web.CoreWeb;
|
||||
import xyz.etztech.qol.QoL;
|
||||
import me.lucko.spark.api.Spark;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -20,19 +18,19 @@ public class TPSRunnable implements Runnable {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
Spark spark = plugin.getSpark();
|
||||
if (spark != null) {
|
||||
DoubleStatistic<StatisticWindow.TicksPerSecond> tps = spark.tps();
|
||||
IEssentials essentials = plugin.getEssentials();
|
||||
if (essentials != null) {
|
||||
double tps = essentials.getTimer().getAverageTPS();
|
||||
int threshold = plugin.getConfig().getInt("tps.threshold", 0);
|
||||
String webhook = plugin.getConfig().getString("tps.webhook", "");
|
||||
String message = "@here TPS has fallen below " + threshold + "!";
|
||||
if (tps.poll(StatisticWindow.TicksPerSecond.SECONDS_10) < threshold) {
|
||||
if (tps < threshold) {
|
||||
plugin.log(message);
|
||||
if (StringUtils.isNotEmpty(webhook)) {
|
||||
Map<String, String> data = new HashMap<>();
|
||||
data.put("username", "TPS Alert");
|
||||
data.put("content", message);
|
||||
Http.asyncPost(plugin, webhook, data);
|
||||
CoreWeb.asyncPost(plugin, webhook, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,19 +60,10 @@ schedule:
|
|||
|
||||
# To disable, set minutes to 0
|
||||
reminders:
|
||||
frequency: 1 # In minutes
|
||||
reminder_groups:
|
||||
standard:
|
||||
color: '#3273DC'
|
||||
reminders:
|
||||
- '1st Standard Reminder'
|
||||
- '2nd Standard Reminder'
|
||||
event:
|
||||
color: '#3273DC'
|
||||
period: 2
|
||||
reminders:
|
||||
- '1st Event Reminder'
|
||||
- '2nd Event Reminder'
|
||||
frequency: 5 # In minutes
|
||||
color: '&a'
|
||||
messages:
|
||||
- 'Check out the Discord!'
|
||||
|
||||
# A list of links for link command aliases, separated by a comma between name and URL
|
||||
links:
|
||||
|
@ -93,9 +84,6 @@ disable-fire:
|
|||
ender_crystal: false
|
||||
explosion: false
|
||||
|
||||
disable-mob-grief:
|
||||
enderman: false
|
||||
|
||||
# A list of commands to confirm before using if the user isn't in spectator mode
|
||||
spec-confirm:
|
||||
- "tp"
|
||||
|
@ -116,13 +104,3 @@ dynmap:
|
|||
defaults:
|
||||
map: "surface"
|
||||
zoom: 5
|
||||
|
||||
# Shopkeepers Player Head Shop
|
||||
head_shop:
|
||||
# Shopkeeper Shop ID, set to -1 to disable
|
||||
id: -1
|
||||
# Diamond price of a head in the shop, default is 2 diamonds
|
||||
price: 2
|
||||
|
||||
# Base URL for the /wiki command. Should support a https://www.mediawiki.org/wiki/API:Opensearch request
|
||||
wiki-base-url: 'https://minecraft.wiki'
|
||||
|
|
|
@ -4,14 +4,13 @@ description: ${description}
|
|||
author: ${author}
|
||||
website: ${url}
|
||||
main: ${mainClass}
|
||||
softdepend: [spark, dynmap, DiscordSRV, Shopkeepers]
|
||||
api-version: 1.13
|
||||
softdepend: [Essentials, dynmap]
|
||||
commands:
|
||||
qol:
|
||||
description: Base command
|
||||
colors:
|
||||
description: See all color/formatting codes
|
||||
aliases: [color, c, colour, colours]
|
||||
aliases: [color, c]
|
||||
list:
|
||||
description: See a list of players
|
||||
aliases: [players, playerlist]
|
||||
|
@ -47,13 +46,6 @@ commands:
|
|||
marker:
|
||||
description: Dynmap marker command
|
||||
aliases: [mark]
|
||||
wiki:
|
||||
description: Search the Minecraft wiki
|
||||
moon:
|
||||
description: Get information about the current moon phase
|
||||
discordignore:
|
||||
description: Mute chat messages coming from Discord
|
||||
aliases: [dignore]
|
||||
permissions:
|
||||
qol.admin:
|
||||
description: Ability to reload the plugin
|
||||
|
@ -124,15 +116,3 @@ permissions:
|
|||
default: op
|
||||
children:
|
||||
qol.marker.limit: true
|
||||
qol.wiki:
|
||||
description: Ability to use the wiki command
|
||||
default: op
|
||||
qol.moon:
|
||||
description: Ability to use the moon command
|
||||
default: op
|
||||
qol.discordignore:
|
||||
description: Ability to use the use the discordignore command
|
||||
default: op
|
||||
qol.head_shop:
|
||||
description: Controls if a player's head should be added to the head shop
|
||||
default: op
|
||||
|
|
Loading…
Reference in New Issue