Add FaceAttachable interface to handle Grindstone facing in common with Switches

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot 2020-04-01 09:14:20 +11:00
parent 6546b51b70
commit 1628402608
4 changed files with 64 additions and 9 deletions

View file

@ -44,6 +44,7 @@ import org.bukkit.block.data.type.Fire;
import org.bukkit.block.data.type.Furnace;
import org.bukkit.block.data.type.Gate;
import org.bukkit.block.data.type.GlassPane;
import org.bukkit.block.data.type.Grindstone;
import org.bukkit.block.data.type.Hopper;
import org.bukkit.block.data.type.Jukebox;
import org.bukkit.block.data.type.Ladder;
@ -1006,9 +1007,9 @@ public enum Material implements Keyed {
GREEN_WALL_BANNER(15046, Directional.class),
GREEN_WOOL(25085),
/**
* BlockData: {@link Directional}
* BlockData: {@link Grindstone}
*/
GRINDSTONE(26260, Directional.class),
GRINDSTONE(26260, Grindstone.class),
GUARDIAN_SPAWN_EGG(20113),
GUNPOWDER(29974),
/**

View file

@ -0,0 +1,45 @@
package org.bukkit.block.data;
import org.jetbrains.annotations.NotNull;
/**
* 'face' represents the face to which a lever or button is stuck.
* <br>
* This is used in conjunction with {@link Directional} to compute the
* orientation of these blocks.
*/
public interface FaceAttachable extends BlockData {
/**
* Gets the value of the 'face' property.
*
* @return the 'face' value
*/
@NotNull
AttachedFace getAttachedFace();
/**
* Sets the value of the 'face' property.
*
* @param face the new 'face' value
*/
void setAttachedFace(@NotNull AttachedFace face);
/**
* The face to which a switch type block is stuck.
*/
public enum AttachedFace {
/**
* The switch is mounted to the floor and pointing upwards.
*/
FLOOR,
/**
* The switch is mounted to the wall.
*/
WALL,
/**
* The switch is mounted to the ceiling and pointing dowanrds.
*/
CEILING;
}
}

View file

@ -0,0 +1,7 @@
package org.bukkit.block.data.type;
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.FaceAttachable;
public interface Grindstone extends Directional, FaceAttachable {
}

View file

@ -1,35 +1,37 @@
package org.bukkit.block.data.type;
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.FaceAttachable;
import org.bukkit.block.data.Powerable;
import org.jetbrains.annotations.NotNull;
/**
* 'face' represents the face to which a lever or button is stuck.
* <br>
* This is used in conjunction with {@link Directional} to compute the
* orientation of these blocks.
*/
public interface Switch extends Directional, Powerable {
public interface Switch extends Directional, FaceAttachable, Powerable {
/**
* Gets the value of the 'face' property.
*
* @return the 'face' value
* @deprecated use {@link #getAttachedFace()}
*/
@NotNull
@Deprecated
Face getFace();
/**
* Sets the value of the 'face' property.
*
* @param face the new 'face' value
* @deprecated use {@link #getAttachedFace()}
*/
@Deprecated
void setFace(@NotNull Face face);
/**
* The face to which a switch type block is stuck.
*
* @deprecated use {@link AttachedFace}
*/
@Deprecated
public enum Face {
/**
* The switch is mounted to the floor and pointing upwards.