mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-03 19:00:30 +02:00
Move utility methods for altering flags to the BlockFlags utility class.
This commit is contained in:
parent
1eb7dbacf1
commit
15bf8e3ece
|
@ -4,6 +4,7 @@ import org.bukkit.Material;
|
|||
|
||||
import fr.neatmonster.nocheatplus.compat.BlockPropertiesSetup;
|
||||
import fr.neatmonster.nocheatplus.config.WorldConfigProvider;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockFlags;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
|
||||
|
||||
/**
|
||||
|
@ -33,63 +34,46 @@ public class BlocksMC1_5 implements BlockPropertiesSetup {
|
|||
////////////////////
|
||||
|
||||
// 146 Trapped Chest
|
||||
setFlagsAs(146, Material.CHEST);
|
||||
BlockFlags.setFlagsAs(146, Material.CHEST);
|
||||
BlockProperties.setBlockProps(146, BlockProperties.getBlockProps(Material.CHEST.getId()));
|
||||
|
||||
// 147 Weighted Pressure Plate (Light)
|
||||
// 148 Weighted Pressure Plate (Heavy)
|
||||
addFlags(147, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
|
||||
addFlags(148, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
|
||||
BlockFlags.addFlags(147, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
|
||||
BlockFlags.addFlags(148, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
|
||||
|
||||
// 149 Redstone Comparator (inactive)
|
||||
// 150 Redstone Comparator (active)
|
||||
addFlags(149, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
|
||||
addFlags(150, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
|
||||
BlockFlags.addFlags(149, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
|
||||
BlockFlags.addFlags(150, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
|
||||
|
||||
// 151 Daylight Sensor
|
||||
addFlags(151, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
|
||||
BlockFlags.addFlags(151, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT);
|
||||
|
||||
// 152 Block of Redstone
|
||||
// 153 Nether Quartz Ore
|
||||
// 155 Block of Quartz
|
||||
|
||||
// 154 Hopper
|
||||
addFlags(144, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND_HEIGHT);
|
||||
BlockFlags.addFlags(144, BlockProperties.F_IGN_PASSABLE | BlockProperties.F_GROUND_HEIGHT);
|
||||
|
||||
// 158 Dropper
|
||||
setFlagsAs(158, Material.DISPENSER);
|
||||
BlockFlags.setFlagsAs(158, Material.DISPENSER);
|
||||
|
||||
// 156 Quartz Stairs
|
||||
setFlagsAs(156, Material.COBBLESTONE_STAIRS);
|
||||
BlockFlags.setFlagsAs(156, Material.COBBLESTONE_STAIRS);
|
||||
|
||||
// 157 Activator Rail
|
||||
setFlagsAs(157, Material.DETECTOR_RAIL);
|
||||
BlockFlags.setFlagsAs(157, Material.DETECTOR_RAIL);
|
||||
|
||||
/////////////////////
|
||||
// Changed blocks
|
||||
////////////////////
|
||||
|
||||
// 78 Snow
|
||||
addFlags(78, BlockProperties.F_HEIGHT_8_INC);
|
||||
removeFlags(78, BlockProperties.F_HEIGHT_8SIM_INC);
|
||||
BlockFlags.addFlags(78, BlockProperties.F_HEIGHT_8_INC);
|
||||
BlockFlags.removeFlags(78, BlockProperties.F_HEIGHT_8SIM_INC);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set flags of id same as with material.
|
||||
* @param id
|
||||
* @param mat
|
||||
*/
|
||||
public static void setFlagsAs(int id, Material mat){
|
||||
BlockProperties.setBlockFlags(id, BlockProperties.getBlockFlags(mat.getId()));
|
||||
}
|
||||
|
||||
public static void addFlags(int id, long flags){
|
||||
BlockProperties.setBlockFlags(id, BlockProperties.getBlockFlags(id) | flags);
|
||||
}
|
||||
|
||||
public static void removeFlags(int id, long flags){
|
||||
BlockProperties.setBlockFlags(id, BlockProperties.getBlockFlags(id) & ~flags);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package fr.neatmonster.nocheatplus.utilities;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
/**
|
||||
* Utilities for block-flags.<br>
|
||||
* Later the flag constant definitions and parsing might be moved here.
|
||||
* @author mc_dev
|
||||
*
|
||||
*/
|
||||
public class BlockFlags {
|
||||
|
||||
/**
|
||||
* Set flags of id same as already set with flags for the given material. (Uses BlockProperties.)
|
||||
* @param id
|
||||
* @param mat
|
||||
*/
|
||||
public static void setFlagsAs(int id, Material mat){
|
||||
BlockProperties.setBlockFlags(id, BlockProperties.getBlockFlags(mat.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add flags to existent flags. (Uses BlockProperties.)
|
||||
* @param id
|
||||
* @param flags
|
||||
*/
|
||||
public static void addFlags(int id, long flags){
|
||||
BlockProperties.setBlockFlags(id, BlockProperties.getBlockFlags(id) | flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given flags from existent flags. (Uses BlockProperties.)
|
||||
* @param id
|
||||
* @param flags
|
||||
*/
|
||||
public static void removeFlags(int id, long flags){
|
||||
BlockProperties.setBlockFlags(id, BlockProperties.getBlockFlags(id) & ~flags);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user