Skip to content

Commit 05ea897

Browse files
Fix some issues with SURGERY room & a HOSPITAL door circuit
1 parent bf320db commit 05ea897

6 files changed

Lines changed: 73 additions & 28 deletions

File tree

src/main/java/me/eccentric_nz/TARDIS/ARS/TARDISARSRunnable.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ public void run() {
8181
wall_type = Material.ORANGE_WOOL;
8282
floor_type = Material.LIGHT_GRAY_WOOL;
8383
}
84+
// SURGERY special case
85+
if (room.getConfigPath().equals("SURGERY")) {
86+
wall_type = Material.WHITE_CONCRETE;
87+
floor_type = Material.LIGHT_GRAY_CONCRETE;
88+
}
8489
roomData.setMiddleType(wall_type);
8590
roomData.setFloorType(floor_type);
8691
// get start locations

src/main/java/me/eccentric_nz/TARDIS/rooms/TARDISRoomRunnable.java

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import me.eccentric_nz.TARDIS.blueprints.TARDISPermission;
2525
import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayItem;
2626
import me.eccentric_nz.TARDIS.customblocks.TARDISDisplayItemUtils;
27-
import me.eccentric_nz.TARDIS.customblocks.TARDISMushroomBlockData;
2827
import me.eccentric_nz.TARDIS.database.resultset.ResultSetFarming;
2928
import me.eccentric_nz.TARDIS.database.resultset.ResultSetTardisTimeLordName;
3029
import me.eccentric_nz.TARDIS.enumeration.Room;
@@ -88,6 +87,7 @@ public class TARDISRoomRunnable implements Runnable {
8887
private final HashMap<Block, BlockData> redstoneTorchblocks = new HashMap<>();
8988
private final HashMap<Block, BlockData> seagrass = new HashMap<>();
9089
private final HashMap<Block, BlockData> torchblocks = new HashMap<>();
90+
private final HashMap<Block, BlockData> trapdoorblocks = new HashMap<>();
9191
private final HashMap<Block, BlockFace> mushroomblocks = new HashMap<>();
9292
private final HashMap<Block, TARDISBannerData> bannerblocks = new HashMap<>();
9393
private final BlockFace[] repeaterData = new BlockFace[6];
@@ -134,6 +134,7 @@ public TARDISRoomRunnable(TARDIS plugin, TARDISRoomData roomData, UUID uuid, boo
134134
notThese.add(Material.CARROTS);
135135
notThese.add(Material.COCOA);
136136
notThese.add(Material.DARK_OAK_DOOR);
137+
notThese.add(Material.IRON_TRAPDOOR);
137138
notThese.add(Material.JUNGLE_DOOR);
138139
notThese.add(Material.LEVER);
139140
notThese.add(Material.MANGROVE_PROPAGULE);
@@ -208,6 +209,7 @@ public void run() {
208209
case SPRUCE_SIGN -> signblocks.add(postBlock);
209210
case OAK_DOOR -> doorblocks.put(postBlock, postData);
210211
case LEVER -> leverblocks.put(postBlock, postData);
212+
case IRON_TRAPDOOR -> trapdoorblocks.put(postBlock, postData);
211213
default -> {
212214
}
213215
}
@@ -258,6 +260,11 @@ public void run() {
258260
prop.getKey().setBlockData(prop.getValue());
259261
}
260262
}
263+
if (trapdoorblocks.size() > 0) {
264+
for (Map.Entry<Block, BlockData> trap : trapdoorblocks.entrySet()) {
265+
trap.getKey().setBlockData(trap.getValue());
266+
}
267+
}
261268
if (seagrass.size() > 0) {
262269
for (Map.Entry<Block, BlockData> grass : seagrass.entrySet()) {
263270
grass.getKey().setBlockData(grass.getValue());
@@ -624,19 +631,21 @@ public void run() {
624631
sets.put(room.toLowerCase(Locale.ENGLISH), world.getName() + ":" + startx + ":" + starty + ":" + startz);
625632
HashMap<String, Object> wheres = new HashMap<>();
626633
wheres.put("tardis_id", tardis_id);
627-
if (room.equals("RENDERER") || room.equals("ZERO")) {
628-
plugin.getQueryFactory().doUpdate("tardis", sets, wheres);
629-
} else if (room.equals("MAZE")) {
630-
String loc_str = TARDISStaticLocationGetters.makeLocationStr(world, startx, starty + 1, startz);
631-
plugin.getQueryFactory().insertControl(tardis_id, 44, loc_str, 0);
632-
} else {
633-
ResultSetFarming rsf = new ResultSetFarming(plugin, tardis_id);
634-
if (rsf.resultSet()) {
635-
// update
636-
plugin.getQueryFactory().doUpdate("farming", sets, wheres);
637-
} else {
638-
sets.put("tardis_id", tardis_id);
639-
plugin.getQueryFactory().doInsert("farming", sets);
634+
switch (room) {
635+
case "RENDERER", "ZERO" -> plugin.getQueryFactory().doUpdate("tardis", sets, wheres);
636+
case "MAZE" -> {
637+
String loc_str = TARDISStaticLocationGetters.makeLocationStr(world, startx, starty + 1, startz);
638+
plugin.getQueryFactory().insertControl(tardis_id, 44, loc_str, 0);
639+
}
640+
default -> {
641+
ResultSetFarming rsf = new ResultSetFarming(plugin, tardis_id);
642+
if (rsf.resultSet()) {
643+
// update
644+
plugin.getQueryFactory().doUpdate("farming", sets, wheres);
645+
} else {
646+
sets.put("tardis_id", tardis_id);
647+
plugin.getQueryFactory().doInsert("farming", sets);
648+
}
640649
}
641650
}
642651
// replace with correct block
@@ -726,6 +735,12 @@ public void run() {
726735
Block lever = world.getBlockAt(startx, starty, startz);
727736
leverblocks.put(lever, data);
728737
}
738+
// remember iron trap doors if SURGERY room
739+
if (type.equals(Material.IRON_TRAPDOOR) && room.equals("SURGERY")) {
740+
Block trap = world.getBlockAt(startx, starty, startz);
741+
trapdoorblocks.put(trap, data);
742+
rd.getPostBlocks().add(world.getName() + ":" + startx + ":" + starty + ":" + startz + "~" + data.getAsString());
743+
}
729744
// remember redstone torches
730745
if (type.equals(Material.REDSTONE_TORCH)) {
731746
Block torch = world.getBlockAt(startx, starty, startz);
@@ -817,8 +832,13 @@ public void run() {
817832
if (checkRoomNextDoor(world.getBlockAt(startx, starty, startz))) {
818833
data = TARDISConstants.AIR;
819834
} else {
820-
BlockData wall = (ow.equals(Material.ORANGE_WOOL)) ? plugin.getServer().createBlockData(TARDISMushroomBlockData.MUSHROOM_STEM_DATA.get(46)) : ow.createBlockData();
821-
data = (wall_type.equals(Material.ORANGE_WOOL)) ? wall : wall_type.createBlockData();
835+
if (ow.equals(Material.ORANGE_WOOL) && wall_type.equals(Material.ORANGE_WOOL)) {
836+
data = TARDISConstants.BARRIER;
837+
// set hexagon item display
838+
TARDISDisplayItemUtils.set(TARDISDisplayItem.HEXAGON, world, startx, starty, startz);
839+
} else {
840+
data = (wall_type.equals(Material.ORANGE_WOOL)) ? ow.createBlockData() : wall_type.createBlockData();
841+
}
822842
}
823843
}
824844
// always clear the door blocks on the north and west sides of adjacent spaces

src/main/java/me/eccentric_nz/TARDIS/schematic/TARDISItemDisplaySetter.java

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
import org.bukkit.Location;
2525
import org.bukkit.Material;
2626
import org.bukkit.block.Block;
27+
import org.bukkit.entity.Display;
28+
import org.bukkit.entity.EntityType;
29+
import org.bukkit.entity.ItemDisplay;
30+
import org.bukkit.inventory.ItemStack;
31+
import org.bukkit.inventory.meta.ItemMeta;
2732

2833
/**
2934
* @author macgeek
@@ -45,22 +50,38 @@ public static void fakeBlock(JsonObject json, Location start, int id) {
4550
}
4651
if (stack.has("door")) {
4752
HashMap<String, Object> setd = new HashMap<>();
48-
String doorloc = block.getWorld().getName() + ":" + l.getBlockX() + ":" + l.getBlockY() + ":" + l.getBlockZ();
49-
setd.put("tardis_id", id);
50-
setd.put("door_type", 1);
51-
setd.put("door_location", doorloc);
52-
setd.put("door_direction", "SOUTH");
53-
TARDIS.plugin.getQueryFactory().doInsert("doors", setd);
54-
// if create_worlds is true, set the world spawn
55-
if (TARDIS.plugin.getConfig().getBoolean("creation.create_worlds")) {
56-
block.getWorld().setSpawnLocation(l.getBlockX(), l.getBlockY(), (l.getBlockZ() + 1));
57-
}
53+
String doorloc = block.getWorld().getName() + ":" + l.getBlockX() + ":" + l.getBlockY() + ":" + l.getBlockZ();
54+
setd.put("tardis_id", id);
55+
setd.put("door_type", 1);
56+
setd.put("door_location", doorloc);
57+
setd.put("door_direction", "SOUTH");
58+
TARDIS.plugin.getQueryFactory().doInsert("doors", setd);
59+
// if create_worlds is true, set the world spawn
60+
if (TARDIS.plugin.getConfig().getBoolean("creation.create_worlds")) {
61+
block.getWorld().setSpawnLocation(l.getBlockX(), l.getBlockY(), (l.getBlockZ() + 1));
62+
}
5863
}
5964
Material material = Material.valueOf(stack.get("type").getAsString());
6065
TARDISDisplayItem tdi = TARDISDisplayItem.getByMaterialAndData(material, model);
6166
if (tdi != null) {
6267
TARDISDisplayItemUtils.set(tdi, block);
68+
} else {
69+
setInRoom(block, material, model);
6370
}
6471
}
6572
}
73+
74+
public static void setInRoom(Block block, Material material, int model) {
75+
ItemDisplay display = (ItemDisplay) block.getWorld().spawnEntity(block.getLocation().clone().add(0.5d, 0.25d, 0.5d), EntityType.ITEM_DISPLAY);
76+
ItemStack is = new ItemStack(material);
77+
if (model != -1) {
78+
ItemMeta im = is.getItemMeta();
79+
im.setCustomModelData(model);
80+
is.setItemMeta(im);
81+
}
82+
display.setItemStack(is);
83+
display.setItemDisplayTransform(ItemDisplay.ItemDisplayTransform.GROUND);
84+
display.setBillboard(Display.Billboard.VERTICAL);
85+
display.setInvulnerable(true);
86+
}
6687
}
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.

todo.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
## Version 5.0.0
66

7-
1. Fix bottle and xray in surgery room
8-
2. ?
7+
1. ?
98

109
## Next version `5.1.0`
1110

0 commit comments

Comments
 (0)