Skip to content

Commit

Permalink
Added several way to search&reduce lag step by step
Browse files Browse the repository at this point in the history
  • Loading branch information
Amrac committed Dec 13, 2012
1 parent c0c09d7 commit 0e685f8
Show file tree
Hide file tree
Showing 4 changed files with 403 additions and 2 deletions.
99 changes: 99 additions & 0 deletions bin/main/resources/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#################
## General ##
#################
#Whether or not to use the average for TPS. If set to false, the server will always return the value at the last poll.
#Default: true
useAverage: true
#How many polls to keep in LagMeter's memory.
#Default: 10
averageLength: 10
#How often LagMeter should poll the server.
#Default: 40
interval: 40
#Display chunks loaded on plugin (re)load?
#Default: true
LoadedChunksOnLoad: true
#Should LagMeter display all of the entities that exist at the time of plugin (re)load?
#Default: true
displayEntitiesOnLoad: true
#################
## Commands ##
#################
Commands:
Lag:
#Should the commands which show the TPS meter also display entities in each world?
#Default: false
displayEntities: false
#Should the commands which show the TPS meter also display loaded chunks in each world?
displayChunks: false
#################
## Logging ##
#################
log:
#How often the plugin should log information to its log file.
#Default: 150
interval: 150
#Should LagMeter log information to a file?
#Default: true
enable: true
#Should LagMeter use a folder called 'logs' and use 'Day-Month-Year-Lag.log' format for each day's logs?
#Default: false
useLogsFolder: false
#Should LagMeter log how many players are online as well?
#Default: true
logPlayersOnline: true
#Should LagMeter log how many entities are present on the server?
#Default: true
logEntities: true
#Should LagMeter only display total entities, and not those for each world?
#Default: true
logTotalEntitiesOnly: true
#Should LagMeter log how many chunks are currently loaded on the server?
#Default: true
logChunks: true
#Should LagMeter only display total chunks, and not those for each world?
#Default: true
logTotalChunksOnly: true
#Should the plugin have an empty line between each log tick to make the log file neater?
#Default: true
newBlockPerLog: true
#Should the plugin put each statistic (TPS, memory, players) on a separate line?
#Default: true
newLinePerStatistic: true
#################
# Notifications #
#################
Notifications:
Lag:
#Enables low TPS notifications.
#Default: true
Enabled: true
#If the server is at or below this value for memory free, it will notify OPs and anyone with the permission node lagmeter.notify.lag
#Default: 17
Threshold: 17
#How often LagMeter should check on the TPS, in minutes.
#Default: 5
CheckInterval: 5
#Specify a command to use when the plugin notices that the TPS is low. Must be usable from console.
#Default: /lag
ConsoleCommand: /lag
Memory:
#Enables/disables low memory free notifications.
#Default: true
Enabled: true
#If the server is at or below this value for memory free, it will notify OPs and anyone with the permission node lagmeter.notify.mem
#Default: 25
Threshold: 25
#How often LagMeter should check on the free memory, in minutes.
#Default: 10
CheckInterval: 10
#Specify a command to use when the plugin notices that the free memory is low. Must be usable from console.
#Default: /mem
ConsoleCommand: /mem
Mysql:
Enabled: false
Host:
DatabaseName:
User:
TableName:
Password:
3 changes: 3 additions & 0 deletions plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ commands:
lagmeter:
description: Shows the version. Sub-commands of help and reload have obvious functions.
usage: /<command>
lesslag:
description: Reglage du lag
usage: /<command>
permissions:
lagmeter.*:
description: Gives full access
Expand Down
108 changes: 106 additions & 2 deletions src/main/java/com/webkonsept/minecraft/lagmeter/LagMeter.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ public class LagMeter extends JavaPlugin {
protected String TableName;
protected String User;
protected String Password;
public boolean fluids;
public boolean eventBlockFire;
public boolean eventBlockBurn;
public boolean eventBlockPhysics;
public boolean eventLeavesDecay;
public boolean eventBlockForm;
public boolean eventBlockSpread;
public boolean eventEntityExplode;
public boolean eventExplosionPrime;
public boolean eventCreatureSpawn;
public boolean removeEntitiesOnChunkLoad;
public boolean removeEntitiesAnimal;
public boolean removeEntitiesNPC;
public boolean removeEntitiesOnPlayerJoin;


//Accessor
public static LagMeter p;
Expand All @@ -71,7 +86,11 @@ public void onEnable(){
vault = checkVault();
logger = new LagMeterLogger(this);
poller = new LagMeterPoller(this);


//Modif
getServer().getPluginManager().registerEvents(new LagMeterListeners(this), this);


if(!logsFolder.exists() && useLogsFolder && enableLogging){
info("Logs folder not found. Creating one for you.");
logsFolder.mkdir();
Expand Down Expand Up @@ -127,6 +146,7 @@ public void onEnable(){
}
info("Total entities: "+total);
}

}
@Override
public void onDisable(){
Expand Down Expand Up @@ -184,6 +204,9 @@ public float getTPS(){
return ticksPerSecond;
}
protected void handleBaseCommand(CommandSender sender, String[] args){

//sendMessage(sender, 1, "Command:"+args[0]+" arg1:" + args[1]);

if(args[0].equalsIgnoreCase("reload")){
if(permit(sender, "lagmeter.command.lagmeter.reload") || permit(sender, "lagmeter.reload")){
conf.loadConfig();
Expand Down Expand Up @@ -222,7 +245,88 @@ protected void handleBaseCommand(CommandSender sender, String[] args){
sendMessage(sender, 1, "You don't have permission for any of the commands (besides this one)!");
}else
sendMessage(sender, 1, "Sorry, but you don't have access to the help command.");
}else{
}if(args[0].equalsIgnoreCase("lessLag")){

if(args[1].equalsIgnoreCase("all")){
fluids=true;
eventBlockFire=true;
eventBlockBurn=true;
eventBlockPhysics=true;
eventLeavesDecay=true;
eventBlockForm=true;
eventBlockSpread=true;
eventEntityExplode=true;
eventExplosionPrime=true;
eventCreatureSpawn=true;
removeEntitiesOnChunkLoad=false;
removeEntitiesOnPlayerJoin=false;
removeEntitiesAnimal=false;
removeEntitiesNPC=false;
sendMessage(sender, 1, "Tout est actif");
}
else if(args[1].equalsIgnoreCase("off")){
fluids=false;
eventBlockFire=false;
eventBlockBurn=false;
eventBlockPhysics=false;
eventLeavesDecay=false;
eventBlockForm=false;
eventBlockSpread=false;
eventEntityExplode=false;
eventExplosionPrime=false;
eventCreatureSpawn=false;
removeEntitiesOnChunkLoad=false;
removeEntitiesOnPlayerJoin=false;
removeEntitiesAnimal=false;
removeEntitiesNPC=false;
sendMessage(sender, 1, "Tout est eteint");
}
else if(args[1].equalsIgnoreCase("fluids")){
fluids=true;
}
else if(args[1].equalsIgnoreCase("eventBlockFire")){
eventBlockFire=true;
}
else if(args[1].equalsIgnoreCase("eventBlockBurn")){
eventBlockBurn=true;
}
else if(args[1].equalsIgnoreCase("eventBlockPhysics")){
eventBlockPhysics=true;
}
else if(args[1].equalsIgnoreCase("eventLeavesDecay")){
eventLeavesDecay=true;
}
else if(args[1].equalsIgnoreCase("eventBlockForm")){
eventBlockForm=true;
}
else if(args[1].equalsIgnoreCase("eventBlockSpread")){
eventBlockSpread=true;
}
else if(args[1].equalsIgnoreCase("eventEntityExplode")){
eventEntityExplode=true;
}
else if(args[1].equalsIgnoreCase("eventExplosionPrime")){
eventExplosionPrime=true;
}
else if(args[1].equalsIgnoreCase("eventCreatureSpawn")){
eventCreatureSpawn=true;
}
else if(args[1].equalsIgnoreCase("removeEntitiesOnChunkLoad")){
removeEntitiesOnChunkLoad=true;
}
else if(args[1].equalsIgnoreCase("removeEntitiesOnPlayerJoin")){
removeEntitiesOnPlayerJoin=true;
}
else if(args[1].equalsIgnoreCase("removeEntitiesAnimal")){
removeEntitiesAnimal=true;
}
else if(args[1].equalsIgnoreCase("removeEntitiesNPC")){
removeEntitiesNPC=true;
}

}
else{

sendMessage(sender, 1, ChatColor.GOLD+"[LagMeter] "+ChatColor.RED+"Invalid sub-command. "+ChatColor.GOLD+"Try one of these:");
sendMessage(sender, 0, ChatColor.GOLD+"[LagMeter] Available sub-commands: /lagmeter|lm <reload|r>|/lagmeter|lm <help|?>");
}
Expand Down
Loading

0 comments on commit 0e685f8

Please sign in to comment.