This commit is contained in:
boy0001 2015-05-02 16:18:34 +10:00
parent 62073fa488
commit 333128b203
3 changed files with 102 additions and 112 deletions

View File

@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.PlotSquared;
@ -194,123 +195,110 @@ public class HybridPlotWorld extends ClassicPlotWorld {
} }
this.ROAD_SCHEMATIC_ENABLED = true; this.ROAD_SCHEMATIC_ENABLED = true;
} }
public static byte wrap(byte data, int start) {
if (data >= start && data < start + 4) {
data = (byte) ((((data - start) + 2) % 4) + start);
}
return data;
}
public static byte wrap2(byte data, int start) {
if (data >= start && data < start + 2) {
data = (byte) ((((data - start) + 1) % 2) + start);
}
return data;
}
public static boolean isRotate(final short id) { public static byte rotate(final short id, byte data) {
switch (id) { switch (id) {
case 23:
return true;
case 26:
return true;
case 27:
return true;
case 28:
return true;
case 29:
return true;
case 33:
return true;
case 53:
return true;
case 54:
return true;
case 55:
return true;
case 61:
return true;
case 62:
return true;
case 64:
return true;
case 65:
return true;
case 67:
return true;
case 68:
return true;
case 71:
return true;
case 77:
return true;
case 86:
return true;
case 84:
return true;
case 93:
return true;
case 94:
return true;
case 96:
return true;
case 107:
return true;
case 108:
return true;
case 109:
return true;
case 111:
return true;
case 119:
return true;
case 128:
return true;
case 130:
return true;
case 131:
return true;
case 134:
return true;
case 135:
return true;
case 136:
return true;
case 143:
return true;
case 144:
return true;
case 145:
return true;
case 146:
return true;
case 149:
return true;
case 150:
return true;
case 156:
return true;
case 157:
return true;
case 158:
return true;
case 163:
return true;
case 164:
return true;
case 167:
return true;
case 180:
return true;
case 183: case 183:
return true;
case 184: case 184:
return true;
case 185: case 185:
return true;
case 186: case 186:
return true;
case 187: case 187:
return true; case 107:
case 53:
case 67:
case 108:
case 109:
case 114:
case 128:
case 134:
case 135:
case 136:
case 156:
case 163:
case 164:
case 180: {
data = wrap(data, 0);
data = wrap(data, 4);
return data;
}
case 26:
case 86: {
data = wrap(data, 0);
return data;
}
case 64:
case 71:
case 193: case 193:
return true;
case 194: case 194:
return true;
case 195: case 195:
return true;
case 196: case 196:
return true;
case 197: case 197:
return true; case 93:
case 94:
case 131:
case 145:
case 149:
case 150:
case 96:
case 167: {
data = wrap(data, 0);
data = wrap(data, 4);
data = wrap(data, 8);
data = wrap(data, 12);
return data;
}
case 28:
case 66:
case 157:
case 27: {
data = wrap2(data, 0);
data = wrap2(data, 3);
if (data == 2) {
data = 5;
}
else if (data == 5) {
data = 2;
}
return data;
}
case 23:
case 29:
case 33:
case 158:
case 54:
case 130:
case 146:
case 61:
case 62:
case 65:
case 68:
case 144: {
data = wrap(data, 2);
return data;
}
case 143:
case 77: {
data = wrap(data, 1);
return data;
}
default: default:
return false; return data;
} }
} }
@ -326,12 +314,12 @@ public class HybridPlotWorld extends ClassicPlotWorld {
this.G_SCH.put(loc, new HashMap<Short, Short>()); this.G_SCH.put(loc, new HashMap<Short, Short>());
} }
this.G_SCH.get(loc).put(y, id); this.G_SCH.get(loc).put(y, id);
if (isRotate(id)) { if (rotate) {
if (rotate) { byte newdata = rotate(id, data);
data = (byte) ((data + 2) % 4); if (data == 0 && newdata == 0) {
return;
} }
} else if (data == 0) { data = newdata;
return;
} }
if (!this.G_SCH_DATA.containsKey(loc)) { if (!this.G_SCH_DATA.containsKey(loc)) {
this.G_SCH_DATA.put(loc, new HashMap<Short, Byte>()); this.G_SCH_DATA.put(loc, new HashMap<Short, Byte>());

View File

@ -138,7 +138,7 @@ public class HybridPop extends PlotPopulator {
final HashMap<Short, Byte> blocks = this.plotworld.G_SCH_DATA.get(loc); final HashMap<Short, Byte> blocks = this.plotworld.G_SCH_DATA.get(loc);
if (blocks != null) { if (blocks != null) {
for (final short y : blocks.keySet()) { for (final short y : blocks.keySet()) {
setBlock(x, (short) (this.plotheight + y), z, blocks.get(y)); setBlockAbs(x, (short) (this.plotheight + y), z, blocks.get(y));
} }
} }
if (this.plotworld.G_SCH_STATE != null) { if (this.plotworld.G_SCH_STATE != null) {
@ -183,7 +183,7 @@ public class HybridPop extends PlotPopulator {
final HashMap<Short, Byte> blocks = this.plotworld.G_SCH_DATA.get(loc); final HashMap<Short, Byte> blocks = this.plotworld.G_SCH_DATA.get(loc);
if (blocks != null) { if (blocks != null) {
for (final short y : blocks.keySet()) { for (final short y : blocks.keySet()) {
setBlock(x, (short) (this.plotheight + y), z, blocks.get(y)); setBlockAbs(x, (short) (this.plotheight + y), z, blocks.get(y));
} }
} }
if (this.plotworld.G_SCH_STATE != null) { if (this.plotworld.G_SCH_STATE != null) {
@ -218,7 +218,7 @@ public class HybridPop extends PlotPopulator {
final HashMap<Short, Byte> blocks = this.plotworld.G_SCH_DATA.get(loc); final HashMap<Short, Byte> blocks = this.plotworld.G_SCH_DATA.get(loc);
if (blocks != null) { if (blocks != null) {
for (final short y : blocks.keySet()) { for (final short y : blocks.keySet()) {
setBlock(x, (short) (this.roadheight + y), z, blocks.get(y)); setBlockAbs(x, (short) (this.roadheight + y), z, blocks.get(y));
} }
} }
} }

View File

@ -830,10 +830,12 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
final PlotWorld pW = PlotSquared.getPlotWorld(world); final PlotWorld pW = PlotSquared.getPlotWorld(world);
final CreatureSpawnEvent.SpawnReason reason = event.getSpawnReason(); final CreatureSpawnEvent.SpawnReason reason = event.getSpawnReason();
System.out.print("REASON: " + reason);
if ((reason == CreatureSpawnEvent.SpawnReason.SPAWNER_EGG || reason == CreatureSpawnEvent.SpawnReason.DISPENSE_EGG) && !pW.SPAWN_EGGS) { if ((reason == CreatureSpawnEvent.SpawnReason.SPAWNER_EGG || reason == CreatureSpawnEvent.SpawnReason.DISPENSE_EGG) && !pW.SPAWN_EGGS) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} else if ((reason == CreatureSpawnEvent.SpawnReason.BREEDING) && !pW.SPAWN_BREEDING) { } else if ((reason == CreatureSpawnEvent.SpawnReason.BREEDING) && !pW.SPAWN_BREEDING) {
System.out.print("CANCELLED: " + pW.SPAWN_BREEDING);
event.setCancelled(true); event.setCancelled(true);
return; return;
} else if ((reason == CreatureSpawnEvent.SpawnReason.CUSTOM) && !pW.SPAWN_CUSTOM && !(event.getEntityType().getTypeId() == 30)) { } else if ((reason == CreatureSpawnEvent.SpawnReason.CUSTOM) && !pW.SPAWN_CUSTOM && !(event.getEntityType().getTypeId() == 30)) {