This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hintss |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//DISCLAIMER: NOT YET TESTED, THIS CODE MAY CONTAIN SYNTAX ERRORS | |
//this demonstrates lazy cooldowns, because using a list and a scheduler is an absolutely terrible idea | |
//BCBroz, why do you cause us so much pain...*sigh* | |
//in this example, the ability is to be able to break a block instantly with your fist once per minute | |
//as this is an example for tutorial purposes, a lot of code is dragged out into variables for clarity | |
//please do not copy-paste or use this code without reading the comments and fully understanding what is going on | |
private HashMap<UUID, Long> map = new HashMap<UUID, Long>(); //the map to hold our cooldown times |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void countdown(final Player player){ //A method | |
new BukkitRunnable(){ //BukkitRunnable, not Runnable | |
int countdown = 10; //Instance variable in our anonymous class to easily hold the countdown value | |
@Override | |
public void run(){ | |
if(countdown <= 0 || !player.isOnline()){ //countdown is over or player left the server, just two example reasons to exit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package de.bananaco.change; | |
import net.minecraft.server.v1_7_R1.*; | |
import org.bukkit.*; | |
import org.bukkit.command.*; | |
import org.bukkit.craftbukkit.entity.CraftPlayer; | |
import org.bukkit.entity.Player; | |
import org.bukkit.event.*; | |
import org.bukkit.event.player.PlayerJoinEvent; | |
import org.bukkit.plugin.java.JavaPlugin; | |
public class WorldChanger extends JavaPlugin implements Listener { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
((Map) getPrivateStatic(EntityTypes.class, "c")).put(paramString, paramClass); | |
//Registers the name to the mob, this appears to be for saving nbt tags. Theoretically, this will turn all mobs in your world into your mob, so maybe you shouldn't touch it. | |
((Map) getPrivateStatic(EntityTypes.class, "d")).put(paramClass, paramString); | |
//Registers the name you provided. This appears to be used by stuff and not do anything wrong, so you should probably leave this one. | |
((Map) getPrivateStatic(EntityTypes.class, "e")).put(Integer.valueOf(paramInt), paramClass); | |
//Registers mob id to this mob, which, I believe, will cause it to become the default mob class for the id provided. | |
((Map) getPrivateStatic(EntityTypes.class, "f")).put(paramClass, paramInt); | |
//Registers the mob to the mob id. This is essentially the reverse of e, and, I believe, assigns how the mob will display to clients. I'm pretty sure the client crashes without this one. | |
((Map) getPrivateStatic(EntityTypes.class, "g")).put(paramString, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Java: | |
[url=http://docs.oracle.com/javase/tutorial/]Official[/url] | [url=http://thenewboston.org/list.php?cat=31]Youtube[/url] | [url=http://www.pearsonhighered.com/product?ISBN=0132830310]Book[/url] | |
Bukkit: | |
[url=http://wiki.bukkit.org/Plugin_Tutorial]Official[/url] | [url=http://www.youtube.com/PogoStick29Dev]Youtube[/url] | [url=http://www.packtpub.com/building-minecraft-server-modifications/book]Book[/url] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/Bukkit/CraftBukkit/blob/7e1ac0a77129b169704c1e222ff2deb3ab6cd2d2/src/main/java/net/minecraft/server/EntityPlayer.java#L596 | |
//Method to open an anvil inventory to a player | |
public static void openAnvil(Player player, Inventory inventory){ | |
//Get our EntityPlayer | |
EntityPlayer p = ((CraftPlayer) player).getHandle(); | |
//Create the AnvilContainer | |
AnvilContainer container = new AnvilContainer(p); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//NO YAW/PITCH: | |
public static String locationToString(Location location){ //Method to turn a location into a string | |
return location.getWorld() + ";" + location.getX() + ";" + location.getY() + ";" + location.getZ(); //Return a string with the format world;x;y;z | |
} | |
public static Location stringToLocation(String string){ //turn a string into a location | |