KeyCard
Purpose:
KeyCard is a card scanning API. You create an unpaired keycard and an unpaired scanner, pair them, and then you can scan the keycard at that scanner and interact with it through other add-on plugins.Requirements:
- Java 8
- RecipesRedone
- KeyCardRedstone - Scanning sends out a redstone pulse.
- KeyCardChests - Scanning opens a locked chest.
Unpaired Scanner:
User Tutorial
Step 1: Place down your scanner. Each add-on might utilize their own scanner so if you want an add-on's scanner, make sure you craft that instead of the default.
Step 2: Holding your unpaired key card, right click the scanner to pair them.
Step 3: You will now be left with an unnamed key card. Type '/kc name <name>' to name it. Note: The name is to be without spaces.
Step 4: Now they are linked! Right click to scan and utilize the add-ons!
Duplication: To duplicate key cards for friends/players, hold the card to be duped in your hand and also have unpaired key cards in your inventory. /kc duplicate will use up an unpaired key card to form a copy of the card in your hand.
API Tutorial
If you want to make a plugin that uses this API, you must be sure to edit your plugin.yml before doing anything else. In your plugin.yml, make sure to add 'depend: [KeyCard]' and KeyCard.jar to your build path.
Creating a custom scanner : To create a custom scanner, first you must create the ItemStack that you want the scanner to be. As in the user tutorial shows a stone button, you can replace that with whatever you want. If you want to make a plugin that uses this API, you must be sure to edit your plugin.yml before doing anything else. In your plugin.yml, make sure to add 'depend: [KeyCard]' and KeyCard.jar to your build path.
Code (Text):
APIUtils.registerScannerItem(scannerItemStack);
//Registers an ItemStack as a pairable scanner
//Registers an ItemStack as a pairable scanner
Code (Text):
@EventHandler
public void onScannerPair(ScannerPairEvent e)
{
if (e.getScannerItem().isSimilar(scannerItemStack))
{
//Do stuff such as save scanner location to a file
}
}
public void onScannerPair(ScannerPairEvent e)
{
if (e.getScannerItem().isSimilar(scannerItemStack))
{
//Do stuff such as save scanner location to a file
}
}
Code (Text):
@EventHandler
public void onScan(KeyCardScanEvent e)
{
/*
* What happens here is I am scanning a file of saved scanner locations to see if one of my custom scanners is being scanned. If it is, then I collect the information and do what I want with it.
*/
List<String> locStrings = this.scannerFile.contains("data") ? this.scannerFile.getStringList("data") : new ArrayList();
if (locStrings.contains(StringUtils.toLocString(e.getFrame().getLocation())))
{
//StringUtils is a private library that I use
Location loc = e.getFrame().getLocation()
ItemFrame frame = e.getFrame();
BlockFace face = frame.getAttachedFace();
Block b = loc.add(face.getModX(), face.getModY(), face.getModZ()).getBlock();
//This should be enough information to do whatever you need to do
}
}
public void onScan(KeyCardScanEvent e)
{
/*
* What happens here is I am scanning a file of saved scanner locations to see if one of my custom scanners is being scanned. If it is, then I collect the information and do what I want with it.
*/
List<String> locStrings = this.scannerFile.contains("data") ? this.scannerFile.getStringList("data") : new ArrayList();
if (locStrings.contains(StringUtils.toLocString(e.getFrame().getLocation())))
{
//StringUtils is a private library that I use
Location loc = e.getFrame().getLocation()
ItemFrame frame = e.getFrame();
BlockFace face = frame.getAttachedFace();
Block b = loc.add(face.getModX(), face.getModY(), face.getModZ()).getBlock();
//This should be enough information to do whatever you need to do
}
}
Quick facts
- Edition: Minecraft Java
- File type: .jar
- Minecraft versions listed: 1.8, 1.9, 1.10
- How to install: Install the matching mod loader (Forge, Fabric or NeoForge) for your Minecraft version. → Download the .jar. → Put it in the .minecraft/mods folder and launch that loader profile.
- Where to get it: Opens on Spigot — not every file is mirrored on our own servers.
Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.
KeyCard API is a free Minecraft Java mod. Compatible with Minecraft 1.8, 1.9, 1.10, 1.11 and newer. Downloaded 5,214 times (via Spigot). Download it and open it directly in the game.