Skip to content

Commit

Permalink
Fixed minor bugs and added documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Dec 5, 2023
1 parent 6c0f403 commit b854616
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ You can do this by calling the CustomCore.registerItems() method in your onEnabl
```java
@Override
public void onEnable() {
registerItems(new FlightStick());
registerItems(new ShadowSword());
}
```
<br/>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.michadev</groupId>
<artifactId>CustomCore</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<packaging>jar</packaging>

<name>CustomCore</name>
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/me/michadev/customcore/CustomCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import me.michadev.customcore.custominventory.CustomInventoryHandler;
import me.michadev.customcore.customitems.CustomItem;
import me.michadev.customcore.customitems.CustomItemHandler;
import me.michadev.customcore.customitems.impl.FlightStick;
import me.michadev.customcore.customitems.example.FlightStick;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.event.Listener;
Expand All @@ -23,6 +23,10 @@ public final class CustomCore extends JavaPlugin {
public static Map<String, CustomItem> customItemMap;
public static CustomBlockHandler blockHandler;

public CustomItem getCustomItem(String itemID) {
return CustomCore.customItemMap.get(itemID.toLowerCase());
}

@Override
public void onEnable() {
rpgItemKey = new NamespacedKey(this, "rpg_item_key");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ public class CustomItemHandler implements Listener {

@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
event.getPlayer().getInventory().addItem(CustomCore.customItemMap.get("FlightStick").getItem());
event.getPlayer().getInventory().addItem(CustomCore.customItemMap.get("flightstick").getItem());
}

@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
ItemStack heldItem = player.getInventory().getItemInMainHand();

if (heldItem == null) return;

if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK) || event.getAction().equals(Action.RIGHT_CLICK_AIR) && isCustomItem(heldItem)) {
CustomItem customItem = CustomCore.customItemMap.get(getItemId(heldItem));
customItem.handleRightClick(player, heldItem, event);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.michadev.customcore.customitems.impl;
package me.michadev.customcore.customitems.example;

import me.michadev.customcore.customitems.CustomItem;
import org.bukkit.Location;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
main: me.michadev.customcore.CustomCore
name: CustomCore
version: 1.0.1
version: 1.0.2
api-version: 1.20

0 comments on commit b854616

Please sign in to comment.