This commit is contained in:
asofold 2015-01-05 14:45:17 +01:00
parent 5f106dce1b
commit 39cc75c162
10 changed files with 411 additions and 410 deletions

View File

@ -26,66 +26,66 @@ import fr.neatmonster.nocheatplus.utilities.StringUtil;
*
*/
public class ProtocolLibComponent implements DisableListener, INotifyReload{
private final List<PacketAdapter> registeredPacketAdapters = new LinkedList<PacketAdapter>();
public ProtocolLibComponent(Plugin plugin) {
StaticLog.logInfo("Adding packet level hooks for ProtocolLib (MC " + ProtocolLibrary.getProtocolManager().getMinecraftVersion().getVersion() + ")...");
register(plugin);
}
private void register(Plugin plugin) {
// Register Classes having a constructor with Plugin as argument.
if (ConfigManager.isTrueForAnyConfig(ConfPaths.NET_FLYINGFREQUENCY_ACTIVE)) {
register(FlyingFrequency.class, plugin);
}
if (ConfigManager.isTrueForAnyConfig(ConfPaths.NET_SOUNDDISTANCE_ACTIVE)) {
register(SoundDistance.class, plugin);
}
if (!registeredPacketAdapters.isEmpty()) {
List<String> names = new ArrayList<String>(registeredPacketAdapters.size());
for (PacketAdapter adapter : registeredPacketAdapters) {
names.add(adapter.getClass().getSimpleName());
}
StaticLog.logInfo("[NoCheatPlus] Available (and activated) packet level hooks: " + StringUtil.join(names, " | "));
}
}
private void register(Class<? extends PacketAdapter> clazz, Plugin plugin) {
try {
// Construct a new instance using reflection.
PacketAdapter adapter = clazz.getDeclaredConstructor(Plugin.class).newInstance(plugin);
ProtocolLibrary.getProtocolManager().addPacketListener(adapter);
registeredPacketAdapters.add(adapter);
} catch (Throwable t) {
StaticLog.logWarning("[NoCheatPlus] Could not register packet level hook: " + clazz.getSimpleName());
StaticLog.logWarning(t);
}
}
private final List<PacketAdapter> registeredPacketAdapters = new LinkedList<PacketAdapter>();
@Override
public void onDisable() {
unregister();
}
public ProtocolLibComponent(Plugin plugin) {
StaticLog.logInfo("Adding packet level hooks for ProtocolLib (MC " + ProtocolLibrary.getProtocolManager().getMinecraftVersion().getVersion() + ")...");
register(plugin);
}
@Override
public void onReload() {
unregister();
register(Bukkit.getPluginManager().getPlugin("NoCheatPlus")); // Store instead ?
}
private void unregister() {
final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
final NoCheatPlusAPI api = NCPAPIProvider.getNoCheatPlusAPI();
for (PacketAdapter adapter : registeredPacketAdapters) {
try {
protocolManager.removePacketListener(adapter);
api.removeComponent(adapter); // Bit heavy, but consistent.
} catch (Throwable t) {
StaticLog.logWarning("[NoCheatPlus] Failed to unregister packet level hook: " + adapter.getClass().getName());
}
}
registeredPacketAdapters.clear();
}
private void register(Plugin plugin) {
// Register Classes having a constructor with Plugin as argument.
if (ConfigManager.isTrueForAnyConfig(ConfPaths.NET_FLYINGFREQUENCY_ACTIVE)) {
register(FlyingFrequency.class, plugin);
}
if (ConfigManager.isTrueForAnyConfig(ConfPaths.NET_SOUNDDISTANCE_ACTIVE)) {
register(SoundDistance.class, plugin);
}
if (!registeredPacketAdapters.isEmpty()) {
List<String> names = new ArrayList<String>(registeredPacketAdapters.size());
for (PacketAdapter adapter : registeredPacketAdapters) {
names.add(adapter.getClass().getSimpleName());
}
StaticLog.logInfo("[NoCheatPlus] Available (and activated) packet level hooks: " + StringUtil.join(names, " | "));
}
}
private void register(Class<? extends PacketAdapter> clazz, Plugin plugin) {
try {
// Construct a new instance using reflection.
PacketAdapter adapter = clazz.getDeclaredConstructor(Plugin.class).newInstance(plugin);
ProtocolLibrary.getProtocolManager().addPacketListener(adapter);
registeredPacketAdapters.add(adapter);
} catch (Throwable t) {
StaticLog.logWarning("[NoCheatPlus] Could not register packet level hook: " + clazz.getSimpleName());
StaticLog.logWarning(t);
}
}
@Override
public void onDisable() {
unregister();
}
@Override
public void onReload() {
unregister();
register(Bukkit.getPluginManager().getPlugin("NoCheatPlus")); // Store instead ?
}
private void unregister() {
final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
final NoCheatPlusAPI api = NCPAPIProvider.getNoCheatPlusAPI();
for (PacketAdapter adapter : registeredPacketAdapters) {
try {
protocolManager.removePacketListener(adapter);
api.removeComponent(adapter); // Bit heavy, but consistent.
} catch (Throwable t) {
StaticLog.logWarning("[NoCheatPlus] Failed to unregister packet level hook: " + adapter.getClass().getName());
}
}
registeredPacketAdapters.clear();
}
}

