All Projects â†’ Maxlego08 â†’ Templateplugin

Maxlego08 / Templateplugin

Licence: gpl-3.0
A template for creating minecraft plugin from 1.7.10 to 1.16.2

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Templateplugin

Utils
🛠 Lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.
Stars: ✭ 1,158 (+2170.59%)
Mutual labels:  json, pagination
Pager Api
Easy API pagination for Rails
Stars: ✭ 86 (+68.63%)
Mutual labels:  json, pagination
Mymovies
A Flutter app which shows a list of popular movies.
Stars: ✭ 371 (+627.45%)
Mutual labels:  json, pagination
Zeison
Small, fast and easy-to-use JSON library for Scala.
Stars: ✭ 45 (-11.76%)
Mutual labels:  json
Node.pas
Asynchronous Event-driven server programming for EMB Delphi, powered by libuv.
Stars: ✭ 45 (-11.76%)
Mutual labels:  json
Minijson
A lightweight json library (C++)
Stars: ✭ 49 (-3.92%)
Mutual labels:  json
Upcloud Ansible
Dynamic inventory and modules for managing servers via UpCloud's API
Stars: ✭ 50 (-1.96%)
Mutual labels:  inventory
Microblob
Serve millions of JSON documents via HTTP.
Stars: ✭ 45 (-11.76%)
Mutual labels:  json
Flask Restx
Fork of Flask-RESTPlus: Fully featured framework for fast, easy and documented API development with Flask
Stars: ✭ 1,050 (+1958.82%)
Mutual labels:  json
Sesame
Android architecture components made right
Stars: ✭ 48 (-5.88%)
Mutual labels:  pagination
Ansible Config encoder filters
Ansible role used to deliver the Config Encoder Filters.
Stars: ✭ 48 (-5.88%)
Mutual labels:  json
Webpub Manifest
📜 A JSON based Web Publication Manifest format used at the core of the Readium project
Stars: ✭ 46 (-9.8%)
Mutual labels:  json
Generator Http Fake Backend
Yeoman generator for building a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 49 (-3.92%)
Mutual labels:  json
Jj
JSON Stream Editor (command line utility)
Stars: ✭ 1,033 (+1925.49%)
Mutual labels:  json
Kaminari
âš¡ A Scope & Engine based, clean, powerful, customizable and sophisticated paginator for Ruby webapps
Stars: ✭ 8,085 (+15752.94%)
Mutual labels:  pagination
Fiscalberry
[JSON ↔ HW] Connect things using JSON API with the fiscalberry websocket server interact easily with any kind of Hardware. Another IoT solution...
Stars: ✭ 44 (-13.73%)
Mutual labels:  json
Jsonapi parameters
Rails-way to consume JSON:API input
Stars: ✭ 50 (-1.96%)
Mutual labels:  json
Shon
A simple tool to convert json or yaml into a shell-compliant data structure.
Stars: ✭ 47 (-7.84%)
Mutual labels:  json
Cursor Pagination
Cursor pagination for your Laravel API
Stars: ✭ 47 (-7.84%)
Mutual labels:  pagination
Resticprofile
Configuration profiles for restic backup
Stars: ✭ 48 (-5.88%)
Mutual labels:  json

Template Plugin

Here is a simple project for the quick creation of minecraft plugin. Works from version 1.7.10 to version 1.15.2

