diff --git a/NCPCompatGlowstone/pom.xml b/NCPCompatGlowstone/pom.xml new file mode 100644 index 00000000..ce42aabb --- /dev/null +++ b/NCPCompatGlowstone/pom.xml @@ -0,0 +1,45 @@ + + 4.0.0 + fr.neatmonster + ncpcompatglowstone + jar + NCPCompatGlowstone + static + + + fr.neatmonster + nocheatplus-parent + static + + + + + glowstone-repo + Glowstone Repository + http://repo.glowstone.net/content/groups/public/ + + + + + + fr.neatmonster + ncpcore + static + + + net.glowstone + glowstone + LATEST + + + fr.neatmonster + ncpcompatbukkit + static + + + + Native compatibility for Glowstone (experimental): +http://glowstone.net + + \ No newline at end of file diff --git a/NCPCompatGlowstone/src/main/java/fr/neatmonster/nocheatplus/compat/glowstone/BlockCacheGlowstone.java b/NCPCompatGlowstone/src/main/java/fr/neatmonster/nocheatplus/compat/glowstone/BlockCacheGlowstone.java new file mode 100644 index 00000000..b8fac41d --- /dev/null +++ b/NCPCompatGlowstone/src/main/java/fr/neatmonster/nocheatplus/compat/glowstone/BlockCacheGlowstone.java @@ -0,0 +1,15 @@ +package fr.neatmonster.nocheatplus.compat.glowstone; + +import org.bukkit.World; + +import fr.neatmonster.nocheatplus.compat.bukkit.BlockCacheBukkit; + +public class BlockCacheGlowstone extends BlockCacheBukkit{ + + public BlockCacheGlowstone(World world) { + super(world); + } + + // TODO: What now? :p + +} diff --git a/NCPCompatGlowstone/src/main/java/fr/neatmonster/nocheatplus/compat/glowstone/MCAccessGlowstone.java b/NCPCompatGlowstone/src/main/java/fr/neatmonster/nocheatplus/compat/glowstone/MCAccessGlowstone.java new file mode 100644 index 00000000..3b9c937a --- /dev/null +++ b/NCPCompatGlowstone/src/main/java/fr/neatmonster/nocheatplus/compat/glowstone/MCAccessGlowstone.java @@ -0,0 +1,56 @@ +package fr.neatmonster.nocheatplus.compat.glowstone; + +import net.glowstone.GlowServer; +import net.glowstone.entity.GlowPlayer; + +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.command.CommandMap; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import fr.neatmonster.nocheatplus.compat.bukkit.MCAccessBukkit; +import fr.neatmonster.nocheatplus.utilities.BlockCache; + +public class MCAccessGlowstone extends MCAccessBukkit{ + + // TODO: Glowstone: nodamageticks > 0 => damage(...) won't work (no updating). + + /** + * Constructor to let it fail. + */ + public MCAccessGlowstone() { + super(); + getCommandMap(); + // TODO: Nail it down further. + } + + @Override + public String getMCVersion() { + // Might work with earlier versions. + return "1.8"; + } + + @Override + public String getServerVersionTag() { + // TODO: Consider version specific ? + return "Glowstone"; + } + + @Override + public CommandMap getCommandMap() { + return ((GlowServer) Bukkit.getServer()).getCommandMap(); + } + + @Override + public BlockCache getBlockCache(final World world) { + return new BlockCacheGlowstone(world); + } + + @Override + public void dealFallDamage(final Player player, final double damage) { + // NOTE: Fires a damage event. + ((GlowPlayer) player).damage(damage, DamageCause.FALL); + } + +} diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/MCAccess.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/MCAccess.java index 16ecf811..ce1f2e93 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/MCAccess.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/MCAccess.java @@ -61,21 +61,21 @@ public interface MCAccess { /** * NMS Block static. * @param id - * @return + * @return MAYBE if undecided, TRUE or FALSE if decided. */ public AlmostBoolean isBlockSolid(int id); /** * NMS Block static.. * @param id - * @return + * @return MAYBE if undecided, TRUE or FALSE if decided. */ public AlmostBoolean isBlockLiquid(int id); /** * Does only check y bounds, returns false if dead. this is half a check as auxiliary means for PlayerLocation.isIllegal. * @param player - * @return null If undecided, true / false if decided. + * @return MAYBE if undecided, TRUE or FALSE if decided. */ public AlmostBoolean isIllegalBounds(Player player); diff --git a/NCPPlugin/pom.xml b/NCPPlugin/pom.xml index 0c2f447b..bb8dd910 100644 --- a/NCPPlugin/pom.xml +++ b/NCPPlugin/pom.xml @@ -103,6 +103,11 @@ ncpcompatprotocollib static + + fr.neatmonster + ncpcompatglowstone + static + diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/compat/MCAccessFactory.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/compat/MCAccessFactory.java index 94f7fcef..0b9d802d 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/compat/MCAccessFactory.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/compat/MCAccessFactory.java @@ -19,6 +19,7 @@ import fr.neatmonster.nocheatplus.compat.cb2922.MCAccessCB2922; import fr.neatmonster.nocheatplus.compat.cb3026.MCAccessCB3026; import fr.neatmonster.nocheatplus.compat.cb3043.MCAccessCB3043; import fr.neatmonster.nocheatplus.compat.cbdev.MCAccessCBDev; +import fr.neatmonster.nocheatplus.compat.glowstone.MCAccessGlowstone; import fr.neatmonster.nocheatplus.config.ConfPaths; import fr.neatmonster.nocheatplus.config.ConfigManager; import fr.neatmonster.nocheatplus.logging.LogUtil; @@ -29,174 +30,194 @@ import fr.neatmonster.nocheatplus.logging.LogUtil; * */ public class MCAccessFactory { - - private final String[] updateLocs = new String[]{ - "[NoCheatPlus] Check for updates and support at BukkitDev: http://dev.bukkit.org/server-mods/nocheatplus/", - "[NoCheatPlus] Development builds (unsupported by the Bukkit Staff, at your own risk): http://ci.md-5.net/job/NoCheatPlus/changes", - }; - - /** - * Get a new MCAccess instance using the config value for ConfPaths.COMPATIBILITY_BUKKITONLY. - * @return MCAccess instance. - * @throws RuntimeException if no access can be set. - */ - public MCAccess getMCAccess() { - return getMCAccess(ConfigManager.getConfigFile().getBoolean(ConfPaths.COMPATIBILITY_BUKKITONLY)); - } - - /** - * Get a new MCAccess instance. - * @param bukkitOnly Set to true to force using an API-only module. - * @return - * @throws RuntimeException if no access can be set. - */ - public MCAccess getMCAccess(final boolean bukkitOnly) { - final List throwables = new ArrayList(); - - // Try to set up native access. - if (!bukkitOnly) { - - // TEMP // - // Only add as long as no stable module has been added. - // 1.7.10 - try{ - return new MCAccessCBDev(); - } - catch(Throwable t) { - throwables.add(t); - }; - // TEMP END // - - // 1.7.8|1.7.9 - try{ - return new MCAccessCB3043(); - } - catch(Throwable t) { - throwables.add(t); - }; - - // 1.7.5 - try{ - return new MCAccessCB3026(); - } - catch(Throwable t) { - throwables.add(t); - }; - - // 1.7.2 - try{ - return new MCAccessCB2922(); - } - catch(Throwable t) { - throwables.add(t); - }; - - // 1.6.4 - try{ - return new MCAccessCB2882(); - } - catch(Throwable t) { - throwables.add(t); - }; - - // 1.6.2 - try{ - return new MCAccessCB2808(); - } - catch(Throwable t) { - throwables.add(t); - }; - - // 1.6.1 - try{ - return new MCAccessCB2794(); - } - catch(Throwable t) { - throwables.add(t); - }; - - // 1.5.2 - try{ - return new MCAccessCB2763(); - } - catch(Throwable t) { - throwables.add(t); - }; - - // 1.5.1 (cb beta) - try{ - return new MCAccessCB2691(); - } - catch(Throwable t) { - throwables.add(t); - }; - - // 1.5 - try{ - return new MCAccessCB2645(); - } - catch(Throwable t) { - throwables.add(t); - }; - - // 1.4.7 - try{ - return new MCAccessCB2602(); - } - catch(Throwable t) { - throwables.add(t); - }; - - // 1.4.6 - try{ - return new MCAccessCB2545(); - } - catch(Throwable t) { - throwables.add(t); - }; - - // 1.4.5-R1.0 - try{ - return new MCAccessCB2512(); - } - catch(Throwable t) { - throwables.add(t); - }; - - } - - // Try to set up api-only access (since 1.4.6). - try{ - final String msg; - if (bukkitOnly) { - msg = "[NoCheatPlus] The plugin is configured for Bukkit-API-only access."; - } - else{ - msg = "[NoCheatPlus] Could not set up native access for the server-mod (" + Bukkit.getServer().getVersion() + "). Please check for updates and consider to request support."; - for (String uMsg : updateLocs) { - LogUtil.logWarning(uMsg); - } - } - LogUtil.logWarning(msg); - final MCAccess mcAccess = new MCAccessBukkit(); - LogUtil.logWarning("[NoCheatPlus] Bukkit-API-only access: Some features will likely not function properly, performance might suffer."); - return mcAccess; - } - catch(Throwable t) { - throwables.add(t); - }; - - // All went wrong. - // TODO: Fall-back solution (disable plugin, disable checks). - LogUtil.logSevere("[NoCheatPlus] Your version of NoCheatPlus is not compatible with the version of the server-mod (" + Bukkit.getServer().getVersion() + "). Please check for updates and consider to request support."); - for (String msg : updateLocs) { - LogUtil.logSevere(msg); - } - LogUtil.logSevere("[NoCheatPlus] >>> Failed to set up MCAccess <<<"); - for (Throwable t : throwables ) { - LogUtil.logSevere(t); - } - // TODO: Schedule disabling the plugin or running in circles. - throw new RuntimeException("Could not set up native access to the server mod, neither to the Bukkit-API."); - } + + private final String[] updateLocs = new String[]{ + "[NoCheatPlus] Check for updates and support at BukkitDev: http://dev.bukkit.org/server-mods/nocheatplus/", + "[NoCheatPlus] Development builds (unsupported by the Bukkit Staff, at your own risk): http://ci.md-5.net/job/NoCheatPlus/changes", + }; + + /** + * Get a new MCAccess instance using the config value for ConfPaths.COMPATIBILITY_BUKKITONLY. + * @return MCAccess instance. + * @throws RuntimeException if no access can be set. + */ + public MCAccess getMCAccess() { + return getMCAccess(ConfigManager.getConfigFile().getBoolean(ConfPaths.COMPATIBILITY_BUKKITONLY)); + } + + /** + * Get a new MCAccess instance. + * @param bukkitOnly Set to true to force using an API-only module. + * @return + * @throws RuntimeException if no access can be set. + */ + public MCAccess getMCAccess(final boolean bukkitOnly) { + final List throwables = new ArrayList(); + + // Try to set up native access. + if (!bukkitOnly) { + MCAccess mcAccess = getMCAccessCraftBukkit(throwables); + if (mcAccess != null) { + return mcAccess; + } + try { + return new MCAccessGlowstone(); + } catch(Throwable t) { + throwables.add(t); + }; + } + + // Try to set up api-only access (since 1.4.6). + try{ + final String msg; + if (bukkitOnly) { + msg = "[NoCheatPlus] The plugin is configured for Bukkit-API-only access."; + } + else{ + msg = "[NoCheatPlus] Could not set up native access for the server-mod (" + Bukkit.getServer().getVersion() + "). Please check for updates and consider to request support."; + for (String uMsg : updateLocs) { + LogUtil.logWarning(uMsg); + } + } + LogUtil.logWarning(msg); + final MCAccess mcAccess = new MCAccessBukkit(); + LogUtil.logWarning("[NoCheatPlus] Bukkit-API-only access: Some features will likely not function properly, performance might suffer."); + return mcAccess; + } + catch(Throwable t) { + throwables.add(t); + }; + + // All went wrong. + // TODO: Fall-back solution (disable plugin, disable checks). + LogUtil.logSevere("[NoCheatPlus] Your version of NoCheatPlus is not compatible with the version of the server-mod (" + Bukkit.getServer().getVersion() + "). Please check for updates and consider to request support."); + for (String msg : updateLocs) { + LogUtil.logSevere(msg); + } + LogUtil.logSevere("[NoCheatPlus] >>> Failed to set up MCAccess <<<"); + for (Throwable t : throwables ) { + LogUtil.logSevere(t); + } + // TODO: Schedule disabling the plugin or running in circles. + throw new RuntimeException("Could not set up native access to the server mod, neither to the Bukkit-API."); + } + + /** + * Must not throw anything. + * @param throwables + * @return Valid MCAccess instance or null. + */ + private MCAccess getMCAccessCraftBukkit(List throwables) { + + // TODO: Quick return check (note special forks and package info not being usable). + + // TEMP // + // Only add as long as no stable module has been added. + // 1.7.10 + try{ + return new MCAccessCBDev(); + } + catch(Throwable t) { + throwables.add(t); + }; + // TEMP END // + + // 1.7.8|1.7.9 + try{ + return new MCAccessCB3043(); + } + catch(Throwable t) { + throwables.add(t); + }; + + // 1.7.5 + try{ + return new MCAccessCB3026(); + } + catch(Throwable t) { + throwables.add(t); + }; + + // 1.7.2 + try{ + return new MCAccessCB2922(); + } + catch(Throwable t) { + throwables.add(t); + }; + + // 1.6.4 + try{ + return new MCAccessCB2882(); + } + catch(Throwable t) { + throwables.add(t); + }; + + // 1.6.2 + try{ + return new MCAccessCB2808(); + } + catch(Throwable t) { + throwables.add(t); + }; + + // 1.6.1 + try{ + return new MCAccessCB2794(); + } + catch(Throwable t) { + throwables.add(t); + }; + + // 1.5.2 + try{ + return new MCAccessCB2763(); + } + catch(Throwable t) { + throwables.add(t); + }; + + // 1.5.1 (cb beta) + try{ + return new MCAccessCB2691(); + } + catch(Throwable t) { + throwables.add(t); + }; + + // 1.5 + try{ + return new MCAccessCB2645(); + } + catch(Throwable t) { + throwables.add(t); + }; + + // 1.4.7 + try{ + return new MCAccessCB2602(); + } + catch(Throwable t) { + throwables.add(t); + }; + + // 1.4.6 + try{ + return new MCAccessCB2545(); + } + catch(Throwable t) { + throwables.add(t); + }; + + // 1.4.5-R1.0 + try{ + return new MCAccessCB2512(); + } + catch(Throwable t) { + throwables.add(t); + }; + return null; + } + } diff --git a/NoCheatPlus/pom.xml b/NoCheatPlus/pom.xml index 0afad281..2cc02011 100644 --- a/NoCheatPlus/pom.xml +++ b/NoCheatPlus/pom.xml @@ -104,6 +104,7 @@ fr.neatmonster:ncpcompatcb3043 fr.neatmonster:ncpcompatcbdev fr.neatmonster:ncpcompatprotocollib + fr.neatmonster:ncpcompatglowstone fr.neatmonster:ncpplugin diff --git a/pom.xml b/pom.xml index 61b72a0f..694f259e 100644 --- a/pom.xml +++ b/pom.xml @@ -32,6 +32,7 @@ NCPCompatCB3043 NCPCompatCBDev NCPCompatProtocolLib + NCPCompatGlowstone NCPPlugin NoCheatPlus