View File

@ -20,32 +20,33 @@ import fr.neatmonster.nocheatplus.utilities.StringUtil;
public class VersionCommand extends BaseCommand{
public VersionCommand(JavaPlugin plugin) {
super(plugin, "version", Permissions.COMMAND_VERSION, new String[]{"versions", "ver"});
}
public VersionCommand(JavaPlugin plugin) {
super(plugin, "version", Permissions.COMMAND_VERSION, new String[]{"versions", "ver"});
}
@Override
public boolean onCommand(CommandSender sender, Command command,
String label, String[] args) {
final MCAccess mc = NCPAPIProvider.getNoCheatPlusAPI().getMCAccess();
sender.sendMessage(new String[]{
"---- Version information ----",
"#### Server ####",
Bukkit.getServer().getVersion(),
"#### NoCheatPlus ####",
"Plugin: " + access.getDescription().getVersion(),
"MCAccess: " + mc.getMCVersion() + " / " + mc.getServerVersionTag(),
});
final Collection<NCPHook> hooks = NCPHookManager.getAllHooks();
if (!hooks.isEmpty()){
final List<String> fullNames = new LinkedList<String>();
for (final NCPHook hook : hooks){
fullNames.add(hook.getHookName() + " " + hook.getHookVersion());
}
Collections.sort(fullNames, String.CASE_INSENSITIVE_ORDER);
sender.sendMessage("Hooks: " + StringUtil.join(fullNames, " | "));
}
return true;
}
@Override
public boolean onCommand(CommandSender sender, Command command,
String label, String[] args) {
final MCAccess mc = NCPAPIProvider.getNoCheatPlusAPI().getMCAccess();
sender.sendMessage(new String[]{
"---- Version information ----",
"#### Server ####",
Bukkit.getServer().getVersion(),
"#### NoCheatPlus ####",
"Plugin: " + access.getDescription().getVersion(),
"MCAccess: " + mc.getMCVersion() + " / " + mc.getServerVersionTag(),
});
final Collection<NCPHook> hooks = NCPHookManager.getAllHooks();
if (!hooks.isEmpty()){
final List<String> fullNames = new LinkedList<String>();
for (final NCPHook hook : hooks){
fullNames.add(hook.getHookName() + " " + hook.getHookVersion());
}
Collections.sort(fullNames, String.CASE_INSENSITIVE_ORDER);
sender.sendMessage("Hooks: " + StringUtil.join(fullNames, " | "));
}
return true;
}
}

View File

@ -6,33 +6,33 @@ package fr.neatmonster.nocheatplus.compat;
*
*/
public enum AlmostBoolean{
YES,
NO,
MAYBE;
/**
* "Match" a boolean.
* @param value
* @return
*/
public static final AlmostBoolean match(final boolean value) {
return value ? YES : NO;
}
/**
* Pessimistic interpretation: true iff YES.
* @return
*/
public boolean decide(){
return this == YES;
}
/**
* Optimistic interpretation: true iff not NO.
* @return
*/
public boolean decideOptimistically() {
return this != NO;
}
YES,
NO,
MAYBE;
/**
* "Match" a boolean.
* @param value
* @return
*/
public static final AlmostBoolean match(final boolean value) {
return value ? YES : NO;
}
/**
* Pessimistic interpretation: true iff YES.
* @return
*/
public boolean decide(){
return this == YES;
}
/**
* Optimistic interpretation: true iff not NO.
* @return
*/
public boolean decideOptimistically() {
return this != NO;
}
}

