mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-01 04:26:42 +00:00
Compare commits
28 Commits
2022.06.1
...
dependabot
Author | SHA1 | Date | |
---|---|---|---|
3548daa3e5 | |||
8317b1f881 | |||
fc796bd340 | |||
706e9540ce | |||
ac00d36dc6 | |||
a2133369d2 | |||
48728c9524 | |||
d343bbc3d7 | |||
2c357d1d49 | |||
5246639608 | |||
7fb4a477dc | |||
612499ff0a | |||
a332ecfbea | |||
7f78549f9d | |||
21c84d76d3 | |||
88f53c05b9 | |||
51cc527697 | |||
9f8dafb075 | |||
02b2810488 | |||
7e110e8ac6 | |||
6d3f365878 | |||
05bb64ce85 | |||
b05238c51f | |||
7bda4beab0 | |||
97544977b0 | |||
073356be49 | |||
c472c5d5ce | |||
cb401577a4 |
2
.github/workflows/codeql-analysis.yml
vendored
2
.github/workflows/codeql-analysis.yml
vendored
@ -38,7 +38,7 @@ jobs:
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Java JDK
|
||||
uses: actions/setup-java@v3.3.0
|
||||
uses: actions/setup-java@v3.6.0
|
||||
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
|
||||
java-version: 17
|
||||
|
43
.github/workflows/downstream.yml
vendored
43
.github/workflows/downstream.yml
vendored
@ -1,43 +0,0 @@
|
||||
# This is a basic workflow to help you get started with Actions
|
||||
|
||||
name: Downstream Branch Updates
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '20 7 * * *'
|
||||
# scheduled at 07:00 every Monday and Thursday
|
||||
|
||||
workflow_dispatch: # click the button on Github repo!
|
||||
|
||||
|
||||
jobs:
|
||||
sync_with_upstream:
|
||||
runs-on: ubuntu-latest
|
||||
name: Sync main with upstream latest
|
||||
|
||||
steps:
|
||||
# Step 1: run a standard checkout action, provided by github
|
||||
- name: Checkout current development branch
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: development
|
||||
# submodules: 'recursive' ### may be needed in your situation
|
||||
|
||||
# Step 2: run this sync action - specify the upstream repo, upstream branch to sync with, and target sync branch
|
||||
- name: Pull (Fast-Forward) upstream changes
|
||||
id: sync
|
||||
uses: aormsby/Fork-Sync-With-Upstream-action@v3.3
|
||||
with:
|
||||
upstream_repository: AtlasMediaGroup/TotalFreedomMod
|
||||
upstream_branch: main
|
||||
target_branch: development
|
||||
git_pull_args: --ff-only # optional arg use, defaults to simple 'pull'
|
||||
|
||||
# Step 3: Display a message if 'sync' step had new commits (simple test)
|
||||
- name: Check for new commits
|
||||
if: steps.sync.outputs.has_new_commits
|
||||
run: echo "There were new commits."
|
||||
|
||||
# Step 4: Print a helpful timestamp for your records (not required, just nice)
|
||||
- name: Timestamp
|
||||
run: date
|
2
.github/workflows/java17-maven.yml
vendored
2
.github/workflows/java17-maven.yml
vendored
@ -13,7 +13,7 @@ jobs:
|
||||
|
||||
# Java 16 Builds
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3.3.0
|
||||
uses: actions/setup-java@v3.6.0
|
||||
with:
|
||||
java-version: 17
|
||||
distribution: 'adopt'
|
||||
|
26
pom.xml
26
pom.xml
@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>me.totalfreedom</groupId>
|
||||
<artifactId>TotalFreedomMod</artifactId>
|
||||
<version>2022.06.1</version>
|
||||
<version>2022.06</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
@ -100,8 +100,7 @@
|
||||
<id>esentialsx-repo</id>
|
||||
<url>https://repo.essentialsx.net/releases/</url>
|
||||
</repository>
|
||||
|
||||
|
||||
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
@ -128,8 +127,8 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<groupId>me.totalfreedom.scissors</groupId>
|
||||
<artifactId>scissors-api</artifactId>
|
||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
@ -151,7 +150,7 @@
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>worldedit-bukkit</artifactId>
|
||||
<version>7.2.10</version>
|
||||
<version>7.2.12</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@ -193,7 +192,7 @@
|
||||
<dependency>
|
||||
<groupId>net.essentialsx</groupId>
|
||||
<artifactId>EssentialsX</artifactId>
|
||||
<version>2.19.4</version>
|
||||
<version>2.19.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@ -207,17 +206,10 @@
|
||||
<dependency>
|
||||
<groupId>org.javassist</groupId>
|
||||
<artifactId>javassist</artifactId>
|
||||
<version>3.29.0-GA</version>
|
||||
<version>3.29.1-GA</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>me.totalfreedom</groupId>
|
||||
<artifactId>tfguilds</artifactId>
|
||||
<version>2021.06-RC2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
@ -235,7 +227,7 @@
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>5.8.2</version>
|
||||
<version>5.9.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
@ -396,7 +388,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.4.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
|
@ -136,7 +136,7 @@ public class ChatManager extends FreedomService
|
||||
event.setFormat(format);
|
||||
|
||||
// Send to discord
|
||||
if (!ConfigEntry.ADMIN_ONLY_MODE.getBoolean() && !Bukkit.hasWhitelist() && !plugin.pl.getPlayer(player).isMuted() && !plugin.tfg.inGuildChat(player))
|
||||
if (!ConfigEntry.ADMIN_ONLY_MODE.getBoolean() && !Bukkit.hasWhitelist() && !plugin.pl.getPlayer(player).isMuted())
|
||||
{
|
||||
plugin.dc.messageChatChannel(player.getName() + " \u00BB " + ChatColor.stripColor(message));
|
||||
}
|
||||
|
@ -1,34 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.command.Command_sit;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.spigotmc.event.entity.EntityDismountEvent;
|
||||
|
||||
public class Sitter extends FreedomService
|
||||
{
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop()
|
||||
{
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDismount(EntityDismountEvent e)
|
||||
{
|
||||
Entity dm = e.getDismounted();
|
||||
if (dm instanceof ArmorStand)
|
||||
{
|
||||
if (Command_sit.STANDS.contains(dm))
|
||||
{
|
||||
Command_sit.STANDS.remove(dm);
|
||||
dm.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -19,7 +19,6 @@ import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge;
|
||||
import me.totalfreedom.totalfreedommod.bridge.CoreProtectBridge;
|
||||
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
|
||||
import me.totalfreedom.totalfreedommod.bridge.LibsDisguisesBridge;
|
||||
import me.totalfreedom.totalfreedommod.bridge.TFGuildsBridge;
|
||||
import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge;
|
||||
import me.totalfreedom.totalfreedommod.bridge.WorldGuardBridge;
|
||||
import me.totalfreedom.totalfreedommod.caging.Cager;
|
||||
@ -119,7 +118,6 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
public HTTPDaemon hd;
|
||||
public WorldRestrictions wr;
|
||||
public EntityWiper ew;
|
||||
public Sitter st;
|
||||
public VanishHandler vh;
|
||||
public Pterodactyl ptero;
|
||||
//
|
||||
@ -128,7 +126,6 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
public EssentialsBridge esb;
|
||||
public LibsDisguisesBridge ldb;
|
||||
public CoreProtectBridge cpb;
|
||||
public TFGuildsBridge tfg;
|
||||
public WorldEditBridge web;
|
||||
public WorldGuardBridge wgb;
|
||||
|
||||
@ -314,7 +311,6 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
pem = new PermissionManager();
|
||||
gr = new GameRuleHandler();
|
||||
ew = new EntityWiper();
|
||||
st = new Sitter();
|
||||
vh = new VanishHandler();
|
||||
ptero = new Pterodactyl();
|
||||
}
|
||||
@ -342,7 +338,6 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
cpb = new CoreProtectBridge();
|
||||
esb = new EssentialsBridge();
|
||||
ldb = new LibsDisguisesBridge();
|
||||
tfg = new TFGuildsBridge();
|
||||
web = new WorldEditBridge();
|
||||
wgb = new WorldGuardBridge();
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class BlockBlocker extends FreedomService
|
||||
}
|
||||
case STRUCTURE_BLOCK:
|
||||
{
|
||||
if (!ConfigEntry.ALLOW_STRUCTURE_BLOCKS.getBoolean())
|
||||
if (!ConfigEntry.ALLOW_MASTERBLOCKS.getBoolean())
|
||||
{
|
||||
player.sendMessage(ChatColor.GRAY + "Structure blocks are disabled.");
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
@ -81,7 +81,7 @@ public class BlockBlocker extends FreedomService
|
||||
}
|
||||
case JIGSAW:
|
||||
{
|
||||
if (!ConfigEntry.ALLOW_JIGSAWS.getBoolean())
|
||||
if (!ConfigEntry.ALLOW_MASTERBLOCKS.getBoolean())
|
||||
{
|
||||
player.sendMessage(ChatColor.GRAY + "Jigsaws are disabled.");
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
@ -89,6 +89,16 @@ public class BlockBlocker extends FreedomService
|
||||
}
|
||||
break;
|
||||
}
|
||||
case REPEATING_COMMAND_BLOCK:
|
||||
case CHAIN_COMMAND_BLOCK:
|
||||
case COMMAND_BLOCK:
|
||||
if (!ConfigEntry.ALLOW_MASTERBLOCKS.getBoolean())
|
||||
{
|
||||
player.sendMessage(ChatColor.GRAY + "Command blocks are disabled.");
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
break;
|
||||
case GRINDSTONE:
|
||||
{
|
||||
if (!ConfigEntry.ALLOW_GRINDSTONES.getBoolean())
|
||||
|
@ -4,7 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/* TODO This will have to be changed from com.github.atlasmediagroup.scissors to me.totalfreedom.scissors when we migrate to 1.19 */
|
||||
import com.github.atlasmediagroup.scissors.event.block.MasterBlockFireEvent;
|
||||
import io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
@ -20,15 +21,7 @@ import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockDispenseEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockGrowEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.block.LeavesDecayEvent;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
@ -117,6 +110,28 @@ public class EventBlocker extends FreedomService
|
||||
event.setRadius(ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockExplode(BlockExplodeEvent event)
|
||||
{
|
||||
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
event.setYield(ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onMasterBlockFire(MasterBlockFireEvent event)
|
||||
{
|
||||
if (!ConfigEntry.ALLOW_MASTERBLOCKS.getBoolean())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
event.getAt().getBlock().setType(Material.CAKE);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onEntityCombust(EntityCombustEvent event)
|
||||
{
|
||||
@ -150,7 +165,7 @@ public class EventBlocker extends FreedomService
|
||||
Entity entity = event.getEntity();
|
||||
if (entity instanceof Tameable)
|
||||
{
|
||||
if (((Tameable)entity).isTamed())
|
||||
if (((Tameable) entity).isTamed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -69,24 +69,17 @@ public class InteractBlocker extends FreedomService
|
||||
private void handleRightClick(PlayerInteractEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
final Block clickedBlock = event.getClickedBlock();
|
||||
|
||||
if (event.getClickedBlock() != null)
|
||||
if (clickedBlock != null && clickedBlock.getType() == Material.RESPAWN_ANCHOR && !ConfigEntry.ALLOW_RESPAWN_ANCHORS.getBoolean())
|
||||
{
|
||||
if (event.getClickedBlock().getType().equals(Material.STRUCTURE_BLOCK) || event.getClickedBlock().getType().equals(Material.JIGSAW) || event.getClickedBlock().getType().equals(Material.RESPAWN_ANCHOR))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().closeInventory();
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Groups.SPAWN_EGGS.contains(event.getMaterial()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
Block clickedBlock = event.getClickedBlock();
|
||||
if (clickedBlock == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
EntityType eggType = null;
|
||||
try
|
||||
{
|
||||
@ -104,7 +97,7 @@ public class InteractBlocker extends FreedomService
|
||||
{
|
||||
//
|
||||
}
|
||||
if (eggType != null)
|
||||
if (eggType != null && clickedBlock != null)
|
||||
{
|
||||
clickedBlock.getWorld().spawnEntity(clickedBlock.getLocation().add(event.getBlockFace().getDirection()).add(0.5, 0.5, 0.5), eggType);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import org.bukkit.plugin.SimplePluginManager;
|
||||
|
||||
public class CommandBlocker extends FreedomService
|
||||
{
|
||||
private final Pattern whitespacePattern = Pattern.compile("^/?( +)(.*)?");
|
||||
|
||||
private final Pattern flagPattern = Pattern.compile("(:([0-9]){5,})");
|
||||
//
|
||||
private final Map<String, CommandBlockerEntry> entryList = Maps.newHashMap();
|
||||
@ -156,14 +156,6 @@ public class CommandBlocker extends FreedomService
|
||||
|
||||
// Format
|
||||
command = command.toLowerCase().trim();
|
||||
|
||||
// Whitespaces
|
||||
Matcher whitespaceMatcher = whitespacePattern.matcher(command);
|
||||
if (whitespaceMatcher.matches() && whitespaceMatcher.groupCount() == 2)
|
||||
{
|
||||
command = whitespaceMatcher.group(2);
|
||||
}
|
||||
|
||||
command = command.startsWith("/") ? command.substring(1) : command;
|
||||
|
||||
// Check for plugin specific commands
|
||||
|
@ -1,58 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.bridge;
|
||||
|
||||
import me.totalfreedom.tfguilds.Common;
|
||||
import me.totalfreedom.tfguilds.TFGuilds;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class TFGuildsBridge extends FreedomService
|
||||
{
|
||||
public boolean enabled = false;
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop()
|
||||
{
|
||||
}
|
||||
|
||||
public boolean isTFGuildsEnabled()
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final Plugin tfGuilds = server.getPluginManager().getPlugin("TFGuilds");
|
||||
if (tfGuilds != null && tfGuilds.isEnabled())
|
||||
{
|
||||
if (tfGuilds instanceof TFGuilds)
|
||||
{
|
||||
enabled = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NoClassDefFoundError ex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean inGuildChat(Player player)
|
||||
{
|
||||
if (!isTFGuildsEnabled())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return Common.GUILD_CHAT.contains(player);
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.History;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Check the name history of a specified player.", usage = "/<command> <username>", aliases = "nh")
|
||||
public class Command_namehistory extends FreedomCommand
|
||||
{
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
History.reportHistory(sender, args[0]);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Sit at the current place you are at.", usage = "/<command>")
|
||||
public class Command_sit extends FreedomCommand
|
||||
{
|
||||
public static List<ArmorStand> STANDS = new ArrayList<>();
|
||||
|
||||
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||
{
|
||||
if (args.length != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ArmorStand stand = (ArmorStand)playerSender.getWorld().spawnEntity(playerSender.getLocation().clone().subtract(0.0, 1.7, 0.0), EntityType.ARMOR_STAND);
|
||||
stand.setGravity(false);
|
||||
stand.setAI(false);
|
||||
stand.setVisible(false);
|
||||
stand.setInvulnerable(true);
|
||||
stand.addPassenger(playerSender);
|
||||
STANDS.add(stand);
|
||||
msg("You are now sitting.");
|
||||
return true;
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ public class Command_toggle extends FreedomCommand
|
||||
private final List<String> toggles = Arrays.asList(
|
||||
"waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk",
|
||||
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke [range] [count]",
|
||||
"explosives [radius]", "unsafeenchs", "bells", "armorstands", "structureblocks", "jigsaws", "grindstones",
|
||||
"explosives [radius]", "unsafeenchs", "bells", "armorstands", "masterblocks", "grindstones",
|
||||
"jukeboxes", "spawners", "4chan", "beehives", "respawnanchors", "autotp", "autoclear", "minecarts", "mp44",
|
||||
"landmines", "tossmob", "gravity");
|
||||
|
||||
@ -193,15 +193,9 @@ public class Command_toggle extends FreedomCommand
|
||||
break;
|
||||
}
|
||||
|
||||
case "structureblocks":
|
||||
case "masterblocks":
|
||||
{
|
||||
toggle("Structure blocks are", ConfigEntry.ALLOW_STRUCTURE_BLOCKS);
|
||||
break;
|
||||
}
|
||||
|
||||
case "jigsaws":
|
||||
{
|
||||
toggle("Jigsaws are", ConfigEntry.ALLOW_JIGSAWS);
|
||||
toggle("Master blocks are", ConfigEntry.ALLOW_MASTERBLOCKS);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,6 @@ public enum ConfigEntry
|
||||
ALLOW_BELLS(Boolean.class, "allow.bells"),
|
||||
ALLOW_ARMOR_STANDS(Boolean.class, "allow.armorstands"),
|
||||
ALLOW_MINECARTS(Boolean.class, "allow.minecarts"),
|
||||
ALLOW_STRUCTURE_BLOCKS(Boolean.class, "allow.structureblocks"),
|
||||
ALLOW_JIGSAWS(Boolean.class, "allow.jigsaws"),
|
||||
ALLOW_GRINDSTONES(Boolean.class, "allow.grindstones"),
|
||||
ALLOW_JUKEBOXES(Boolean.class, "allow.jukeboxes"),
|
||||
ALLOW_SPAWNERS(Boolean.class, "allow.spawners"),
|
||||
@ -35,6 +33,7 @@ public enum ConfigEntry
|
||||
AUTO_TP(Boolean.class, "allow.auto_tp"),
|
||||
AUTO_CLEAR(Boolean.class, "allow.auto_clear"),
|
||||
ALLOW_GRAVITY(Boolean.class, "allow.gravity"),
|
||||
ALLOW_MASTERBLOCKS(Boolean.class, "allow.masterblocks"),
|
||||
//
|
||||
BLOCKED_CHATCODES(String.class, "blocked_chatcodes"),
|
||||
//
|
||||
|
@ -7,11 +7,8 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.SplittableRandom;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.security.auth.login.LoginException;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@ -41,9 +38,7 @@ import net.dv8tion.jda.api.utils.ChunkingFilter;
|
||||
import net.dv8tion.jda.api.utils.MemberCachePolicy;
|
||||
import net.dv8tion.jda.internal.utils.concurrent.CountingThreadFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.bukkit.GameRule;
|
||||
@ -66,7 +61,6 @@ public class Discord extends FreedomService
|
||||
public List<CompletableFuture<Message>> sentMessages = new ArrayList<>();
|
||||
public Boolean enabled = false;
|
||||
private static final ImmutableList<String> DISCORD_SUBDOMAINS = ImmutableList.of("discordapp.com", "discord.com", "discord.gg");
|
||||
private final Pattern DISCORD_MENTION_PATTERN = Pattern.compile("(<@!?([0-9]{16,20})>)");
|
||||
|
||||
public static String getCode(PlayerData playerData)
|
||||
{
|
||||
@ -209,7 +203,7 @@ public class Discord extends FreedomService
|
||||
catch (NoClassDefFoundError e)
|
||||
{
|
||||
FLog.warning("The JDA plugin is not installed, therefore the discord bot cannot start.");
|
||||
FLog.warning("To resolve this error, please download the latest JDA from: https://github.com/TFPatches/Minecraft-JDA/releases");
|
||||
FLog.warning("To resolve this error, please download the latest JDA from: https://github.com/AtlasMediaGroup/Minecraft-JDA/releases");
|
||||
}
|
||||
|
||||
}
|
||||
@ -277,7 +271,7 @@ public class Discord extends FreedomService
|
||||
|
||||
if (deathMessage != null)
|
||||
{
|
||||
messageChatChannel("**" + PlainTextComponentSerializer.plainText().serialize(deathMessage) + "**", true);
|
||||
messageChatChannel("**" + deformat(PlainTextComponentSerializer.plainText().serialize(deathMessage)) + "**", true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -292,7 +286,7 @@ public class Discord extends FreedomService
|
||||
{
|
||||
if (!plugin.al.isVanished(event.getPlayer().getName()))
|
||||
{
|
||||
messageChatChannel("**" + event.getPlayer().getName() + " joined the server" + "**", true);
|
||||
messageChatChannel("**" + deformat(event.getPlayer().getName()) + " joined the server" + "**", true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -301,7 +295,7 @@ public class Discord extends FreedomService
|
||||
{
|
||||
if (!plugin.al.isVanished(event.getPlayer().getName()))
|
||||
{
|
||||
messageChatChannel("**" + event.getPlayer().getName() + " left the server" + "**", true);
|
||||
messageChatChannel("**" + deformat(event.getPlayer().getName()) + " left the server" + "**", true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -437,8 +431,21 @@ public class Discord extends FreedomService
|
||||
}
|
||||
|
||||
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();
|
||||
embedBuilder.setTitle("Report for " + reported.getName() + " (offline)");
|
||||
embedBuilder.setDescription(reason);
|
||||
@ -456,7 +463,7 @@ public class Discord extends FreedomService
|
||||
}
|
||||
}
|
||||
MessageEmbed embed = embedBuilder.build();
|
||||
Message message = channel.sendMessage(embed).complete();
|
||||
Message message = channel.sendMessageEmbeds(embed).complete();
|
||||
|
||||
if (!ConfigEntry.DISCORD_REPORT_ARCHIVE_CHANNEL_ID.getString().isEmpty())
|
||||
{
|
||||
@ -474,8 +481,21 @@ public class Discord extends FreedomService
|
||||
}
|
||||
|
||||
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();
|
||||
embedBuilder.setTitle("Report for " + reported.getName());
|
||||
embedBuilder.setDescription(reason);
|
||||
@ -496,7 +516,7 @@ public class Discord extends FreedomService
|
||||
}
|
||||
|
||||
MessageEmbed embed = embedBuilder.build();
|
||||
Message message = channel.sendMessage(embed).complete();
|
||||
Message message = channel.sendMessageEmbeds(embed).complete();
|
||||
|
||||
if (!ConfigEntry.DISCORD_REPORT_ARCHIVE_CHANNEL_ID.getString().isEmpty())
|
||||
{
|
||||
|
@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.discord;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.discord.command.DiscordCommandManager;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.rank.Title;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
|
@ -7,7 +7,7 @@ public abstract class DiscordCommandImpl implements DiscordCommand
|
||||
@Override
|
||||
public boolean canExecute(Member member)
|
||||
{
|
||||
//return !isAdmin() || member.getRoles().stream().filter((role -> role.getName().toLowerCase().contains("admin") && !role.getName().toLowerCase().contains("discord"))).toList().size() > 0;
|
||||
// TODO Implement administrator checks if/when any administrative Discord commands are added to the bot
|
||||
return !isAdmin();
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,6 @@ public class HelpCommand extends DiscordCommandImpl
|
||||
embedBuilder.addField(category, fieldValue.toString().trim(), false);
|
||||
}
|
||||
|
||||
return new MessageBuilder().setEmbed(embedBuilder.build());
|
||||
return new MessageBuilder().setEmbeds(embedBuilder.build());
|
||||
}
|
||||
}
|
||||
|
@ -3,16 +3,14 @@ package me.totalfreedom.totalfreedommod.discord.commands;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.discord.command.DiscordCommand;
|
||||
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||
import me.totalfreedom.totalfreedommod.discord.command.DiscordCommandImpl;
|
||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||
import me.totalfreedom.totalfreedommod.rank.RankManager;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -82,13 +80,14 @@ public class ListCommand extends DiscordCommandImpl
|
||||
|
||||
Displayable displayable = rankManager.getDisplay(onlinePlayer);
|
||||
|
||||
final String name = Discord.deformat(onlinePlayer.getName());
|
||||
|
||||
if (displayables.containsKey(displayable))
|
||||
{
|
||||
displayables.get(displayable).add(onlinePlayer.getName());
|
||||
}
|
||||
else
|
||||
displayables.get(displayable).add(name);
|
||||
} else
|
||||
{
|
||||
displayables.put(displayable, new ArrayList<>(List.of(onlinePlayer.getName())));
|
||||
displayables.put(displayable, new ArrayList<>(List.of(name)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,6 +100,6 @@ public class ListCommand extends DiscordCommandImpl
|
||||
String.join(", ", players), false);
|
||||
}
|
||||
|
||||
return new MessageBuilder().setEmbed(embedBuilder.build());
|
||||
return new MessageBuilder().setEmbeds(embedBuilder.build());
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,11 @@
|
||||
package me.totalfreedom.totalfreedommod.discord.commands;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.discord.command.DiscordCommand;
|
||||
import me.totalfreedom.totalfreedommod.discord.command.DiscordCommandImpl;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -55,6 +53,6 @@ public class TPSCommand extends DiscordCommandImpl
|
||||
builder.addField("Allocated Memory", Math.ceil(FUtil.getTotalMem()) + " MB", false);
|
||||
builder.addField("Free Memory", Math.ceil(FUtil.getFreeMem()) + " MB", false);
|
||||
|
||||
return new MessageBuilder().setEmbed(builder.build());
|
||||
return new MessageBuilder().setEmbeds(builder.build());
|
||||
}
|
||||
}
|
||||
|
@ -1,114 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.util;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class History
|
||||
{
|
||||
|
||||
public static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
public static void reportHistory(final CommandSender sender, final String username)
|
||||
{
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
UUID uuid = UUIDFetcher.fetch(username);
|
||||
if (uuid != null)
|
||||
{
|
||||
Gson gson = new GsonBuilder().create();
|
||||
String compactUuid = uuid.toString().replace("-", "");
|
||||
try
|
||||
{
|
||||
//UUIDs or playernames actually work with this one
|
||||
//TODO: fix the stupid api on how it's not working name histories
|
||||
//URL url = new URL("https://api.ashcon.app/mojang/v2/user/" + compactUuid);
|
||||
URL url = new URL("https://api.mojang.com/user/profiles/" + compactUuid + "/names");
|
||||
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
|
||||
//conn.setRequestProperty("User-Agent", "");
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
FName[] oldNames = gson.fromJson(reader, FName[].class);
|
||||
if (oldNames == null)
|
||||
{
|
||||
FSync.playerMsg(sender, ChatColor.RED + "Player not found!");
|
||||
return;
|
||||
}
|
||||
reader.close();
|
||||
conn.disconnect();
|
||||
Arrays.sort(oldNames);
|
||||
printHistory(sender, oldNames);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FSync.playerMsg(sender, ChatColor.RED + "Error, see logs for more details.");
|
||||
FLog.severe(ex);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FSync.playerMsg(sender, ChatColor.RED + "Player not found!");
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(TotalFreedomMod.getPlugin());
|
||||
}
|
||||
|
||||
private static void printHistory(CommandSender sender, FName[] oldNames)
|
||||
{
|
||||
if (oldNames.length == 1)
|
||||
{
|
||||
FSync.playerMsg(sender, ChatColor.GREEN + oldNames[0].getName() + ChatColor.GOLD + " has never changed their name.");
|
||||
return;
|
||||
}
|
||||
FSync.playerMsg(sender, ChatColor.GOLD + "Original name: " + ChatColor.GREEN + oldNames[0].getName());
|
||||
for (int i = 1; i < oldNames.length; i++)
|
||||
{
|
||||
Date date = new Date(oldNames[i].getChangedToAt());
|
||||
String formattedDate = dateFormat.format(date);
|
||||
FSync.playerMsg(sender, ChatColor.BLUE + formattedDate + ChatColor.GOLD + " changed to " + ChatColor.GREEN + oldNames[i].getName());
|
||||
}
|
||||
}
|
||||
|
||||
private static class FName implements Comparable<FName>
|
||||
{
|
||||
private final String name;
|
||||
private final long changedToAt;
|
||||
|
||||
//Added constructor because otherwise there's no way name or changedToAt would have been anything other than null.
|
||||
public FName(String name, long changedToAt)
|
||||
{
|
||||
this.name = name;
|
||||
this.changedToAt = changedToAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(FName other)
|
||||
{
|
||||
return Long.compare(this.changedToAt, other.changedToAt);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public long getChangedToAt()
|
||||
{
|
||||
return changedToAt;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.util;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.UUID;
|
||||
|
||||
// UUIDFetcher retrieves UUIDs from usernames via web requests to Mojang.
|
||||
public class UUIDFetcher
|
||||
{
|
||||
|
||||
private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft";
|
||||
|
||||
public static UUID fetch(String name)
|
||||
{
|
||||
try
|
||||
{
|
||||
Gson gson = new GsonBuilder().create();
|
||||
UUID uuid;
|
||||
String body = gson.toJson(name);
|
||||
URL url = new URL(PROFILE_URL);
|
||||
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
connection.setUseCaches(false);
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(true);
|
||||
OutputStream stream = connection.getOutputStream();
|
||||
stream.write(body.getBytes());
|
||||
stream.flush();
|
||||
stream.close();
|
||||
FetchedUuid[] id = gson.fromJson(
|
||||
new InputStreamReader(connection.getInputStream()),
|
||||
FetchedUuid[].class);
|
||||
|
||||
if (id.length == 0 || id[0].getID() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
String idd = id[0].getID();
|
||||
uuid = UUID.fromString(idd.substring(0, 8) + "-" + idd.substring(8, 12)
|
||||
+ "-" + idd.substring(12, 16) + "-" + idd.substring(16, 20) + "-"
|
||||
+ idd.substring(20, 32));
|
||||
return uuid;
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
FLog.severe(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class FetchedUuid
|
||||
{
|
||||
|
||||
private String id;
|
||||
|
||||
public String getID()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
}
|
||||
}
|
@ -224,8 +224,6 @@ allow:
|
||||
minecarts: true
|
||||
clearonjoin: false
|
||||
tpronjoin: false
|
||||
structureblocks: false
|
||||
jigsaws: false
|
||||
grindstones: true
|
||||
jukeboxes: true
|
||||
spawners: false
|
||||
@ -234,6 +232,7 @@ allow:
|
||||
auto_tp: false
|
||||
auto_clear: false
|
||||
gravity: false
|
||||
masterblocks: false
|
||||
|
||||
blocked_commands:
|
||||
#
|
||||
|
Reference in New Issue
Block a user