mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-26 17:05:01 +00:00
Merge pull request #340 from AtlasMediaGroup/merge/main/development
Main -> Development Pro Max
This commit is contained in:
commit
1364b551d8
2
.github/workflows/codacy-analysis.yml
vendored
2
.github/workflows/codacy-analysis.yml
vendored
@ -25,7 +25,7 @@ jobs:
|
|||||||
|
|
||||||
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
|
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
|
||||||
- name: Run Codacy Analysis CLI
|
- name: Run Codacy Analysis CLI
|
||||||
uses: codacy/codacy-analysis-cli-action@v4.2.0
|
uses: codacy/codacy-analysis-cli-action@v4
|
||||||
with:
|
with:
|
||||||
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
|
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
|
||||||
# You can also omit the token and run the tools that support default configurations
|
# You can also omit the token and run the tools that support default configurations
|
||||||
|
2
.github/workflows/codeql-analysis.yml
vendored
2
.github/workflows/codeql-analysis.yml
vendored
@ -38,7 +38,7 @@ jobs:
|
|||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup Java JDK
|
- name: Setup Java JDK
|
||||||
uses: actions/setup-java@v3.9.0
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
# The Java version to make available on the path. Takes a whole or semver Java version, or 1.x syntax (e.g. 1.8 => Java 8.x). Early access versions can be specified in the form of e.g. 14-ea, 14.0.0-ea, or 14.0.0-ea.28
|
# The Java version to make available on the path. Takes a whole or semver Java version, or 1.x syntax (e.g. 1.8 => Java 8.x). Early access versions can be specified in the form of e.g. 14-ea, 14.0.0-ea, or 14.0.0-ea.28
|
||||||
java-version: 17
|
java-version: 17
|
||||||
|
2
.github/workflows/java17-maven.yml
vendored
2
.github/workflows/java17-maven.yml
vendored
@ -13,7 +13,7 @@ jobs:
|
|||||||
|
|
||||||
# Java 16 Builds
|
# Java 16 Builds
|
||||||
- name: Set up JDK 17
|
- name: Set up JDK 17
|
||||||
uses: actions/setup-java@v3.9.0
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
java-version: 17
|
java-version: 17
|
||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -39,3 +39,6 @@ manifest.mf
|
|||||||
ehthumbs.db
|
ehthumbs.db
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
.idea/inspectionProfiles/Project_Default.xml
|
.idea/inspectionProfiles/Project_Default.xml
|
||||||
|
|
||||||
|
# Common working directory
|
||||||
|
run/
|
36
pom.xml
36
pom.xml
@ -65,11 +65,6 @@
|
|||||||
<url>https://maven.elmakers.com/repository/</url>
|
<url>https://maven.elmakers.com/repository/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
<repository>
|
|
||||||
<id>sk89q-snapshots</id>
|
|
||||||
<url>https://maven.sk89q.com/artifactory/repo</url>
|
|
||||||
</repository>
|
|
||||||
|
|
||||||
<repository>
|
<repository>
|
||||||
<id>dv8tion</id>
|
<id>dv8tion</id>
|
||||||
<name>m2-dv8tion</name>
|
<name>m2-dv8tion</name>
|
||||||
@ -91,11 +86,6 @@
|
|||||||
<url>https://repo.dmulloy2.net/nexus/repository/public/</url>
|
<url>https://repo.dmulloy2.net/nexus/repository/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
<repository>
|
|
||||||
<id>sk89q-repo</id>
|
|
||||||
<url>https://maven.sk89q.com/repo/</url>
|
|
||||||
</repository>
|
|
||||||
|
|
||||||
<repository>
|
<repository>
|
||||||
<id>esentialsx-repo</id>
|
<id>esentialsx-repo</id>
|
||||||
<url>https://repo.essentialsx.net/releases/</url>
|
<url>https://repo.essentialsx.net/releases/</url>
|
||||||
@ -108,7 +98,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>2.11.0</version>
|
<version>2.13.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -122,7 +112,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bstats</groupId>
|
<groupId>org.bstats</groupId>
|
||||||
<artifactId>bstats-bukkit</artifactId>
|
<artifactId>bstats-bukkit</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.0.2</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -157,28 +147,28 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.dv8tion</groupId>
|
<groupId>net.dv8tion</groupId>
|
||||||
<artifactId>JDA</artifactId>
|
<artifactId>JDA</artifactId>
|
||||||
<version>4.4.0_352</version>
|
<version>4.4.1_353</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.coreprotect</groupId>
|
<groupId>net.coreprotect</groupId>
|
||||||
<artifactId>coreprotect</artifactId>
|
<artifactId>coreprotect</artifactId>
|
||||||
<version>21.2</version>
|
<version>21.3</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q.worldguard</groupId>
|
<groupId>com.sk89q.worldguard</groupId>
|
||||||
<artifactId>worldguard-bukkit</artifactId>
|
<artifactId>worldguard-bukkit</artifactId>
|
||||||
<version>7.0.7</version>
|
<version>7.0.8</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.papermc</groupId>
|
<groupId>io.papermc</groupId>
|
||||||
<artifactId>paperlib</artifactId>
|
<artifactId>paperlib</artifactId>
|
||||||
<version>1.0.7</version>
|
<version>1.0.8</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -192,7 +182,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.essentialsx</groupId>
|
<groupId>net.essentialsx</groupId>
|
||||||
<artifactId>EssentialsX</artifactId>
|
<artifactId>EssentialsX</artifactId>
|
||||||
<version>2.19.6</version>
|
<version>2.20.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -213,21 +203,21 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains</groupId>
|
<groupId>org.jetbrains</groupId>
|
||||||
<artifactId>annotations</artifactId>
|
<artifactId>annotations</artifactId>
|
||||||
<version>23.0.0</version>
|
<version>24.0.1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
<version>3.1.2</version>
|
<version>3.3.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter</artifactId>
|
<artifactId>junit-jupiter</artifactId>
|
||||||
<version>5.9.0</version>
|
<version>5.10.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -259,7 +249,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.10.1</version>
|
<version>3.11.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<outputFileName>TotalFreedomMod.jar</outputFileName>
|
<outputFileName>TotalFreedomMod.jar</outputFileName>
|
||||||
<compilerVersion>17</compilerVersion>
|
<compilerVersion>17</compilerVersion>
|
||||||
@ -363,7 +353,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>buildnumber-maven-plugin</artifactId>
|
<artifactId>buildnumber-maven-plugin</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.2.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>generate-resources</phase>
|
<phase>generate-resources</phase>
|
||||||
@ -388,7 +378,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>3.4.1</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
|
@ -46,8 +46,13 @@ public class ChatManager extends FreedomService
|
|||||||
private void handleChatEvent(AsyncPlayerChatEvent event)
|
private void handleChatEvent(AsyncPlayerChatEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
String message = event.getMessage().trim();
|
String originalMessage = event.getMessage();
|
||||||
|
if (plugin.mu.onPlayerChat(player) || plugin.sh.handlePlayerChat(player, originalMessage))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String message = originalMessage.trim();
|
||||||
// Format colors and strip &k
|
// Format colors and strip &k
|
||||||
message = FUtil.colorize(message);
|
message = FUtil.colorize(message);
|
||||||
message = message.replaceAll(ChatColor.MAGIC.toString(), "&k");
|
message = message.replaceAll(ChatColor.MAGIC.toString(), "&k");
|
||||||
@ -82,6 +87,8 @@ public class ChatManager extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugin.dc.onPlayerChat(player, ChatColor.stripColor(message));
|
||||||
|
|
||||||
// Check for 4chan trigger
|
// Check for 4chan trigger
|
||||||
if (ConfigEntry.FOURCHAN_ENABLED.getBoolean())
|
if (ConfigEntry.FOURCHAN_ENABLED.getBoolean())
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
@ -23,7 +23,7 @@ public class CommandSpy extends FreedomService
|
|||||||
{
|
{
|
||||||
server.getOnlinePlayers().stream().filter(player -> plugin.al.isAdmin(player)
|
server.getOnlinePlayers().stream().filter(player -> plugin.al.isAdmin(player)
|
||||||
&& plugin.al.getAdmin(player).getCommandSpy() && player != event.getPlayer()).forEach(player ->
|
&& plugin.al.getAdmin(player).getCommandSpy() && player != event.getPlayer()).forEach(player ->
|
||||||
player.sendMessage(Component.text(event.getPlayer().getName()).append(Component.text(": "))
|
player.sendMessage(Component.text(event.getPlayer().getName(), NamedTextColor.GRAY).append(Component.text(": ", NamedTextColor.GRAY))
|
||||||
.append(Component.text(event.getMessage()))));
|
.append(Component.text(event.getMessage(), NamedTextColor.GRAY))));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod;
|
|||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -11,7 +10,6 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
public class Muter extends FreedomService
|
public class Muter extends FreedomService
|
||||||
@ -26,26 +24,23 @@ public class Muter extends FreedomService
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
public boolean onPlayerChat(Player player)
|
||||||
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
|
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
|
||||||
|
|
||||||
FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
||||||
|
|
||||||
if (!fPlayer.isMuted())
|
if (!fPlayer.isMuted())
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.al.isAdminSync(player))
|
if (plugin.al.isAdminSync(player))
|
||||||
{
|
{
|
||||||
fPlayer.setMuted(false);
|
fPlayer.setMuted(false);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(Component.text("You are muted.", NamedTextColor.RED));
|
player.sendMessage(Component.text("You are muted.", NamedTextColor.RED));
|
||||||
event.setCancelled(true);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
@ -66,8 +66,13 @@ public class ActivityLogEntry implements IConfig
|
|||||||
|
|
||||||
public void addLogin()
|
public void addLogin()
|
||||||
{
|
{
|
||||||
Date currentTime = Date.from(Instant.now());
|
this.addLogin(System.currentTimeMillis());
|
||||||
timestamps.add("Login: " + FUtil.dateToString(currentTime));
|
}
|
||||||
|
|
||||||
|
public void addLogin(final long timestamp)
|
||||||
|
{
|
||||||
|
Date time = Date.from(Instant.ofEpochMilli(timestamp));
|
||||||
|
timestamps.add("Login: " + FUtil.dateToString(time));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addLogout()
|
public void addLogout()
|
||||||
|
@ -194,6 +194,15 @@ public class AdminList extends FreedomService
|
|||||||
// Save admin
|
// Save admin
|
||||||
plugin.sql.addAdmin(admin);
|
plugin.sql.addAdmin(admin);
|
||||||
|
|
||||||
|
// Add login time
|
||||||
|
UUID uuid = admin.getUuid();
|
||||||
|
Player player = Bukkit.getPlayer(uuid);
|
||||||
|
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
plugin.acl.getActivityLog(player).addLogin(player.getLastLogin());
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +274,8 @@ public class AdminList extends FreedomService
|
|||||||
ResultSet currentSave = plugin.sql.getAdminByUuid(admin.getUuid());
|
ResultSet currentSave = plugin.sql.getAdminByUuid(admin.getUuid());
|
||||||
for (Map.Entry<String, Object> entry : admin.toSQLStorable().entrySet())
|
for (Map.Entry<String, Object> entry : admin.toSQLStorable().entrySet())
|
||||||
{
|
{
|
||||||
Object storedValue = plugin.sql.getValue(currentSave, entry.getKey(), entry.getValue()); if (storedValue != null && !storedValue.equals(entry.getValue()) || storedValue == null && entry.getValue() != null || entry.getValue() == null)
|
Object storedValue = plugin.sql.getValue(currentSave, entry.getKey(), entry.getValue());
|
||||||
|
if (storedValue != null && !storedValue.equals(entry.getValue()) || storedValue == null && entry.getValue() != null || entry.getValue() == null)
|
||||||
{
|
{
|
||||||
plugin.sql.setAdminValue(admin, entry.getKey(), entry.getValue());
|
plugin.sql.setAdminValue(admin, entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import me.totalfreedom.totalfreedommod.FreedomService;
|
|||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
@ -26,7 +27,7 @@ public class InteractBlocker extends FreedomService
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onPlayerInteract(PlayerInteractEvent event)
|
public void onPlayerInteract(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
switch (event.getAction())
|
switch (event.getAction())
|
||||||
@ -69,6 +70,10 @@ public class InteractBlocker extends FreedomService
|
|||||||
private void handleRightClick(PlayerInteractEvent event)
|
private void handleRightClick(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
if (player.getGameMode().equals(GameMode.SPECTATOR)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final Block clickedBlock = event.getClickedBlock();
|
final Block clickedBlock = event.getClickedBlock();
|
||||||
|
|
||||||
if (clickedBlock != null && clickedBlock.getType() == Material.RESPAWN_ANCHOR && !ConfigEntry.ALLOW_RESPAWN_ANCHORS.getBoolean())
|
if (clickedBlock != null && clickedBlock.getType() == Material.RESPAWN_ANCHOR && !ConfigEntry.ALLOW_RESPAWN_ANCHORS.getBoolean())
|
||||||
|
@ -30,24 +30,6 @@ public class CommandBlocker extends FreedomService
|
|||||||
private final Map<String, CommandBlockerEntry> entryList = Maps.newHashMap();
|
private final Map<String, CommandBlockerEntry> entryList = Maps.newHashMap();
|
||||||
private final List<String> unknownCommands = Lists.newArrayList();
|
private final List<String> unknownCommands = Lists.newArrayList();
|
||||||
|
|
||||||
public static CommandMap getCommandMap()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
SimplePluginManager simplePluginManager = (SimplePluginManager)Bukkit.getServer().getPluginManager();
|
|
||||||
|
|
||||||
Field commandMapField = SimplePluginManager.class.getDeclaredField("commandMap");
|
|
||||||
commandMapField.setAccessible(true);
|
|
||||||
|
|
||||||
return (SimpleCommandMap)commandMapField.get(simplePluginManager);
|
|
||||||
}
|
|
||||||
catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e)
|
|
||||||
{
|
|
||||||
FLog.severe("Failed to get command map field (" + e.getMessage() + ")");
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
@ -65,7 +47,7 @@ public class CommandBlocker extends FreedomService
|
|||||||
entryList.clear();
|
entryList.clear();
|
||||||
unknownCommands.clear();
|
unknownCommands.clear();
|
||||||
|
|
||||||
final CommandMap commandMap = getCommandMap();
|
final CommandMap commandMap = Bukkit.getCommandMap();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<String> blockedCommands = (List<String>)ConfigEntry.BLOCKED_COMMANDS.getList();
|
List<String> blockedCommands = (List<String>)ConfigEntry.BLOCKED_COMMANDS.getList();
|
||||||
|
@ -6,7 +6,6 @@ import me.totalfreedom.totalfreedommod.FreedomService;
|
|||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -14,7 +13,6 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@ -129,7 +127,7 @@ public class EssentialsBridge extends FreedomService
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
User user = getEssentialsUser(username);
|
User user = getEssentialsUser(username);
|
||||||
if (user != null)
|
if (user != null && user.getBase().isOnline())
|
||||||
{
|
{
|
||||||
user.setVanished(vanished);
|
user.setVanished(vanished);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -8,11 +10,28 @@ import org.bukkit.OfflinePlayer;
|
|||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME, blockHostConsole = true)
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME, blockHostConsole = true)
|
||||||
@CommandParameters(description = "Report a player for all admins to see.", usage = "/<command> <player> <reason>")
|
@CommandParameters(description = "Report a player for all admins to see.", usage = "/<command> <player> <reason>")
|
||||||
public class Command_report extends FreedomCommand
|
public class Command_report extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
private void handleLog(final @Nullable Boolean value, final @Nullable Throwable ex, final CommandSender sender)
|
||||||
|
{
|
||||||
|
if (ex != null)
|
||||||
|
{
|
||||||
|
sender.sendMessage(Component.text("An error occurred while attempting to log your previously filed report to a Discord channel.", NamedTextColor.RED));
|
||||||
|
ex.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Boolean.FALSE.equals(value))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(Component.text("The report you previously filed has been successfully logged to a Discord channel. Please note that spamming reports is not allowed, and you will be sanctioned if you are found to be doing it.", NamedTextColor.GRAY));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
@ -50,18 +69,16 @@ public class Command_report extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
String report = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
String report = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||||
plugin.cm.reportAction(playerSender, (player == null) ? offlinePlayer.getName() : player.getName(), report);
|
String reportedUsername = (player == null) ? offlinePlayer.getName() : player.getName();
|
||||||
|
plugin.cm.reportAction(playerSender, reportedUsername, report);
|
||||||
|
|
||||||
boolean logged = false;
|
msg(ChatColor.GREEN + "Thank you, your report is being processed.");
|
||||||
|
|
||||||
if (plugin.dc.enabled)
|
if (plugin.dc.enabled)
|
||||||
{
|
{
|
||||||
logged = (player == null) ? plugin.dc.sendReportOffline(playerSender, offlinePlayer, report) : plugin.dc.sendReport(playerSender, player, report);
|
plugin.dc.sendReport(playerSender.getName(), reportedUsername, report).whenCompleteAsync((logged, ex) -> handleLog(logged, ex, sender));
|
||||||
}
|
}
|
||||||
|
|
||||||
msg(ChatColor.GREEN + "Thank you, your report has been successfully logged."
|
|
||||||
+ (logged ? ChatColor.RED + "\nNote: This report has been logged to a discord channel, as with any report system, spamming reports can lead to you getting banned." : ""));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,10 +3,7 @@ package me.totalfreedom.totalfreedommod.discord;
|
|||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||||
import javax.security.auth.login.LoginException;
|
import javax.security.auth.login.LoginException;
|
||||||
@ -26,11 +23,9 @@ import net.dv8tion.jda.api.entities.Guild;
|
|||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||||
import net.dv8tion.jda.api.entities.PrivateChannel;
|
|
||||||
import net.dv8tion.jda.api.entities.Role;
|
import net.dv8tion.jda.api.entities.Role;
|
||||||
import net.dv8tion.jda.api.entities.SelfUser;
|
import net.dv8tion.jda.api.entities.SelfUser;
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
import net.dv8tion.jda.api.entities.TextChannel;
|
||||||
import net.dv8tion.jda.api.entities.User;
|
|
||||||
import net.dv8tion.jda.api.events.ReadyEvent;
|
import net.dv8tion.jda.api.events.ReadyEvent;
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
import net.dv8tion.jda.api.requests.GatewayIntent;
|
import net.dv8tion.jda.api.requests.GatewayIntent;
|
||||||
@ -42,16 +37,18 @@ import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
|||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.apache.commons.lang.WordUtils;
|
import org.apache.commons.lang.WordUtils;
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameRule;
|
import org.bukkit.GameRule;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class Discord extends FreedomService
|
public class Discord extends FreedomService
|
||||||
{
|
{
|
||||||
@ -282,12 +279,6 @@ public class Discord extends FreedomService
|
|||||||
{
|
{
|
||||||
String newMessage = message;
|
String newMessage = message;
|
||||||
|
|
||||||
if (message.contains("@"))
|
|
||||||
{
|
|
||||||
// \u200B is Zero Width Space, invisible on Discord
|
|
||||||
newMessage = message.replaceAll("@", "@\u200B");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message.toLowerCase().contains("discord.gg")) // discord.gg/invite works as an invite
|
if (message.toLowerCase().contains("discord.gg")) // discord.gg/invite works as an invite
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
@ -303,10 +294,10 @@ public class Discord extends FreedomService
|
|||||||
|
|
||||||
if (message.contains("§"))
|
if (message.contains("§"))
|
||||||
{
|
{
|
||||||
newMessage = message.replaceAll("§", "");
|
newMessage = message.replace("§", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
return deformat(newMessage);
|
return newMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void messageChatChannel(String message)
|
public void messageChatChannel(String message)
|
||||||
@ -324,7 +315,7 @@ public class Discord extends FreedomService
|
|||||||
|
|
||||||
if (enabled && !chat_channel_id.isEmpty())
|
if (enabled && !chat_channel_id.isEmpty())
|
||||||
{
|
{
|
||||||
CompletableFuture<Message> sentMessage = Objects.requireNonNull(bot.getTextChannelById(chat_channel_id)).sendMessage(sanitizedMessage).submit(true);
|
CompletableFuture<Message> sentMessage = Objects.requireNonNull(bot.getTextChannelById(chat_channel_id)).sendMessage(sanitizedMessage).allowedMentions(Collections.emptyList()).submit(true);
|
||||||
sentMessages.add(sentMessage);
|
sentMessages.add(sentMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +335,7 @@ public class Discord extends FreedomService
|
|||||||
|
|
||||||
if (enabled && !chat_channel_id.isEmpty())
|
if (enabled && !chat_channel_id.isEmpty())
|
||||||
{
|
{
|
||||||
CompletableFuture<Message> sentMessage = Objects.requireNonNull(bot.getTextChannelById(chat_channel_id)).sendMessage(sanitizedMessage).submit(true);
|
CompletableFuture<Message> sentMessage = Objects.requireNonNull(bot.getTextChannelById(chat_channel_id)).sendMessage(sanitizedMessage).allowedMentions(Collections.emptyList()).submit(true);
|
||||||
sentMessages.add(sentMessage);
|
sentMessages.add(sentMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -402,7 +393,9 @@ public class Discord extends FreedomService
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean sendReportOffline(Player reporter, OfflinePlayer reported, String reason)
|
public CompletableFuture<Boolean> sendReport(String reporterName, String reportedName, String reason)
|
||||||
|
{
|
||||||
|
return CompletableFuture.supplyAsync(() ->
|
||||||
{
|
{
|
||||||
if (!shouldISendReport())
|
if (!shouldISendReport())
|
||||||
{
|
{
|
||||||
@ -425,73 +418,49 @@ public class Discord extends FreedomService
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final EmbedBuilder embedBuilder = new EmbedBuilder();
|
Player onlinePlayer = Bukkit.getPlayer(reportedName);
|
||||||
embedBuilder.setTitle("Report for " + reported.getName() + " (offline)");
|
boolean online = onlinePlayer != null;
|
||||||
embedBuilder.setDescription(reason);
|
|
||||||
embedBuilder.setFooter("Reported by " + reporter.getName(), "https://minotar.net/helm/" + reporter.getName() + ".png");
|
|
||||||
embedBuilder.setTimestamp(Instant.from(ZonedDateTime.now()));
|
|
||||||
if (plugin.esb.isEnabled())
|
|
||||||
{
|
|
||||||
com.earth2me.essentials.User user = plugin.esb.getEssentialsUser(reported.getName());
|
|
||||||
String location = "World: " + Objects.requireNonNull(user.getLastLocation().getWorld()).getName() + ", X: " + user.getLastLocation().getBlockX() + ", Y: " + user.getLastLocation().getBlockY() + ", Z: " + user.getLastLocation().getBlockZ();
|
|
||||||
embedBuilder.addField("Location", location, true);
|
|
||||||
embedBuilder.addField("God Mode", WordUtils.capitalizeFully(String.valueOf(user.isGodModeEnabled())), true);
|
|
||||||
if (user.getNickname() != null)
|
|
||||||
{
|
|
||||||
embedBuilder.addField("Nickname", user.getNickname(), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MessageEmbed embed = embedBuilder.build();
|
|
||||||
Message message = channel.sendMessageEmbeds(embed).complete();
|
|
||||||
|
|
||||||
if (!ConfigEntry.DISCORD_REPORT_ARCHIVE_CHANNEL_ID.getString().isEmpty())
|
|
||||||
{
|
|
||||||
message.addReaction("\uD83D\uDCCB").complete();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean sendReport(Player reporter, Player reported, String reason)
|
|
||||||
{
|
|
||||||
if (!shouldISendReport())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Guild server = bot.getGuildById(ConfigEntry.DISCORD_SERVER_ID.getString());
|
|
||||||
|
|
||||||
if (server == null)
|
|
||||||
{
|
|
||||||
FLog.severe("The guild ID specified in the config is invalid.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final TextChannel channel = server.getTextChannelById(ConfigEntry.DISCORD_REPORT_CHANNEL_ID.getString());
|
|
||||||
|
|
||||||
if (channel == null)
|
|
||||||
{
|
|
||||||
FLog.severe("The report channel ID specified in the config is invalid.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final EmbedBuilder embedBuilder = new EmbedBuilder();
|
final EmbedBuilder embedBuilder = new EmbedBuilder();
|
||||||
embedBuilder.setTitle("Report for " + reported.getName());
|
embedBuilder.setTitle("Report for " + reportedName + (online ? "" : " (offline)"));
|
||||||
embedBuilder.setDescription(reason);
|
embedBuilder.setDescription(reason);
|
||||||
embedBuilder.setFooter("Reported by " + reporter.getName(), "https://minotar.net/helm/" + reporter.getName() + ".png");
|
embedBuilder.setFooter("Reported by " + reporterName, "https://minotar.net/helm/" + reporterName + ".png");
|
||||||
embedBuilder.setTimestamp(Instant.from(ZonedDateTime.now()));
|
embedBuilder.setTimestamp(Instant.from(ZonedDateTime.now()));
|
||||||
String location = "World: " + Objects.requireNonNull(reported.getLocation().getWorld()).getName() + ", X: " + reported.getLocation().getBlockX() + ", Y: " + reported.getLocation().getBlockY() + ", Z: " + reported.getLocation().getBlockZ();
|
|
||||||
embedBuilder.addField("Location", location, true);
|
Location location = null;
|
||||||
embedBuilder.addField("Game Mode", WordUtils.capitalizeFully(reported.getGameMode().name()), true);
|
Boolean godMode = null;
|
||||||
|
String nickName = null;
|
||||||
|
|
||||||
if (plugin.esb.isEnabled())
|
if (plugin.esb.isEnabled())
|
||||||
{
|
{
|
||||||
com.earth2me.essentials.User user = plugin.esb.getEssentialsUser(reported.getName());
|
com.earth2me.essentials.User user = plugin.esb.getEssentialsUser(reportedName);
|
||||||
embedBuilder.addField("God Mode", WordUtils.capitalizeFully(String.valueOf(user.isGodModeEnabled())), true);
|
if (!online)
|
||||||
if (user.getNickname() != null)
|
|
||||||
{
|
{
|
||||||
embedBuilder.addField("Nickname", user.getNickname(), true);
|
location = user.getLastLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
godMode = user.isGodModeEnabled();
|
||||||
|
nickName = user.getNickname();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (location == null && online)
|
||||||
|
{
|
||||||
|
location = onlinePlayer.getLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (location != null)
|
||||||
|
{
|
||||||
|
embedBuilder.addField("Location", "World: " + location.getWorld().getName() + ", X: " + location.getBlockX() + ", Y: " + location.getBlockY() + ", Z: " + location.getBlockZ(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (godMode != null)
|
||||||
|
{
|
||||||
|
embedBuilder.addField("God Mode", WordUtils.capitalizeFully(godMode.toString()), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nickName != null)
|
||||||
|
{
|
||||||
|
embedBuilder.addField("Nickname", nickName, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageEmbed embed = embedBuilder.build();
|
MessageEmbed embed = embedBuilder.build();
|
||||||
@ -503,6 +472,7 @@ public class Discord extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}, t -> Bukkit.getScheduler().runTaskAsynchronously(plugin, t));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do no ask why this is here. I spent two hours trying to make a simple thing work
|
// Do no ask why this is here. I spent two hours trying to make a simple thing work
|
||||||
@ -514,16 +484,28 @@ public class Discord extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
public void onPlayerChat(Player player, String message)
|
||||||
public void onAsyncPlayerChat(AsyncPlayerChatEvent event)
|
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
||||||
String message = event.getMessage();
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ConfigEntry.ADMIN_ONLY_MODE.getBoolean() && !server.hasWhitelist()
|
if (server.hasWhitelist())
|
||||||
&& !plugin.pl.getPlayer(player).isMuted() && bot != null)
|
|
||||||
{
|
{
|
||||||
messageChatChannel(player.getName() + " \u00BB " + ChatColor.stripColor(message));
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (plugin.pl.getPlayer(player).isMuted())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bot == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
messageChatChannel(deformat(player.getName()) + " \u00BB " + ChatColor.stripColor(message));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -58,9 +58,8 @@ public class DiscordToMinecraftListener extends ListenerAdapter
|
|||||||
final Message msg = event.getMessage();
|
final Message msg = event.getMessage();
|
||||||
final String content = msg.getContentStripped();
|
final String content = msg.getContentStripped();
|
||||||
|
|
||||||
if (content.startsWith(ConfigEntry.DISCORD_PREFIX.getString()))
|
if (content.toLowerCase().startsWith(ConfigEntry.DISCORD_PREFIX.getString().toLowerCase()) && Discord.DISCORD_COMMAND_MANAGER.parse(content, member, textChannel))
|
||||||
{
|
{
|
||||||
Discord.DISCORD_COMMAND_MANAGER.parse(content, member, textChannel);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@ import net.dv8tion.jda.api.entities.TextChannel;
|
|||||||
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
|
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
public class MessageReactionListener extends ListenerAdapter
|
public class MessageReactionListener extends ListenerAdapter
|
||||||
{
|
{
|
||||||
public void onMessageReactionAdd(MessageReactionAddEvent messageReactionAddEvent)
|
public void onMessageReactionAdd(MessageReactionAddEvent messageReactionAddEvent)
|
||||||
@ -59,7 +61,8 @@ public class MessageReactionListener extends ListenerAdapter
|
|||||||
final MessageEmbed embed = message.getEmbeds().get(0);
|
final MessageEmbed embed = message.getEmbeds().get(0);
|
||||||
final MessageBuilder archiveMessageBuilder = new MessageBuilder();
|
final MessageBuilder archiveMessageBuilder = new MessageBuilder();
|
||||||
archiveMessageBuilder.setContent("Report completed by " + completer.getUser().getAsMention() + " (" + Discord.deformat(completer.getUser().getAsTag() + ")"));
|
archiveMessageBuilder.setContent("Report completed by " + completer.getUser().getAsMention() + " (" + Discord.deformat(completer.getUser().getAsTag() + ")"));
|
||||||
archiveMessageBuilder.setEmbed(embed);
|
archiveMessageBuilder.setAllowedMentions(Collections.emptyList());
|
||||||
|
archiveMessageBuilder.setEmbeds(embed);
|
||||||
final Message archiveMessage = archiveMessageBuilder.build();
|
final Message archiveMessage = archiveMessageBuilder.build();
|
||||||
|
|
||||||
archiveChannel.sendMessage(archiveMessage).complete();
|
archiveChannel.sendMessage(archiveMessage).complete();
|
||||||
|
@ -46,11 +46,21 @@ public class DiscordCommandManager
|
|||||||
FLog.info("Loaded " + commands.size() + " Discord commands.");
|
FLog.info("Loaded " + commands.size() + " Discord commands.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void parse(String content, Member member, TextChannel channel)
|
public boolean parse(String content, Member member, TextChannel channel)
|
||||||
{
|
{
|
||||||
List<String> args = new ArrayList<>(Arrays.asList(content.split(" ")));
|
final String actualContent = content.substring(PREFIX.length()).trim();
|
||||||
|
List<String> args = new ArrayList<>(Arrays.asList(actualContent.split(" ")));
|
||||||
|
if (args.isEmpty())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
final String alias = args.remove(0).split(PREFIX)[1]; // The joys of command parsing
|
final String alias = args.get(0);
|
||||||
|
|
||||||
|
if (alias.isEmpty())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for (DiscordCommand command : commands)
|
for (DiscordCommand command : commands)
|
||||||
{
|
{
|
||||||
@ -63,6 +73,7 @@ public class DiscordCommandManager
|
|||||||
final CompletableFuture<Message> futureMessage = channel.sendMessage(message).submit(true);
|
final CompletableFuture<Message> futureMessage = channel.sendMessage(message).submit(true);
|
||||||
|
|
||||||
this.discord.sentMessages.add(futureMessage);
|
this.discord.sentMessages.add(futureMessage);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -71,14 +82,17 @@ public class DiscordCommandManager
|
|||||||
embedBuilder.setTitle("Command error");
|
embedBuilder.setTitle("Command error");
|
||||||
embedBuilder.setColor(Color.RED);
|
embedBuilder.setColor(Color.RED);
|
||||||
embedBuilder.setDescription("You don't have permission to execute this command.");
|
embedBuilder.setDescription("You don't have permission to execute this command.");
|
||||||
messageBuilder.setEmbed(embedBuilder.build());
|
messageBuilder.setEmbeds(embedBuilder.build());
|
||||||
final Message message = messageBuilder.build();
|
final Message message = messageBuilder.build();
|
||||||
|
|
||||||
final CompletableFuture<Message> futureMessage = channel.sendMessage(message).submit(true);
|
final CompletableFuture<Message> futureMessage = channel.sendMessage(message).submit(true);
|
||||||
|
|
||||||
this.discord.sentMessages.add(futureMessage);
|
this.discord.sentMessages.add(futureMessage);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,13 +13,7 @@ import me.totalfreedom.totalfreedommod.player.FPlayer;
|
|||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
import me.totalfreedom.totalfreedommod.shop.ShopItem;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.*;
|
||||||
import org.bukkit.Color;
|
|
||||||
import org.bukkit.FireworkEffect;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.SoundCategory;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.EnderPearl;
|
import org.bukkit.entity.EnderPearl;
|
||||||
@ -95,11 +89,16 @@ public class ItemFun extends FreedomService
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onPlayerEntityInteract(PlayerInteractEntityEvent event)
|
public void onPlayerEntityInteract(PlayerInteractEntityEvent event)
|
||||||
{
|
{
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
if (player.getGameMode().equals(GameMode.SPECTATOR))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Entity entity = event.getRightClicked();
|
Entity entity = event.getRightClicked();
|
||||||
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
@ -412,23 +411,35 @@ public class Shop extends FreedomService
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
public boolean handlePlayerChat(Player player, String message)
|
||||||
public void onPlayerChat(AsyncPlayerChatEvent event)
|
|
||||||
{
|
{
|
||||||
String message = event.getMessage();
|
if (!ConfigEntry.SHOP_ENABLED.getBoolean())
|
||||||
Player player = event.getPlayer();
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (ConfigEntry.SHOP_ENABLED.getBoolean() && ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean()
|
if (!ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean())
|
||||||
&& !plugin.sh.reactionString.isEmpty() && message.equals(plugin.sh.reactionString))
|
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.sh.reactionString.isEmpty())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!message.equals(plugin.sh.reactionString))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
PlayerData data = plugin.pl.getData(player);
|
PlayerData data = plugin.pl.getData(player);
|
||||||
data.setCoins(data.getCoins() + plugin.sh.coinsPerReactionWin);
|
data.setCoins(data.getCoins() + plugin.sh.coinsPerReactionWin);
|
||||||
plugin.pl.save(data);
|
plugin.pl.save(data);
|
||||||
plugin.sh.endReaction(player.getName());
|
plugin.sh.endReaction(player.getName());
|
||||||
player.sendMessage(ChatColor.GREEN + "You have been given " + ChatColor.GOLD
|
player.sendMessage(ChatColor.GREEN + "You have been given " + ChatColor.GOLD
|
||||||
+ plugin.sh.coinsPerReactionWin + ChatColor.GREEN + " coins!");
|
+ plugin.sh.coinsPerReactionWin + ChatColor.GREEN + " coins!");
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShopItem getShopItem(int slot)
|
public ShopItem getShopItem(int slot)
|
||||||
|
@ -90,6 +90,15 @@ public class SQLite extends FreedomService
|
|||||||
{
|
{
|
||||||
FLog.severe("Failed to create the admins table: " + e.getMessage());
|
FLog.severe("Failed to create the admins table: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
connection.createStatement().execute("ALTER TABLE `admins` DROP COLUMN `ptero_id`");
|
||||||
|
} catch (SQLException e)
|
||||||
|
{
|
||||||
|
// Ignore the error. If someone else wants to add WORKING AND TESTED CODE to check if the `ptero_id` column exists, they can, but I couldn't find a good way.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (tableExists(meta, "players"))
|
if (tableExists(meta, "players"))
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,7 @@ import java.time.Instant;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.bukkit.Bukkit.getServer;
|
import static org.bukkit.Bukkit.getServer;
|
||||||
|
|
||||||
@ -144,10 +145,11 @@ public class FUtil
|
|||||||
return (count == 1 ? "" : "s");
|
return (count == 1 ? "" : "s");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("java:S6204")
|
||||||
public static List<String> getPlayerList()
|
public static List<String> getPlayerList()
|
||||||
{
|
{
|
||||||
return getServer().getOnlinePlayers().stream().filter(player ->
|
return getServer().getOnlinePlayers().stream().filter(player ->
|
||||||
!TotalFreedomMod.getPlugin().al.isVanished(player.getUniqueId())).map(HumanEntity::getName).toList();
|
!TotalFreedomMod.getPlugin().al.isVanished(player.getUniqueId())).map(HumanEntity::getName).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String listToString(List<String> list)
|
public static String listToString(List<String> list)
|
||||||
|
Loading…
Reference in New Issue
Block a user