View File

@ -11,9 +11,9 @@ import fr.neatmonster.nocheatplus.config.WorldConfigProvider;
*
*/
public interface BlockPropertiesSetup {
/**
* Additional initialization.
* @param worldConfigProvider Configuration provider if needed.
*/
public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider);
/**
* Additional initialization.
* @param worldConfigProvider Configuration provider if needed.
*/
public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider);
}

View File

@ -15,79 +15,79 @@ import fr.neatmonster.nocheatplus.utilities.BlockProperties;
*
*/
public class BlocksMC1_5 implements BlockPropertiesSetup {
public BlocksMC1_5(){
// Test if materials exist.
BlockInit.assertMaterialNameMatch(152, "redstone", "block");
}
@Override
public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider) {
/////////////////////
// New blocks
////////////////////
// 146 Trapped Chest
BlockInit.setAs(146, Material.CHEST);
// 147 Weighted Pressure Plate (Light)
// BlockFlags.addFlags(147, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
BlockInit.setAs(147, Material.STONE_PLATE);
public BlocksMC1_5(){
// Test if materials exist.
BlockInit.assertMaterialNameMatch(152, "redstone", "block");
}
// 148 Weighted Pressure Plate (Heavy)
// BlockFlags.addFlags(148, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
BlockInit.setAs(148, Material.STONE_PLATE);
// 149 Redstone Comparator (inactive)
// BlockFlags.addFlags(149, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
BlockInit.setAs(149, Material.DIODE_BLOCK_OFF);
// 150 Redstone Comparator (active)
// BlockFlags.addFlags(150, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
BlockInit.setAs(150, Material.DIODE_BLOCK_ON);
// 151 Daylight Sensor
// BlockFlags.addFlags(151, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
BlockInit.setAs(151, Material.HUGE_MUSHROOM_1);
// 152 Block of Redstone
BlockInit.setAs(152, Material.ENCHANTMENT_TABLE);
// 153 Nether Quartz Ore
BlockInit.setAs(153, Material.COAL_ORE);
// 154 Hopper
BlockInit.setAs(154, Material.COAL_ORE);
// TODO: Needs workaround. [workaround-flag + different purpose flag sets ?]
BlockFlags.addFlags(154, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND_HEIGHT);
// 155 Block of Quartz
BlockInit.setAs(155, Material.SANDSTONE);
// 156 Quartz Stairs
BlockInit.setAs(156, Material.SANDSTONE_STAIRS);
// 157 Activator Rail
BlockInit.setAs(157, Material.DETECTOR_RAIL);
// 158 Dropper
// BlockFlags.setFlagsAs(158, Material.DISPENSER);
BlockInit.setAs(158, Material.DISPENSER);
/////////////////////
// Changed blocks
////////////////////
// 78 Snow
BlockFlags.addFlags(78, BlockProperties.F_HEIGHT_8_INC);
BlockFlags.removeFlags(78, BlockProperties.F_HEIGHT_8SIM_INC);
// 95 Locked chest
BlockProperties.setBlockProps(95, BlockProperties.instantType);
StaticLog.logInfo("[NoCheatPlus] Added block-info for Minecraft 1.5 blocks.");
}
@Override
public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider) {
/////////////////////
// New blocks
////////////////////
// 146 Trapped Chest
BlockInit.setAs(146, Material.CHEST);
// 147 Weighted Pressure Plate (Light)
// BlockFlags.addFlags(147, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
BlockInit.setAs(147, Material.STONE_PLATE);
// 148 Weighted Pressure Plate (Heavy)
// BlockFlags.addFlags(148, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
BlockInit.setAs(148, Material.STONE_PLATE);
// 149 Redstone Comparator (inactive)
// BlockFlags.addFlags(149, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
BlockInit.setAs(149, Material.DIODE_BLOCK_OFF);
// 150 Redstone Comparator (active)
// BlockFlags.addFlags(150, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
BlockInit.setAs(150, Material.DIODE_BLOCK_ON);
// 151 Daylight Sensor
// BlockFlags.addFlags(151, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
BlockInit.setAs(151, Material.HUGE_MUSHROOM_1);
// 152 Block of Redstone
BlockInit.setAs(152, Material.ENCHANTMENT_TABLE);
// 153 Nether Quartz Ore
BlockInit.setAs(153, Material.COAL_ORE);
// 154 Hopper
BlockInit.setAs(154, Material.COAL_ORE);
// TODO: Needs workaround. [workaround-flag + different purpose flag sets ?]
BlockFlags.addFlags(154, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND_HEIGHT);
// 155 Block of Quartz
BlockInit.setAs(155, Material.SANDSTONE);
// 156 Quartz Stairs
BlockInit.setAs(156, Material.SANDSTONE_STAIRS);
// 157 Activator Rail
BlockInit.setAs(157, Material.DETECTOR_RAIL);
// 158 Dropper
// BlockFlags.setFlagsAs(158, Material.DISPENSER);
BlockInit.setAs(158, Material.DISPENSER);
/////////////////////
// Changed blocks
////////////////////
// 78 Snow
BlockFlags.addFlags(78, BlockProperties.F_HEIGHT_8_INC);
BlockFlags.removeFlags(78, BlockProperties.F_HEIGHT_8SIM_INC);
// 95 Locked chest
BlockProperties.setBlockProps(95, BlockProperties.instantType);
StaticLog.logInfo("[NoCheatPlus] Added block-info for Minecraft 1.5 blocks.");
}
}

