-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a9077e
commit da79bab
Showing
3 changed files
with
92 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/world/state/states/Version_1_13.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package cc.funkemunky.api.utils.world.state.states; | ||
|
||
import cc.funkemunky.api.tinyprotocol.api.ProtocolVersion; | ||
import cc.funkemunky.api.utils.Init; | ||
import cc.funkemunky.api.utils.world.state.BlockStateManager; | ||
import org.bukkit.Material; | ||
import org.bukkit.block.data.Bisected; | ||
import org.bukkit.block.data.type.Door; | ||
|
||
import java.util.Arrays; | ||
|
||
@Init(requireProtocolVersion = ProtocolVersion.V1_13) | ||
public class Version_1_13 { | ||
public Version_1_13() { | ||
Arrays.stream(Material.values()) | ||
.filter(m -> m.name().contains("DOOR") && !m.name().contains("TRAP")) | ||
.forEach(m -> { | ||
BlockStateManager.stateInterfaceMap.put(m, (field, block) -> { | ||
Door door = (Door) block.getBlockData(); | ||
switch (field.toLowerCase()) { | ||
case "hinge": { | ||
return door.getHinge().equals(Door.Hinge.RIGHT); | ||
} | ||
case "top": { | ||
return door.getHalf().equals(Bisected.Half.TOP); | ||
} | ||
case "facing": { | ||
return door.getFacing().ordinal() - 1; | ||
} | ||
case "open": { | ||
return door.isOpen(); | ||
} | ||
} | ||
return null; | ||
}); | ||
}); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...Parent/Atlas/src/main/java/cc/funkemunky/api/utils/world/state/states/Version_1_7_10.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package cc.funkemunky.api.utils.world.state.states; | ||
|
||
import cc.funkemunky.api.tinyprotocol.api.ProtocolVersion; | ||
import cc.funkemunky.api.utils.Init; | ||
import cc.funkemunky.api.utils.world.state.BlockStateManager; | ||
import org.bukkit.Material; | ||
import org.bukkit.block.data.Bisected; | ||
import org.bukkit.material.Door; | ||
|
||
import java.util.Arrays; | ||
|
||
@Init | ||
public class Version_1_7_10 { | ||
public Version_1_7_10() { | ||
if(ProtocolVersion.getGameVersion().isBelow(ProtocolVersion.V1_13)) { | ||
Arrays.stream(Material.values()) | ||
.filter(m -> m.name().contains("DOOR") && !m.name().contains("TRAP")) | ||
.forEach(m -> { | ||
BlockStateManager.stateInterfaceMap.put(m, (field, block) -> { | ||
Door door = (Door) block.getType().getNewData(block.getData()); | ||
switch (field.toLowerCase()) { | ||
case "hinge": { | ||
return door.getHinge(); | ||
} | ||
case "top": { | ||
return door.isTopHalf(); | ||
} | ||
case "facing": { | ||
return door.getFacing().ordinal(); | ||
} | ||
case "open": { | ||
return door.isOpen(); | ||
} | ||
} | ||
return null; | ||
}); | ||
}); | ||
} | ||
} | ||
} |