Add ability to run extra BlockProperties setup if MCAccess implements

the interface.
This commit is contained in:
asofold 2013-01-20 04:31:00 +01:00
parent ee1f410dae
commit 835ae9cb26
3 changed files with 20 additions and 1 deletions

View File

@ -0,0 +1,14 @@
package fr.neatmonster.nocheatplus.compat;
/**
* Provide a setup method for additional BlockProperties initialization.<br>
* Typically MCAccess can implement it. TODO: An extra factory for Bukkit level.
* @author mc_dev
*
*/
public interface BlockPropertiesSetup {
/**
* Additional initialization.
*/
public void setupBlockProperties();
}

View File

@ -12,8 +12,9 @@ import fr.neatmonster.nocheatplus.utilities.BlockCache;
* Compatibility interface to get properties for Bukkit instances that need access of CraftBukkit or Minecraft classes.<br> * Compatibility interface to get properties for Bukkit instances that need access of CraftBukkit or Minecraft classes.<br>
* NOTE: All methods returning AlmostBoolean must never return null, unless stated otherwise.<br> * NOTE: All methods returning AlmostBoolean must never return null, unless stated otherwise.<br>
* NOTE: Expect API changes in the near future!<br> * NOTE: Expect API changes in the near future!<br>
* NOTE: If an instance implements BlockPropertiesSetup, the setup method will be called after basic initialization but before configuration is applied.<br>
* <hr> * <hr>
* TODO: Make minimal (do we need WorldServer yet)? * TODO: Make minimal.
* @author mc_dev * @author mc_dev
* *
*/ */

View File

@ -15,6 +15,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import fr.neatmonster.nocheatplus.compat.BlockPropertiesSetup;
import fr.neatmonster.nocheatplus.compat.MCAccess; import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.config.RawConfigFile; import fr.neatmonster.nocheatplus.config.RawConfigFile;
import fr.neatmonster.nocheatplus.config.RootConfPaths; import fr.neatmonster.nocheatplus.config.RootConfPaths;
@ -277,6 +278,9 @@ public class BlockProperties {
try{ try{
initTools(mcAccess); initTools(mcAccess);
initBlocks(mcAccess); initBlocks(mcAccess);
if (mcAccess instanceof BlockPropertiesSetup){
((BlockPropertiesSetup) mcAccess).setupBlockProperties();
}
} }
catch(Throwable t){ catch(Throwable t){
LogUtil.logSevere(t); LogUtil.logSevere(t);