-
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.
Merge pull request #11 from the-codeboy/dev
Dev
- Loading branch information
Showing
11 changed files
with
295 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: "[BUG] " | ||
labels: bug | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**Desktop (please complete the following information):** | ||
- OS: [e.g. Windows 11, Linux] | ||
- Java version: [e.g. OpenJDK 1.8, 17] | ||
- Minecraft version: [e.g. 1.8.8, 1.16.1] | ||
- Plugin version: [e.g. 1.1, 1.2] | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
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,20 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: '' | ||
labels: enhancement | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
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
35 changes: 35 additions & 0 deletions
35
src/main/java/com/github/codeboy/mcide/commands/BoundItemCommand.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,35 @@ | ||
package com.github.codeboy.mcide.commands; | ||
|
||
import com.github.codeboy.mcide.config.Message; | ||
import com.github.codeboy.mcide.ide.gui.ProjectSelector; | ||
import com.github.codeboy.mcide.services.CustomItemEventManager; | ||
import ml.codeboy.bukkitbootstrap.CustomItem; | ||
import org.bukkit.Material; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.block.Action; | ||
|
||
public class BoundItemCommand implements CommandExecutor { | ||
@Override | ||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { | ||
if (!(sender instanceof Player)) { | ||
return false; | ||
} | ||
Player player = (Player) sender; | ||
CustomItem customItem = CustomItem.createItemOrGet(player.getPlayerListName(), Material.GOLD_HOE, (short) 0); | ||
player.getInventory().addItem(customItem.getItem()); | ||
|
||
CustomItemEventManager.addInteraction(customItem, event -> { | ||
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) { | ||
Player p = event.getPlayer(); | ||
event.setCancelled(true); | ||
ProjectSelector menu = new ProjectSelector(p); | ||
menu.open(p); | ||
event.setCancelled(true); | ||
} | ||
}); | ||
return true; | ||
} | ||
} |
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
35 changes: 35 additions & 0 deletions
35
src/main/java/com/github/codeboy/mcide/services/CustomItemEventManager.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,35 @@ | ||
package com.github.codeboy.mcide.services; | ||
|
||
import ml.codeboy.bukkitbootstrap.CustomItem; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerInteractEvent; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
import java.util.HashMap; | ||
import java.util.function.Consumer; | ||
|
||
public class CustomItemEventManager implements Listener { | ||
|
||
private static final HashMap<CustomItem, Consumer<PlayerInteractEvent>> interactions = new HashMap<>(); | ||
|
||
@EventHandler | ||
public void onPlayerUse(PlayerInteractEvent event) { | ||
Player player = event.getPlayer(); | ||
ItemStack item = player.getItemInHand(); | ||
for(CustomItem customItem:interactions.keySet()){ | ||
if (customItem.itemIsInstance(item)) { | ||
interactions.get(customItem).accept(event); | ||
} | ||
} | ||
} | ||
|
||
public static boolean addInteraction(CustomItem customItem,Consumer<PlayerInteractEvent> interaction){ | ||
if(interactions.containsKey(customItem)){ | ||
return false; | ||
} | ||
interactions.put(customItem,interaction); | ||
return true; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -7,4 +7,5 @@ website: https://github.com/the-codeboy | |
commands: | ||
run: | ||
ide: | ||
create-project: | ||
create-project: | ||
bound-item: |
Oops, something went wrong.