-
Notifications
You must be signed in to change notification settings - Fork 1
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
c329abc
commit f977dd4
Showing
43 changed files
with
800 additions
and
204 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
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
45 changes: 45 additions & 0 deletions
45
api/src/main/java/kor/toxicity/questadder/api/gui/GuiData.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,45 @@ | ||
package kor.toxicity.questadder.api.gui; | ||
|
||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.Inventory; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Objects; | ||
|
||
public class GuiData { | ||
private final IGui gui; | ||
private final Inventory inventory; | ||
private GuiExecutor executor; | ||
private final Player player; | ||
|
||
public GuiData(@NotNull IGui gui, @NotNull Inventory inventory, @NotNull GuiExecutor executor, @NotNull Player player) { | ||
this.gui = gui; | ||
this.inventory = inventory; | ||
this.executor = executor; | ||
this.player = player; | ||
} | ||
|
||
public @NotNull GuiExecutor getExecutor() { | ||
return executor; | ||
} | ||
|
||
public @NotNull IGui getGui() { | ||
return gui; | ||
} | ||
|
||
public @NotNull Inventory getInventory() { | ||
return inventory; | ||
} | ||
|
||
public @NotNull Player getPlayer() { | ||
return player; | ||
} | ||
|
||
public void setExecutor(@NotNull GuiExecutor executor) { | ||
this.executor = Objects.requireNonNull(executor); | ||
} | ||
|
||
public void reopen() { | ||
gui.open(player,executor); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
api/src/main/java/kor/toxicity/questadder/api/gui/GuiExecutor.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,10 @@ | ||
package kor.toxicity.questadder.api.gui; | ||
|
||
import org.bukkit.inventory.ItemStack; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public interface GuiExecutor { | ||
void initialize(@NotNull GuiData data); | ||
void click(@NotNull GuiData data, @NotNull ItemStack clickedItem, int clickedSlot, boolean isPlayerInventory, @NotNull MouseButton button); | ||
void end(@NotNull GuiData data); | ||
} |
37 changes: 37 additions & 0 deletions
37
api/src/main/java/kor/toxicity/questadder/api/gui/GuiHolder.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,37 @@ | ||
package kor.toxicity.questadder.api.gui; | ||
|
||
import net.kyori.adventure.text.Component; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.Inventory; | ||
import org.bukkit.inventory.InventoryHolder; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Map; | ||
|
||
public class GuiHolder implements InventoryHolder { | ||
private final Inventory inventory; | ||
private final GuiData data; | ||
private final GuiExecutor executor; | ||
public GuiHolder(@NotNull IGui gui, int size, @NotNull Component name, @NotNull Player player, @NotNull GuiExecutor executor, @NotNull Map<Integer, ItemStack> map) { | ||
inventory = Bukkit.createInventory(this, size, name); | ||
map.forEach(inventory::setItem); | ||
data = new GuiData(gui, inventory, executor, player); | ||
this.executor = executor; | ||
executor.initialize(data); | ||
} | ||
|
||
public @NotNull GuiExecutor getExecutor() { | ||
return executor; | ||
} | ||
|
||
public @NotNull GuiData getData() { | ||
return data; | ||
} | ||
|
||
@Override | ||
public @NotNull Inventory getInventory() { | ||
return inventory; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
api/src/main/java/kor/toxicity/questadder/api/gui/IGui.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,16 @@ | ||
package kor.toxicity.questadder.api.gui; | ||
|
||
import net.kyori.adventure.text.Component; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Map; | ||
|
||
public interface IGui { | ||
@NotNull GuiHolder open(@NotNull Player player, @NotNull GuiExecutor executor); | ||
@NotNull | ||
Component getGuiName(); | ||
@NotNull | ||
Map<Integer, ItemStack> getInnerItems(); | ||
} |
9 changes: 9 additions & 0 deletions
9
api/src/main/java/kor/toxicity/questadder/api/gui/MouseButton.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,9 @@ | ||
package kor.toxicity.questadder.api.gui; | ||
|
||
public enum MouseButton { | ||
LEFT, | ||
RIGHT, | ||
SHIFT_LEFT, | ||
SHIFT_RIGHT, | ||
OTHER | ||
} |
19 changes: 19 additions & 0 deletions
19
api/src/main/java/kor/toxicity/questadder/api/mechanic/DialogSender.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,19 @@ | ||
package kor.toxicity.questadder.api.mechanic; | ||
|
||
import kor.toxicity.questadder.api.gui.IGui; | ||
import kor.toxicity.questadder.api.util.SoundData; | ||
import org.bukkit.entity.Entity; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public interface DialogSender { | ||
@Nullable | ||
Entity getEntity(); | ||
@NotNull | ||
SoundData getSoundData(); | ||
@NotNull | ||
String getTalkerName(); | ||
long getTypingSpeed(); | ||
@Nullable | ||
IGui getGui(); | ||
} |
7 changes: 4 additions & 3 deletions
7
api/src/main/java/kor/toxicity/questadder/api/mechanic/IActualNPC.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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
package kor.toxicity.questadder.api.mechanic; | ||
|
||
import net.citizensnpcs.api.npc.NPC; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public interface IActualNPC { | ||
NPC toCitizensNPC(); | ||
IQuestNPC toQuestNPC(); | ||
public interface IActualNPC extends DialogSender { | ||
@NotNull NPC toCitizensNPC(); | ||
@NotNull IQuestNPC toQuestNPC(); | ||
} |
21 changes: 21 additions & 0 deletions
21
api/src/main/java/kor/toxicity/questadder/api/util/SoundData.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,21 @@ | ||
package kor.toxicity.questadder.api.util; | ||
|
||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public record SoundData(@NotNull String name, float volume, float pitch) { | ||
public static @Nullable SoundData fromString(@NotNull String string) { | ||
var split = string.split(" "); | ||
if (split.length < 3) return null; | ||
try { | ||
return new SoundData(split[0], Float.parseFloat(split[1]), Float.parseFloat(split[2])); | ||
} catch (Exception e) { | ||
return null; | ||
} | ||
} | ||
|
||
public void play(@NotNull Player player) { | ||
player.playSound(player.getLocation(), name, volume, pitch); | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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
52 changes: 52 additions & 0 deletions
52
plugin/src/main/java/kor/toxicity/questadder/block/BrownMushroomBlockData.kt
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,52 @@ | ||
package kor.toxicity.questadder.block | ||
|
||
import org.bukkit.Material | ||
import org.bukkit.block.BlockFace | ||
import org.bukkit.block.data.BlockData | ||
import org.bukkit.block.data.MultipleFacing | ||
|
||
data class BrownMushroomBlockData( | ||
val west: Boolean, | ||
val up: Boolean, | ||
val south: Boolean, | ||
val north: Boolean, | ||
val east: Boolean, | ||
val down: Boolean | ||
): QuestBlockData { | ||
companion object { | ||
fun fromHash(hash: Int): BrownMushroomBlockData { | ||
val bit = hash and ((1 shl 6) - 1) | ||
|
||
return BrownMushroomBlockData( | ||
(bit and 1) == 1, | ||
((bit ushr 1) and 1) == 1, | ||
((bit ushr 2) and 1) == 1, | ||
((bit ushr 3) and 1) == 1, | ||
((bit ushr 4) and 1) == 1, | ||
((bit ushr 5) and 1) == 1, | ||
) | ||
} | ||
fun fromBlock(blockData: MultipleFacing): BrownMushroomBlockData { | ||
val direction = blockData.faces | ||
return BrownMushroomBlockData( | ||
direction.contains(BlockFace.WEST), | ||
direction.contains(BlockFace.UP), | ||
direction.contains(BlockFace.SOUTH), | ||
direction.contains(BlockFace.NORTH), | ||
direction.contains(BlockFace.EAST), | ||
direction.contains(BlockFace.DOWN) | ||
) | ||
} | ||
} | ||
|
||
override fun toKey(): String = "west=$west,up=$up,south=$south,north=$north,east=$east,down=$down" | ||
|
||
override fun createBlockData(): BlockData = (Material.BROWN_MUSHROOM_BLOCK.createBlockData() as MultipleFacing).also { | ||
it.setFace(BlockFace.WEST, west) | ||
it.setFace(BlockFace.UP, up) | ||
it.setFace(BlockFace.SOUTH, south) | ||
it.setFace(BlockFace.NORTH, north) | ||
it.setFace(BlockFace.EAST, east) | ||
it.setFace(BlockFace.DOWN, down) | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
plugin/src/main/java/kor/toxicity/questadder/block/ChorusPlantBlockData.kt
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,52 @@ | ||
package kor.toxicity.questadder.block | ||
|
||
import org.bukkit.Material | ||
import org.bukkit.block.BlockFace | ||
import org.bukkit.block.data.BlockData | ||
import org.bukkit.block.data.MultipleFacing | ||
|
||
data class ChorusPlantBlockData( | ||
val west: Boolean, | ||
val up: Boolean, | ||
val south: Boolean, | ||
val north: Boolean, | ||
val east: Boolean, | ||
val down: Boolean | ||
): QuestBlockData { | ||
companion object { | ||
fun fromHash(hash: Int): ChorusPlantBlockData { | ||
val bit = hash and ((1 shl 6) - 1) | ||
|
||
return ChorusPlantBlockData( | ||
(bit and 1) == 1, | ||
((bit ushr 1) and 1) == 1, | ||
((bit ushr 2) and 1) == 1, | ||
((bit ushr 3) and 1) == 1, | ||
((bit ushr 4) and 1) == 1, | ||
((bit ushr 5) and 1) == 1, | ||
) | ||
} | ||
fun fromBlock(blockData: MultipleFacing): ChorusPlantBlockData { | ||
val direction = blockData.faces | ||
return ChorusPlantBlockData( | ||
direction.contains(BlockFace.WEST), | ||
direction.contains(BlockFace.UP), | ||
direction.contains(BlockFace.SOUTH), | ||
direction.contains(BlockFace.NORTH), | ||
direction.contains(BlockFace.EAST), | ||
direction.contains(BlockFace.DOWN) | ||
) | ||
} | ||
} | ||
|
||
override fun toKey(): String = "west=$west,up=$up,south=$south,north=$north,east=$east,down=$down" | ||
|
||
override fun createBlockData(): BlockData = (Material.CHORUS_PLANT.createBlockData() as MultipleFacing).also { | ||
it.setFace(BlockFace.WEST, west) | ||
it.setFace(BlockFace.UP, up) | ||
it.setFace(BlockFace.SOUTH, south) | ||
it.setFace(BlockFace.NORTH, north) | ||
it.setFace(BlockFace.EAST, east) | ||
it.setFace(BlockFace.DOWN, down) | ||
} | ||
} |
Oops, something went wrong.