<commit_before>package com.aaomidi.justskyblock.engine.protection.events;

import org.bukkit.event.Listener;

/**
 * @author aaomidi
 */
public class SkyblockIslandProtectedEvent implements Listener {

}<commit_msg>Blocks entry to islands player does not have permission to.<commit_after>package com.aaomidi.justskyblock.engine.protection.events;

import com.aaomidi.justskyblock.JustSkyblock;
import com.aaomidi.justskyblock.engine.objects.SkyblockPermission;
import com.aaomidi.justskyblock.engine.objects.SkyblockPlayer;
import com.aaomidi.justskyblock.engine.objects.enums.PermissionLevel;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;

/**
 * @author aaomidi
 */
public class SkyblockIslandProtectedEvent implements Listener {
    private final JustSkyblock instance;

    public SkyblockIslandProtectedEvent(JustSkyblock instance) {
        this.instance = instance;
    }

    public void onIslandEnter(PlayerMoveEvent event) {
        if (event.getFrom().toVector().distanceSquared(event.getTo().toVector()) < 1) {
            return;
        }
        Player player = event.getPlayer();
        //TODO: Make this point somewhere
        SkyblockPlayer skyblockPlayer = null;
        for (SkyblockPermission perm : skyblockPlayer.getSkyblockPermissions()) {
            if (!perm.isInIsland(player.getLocation())) {
                continue;
            }
            if (!perm.getPermissionLevel().equals(PermissionLevel.BUILDING) || !perm.getPermissionLevel().equals(PermissionLevel.ENTERING) || !perm.getPermissionLevel().equals(PermissionLevel.OWNERSHIP)) {
                //TODO: Send message to player that they're not allowed to enter the island.
                event.setCancelled(true);
            }
        }

    }
}
{'fraction_non_alphanumeric': 0.10022148394241417, 'fraction_numerical': 0.0005537098560354374, 'mean_word_length': 3.5175, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2898393', 'n_tokens_mistral': 524, 'n_tokens_neox': 498, 'n_words': 96}