mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-02-16 03:31:37 +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.
|
* NMS Block static.
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return MAYBE if undecided, TRUE or FALSE if decided.
|
||||||
*/
|
*/
|
||||||
public AlmostBoolean isBlockSolid(int id);
|
public AlmostBoolean isBlockSolid(int id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NMS Block static..
|
* NMS Block static..
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return MAYBE if undecided, TRUE or FALSE if decided.
|
||||||
*/
|
*/
|
||||||
public AlmostBoolean isBlockLiquid(int id);
|
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.
|
* Does only check y bounds, returns false if dead. this is half a check as auxiliary means for PlayerLocation.isIllegal.
|
||||||
* @param player
|
* @param player
|
||||||
* @return null If undecided, true / false if decided.
|
* @return MAYBE if undecided, TRUE or FALSE if decided.
|
||||||
*/
|
*/
|
||||||
public AlmostBoolean isIllegalBounds(Player player);
|
public AlmostBoolean isIllegalBounds(Player player);
|
||||||
|
|
||||||
|
@ -103,6 +103,11 @@
|
|||||||
<artifactId>ncpcompatprotocollib</artifactId>
|
<artifactId>ncpcompatprotocollib</artifactId>
|
||||||
<version>static</version>
|
<version>static</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>fr.neatmonster</groupId>
|
||||||
|
<artifactId>ncpcompatglowstone</artifactId>
|
||||||
|
<version>static</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<!-- Properties -->
|
<!-- Properties -->
|
||||||
|
@ -19,6 +19,7 @@ import fr.neatmonster.nocheatplus.compat.cb2922.MCAccessCB2922;
|
|||||||
import fr.neatmonster.nocheatplus.compat.cb3026.MCAccessCB3026;
|
import fr.neatmonster.nocheatplus.compat.cb3026.MCAccessCB3026;
|
||||||
import fr.neatmonster.nocheatplus.compat.cb3043.MCAccessCB3043;
|
import fr.neatmonster.nocheatplus.compat.cb3043.MCAccessCB3043;
|
||||||
import fr.neatmonster.nocheatplus.compat.cbdev.MCAccessCBDev;
|
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.ConfPaths;
|
||||||
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
||||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||||
@ -55,6 +56,60 @@ public class MCAccessFactory {
|
|||||||
|
|
||||||
// Try to set up native access.
|
// Try to set up native access.
|
||||||
if (!bukkitOnly) {
|
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 //
|
// TEMP //
|
||||||
// Only add as long as no stable module has been added.
|
// Only add as long as no stable module has been added.
|
||||||
@ -162,41 +217,7 @@ public class MCAccessFactory {
|
|||||||
catch(Throwable t) {
|
catch(Throwable t) {
|
||||||
throwables.add(t);
|
throwables.add(t);
|
||||||
};
|
};
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -104,6 +104,7 @@
|
|||||||
<include>fr.neatmonster:ncpcompatcb3043</include>
|
<include>fr.neatmonster:ncpcompatcb3043</include>
|
||||||
<include>fr.neatmonster:ncpcompatcbdev</include>
|
<include>fr.neatmonster:ncpcompatcbdev</include>
|
||||||
<include>fr.neatmonster:ncpcompatprotocollib</include>
|
<include>fr.neatmonster:ncpcompatprotocollib</include>
|
||||||
|
<include>fr.neatmonster:ncpcompatglowstone</include>
|
||||||
<include>fr.neatmonster:ncpplugin</include>
|
<include>fr.neatmonster:ncpplugin</include>
|
||||||
<!-- <include>fr.neatmonster:nocheatplus-parent</include> -->
|
<!-- <include>fr.neatmonster:nocheatplus-parent</include> -->
|
||||||
</includes>
|
</includes>
|
||||||
|
1
pom.xml
1
pom.xml
@ -32,6 +32,7 @@
|
|||||||
<module>NCPCompatCB3043</module>
|
<module>NCPCompatCB3043</module>
|
||||||
<module>NCPCompatCBDev</module>
|
<module>NCPCompatCBDev</module>
|
||||||
<module>NCPCompatProtocolLib</module>
|
<module>NCPCompatProtocolLib</module>
|
||||||
|
<module>NCPCompatGlowstone</module>
|
||||||
<module>NCPPlugin</module>
|
<module>NCPPlugin</module>
|
||||||
<module>NoCheatPlus</module>
|
<module>NoCheatPlus</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
Loading…
Reference in New Issue
Block a user