View File

@ -12,33 +12,33 @@ import fr.neatmonster.nocheatplus.utilities.BlockProperties.BlockProps;
@SuppressWarnings("deprecation")
public class BlocksMC1_6_1 implements BlockPropertiesSetup{
public BlocksMC1_6_1(){
BlockInit.assertMaterialNameMatch(173, "coal", "block");
}
@Override
public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider) {
// Block of Coal: like block of redstone.
BlockInit.setAs(173, 152);
// Hardened Clay
BlockProperties.setBlockProps(172, new BlockProps(BlockProperties.woodPickaxe, 1.25f, BlockProperties.secToMs(6.25, 0.95, 0.5, 0.35, 0.25, 0.2)));
BlockFlags.setFlagsAs(172, Material.STONE); // TODO: Assumption (!).
// Stained Clay: Set as hardened clay.
BlockInit.setAs(159, 172);
// Hay Bale
BlockInit.setPropsAs(170, Material.STONE_BUTTON);
BlockFlags.setFlagsAs(170, Material.STONE); // TODO: Assumption (!).
// Carpet
BlockProperties.setBlockProps(171, new BlockProps(BlockProperties.noTool, 0.1f, BlockProperties.secToMs(0.15)));
BlockProperties.setBlockFlags(171, BlockProperties.F_GROUND|BlockProperties.F_IGN_PASSABLE|BlockProperties.F_GROUND_HEIGHT);
StaticLog.logInfo("[NoCheatPlus] Added block-info for Minecraft 1.6.1 blocks.");
}
public BlocksMC1_6_1(){
BlockInit.assertMaterialNameMatch(173, "coal", "block");
}
@Override
public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider) {
// Block of Coal: like block of redstone.
BlockInit.setAs(173, 152);
// Hardened Clay
BlockProperties.setBlockProps(172, new BlockProps(BlockProperties.woodPickaxe, 1.25f, BlockProperties.secToMs(6.25, 0.95, 0.5, 0.35, 0.25, 0.2)));
BlockFlags.setFlagsAs(172, Material.STONE); // TODO: Assumption (!).
// Stained Clay: Set as hardened clay.
BlockInit.setAs(159, 172);
// Hay Bale
BlockInit.setPropsAs(170, Material.STONE_BUTTON);
BlockFlags.setFlagsAs(170, Material.STONE); // TODO: Assumption (!).
// Carpet
BlockProperties.setBlockProps(171, new BlockProps(BlockProperties.noTool, 0.1f, BlockProperties.secToMs(0.15)));
BlockProperties.setBlockFlags(171, BlockProperties.F_GROUND|BlockProperties.F_IGN_PASSABLE|BlockProperties.F_GROUND_HEIGHT);
StaticLog.logInfo("[NoCheatPlus] Added block-info for Minecraft 1.6.1 blocks.");
}
}

