mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 19:49:35 +01:00
Remove Jukebox MaterialData in favour of Jukebox BlockState
By: Celtic Minstrel <celtic.minstrel.ca@some.place>
This commit is contained in:
parent
c2d3c5ce3e
commit
cae1a829df
3 changed files with 33 additions and 85 deletions
|
@ -96,7 +96,7 @@ public enum Material {
|
|||
CACTUS(81, MaterialData.class),
|
||||
CLAY(82),
|
||||
SUGAR_CANE_BLOCK(83, MaterialData.class),
|
||||
JUKEBOX(84, Jukebox.class),
|
||||
JUKEBOX(84),
|
||||
FENCE(85),
|
||||
PUMPKIN(86, Pumpkin.class),
|
||||
NETHERRACK(87),
|
||||
|
|
32
paper-api/src/main/java/org/bukkit/block/Jukebox.java
Normal file
32
paper-api/src/main/java/org/bukkit/block/Jukebox.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
package org.bukkit.block;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
/**
|
||||
* Represents a Jukebox
|
||||
*/
|
||||
public interface Jukebox extends BlockState {
|
||||
/**
|
||||
* Get the record currently playing
|
||||
* @return The record Material, or AIR if none is playing
|
||||
*/
|
||||
public Material getPlaying();
|
||||
|
||||
/**
|
||||
* Set the record currently playing
|
||||
* @param record The record Material, or null/AIR to stop playing
|
||||
*/
|
||||
public void setPlaying(Material record);
|
||||
|
||||
/**
|
||||
* Check if the jukebox is currently playing a record
|
||||
* @return True if there is a record playing
|
||||
*/
|
||||
public boolean isPlaying();
|
||||
|
||||
/**
|
||||
* Stop the jukebox playing and eject the current record
|
||||
* @return True if a record was ejected; false if there was none playing
|
||||
*/
|
||||
public boolean eject();
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
package org.bukkit.material;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class Jukebox extends MaterialData {
|
||||
private static HashSet<Material> recordTypes = new HashSet<Material>();
|
||||
static {
|
||||
recordTypes.add(Material.GOLD_RECORD);
|
||||
recordTypes.add(Material.GREEN_RECORD);
|
||||
}
|
||||
|
||||
public Jukebox() {
|
||||
super(Material.JUKEBOX);
|
||||
}
|
||||
|
||||
public Jukebox(int type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public Jukebox(Material type) {
|
||||
super((recordTypes.contains(type)) ? Material.JUKEBOX : type);
|
||||
if (recordTypes.contains(type)) {
|
||||
setPlaying(type);
|
||||
}
|
||||
}
|
||||
|
||||
public Jukebox(int type, byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
public Jukebox(Material type, byte data) {
|
||||
super(type, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type of record currently playing
|
||||
*
|
||||
* @return The type of record (Material.GOLD_RECORD or Material.GREEN_RECORD), or null for none.
|
||||
*/
|
||||
public Material getPlaying() {
|
||||
switch ((int) getData()) {
|
||||
default:
|
||||
case 0x0:
|
||||
return null;
|
||||
|
||||
case 0x1:
|
||||
return Material.GOLD_RECORD;
|
||||
|
||||
case 0x2:
|
||||
return Material.GREEN_RECORD;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of record currently playing
|
||||
*
|
||||
* @param rec The type of record (Material.GOLD_RECORD or Material.GREEN_RECORD), or null for none.
|
||||
*/
|
||||
public void setPlaying(Material rec) {
|
||||
if (rec == null) {
|
||||
setData((byte) 0x0);
|
||||
} else {
|
||||
switch (rec) {
|
||||
case GOLD_RECORD:
|
||||
setData((byte) 0x1);
|
||||
break;
|
||||
|
||||
case GREEN_RECORD:
|
||||
setData((byte) 0x2);
|
||||
break;
|
||||
|
||||
default:
|
||||
setData((byte) 0x0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + " playing " + getPlaying();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue