Its really easy. You need to add the CraftBukkit jar to your project. Then, get the relevant player variable from an event or wherever: Code: CraftPlayer cp = (CraftPlayer) player; cp.getHandle().addEffect(new MobEffect(id, ticks, strength); It takes 3 ints: id - The id of the effect. ticks - The length of time (in ticks) that the effect lasts for strength - The strength of the effect So for example, to add the portal effect (confusion, also called nausea) you would do: Code: cp.getHandle().addEffect(new MobEffect(9, 200, 2); Which would add the portal effect for 200 ticks, at strength level 2. You can find the effect id's and more information here: http://www.minecraftwiki.net/wiki/Potion_effects Hope this helps!
Holy crap, I had no idea you could do this! I might make a plugin like this too just so you can set these effects to commands. Would be nice to be able to give a player nightvision just by doing /nightvision etc.
wow dude thats AWESOME but how did u figure it out? all the bukkit docs are just for the bukkit api... @DirtyStarfish ZOMG thats puuuuuurfect!!!! i already have the drunk walking code done so this is pretty much alls i need for the rest. the config stuff isnt that hard EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Yeah, it wouldn't be too hard, although as far as I can tell, nightvision hasn't been implemented, it didn't do anything when I tried it anyway! edit: Don't think the invisiblity effect works either. I used to use mob effects in my old drug plugin, but only a few worked and you had to write the add/remove effect methods yourself. I think since the addition of potions the method I just posted was added. You can do some cool stuff if you use the craftbukkit jar in your project, like that old torch plugin that gives of light from the player when you hold certain items.
Ooooooo these effects r fun o cool, it would just be cool if there was a nice docs site set up somewhere. i LOVE the portal effects it goes great with the drunk walking EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Maybe I should write a thread in the resources section.. The portal effect has changed though. It used to be much better imo. It didn't have the purple spiral, its still pretty good though! Glad that your making progess! Im stuck on mine!
If you mind my asking, for the player staggering around like they're drunk, did you just do a slight change of velocity? I'm interested in this. :3
I think that would open up so many more possibilities with plugins too. Devs could be more free with adding cool things like effects. I sure would use it a lot.
You'll want these then. Code: public void setMobEffect(LivingEntity entity, int type, int duration, int amplifier) { ((CraftLivingEntity)entity).getHandle().addEffect(new MobEffect(type, duration * 20, amplifier)); } public void removeMobEffect(LivingEntity entity, int type) { try { if ((entity instanceof Player)) { EntityPlayer player = ((CraftPlayer)entity).getHandle(); player.netServerHandler.sendPacket(new Packet42RemoveMobEffect(player.id, new MobEffect(type, 0, 0))); } Field field = EntityLiving.class.getDeclaredField("effects"); field.setAccessible(true); @SuppressWarnings("rawtypes") HashMap effects = (HashMap)field.get(((CraftLivingEntity)entity).getHandle()); effects.remove(Integer.valueOf(type)); } catch (Exception e) { } } } Questions?
yup this plugin is 0% SPOUT DEPENDENT!!! and might i say i was able to add a few more things heres some new features but i wanna get back to coding it so ill make it brief: * screen flipping * jumping very high * weird screen spinning look * walking fast/slow with weird screen * near blindness * super strength/weekness and more and more and more and its all 100% configible! @ccrock4t, @anyone_who_cares Ok it cant handle multiple effects per-drug yet, i dont have the bukkitDev page up yet, and there may be a few bugs here and there but its worthy of alpha testing To take a "drug" rite click the air with the item in the config Download it here. (dont worry, it my private domain, theres no viruses ) To use: Just place it in your plugin folder and run the server once. after that a folder called DrugMeUp will be generated. Inside you need to open up the config.yml. The initial config.yml looks like this: Code: DrugIds: '353': Effect: 9 '351': Effect: 9 '40': Effect: 9 the DrugId's are simply the data values for the drugs you want to use. you can find a complete list here. You can add however many/few drugs as you want. I just put those three in to give you a starting point. What is a bit more interesting and complicated is the Effect. Here are the current avaliable effects (as this is still alpha you can only assign one per drug): These first 3 are hard to explain, u kinda need to try them 4 urself Effect 1: Makes the world spin and makes you walk funny (needs to be fine tuned) Effect 2: Zooms everything in and makes you walk slow Effect 3: Zooms everything out and makes you walk faster Effect 4: SupaStrength! Makes you deal more damage and break blocks faster! Effect 5: Restricts view area "blinding" you Effect 6: makes you SUPER hungry! Effect 7: Makes you sick, slows down mining speed, and weaker to any damage you take Effect 8: Gives you the ability to jump super high! Effect 9: Will randomly choose an effect each time the drug is used Because all of these are based on random numbers each time you do a "drug", even if its the same, the effect will be slightly different. Because I dont encourage drug use there are a few side effects: * While drunk your speech is MESSED up you kinda have to see it to really get it * When you take a drug there is a chance that you will either instantly OD and explode, burst into flames, or puke out your entire inventory * Again because of the randomness each time you take a drug there is no set time it will take to wear off NOTES/BUGS: When you "take" the "drug" it will take one of the items from ur inventory While drunk doing /me <message> is not scrambled In the future I plan to allow multiple drug effects per drug but as of rite now you cant You can take near infinite amounts drugs if you just hold down the key To take a "drug" rite click the air with the item in the config THIS IS ALPHA SO THERE WILL BE BUGS!!! IF YOU FIND SOME LEMME KNOW! ILL GET A BUKKITDEV PAGE UP TOMORROW! EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Make it so you have to shift right click to eat it, or it has a questioner and asks if you want to eat it when you right click it
@XepherLink sure i like the shift idea...gimmie a few min @XepherLink ok sneeking (holding shift) is now required. get it here EDIT by Moderator: merged posts, please use the edit button instead of double posting.
lolz ill change it to instant death gimmie a sec, BTW can i has ur server ip im boooored @XepherLink ok OD's are now just instant death w/ no boom same ol' link EDIT by Moderator: merged posts, please use the edit button instead of double posting.