View File

@ -9,32 +9,32 @@ import fr.neatmonster.nocheatplus.logging.StaticLog;
public class BlocksMC1_7_2 implements BlockPropertiesSetup{
public BlocksMC1_7_2() {
BlockInit.assertMaterialNameMatch(95, "stained", "glass");
BlockInit.assertMaterialNameMatch(174, "packed", "ice");
}
@Override
public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider) {
// Stained glass
BlockInit.setAs(95, Material.GLASS);
// Stained glass pane
BlockInit.setAs(160, 102);
// Leaves 2
BlockInit.setAs(161, Material.LEAVES);
// Log 2
BlockInit.setAs(162, Material.LOG);
// Acacia wood stairs
BlockInit.setAs(163, Material.WOOD_STAIRS);
// Oak wood stairs
BlockInit.setAs(164, Material.WOOD_STAIRS);
// Packed ice
BlockInit.setAs(174, Material.ICE);
// Large flowers
BlockInit.setAs(175, Material.YELLOW_FLOWER);
StaticLog.logInfo("[NoCheatPlus] Added block-info for Minecraft 1.7.2 blocks.");
}
public BlocksMC1_7_2() {
BlockInit.assertMaterialNameMatch(95, "stained", "glass");
BlockInit.assertMaterialNameMatch(174, "packed", "ice");
}
@Override
public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider) {
// Stained glass
BlockInit.setAs(95, Material.GLASS);
// Stained glass pane
BlockInit.setAs(160, 102);
// Leaves 2
BlockInit.setAs(161, Material.LEAVES);
// Log 2
BlockInit.setAs(162, Material.LOG);
// Acacia wood stairs
BlockInit.setAs(163, Material.WOOD_STAIRS);
// Oak wood stairs
BlockInit.setAs(164, Material.WOOD_STAIRS);
// Packed ice
BlockInit.setAs(174, Material.ICE);
// Large flowers
BlockInit.setAs(175, Material.YELLOW_FLOWER);
StaticLog.logInfo("[NoCheatPlus] Added block-info for Minecraft 1.7.2 blocks.");
}
}

View File

