Remove unnecessary .stream() call

Optimizes .html files (tested)
Removes unnecessary throws
This commit is contained in:
Fuzzlemann 2017-08-03 13:23:59 +02:00
parent 4f3c542bda
commit 3fc0abc4f1
13 changed files with 75 additions and 111 deletions

View File

@ -31,7 +31,7 @@ public abstract class PluginData {
* <p>
* Second parameter of any super constructor.
*/
protected String placeholder;
protected final String placeholder;
/**
* Name of the plugin the data is coming from.
* <p>
@ -43,7 +43,7 @@ public abstract class PluginData {
* <p>
* First parameter of any super constructor.
*/
protected String sourcePlugin;
protected final String sourcePlugin;
/**
* Determines if the datapoint should only be used for the analysis page.
* <p>

View File

@ -339,11 +339,8 @@ public class DataCacheHandler extends SessionCache {
if (averages.isEmpty()) {
return;
}
try {
db.getTpsTable().saveTPSData(averages);
} catch (SQLException ex) {
Log.toLog(this.getClass().getName(), ex);
}
db.getTpsTable().saveTPSData(averages);
}
private List<TPS> calculateAverageTpsForEachMinute() {

View File

@ -130,7 +130,7 @@ public abstract class Importer {
handler.addToPool(importData(uuid, args));
}
plan.processStatus().finishExecution(processName);
processStatus.finishExecution(processName);
} finally {
plan.getAnalysisCache().enableAnalysis();
}

View File

@ -220,7 +220,7 @@ public class GMTimesTable extends Table {
List<List<Container<GMTimes>>> batches = DBUtils.splitIntoBatchesWithID(gmTimes);
batches.stream().forEach(batch -> {
batches.forEach(batch -> {
try {
saveGMTimesBatch(batch);
} catch (SQLException e) {
@ -281,7 +281,7 @@ public class GMTimesTable extends Table {
}
}
private void addNewGMTimesRows(Map<Integer, Map<String, Long>> gamemodeTimes) throws SQLException {
private void addNewGMTimesRows(Map<Integer, Map<String, Long>> gamemodeTimes) {
if (Verify.isEmpty(gamemodeTimes)) {
return;
}

View File

@ -265,10 +265,7 @@ public class SessionsTable extends Table {
}
}
/**
* @throws SQLException
*/
public void clean() throws SQLException {
public void clean() {
// TODO Clean sessions before Configurable time span
}
}

View File

@ -117,10 +117,9 @@ public class TPSTable extends Table {
* @param data
* @throws SQLException
*/
public void saveTPSData(List<TPS> data) throws SQLException {
public void saveTPSData(List<TPS> data) {
List<List<TPS>> batches = DBUtils.splitIntoBatches(data);
batches.stream()
.forEach(batch -> {
batches.forEach(batch -> {
try {
saveTPSBatch(batch);
} catch (SQLException e) {

View File

@ -683,7 +683,7 @@ public class UsersTable extends Table {
List<List<UserData>> batches = DBUtils.splitIntoBatches(newUserdata);
batches.stream()
batches
.forEach(batch -> {
try {
insertNewUserData(batch);

View File

@ -169,7 +169,7 @@ public class WebServer {
}
}
private boolean startHttpsServer() throws IOException {
private boolean startHttpsServer() {
String keyStorePath = Settings.WEBSERVER_CERTIFICATE_PATH.toString();
if (!Paths.get(keyStorePath).isAbsolute()) {
keyStorePath = plugin.getDataFolder() + File.separator + keyStorePath;

View File

@ -14,7 +14,7 @@
left: 0;
width: 100%;
height: 88px;
padding: 0px;
padding: 0;
background-color: #348e0f;
z-index: 1;
}
@ -44,11 +44,11 @@
text-decoration: none;
background-color: #89c471;
color: #fff;
margin: 10px 0px;
margin: 10px 0;
}
.sidenav a {
margin: 10px 0px;
margin: 10px 0;
width: 100%;
padding: 8px 8px 8px 16px;
text-decoration: none;
@ -86,10 +86,9 @@
background-color: #fff;
padding: 5px;
text-decoration: none;!important;
color: #000
color: #000;
text-align: left;
margin: 5px;
padding: 5px;
}
.box p {
@ -106,7 +105,7 @@
.content {
text-align: center;
padding: 5px;
margin: 0px;
margin: 0;
}
.row {
width: 50%;
@ -151,8 +150,7 @@
.headerbox {
color: #348e0f;
display: inline-block;
border-style: solid;
border-color: #348e0f;
border: solid #348e0f;
padding: 8px 14px;
border-radius: 3px;
width: 95%;
@ -165,9 +163,9 @@
font-size: x-large;
}
.header-label {
padding: 0px;
margin: 0px;
border: 0px;
padding: 0;
margin: 0;
border: 0;
}
.button {
padding: 8px 14px;
@ -183,8 +181,7 @@
.table {
border-collapse: collapse;
table-layout: fixed;
border-style: solid;
border-width: 1px;
border: 1px solid;
padding: 8px 14px;
width: 100%;
}
@ -243,20 +240,18 @@
display: none;
}
header {
margin: 0px;
padding 0px;
margin: 0;
padding: 0;
}
header h1 {
margin: 0px;
margin: 0;
}
header img {
padding: 0;
margin: 0px;
padding: 0px;
margin-right: 0px;
}
header p {
margin: 0px;
margin-top: 5px;
margin: 5px 0px 0px;
}
.tab {
flex-direction: column;
@ -268,11 +263,11 @@
width: 100%;
}
.sidenav {
width: 0%;
width: 0;
transition: 0s;
}
.main-limiter {
margin-left: 0%;
margin-left: 0;
width: 100%;
}
}
@ -342,7 +337,7 @@
</div>
</div>
</div>
<div id="playerChartDay" style="width=100%; height=350px;"></div>
<div id="playerChartDay" style="width:100%; height:350px;"></div>
<p><i class="fa fa-user-circle" aria-hidden="true"></i> Unique Players: %uniquejoinsday% | <i
class="fa fa-user-circle-o" aria-hidden="true"></i> Unique/Day: %avguniquejoinsday%</p>
</div>
@ -419,7 +414,7 @@
</div>
</div>
</div>
<div id="playerChartMonth" style="width=100%; height=350px;"></div>
<div id="playerChartMonth" style="width: 100%; height: 350px;"></div>
</div>
<div class=" box column">
<p><b>Month:</b><br>
@ -678,7 +673,8 @@
var playersOnlineSeries = {
name: 'Players Online',
data: %playersonlineseries%,
type: 'areaspline',
type: 'areaspline'
,
color: '#%playersgraphcolor%',
tooltip: {
valueDecimals: 0
@ -797,7 +793,7 @@
</script>
<script>
function playersChart() {
var myChart = Highcharts.stockChart('playerChartDay', {
Highcharts.stockChart('playerChartDay', {
rangeSelector: {
selected: 1,
buttons: [{
@ -1239,13 +1235,13 @@
var navButtons = document.getElementsByClassName("nav-button");
var tabs = document.getElementsByClassName("tab");
var slideIndex = window.sessionStorage.getItem("AnalysisSlideIndex");
if (slideIndex == null) {
if (slideIndex === null) {
slideIndex = 0;
}
var x = document.getElementById("main");
x.style.transform = "translate3d(0px,0px,0)";
x.style.width = "" + navButtons.length * 100 + "%";
for (i = 0; i < navButtons.length; i++) {
for (var i = 0; i < navButtons.length; i++) {
navButtons[i].onclick = openFunc(i)
tabs[i].style.width = "" + 100 / navButtons.length + "%";
}
@ -1266,12 +1262,12 @@
function openFunc(i) {
return function() {
if (window.getComputedStyle(document.getElementById("navbutton")).getPropertyValue('display') == "inline") {
if (window.getComputedStyle(document.getElementById("navbutton")).getPropertyValue('display') === "inline") {
closeNav();
}
var max = navButtons.length;
for (var j = 0; j < max; j++) {
if (j == i) {
if (j === i) {
navButtons[j].classList.add('active');
continue;
}

View File

@ -13,7 +13,7 @@
left: 0;
width: 100%;
height: 88px;
padding: 0px;
padding: 0;
background-color: #348e0f;
z-index: 1;
}
@ -43,11 +43,11 @@
text-decoration: none;
background-color: #89c471;
color: #fff;
margin: 10px 0px;
margin: 10px 0;
}
.sidenav a {
margin: 10px 0px;
margin: 10px 0;
width: 100%;
padding: 8px 8px 8px 16px;
text-decoration: none;
@ -59,7 +59,7 @@
z-index: 1;
}
.sidenav a.active {
.sidenav {
background-color: #5da341
}
@ -88,7 +88,6 @@
color: #000;
text-align: left;
margin: 5px;
padding: 5px;
}
.box p {
@ -111,17 +110,13 @@
.content {
text-align: center;
padding: 5px;
margin: 0px;
}
.columns {
display: flex;
margin: 0;
}
.column {
flex: 1;
}
.box-area {
width: 100%;
}
.infobox {
margin-left: 3px;
color: white;
@ -150,8 +145,7 @@
.headerbox {
color: #348e0f;
display: inline-block;
border-style: solid;
border-color: #348e0f;
border: solid #348e0f;
padding: 8px 14px;
border-radius: 10px;
width: 95%;
@ -164,32 +158,19 @@
font-size: x-large;
}
.header-label {
padding: 0px;
margin: 0px;
border: 0px;
}
.button {
padding: 8px 14px;
background-color: #348e0f;
border: none;
color: white;
outline: 0;
text-decoration:none!important;
}
.button:hover {
background-color: #267F00;
padding: 0;
margin: 0;
border: 0;
}
.table {
border-collapse: collapse;
table-layout: fixed;
border-style: solid;
border-width: 1px;
border: 1px solid;
padding: 8px 14px;
width: 100%;
}
.buttons {
line-height: 270%;
}
.link {
color: #348e0f;
text-decoration:none!important;
@ -281,20 +262,18 @@
display: none;
}
header {
margin: 0px;
padding 0px;
margin: 0;
padding: 0;
}
header h1 {
margin: 0px;
margin: 0;
}
header img {
margin: 0px;
padding: 0px;
margin-right: 0px;
padding: 0;
}
header p {
margin: 0px;
margin-top: 5px;
margin: 5px 0px 0px;
}
.tab {
flex-direction: column;
@ -306,11 +285,11 @@
width: 100%;
}
.sidenav {
width: 0%;
width: 0;
transition: 0s;
}
.main-limiter {
margin-left: 0%;
margin-left: 0;
width: 100%;
}
}
@ -406,7 +385,7 @@
</div>
</div>
</div>
<div id="playerChart" style="width=100%; height=350px;"></div>
<div id="playerChart" style="width:100%; height:350px;"></div>
</div>
<div class="about box column">
<div class="headerbox">
@ -505,13 +484,13 @@
seconds = Math.floor(seconds);
if (dd != 0) {
if (dd !== 0) {
out += dd.toString() + "d ";
}
if (dh != 0) {
if (dh !== 0) {
out += dh.toString() + "h ";
}
if (dm != 0) {
if (dm !== 0) {
out += dm.toString() + "m ";
}
out += seconds.toString() + "s ";
@ -564,7 +543,7 @@
</script>
<script>
function playersChart() {
var myChart = Highcharts.stockChart('playerChart', {
Highcharts.stockChart('playerChart', {
rangeSelector: {
selected: 2,
buttons: [{
@ -627,7 +606,7 @@
</script>
<script>
function worldPie() {
var myChart = Highcharts.chart('worldPie', {
Highcharts.chart('worldPie', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
@ -671,7 +650,7 @@
tickInterval: 3600000
},
yAxis: {
categories: ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],
categories: ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
},
tooltip: {
pointFormat: 'Activity: {point.z}'
@ -728,7 +707,7 @@
var navButtons = document.getElementsByClassName("nav-button");
var tabs = document.getElementsByClassName("tab");
var slideIndex = window.sessionStorage.getItem("InspectSlideIndex");
if (slideIndex == null) {
if (slideIndex === null) {
slideIndex = 0;
}
var x = document.getElementById("main");
@ -736,7 +715,7 @@
x.style.transform = "translate3d(0px,0px,0)";
x.style.width = ""+navButtons.length*100+"%";
for (i=0; i < navButtons.length; i++) {
for (var i = 0; i < navButtons.length; i++) {
navButtons[i].onclick = openFunc(i)
tabs[i].style.width = ""+100/navButtons.length+"%";
}

View File

@ -37,8 +37,6 @@ import static org.powermock.api.mockito.PowerMockito.when;
@PrepareForTest(JavaPlugin.class)
public class KillInfoTest {
private Database db;
/**
*
*/
@ -52,7 +50,7 @@ public class KillInfoTest {
public void setUp() throws Exception {
TestInit t = TestInit.init();
Plan plan = t.getPlanMock();
db = new SQLiteDB(plan, "debug" + MiscUtils.getTime()) {
Database db = new SQLiteDB(plan, "debug" + MiscUtils.getTime()) {
@Override
public void startConnectionPingTask() {
@ -68,10 +66,10 @@ public class KillInfoTest {
return new UsersTable(null, false) {
@Override
public int getUserId(UUID uuid) {
if (uuid.equals(MockUtils.getPlayerUUID())) {
return 2;
}
return 1;
if (uuid.equals(MockUtils.getPlayerUUID())) {
return 2;
}
return 1;
}
};
}

View File

@ -18,7 +18,6 @@ import org.powermock.api.mockito.PowerMockito;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
@ -154,7 +153,7 @@ public class MockUtils {
return PowerMockito.mock(CommandSender.class);
}
public static HttpServer mockHTTPServer() throws UnknownHostException {
public static HttpServer mockHTTPServer() {
HttpServer httpServer = PowerMockito.mock(HttpServer.class);
when(httpServer.getAddress()).thenReturn(InetSocketAddress.createUnresolved("127.0.0.1", 80));
when(httpServer.getExecutor()).thenReturn(command -> System.out.println("HTTP Server command received"));

View File

@ -100,9 +100,8 @@ public class TestInit {
return mockServer;
}
private static File getTestFolder() throws IOException {
private static File getTestFolder() {
File testFolder = new File("temporaryTestFolder");
testFolder = new File("temporaryTestFolder");
testFolder.mkdir();
return testFolder;
}