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{ 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) { private final List<PacketAdapter> registeredPacketAdapters = new LinkedList<PacketAdapter>();
// 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 ProtocolLibComponent(Plugin plugin) {
public void onDisable() { StaticLog.logInfo("Adding packet level hooks for ProtocolLib (MC " + ProtocolLibrary.getProtocolManager().getMinecraftVersion().getVersion() + ")...");
unregister(); register(plugin);
} }
@Override private void register(Plugin plugin) {
public void onReload() { // Register Classes having a constructor with Plugin as argument.
unregister(); if (ConfigManager.isTrueForAnyConfig(ConfPaths.NET_FLYINGFREQUENCY_ACTIVE)) {
register(Bukkit.getPluginManager().getPlugin("NoCheatPlus")); // Store instead ? register(FlyingFrequency.class, plugin);
} }
if (ConfigManager.isTrueForAnyConfig(ConfPaths.NET_SOUNDDISTANCE_ACTIVE)) {
private void unregister() { register(SoundDistance.class, plugin);
final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); }
final NoCheatPlusAPI api = NCPAPIProvider.getNoCheatPlusAPI(); if (!registeredPacketAdapters.isEmpty()) {
for (PacketAdapter adapter : registeredPacketAdapters) { List<String> names = new ArrayList<String>(registeredPacketAdapters.size());
try { for (PacketAdapter adapter : registeredPacketAdapters) {
protocolManager.removePacketListener(adapter); names.add(adapter.getClass().getSimpleName());
api.removeComponent(adapter); // Bit heavy, but consistent. }
} catch (Throwable t) { StaticLog.logInfo("[NoCheatPlus] Available (and activated) packet level hooks: " + StringUtil.join(names, " | "));
StaticLog.logWarning("[NoCheatPlus] Failed to unregister packet level hook: " + adapter.getClass().getName()); }
} }
}
registeredPacketAdapters.clear(); 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 class VersionCommand extends BaseCommand{
public VersionCommand(JavaPlugin plugin) { public VersionCommand(JavaPlugin plugin) {
super(plugin, "version", Permissions.COMMAND_VERSION, new String[]{"versions", "ver"}); super(plugin, "version", Permissions.COMMAND_VERSION, new String[]{"versions", "ver"});
} }
@Override @Override
public boolean onCommand(CommandSender sender, Command command, public boolean onCommand(CommandSender sender, Command command,
String label, String[] args) { String label, String[] args) {
final MCAccess mc = NCPAPIProvider.getNoCheatPlusAPI().getMCAccess(); final MCAccess mc = NCPAPIProvider.getNoCheatPlusAPI().getMCAccess();
sender.sendMessage(new String[]{ sender.sendMessage(new String[]{
"---- Version information ----", "---- Version information ----",
"#### Server ####", "#### Server ####",
Bukkit.getServer().getVersion(), Bukkit.getServer().getVersion(),
"#### NoCheatPlus ####", "#### NoCheatPlus ####",
"Plugin: " + access.getDescription().getVersion(), "Plugin: " + access.getDescription().getVersion(),
"MCAccess: " + mc.getMCVersion() + " / " + mc.getServerVersionTag(), "MCAccess: " + mc.getMCVersion() + " / " + mc.getServerVersionTag(),
}); });
final Collection<NCPHook> hooks = NCPHookManager.getAllHooks();
if (!hooks.isEmpty()){ final Collection<NCPHook> hooks = NCPHookManager.getAllHooks();
final List<String> fullNames = new LinkedList<String>(); if (!hooks.isEmpty()){
for (final NCPHook hook : hooks){ final List<String> fullNames = new LinkedList<String>();
fullNames.add(hook.getHookName() + " " + hook.getHookVersion()); for (final NCPHook hook : hooks){
} fullNames.add(hook.getHookName() + " " + hook.getHookVersion());
Collections.sort(fullNames, String.CASE_INSENSITIVE_ORDER); }
sender.sendMessage("Hooks: " + StringUtil.join(fullNames, " | ")); Collections.sort(fullNames, String.CASE_INSENSITIVE_ORDER);
} sender.sendMessage("Hooks: " + StringUtil.join(fullNames, " | "));
return true; }
} return true;
}
} }

View File

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

View File

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

View File

