2015-07-26 16:51:12 +02:00
|
|
|
package com.plotsquared.bukkit.object;
|
2015-07-09 16:20:19 +02:00
|
|
|
|
2015-07-26 16:51:12 +02:00
|
|
|
import com.intellectualcrafters.plot.object.LazyBlock;
|
|
|
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
2016-03-23 02:41:37 +01:00
|
|
|
import org.bukkit.block.Block;
|
2015-07-09 16:20:19 +02:00
|
|
|
|
2015-09-13 06:04:31 +02:00
|
|
|
public class BukkitLazyBlock extends LazyBlock {
|
2016-03-23 02:41:37 +01:00
|
|
|
|
2015-11-29 09:21:32 +01:00
|
|
|
private int id;
|
2015-07-09 16:20:19 +02:00
|
|
|
private Block block;
|
|
|
|
private PlotBlock pb;
|
2016-03-23 02:41:37 +01:00
|
|
|
|
|
|
|
public BukkitLazyBlock(int id, Block block) {
|
2015-07-09 16:20:19 +02:00
|
|
|
this.id = id;
|
|
|
|
this.block = block;
|
|
|
|
}
|
2016-03-23 02:41:37 +01:00
|
|
|
|
|
|
|
public BukkitLazyBlock(PlotBlock pb) {
|
|
|
|
this.id = pb.id;
|
2015-07-09 16:20:19 +02:00
|
|
|
this.pb = pb;
|
|
|
|
}
|
2016-03-23 02:41:37 +01:00
|
|
|
|
|
|
|
public BukkitLazyBlock(Block block) {
|
2015-07-09 16:20:19 +02:00
|
|
|
this.block = block;
|
|
|
|
}
|
2016-03-23 02:41:37 +01:00
|
|
|
|
2015-07-09 16:20:19 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public PlotBlock getPlotBlock() {
|
2016-03-23 02:41:37 +01:00
|
|
|
if (this.pb != null) {
|
|
|
|
return this.pb;
|
2015-09-13 06:04:31 +02:00
|
|
|
}
|
2016-03-23 02:41:37 +01:00
|
|
|
if (this.id == 0) {
|
|
|
|
this.id = this.block.getTypeId();
|
2015-07-09 16:20:19 +02:00
|
|
|
}
|
|
|
|
byte data;
|
2016-03-23 02:41:37 +01:00
|
|
|
switch (this.id) {
|
2015-07-09 16:20:19 +02:00
|
|
|
case 0:
|
|
|
|
case 2:
|
|
|
|
case 4:
|
|
|
|
case 13:
|
|
|
|
case 14:
|
|
|
|
case 15:
|
|
|
|
case 20:
|
|
|
|
case 21:
|
|
|
|
case 22:
|
|
|
|
case 24:
|
|
|
|
case 25:
|
|
|
|
case 30:
|
|
|
|
case 32:
|
|
|
|
case 37:
|
|
|
|
case 39:
|
|
|
|
case 40:
|
|
|
|
case 41:
|
|
|
|
case 42:
|
|
|
|
case 45:
|
|
|
|
case 46:
|
|
|
|
case 47:
|
|
|
|
case 48:
|
|
|
|
case 49:
|
|
|
|
case 51:
|
|
|
|
case 52:
|
|
|
|
case 54:
|
|
|
|
case 55:
|
|
|
|
case 56:
|
|
|
|
case 57:
|
|
|
|
case 58:
|
|
|
|
case 60:
|
|
|
|
case 61:
|
|
|
|
case 62:
|
|
|
|
case 7:
|
|
|
|
case 8:
|
|
|
|
case 9:
|
|
|
|
case 10:
|
|
|
|
case 11:
|
|
|
|
case 73:
|
|
|
|
case 74:
|
|
|
|
case 78:
|
|
|
|
case 79:
|
|
|
|
case 80:
|
|
|
|
case 81:
|
|
|
|
case 82:
|
|
|
|
case 83:
|
|
|
|
case 84:
|
|
|
|
case 85:
|
|
|
|
case 87:
|
|
|
|
case 88:
|
|
|
|
case 101:
|
|
|
|
case 102:
|
|
|
|
case 103:
|
|
|
|
case 110:
|
|
|
|
case 112:
|
|
|
|
case 113:
|
|
|
|
case 117:
|
|
|
|
case 121:
|
|
|
|
case 122:
|
|
|
|
case 123:
|
|
|
|
case 124:
|
|
|
|
case 129:
|
|
|
|
case 133:
|
|
|
|
case 138:
|
|
|
|
case 137:
|
|
|
|
case 140:
|
|
|
|
case 165:
|
|
|
|
case 166:
|
|
|
|
case 169:
|
|
|
|
case 170:
|
|
|
|
case 172:
|
|
|
|
case 173:
|
|
|
|
case 174:
|
|
|
|
case 176:
|
|
|
|
case 177:
|
|
|
|
case 181:
|
|
|
|
case 182:
|
|
|
|
case 188:
|
|
|
|
case 189:
|
|
|
|
case 190:
|
|
|
|
case 191:
|
|
|
|
case 192:
|
|
|
|
data = 0;
|
2015-11-29 09:21:32 +01:00
|
|
|
break;
|
2015-07-09 16:20:19 +02:00
|
|
|
default:
|
2016-03-23 02:41:37 +01:00
|
|
|
data = this.block.getData();
|
2015-11-29 09:21:32 +01:00
|
|
|
break;
|
2015-07-09 16:20:19 +02:00
|
|
|
}
|
2016-06-03 22:20:13 +02:00
|
|
|
this.pb = PlotBlock.get((short) this.id, data);
|
2016-03-23 02:41:37 +01:00
|
|
|
return this.pb;
|
|
|
|
|
2015-07-09 16:20:19 +02:00
|
|
|
}
|
2016-03-23 02:41:37 +01:00
|
|
|
|
2015-07-09 16:20:19 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public int getId() {
|
2016-03-23 02:41:37 +01:00
|
|
|
if (this.id == 0) {
|
|
|
|
this.id = this.block.getTypeId();
|
2015-07-09 16:20:19 +02:00
|
|
|
}
|
2016-03-23 02:41:37 +01:00
|
|
|
return this.id;
|
2015-07-09 16:20:19 +02:00
|
|
|
}
|
2016-03-23 02:41:37 +01:00
|
|
|
|
2015-07-09 16:20:19 +02:00
|
|
|
}
|