mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-11-04 03:03:43 +01:00 
			
		
		
		
	Start working on the new permission system
This commit is contained in:
		@@ -33,6 +33,7 @@ import com.plotsquared.core.generator.HybridUtils;
 | 
			
		||||
import com.plotsquared.core.generator.IndependentPlotGenerator;
 | 
			
		||||
import com.plotsquared.core.inject.annotations.DefaultGenerator;
 | 
			
		||||
import com.plotsquared.core.location.World;
 | 
			
		||||
import com.plotsquared.core.permissions.PermissionHandler;
 | 
			
		||||
import com.plotsquared.core.player.PlotPlayer;
 | 
			
		||||
import com.plotsquared.core.queue.GlobalBlockQueue;
 | 
			
		||||
import com.plotsquared.core.util.ChatManager;
 | 
			
		||||
@@ -266,4 +267,13 @@ public interface PlotPlatform<P> extends ILogger {
 | 
			
		||||
        return getInjector().getInstance(ChunkManager.class);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the {@link PermissionHandler} implementation for the platform
 | 
			
		||||
     *
 | 
			
		||||
     * @return Permission handler
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull default PermissionHandler getPermissionHandler() {
 | 
			
		||||
        return getInjector().getInstance(PermissionHandler.class);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,37 @@
 | 
			
		||||
/*
 | 
			
		||||
 *       _____  _       _    _____                                _
 | 
			
		||||
 *      |  __ \| |     | |  / ____|                              | |
 | 
			
		||||
 *      | |__) | | ___ | |_| (___   __ _ _   _  __ _ _ __ ___  __| |
 | 
			
		||||
 *      |  ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
 | 
			
		||||
 *      | |    | | (_) | |_ ____) | (_| | |_| | (_| | | |  __/ (_| |
 | 
			
		||||
 *      |_|    |_|\___/ \__|_____/ \__, |\__,_|\__,_|_|  \___|\__,_|
 | 
			
		||||
 *                                    | |
 | 
			
		||||
 *                                    |_|
 | 
			
		||||
 *            PlotSquared plot management system for Minecraft
 | 
			
		||||
 *                  Copyright (C) 2020 IntellectualSites
 | 
			
		||||
 *
 | 
			
		||||
 *     This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 *     it under the terms of the GNU General Public License as published by
 | 
			
		||||
 *     the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
 *     (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 *     This program is distributed in the hope that it will be useful,
 | 
			
		||||
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 *     GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 *     You should have received a copy of the GNU General Public License
 | 
			
		||||
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
package com.plotsquared.core.permissions;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
 | 
			
		||||
public enum ConsolePermissionProfile implements PermissionProfile {
 | 
			
		||||
    INSTANCE;
 | 
			
		||||
 | 
			
		||||
    @Override public boolean hasPermission(@Nonnull final String permission) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,37 @@
 | 
			
		||||
/*
 | 
			
		||||
 *       _____  _       _    _____                                _
 | 
			
		||||
 *      |  __ \| |     | |  / ____|                              | |
 | 
			
		||||
 *      | |__) | | ___ | |_| (___   __ _ _   _  __ _ _ __ ___  __| |
 | 
			
		||||
 *      |  ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
 | 
			
		||||
 *      | |    | | (_) | |_ ____) | (_| | |_| | (_| | | |  __/ (_| |
 | 
			
		||||
 *      |_|    |_|\___/ \__|_____/ \__, |\__,_|\__,_|_|  \___|\__,_|
 | 
			
		||||
 *                                    | |
 | 
			
		||||
 *                                    |_|
 | 
			
		||||
 *            PlotSquared plot management system for Minecraft
 | 
			
		||||
 *                  Copyright (C) 2020 IntellectualSites
 | 
			
		||||
 *
 | 
			
		||||
 *     This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 *     it under the terms of the GNU General Public License as published by
 | 
			
		||||
 *     the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
 *     (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 *     This program is distributed in the hope that it will be useful,
 | 
			
		||||
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 *     GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 *     You should have received a copy of the GNU General Public License
 | 
			
		||||
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
package com.plotsquared.core.permissions;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
 | 
			
		||||
public enum NullPermissionProfile implements PermissionProfile {
 | 
			
		||||
    INSTANCE;
 | 
			
		||||
 | 
			
		||||
    @Override public boolean hasPermission(@Nonnull final String permission) {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,95 @@
 | 
			
		||||
/*
 | 
			
		||||
 *       _____  _       _    _____                                _
 | 
			
		||||
 *      |  __ \| |     | |  / ____|                              | |
 | 
			
		||||
 *      | |__) | | ___ | |_| (___   __ _ _   _  __ _ _ __ ___  __| |
 | 
			
		||||
 *      |  ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
 | 
			
		||||
 *      | |    | | (_) | |_ ____) | (_| | |_| | (_| | | |  __/ (_| |
 | 
			
		||||
 *      |_|    |_|\___/ \__|_____/ \__, |\__,_|\__,_|_|  \___|\__,_|
 | 
			
		||||
 *                                    | |
 | 
			
		||||
 *                                    |_|
 | 
			
		||||
 *            PlotSquared plot management system for Minecraft
 | 
			
		||||
 *                  Copyright (C) 2020 IntellectualSites
 | 
			
		||||
 *
 | 
			
		||||
 *     This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 *     it under the terms of the GNU General Public License as published by
 | 
			
		||||
 *     the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
 *     (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 *     This program is distributed in the hope that it will be useful,
 | 
			
		||||
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 *     GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 *     You should have received a copy of the GNU General Public License
 | 
			
		||||
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
package com.plotsquared.core.permissions;
 | 
			
		||||
 | 
			
		||||
import com.plotsquared.core.player.OfflinePlotPlayer;
 | 
			
		||||
import com.plotsquared.core.player.PlotPlayer;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import java.util.Optional;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Permission handler
 | 
			
		||||
 */
 | 
			
		||||
public interface PermissionHandler {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Initialize the permission handler
 | 
			
		||||
     */
 | 
			
		||||
    void initialize();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Attempt to construct a permission profile for a plot player
 | 
			
		||||
     *
 | 
			
		||||
     * @param playerPlotPlayer Plot player
 | 
			
		||||
     * @return Permission profile, if one was able to be constructed
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull Optional<PermissionProfile> getPermissionProfile(
 | 
			
		||||
        @Nonnull PlotPlayer<?> playerPlotPlayer);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Attempt to construct a permission profile for an offline plot player
 | 
			
		||||
     *
 | 
			
		||||
     * @param offlinePlotPlayer Offline player
 | 
			
		||||
     * @return Permission profile, if one was able to be constructed
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull Optional<PermissionProfile> getPermissionProfile(
 | 
			
		||||
        @Nonnull OfflinePlotPlayer offlinePlotPlayer);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get all capabilities that the permission handler has
 | 
			
		||||
     *
 | 
			
		||||
     * @return Immutable set of capabilities
 | 
			
		||||
     */
 | 
			
		||||
    @Nonnull Set<PermissionHandlerCapability> getCapabilities();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Check whether or not the permission handler has a given capability
 | 
			
		||||
     *
 | 
			
		||||
     * @param capability Capability
 | 
			
		||||
     * @return {@code true} if the handler has the capability, else {@code false}
 | 
			
		||||
     */
 | 
			
		||||
    default boolean hasCapability(@Nonnull final PermissionHandlerCapability capability) {
 | 
			
		||||
        return this.getCapabilities().contains(capability);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Permission handler capabilities
 | 
			
		||||
     */
 | 
			
		||||
    enum PermissionHandlerCapability {
 | 
			
		||||
        /**
 | 
			
		||||
         * The ability to check for online (player) permissions
 | 
			
		||||
         */
 | 
			
		||||
        ONLINE_PERMISSIONS,
 | 
			
		||||
        /**
 | 
			
		||||
         * The ability to check for offline (player) permissions
 | 
			
		||||
         */
 | 
			
		||||
        OFFLINE_PERMISSIONS
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,43 @@
 | 
			
		||||
/*
 | 
			
		||||
 *       _____  _       _    _____                                _
 | 
			
		||||
 *      |  __ \| |     | |  / ____|                              | |
 | 
			
		||||
 *      | |__) | | ___ | |_| (___   __ _ _   _  __ _ _ __ ___  __| |
 | 
			
		||||
 *      |  ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
 | 
			
		||||
 *      | |    | | (_) | |_ ____) | (_| | |_| | (_| | | |  __/ (_| |
 | 
			
		||||
 *      |_|    |_|\___/ \__|_____/ \__, |\__,_|\__,_|_|  \___|\__,_|
 | 
			
		||||
 *                                    | |
 | 
			
		||||
 *                                    |_|
 | 
			
		||||
 *            PlotSquared plot management system for Minecraft
 | 
			
		||||
 *                  Copyright (C) 2020 IntellectualSites
 | 
			
		||||
 *
 | 
			
		||||
 *     This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 *     it under the terms of the GNU General Public License as published by
 | 
			
		||||
 *     the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
 *     (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 *     This program is distributed in the hope that it will be useful,
 | 
			
		||||
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 *     GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 *     You should have received a copy of the GNU General Public License
 | 
			
		||||
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
package com.plotsquared.core.permissions;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Any object which can hold permissions
 | 
			
		||||
 */
 | 
			
		||||
public interface PermissionHolder {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Check if the permission holder has the given permission node
 | 
			
		||||
     *
 | 
			
		||||
     * @param permission Permission node
 | 
			
		||||
     * @return {@code true} if the holder has the given permission node, else {@code false}
 | 
			
		||||
     */
 | 
			
		||||
    boolean hasPermission(@Nonnull String permission);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,43 @@
 | 
			
		||||
/*
 | 
			
		||||
 *       _____  _       _    _____                                _
 | 
			
		||||
 *      |  __ \| |     | |  / ____|                              | |
 | 
			
		||||
 *      | |__) | | ___ | |_| (___   __ _ _   _  __ _ _ __ ___  __| |
 | 
			
		||||
 *      |  ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
 | 
			
		||||
 *      | |    | | (_) | |_ ____) | (_| | |_| | (_| | | |  __/ (_| |
 | 
			
		||||
 *      |_|    |_|\___/ \__|_____/ \__, |\__,_|\__,_|_|  \___|\__,_|
 | 
			
		||||
 *                                    | |
 | 
			
		||||
 *                                    |_|
 | 
			
		||||
 *            PlotSquared plot management system for Minecraft
 | 
			
		||||
 *                  Copyright (C) 2020 IntellectualSites
 | 
			
		||||
 *
 | 
			
		||||
 *     This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 *     it under the terms of the GNU General Public License as published by
 | 
			
		||||
 *     the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
 *     (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 *     This program is distributed in the hope that it will be useful,
 | 
			
		||||
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 *     GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 *     You should have received a copy of the GNU General Public License
 | 
			
		||||
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
package com.plotsquared.core.permissions;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A permission profile that can be used to check for permissions
 | 
			
		||||
 */
 | 
			
		||||
public interface PermissionProfile {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Check if the owner of the profile has a given permission
 | 
			
		||||
     *
 | 
			
		||||
     * @param permission Permission
 | 
			
		||||
     * @return {@code true} if the owner has the given permission, else {@code false}
 | 
			
		||||
     */
 | 
			
		||||
    boolean hasPermission(@Nonnull String permission);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -32,6 +32,7 @@ import com.plotsquared.core.database.DBFunc;
 | 
			
		||||
import com.plotsquared.core.events.TeleportCause;
 | 
			
		||||
import com.plotsquared.core.inject.annotations.ConsoleActor;
 | 
			
		||||
import com.plotsquared.core.location.Location;
 | 
			
		||||
import com.plotsquared.core.permissions.PermissionHandler;
 | 
			
		||||
import com.plotsquared.core.plot.PlotArea;
 | 
			
		||||
import com.plotsquared.core.plot.PlotWeather;
 | 
			
		||||
import com.plotsquared.core.plot.world.PlotAreaManager;
 | 
			
		||||
@@ -42,11 +43,11 @@ import com.sk89q.worldedit.regions.CuboidRegion;
 | 
			
		||||
import com.sk89q.worldedit.world.gamemode.GameMode;
 | 
			
		||||
import com.sk89q.worldedit.world.gamemode.GameModes;
 | 
			
		||||
import com.sk89q.worldedit.world.item.ItemType;
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
import org.slf4j.LoggerFactory;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
 | 
			
		||||
public class ConsolePlayer extends PlotPlayer<Actor> {
 | 
			
		||||
@@ -59,8 +60,9 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
 | 
			
		||||
    @Inject private ConsolePlayer(@Nonnull final PlotAreaManager plotAreaManager,
 | 
			
		||||
                                  @Nonnull final EventDispatcher eventDispatcher,
 | 
			
		||||
                                  @ConsoleActor @Nonnull final Actor actor,
 | 
			
		||||
                                  @Nullable final EconHandler econHandler) {
 | 
			
		||||
        super(plotAreaManager, eventDispatcher, econHandler);
 | 
			
		||||
                                  @Nullable final EconHandler econHandler,
 | 
			
		||||
                                  @Nonnull final PermissionHandler permissionHandler) {
 | 
			
		||||
        super(plotAreaManager, eventDispatcher, econHandler, permissionHandler);
 | 
			
		||||
        this.actor = actor;
 | 
			
		||||
        final PlotArea[] areas = plotAreaManager.getAllPlotAreas();
 | 
			
		||||
        final PlotArea area;
 | 
			
		||||
@@ -121,10 +123,6 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override public boolean hasPermission(String permission) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override public boolean isPermissionSet(String permission) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -25,9 +25,11 @@
 | 
			
		||||
 */
 | 
			
		||||
package com.plotsquared.core.player;
 | 
			
		||||
 | 
			
		||||
import com.plotsquared.core.permissions.PermissionHolder;
 | 
			
		||||
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
 | 
			
		||||
public interface OfflinePlotPlayer {
 | 
			
		||||
public interface OfflinePlotPlayer extends PermissionHolder {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets the {@code UUID} of this player
 | 
			
		||||
@@ -57,4 +59,5 @@ public interface OfflinePlotPlayer {
 | 
			
		||||
     * @return the player name
 | 
			
		||||
     */
 | 
			
		||||
    String getName();
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -35,6 +35,9 @@ import com.plotsquared.core.configuration.Settings;
 | 
			
		||||
import com.plotsquared.core.database.DBFunc;
 | 
			
		||||
import com.plotsquared.core.events.TeleportCause;
 | 
			
		||||
import com.plotsquared.core.location.Location;
 | 
			
		||||
import com.plotsquared.core.permissions.NullPermissionProfile;
 | 
			
		||||
import com.plotsquared.core.permissions.PermissionHandler;
 | 
			
		||||
import com.plotsquared.core.permissions.PermissionProfile;
 | 
			
		||||
import com.plotsquared.core.plot.Plot;
 | 
			
		||||
import com.plotsquared.core.plot.PlotArea;
 | 
			
		||||
import com.plotsquared.core.plot.PlotCluster;
 | 
			
		||||
@@ -54,11 +57,11 @@ import com.plotsquared.core.util.task.TaskManager;
 | 
			
		||||
import com.sk89q.worldedit.extension.platform.Actor;
 | 
			
		||||
import com.sk89q.worldedit.world.gamemode.GameMode;
 | 
			
		||||
import com.sk89q.worldedit.world.item.ItemType;
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
import org.slf4j.LoggerFactory;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
import java.nio.ByteBuffer;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.Collections;
 | 
			
		||||
@@ -95,11 +98,15 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
 | 
			
		||||
    private final PlotAreaManager plotAreaManager;
 | 
			
		||||
    private final EventDispatcher eventDispatcher;
 | 
			
		||||
    private final EconHandler econHandler;
 | 
			
		||||
    private final PermissionProfile permissionProfile;
 | 
			
		||||
 | 
			
		||||
    public PlotPlayer(@Nonnull final PlotAreaManager plotAreaManager, @Nonnull final EventDispatcher eventDispatcher, @Nullable final EconHandler econHandler) {
 | 
			
		||||
    public PlotPlayer(@Nonnull final PlotAreaManager plotAreaManager, @Nonnull final EventDispatcher eventDispatcher, @Nullable final EconHandler econHandler,
 | 
			
		||||
        @Nonnull final PermissionHandler permissionHandler) {
 | 
			
		||||
        this.plotAreaManager = plotAreaManager;
 | 
			
		||||
        this.eventDispatcher = eventDispatcher;
 | 
			
		||||
        this.econHandler = econHandler;
 | 
			
		||||
        this.permissionProfile = permissionHandler.getPermissionProfile(this).orElse(
 | 
			
		||||
            NullPermissionProfile.INSTANCE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static <T> PlotPlayer<T> from(@Nonnull final T object) {
 | 
			
		||||
@@ -147,6 +154,10 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
 | 
			
		||||
        return PlotSquared.platform().wrapPlayer(player);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override public final boolean hasPermission(@Nonnull final String permission) {
 | 
			
		||||
        return this.permissionProfile.hasPermission(permission);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public abstract Actor toActor();
 | 
			
		||||
 | 
			
		||||
    public abstract P getPlatformPlayer();
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,28 @@
 | 
			
		||||
/*
 | 
			
		||||
 *       _____  _       _    _____                                _
 | 
			
		||||
 *      |  __ \| |     | |  / ____|                              | |
 | 
			
		||||
 *      | |__) | | ___ | |_| (___   __ _ _   _  __ _ _ __ ___  __| |
 | 
			
		||||
 *      |  ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
 | 
			
		||||
 *      | |    | | (_) | |_ ____) | (_| | |_| | (_| | | |  __/ (_| |
 | 
			
		||||
 *      |_|    |_|\___/ \__|_____/ \__, |\__,_|\__,_|_|  \___|\__,_|
 | 
			
		||||
 *                                    | |
 | 
			
		||||
 *                                    |_|
 | 
			
		||||
 *            PlotSquared plot management system for Minecraft
 | 
			
		||||
 *                  Copyright (C) 2020 IntellectualSites
 | 
			
		||||
 *
 | 
			
		||||
 *     This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 *     it under the terms of the GNU General Public License as published by
 | 
			
		||||
 *     the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
 *     (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 *     This program is distributed in the hope that it will be useful,
 | 
			
		||||
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 *     GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 *     You should have received a copy of the GNU General Public License
 | 
			
		||||
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
package com.plotsquared.core.util;
 | 
			
		||||
 | 
			
		||||
import lombok.experimental.UtilityClass;
 | 
			
		||||
 
 | 
			
		||||
@@ -44,6 +44,53 @@ import javax.annotation.Nonnull;
 | 
			
		||||
    private static final Logger logger =
 | 
			
		||||
        LoggerFactory.getLogger("P2/" + MainUtil.class.getSimpleName());
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Cache of mapping x,y,z coordinates to the chunk array<br>
 | 
			
		||||
     * - Used for efficient world generation<br>
 | 
			
		||||
     */
 | 
			
		||||
    public static short[][] x_loc;
 | 
			
		||||
    public static short[][] y_loc;
 | 
			
		||||
    public static short[][] z_loc;
 | 
			
		||||
    public static short[][][] CACHE_I = null;
 | 
			
		||||
    public static short[][][] CACHE_J = null;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This cache is used for world generation and just saves a bit of calculation time when checking if something is in the plot area.
 | 
			
		||||
     */
 | 
			
		||||
    public static void initCache() {
 | 
			
		||||
        if (x_loc == null) {
 | 
			
		||||
            x_loc = new short[16][4096];
 | 
			
		||||
            y_loc = new short[16][4096];
 | 
			
		||||
            z_loc = new short[16][4096];
 | 
			
		||||
            for (int i = 0; i < 16; i++) {
 | 
			
		||||
                int i4 = i << 4;
 | 
			
		||||
                for (int j = 0; j < 4096; j++) {
 | 
			
		||||
                    int y = i4 + (j >> 8);
 | 
			
		||||
                    int a = j - ((y & 0xF) << 8);
 | 
			
		||||
                    int z1 = a >> 4;
 | 
			
		||||
                    int x1 = a - (z1 << 4);
 | 
			
		||||
                    x_loc[i][j] = (short) x1;
 | 
			
		||||
                    y_loc[i][j] = (short) y;
 | 
			
		||||
                    z_loc[i][j] = (short) z1;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (CACHE_I == null) {
 | 
			
		||||
            CACHE_I = new short[256][16][16];
 | 
			
		||||
            CACHE_J = new short[256][16][16];
 | 
			
		||||
            for (int x = 0; x < 16; x++) {
 | 
			
		||||
                for (int z = 0; z < 16; z++) {
 | 
			
		||||
                    for (int y = 0; y < 256; y++) {
 | 
			
		||||
                        short i = (short) (y >> 4);
 | 
			
		||||
                        short j = (short) ((y & 0xF) << 8 | z << 4 | x);
 | 
			
		||||
                        CACHE_I[y][x][z] = i;
 | 
			
		||||
                        CACHE_J[y][x][z] = j;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Send a message to the player.
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user