@ -13,115 +13,115 @@ import fr.neatmonster.nocheatplus.utilities.BlockProperties.BlockProps;
@SuppressWarnings("deprecation")
public class BlocksMC1_8 implements BlockPropertiesSetup {
public BlocksMC1_8() {
BlockInit.assertMaterialNameMatch(166, "barrier");
BlockInit.assertMaterialNameMatch(165, "slime");
BlockInit.assertMaterialNameMatch(187, "fence", "gate");
BlockInit.assertMaterialNameMatch(176, "banner");
BlockInit.assertMaterialNameMatch(169, "sea", "lantern");
}
public BlocksMC1_8() {
BlockInit.assertMaterialNameMatch(166, "barrier");
BlockInit.assertMaterialNameMatch(165, "slime");
BlockInit.assertMaterialNameMatch(187, "fence", "gate");
BlockInit.assertMaterialNameMatch(176, "banner");
BlockInit.assertMaterialNameMatch(169, "sea", "lantern");
}
@Override
public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider) {
@Override
public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider) {
// Melon/pumpkin block breaking times.
BlockProps props = new BlockProps(BlockProperties.woodAxe, 1f, BlockProperties.secToMs(1.45, 0.70, 0.325, 0.2, 0.13, 0.075), 3f);
for (Material mat : new Material[] {
Material.MELON_BLOCK,
Material.PUMPKIN,
Material.JACK_O_LANTERN,
// Same core breaking times, but behave different on efficiency + other tool (?):
Material.WALL_SIGN,
Material.SIGN_POST,
}) {
BlockProperties.setBlockProps(BlockProperties.getId(mat), props);
}
// Melon/pumpkin block breaking times.
BlockProps props = new BlockProps(BlockProperties.woodAxe, 1f, BlockProperties.secToMs(1.45, 0.70, 0.325, 0.2, 0.13, 0.075), 3f);
for (Material mat : new Material[] {
Material.MELON_BLOCK,
Material.PUMPKIN,
Material.JACK_O_LANTERN,
// Same core breaking times, but behave different on efficiency + other tool (?):
Material.WALL_SIGN,
Material.SIGN_POST,
}) {
BlockProperties.setBlockProps(BlockProperties.getId(mat), props);
}
// 165(SLIME_BLOCK
BlockInit.setAs(165, Material.TNT); // Full block, instant break.
// Add the bouncing flag.
BlockProperties.setBlockFlags(165, BlockProperties.getBlockFlags(165) | BlockProperties.F_BOUNCE25);
// 165(SLIME_BLOCK
BlockInit.setAs(165, Material.TNT); // Full block, instant break.
// Add the bouncing flag.
BlockProperties.setBlockFlags(165, BlockProperties.getBlockFlags(165) | BlockProperties.F_BOUNCE25);
// 166(BARRIER
BlockInit.setAs(166, Material.BEDROCK); // Full block, unbreakable.
// 166(BARRIER
BlockInit.setAs(166, Material.BEDROCK); // Full block, unbreakable.
// 167(IRON_TRAP_DOOR
BlockFlags.setFlagsAs(167, Material.TRAP_DOOR);
BlockInit.setPropsAs(167, Material.IRON_DOOR_BLOCK);
// 167(IRON_TRAP_DOOR
BlockFlags.setFlagsAs(167, Material.TRAP_DOOR);
BlockInit.setPropsAs(167, Material.IRON_DOOR_BLOCK);
// 168(PRISMARINE
BlockInit.setAs(168, Material.STONE);
// 168(PRISMARINE
BlockInit.setAs(168, Material.STONE);
// 169(SEA_LANTERN
BlockInit.setAs(169, Material.REDSTONE_LAMP_OFF);
// 169(SEA_LANTERN
BlockInit.setAs(169, Material.REDSTONE_LAMP_OFF);
// 176(STANDING_BANNER
BlockInit.setInstantAir(176);
// 176(STANDING_BANNER
BlockInit.setInstantAir(176);
// 177(WALL_BANNER
BlockInit.setInstantAir(177);
// 177(WALL_BANNER
BlockInit.setInstantAir(177);
// 178(DAYLIGHT_DETECTOR_INVERTED
BlockInit.setAs(178, Material.DAYLIGHT_DETECTOR);
// 178(DAYLIGHT_DETECTOR_INVERTED
BlockInit.setAs(178, Material.DAYLIGHT_DETECTOR);
// 179(RED_SANDSTONE
BlockInit.setAs(179, Material.SANDSTONE);
// 179(RED_SANDSTONE
BlockInit.setAs(179, Material.SANDSTONE);
// 180(RED_SANDSTONE_STAIRS
BlockInit.setAs(180, Material.SANDSTONE_STAIRS);
// 180(RED_SANDSTONE_STAIRS
BlockInit.setAs(180, Material.SANDSTONE_STAIRS);
// 181(DOUBLE_STEP_2
BlockInit.setAs(181, Material.DOUBLE_STEP); // TODO: red sandstone / prismarine ?
// 181(DOUBLE_STEP_2
BlockInit.setAs(181, Material.DOUBLE_STEP); // TODO: red sandstone / prismarine ?
// 182(STEP_2
BlockInit.setAs(182, Material.STEP); // TODO: red sandstone / prismarine ?
// 182(STEP_2
BlockInit.setAs(182, Material.STEP); // TODO: red sandstone / prismarine ?
// 183(SPRUCE_FENCE_GATE
BlockInit.setAs(183, Material.FENCE_GATE);
// 183(SPRUCE_FENCE_GATE
BlockInit.setAs(183, Material.FENCE_GATE);
// 184(BIRCH_FENCE_GATE
BlockInit.setAs(184, Material.FENCE_GATE);
// 184(BIRCH_FENCE_GATE
BlockInit.setAs(184, Material.FENCE_GATE);
// 185(JUNGLE_FENCE_GATE
BlockInit.setAs(185, Material.FENCE_GATE);
// 185(JUNGLE_FENCE_GATE
BlockInit.setAs(185, Material.FENCE_GATE);
// 186(DARK_OAK_FENCE_GATE
BlockInit.setAs(186, Material.FENCE_GATE);
// 186(DARK_OAK_FENCE_GATE
BlockInit.setAs(186, Material.FENCE_GATE);
// 187(ACACIA_FENCE_GATE
BlockInit.setAs(187, Material.FENCE_GATE);
// 187(ACACIA_FENCE_GATE
BlockInit.setAs(187, Material.FENCE_GATE);
// 188(SPRUCE_FENCE
BlockInit.setAs(188, Material.FENCE);
// 188(SPRUCE_FENCE
BlockInit.setAs(188, Material.FENCE);
// 189(BIRCH_FENCE
BlockInit.setAs(189, Material.FENCE);
// 189(BIRCH_FENCE
BlockInit.setAs(189, Material.FENCE);
// 190(JUNGLE_FENCE
BlockInit.setAs(190, Material.FENCE);
// 190(JUNGLE_FENCE
BlockInit.setAs(190, Material.FENCE);
// 191(DARK_OAK_FENCE
BlockInit.setAs(191, Material.FENCE);
// 191(DARK_OAK_FENCE
BlockInit.setAs(191, Material.FENCE);
// 192(ACACIA_FENCE
BlockInit.setAs(192, Material.FENCE);
// 192(ACACIA_FENCE
BlockInit.setAs(192, Material.FENCE);
// 193(SPRUCE_DOOR
BlockInit.setAs(193, Material.WOODEN_DOOR);
// 193(SPRUCE_DOOR
BlockInit.setAs(193, Material.WOODEN_DOOR);
// 194(BIRCH_DOOR
BlockInit.setAs(194, Material.WOODEN_DOOR);
// 194(BIRCH_DOOR
BlockInit.setAs(194, Material.WOODEN_DOOR);
// 195(JUNGLE_DOOR
BlockInit.setAs(195, Material.WOODEN_DOOR);
// 195(JUNGLE_DOOR
BlockInit.setAs(195, Material.WOODEN_DOOR);
// 196(ACACIA_DOOR
BlockInit.setAs(196, Material.WOODEN_DOOR);
// 196(ACACIA_DOOR
BlockInit.setAs(196, Material.WOODEN_DOOR);
// 197(DARK_OAK_DOOR
BlockInit.setAs(197, Material.WOODEN_DOOR);
// 197(DARK_OAK_DOOR
BlockInit.setAs(197, Material.WOODEN_DOOR);
StaticLog.logInfo("[NoCheatPlus] Added block-info for Minecraft 1.8 blocks.");
}
StaticLog.logInfo("[NoCheatPlus] Added block-info for Minecraft 1.8 blocks.");
}
}

