NoCheatPlus/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/map/BlockFlags.java

101 lines
3.1 KiB
Java

/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.utilities.map;
import org.bukkit.Material;
// TODO: Auto-generated Javadoc
/**
* 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
* the id
* @param mat
* the mat
*/
public static void setFlagsAs(String id, Material mat) {
BlockProperties.setBlockFlags(id, BlockProperties.getBlockFlags(mat));
}
/**
* Set flags of id same as already set with flags for the given material.
* (Uses BlockProperties.)
*
* @param id
* the id
* @param otherId
* the other id
*/
public static void setFlagsAs(String id, String otherId) {
BlockProperties.setBlockFlags(id, BlockProperties.getBlockFlags(otherId));
}
/**
* Set the same flags for newMat as are present for mat.
*
* @param newMat
* @param mat
*/
public static void setFlagsAs(Material newMat, Material mat) {
BlockProperties.setBlockFlags(newMat, BlockProperties.getBlockFlags(mat));
}
/**
* Add flags to existent flags. (Uses BlockProperties.)
*
* @param id
* Id of the block.
* @param flags
* Block flags.
*/
public static void addFlags(String id, long flags) {
BlockProperties.setBlockFlags(id, BlockProperties.getBlockFlags(id) | flags);
}
/**
* Add flags to existent flags. (Uses BlockProperties.)
*
* @param blockType
* Bukkit Material type. Id of the block.
* @param flags
* Block flags.
*/
public static void addFlags(Material blockType, long flags) {
BlockProperties.setBlockFlags(blockType, BlockProperties.getBlockFlags(blockType) | flags);
}
/**
* Remove the given flags from existent flags. (Uses BlockProperties.)
*
* @param id
* the id
* @param flags
* the flags
*/
public static void removeFlags(String id, long flags) {
BlockProperties.setBlockFlags(id, BlockProperties.getBlockFlags(id) & ~flags);
}
}