-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #161 from SpaceServerUniverse/dev/m1sk9-impove-mai…
…n-menu feat: メインメニュー関連の改善
- Loading branch information
Showing
8 changed files
with
153 additions
and
51 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
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
33 changes: 33 additions & 0 deletions
33
src/main/java/space/yurisi/universecorev2/event/player/OpenMainMenuEvent.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,33 @@ | ||
package space.yurisi.universecorev2.event.player; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerInteractEvent; | ||
import org.bukkit.inventory.ItemStack; | ||
import space.yurisi.universecorev2.item.UniverseItem; | ||
import space.yurisi.universecorev2.item.book.MainMenuBook; | ||
|
||
public class OpenMainMenuEvent implements Listener { | ||
|
||
@EventHandler(priority = EventPriority.HIGH) | ||
public void onInteract(PlayerInteractEvent event) { | ||
Player player = event.getPlayer(); | ||
|
||
ItemStack targetItem = event.getItem(); | ||
|
||
switch (targetItem.getType()) { | ||
case KNOWLEDGE_BOOK -> { | ||
ItemStack item = UniverseItem.getItem(MainMenuBook.id).getItem(); | ||
if (targetItem.isSimilar(item)) { | ||
Bukkit.dispatchCommand(player, "menu"); | ||
} | ||
event.setCancelled(true); | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
28 changes: 0 additions & 28 deletions
28
src/main/java/space/yurisi/universecorev2/event/player/TouchEvent.java
This file was deleted.
Oops, something went wrong.
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
36 changes: 36 additions & 0 deletions
36
src/main/java/space/yurisi/universecorev2/item/book/MainMenuBook.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,36 @@ | ||
package space.yurisi.universecorev2.item.book; | ||
|
||
import net.kyori.adventure.text.Component; | ||
import org.bukkit.Material; | ||
import org.bukkit.enchantments.Enchantment; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.inventory.meta.ItemMeta; | ||
import space.yurisi.universecorev2.item.CustomItem; | ||
|
||
public class MainMenuBook extends CustomItem { | ||
|
||
public static final String id = "main_menu_book"; | ||
|
||
public MainMenuBook() { | ||
super( | ||
id, | ||
"§eメインメニュー", | ||
// 本来の用途はレシピの限定解放だが, あくまでミニゲーム用で生活鯖運用ではただの緑の本 | ||
// https://ja.minecraft.wiki/w/%E7%9F%A5%E6%81%B5%E3%81%AE%E6%9C%AC | ||
ItemStack.of(Material.KNOWLEDGE_BOOK) | ||
); | ||
} | ||
|
||
@Override | ||
protected void registerItemFunction() { | ||
default_setting = (item) -> { | ||
ItemMeta meta = item.getItemMeta(); | ||
if (meta != null) { | ||
meta.addEnchant(Enchantment.VANISHING_CURSE, 1, true); | ||
meta.setUnbreakable(true); | ||
item.setItemMeta(meta); | ||
} | ||
return item; | ||
}; | ||
} | ||
} |
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