@ -15,79 +15,79 @@ import fr.neatmonster.nocheatplus.utilities.BlockProperties;
* *
*/ */
public class BlocksMC1_5 implements BlockPropertiesSetup { public class BlocksMC1_5 implements BlockPropertiesSetup {
public BlocksMC1_5(){
// Test if materials exist.
BlockInit.assertMaterialNameMatch(152, "redstone", "block");
}
@Override public BlocksMC1_5(){
public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider) { // Test if materials exist.
BlockInit.assertMaterialNameMatch(152, "redstone", "block");
///////////////////// }
// 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) @Override
// BlockFlags.addFlags(148, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT); public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider) {
BlockInit.setAs(148, Material.STONE_PLATE);
/////////////////////
// 149 Redstone Comparator (inactive) // New blocks
// BlockFlags.addFlags(149, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT); ////////////////////
BlockInit.setAs(149, Material.DIODE_BLOCK_OFF);
// 146 Trapped Chest
// 150 Redstone Comparator (active) BlockInit.setAs(146, Material.CHEST);
// BlockFlags.addFlags(150, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
BlockInit.setAs(150, Material.DIODE_BLOCK_ON); // 147 Weighted Pressure Plate (Light)
// BlockFlags.addFlags(147, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
// 151 Daylight Sensor BlockInit.setAs(147, Material.STONE_PLATE);
// BlockFlags.addFlags(151, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
BlockInit.setAs(151, Material.HUGE_MUSHROOM_1); // 148 Weighted Pressure Plate (Heavy)
// BlockFlags.addFlags(148, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
// 152 Block of Redstone BlockInit.setAs(148, Material.STONE_PLATE);
BlockInit.setAs(152, Material.ENCHANTMENT_TABLE);
// 149 Redstone Comparator (inactive)
// 153 Nether Quartz Ore // BlockFlags.addFlags(149, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
BlockInit.setAs(153, Material.COAL_ORE); BlockInit.setAs(149, Material.DIODE_BLOCK_OFF);
// 154 Hopper // 150 Redstone Comparator (active)
BlockInit.setAs(154, Material.COAL_ORE); // BlockFlags.addFlags(150, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
// TODO: Needs workaround. [workaround-flag + different purpose flag sets ?] BlockInit.setAs(150, Material.DIODE_BLOCK_ON);
BlockFlags.addFlags(154, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND_HEIGHT);
// 151 Daylight Sensor
// 155 Block of Quartz // BlockFlags.addFlags(151, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
BlockInit.setAs(155, Material.SANDSTONE); BlockInit.setAs(151, Material.HUGE_MUSHROOM_1);
// 156 Quartz Stairs // 152 Block of Redstone
BlockInit.setAs(156, Material.SANDSTONE_STAIRS); BlockInit.setAs(152, Material.ENCHANTMENT_TABLE);
// 157 Activator Rail // 153 Nether Quartz Ore
BlockInit.setAs(157, Material.DETECTOR_RAIL); BlockInit.setAs(153, Material.COAL_ORE);
// 158 Dropper // 154 Hopper
// BlockFlags.setFlagsAs(158, Material.DISPENSER); BlockInit.setAs(154, Material.COAL_ORE);
BlockInit.setAs(158, Material.DISPENSER); // TODO: Needs workaround. [workaround-flag + different purpose flag sets ?]
BlockFlags.addFlags(154, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND_HEIGHT);
///////////////////// // 155 Block of Quartz
// Changed blocks BlockInit.setAs(155, Material.SANDSTONE);
////////////////////
// 156 Quartz Stairs
// 78 Snow BlockInit.setAs(156, Material.SANDSTONE_STAIRS);
BlockFlags.addFlags(78, BlockProperties.F_HEIGHT_8_INC);
BlockFlags.removeFlags(78, BlockProperties.F_HEIGHT_8SIM_INC); // 157 Activator Rail
BlockInit.setAs(157, Material.DETECTOR_RAIL);
// 95 Locked chest
BlockProperties.setBlockProps(95, BlockProperties.instantType); // 158 Dropper
// BlockFlags.setFlagsAs(158, Material.DISPENSER);
StaticLog.logInfo("[NoCheatPlus] Added block-info for Minecraft 1.5 blocks."); 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") @SuppressWarnings("deprecation")
public class BlocksMC1_6_1 implements BlockPropertiesSetup{ public class BlocksMC1_6_1 implements BlockPropertiesSetup{
public BlocksMC1_6_1(){
BlockInit.assertMaterialNameMatch(173, "coal", "block");
}
@Override public BlocksMC1_6_1(){
public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider) { BlockInit.assertMaterialNameMatch(173, "coal", "block");
}
// Block of Coal: like block of redstone.
BlockInit.setAs(173, 152); @Override
public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider) {
// 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))); // Block of Coal: like block of redstone.
BlockFlags.setFlagsAs(172, Material.STONE); // TODO: Assumption (!). BlockInit.setAs(173, 152);
// Stained Clay: Set as hardened clay. // Hardened Clay
BlockInit.setAs(159, 172); 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 (!).
// Hay Bale
BlockInit.setPropsAs(170, Material.STONE_BUTTON); // Stained Clay: Set as hardened clay.
BlockFlags.setFlagsAs(170, Material.STONE); // TODO: Assumption (!). BlockInit.setAs(159, 172);
// Carpet // Hay Bale
BlockProperties.setBlockProps(171, new BlockProps(BlockProperties.noTool, 0.1f, BlockProperties.secToMs(0.15))); BlockInit.setPropsAs(170, Material.STONE_BUTTON);
BlockProperties.setBlockFlags(171, BlockProperties.F_GROUND|BlockProperties.F_IGN_PASSABLE|BlockProperties.F_GROUND_HEIGHT); BlockFlags.setFlagsAs(170, Material.STONE); // TODO: Assumption (!).
StaticLog.logInfo("[NoCheatPlus] Added block-info for Minecraft 1.6.1 blocks."); // 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 class BlocksMC1_7_2 implements BlockPropertiesSetup{
public BlocksMC1_7_2() {
BlockInit.assertMaterialNameMatch(95, "stained", "glass");
BlockInit.assertMaterialNameMatch(174, "packed", "ice");
}
@Override public BlocksMC1_7_2() {
public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider) { BlockInit.assertMaterialNameMatch(95, "stained", "glass");
// Stained glass BlockInit.assertMaterialNameMatch(174, "packed", "ice");
BlockInit.setAs(95, Material.GLASS); }
// Stained glass pane
BlockInit.setAs(160, 102); @Override
// Leaves 2 public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider) {
BlockInit.setAs(161, Material.LEAVES); // Stained glass
// Log 2 BlockInit.setAs(95, Material.GLASS);
BlockInit.setAs(162, Material.LOG); // Stained glass pane
// Acacia wood stairs BlockInit.setAs(160, 102);
BlockInit.setAs(163, Material.WOOD_STAIRS); // Leaves 2
// Oak wood stairs BlockInit.setAs(161, Material.LEAVES);
BlockInit.setAs(164, Material.WOOD_STAIRS); // Log 2
// Packed ice BlockInit.setAs(162, Material.LOG);
BlockInit.setAs(174, Material.ICE); // Acacia wood stairs
// Large flowers BlockInit.setAs(163, Material.WOOD_STAIRS);
BlockInit.setAs(175, Material.YELLOW_FLOWER); // Oak wood stairs
BlockInit.setAs(164, Material.WOOD_STAIRS);
StaticLog.logInfo("[NoCheatPlus] Added block-info for Minecraft 1.7.2 blocks."); // 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") @SuppressWarnings("deprecation")
public class BlocksMC1_8 implements BlockPropertiesSetup { public class BlocksMC1_8 implements BlockPropertiesSetup {
public BlocksMC1_8() { public BlocksMC1_8() {
BlockInit.assertMaterialNameMatch(166, "barrier"); BlockInit.assertMaterialNameMatch(166, "barrier");
BlockInit.assertMaterialNameMatch(165, "slime"); BlockInit.assertMaterialNameMatch(165, "slime");
BlockInit.assertMaterialNameMatch(187, "fence", "gate"); BlockInit.assertMaterialNameMatch(187, "fence", "gate");
BlockInit.assertMaterialNameMatch(176, "banner"); BlockInit.assertMaterialNameMatch(176, "banner");
BlockInit.assertMaterialNameMatch(169, "sea", "lantern"); BlockInit.assertMaterialNameMatch(169, "sea", "lantern");
} }
@Override @Override
public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider) { public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider) {
// Melon/pumpkin block breaking times. // 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); 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[] { for (Material mat : new Material[] {
Material.MELON_BLOCK, Material.MELON_BLOCK,
Material.PUMPKIN, Material.PUMPKIN,
Material.JACK_O_LANTERN, Material.JACK_O_LANTERN,
// Same core breaking times, but behave different on efficiency + other tool (?): // Same core breaking times, but behave different on efficiency + other tool (?):
Material.WALL_SIGN, Material.WALL_SIGN,
Material.SIGN_POST, Material.SIGN_POST,
}) { }) {
BlockProperties.setBlockProps(BlockProperties.getId(mat), props); BlockProperties.setBlockProps(BlockProperties.getId(mat), props);
} }
// 165(SLIME_BLOCK // 165(SLIME_BLOCK
BlockInit.setAs(165, Material.TNT); // Full block, instant break. BlockInit.setAs(165, Material.TNT); // Full block, instant break.
// Add the bouncing flag. // Add the bouncing flag.
BlockProperties.setBlockFlags(165, BlockProperties.getBlockFlags(165) | BlockProperties.F_BOUNCE25); BlockProperties.setBlockFlags(165, BlockProperties.getBlockFlags(165) | BlockProperties.F_BOUNCE25);
// 166(BARRIER // 166(BARRIER
BlockInit.setAs(166, Material.BEDROCK); // Full block, unbreakable. BlockInit.setAs(166, Material.BEDROCK); // Full block, unbreakable.
// 167(IRON_TRAP_DOOR // 167(IRON_TRAP_DOOR
BlockFlags.setFlagsAs(167, Material.TRAP_DOOR); BlockFlags.setFlagsAs(167, Material.TRAP_DOOR);
BlockInit.setPropsAs(167, Material.IRON_DOOR_BLOCK); BlockInit.setPropsAs(167, Material.IRON_DOOR_BLOCK);
// 168(PRISMARINE // 168(PRISMARINE
BlockInit.setAs(168, Material.STONE); BlockInit.setAs(168, Material.STONE);
// 169(SEA_LANTERN // 169(SEA_LANTERN
BlockInit.setAs(169, Material.REDSTONE_LAMP_OFF); BlockInit.setAs(169, Material.REDSTONE_LAMP_OFF);
// 176(STANDING_BANNER // 176(STANDING_BANNER
BlockInit.setInstantAir(176); BlockInit.setInstantAir(176);
// 177(WALL_BANNER // 177(WALL_BANNER
BlockInit.setInstantAir(177); BlockInit.setInstantAir(177);
// 178(DAYLIGHT_DETECTOR_INVERTED // 178(DAYLIGHT_DETECTOR_INVERTED
BlockInit.setAs(178, Material.DAYLIGHT_DETECTOR); BlockInit.setAs(178, Material.DAYLIGHT_DETECTOR);
// 179(RED_SANDSTONE // 179(RED_SANDSTONE
BlockInit.setAs(179, Material.SANDSTONE); BlockInit.setAs(179, Material.SANDSTONE);
// 180(RED_SANDSTONE_STAIRS // 180(RED_SANDSTONE_STAIRS
BlockInit.setAs(180, Material.SANDSTONE_STAIRS); BlockInit.setAs(180, Material.SANDSTONE_STAIRS);
// 181(DOUBLE_STEP_2 // 181(DOUBLE_STEP_2
BlockInit.setAs(181, Material.DOUBLE_STEP); // TODO: red sandstone / prismarine ? BlockInit.setAs(181, Material.DOUBLE_STEP); // TODO: red sandstone / prismarine ?
// 182(STEP_2 // 182(STEP_2
BlockInit.setAs(182, Material.STEP); // TODO: red sandstone / prismarine ? BlockInit.setAs(182, Material.STEP); // TODO: red sandstone / prismarine ?
// 183(SPRUCE_FENCE_GATE // 183(SPRUCE_FENCE_GATE
BlockInit.setAs(183, Material.FENCE_GATE); BlockInit.setAs(183, Material.FENCE_GATE);
// 184(BIRCH_FENCE_GATE // 184(BIRCH_FENCE_GATE
BlockInit.setAs(184, Material.FENCE_GATE); BlockInit.setAs(184, Material.FENCE_GATE);
// 185(JUNGLE_FENCE_GATE // 185(JUNGLE_FENCE_GATE
BlockInit.setAs(185, Material.FENCE_GATE); BlockInit.setAs(185, Material.FENCE_GATE);
// 186(DARK_OAK_FENCE_GATE // 186(DARK_OAK_FENCE_GATE
BlockInit.setAs(186, Material.FENCE_GATE); BlockInit.setAs(186, Material.FENCE_GATE);
// 187(ACACIA_FENCE_GATE // 187(ACACIA_FENCE_GATE
BlockInit.setAs(187, Material.FENCE_GATE); BlockInit.setAs(187, Material.FENCE_GATE);
// 188(SPRUCE_FENCE // 188(SPRUCE_FENCE
BlockInit.setAs(188, Material.FENCE); BlockInit.setAs(188, Material.FENCE);
// 189(BIRCH_FENCE // 189(BIRCH_FENCE
BlockInit.setAs(189, Material.FENCE); BlockInit.setAs(189, Material.FENCE);
// 190(JUNGLE_FENCE // 190(JUNGLE_FENCE
BlockInit.setAs(190, Material.FENCE); BlockInit.setAs(190, Material.FENCE);
// 191(DARK_OAK_FENCE // 191(DARK_OAK_FENCE
BlockInit.setAs(191, Material.FENCE); BlockInit.setAs(191, Material.FENCE);
// 192(ACACIA_FENCE // 192(ACACIA_FENCE
BlockInit.setAs(192, Material.FENCE); BlockInit.setAs(192, Material.FENCE);
// 193(SPRUCE_DOOR // 193(SPRUCE_DOOR
BlockInit.setAs(193, Material.WOODEN_DOOR); BlockInit.setAs(193, Material.WOODEN_DOOR);
// 194(BIRCH_DOOR // 194(BIRCH_DOOR
BlockInit.setAs(194, Material.WOODEN_DOOR); BlockInit.setAs(194, Material.WOODEN_DOOR);
// 195(JUNGLE_DOOR // 195(JUNGLE_DOOR
BlockInit.setAs(195, Material.WOODEN_DOOR); BlockInit.setAs(195, Material.WOODEN_DOOR);
// 196(ACACIA_DOOR // 196(ACACIA_DOOR
BlockInit.setAs(196, Material.WOODEN_DOOR); BlockInit.setAs(196, Material.WOODEN_DOOR);
// 197(DARK_OAK_DOOR // 197(DARK_OAK_DOOR
BlockInit.setAs(197, Material.WOODEN_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{ public class VanillaBlocksFactory implements BlockPropertiesSetup{
@Override @Override
public void setupBlockProperties(final WorldConfigProvider<?> worldConfigProvider) { public void setupBlockProperties(final WorldConfigProvider<?> worldConfigProvider) {
// Standard setups (abort with first failure, low to high MC version). // Standard setups (abort with first failure, low to high MC version).
final List<BlockPropertiesSetup> setups = new LinkedList<BlockPropertiesSetup>(); final List<BlockPropertiesSetup> setups = new LinkedList<BlockPropertiesSetup>();
try{ try{
setups.add(new BlocksMC1_5()); setups.add(new BlocksMC1_5());
setups.add(new BlocksMC1_6_1()); setups.add(new BlocksMC1_6_1());
setups.add(new BlocksMC1_7_2()); setups.add(new BlocksMC1_7_2());
setups.add(new BlocksMC1_8()); setups.add(new BlocksMC1_8());
} }
catch(Throwable t){} catch(Throwable t){}
for (final BlockPropertiesSetup setup : setups){ for (final BlockPropertiesSetup setup : setups){
try{ try{
// Assume the blocks setup to message success. // Assume the blocks setup to message success.
setup.setupBlockProperties(worldConfigProvider); setup.setupBlockProperties(worldConfigProvider);
} }
catch(Throwable t){ catch(Throwable t){
StaticLog.logSevere("[NoCheatPlus] " + setup.getClass().getSimpleName() + ".setupBlockProperties could not execute properly: " + t.getClass().getSimpleName() + " - " + t.getMessage()); StaticLog.logSevere("[NoCheatPlus] " + setup.getClass().getSimpleName() + ".setupBlockProperties could not execute properly: " + t.getClass().getSimpleName() + " - " + t.getMessage());
StaticLog.logSevere(t); StaticLog.logSevere(t);
// Abort further processing. // Abort further processing.
break; break;
} }
} }
} }
} }

View File

@ -19,77 +19,77 @@ import fr.neatmonster.nocheatplus.logging.LogManager;
* *
*/ */
public interface NoCheatPlusAPI extends ComponentRegistry<Object>, ComponentRegistryProvider, GenericInstanceRegistry, MCAccessHolder { 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). * Allow login (remove from deny login map).
* @param playerName * @param playerName
* @return If player was denied to login. * @return If player was denied to login.
*/ */
public boolean allowLogin(String playerName); public boolean allowLogin(String playerName);
/** /**
* Remove all players from the allow login set. * Remove all players from the allow login set.
* @return Number of players that had actually been denied to login. * @return Number of players that had actually been denied to login.
*/ */
public int allowLoginAll(); 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. * Deny the player to login. This will also remove expired entries.
* @param playerName * @param playerName
* @param currentTimeMillis * @param duration Duration from now on, in milliseconds.
* @return */
*/ public void denyLogin(String playerName, long duration);
public boolean isLoginDenied(String playerName, long time);
/**
/** * Check if player is denied to login right now.
* Get the central access point for logging (LogManager), * @param playerName
* @return * @return
*/ */
public LogManager getLogManager(); 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();
} }