Hi! I have been searching all the morning for a plugin that avoids Teaming in PvP servers (like Hunger Games or Survival) because I hate when you play alone or with one friend, and you find 5 people together coming to kill you. So I suggest a plugin which damages, sets on fire/poison, etc when detects a lot of people together in a long period of time. Plugin category: General, Fixes or Admin Tools Suggested name: Anti-Teams What I want: I'd like a plugin which detects when the same group of players (4+) stays together (like in less than 30 blocks of distance) for a period of time (2-4 minutes for a Hunger Games version, and 15-20 minutes for a survival server). Then sets them on fire or poison, insta damage, and asks them to sepair if they dont want to die! Why this? Because a lot of people make big teams in servers, which are unfair for some players who play alone, or with his friend. I don't understand why It doesn't exist a plugin like this, because a LOT of people would want to use this plugin. Ideas for commands: /at or /at help : for commands /at set time [seconds] : sets the maximum time a team can stay together /at set distance [blocks] : sets the distance players can't stay together in big groups /at set people [number] : sets the maximum number of people can be on a team, if they don't want to be cursed /at set punishment... (Here you can do a lot of things, set the warning, the punishment of teaming, when does the punishment happen...) /at enable : Enables the plugin /at disable : Disables the plugin /at punish [playername] [playername]... : Punishes manually the selected players (can be 1 or more) Ideas for permissions: When I'd like it by: I just want someone to create a plugin like this, but take as time as you need Me and a lot of people will thank it a lot. PS: English is not my first language
Yes this is going to use a lot of ram, because I need to check every time a player moves if there's X amount of players within their radius. And I need to do this for every player. That's a lot of event firing I'm gonna try to find a better way to do it that requires less memory.
Yea.. it would be CPU usage not ram... And you don't need to do it on every move event, that would be stupid to do in the first place. Just do a task that checks every few seconds, rather than hundreds of times a second.
To add on to the actual concept, all you have to do is walk away and back again every few minutes and you're fine. You'd have to create a "score" that slowly decreases when they're separated so that you can't just run out and back.
I actually just realized this myself. I put it into a runnable instead of when the player moves. Silly me, this would be CPU. Duh moment That was the plan. I was going to add a configurable amount of time that the player needs to be away from the team before he's considered "alone" again. Do you think this would be the most efficient way of going about this? Code:java getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { @Override public void run() { for(Player p : getServer().getWorld("world").getPlayers()) { for(Entity e : p.getNearbyEntities(50.0, 50.0, 50.0)) // 50 will be replaced by config amount.. just for testing purposes { if(e instanceof Player) { Player playerNear = (Player) e; if(playerNear.getLocation().distanceSquared(p.getLocation()) < 50) { playersTooClose.add(playerNear); playersTooClose.add(p); } } else continue; } } } }, 0, 20L); playersTooClose is just an ArrayList that I will check every second or so, and see if it contains players and punish them accordingly. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Appljuze What is "else continue;" Running else will continue anyway - if you want to exit just return.
Good point. No I don't want to exit but you're correct, if it doesn't enter that if statement it will just continue through the loop anyway. Thanks.
I actually didn't think about it - however as far I know java it isn't correct or "good convention" to use "else continue" where "else" does exactly the same thing.
There's probably a situation in which it would do something, but there would probably be a better way to do it... Code:java for(Player p : Bukkit.getServer().getOnlinePlayers()){ if(p.isSprinting()) p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1, 1); else continue; p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1, 1); } Now obviously there's a better, more readable way to write that, but there's probably some way that something like this would make more sense...I just can't think of one right now.
Garris0n But this Code:java for(Player p : Bukkit.getServer().getOnlinePlayers()){ if(p.isSprinting())p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1, 1);else{ p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1, 1); } } Would do the exact same thing - right? EDIT: curly braces are missing for the if statement too..
Yes, but the actual best way to do it(for readability and general good practice) would be Code:java for(Player p : Bukkit.getServer().getOnlinePlayers()){ if(!p.isSprinting()){ p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1, 1); continue; } p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1, 1); //this being the first //one, I didn't mean for them to be the same initially } But yes, the first thing I posted was redundant, I just meant something similar to that probably makes sense in some situation, I just haven't thought of it.