@@ -0,0 +1,3371 @@
+/*%0A * Copyright 2017 Christian Aguirre %3Cpvpaguirre@gmail.com%3E.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage uk.org.whoami.authme.listener;%0A%0Aimport org.bukkit.entity.Entity;%0Aimport org.bukkit.entity.Player;%0Aimport org.bukkit.event.entity.EntityDamageEvent;%0Aimport org.bukkit.event.entity.EntityListener;%0Aimport org.bukkit.event.entity.EntityTargetEvent;%0Aimport org.bukkit.event.entity.FoodLevelChangeEvent;%0A%0Aimport uk.org.whoami.authme.cache.auth.PlayerCache;%0Aimport uk.org.whoami.authme.citizens.CitizensCommunicator;%0Aimport uk.org.whoami.authme.datasource.DataSource;%0Aimport uk.org.whoami.authme.settings.Settings;%0A%0Apublic class AuthMeEntityListener extends EntityListener %7B%0A%0A    private DataSource data;%0A    private Settings settings = Settings.getInstance();%0A%0A    public AuthMeEntityListener(DataSource data) %7B%0A        this.data = data;%0A    %7D%0A%0A    @Override%0A    public void onEntityDamage(EntityDamageEvent event) %7B%0A        if (event.isCancelled()) %7B%0A            return;%0A        %7D%0A        Entity entity = event.getEntity();%0A        if (!(entity instanceof Player)) %7B%0A            return;%0A        %7D%0A%0A        if(CitizensCommunicator.isNPC(entity)) %7B%0A            return;%0A        %7D%0A%0A        Player player = (Player) entity;%0A        String name = player.getName().toLowerCase();%0A%0A        if (PlayerCache.getInstance().isAuthenticated(name)) %7B%0A            return;%0A        %7D%0A%0A        if (!data.isAuthAvailable(name)) %7B%0A            if (!settings.isForcedRegistrationEnabled()) %7B%0A                return;%0A            %7D%0A        %7D%0A%0A        event.setCancelled(true);%0A    %7D%0A%0A    @Override%0A    public void onEntityTarget(EntityTargetEvent event) %7B%0A        if (event.isCancelled()) %7B%0A            return;%0A        %7D%0A%0A        Entity entity = event.getEntity();%0A        if (!(entity instanceof Player)) %7B%0A            return;%0A        %7D%0A%0A        Player player = (Player) entity;%0A        String name = player.getName().toLowerCase();%0A%0A        if (PlayerCache.getInstance().isAuthenticated(name)) %7B%0A            return;%0A        %7D%0A%0A        if (!data.isAuthAvailable(name)) %7B%0A            if (!settings.isForcedRegistrationEnabled()) %7B%0A                return;%0A            %7D%0A        %7D%0A%0A        event.setCancelled(true);%0A    %7D%0A%0A    @Override%0A    public void onFoodLevelChange(FoodLevelChangeEvent event) %7B%0A        if (event.isCancelled()) %7B%0A            return;%0A        %7D%0A%0A        Entity entity = event.getEntity();%0A        if (!(entity instanceof Player)) %7B%0A            return;%0A        %7D%0A%0A        Player player = (Player) entity;%0A        String name = player.getName().toLowerCase();%0A%0A        if (PlayerCache.getInstance().isAuthenticated(name)) %7B%0A            return;%0A        %7D%0A%0A        if (!data.isAuthAvailable(name)) %7B%0A            if (!settings.isForcedRegistrationEnabled()) %7B%0A                return;%0A            %7D%0A        %7D%0A%0A        event.setCancelled(true);%0A    %7D%0A%7D%0A

Create AuthMeEntityListener.java