Features

  • Commands
  • TabCompleter
  • Inventories
  • Json file
  • Useful function (in the class ZUtils)
  • ItemBuilder
  • CooldownBuilder
  • TimerBuilder
  • Pagination
  • Inventory button
  • Custom Event
  • YML Loader (itemstack and button)
  • Scoreboard (https://github.com/MrMicky-FR/FastBoard)

Command example:

Add a command
You will create a command with the addCommand (command, class extant VCommand), this will save your command and add its executor in the class CommandManager
To add a command with an argument you must pass in setting the parent class

addCommand("test", new CommandTest());
register("test", new CommandTest());

You can directly add command from the main class:

this.registerCommand("command", new CommandTest(), "myaliaisase");
  • CommandTest
public class CommandTest extends VCommand {

	public CommandTest() {
		this.addSubCommand(new CommanndTestSub());
	}
	
	@Override
	public CommandType perform(Template main) {
		
		ModuleTest.getInstance().test(sender);
		
		return CommandType.SUCCESS;
	}
}
  • CommandTestSub
public class CommanndTestSub extends VCommand {

	public CommanndTestSub() {
		this.addSubCommand("sub");
		this.addRequireArg("location");
	}

	@Override
	public CommandType perform(Template main) {

		Location location = argAsLocation(0);
		player.teleport(location);
		
		return CommandType.SUCCESS;
	}

}
  • Add custom tab
public class CommandTest extends VCommand {

	public CommandTest() {
		this.addSubCommand(new CommanndTestSub());
		this.setTabCompletor();
	}
	
	@Override
	public CommandType perform(Template main) {
		
		ModuleTest.getInstance().test(sender);
		
		return CommandType.SUCCESS;
	}
	
	@Override
	public List<String> toTab(Template plugin, CommandSender sender, String[] args) {

		if (args.length == 3) {

			String startWith = args[2];

			List<String> entities = new ArrayList<String>();
			for (EntityType type : EntityType.values()) {
				if (type.isAlive() && !type.equals(EntityType.PLAYER)) {
					if (startWith.length() == 0 || type.name().toLowerCase().startsWith(startWith))
						entities.add(name(type.name()));
				}
			}

			return entities;

		}

		return null;
	}
}

Inventories

You can create inventories with the same principle as for commands.
So, you will create your class that will be extended from VInventory and then add it to the InventoryManager class with a unique ID

addInventory(Inventory.INVENTORY_TEST, new InventoryExample());
  • InventoryExample
    So you have the three most common vents for menu use that will be called by the class
public class InventoryExample extends VInventory {

	@Override
	public InventoryResult openInventory(Template main, Player player, int page, Object... args)
			throws InventoryOpenException {
		
		createInventory("myInventory", 54);
		
		ItemBuilder builder = new ItemBuilder(Material.DIAMOND);
		addItem(35, builder).setLeftClick(event -> {
			//When a player clicks left
		}).setRightClick(event -> {
			//When a player right clicks
		}).setMiddleClick(event -> {
			//When a player middle clicks
		}).setClick(event -> {
			//When the player clicks, whether it's left, right or middle
		});
		
		return InventoryResult.SUCCESS;
	}

	@Override
	protected void onClose(InventoryCloseEvent event, Template plugin, Player player) {

	}

	@Override
	protected void onDrag(InventoryDragEvent event, Template plugin, Player player) {

	}

}
  • InventoryPagination
    With this you will be able to create several pages based on a list, everything is managed automatically by the plugin. In this example, there will be several pages depending on an itemstack
public class InventoryExample extends PaginateInventory<ItemStack> {

	public InventoryExample() {
		super("My cystom name %p%/%mp%", InventorySize.FULL_INVENTORY);
	}

	@Override
	public ItemStack buildItem(ItemStack object) {
		return object;
	}

	@Override
	public void onClick(ItemStack object, ItemButton button) {
		message(player, "§eYou click on " + getItemName(object));
	}

	@Override
	public List<ItemStack> preOpenInventory() {
		//You must put your list here
		return Arrays.asList(new ItemStack(Material.DIAMOND), new ItemStack(Material.EMERALD));
	}

	@Override
	public void postOpenInventory() {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void onClose(InventoryCloseEvent event, Template plugin, Player player) {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void onDrag(InventoryDragEvent event, Template plugin, Player player) {
		// TODO Auto-generated method stub
		
	}
	
	//To avoid problems directly make your own clone of the class
	@Override
	protected InventoryExample clone() {
		return new InventoryExample();
	}

}

Here is an example of use in the zSpawner plugin. The inventory will create several pages based on a spawner list.

public class InventorySpawnerPaginate extends PaginateInventory<Spawner> {

	private PlayerSpawner playerSpawner;

	public InventorySpawnerPaginate() {
		super(Config.inventoryName, Config.inventorySize);
	}

	@Override
	public ItemStack buildItem(Spawner object) {
		return object.getItemStack();
	}

	@Override
	public void onClick(Spawner object, ItemButton button) {

		if (object.isPlace()) {

			object.delete(manager.getBoard());
			message(player, Message.REMOVE_SPAWNER);
			createInventory(player, Inventory.INVENTORY_SPAWNER_PAGINATE, getPage(), playerSpawner);

			return;
		}

		SpawnerPrePlaceEvent event = new SpawnerPrePlaceEvent(player, object, playerSpawner);
		event.callEvent();

		if (event.isCancelled())
			return;

		playerSpawner.setCurrentPlacingSpawner(object);
		player.closeInventory();
		message(player, Message.PLACE_SPAWNER_START);

	}

	@Override
	public List<Spawner> preOpenInventory() {
		//The list is retrieved according to an argument sent during the opening of the inventory
		playerSpawner = (PlayerSpawner) args[0];
		return playerSpawner.getShortSpawners();
	}

	@Override
	public void postOpenInventory() {

		if (Config.displayInformation) {
			Button button = Config.buttonInformation;
			int slot1 = button.getSlot() > inventorySize ? infoSlot : button.getSlot();
			addItem(slot1, button.toItemStack(playerSpawner)).setClick(event -> {
				playerSpawner.toggleShort();
				createInventory(player, Inventory.INVENTORY_SPAWNER_PAGINATE, getPage(), playerSpawner);
			});
		}
		
		if (Config.displayRemoveAllButton) {
			Button button = Config.buttonRemoveAll;
			int slot1 = button.getSlot() > inventorySize ? removeAllSlot : button.getSlot();
			addItem(slot1, button.toItemStack(playerSpawner)).setClick(event -> {
				playerSpawner.deleteAllSpawners(manager.getBoard());
				createInventory(player, Inventory.INVENTORY_SPAWNER_PAGINATE, getPage(), playerSpawner);
			});
		}

	}

	@Override
	protected void onClose(InventoryCloseEvent event, ZSpawnerPlugin plugin, Player player) {

	}

	@Override
	protected void onDrag(InventoryDragEvent event, ZSpawnerPlugin plugin, Player player) {

	}

	@Override
	protected InventorySpawnerPaginate clone() {
		return new InventorySpawnerPaginate();
	}

}

You can directly add inventory from the main class:

this.registerInventory(Inventory.INVENTORY_TEST, new InventoryExample());

Json Saver

You will be able to create class to save anything in json very simply

public class Config implements Saveable {

	public static String version = "0.0.0.1";
	
	@Override
	public void save(Persist persist) {
		persist.save(this, "config");
	}

	@Override
	public void load(Persist persist) {
		persist.loadOrSaveDefault(this, Config.class, "config");
	}
}

You must then add the class like this in the main class

addSave(new ConfigExample());

Pagination

You can easily make list or map pagination

  • Create a pagination
Pagination<T> pagination = new Pagination<T>();
  • Simple pagination
List<T> list = pagination.paginate(List<T> list, int size, int page)
List<T> list = pagination.paginate(Map<?, T> map, int size, int page)
  • Reverse pagination
List<T> list = pagination.paginateReverse(List<T> list, int size, int page)
List<T> list = pagination.paginateReverse(Map<?, T> map, int size, int page)

YML Loader

  • ItemStack You will be able to recover and save an itemstack according to a YamlConfiguration and a path
Loader<ItemStack> loader = new ItemStackYAMLoader();
ItemStack item = loader.load(configuration, path);
loader.save(item, configuration, path);

Scoreboard (https://github.com/MrMicky-FR/FastBoard)

You will be able to manage scoreboards very simply with the ScoreBoardManager class. It is initialized directly in the main class but you will have to make additions to make the scoreboard work

  • Update lines

You will be able to add a consumer which will update the lines according to a Player, you can also activate a task to manage the automatic update

scoreboardManager.setLines(player -> {
	List<String> lines = new ArrayList<>();
	
	lines.add(""); // Empty line
	lines.add("Hey " + player.getName());
	lines.add(""); // Empty line
	lines.add("Online: " + getServer().getOnlinePlayers().size());
	
	return lines;
});

To start the task you have two choices, either the scoreboardManager.schedule (); or the scoreboardManager.setLines (player -> {return lines};

  • Update title
scoreboardManager.updateTitle(player, title);
  • Update line

You will be able to modify just one line according to its index

scoreboardManager.updateLine(player, line, string);
  • Delete scoreboard
scoreboardManager.delete(player);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].