Skip to content

Commit

Permalink
Merge pull request #3 from luisBazanDev/development
Browse files Browse the repository at this point in the history
Added createKitFromPlayer method in KitsHelper and update version to …
  • Loading branch information
luisBazanDev authored Feb 2, 2024
2 parents 217592f + 27f9022 commit 928fd40
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
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>pe.bazan.luis.plugins</groupId>
<artifactId>KitsAPI</artifactId>
<version>1.2</version>
<version>1.2.1</version>
<packaging>jar</packaging>

<name>KitsAPI</name>
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/pe/bazan/luis/plugins/kitsapi/api/KitsHelper.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package pe.bazan.luis.plugins.kitsapi.api;

import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import pe.bazan.luis.plugins.kitsapi.KitsAPI;
Expand Down Expand Up @@ -50,4 +53,19 @@ public static PluginKitsManager getKitManager(Plugin plugin) {
pluginsKitManagers.put(plugin, new PluginKitsManager(plugin));
return pluginsKitManagers.get(plugin);
}

/**
* Create a kit from player inventory
* @param player player to create kit
* @return new instance of Kit, without any tracking or saving
*/
public static Kit createKitFromPlayer(Player player) {
PlayerInventory playerInventory = player.getInventory();
HashMap<Integer, ItemStack> items = new HashMap<>();
for (int i = 0; i <= 45; i++) {
if (playerInventory.getItem(i) == null) continue;
items.put(i, playerInventory.getItem(i));
}
return new Kit(player.getName(), items);
}
}

0 comments on commit 928fd40

Please sign in to comment.