niki nos

Make a Paper 1.21.11 plugin (Java 21) called SizeChanger. Players use /size to change their size, and the size changes how they play.

COMMANDS /size <number>: set your size (1 = normal). Min 0.0625, max 16 (configurable). /size reset: back to normal. /size <number> <player>: change another player's size (permission: size.others).

Tab complete: 0.25, 0.5, 1, 2, 5, 10, reset, and player names.

Permission for the command: size.use

WHAT SIZE CHANGES Size: use the SCALE attribute.

Damage: smaller = less damage dealt, bigger = more.

Reach: smaller = less reach, bigger = more (block and entity interaction range).

Fall damage: smaller = MORE fall damage, bigger = less.

Hearts: bigger than normal = extra hearts. Normal or smaller = normal 20 HP.

Speed, camera and FOV: same as a normal player, just scaled to the new size.

Block placing and breaking: blocks should feel scaled to the player's size, so reach and mining speed scale too. If real scaled blocks aren't possible, tell me and use the closest option.

RULES Save each player's size so it stays after relog and restart.

Reapply it on join, respawn, world change, and gamemode change.

Works in all gamemodes.

Only remove this plugin's own attribute changes, never other plugins'.

Move the player out of blocks if they get stuck after resizing.

Put the multipliers (damage, reach, fall, health, speed) in config.yml so I can edit them.

Kodari AI
KodariNov 12 at 3:28 am 4
SizeChanger
A Paper 1.21.11 plugin that lets players change their size via /size command. Uses the SCALE attribute to resize players from 0.0625x to 16x normal. Size affects damage dealt, block/entity reach, fall damage, and health (bigger players get extra hearts). All multipliers are configurable in config.yml. Sizes persist across relogs and restarts via YAML storage, reapply on join/respawn/world change/gamemode change, and work in all gamemodes. Includes tab completion, permission checks, safe teleportation out of blocks when stuck, and only modifies its own attribute changes to avoid conflicts with other plugins.

Created SizeChanger with persistent sizes, configurable gameplay scaling, permissions, tab completion, and reapplication on player lifecycle events.

Real scaled blocks aren’t possible with a server plugin. The closest option used here is scaled interaction reach and mining speed; blocks retain their normal size.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
5 315
src/main/java/com/kodari/sizechanger/SizeChanger.java
package com.kodari.sizechanger;

import com.cryptomorin.xseries.XAttribute;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.BoundingBox;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.UUID;

