mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-01 04:26:42 +00:00
Compare commits
73 Commits
dependabot
...
merge-bran
Author | SHA1 | Date | |
---|---|---|---|
beddbe42dd | |||
fefb750b47 | |||
bd5edc3156 | |||
cc13d9cf49 | |||
96be5f1149 | |||
d7da199d26 | |||
64f4fbfe18 | |||
fa1b6dde4c | |||
6a5b5c241e | |||
cec506f148 | |||
4602e2246b | |||
3ac893db50 | |||
bcf8c2f04a | |||
88eceab480 | |||
df756d43ef | |||
91c4153037 | |||
c5f0886df6 | |||
ca990bc526 | |||
546827cd5a | |||
e7e08c060e | |||
eb6a91323d | |||
2fbd7578ab | |||
75cd1864f6 | |||
a420339017 | |||
2b5ea048cc | |||
20f341ea45 | |||
eadbc504e5 | |||
760ab3c622 | |||
b804459dcc | |||
63f805935f | |||
1937a3d4de | |||
36663385ab | |||
5d4085ab07 | |||
0686419ce3 | |||
9998392b1a | |||
90c276668b | |||
19db8a14dc | |||
7f0eeab09c | |||
410f26f76f | |||
2d918fe17b | |||
44bae8ab00 | |||
6cc9b26661 | |||
6761ab8035 | |||
9490dacf36 | |||
173f37d55e | |||
25c8c0b654 | |||
217e5fd62e | |||
2eef02ef13 | |||
41cf62c8c0 | |||
268b71f8a3 | |||
a84a47980a | |||
3a502713ea | |||
5dc5e5dcc5 | |||
171daf25a4 | |||
2fa7b6855b | |||
38de6f9e67 | |||
7faf719555 | |||
3bcf0f5082 | |||
c5f24b46d5 | |||
3016c57e3e | |||
00351f1163 | |||
40d22fa2e3 | |||
41923b29d7 | |||
0e7a2d9bce | |||
dcebf7bbe7 | |||
d30e335f57 | |||
cca95dc3f1 | |||
42b68011ea | |||
87d7ba19de | |||
16c00e3ed6 | |||
79e7f6904b | |||
520bd97176 | |||
654f5900ba |
8
pom.xml
8
pom.xml
@ -128,8 +128,8 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>me.totalfreedom.scissors</groupId>
|
||||
<artifactId>scissors-api</artifactId>
|
||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
||||
<artifactId>Scissors-API</artifactId>
|
||||
<version>1.19.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@ -150,7 +150,7 @@
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>worldedit-bukkit</artifactId>
|
||||
<version>7.2.12</version>
|
||||
<version>7.2.15</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@ -259,7 +259,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<version>3.10.1</version>
|
||||
<configuration>
|
||||
<outputFileName>TotalFreedomMod.jar</outputFileName>
|
||||
<compilerVersion>17</compilerVersion>
|
||||
|
@ -1,25 +1,17 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
import io.papermc.lib.PaperLib;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import org.bukkit.ChatColor;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeModifier;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.spigotmc.event.player.PlayerSpawnLocationEvent;
|
||||
|
||||
public class MovementValidator extends FreedomService
|
||||
{
|
||||
@ -41,67 +33,36 @@ public class MovementValidator extends FreedomService
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
// Check absolute value to account for negatives
|
||||
if (Math.abs(Objects.requireNonNull(event.getTo()).getX()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getY()) >= MAX_XYZ_COORD)
|
||||
if (isOutOfBounds(event.getTo()))
|
||||
{
|
||||
event.setCancelled(true); // illegal position, cancel it
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isOutOfBounds(final Location position)
|
||||
{
|
||||
return Math.abs(position.getX()) >= MAX_XYZ_COORD || Math.abs(position.getY()) >= MAX_XYZ_COORD || Math.abs(position.getZ()) >= MAX_XYZ_COORD;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerMove(PlayerMoveEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
Location from = event.getFrom();
|
||||
Location to = event.getTo();
|
||||
assert to != null;
|
||||
if (to.getX() >= from.getX() + MAX_DISTANCE_TRAVELED || to.getY() >= from.getY() + MAX_DISTANCE_TRAVELED || to.getZ() >= from.getZ() + MAX_DISTANCE_TRAVELED)
|
||||
double distance = from.distanceSquared(to);
|
||||
|
||||
if (distance >= MAX_DISTANCE_TRAVELED)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
player.kickPlayer(ChatColor.RED + "You were moving too quickly!");
|
||||
player.kick(Component.text("You were moving too quickly!", NamedTextColor.RED));
|
||||
}
|
||||
// Check absolute value to account for negatives
|
||||
if (Math.abs(event.getTo().getX()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getY()) >= MAX_XYZ_COORD)
|
||||
if (isOutOfBounds(event.getTo()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
PaperLib.teleportAsync(player, player.getWorld().getSpawnLocation());
|
||||
}
|
||||
|
||||
if (exploitItem(event.getPlayer().getInventory().getHelmet()))
|
||||
{
|
||||
event.getPlayer().getInventory().setHelmet(new ItemStack(Material.AIR));
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your helmet slot.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (exploitItem(event.getPlayer().getInventory().getBoots()))
|
||||
{
|
||||
event.getPlayer().getInventory().setBoots(new ItemStack(Material.AIR));
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your boots slot.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (exploitItem(event.getPlayer().getInventory().getLeggings()))
|
||||
{
|
||||
event.getPlayer().getInventory().setLeggings(new ItemStack(Material.AIR));
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your leggings slot.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (exploitItem(event.getPlayer().getInventory().getChestplate()))
|
||||
{
|
||||
event.getPlayer().getInventory().setChestplate(new ItemStack(Material.AIR));
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your chestplate slot.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (exploitItem(event.getPlayer().getInventory().getItemInMainHand()))
|
||||
{
|
||||
event.getPlayer().getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your hand.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (exploitItem(event.getPlayer().getInventory().getItemInOffHand()))
|
||||
{
|
||||
event.getPlayer().getInventory().setItemInOffHand(new ItemStack(Material.AIR));
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your offhand.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@ -110,72 +71,28 @@ public class MovementValidator extends FreedomService
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
// Validate position
|
||||
if (Math.abs(player.getLocation().getX()) >= MAX_XYZ_COORD || Math.abs(player.getLocation().getZ()) >= MAX_XYZ_COORD || Math.abs(player.getLocation().getY()) >= MAX_XYZ_COORD)
|
||||
if (isOutOfBounds(player.getLocation()))
|
||||
{
|
||||
PaperLib.teleportAsync(player, player.getWorld().getSpawnLocation()); // Illegal position, teleport to spawn
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerHoldItem(PlayerItemHeldEvent event)
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerSpawn(PlayerSpawnLocationEvent event)
|
||||
{
|
||||
if (exploitItem(event.getPlayer().getInventory().getItemInMainHand()))
|
||||
{
|
||||
event.getPlayer().getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your hand.");
|
||||
}
|
||||
if (exploitItem(event.getPlayer().getInventory().getItemInOffHand()))
|
||||
{
|
||||
event.getPlayer().getInventory().setItemInOffHand(new ItemStack(Material.AIR));
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your offhand.");
|
||||
}
|
||||
}
|
||||
final Location playerSpawn = event.getSpawnLocation();
|
||||
final Location worldSpawn = event.getPlayer().getWorld().getSpawnLocation();
|
||||
|
||||
private Boolean exploitItem(ItemStack item)
|
||||
{
|
||||
if (item == null)
|
||||
// If the player's spawn is equal to the world's spawn, there is no need to check.
|
||||
// This will also prevent any possible feedback loops pertaining to setting an out of bounds world spawn to the same world spawn.
|
||||
if (playerSpawn == worldSpawn)
|
||||
{
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null)
|
||||
if (isOutOfBounds(worldSpawn))
|
||||
{
|
||||
Multimap<Attribute, AttributeModifier> attributes = meta.getAttributeModifiers();
|
||||
if (attributes != null)
|
||||
{
|
||||
Map<Attribute, Collection<AttributeModifier>> attrMap = attributes.asMap();
|
||||
|
||||
// For every attribute...
|
||||
for (Attribute attr : attributes.keySet())
|
||||
{
|
||||
// Default values
|
||||
boolean posInf = false;
|
||||
boolean negInf = false;
|
||||
|
||||
// For every AttributeModifier...
|
||||
for (AttributeModifier modifier : attrMap.get(attr))
|
||||
{
|
||||
// Are they ∞ or -∞?
|
||||
if (modifier.getAmount() == Double.POSITIVE_INFINITY)
|
||||
{
|
||||
posInf = true;
|
||||
}
|
||||
else if (modifier.getAmount() == Double.NEGATIVE_INFINITY)
|
||||
{
|
||||
negInf = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Are both values set as true?
|
||||
if (posInf && negInf)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
event.setSpawnLocation(worldSpawn);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -156,7 +156,7 @@ public class Admin
|
||||
}
|
||||
|
||||
// Ensure admins don't have admin functionality when removed (FS-222)
|
||||
AdminList.vanished.remove(getName());
|
||||
AdminList.vanished.remove(getUuid());
|
||||
|
||||
if (plugin.esb != null)
|
||||
{
|
||||
|
@ -4,8 +4,7 @@ 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 me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
|
||||
import io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
@ -109,6 +108,16 @@ 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.HIGH)
|
||||
public void onBlockExplode(BlockExplodeEvent event)
|
||||
|
@ -13,9 +13,9 @@ softdepend:
|
||||
- JDA
|
||||
- Votifier
|
||||
authors: [Madgeek1450, Prozza]
|
||||
api-version: "1.17"
|
||||
api-version: "1.19"
|
||||
libraries:
|
||||
- org.apache.commons:commons-lang3:3.12.0
|
||||
- commons-io:commons-io:2.11.0
|
||||
- org.jetbrains:annotations:23.0.0
|
||||
- org.javassist:javassist:3.29.1-GA
|
||||
- org.javassist:javassist:3.29.1-GA
|
||||
|
Reference in New Issue
Block a user