Ajout d'une protection contre les spawn massif d'entités en créatif
This commit is contained in:
parent
e2b897908c
commit
6819ff2ee7
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<jardesc>
|
<jardesc>
|
||||||
<jar path="PandacraftUtils/jar_export/PandacraftUtils-3.3.jar"/>
|
<jar path="PandacraftUtils/jar_export/PandacraftUtils-3.4.jar"/>
|
||||||
<options buildIfNeeded="true" compress="true" descriptionLocation="/PandacraftUtils/make_jar.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
|
<options buildIfNeeded="true" compress="true" descriptionLocation="/PandacraftUtils/make_jar.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
|
||||||
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
|
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
|
||||||
<selectedProjects/>
|
<selectedProjects/>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: PandacraftUtils
|
name: PandacraftUtils
|
||||||
main: net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils
|
main: net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils
|
||||||
version: 3.3
|
version: 3.4
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,6 +99,13 @@ public class ConfigManager {
|
|||||||
// TODO gérer les codes de coloration;
|
// TODO gérer les codes de coloration;
|
||||||
ServerMOTD = "§7Serveur §fPandacraft§7, §eVenez nous rejoindre :D\n§bCreatif§7, §6Survie§7 et §4Faction/PVP§7 !";
|
ServerMOTD = "§7Serveur §fPandacraft§7, §eVenez nous rejoindre :D\n§bCreatif§7, §6Survie§7 et §4Faction/PVP§7 !";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
EntitySpam_worlds = "creative"; // séparé avec des point-virgules
|
||||||
|
EntitySpam_limitPerChunks = 50;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
initChatAnalysisBadWord();
|
initChatAnalysisBadWord();
|
||||||
initCommandAlias();
|
initCommandAlias();
|
||||||
initAutomessages();
|
initAutomessages();
|
||||||
@ -130,6 +137,14 @@ public class ConfigManager {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Entity Spam
|
||||||
|
*/
|
||||||
|
public String EntitySpam_worlds;
|
||||||
|
public int EntitySpam_limitPerChunks;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import net.mc_pandacraft.java.plugin.pandacraftutils.modules.SurvivalCuboManager
|
|||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.TPSAnalysisManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.TPSAnalysisManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.WESelectionDisplayManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.WESelectionDisplayManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.cheat_protect.CreativCheatManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.cheat_protect.CreativCheatManager;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.cheat_protect.EntitySpamManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.cheat_protect.NoPvpProtectManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.cheat_protect.NoPvpProtectManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
|
||||||
|
|
||||||
@ -44,6 +45,7 @@ public class PandacraftUtils extends JavaPlugin {
|
|||||||
public StaffQueueManager staffQueueManager;
|
public StaffQueueManager staffQueueManager;
|
||||||
public TPSAnalysisManager tpsAnalysisManager;
|
public TPSAnalysisManager tpsAnalysisManager;
|
||||||
public AutoMessagesManager autoMessagesManager;
|
public AutoMessagesManager autoMessagesManager;
|
||||||
|
public EntitySpamManager entitySpamManager;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -84,7 +86,7 @@ public class PandacraftUtils extends JavaPlugin {
|
|||||||
staffQueueManager = new StaffQueueManager();
|
staffQueueManager = new StaffQueueManager();
|
||||||
tpsAnalysisManager = new TPSAnalysisManager();
|
tpsAnalysisManager = new TPSAnalysisManager();
|
||||||
autoMessagesManager = new AutoMessagesManager();
|
autoMessagesManager = new AutoMessagesManager();
|
||||||
|
entitySpamManager = new EntitySpamManager();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -113,6 +115,7 @@ public class PandacraftUtils extends JavaPlugin {
|
|||||||
staffQueueManager = null;
|
staffQueueManager = null;
|
||||||
tpsAnalysisManager = null;
|
tpsAnalysisManager = null;
|
||||||
autoMessagesManager = null;
|
autoMessagesManager = null;
|
||||||
|
entitySpamManager = null;
|
||||||
|
|
||||||
|
|
||||||
ConfigManager.reloadConfig();
|
ConfigManager.reloadConfig();
|
||||||
|
@ -0,0 +1,97 @@
|
|||||||
|
package net.mc_pandacraft.java.plugin.pandacraftutils.modules.cheat_protect;
|
||||||
|
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.ThrownExpBottle;
|
||||||
|
import org.bukkit.entity.Vehicle;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.ExpBottleEvent;
|
||||||
|
import org.bukkit.event.vehicle.VehicleCreateEvent;
|
||||||
|
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
||||||
|
|
||||||
|
public class EntitySpamManager implements Listener {
|
||||||
|
|
||||||
|
private PandacraftUtils plugin = PandacraftUtils.getInstance();
|
||||||
|
|
||||||
|
public EntitySpamManager() {
|
||||||
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Non pris en charge pour le moment
|
||||||
|
@EventHandler
|
||||||
|
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prends en charge l'évènement de création d'un véhicule, et programme sa destruction
|
||||||
|
* si le chunk dans lequel il se trouve dépasse le nombre d'entité autorisé
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
@EventHandler
|
||||||
|
public void onVehicleCreate(VehicleCreateEvent event) {
|
||||||
|
Vehicle v = event.getVehicle();
|
||||||
|
Location l = v.getLocation();
|
||||||
|
if (!isInWorld(l)) return;
|
||||||
|
if (containsTooManyEntity(l.getChunk()))
|
||||||
|
{
|
||||||
|
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
|
||||||
|
private Vehicle vehicle;
|
||||||
|
public Runnable init(Vehicle v) {
|
||||||
|
vehicle = v;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
vehicle.remove();
|
||||||
|
}
|
||||||
|
}.init(v), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onExpBottle(ExpBottleEvent event) {
|
||||||
|
ThrownExpBottle b = event.getEntity();
|
||||||
|
if (!isInWorld(b.getLocation())) return;
|
||||||
|
if (containsTooManyEntity(b.getLocation().getChunk())) {
|
||||||
|
event.setExperience(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private boolean isInWorld(Location l) {
|
||||||
|
World w = l.getWorld();
|
||||||
|
String config = ConfigManager.getInstance().EntitySpam_worlds;
|
||||||
|
String[] worlds = config.split(";");
|
||||||
|
for (String ws : worlds)
|
||||||
|
if (w.getName().equalsIgnoreCase(ws))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean containsTooManyEntity(Chunk c) {
|
||||||
|
if (!c.isLoaded()) c.load();
|
||||||
|
Entity[] ents = c.getEntities();
|
||||||
|
return (ents.length > ConfigManager.getInstance().EntitySpam_limitPerChunks);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user