Disable automatic timings reports

This commit is contained in:
cnr 2017-06-26 20:17:45 -07:00
parent dddeb69391
commit ed541b7a4f
6 changed files with 25 additions and 163 deletions

View File

@ -1,104 +0,0 @@
package mineplex.core;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import sun.net.www.protocol.http.HttpURLConnection;
import javax.net.ssl.HttpsURLConnection;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
@ReflectivelyCreateMiniPlugin
public class TimingsFix extends MiniPlugin
{
private static final Gson GSON = new Gson();
private TimingsFix()
{
super("Timings Fix");
URL.setURLStreamHandlerFactory(protocol ->
{
if (protocol.equals("http"))
{
return new sun.net.www.protocol.http.Handler()
{
@Override
protected URLConnection openConnection(URL u) throws IOException
{
if (u.getHost().contains("paste.ubuntu.com"))
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
return new HttpURLConnection(u, null, this)
{
@Override
public OutputStream getOutputStream()
{
return baos;
}
@Override
public InputStream getInputStream()
{
return bais;
}
@Override
public String getHeaderField(String name)
{
if (name.equals("Location"))
{
try
{
String request = new String(baos.toByteArray(), StandardCharsets.UTF_8);
request = request.substring("poster=Spigot&syntax=text&content=".length());
request = URLDecoder.decode(request, "UTF-8");
URL url = new URL("https://timings.spigotmc.org/paste");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setInstanceFollowRedirects(false);
connection.getOutputStream().write(request.getBytes(StandardCharsets.UTF_8));
connection.getOutputStream().close();
JsonObject object = GSON.fromJson(new InputStreamReader(connection.getInputStream()), JsonObject.class);
return "http://paste.ubuntu.com/" + object.get("key").getAsString() + "/";
}
catch (Throwable e)
{
e.printStackTrace();
return "http://paste.ubuntu.com/0/";
}
}
return null;
}
};
}
return super.openConnection(u);
}
@Override
protected URLConnection openConnection(URL u, Proxy p) throws IOException
{
return super.openConnection(u, p);
}
};
}
return null;
});
}
}

View File

@ -2,6 +2,15 @@ package mineplex.core.monitor;
import java.util.HashSet;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
@ -10,17 +19,6 @@ import mineplex.core.common.util.F;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import net.minecraft.server.v1_8_R3.MinecraftServer;
public class LagMeter extends MiniPlugin
{
private CoreClientManager _clientManager;
@ -31,12 +29,6 @@ public class LagMeter extends MiniPlugin
private long _lastAverage;
private long _start;
private long _lastTick = 0;
private boolean _timingsRunning;
private boolean _timingsPasted;
private long _timingsStarted;
private HashSet<Player> _monitoring = new HashSet<Player>();
public LagMeter(JavaPlugin plugin, CoreClientManager clientManager)
@ -98,24 +90,6 @@ public class LagMeter extends MiniPlugin
_lastRun = now;
_count++;
if (System.currentTimeMillis() - _start > 30000)
{
if (_timingsRunning)
{
if (System.currentTimeMillis() - _timingsStarted > 30000)
{
getPlugin().getServer().dispatchCommand(Bukkit.getConsoleSender(), "timings paste");
_timingsRunning = false;
}
}
else if (_ticksPerSecond < 10)
{
_timingsRunning = true;
_timingsStarted = System.currentTimeMillis();
getPlugin().getServer().dispatchCommand(Bukkit.getConsoleSender(), "timings on");
}
}
}
public double getTicksPerSecond()

View File

@ -1,10 +1,10 @@
package mineplex.game.clans;
import static mineplex.core.Managers.require;
import java.io.File;
import java.io.IOException;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
@ -14,7 +14,6 @@ import org.spigotmc.SpigotConfig;
import mineplex.core.CustomTagFix;
import mineplex.core.FoodDupeFix;
import mineplex.core.TimingsFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.AntiHack;
@ -75,7 +74,8 @@ import mineplex.game.clans.shop.mining.MiningShop;
import mineplex.game.clans.shop.pvp.PvpShop;
import mineplex.game.clans.spawn.travel.TravelShop;
import mineplex.game.clans.world.WorldManager;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import static mineplex.core.Managers.require;
public class Clans extends JavaPlugin
{
@ -113,8 +113,6 @@ public class Clans extends JavaPlugin
_clientManager = new CoreClientManager(this);
CommandCenter.Instance.setClientManager(_clientManager);
require(TimingsFix.class);
ItemStackFactory.Initialize(this, false);
DelayedTask.Initialize(this);

View File

@ -43,7 +43,6 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.Managers;
import mineplex.core.MiniClientPlugin;
import mineplex.core.TimingsFix;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
@ -273,7 +272,6 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
// new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager);
require(PlayerDisguiseManager.class);
require(TimingsFix.class);
// NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager);
// new MailManager(_plugin, notificationManager);
new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _gadgetManager, statsManager);

View File

@ -1,10 +1,10 @@
package nautilus.game.arcade;
import static mineplex.core.Managers.require;
import java.io.File;
import java.util.HashMap;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@ -16,7 +16,6 @@ import org.spigotmc.SpigotConfig;
import mineplex.core.CustomTagFix;
import mineplex.core.FoodDupeFix;
import mineplex.core.PacketsInteractionFix;
import mineplex.core.TimingsFix;
import mineplex.core.TwitchIntegrationFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
@ -82,10 +81,11 @@ import mineplex.core.visibility.VisibilityManager;
import mineplex.core.website.WebsiteLinkManager;
import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.damage.DamageManager;
import nautilus.game.arcade.anticheatmetadata.GameInfoMetadata;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameServerConfig;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import static mineplex.core.Managers.require;
public class Arcade extends JavaPlugin
{
@ -138,8 +138,6 @@ public class Arcade extends JavaPlugin
CommandCenter.Instance.setClientManager(_clientManager);
require(ProfileCacheManager.class);
require(TimingsFix.class);
ItemStackFactory.Initialize(this, false);
Recharge.Initialize(this);

View File

@ -1,8 +1,15 @@
package mineplex.gemhunters;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.plugin.java.JavaPlugin;
import org.spigotmc.SpigotConfig;
import mineplex.core.CustomTagFix;
import mineplex.core.FoodDupeFix;
import mineplex.core.TimingsFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.AntiHack;
@ -93,12 +100,6 @@ import mineplex.gemhunters.worldevent.WorldEventModule;
import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.damage.DamageManager;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.plugin.java.JavaPlugin;
import org.spigotmc.SpigotConfig;
import static mineplex.core.Managers.require;
@ -132,9 +133,6 @@ public class GemHunters extends JavaPlugin
// Command Centre
CommandCenter.Instance.setClientManager(clientManager);
// Timings
require(TimingsFix.class);
// ItemStacks
ItemStackFactory.Initialize(this, false);