public final class SizeChanger extends JavaPlugin implements Listener, CommandExecutor, TabCompleter {
    private static final List<String> ATTRIBUTES = Arrays.asList("scale", "block_interaction_range",
            "entity_interaction_range", "max_health", "movement_speed", "block_break_speed");
    private File dataFile;
    private YamlConfiguration data;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        dataFile = new File(getDataFolder(), "sizes.yml");
        data = YamlConfiguration.loadConfiguration(dataFile);
        getServer().getPluginManager().registerEvents(this, this);
        getCommand("size").setExecutor(this);
        getCommand("size").setTabCompleter(this);
        for (Player player : Bukkit.getOnlinePlayers()) {
            apply(player);
        }
    }

    @Override
    public void onDisable() {
        for (Player player : Bukkit.getOnlinePlayers()) {
            clearModifiers(player);
            clampHealth(player);
        }
    }

    private double size(UUID id) {
        double value = data.getDouble(id.toString(), 1.0);
        return Double.isFinite(value) ? Math.max(0.0625, Math.min(16.0, value)) : 1.0;
    }

    private double exponent(String name, double fallback) {
        double value = getConfig().getDouble("multipliers." + name, fallback);
        return Double.isFinite(value) ? Math.max(-8.0, Math.min(8.0, value)) : fallback;
    }

    private double factor(double size, String name, double fallback) {
        return Math.pow(size, exponent(name, fallback));
    }

    private NamespacedKey key(String attribute) {
        return new NamespacedKey(this, attribute);
    }

    private AttributeInstance attribute(Player player, String name) {
        return XAttribute.of(name).map(a -> player.getAttribute(a.get())).orElse(null);
    }

    private void clearModifiers(Player player) {
        for (String name : ATTRIBUTES) {
            AttributeInstance instance = attribute(player, name);
            if (instance == null) continue;
            NamespacedKey key = key(name);
            for (AttributeModifier modifier : instance.getModifiers()) {
                if (modifier.getKey().equals(key)) instance.removeModifier(modifier);
            }
        }
    }

    private void clampHealth(Player player) {
        AttributeInstance maxHealth = attribute(player, "max_health");
        if (maxHealth != null && player.getHealth() > maxHealth.getValue()) {
            player.setHealth(maxHealth.getValue());
        }
    }

    private void modify(Player player, String name, double amount, AttributeModifier.Operation operation) {
        AttributeInstance instance = attribute(player, name);
        if (instance != null && Double.isFinite(amount) && amount != 0.0) {
            instance.addModifier(new AttributeModifier(key(name), amount, operation));
        }
    }

    private void apply(Player player) {
        double size = size(player.getUniqueId());
        clearModifiers(player);
        AttributeInstance scale = attribute(player, "scale");
        if (scale != null) {
            modify(player, "scale", size - scale.getValue(), AttributeModifier.Operation.ADD_NUMBER);
        }
        double reach = factor(size, "reach", 1.0) - 1.0;
        modify(player, "block_interaction_range", reach, AttributeModifier.Operation.MULTIPLY_SCALAR_1);
        modify(player, "entity_interaction_range", reach, AttributeModifier.Operation.MULTIPLY_SCALAR_1);
        modify(player, "movement_speed", factor(size, "speed", 0.0) - 1.0,
                AttributeModifier.Operation.MULTIPLY_SCALAR_1);
        modify(player, "block_break_speed", factor(size, "mining", 1.0) - 1.0,
                AttributeModifier.Operation.MULTIPLY_SCALAR_1);
        if (size > 1.0) {
            double extraHealth = 20.0 * Math.max(0.0, factor(size, "health", 1.0) - 1.0);
            modify(player, "max_health", extraHealth, AttributeModifier.Operation.ADD_NUMBER);
        }
        clampHealth(player);
        moveOutOfBlocks(player);
    }

    private boolean clearAt(Player player, Location destination) {
        Location original = player.getLocation();
        BoundingBox box = player.getBoundingBox().clone().shift(destination.getX() - original.getX(),
                destination.getY() - original.getY(), destination.getZ() - original.getZ());
        if (box.getMinY() < player.getWorld().getMinHeight() || box.getMaxY() > player.getWorld().getMaxHeight()) return false;
        if (!player.getWorld().getWorldBorder().isInside(destination)) return false;
        int minX = (int) Math.floor(box.getMinX());
        int maxX = (int) Math.floor(box.getMaxX() - 1.0e-7);
        int minY = (int) Math.floor(box.getMinY());
        int maxY = (int) Math.floor(box.getMaxY() - 1.0e-7);
        int minZ = (int) Math.floor(box.getMinZ());
        int maxZ = (int) Math.floor(box.getMaxZ() - 1.0e-7);
        for (int x = minX; x <= maxX; x++) {
            for (int y = minY; y <= maxY; y++) {
                for (int z = minZ; z <= maxZ; z++) {
                    Block block = player.getWorld().getBlockAt(x, y, z);
                    if (!block.isPassable()) return false;
                }
            }
        }
        return true;
    }

    private void moveOutOfBlocks(Player player) {
        Location original = player.getLocation();
        if (clearAt(player, original)) return;
        for (int y = 1; y <= 32; y++) {
            Location candidate = original.clone().add(0, y, 0);
            if (clearAt(player, candidate)) {
                player.teleport(candidate);
                return;
            }
        }
        player.sendMessage("§eYour size leaves you inside blocks; move to an open area.");
    }

    private void reapplyLater(Player player) {
        Bukkit.getScheduler().runTask(this, () -> {
            if (player.isOnline()) apply(player);
        });
    }

    @EventHandler public void onJoin(PlayerJoinEvent event) { reapplyLater(event.getPlayer()); }
    @EventHandler public void onRespawn(PlayerRespawnEvent event) { reapplyLater(event.getPlayer()); }
    @EventHandler public void onWorldChange(PlayerChangedWorldEvent event) { reapplyLater(event.getPlayer()); }
    @EventHandler(ignoreCancelled = true) public void onGameMode(PlayerGameModeChangeEvent event) { reapplyLater(event.getPlayer()); }

    @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
    public void onDamage(EntityDamageEvent event) {
        if (event.getCause() == EntityDamageEvent.DamageCause.FALL && event.getEntity() instanceof Player player) {
            event.setDamage(event.getDamage() / factor(size(player.getUniqueId()), "fall", 1.0));
        }
        if (event instanceof EntityDamageByEntityEvent attack) {
            Entity damager = attack.getDamager();
            Player attacker = damager instanceof Player p ? p :
                    damager instanceof Projectile projectile && projectile.getShooter() instanceof Player p ? p : null;
            if (attacker != null) {
                event.setDamage(event.getDamage() * factor(size(attacker.getUniqueId()), "damage", 1.0));
            }
        }
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (args.length < 1 || args.length > 2) return false;
        Player target;
        if (args.length == 2) {