Skip to content

Repository files navigation

Craftions API

The Craftions API is an Application Programming Interface which helps you to create awesome minecraft plugins!

Features

  • Minigame Api
    • Teams
    • Countdown (start and stop)
    • Multi Language (de_de/en_us)
    • Minimal players
    • Default Inventories
    • Game start and stop event
  • Easier Interface for communicating with the Bukkit FileConfigurationAPI
  • Convert &-colorcodes to §-colorcodes and backwards
  • MySQL Connections
  • RSA Encryption
  • Download Files
  • Send Players to other BungeeCord Servers
  • Player heads with custom textures

Usage/Examples

Mini Games

packagenet.craftions.apitest;
importnet.craftions.api.game.util.GameBuilder;
importnet.craftions.api.game.util.TeamBuilder;
importnet.craftions.api.game.Game;
importnet.craftions.api.language.Language;
importnet.craftions.api.game.events.GameEndEvent;
importnet.craftions.api.game.events.GameStartEvent;
importorg.bukkit.plugin.java.JavaPlugin;
importorg.bukkit.Location;
importorg.bukkit.Bukkit;
importorg.bukkit.event.inventory.InventoryType;
importorg.bukkit.event.Listener;
publicclassMyMiniGameextendsJavaPluginimplementsListener {
@OverridepublicvoidonEnable(){
// create the gameGamegame = newGameBuilder()
.setName("MyGame")
.setMinPlayers(2)
.setUseTeams(true)
.setUseTeamSpawns(true)
.setStartTime(30)
.setEndTime(40)
.setLanguage(Language.Code.GERMAN)
.setColorCode("§c")
.setSpawn(null)
.setWaitingLobby(newLocation(Bukkit.getWorld("world"), 0, 100, 0))
.setTeamSize(1)
.addTeam(newTeamBuilder()
.setName("Blau")
.setSpawn(newLocation(Bukkit.getWorld("world"), 0, 100, 100))
.setColor("§9")
.build()
)
.addTeam(newTeamBuilder()
.setName("Rot")
.setSpawn(newLocation(Bukkit.getWorld("world"), 100, 100, 0))
.setColor("§c")
.build()
)
.setDefaultInventory(Bukkit.createInventory(null, InventoryType.PLAYER))
.build();
// register the listenersBukkit.getPluginManager().registerEvents(this, this);
}
@EventHandlerpublicvoidonGameStart(GameStartEventevent){
System.out.println("The game has started!");
}
@EventHandlerpublicvoidonGameEnd(GameEndEventevent){
System.out.println("The game has end!");
}
}

File Configuration

packagenet.craftions.apitest;
importnet.craftions.api.config.Config;
importjava.io.File;
publicclassMyClass {
publicstaticvoidmyMethod() {
Fileconf = newFile("plugins/myplugin/config.yml");
try {
if(!conf.exists()){
if(!conf.getParentFile().isDirectory()){
conf.mkdirs();
}
conf.createNewFile();
}
}catch(Exceptionex){
ex.printStackTrace();
}
Configconfig = newConfig(conf, "myConfigName");
// get the configConfigconfig2 = Config.getInstance("myConfigName");
// set a valueconfig.set("path", null); // "path", Object// get a valueconfig.get("path");
// save the config (true reloads the config)config.reload(true);
}
}

Convert Color Codes

packagenet.craftions.apitest;
importnet.craftions.api.color.ColorCode;
publicclassMyColorCodeClass {
publicstaticvoidconvert(){
Stringmsg = "";
// convert & to §msg = ColorCode.to("&cHallo Welt");
// convert § to &msg = ColorCode.from(msg);
}
}

MySQL Connections

Please visit MCTzOCK/JavaMySQL

RSA Encryption

Please visit MCTzOCK/RSAKeys

Download a File

packagenet.craftions.apitest;
importnet.craftions.api.networking.NetUtils;
importjava.io.File;
publicclassMyDownloadClass {
publicstaticvoiddownloadDefaults(){
NetUtils.download("https://craftions.net/index.html", newFile("craftions.html"));
}
}

Send Players to other BungeeCord Servers

packagenet.craftions.apitest;
importnet.craftions.api.bungeecord.BungeeCordConnector;
importorg.bukkit.entity.Player;
importorg.bukkit.Bukkit;
publicclassMyConnectorClass(){
publicstaticvoidsendToLobby() {
BungeeCordConnector.connect(Bukkit.getPlayer("MCTzOCK"), "lobby");
}
}

Player heads with custom textures

packagenet.craftions.apitest;
importnet.craftions.api.util.PlayerHeads;
importorg.bukkit.inventory.ItemStack;
publicclassMyHeadClass {
publicstaticvoidexample(){
ItemStackhead = PlayerHeads.getHead("http://textures.minecraft.net/texture/4ea0c6e1b754e83f0e6e42900343a2dfe41dff342d8b062af532611b9ef6c99b");
}
}

Installation (Developers)

Install the Craftions API with maven

 <dependency>
<groupId>net.craftions</groupId>
<artifactId>api</artifactId>
<version>1.2-SNAPSHOT</version>
</dependency>

Installation (Server Admins)

  • Download the latest jar file from the release-tab
  • Drag and drop it into your plugins folder
  • Restart your server

Roadmap

  • ScoreBoard Manager
  • Vanilla Hex Codes
  • Everything you want! Create an issue or reach me on discord: MCTzOCK#0047

Authors

Documentation

License

GPL-3.0-ONLY

About

A simple API for creating spigot plugins!

Topics

Resources

Code of conduct

Contributing

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages