mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-02-14 18:52:04 +01:00
[BLIND] Add dedicated compatibility module for Glowstone.
This is extending the classes for Bukkit (API only), and only overriding very few methods, such as getCommandMap, dealFallDamage.
This commit is contained in:
parent
43dea0830a
commit
7b2a680ead
45
NCPCompatGlowstone/pom.xml
Normal file
45
NCPCompatGlowstone/pom.xml
Normal file
@ -0,0 +1,45 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcompatglowstone</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>NCPCompatGlowstone</name>
|
||||
<version>static</version>
|
||||
|
||||
<parent>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>nocheatplus-parent</artifactId>
|
||||
<version>static</version>
|
||||
</parent>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>glowstone-repo</id>
|
||||
<name>Glowstone Repository</name>
|
||||
<url>http://repo.glowstone.net/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcore</artifactId>
|
||||
<version>static</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.glowstone</groupId>
|
||||
<artifactId>glowstone</artifactId>
|
||||
<version>LATEST</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcompatbukkit</artifactId>
|
||||
<version>static</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<description>Native compatibility for Glowstone (experimental):
|
||||
http://glowstone.net
|
||||
</description>
|
||||
</project>
|
@ -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
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
|
||||
|
@ -103,6 +103,11 @@
|
||||
<artifactId>ncpcompatprotocollib</artifactId>
|
||||
<version>static</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcompatglowstone</artifactId>
|
||||
<version>static</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- Properties -->
|
||||
|
@ -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<Throwable> throwables = new ArrayList<Throwable>();
|
||||
|
||||
// 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<Throwable> throwables = new ArrayList<Throwable>();
|
||||
|
||||
// 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<Throwable> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -104,6 +104,7 @@
|
||||
<include>fr.neatmonster:ncpcompatcb3043</include>
|
||||
<include>fr.neatmonster:ncpcompatcbdev</include>
|
||||
<include>fr.neatmonster:ncpcompatprotocollib</include>
|
||||
<include>fr.neatmonster:ncpcompatglowstone</include>
|
||||
<include>fr.neatmonster:ncpplugin</include>
|
||||
<!-- <include>fr.neatmonster:nocheatplus-parent</include> -->
|
||||
</includes>
|
||||
|
Loading…
Reference in New Issue
Block a user