View File

@ -9,29 +9,29 @@ import fr.neatmonster.nocheatplus.logging.StaticLog;
public class VanillaBlocksFactory implements BlockPropertiesSetup{
@Override
public void setupBlockProperties(final WorldConfigProvider<?> worldConfigProvider) {
// Standard setups (abort with first failure, low to high MC version).
final List<BlockPropertiesSetup> setups = new LinkedList<BlockPropertiesSetup>();
try{
setups.add(new BlocksMC1_5());
setups.add(new BlocksMC1_6_1());
setups.add(new BlocksMC1_7_2());
setups.add(new BlocksMC1_8());
}
catch(Throwable t){}
for (final BlockPropertiesSetup setup : setups){
try{
// Assume the blocks setup to message success.
setup.setupBlockProperties(worldConfigProvider);
}
catch(Throwable t){
StaticLog.logSevere("[NoCheatPlus] " + setup.getClass().getSimpleName() + ".setupBlockProperties could not execute properly: " + t.getClass().getSimpleName() + " - " + t.getMessage());
StaticLog.logSevere(t);
// Abort further processing.
break;
}
}
}
@Override
public void setupBlockProperties(final WorldConfigProvider<?> worldConfigProvider) {
// Standard setups (abort with first failure, low to high MC version).
final List<BlockPropertiesSetup> setups = new LinkedList<BlockPropertiesSetup>();
try{
setups.add(new BlocksMC1_5());
setups.add(new BlocksMC1_6_1());
setups.add(new BlocksMC1_7_2());
setups.add(new BlocksMC1_8());
}
catch(Throwable t){}
for (final BlockPropertiesSetup setup : setups){
try{
// Assume the blocks setup to message success.
setup.setupBlockProperties(worldConfigProvider);
}
catch(Throwable t){
StaticLog.logSevere("[NoCheatPlus] " + setup.getClass().getSimpleName() + ".setupBlockProperties could not execute properly: " + t.getClass().getSimpleName() + " - " + t.getMessage());
StaticLog.logSevere(t);
// Abort further processing.
break;
}
}
}
}

