[BLEEDING] Some missing parts [might still be missing some].

Set to bleeding, because the last commits are. Bukkit-API-only access
shortly tested. There will be issues, but this might help over the
darkest of days.
This commit is contained in:
asofold 2013-01-20 05:25:21 +01:00
parent 4c6798b979
commit 762ae9174d
3 changed files with 40 additions and 15 deletions

View File

@ -14,25 +14,29 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.potion.PotionEffectType;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.BlockPropertiesSetup;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
import fr.neatmonster.nocheatplus.utilities.PotionUtil;
public class MCAccessBukkit implements MCAccess{
public class MCAccessBukkit implements MCAccess, BlockPropertiesSetup{
/**
* Constructor to let it fail.
*/
public MCAccessBukkit(){
// TODO: ...
// TODO: Add more that might fail if not supported ?
Material.AIR.isSolid();
Material.AIR.isOccluding();
// TODO: Deactivate checks that might not work. => MCAccess should have availability method, NCP deactivates check on base of that.
}
@Override
public String getMCVersion() {
// Bukkit API.
// TODO: maybe output something else.
return "?";
return "1.4.6|1.4.7|?";
}
@Override
@ -146,5 +150,15 @@ public class MCAccessBukkit implements MCAccess{
player.setHealth(0);
player.damage(1);
}
@Override
public void setupBlockProperties() {
// TODO Set some generic properties matching what BlockCache.getShape returns.
for (Material mat : Material.values()){
if (!mat.isOccluding() || !mat.isSolid() || mat.isTransparent()){
BlockProperties.setBlockFlags(mat.getId(), BlockProperties.getBLockFlags(mat.getId()) | BlockProperties.F_IGN_PASSABLE);
}
}
}
}

View File

@ -445,12 +445,18 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
TickTask.cancel();
TickTask.reset();
// Reset MCAccess.
mcAccess = null;
// Read the configuration files.
ConfigManager.init(this);
// Setup file logger.
StaticLogFile.setupLogger(new File(getDataFolder(), ConfigManager.getConfigFile().getString(ConfPaths.LOGGING_FILENAME)));
// Set up BlockProperties.
BlockProperties.init(getMCAccess());
// Allow entries to TickTask (just in case).
TickTask.setLocked(false);
@ -472,6 +478,22 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
addComponent(nameSetPerms);
addListener(getCoreListener());
for (final Object obj : new Object[]{
// Put ReloadListener first, because Checks could also listen to it.
new INotifyReload() {
// Only for reloading, not INeedConfig.
@Override
public void onReload() {
// Reset MCAccess.
mcAccess = null;
// Reset BlockProperties.
BlockProperties.init(getMCAccess());
final ConfigFile config = ConfigManager.getConfigFile();
BlockProperties.applyConfig(config, ConfPaths.COMPATIBILITY_BLOCKS);
// Reset Command protection.
undoCommandChanges();
if (config.getBoolean(ConfPaths.MISCELLANEOUS_PROTECTPLUGINS)) setupCommandProtection();
}
},
NCPExemptionManager.getListener(),
dataMan,
new BlockBreakListener(),
@ -483,17 +505,6 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
new FightListener(),
new InventoryListener(),
new MovingListener(),
new INotifyReload() {
@Override
public void onReload() {
// Only for reloading, not INeedConfig.
BlockProperties.init(getMCAccess());
final ConfigFile config = ConfigManager.getConfigFile();
BlockProperties.applyConfig(config, ConfPaths.COMPATIBILITY_BLOCKS);
undoCommandChanges();
if (config.getBoolean(ConfPaths.MISCELLANEOUS_PROTECTPLUGINS)) setupCommandProtection();
}
},
}){
addComponent(obj);
}

View File

@ -76,8 +76,8 @@ public class MCAccessFactory {
else{
msg = "[NoCheatPlus] Could not set up native access for your specific Minecraft + server-mod version.";
}
LogUtil.logWarning("[NoCheatPlus] Some features will likely not function properly, performance might suffer.");
LogUtil.logWarning(msg);
LogUtil.logWarning("[NoCheatPlus] Some features will likely not function properly, performance might suffer.");
for (String uMsg : updateLocs){
LogUtil.logWarning(uMsg);
}