Horse Api
Overview
This plugin was created out of the lack of an official horse api. I was frustrated that it was next to impossible to make horses protected on my server so I made this plugin.
How to install
1. Download the latest version
2. Place in your server's /plugins folder
3. Reload or restart
Legal Stuff
You can use this api in whatever plugin you want as long as the following conditions are met.
"My code" refers to the code created by me (john01dav) and hosted on dev.bukkit.org labed as part of the project "horse-api"
"The Pluign" and "Your Plugin" Refer to any code you create refrencing my code
1. Your plugin must be posted on bukkitdev or be a custom private plugin used only on servers you or someone you are making the plugin for operate
2. Your plugin must not be posted on any site other then dev.bukkit.org, curse.com or any servers running the jenkins ci server
3. This page must be linked to in the bukkitdev description of your plugin
How to use this api in your own plugin
This plugin simply adds one event the HorseMountedEvent. Use the new event just like you would any other normal bukkit event.Example code making horses protected in GriefPrevention claims is shown below.
package src.john01dav.horseprotect; import src.john01dav.horseapi.HorseMountedEvent; import me.ryanhamshire.GriefPrevention.*; import org.bukkit.ChatColor; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.plugin.java.JavaPlugin; public class HorseProtect extends JavaPlugin implements Listener{ public void onEnable(){ getServer().getPluginManager().registerEvents(this, this); getLogger().info("HorseProtect Has Been Enabled!"); } public void onDisable(){ getLogger().info("HorseProtect Has Been Disabled."); } @EventHandler public void HorseMountedEvent(HorseMountedEvent e){ if(!e.getPlayer().isOp()){ Claim claim = GriefPrevention.instance.dataStore.getClaimAt(e.getHorse().getLocation(), false, null); if(claim != null){ if(claim.allowBuild(e.getPlayer()) != null){ e.getPlayer().sendMessage(ChatColor.RED + "You do not have " + claim.getOwnerName() + "'s permissions to ride that horse!"); e.setCancelled(true); } } } } }
Comments