Package com.onarandombox.MultiverseCore.configuration

Source Code of com.onarandombox.MultiverseCore.configuration.WorldPropertyValidator

package com.onarandombox.MultiverseCore.configuration;

import org.bukkit.Bukkit;

import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.event.MVWorldPropertyChangeEvent;

import me.main__.util.SerializationConfig.ChangeDeniedException;
import me.main__.util.SerializationConfig.ObjectUsingValidator;

/**
* Validates world-property-changes.
* @param <T> The type of the property that should be validated.
*/
public class WorldPropertyValidator<T> extends ObjectUsingValidator<T, MVWorld> {
    /**
     * {@inheritDoc}
     */
    @Override
    public T validateChange(String property, T newValue, T oldValue, MVWorld object) throws ChangeDeniedException {
        MVWorldPropertyChangeEvent<T> event = new MVWorldPropertyChangeEvent<T>(object, null, property, newValue);
        Bukkit.getPluginManager().callEvent(event);
        if (event.isCancelled())
            throw new ChangeDeniedException();
        return event.getTheNewValue();
    }
}
TOP

Related Classes of com.onarandombox.MultiverseCore.configuration.WorldPropertyValidator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.