View File

@ -19,77 +19,77 @@ import fr.neatmonster.nocheatplus.logging.LogManager;
*
*/
public interface NoCheatPlusAPI extends ComponentRegistry<Object>, ComponentRegistryProvider, GenericInstanceRegistry, MCAccessHolder {
/**
* By default addComponent(Object) will register ComponentFactories as well.
* @param obj
* @param allowComponentRegistry If to allow registering ComponentFactories.
* @return
*/
public boolean addComponent(Object obj, boolean allowComponentRegistry);
/**
* Send all players with the nocheatplus.admin.notify permission a message.<br>
* This will act according to configuration (stored permissions and/or permission subscriptions).
*
* @param message
* @return Number of players messaged.
*/
public int sendAdminNotifyMessage(final String message);
/**
* Thread-safe method to send a message to a player in a scheduled task. The scheduling preserves order of messages.
* @param playerName
* @param message
*/
public void sendMessageOnTick(final String playerName, final String message);
/**
/**
* By default addComponent(Object) will register ComponentFactories as well.
* @param obj
* @param allowComponentRegistry If to allow registering ComponentFactories.
* @return
*/
public boolean addComponent(Object obj, boolean allowComponentRegistry);
/**
* Send all players with the nocheatplus.admin.notify permission a message.<br>
* This will act according to configuration (stored permissions and/or permission subscriptions).
*
* @param message
* @return Number of players messaged.
*/
public int sendAdminNotifyMessage(final String message);
/**
* Thread-safe method to send a message to a player in a scheduled task. The scheduling preserves order of messages.
* @param playerName
* @param message
*/
public void sendMessageOnTick(final String playerName, final String message);
/**
* Allow login (remove from deny login map).
* @param playerName
* @return If player was denied to login.
*/
public boolean allowLogin(String playerName);
/**
* Remove all players from the allow login set.
* @return Number of players that had actually been denied to login.
*/
public int allowLoginAll();
/**
* Deny the player to login. This will also remove expired entries.
* @param playerName
* @param duration Duration from now on, in milliseconds.
*/
public void denyLogin(String playerName, long duration);
/**
* Check if player is denied to login right now.
* @param playerName
* @return
*/
public boolean isLoginDenied(String playerName);
/**
* Get the names of all players who are denied to log in at present.
* @return
*/
public String[] getLoginDeniedPlayers();
/**
* Check if a player is denied to login at a certain point of time.
* @param playerName
* @param currentTimeMillis
* @return
*/
public boolean isLoginDenied(String playerName, long time);
/**
* Get the central access point for logging (LogManager),
* @return
*/
public LogManager getLogManager();
/**
* Deny the player to login. This will also remove expired entries.
* @param playerName
* @param duration Duration from now on, in milliseconds.
*/
public void denyLogin(String playerName, long duration);
/**
* Check if player is denied to login right now.
* @param playerName
* @return
*/
public boolean isLoginDenied(String playerName);
/**
* Get the names of all players who are denied to log in at present.
* @return
*/
public String[] getLoginDeniedPlayers();
/**
* Check if a player is denied to login at a certain point of time.
* @param playerName
* @param currentTimeMillis
* @return
*/
public boolean isLoginDenied(String playerName, long time);
/**
* Get the central access point for logging (LogManager),
* @return
*/
public LogManager getLogManager();
}