Skip to content

elgbar/BukkitUtil

Repository files navigation

BukkitUtil

Various utilities for easier programming in bukkit. Some might require protocol lib ( eks AdvancedChat). Everything is version independent and no NMS code has been used.

List of utilities

Major Utilities

Single Class Utilities

Sorted from most to the least useful (for an average plugin)

  • ConfigUtil Various utilities with bukkit YAML configuration.
  • ChatUtil - Easier chat usage, including newline and tab fixer.
  • FileUtils - Easily read and write files for a plugin.
  • AdvancedChat - Use System and Action Bar for minecraft versions that doesn't support them, 1.8.x being one. (requires ProtocolLib for lower than 1.9.2)
  • InventoryUtil - Get more control over Bukkit's inventories.
  • MCConstans - Convert millisecond to tick and visa versa, also contains some time constants.
  • OnJoinMessage - Let players get messages even if they're not on.
  • WorldUtil - Get the highest valid block from a location.
  • MultiPage - Create a help-ish menu but with any text.
  • InterfaceImplManager Add an API layer to implementation of interfaces.
  • EntityUtil Metadata utility for entities.

Interfaces

For more general java utilities see CommonUtilsJava

Install

If BukkitUtil fails to build because it cannot find org.bukkit:bukkit:1.14.4-R0.1-SNAPSHOT (or something similar) you need to locally build the spigot using its BuildTools you can either do this manually (remember to build the correct version) or run the script setup.sh found in the root folder.

maven

Add my repo to your pom.xml. https://raw.githubusercontent.com/rjenkinsjr/maven2/repo and http://maven.sk89q.com/repo/ might also be needed

Then add this as a dependency under the dependencies tag

<dependency>
    <groupId>no.kh498.util</groupId>
  <artifactId>BukkitUtil</artifactId>
  <version>4.4.5</version>
</dependency>

You might also need to shade (read copy) the used classes into your jar. Add the following into your pom.xml

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.2.1</version>
            <executions>
                <execution>
                    <id>shade</id>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <minimizeJar>true</minimizeJar> <!-- Only include packages that you are using. Note: Requires Java 1.5 or higher. -->
                <artifactSet>
                    <includes>
                        <include>no.kh498.util:BukkitUtil</include>
                    </includes>
                </artifactSet>
            </configuration>
        </plugin>
    </plugins>
</build>       

gradle

The following is a skeleton gradle.build file. NOTE the order of the methods is required as is below.

//setup shade (ie include the whole of this lib in your jar)
configurations {
  shade
  implementation.extendsFrom shade
}

repositories {
  mavenCentral()

  //your other repositories goes here

  //my repo
  maven { url "https://raw.githubusercontent.com/elgbar/maven2/repo" }
  //these might be required
  maven { url "https://raw.githubusercontent.com/rjenkinsjr/maven2/repo" } // needed by slf4bukkit (a logger)
  maven { url "http://maven.sk89q.com/repo/" } //needed by WorldGuard
}


dependencies {
  //your other decencies goes here

  //use implementation if you do not want to include it in your jar
  shade "no.kh498.util:BukkitUtil:4.4.5"
}

jar {
  configurations.shade.each { dep ->
    from(project.zipTree(dep)) {
      exclude 'META-INF', 'META-INF/**', 'plugin.yml' //delete unwanted/duplicate stuff
    }
  }
}