HELP! Someone banned me with a kick potion D:

ArchivesProblems & bugs → HELP! Someone banned me with a kick potion D:

SOLVED

someone just randomly hit me with a kick potion and i cannot respawn D:
Ok NVm it wore off thank god
Do you know who threw it?
Those potions should be banned. Is there any way to remove potion effects off dead/offline players? Bukkit’s OfflinePlayer? I have no idea. I tried to code a plugin to ban those potions, but I just don’t know what event to use. Help? Or you could just add that to the redstoner-utils and code it in python.
@redstone_sheep @Dico200? Potion Plugin? (Post above)
Maybe make it so players aren’t effected by splash potions and only normal potions or /effect will work
Didn’t you already disallow some splash potions? Just don’t allow those specifically, or Ban all. My 2 cents :3

I am terribly sorry for the inconvenience. I’m currently in the process of writing a plugin which removes the potion from any inventory when being opened - this includes, but is not limited to chests, enderchests and player inventories.

The event which I’m using is Inventory.InventoryOpenEvent, but I can’t figure out how to set the itemstack correctly. Would you be able to help me out on this? if you know how to do that, that would be great. I’m not really that pro with python.

What do you mean to set the itemstack correctly? To get from Potion to ItemStack? I don’t have my IDE at the moment, but let me just google something. ;)

In java I’d use:

That is written from the top of my head, so I can’t assure it working…

public void onInventoryOpen (InventoryOpenEvent e) {
    Potion p = new Potion(PotionType type, int lvl); //PotionType.? - I think lvl = amplifier, so should be negative
    if (e.getInventory().contains(p.toItemStack()) {
        e.removeItem(p.toItemStack());
    }
}

Ah, what just came to my mind: InventoryOpenEvent won’t help. If someone /i’s a potion like this, it won’t be triggered and they won’t have to open their inventory to throw it at someone. I’ve tried some PotionSplashEvent, but that doesn’t work either, because it is triggered when the potion hits something.

And, as a fancy addon feature, you could add that staff will be notified if any of those potions are deleted out of an inventory or thrown.

You could even automatically kill the player hit.

@Dico200 Why when asecta is on holidays?

Hmm thats quite nice, but its e.remove(ItemStack item) I wasn’t quite sure how to make it happen. I can tell you whats returned by the potion if you look for it in your first hotbar slot: CraftItemStack: ItemStack{POTION x 1, POTION_META:{meta-type=POTION, display-name=CP, custom-effects=[HEALTH_BOOST:3000t-x-120]}}

I was personally going to use InventoryOpenEvent in the first place, but asecta told me to use ProjectileLaunchEvent, which works too. The part that doesnt work is getting to the eventhandler it seems… It just doesnt work.

@hook.event(“entity.ProjectileLaunchEvent”,“monitor”) Doesn’t work? Sorry, just on the Phone now, can’t get that to Code… Isn’t there a class called PotionMeta? I’d try and Code it myself in Java, but atm I don’t have access to my MacBook and I can only join the Server via minechat.
@Dico200 just remove all the potions from everyone’s inventory and then remove the permission from everyone because then that will stop it
Potion splash event, and heal /kill all the players around it. This kills them but gets rid of the effect
You can cancel the potionsplashevent, but I’m using ProjectileLaunchEvent, which includes ThrownPotion. I want to cancel the thrownpotion event, remove the potion from the players inventory and kick the player Using PotionSplashEvent, you can’t retrieve who threw the potion, which isn’t exactly nice.
How about you add a nice little counter to it so if they do it 3 times they get temp banned :D

What you’d have to do with projectile launch event would be: (I’m not 100% sure if this will work)

public void onEvent(ProjectileLaunchEvent event) {
    Projectile projectile = event.getEntity();
    try {
        Player player = (Player) projectile.getShooter();
        ThrownPotion potion = (ThrownPotion) projectile;
    } catch (Exception e) {
        return;
    }
    for (PotionEffect effect : potion.getEffects()) {
        if (effect.getAmplifier() > 4 || effect.getAmplifier() < 0)
            event.setCancelled(true);
    }
    if (event.isCancelled()) {
        Inventory inventory = player.getInventory();
        # Here you have to remove the item which I don't know how to do from the top of my head.
        player.kickPlayer("OP Potions are not tolerated on this server.");
    }
}
public void onEvent(ProjectileLaunchEvent event) 
    {
        Projectile projectile = event.getEntity();
        try 
        {
            Player player = (Player) projectile.getShooter();
            ThrownPotion potion = (ThrownPotion) projectile;
        } 
        
        catch (Exception e) 
        {
        return;
        }
    
    for (PotionEffect effect : potion.getEffects()) 
    {
        if (effect.getAmplifier() > 4 || effect.getAmplifier() < 0)
        {
            event.setCancelled(true);
        }
    }
    
    if (event.isCancelled()) 
    {
        Inventory inventory = player.getInventory();
        # Here you have to remove the item which I don't know how to do from the top of my head.
        player.kickPlayer("OP Potions are not tolerated on this server.");
    }
}

Sorry i really had to, othwise i can't read it and get it
If you parse ThrownPotion over to Potion, there is a method toItemStack() as far äs i know?

Sorry for any typos, mostly Typing of my phone atm.

I have tried to put that into python - but Python is not my strongest language. Don’t be mad :3

import org.bukkit as noreply+1100@redstoner.com("ProjectileLaunchEvent","monitor")
def onPotion(event):
	projectile = event.getEntity()
	try:
		player = projectile.getShooter()
		potion = #Parsing in python? No idea again sorry
	for effect in potion.getEffects():
		if effect.getAmplifier() > 4 or effect.getAmplifier() < 0:
			event.setCancelled(true)
	if event.isCancelled():
		inventory = player.getInventory()
		inventory.removeItem(potion.toItemStack()) #Like this?
		player.kickPlayer("OP Potions are not tolerated on this server.")
		#Notifying staff? Does staff have op? Otherwise with a perm.
		for p in bukkit.getServer().getOnlinePlayers():
			if p.isOp():
				p.sendMessage(player.getName() + "threw a potion.")

That staff notifying part can of course also be: (I don’t know how you handle these)

for p in bukkit.getServer().getOnlinePlayers():
			if p.hasPermission("some.permission"):
				p.sendMessage(player.getName() + "threw a potion.")
Okay, thought that only worked when posting. :3
Theres a small problem with this - after cancelling you shouldnt check if it was cancelled. I’m also thinking that we should just clear the inventory.

You’ve written that if cancelled initially, I just copied it ;)

And yes, would make removing it easier.