Skip to content

Commit

Permalink
JitPack
Browse files Browse the repository at this point in the history
  • Loading branch information
Moderrek committed Jan 27, 2024
1 parent 5b197ca commit c31baac
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
15 changes: 15 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
plugins {
id 'java'
id 'maven-publish'
}

apply plugin: 'maven-publish'

group = 'com.impact.lib'
version = '1.0'

Expand Down Expand Up @@ -55,3 +58,15 @@ processResources {
expand props
}
}

publishing {
publications {
maven(MavenPublication) {
groupId = 'com.impact.lib'
artifactId = 'ImpactMC'
version = '1.0'

from components.java
}
}
}
2 changes: 2 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jdk:
- openjdk17
34 changes: 34 additions & 0 deletions src/main/java/com/impact/lib/Impact.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitTask;
import org.jetbrains.annotations.Contract;
Expand Down Expand Up @@ -288,4 +289,37 @@ public static Command registerCommand(@NotNull NamespacedKey key, @NotNull MComm
return ImpactRegistry.register(ImpactRegistries.COMMAND, key, command);
}

public static ArrayList<ItemStack> Items(ItemStack... items) {
return Arrays.stream(items).collect(Collectors.toCollection(ArrayList::new));
}

@Contract("_, _ -> new")
public static @NotNull ItemStack Item(Material material, int amount) {
return new ItemStack(material, amount);
}

@Contract("_ -> new")
public static @NotNull ItemStack Item(Material material) {
return new ItemStack(material, 1);
}

@Contract("_ -> new")
public static @NotNull ItemStack Stack(Material material) {
return new ItemStack(material, material.getMaxStackSize());
}

@Contract("_ -> new")
public static @NotNull ItemStack Item(String material_name) {
final Material material = Material.getMaterial(material_name);
if (material == null) throw new RuntimeException("Material of name '" + material_name + "' is unknown!");
return new ItemStack(material, 1);
}

@Contract("_ -> new")
public static @NotNull ItemStack Stack(String material_name) {
final Material material = Material.getMaterial(material_name);
if (material == null) throw new RuntimeException("Material of name '" + material_name + "' is unknown!");
return new ItemStack(material, material.getMaxStackSize());
}

}

0 comments on commit c31baac

Please sign in to comment.