timer
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package DBAcess;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.apache.commons.dbcp2.BasicDataSource;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class DBCPDataSource {
|
||||
|
||||
private static BasicDataSource ds = new BasicDataSource();
|
||||
|
||||
static {
|
||||
try {
|
||||
ds.setDriver(new com.mysql.cj.jdbc.Driver());
|
||||
//ds.setUrl("jdbc:mysql://151.80.230.149:3306/unloze_racetimer_css?useLegacyDatetimeCode=false&serverTimezone=UTC");
|
||||
ds.setUrl("jdbc:mysql://localhost:3306/unloze_racetimer_css?useLegacyDatetimeCode=false&serverTimezone=UTC");
|
||||
ds.setUsername("unloze_racetimer_css");
|
||||
ds.setPassword("ahsdbahb/#¤FHdasd");
|
||||
ds.setMaxTotal(-1);
|
||||
ds.setMinIdle(5);
|
||||
ds.setMaxIdle(-1);
|
||||
ds.setMaxOpenPreparedStatements(100);
|
||||
} catch (SQLException ex) {
|
||||
Logger.getLogger(DBCPDataSource.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static Connection getConnection() throws SQLException {
|
||||
return ds.getConnection();
|
||||
}
|
||||
|
||||
private DBCPDataSource() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package DBAcess;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.apache.commons.dbcp2.BasicDataSource;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class DBCPDataSource2 {
|
||||
private static BasicDataSource ds = new BasicDataSource();
|
||||
|
||||
static {
|
||||
try {
|
||||
ds.setDriver(new com.mysql.cj.jdbc.Driver());
|
||||
//ds.setUrl("jdbc:mysql://151.80.230.149:3306/unloze_stats?useLegacyDatetimeCode=false&serverTimezone=UTC");
|
||||
ds.setUrl("jdbc:mysql://localhost:3306/unloze_stats?useLegacyDatetimeCode=false&serverTimezone=UTC");
|
||||
ds.setUsername("unloze_stats");
|
||||
ds.setPassword("R8J8E9Fzmcc7ZfDAGAk7");
|
||||
ds.setMaxTotal(-1);
|
||||
ds.setMinIdle(5);
|
||||
ds.setMaxIdle(-1);
|
||||
ds.setMaxOpenPreparedStatements(100);
|
||||
} catch (SQLException ex) {
|
||||
Logger.getLogger(DBCPDataSource.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static Connection getConnection() throws SQLException {
|
||||
return ds.getConnection();
|
||||
}
|
||||
|
||||
private DBCPDataSource2() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package DBAcess;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.apache.commons.dbcp2.BasicDataSource;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class DBCPDataSource3 {
|
||||
private static BasicDataSource ds = new BasicDataSource();
|
||||
static {
|
||||
try {
|
||||
ds.setDriver(new com.mysql.cj.jdbc.Driver());
|
||||
//ds.setUrl("jdbc:mysql://151.80.230.149:3306/xenforo?useLegacyDatetimeCode=false&serverTimezone=UTC");
|
||||
ds.setUrl("jdbc:mysql://localhost:3306/xenforo?useLegacyDatetimeCode=false&serverTimezone=UTC");
|
||||
ds.setUsername("XenforoWebTimer");
|
||||
ds.setPassword("FNF#)(EFHFSNj23n4nfdsfbFE");
|
||||
ds.setMaxTotal(-1);
|
||||
ds.setMinIdle(5);
|
||||
ds.setMaxIdle(-1);
|
||||
ds.setMaxOpenPreparedStatements(100);
|
||||
} catch (SQLException ex) {
|
||||
Logger.getLogger(DBCPDataSource.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static Connection getConnection() throws SQLException {
|
||||
return ds.getConnection();
|
||||
}
|
||||
|
||||
private DBCPDataSource3() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,548 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package DBAcess;
|
||||
|
||||
import FunctionLayer.ErrorMessageDisplay;
|
||||
import FunctionLayer.MapBoard;
|
||||
import FunctionLayer.MapValues;
|
||||
import FunctionLayer.RecentTimes;
|
||||
import FunctionLayer.UserBanners;
|
||||
import FunctionLayer.Users;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class DataMapper {
|
||||
|
||||
private static String DefaultAvatar = "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/fe/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb_full.jpg";
|
||||
|
||||
public static List<MapBoard> GetAllMapColoumns() throws SQLException, ErrorMessageDisplay, IOException, PropertyVetoException {
|
||||
List<MapBoard> AllMapColoumns = new ArrayList();
|
||||
List<MapValues> mv = new ArrayList();
|
||||
int prefixSkip = 3;
|
||||
MapBoard mapboardnames = null;
|
||||
Connection l_cCon = null;
|
||||
PreparedStatement l_pStatement = null;
|
||||
ResultSet l_rsSearch = null;
|
||||
try {
|
||||
l_cCon = DBCPDataSource.getConnection();
|
||||
String l_sSQL = "SELECT * FROM `zetimer_table` LIMIT 1;";
|
||||
l_pStatement = l_cCon.prepareStatement(l_sSQL);
|
||||
l_rsSearch = l_pStatement.executeQuery();
|
||||
ResultSetMetaData metaData = l_rsSearch.getMetaData();
|
||||
for (int i = prefixSkip; i <= metaData.getColumnCount(); i++) {
|
||||
mapboardnames = new MapBoard(metaData.getColumnLabel(i), mv);
|
||||
AllMapColoumns.add(mapboardnames);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
throw new ErrorMessageDisplay("failed in DataMapper 1 " + ex.getMessage());
|
||||
} finally {
|
||||
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
||||
}
|
||||
Collections.sort(AllMapColoumns,
|
||||
(d1, d2) -> d1.getMapName().compareTo(d2.getMapName()));
|
||||
return AllMapColoumns;
|
||||
}
|
||||
|
||||
public static List<Users> getAllUsersNameSteamIdInitialization() throws SQLException, ErrorMessageDisplay, IOException, PropertyVetoException {
|
||||
List<Users> userlist = new ArrayList();
|
||||
Users user = null;
|
||||
Connection l_cCon = null;
|
||||
PreparedStatement l_pStatement = null;
|
||||
ResultSet l_rsSearch = null;
|
||||
try {
|
||||
l_cCon = DBCPDataSource.getConnection();
|
||||
String l_sSQL = "SELECT steam_auth, name FROM `zetimer_table`";
|
||||
l_pStatement = l_cCon.prepareStatement(l_sSQL);
|
||||
l_rsSearch = l_pStatement.executeQuery();
|
||||
while (l_rsSearch.next()) {
|
||||
user = new Users(l_rsSearch.getString(1), l_rsSearch.getString(2), "", 0, 0, 0);
|
||||
userlist.add(user);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
throw new ErrorMessageDisplay("failed in DataMapper 2 " + ex.getMessage());
|
||||
} finally {
|
||||
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
||||
}
|
||||
return userlist;
|
||||
}
|
||||
|
||||
public static LinkedHashMap<Users, Float> GetMapTimes(String mapindexes, List<Users> LeaderBoard, LinkedHashMap<String, Users> Usermap) throws ErrorMessageDisplay {
|
||||
String l_sSQL = "SELECT steam_auth, "
|
||||
+ mapindexes + " FROM `zetimer_table` WHERE "
|
||||
+ mapindexes + " > 0.00 ORDER BY "
|
||||
+ mapindexes + " ASC;";
|
||||
Connection l_cCon = null;
|
||||
PreparedStatement l_pStatement = null;
|
||||
ResultSet l_rsSearch = null;
|
||||
LinkedHashMap<Users, Float> usertimes = new LinkedHashMap();
|
||||
Users user;
|
||||
try {
|
||||
l_cCon = DBCPDataSource.getConnection();
|
||||
l_pStatement = l_cCon.prepareStatement(l_sSQL);
|
||||
l_rsSearch = l_pStatement.executeQuery();
|
||||
while (l_rsSearch.next()) {
|
||||
user = Usermap.get(l_rsSearch.getString(1));
|
||||
usertimes.put(user, l_rsSearch.getFloat(2));
|
||||
}
|
||||
l_cCon.close();
|
||||
} catch (SQLException ex) {
|
||||
throw new ErrorMessageDisplay("failed in DataMapper GetMapTimes sql: " + l_sSQL + ex.getMessage());
|
||||
} finally {
|
||||
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
||||
}
|
||||
return usertimes;
|
||||
}
|
||||
|
||||
public static List<Users> SetUsersAvatars(List<Users> userAvatarLinks) throws IOException, ErrorMessageDisplay, SQLException {
|
||||
String l_SQL = "SELECT * FROM `userStrings`";
|
||||
HashBiMap<String, String> strList = HashBiMap.create();
|
||||
Connection l_cCon = null;
|
||||
PreparedStatement l_pStatement = null;
|
||||
ResultSet l_rsSearch = null;
|
||||
try {
|
||||
l_cCon = DBCPDataSource.getConnection();
|
||||
l_pStatement = l_cCon.prepareStatement(l_SQL);
|
||||
l_rsSearch = l_pStatement.executeQuery();
|
||||
while (l_rsSearch.next()) {
|
||||
strList.put(l_rsSearch.getString(1), l_rsSearch.getString(2));
|
||||
}
|
||||
for (int i = 0; i < userAvatarLinks.size(); i++) {
|
||||
String str = strList.inverse().get(userAvatarLinks.get(i).getSteamID());
|
||||
if (str != null) {
|
||||
userAvatarLinks.get(i).setAvatar(str);
|
||||
} else {
|
||||
userAvatarLinks.get(i).setAvatar(DefaultAvatar);
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
throw new ErrorMessageDisplay("Datamapper sql: " + l_SQL + ex.getMessage());
|
||||
} finally {
|
||||
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
||||
}
|
||||
return userAvatarLinks;
|
||||
}
|
||||
|
||||
public synchronized static void UpdatePlayerAvatarsToDB(List<Users> userAvatars, List<String> ConvertedID, int start, int end) throws ErrorMessageDisplay, MalformedURLException, IOException {
|
||||
List<String> arr = new ArrayList();
|
||||
String Avatar = "";
|
||||
Connection l_cCon = null;
|
||||
PreparedStatement l_pStatement = null;
|
||||
ResultSet l_rsSearch = null;
|
||||
String l_sSQL = "CREATE TABLE IF NOT EXISTS `userStrings` (`strings` VARCHAR(254) NOT NULL, `steam_auth` VARCHAR(65) NOT NULL, PRIMARY KEY (`steam_auth`));";
|
||||
try {
|
||||
l_cCon = DBCPDataSource.getConnection();
|
||||
l_pStatement = l_cCon.prepareStatement(l_sSQL);
|
||||
l_pStatement.executeUpdate();
|
||||
for (int i = start; i < end; i++) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
URL url = new URL("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=262F3F0C6B83E0F263C272C3762002F1&steamids="
|
||||
+ ConvertedID.get(i));
|
||||
try (InputStream is = url.openStream();
|
||||
InputStreamReader in = new InputStreamReader(is);
|
||||
BufferedReader reader = new BufferedReader(in)) {
|
||||
String word;
|
||||
while ((word = reader.readLine()) != null) {
|
||||
sb.append(word);
|
||||
}
|
||||
}
|
||||
arr.add(sb.toString());
|
||||
}
|
||||
for (int i = start; i < end; i++) {
|
||||
if (arr.get(i).contains("avatarfull\":")) {
|
||||
Avatar = arr.get(i).substring(arr.get(i).indexOf("avatarfull\":") + 13, arr.get(i).indexOf("\",\"personastate"));
|
||||
l_sSQL = "INSERT INTO `userStrings` (`steam_auth`, `strings`) VALUES ('" + userAvatars.get(i).getSteamID()
|
||||
+ "', '" + Avatar + "') ON DUPLICATE KEY UPDATE `strings` = '" + Avatar + "'";
|
||||
l_pStatement.addBatch(l_sSQL);
|
||||
}
|
||||
}
|
||||
l_pStatement.executeBatch();
|
||||
} catch (SQLException ex) {
|
||||
throw new ErrorMessageDisplay("failed in DataMapper 5 sql: " + l_sSQL + ex.getMessage());
|
||||
} finally {
|
||||
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated @param PlayerIndexSteamID
|
||||
* @return
|
||||
* @throws ErrorMessageDisplay
|
||||
* @throws SQLException
|
||||
* @throws IOException
|
||||
* @throws PropertyVetoException
|
||||
*/
|
||||
public static List<Float> GetSpecificPlayerTimes(String PlayerIndexSteamID) throws ErrorMessageDisplay, SQLException, IOException, PropertyVetoException {
|
||||
List<Float> PlayerTimes = new ArrayList();
|
||||
List<MapBoard> AllMaps = GetAllMapColoumns();
|
||||
String l_sSQL = "";
|
||||
Connection l_cCon = null;
|
||||
PreparedStatement l_pStatement = null;
|
||||
ResultSet l_rsSearch = null;
|
||||
try {
|
||||
l_cCon = DBCPDataSource.getConnection();
|
||||
for (int i = 0; i < AllMaps.size(); i++) {
|
||||
l_sSQL = "SELECT " + AllMaps.get(i).getMapName() + " FROM `zetimer_table` WHERE steam_auth = '" + PlayerIndexSteamID + "'"
|
||||
+ " AND " + AllMaps.get(i).getMapName() + " > 0.00";
|
||||
l_pStatement = l_cCon.prepareStatement(l_sSQL);
|
||||
l_rsSearch = l_pStatement.executeQuery();
|
||||
if (l_rsSearch.next()) {
|
||||
PlayerTimes.add(l_rsSearch.getFloat(1));
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
throw new ErrorMessageDisplay("failed in DataMapper sql: " + l_sSQL + ex.getMessage());
|
||||
} finally {
|
||||
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
||||
}
|
||||
return PlayerTimes;
|
||||
}
|
||||
|
||||
public static List<MapBoard> GetPlayerRelatedMaps(String PlayerIndexSteamID) throws ErrorMessageDisplay, SQLException, IOException, PropertyVetoException {
|
||||
List<MapBoard> AllPlayerRelatedMaps = new ArrayList();
|
||||
List<MapValues> mv = new ArrayList();
|
||||
List<MapBoard> AllMaps = GetAllMapColoumns();
|
||||
MapBoard map = null;
|
||||
Connection l_cCon = null;
|
||||
PreparedStatement l_pStatement = null;
|
||||
ResultSet l_rsSearch = null;
|
||||
String l_SQL = "";
|
||||
try {
|
||||
l_cCon = DBCPDataSource.getConnection();
|
||||
for (int i = 0; i < AllMaps.size(); i++) {
|
||||
l_SQL = "SELECT " + AllMaps.get(i).getMapName() + " FROM `zetimer_table` WHERE steam_auth = '" + PlayerIndexSteamID + "'";
|
||||
l_pStatement = l_cCon.prepareStatement(l_SQL);
|
||||
l_rsSearch = l_pStatement.executeQuery();
|
||||
if (l_rsSearch.next()) {
|
||||
if (l_rsSearch.getFloat(1) > 0.0) {
|
||||
map = new MapBoard(AllMaps.get(i).getMapName(), mv);
|
||||
AllPlayerRelatedMaps.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
throw new ErrorMessageDisplay("failed in DataMapper sql: " + l_SQL + ex.getMessage());
|
||||
} finally {
|
||||
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
||||
}
|
||||
return AllPlayerRelatedMaps;
|
||||
}
|
||||
|
||||
public static int GetAdmin(String name, String psw) throws ErrorMessageDisplay {
|
||||
String l_SQL = "";
|
||||
Connection l_cCon = null;
|
||||
PreparedStatement l_pStatement = null;
|
||||
ResultSet l_rsSearch = null;
|
||||
try {
|
||||
l_cCon = DBCPDataSource.getConnection();
|
||||
l_SQL = "CREATE TABLE IF NOT EXISTS `Admins` (`username` VARCHAR(64) NOT NULL, `password` VARCHAR(65) NOT NULL, `role` VARCHAR(65) NOT NULL, PRIMARY KEY (`username`));";
|
||||
l_pStatement = l_cCon.prepareStatement(l_SQL);
|
||||
l_pStatement.executeUpdate();
|
||||
l_SQL = "SELECT role FROM `Admins` WHERE username = '" + name + "' AND password = '" + psw + "'";
|
||||
l_pStatement = l_cCon.prepareStatement(l_SQL);
|
||||
l_rsSearch = l_pStatement.executeQuery();
|
||||
if (l_rsSearch.next()) {
|
||||
switch (l_rsSearch.getString(1)) {
|
||||
case "Tech": {
|
||||
return 3;
|
||||
}
|
||||
case "Global Admin": {
|
||||
return 2;
|
||||
}
|
||||
case "Admin": {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
throw new ErrorMessageDisplay("failed in DataMapper sql: " + l_SQL + ex.getMessage());
|
||||
} finally {
|
||||
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void DeleteMapEntry(String map, String steamID) throws ErrorMessageDisplay {
|
||||
String l_SQL = "";
|
||||
Connection l_cCon = null;
|
||||
PreparedStatement l_pStatement = null;
|
||||
ResultSet l_rsSearch = null;
|
||||
try {
|
||||
l_cCon = DBCPDataSource.getConnection();
|
||||
l_SQL = "UPDATE `zetimer_table` SET `" + map + "` = 0.000 WHERE `steam_auth` = '" + steamID + "';";
|
||||
l_pStatement = l_cCon.prepareStatement(l_SQL);
|
||||
l_pStatement.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
throw new ErrorMessageDisplay("failed in DataMapper sql: " + l_SQL + ex.getMessage());
|
||||
} finally {
|
||||
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
||||
}
|
||||
}
|
||||
|
||||
public static MapBoard getCurrentMap() throws IOException, ErrorMessageDisplay {
|
||||
String GetCurrentmap = "https://api.steampowered.com/IGameServersService/GetServerList/v1/?key=262F3F0C6B83E0F263C272C3762002F1&filter=addr\\151.80.230.149:27015&limit=1";
|
||||
JSONObject json = readJsonFromUrl(GetCurrentmap);
|
||||
String sjson = json.toString();
|
||||
List<MapValues> mv = new ArrayList();
|
||||
MapBoard map = new MapBoard(sjson.substring(sjson.indexOf("map\":\"") + 6, sjson.indexOf("\",\"specport\"")), mv);
|
||||
return map;
|
||||
}
|
||||
|
||||
private static String readAll(Reader rd) throws IOException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int cp;
|
||||
while ((cp = rd.read()) != -1) {
|
||||
sb.append((char) cp);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static JSONObject readJsonFromUrl(String url) throws IOException, JSONException {
|
||||
InputStream is = new URL(url).openStream();
|
||||
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
|
||||
String jsonText = readAll(rd);
|
||||
JSONObject json = new JSONObject(jsonText);
|
||||
return json;
|
||||
}
|
||||
|
||||
public static List<String> getHlstatsxIngamePlayerSteamID() throws ErrorMessageDisplay {
|
||||
List<String> ingamePlayersSteamID = new ArrayList();
|
||||
Connection l_cCon = null;
|
||||
PreparedStatement l_pStatement = null;
|
||||
ResultSet l_rsSearch = null;
|
||||
String l_SQL = "";
|
||||
try {
|
||||
l_cCon = DBCPDataSource2.getConnection();
|
||||
l_SQL = "SELECT steam_id FROM `hlstats_Livestats` WHERE server_id = 1";
|
||||
l_pStatement = l_cCon.prepareStatement(l_SQL);
|
||||
l_rsSearch = l_pStatement.executeQuery();
|
||||
while (l_rsSearch.next()) {
|
||||
ingamePlayersSteamID.add(l_rsSearch.getString(1));
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
throw new ErrorMessageDisplay("failed in DataMapper sql: " + l_SQL + ex.getMessage());
|
||||
} finally {
|
||||
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
||||
}
|
||||
return ingamePlayersSteamID;
|
||||
}
|
||||
|
||||
public static List<MapBoard> getCurrentMapLevels(MapBoard map) throws SQLException, ErrorMessageDisplay, IOException, PropertyVetoException {
|
||||
List<MapBoard> allColoumns = GetAllMapColoumns();
|
||||
List<MapBoard> currentLvls = new ArrayList();
|
||||
for (int i = 0; i < allColoumns.size(); i++) {
|
||||
if (allColoumns.get(i).getMapName().contains(map.getMapName())) {
|
||||
currentLvls.add(allColoumns.get(i));
|
||||
}
|
||||
}
|
||||
return currentLvls;
|
||||
}
|
||||
|
||||
public static Map<String, String> getAllAdmins() throws ErrorMessageDisplay {
|
||||
Map<String, String> HM = new HashMap();
|
||||
Connection l_cCon = null;
|
||||
PreparedStatement l_pStatement = null;
|
||||
ResultSet l_rsSearch = null;
|
||||
String l_SQL = "SELECT username, role FROM `Admins`";
|
||||
try {
|
||||
l_cCon = DBCPDataSource.getConnection();
|
||||
l_pStatement = l_cCon.prepareStatement(l_SQL);
|
||||
l_rsSearch = l_pStatement.executeQuery();
|
||||
while (l_rsSearch.next()) {
|
||||
HM.put(l_rsSearch.getString(1), l_rsSearch.getString(2));
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
throw new ErrorMessageDisplay("failed in DataMapper sql: " + l_SQL + ex.getMessage());
|
||||
} finally {
|
||||
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
||||
}
|
||||
return HM;
|
||||
}
|
||||
|
||||
public static void createAdmin(String name, String password, String role) throws ErrorMessageDisplay {
|
||||
String l_SQL = "INSERT INTO `Admins` (`username`,`password`,`role`) VALUES (?, ?, ?)";
|
||||
Connection l_cCon = null;
|
||||
PreparedStatement l_pStatement = null;
|
||||
ResultSet l_rsSearch = null;
|
||||
try {
|
||||
l_cCon = DBCPDataSource.getConnection();
|
||||
l_pStatement = l_cCon.prepareStatement(l_SQL);
|
||||
l_pStatement.setString(1, name);
|
||||
l_pStatement.setString(2, password);
|
||||
l_pStatement.setString(3, role);
|
||||
l_pStatement.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
throw new ErrorMessageDisplay("failed in DataMapper sql: " + l_SQL + ex.getMessage());
|
||||
} finally {
|
||||
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
||||
}
|
||||
}
|
||||
|
||||
public static LinkedHashMap<Users, Float> GetMapRelatedTimes(MapBoard mapname, List<Users> LeaderBoardInfo, Map<String, Users> UserMap) throws ErrorMessageDisplay {
|
||||
LinkedHashMap<Users, Float> LHM = new LinkedHashMap();
|
||||
int index = 0;
|
||||
int counter = 0;
|
||||
Connection l_cCon = null;
|
||||
PreparedStatement l_pStatement = null;
|
||||
ResultSet l_rsSearch = null;
|
||||
String l_SQL = "SELECT steam_auth, "
|
||||
+ mapname.getMapName() + " FROM `zetimer_table` WHERE "
|
||||
+ mapname.getMapName() + " > 0.00 ORDER BY "
|
||||
+ mapname.getMapName() + " ASC;";
|
||||
try {
|
||||
l_cCon = DBCPDataSource.getConnection();
|
||||
l_pStatement = l_cCon.prepareStatement(l_SQL);
|
||||
l_rsSearch = l_pStatement.executeQuery();
|
||||
while (l_rsSearch.next()) {
|
||||
counter++;
|
||||
Users user = UserMap.get(l_rsSearch.getString(1));
|
||||
index = LeaderBoardInfo.indexOf(user);
|
||||
LHM.put(LeaderBoardInfo.get(index), l_rsSearch.getFloat(2));
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
throw new ErrorMessageDisplay("failed in DataMapper GetMapRelatedTimes sql: " + l_SQL + ex.getMessage());
|
||||
} finally {
|
||||
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
||||
}
|
||||
return LHM;
|
||||
}
|
||||
|
||||
public static List<UserBanners> getUserbanners(List<Users> PlayerLeaderBoard, List<String> ConvertedID) throws ErrorMessageDisplay {
|
||||
List<UserBanners> UBList = new ArrayList();
|
||||
UserBanners ub;
|
||||
Connection l_cCon = null;
|
||||
PreparedStatement l_pStatement = null;
|
||||
ResultSet l_rsSearch = null;
|
||||
List<Integer> user_id = new ArrayList();
|
||||
List<Long> Provider_key = new ArrayList();
|
||||
List<Integer> user_group_id = new ArrayList();
|
||||
String l_SQL = "SELECT t2.user_id, t2.provider_key, t1.user_group_id FROM `xf_user_group_relation` t1, `xf_user_external_auth` t2 WHERE t1.user_id = t2.user_id AND t2.provider = \"steam\"";
|
||||
try {
|
||||
l_cCon = DBCPDataSource3.getConnection();
|
||||
l_pStatement = l_cCon.prepareStatement(l_SQL);
|
||||
l_rsSearch = l_pStatement.executeQuery();
|
||||
while (l_rsSearch.next()) {
|
||||
user_id.add(l_rsSearch.getInt(1));
|
||||
Provider_key.add(l_rsSearch.getLong(2));
|
||||
user_group_id.add(l_rsSearch.getInt(3));
|
||||
}
|
||||
int indexIDs = 0;
|
||||
int counter = 0;
|
||||
while (indexIDs < user_id.size()) {
|
||||
List<Integer> Iarr = new ArrayList();
|
||||
while (indexIDs < user_id.size() && Provider_key.get(indexIDs).intValue() == Provider_key.get(counter).intValue()) {
|
||||
//2 = user, 6 = mapper, 7 = admin, 8 = technical staff, 10 = leader, 12 = vip, 15 = event winner, 19 = discord manager, 20 NSFW, 25 = event manager
|
||||
// 11 = GA
|
||||
int groupID = user_group_id.get(indexIDs);
|
||||
if (groupID == 6 || groupID == 7 || groupID == 8 || groupID == 10 || groupID == 11 || groupID == 12 || groupID == 15 || groupID == 19
|
||||
|| groupID == 25) {
|
||||
Iarr.add(groupID);
|
||||
}
|
||||
indexIDs++;
|
||||
}
|
||||
counter = indexIDs;
|
||||
boolean end = false;
|
||||
if (indexIDs >= user_id.size()) {
|
||||
indexIDs = user_id.size() - 1;
|
||||
end = true;
|
||||
}
|
||||
int index = ConvertedID.indexOf(String.valueOf(Provider_key.get(indexIDs - 1)));
|
||||
if (index != -1) {
|
||||
ub = new UserBanners(Iarr, PlayerLeaderBoard.get(index));
|
||||
UBList.add(ub);
|
||||
}
|
||||
if (end) {
|
||||
break;
|
||||
}
|
||||
/*
|
||||
if (Objects.equals(Provider_key.get(indexIDs - 1), Long.valueOf("76561198343747394"))) {
|
||||
throw new ErrorMessageDisplay("UBList kaka size: " + UBList.get(UBList.size() - 1).getUrlBanners().size()
|
||||
+ " name: " + UBList.get(UBList.size() - 1).getUser().getName());
|
||||
}
|
||||
*/
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
throw new ErrorMessageDisplay("failed in DataMapper getUserbanners sql: " + l_SQL + ex.getMessage());
|
||||
} finally {
|
||||
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
||||
}
|
||||
return UBList;
|
||||
}
|
||||
|
||||
public static List<RecentTimes> getRecentTimes() throws ErrorMessageDisplay {
|
||||
List<RecentTimes> RTlist = new ArrayList();
|
||||
Connection l_cCon = null;
|
||||
PreparedStatement l_pStatement = null;
|
||||
ResultSet l_rsSearch = null;
|
||||
String SQL = "SELECT * FROM `recenttimes_table`";
|
||||
try {
|
||||
l_cCon = DBCPDataSource.getConnection();
|
||||
l_pStatement = l_cCon.prepareStatement(SQL);
|
||||
l_rsSearch = l_pStatement.executeQuery();
|
||||
while (l_rsSearch.next() && RTlist.size() < 500) {
|
||||
RecentTimes RT = new RecentTimes(l_rsSearch.getString(2), l_rsSearch.getString(3), l_rsSearch.getFloat(4), null, 0);
|
||||
RTlist.add(RT);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
throw new ErrorMessageDisplay("failed in DataMapper getRecentTimes sql: " + SQL + ex.getMessage());
|
||||
} finally {
|
||||
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
||||
}
|
||||
return RTlist;
|
||||
}
|
||||
|
||||
public static void CloseConnections(PreparedStatement ps, ResultSet rs, Connection con) {
|
||||
if (rs != null) {
|
||||
try {
|
||||
rs.close();
|
||||
} catch (SQLException ex) {
|
||||
Logger.getLogger(DataMapper.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
if (ps != null) {
|
||||
try {
|
||||
ps.close();
|
||||
} catch (SQLException ex) {
|
||||
Logger.getLogger(DataMapper.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
if (con != null) {
|
||||
try {
|
||||
con.close();
|
||||
} catch (SQLException ex) {
|
||||
Logger.getLogger(DataMapper.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package FunctionLayer.Caching;
|
||||
|
||||
import FunctionLayer.ErrorMessageDisplay;
|
||||
import FunctionLayer.LogicFacade;
|
||||
import FunctionLayer.MapBoard;
|
||||
import FunctionLayer.RecentTimes;
|
||||
import FunctionLayer.UserBanners;
|
||||
import FunctionLayer.Users;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
//https://stackoverflow.com/questions/15357953/cached-map-with-data-initialization-and-whole-data-refreshed-periodically-in-jav
|
||||
public class GACaching {
|
||||
|
||||
//change to 3 hours again
|
||||
public static final long EXPIRE_TIME_IN_SECONDS = TimeUnit.SECONDS.convert(3, TimeUnit.HOURS);
|
||||
public static int UPDATE_AVATARS_CYCLE = 2;
|
||||
public static int AVATAR_INDEXES = 0;
|
||||
public static GACaching instance = new GACaching();
|
||||
private final ConcurrentMap<Integer, Users> UsersCache;
|
||||
private final ConcurrentMap<Integer, Users> UsersCachePoints;
|
||||
private final ConcurrentMap<Integer, MapBoard> MapCache;
|
||||
private final ConcurrentMap<Integer, MapBoard> MapCacheValues;
|
||||
private final ConcurrentMap<Integer, UserBanners> UserBannerCache;
|
||||
private final ConcurrentMap<Integer, Users> UserCacheTimeAmount;
|
||||
private final ConcurrentMap<Integer, RecentTimes> UserCacheRecentTimes;
|
||||
private final Stopwatch stopwatch;
|
||||
|
||||
public GACaching() {
|
||||
this.stopwatch = Stopwatch.createUnstarted();
|
||||
this.UsersCache = new MapMaker().concurrencyLevel(2).makeMap();
|
||||
this.MapCache = new MapMaker().concurrencyLevel(2).makeMap();
|
||||
this.UsersCachePoints = new MapMaker().concurrencyLevel(2).makeMap();
|
||||
this.MapCacheValues = new MapMaker().concurrencyLevel(2).makeMap();
|
||||
this.UserBannerCache = new MapMaker().concurrencyLevel(2).makeMap();
|
||||
this.UserCacheTimeAmount = new MapMaker().concurrencyLevel(2).makeMap();
|
||||
this.UserCacheRecentTimes = new MapMaker().concurrencyLevel(2).makeMap();
|
||||
}
|
||||
|
||||
public synchronized void Initialization() throws ErrorMessageDisplay {
|
||||
// if the map is not initialized, initialize it with the data
|
||||
try {
|
||||
if (!stopwatch.isRunning()) {
|
||||
putAllConcurrentMaps();
|
||||
stopwatch.start();
|
||||
}
|
||||
if (stopwatch.elapsed(TimeUnit.MINUTES) >= UPDATE_AVATARS_CYCLE && AVATAR_INDEXES < UserCacheTimeAmount.values().size()) {
|
||||
UPDATE_AVATARS_CYCLE = (int) (stopwatch.elapsed().toMinutes() + 2);
|
||||
updateAvatars(AVATAR_INDEXES);
|
||||
}
|
||||
// if the map is expired, refresh all the data in the map
|
||||
if (stopwatch.elapsed(TimeUnit.SECONDS) >= EXPIRE_TIME_IN_SECONDS) {
|
||||
UPDATE_AVATARS_CYCLE = 2;
|
||||
if (AVATAR_INDEXES >= UserCacheTimeAmount.values().size()) {
|
||||
AVATAR_INDEXES = 0;
|
||||
}
|
||||
clearConcurrentMaps();
|
||||
putAllConcurrentMaps();
|
||||
stopwatch.reset();
|
||||
}
|
||||
} catch (SQLException | IOException | PropertyVetoException ex) {
|
||||
throw new ErrorMessageDisplay("Initialization failed: " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void UpdateDeletedEntries() throws SQLException, ErrorMessageDisplay, IOException, PropertyVetoException {
|
||||
clearConcurrentMaps();
|
||||
putAllConcurrentMaps();
|
||||
stopwatch.reset();
|
||||
}
|
||||
|
||||
public synchronized void updateAvatars(int AVATAR_INDEXES1) throws ErrorMessageDisplay {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
LogicFacade.UpdatePlayerAvatarsToDB((new ArrayList(UserCacheTimeAmount.values())), AVATAR_INDEXES1);
|
||||
} catch (IOException | ErrorMessageDisplay ex) {
|
||||
Logger.getLogger(GACaching.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}).start();
|
||||
//each itereation handle 200 updates
|
||||
AVATAR_INDEXES += 200;
|
||||
}
|
||||
|
||||
private Map<Integer, RecentTimes> getUserRecentTimesCache(ConcurrentMap<Integer, Users> UserCacheTimeAmount1, ConcurrentMap<Integer, MapBoard> mpb) throws ErrorMessageDisplay {
|
||||
LinkedHashMap<Integer, RecentTimes> LHM = LogicFacade.getRecentTimes(UserCacheTimeAmount1, mpb);
|
||||
return LHM;
|
||||
}
|
||||
|
||||
private Map<Integer, Users> getUserCacheContent() throws SQLException, ErrorMessageDisplay, IOException, PropertyVetoException {
|
||||
List<Users> Users;
|
||||
Users = LogicFacade.getAllUsersNameSteamIdInitialization();
|
||||
LinkedHashMap<Integer, Users> LHM = new LinkedHashMap();
|
||||
for (int i = 0; i < Users.size(); i++) {
|
||||
LHM.put(i, Users.get(i));
|
||||
}
|
||||
return LHM;
|
||||
}
|
||||
|
||||
private Map<Integer, MapBoard> getMapBoardCacheContent() throws ErrorMessageDisplay, SQLException, IOException, PropertyVetoException {
|
||||
List<MapBoard> MB;
|
||||
MB = LogicFacade.GetAllMapColoumns();
|
||||
LinkedHashMap<Integer, MapBoard> LHM = new LinkedHashMap();
|
||||
for (int i = 0; i < MB.size(); i++) {
|
||||
LHM.put(i, MB.get(i));
|
||||
}
|
||||
return LHM;
|
||||
}
|
||||
|
||||
private Map<Integer, Users> getUserPointCacheContent(List<Users> PlayerLeaderBoard, List<MapBoard> mapBoard) throws ErrorMessageDisplay, SQLException, IOException, PropertyVetoException {
|
||||
List<Users> Users;
|
||||
Users = LogicFacade.getPlayerPointsAndRankInitialization(PlayerLeaderBoard, mapBoard);
|
||||
LinkedHashMap<Integer, Users> LHM = new LinkedHashMap();
|
||||
for (int i = 0; i < Users.size(); i++) {
|
||||
LHM.put(i, Users.get(i));
|
||||
}
|
||||
return LHM;
|
||||
}
|
||||
|
||||
private Map<Integer, MapBoard> getMapBoardCacheValues(List<MapBoard> mapBoard, List<Users> PlayerLeaderBoard) throws ErrorMessageDisplay {
|
||||
List<MapBoard> MB;
|
||||
MB = LogicFacade.getAllMapValues(mapBoard, PlayerLeaderBoard);
|
||||
LinkedHashMap<Integer, MapBoard> LHM = new LinkedHashMap();
|
||||
for (int i = 0; i < MB.size(); i++) {
|
||||
LHM.put(i, MB.get(i));
|
||||
}
|
||||
return LHM;
|
||||
}
|
||||
|
||||
private Map<Integer, UserBanners> getUserBannerCacheContent(List<Users> PlayerLeaderBoard) throws ErrorMessageDisplay {
|
||||
List<UserBanners> UB;
|
||||
UB = LogicFacade.getUserBanners(PlayerLeaderBoard);
|
||||
LinkedHashMap<Integer, UserBanners> LHM = new LinkedHashMap();
|
||||
for (int i = 0; i < UB.size(); i++) {
|
||||
LHM.put(i, UB.get(i));
|
||||
}
|
||||
return LHM;
|
||||
}
|
||||
|
||||
private Map<Integer, Users> getUserTimeCache(List<Users> PlayerLeaderBoard, List<MapBoard> mapBoard) {
|
||||
List<Users> Users;
|
||||
Users = LogicFacade.getPlayertimeAmount(PlayerLeaderBoard, mapBoard);
|
||||
LinkedHashMap<Integer, Users> LHM = new LinkedHashMap();
|
||||
for (int i = 0; i < Users.size(); i++) {
|
||||
LHM.put(i, Users.get(i));
|
||||
}
|
||||
return LHM;
|
||||
}
|
||||
|
||||
public List<MapBoard> getAllMapValues() {
|
||||
List<MapBoard> MapColoumns = new ArrayList(MapCacheValues.values());
|
||||
return MapColoumns;
|
||||
}
|
||||
|
||||
public List<UserBanners> getUserBanners() {
|
||||
List<UserBanners> UB = new ArrayList(UserBannerCache.values());
|
||||
return UB;
|
||||
}
|
||||
|
||||
public List<Users> getAllPlayerValues() {
|
||||
List<Users> Users = new ArrayList(UserCacheTimeAmount.values());
|
||||
return Users;
|
||||
}
|
||||
|
||||
public List<RecentTimes> getAllRecentTimes() {
|
||||
List<RecentTimes> RT = new ArrayList(UserCacheRecentTimes.values());
|
||||
return RT;
|
||||
}
|
||||
|
||||
public int getAvatatindexTest() {
|
||||
return AVATAR_INDEXES;
|
||||
}
|
||||
|
||||
public int getUPDATE_AVATARS_CYCLE() {
|
||||
return UPDATE_AVATARS_CYCLE;
|
||||
}
|
||||
|
||||
public int getStopWatchMinutes() {
|
||||
return (int) stopwatch.elapsed(TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
private void clearConcurrentMaps() {
|
||||
UsersCache.clear();
|
||||
MapCache.clear();
|
||||
UsersCachePoints.clear();
|
||||
MapCacheValues.clear();
|
||||
UserBannerCache.clear();
|
||||
UserCacheTimeAmount.clear();
|
||||
UserCacheRecentTimes.clear();
|
||||
}
|
||||
|
||||
private void putAllConcurrentMaps() throws SQLException, ErrorMessageDisplay, IOException, PropertyVetoException {
|
||||
UsersCache.putAll(getUserCacheContent());
|
||||
MapCache.putAll(getMapBoardCacheContent());
|
||||
UsersCachePoints.putAll(getUserPointCacheContent(new ArrayList(UsersCache.values()), new ArrayList(MapCache.values())));
|
||||
MapCacheValues.putAll(getMapBoardCacheValues(new ArrayList(MapCache.values()), new ArrayList(UsersCachePoints.values())));
|
||||
UserBannerCache.putAll(getUserBannerCacheContent(new ArrayList(UsersCachePoints.values())));
|
||||
UserCacheTimeAmount.putAll(getUserTimeCache(new ArrayList(UsersCachePoints.values()), new ArrayList(MapCacheValues.values())));
|
||||
UserCacheRecentTimes.putAll(getUserRecentTimesCache(UserCacheTimeAmount, MapCacheValues));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package FunctionLayer.Caching;
|
||||
|
||||
import FunctionLayer.ErrorMessageDisplay;
|
||||
import FunctionLayer.LogicFacade;
|
||||
import FunctionLayer.MapBoard;
|
||||
import FunctionLayer.Users;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Suppliers;
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class Guava {
|
||||
|
||||
//https://www.tutorialspoint.com/guava/guava_caching_utilities.htm
|
||||
//https://stackoverflow.com/questions/31576136/how-should-i-implement-guava-cache-when-i-plan-to-cache-multiple-values-efficien
|
||||
/**
|
||||
* @deprecated @return the same list with Values for Usernames, steam ids
|
||||
* and avatars on initializing being set
|
||||
* @throws ErrorMessageDisplay
|
||||
*/
|
||||
public List<Users> getAllUsersNameSteamIdInitialization() throws ErrorMessageDisplay {
|
||||
Supplier<List<Users>> fulllist = Suppliers.memoize(() -> {
|
||||
List<Users> users = new ArrayList();
|
||||
try {
|
||||
users = LogicFacade.getAllUsersNameSteamIdInitialization();
|
||||
} catch (SQLException | ErrorMessageDisplay | IOException | PropertyVetoException ex) {
|
||||
Logger.getLogger(Guava.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return users;
|
||||
});
|
||||
return fulllist.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return
|
||||
*/
|
||||
public List<MapBoard> GetAllMapColoumns() {
|
||||
Supplier<List<MapBoard>> fulllist = Suppliers.memoize(() -> {
|
||||
List<MapBoard> MapColoumns = new ArrayList();
|
||||
try {
|
||||
MapColoumns = LogicFacade.GetAllMapColoumns();
|
||||
} catch (SQLException | ErrorMessageDisplay | IOException | PropertyVetoException ex) {
|
||||
Logger.getLogger(Guava.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return MapColoumns;
|
||||
});
|
||||
return fulllist.get();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* @deprecated @param PlayerLeaderBoard
|
||||
* @return
|
||||
|
||||
public List<Users> getAllUsersNameSteamIdUpdates(List<Users> PlayerLeaderBoard) {
|
||||
Supplier<List<Users>> fulllist = Suppliers.memoize(() -> {
|
||||
List<Users> users = new ArrayList();
|
||||
try {
|
||||
users = LogicFacade.getAllUsersNameSteamIdUpdates(PlayerLeaderBoard);
|
||||
} catch (SQLException | ErrorMessageDisplay | IOException | PropertyVetoException ex) {
|
||||
Logger.getLogger(Guava.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return users;
|
||||
});
|
||||
return fulllist.get();
|
||||
}*/
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @param PlayerLeaderBoard
|
||||
* @param mapBoard
|
||||
* @return
|
||||
*/
|
||||
public List<Users> getPlayerPointsAndRankInitialization(List<Users> PlayerLeaderBoard, List<MapBoard> mapBoard) {
|
||||
Supplier<List<Users>> fulllist = Suppliers.memoize(() -> {
|
||||
List<Users> users = new ArrayList();
|
||||
try {
|
||||
users = LogicFacade.getPlayerPointsAndRankInitialization(PlayerLeaderBoard, mapBoard);
|
||||
} catch (SQLException | ErrorMessageDisplay | IOException | PropertyVetoException ex) {
|
||||
Logger.getLogger(Guava.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return users;
|
||||
});
|
||||
return fulllist.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @param PlayerLeaderBoard
|
||||
* @param mapBoard
|
||||
* @return
|
||||
*/
|
||||
public List<Users> getPlayerPointsAndRankUpdates(List<Users> PlayerLeaderBoard, List<MapBoard> mapBoard) {
|
||||
Supplier<List<Users>> fulllist = Suppliers.memoize(() -> {
|
||||
List<Users> users = new ArrayList();
|
||||
try {
|
||||
users = LogicFacade.getPlayerPointsAndRankUpdates(PlayerLeaderBoard, mapBoard);
|
||||
} catch (SQLException | ErrorMessageDisplay | IOException | PropertyVetoException ex) {
|
||||
Logger.getLogger(Guava.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return users;
|
||||
});
|
||||
return fulllist.get();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package FunctionLayer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class ErrorMessageDisplay extends Exception {
|
||||
|
||||
public ErrorMessageDisplay(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,424 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package FunctionLayer;
|
||||
|
||||
import DBAcess.DataMapper;
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class LogicFacade {
|
||||
|
||||
public static List<MapBoard> GetAllMapColoumns() throws ErrorMessageDisplay, SQLException, IOException, PropertyVetoException {
|
||||
List<MapBoard> AllMapColoumns = DataMapper.GetAllMapColoumns();
|
||||
AllMapColoumns = MapNameUpdate(AllMapColoumns);
|
||||
return AllMapColoumns;
|
||||
}
|
||||
|
||||
public static List<Users> getAllUsersNameSteamIdInitialization() throws SQLException, ErrorMessageDisplay, IOException, PropertyVetoException {
|
||||
List<Users> users = DataMapper.getAllUsersNameSteamIdInitialization();
|
||||
users = DataMapper.SetUsersAvatars(users);
|
||||
return users;
|
||||
}
|
||||
|
||||
private static List<MapBoard> MapNameUpdate(List<MapBoard> AllMapColoumns) {
|
||||
int l_iLength = 0;
|
||||
StringBuilder sb;
|
||||
for (int i = 0; i < AllMapColoumns.size(); i++) {
|
||||
l_iLength = AllMapColoumns.get(i).getMapName().length() - 1;
|
||||
while (Character.isDigit(AllMapColoumns.get(i).getMapName().charAt(l_iLength))) {
|
||||
l_iLength--;
|
||||
}
|
||||
if (AllMapColoumns.get(i).getMapName().charAt(l_iLength) == 'S') {
|
||||
sb = new StringBuilder();
|
||||
sb = sb.append(AllMapColoumns.get(i).getMapName().substring(0, l_iLength));
|
||||
AllMapColoumns.get(i).setMapName(sb.toString() + " Stage: "
|
||||
+ AllMapColoumns.get(i).getMapName().substring(l_iLength + 1, AllMapColoumns.get(i).getMapName().length()));
|
||||
}
|
||||
}
|
||||
return AllMapColoumns;
|
||||
}
|
||||
|
||||
private static List<RecentTimes> MapNameUpdateRecentTimes(List<RecentTimes> AllRecentTimes) {
|
||||
int l_iLength = 0;
|
||||
StringBuilder sb;
|
||||
for (int i = 0; i < AllRecentTimes.size(); i++) {
|
||||
l_iLength = AllRecentTimes.get(i).getMYSQLStage().length() - 1;
|
||||
while (Character.isDigit(AllRecentTimes.get(i).getMYSQLStage().charAt(l_iLength))) {
|
||||
l_iLength--;
|
||||
}
|
||||
if (AllRecentTimes.get(i).getMYSQLStage().charAt(l_iLength) == 'S') {
|
||||
sb = new StringBuilder();
|
||||
sb = sb.append(AllRecentTimes.get(i).getMYSQLStage().substring(0, l_iLength));
|
||||
AllRecentTimes.get(i).setMYSQLStage(sb.toString() + " Stage: "
|
||||
+ AllRecentTimes.get(i).getMYSQLStage().substring(l_iLength + 1, AllRecentTimes.get(i).getMYSQLStage().length()));
|
||||
}
|
||||
}
|
||||
return AllRecentTimes;
|
||||
}
|
||||
|
||||
public synchronized static void UpdatePlayerAvatarsToDB(List<Users> userAvatarLinks, int AVATAR_INDEXES1) throws IOException, ErrorMessageDisplay {
|
||||
List<String> ConvertedID = new ArrayList();
|
||||
int indexRange = AVATAR_INDEXES1;
|
||||
if (AVATAR_INDEXES1 + 200 >= userAvatarLinks.size()) {
|
||||
indexRange = userAvatarLinks.size();
|
||||
} else {
|
||||
indexRange += 200;
|
||||
}
|
||||
for (int i = AVATAR_INDEXES1; i < indexRange; i++) {
|
||||
ConvertedID.add(Long.toString(convertSteamIdToCommunityId(userAvatarLinks.get(i).getSteamID())));
|
||||
}
|
||||
DataMapper.UpdatePlayerAvatarsToDB(userAvatarLinks, ConvertedID, AVATAR_INDEXES1, indexRange);
|
||||
}
|
||||
|
||||
public static long convertSteamIdToCommunityId(String steamId) {
|
||||
if (steamId.matches("^STEAM_[0-1]:[0-1]:[0-9]+$")) {
|
||||
String[] tmpId = steamId.substring(8).split(":");
|
||||
return Long.valueOf(tmpId[0]) + Long.valueOf(tmpId[1]) * 2 + 76561197960265728L; //76561197960265728L
|
||||
} else if (steamId.matches("^\\[U:[0-1]:[0-9]+\\]+$")) {
|
||||
String[] tmpId = steamId.substring(3, steamId.length() - 1).split(":");
|
||||
return Long.valueOf(tmpId[0]) + Long.valueOf(tmpId[1]) + 76561197960265728L; //76561197960265727L
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static Users getUser(String PlayerIndexSteamID, List<Users> users, List<MapBoard> mapBoard) throws ErrorMessageDisplay {
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
if (users.get(i).getSteamID().equals(PlayerIndexSteamID)) {
|
||||
Users user = users.get(i);
|
||||
return user;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<Users> getPlayerPointsAndRankInitialization(List<Users> LeaderBoard, List<MapBoard> AllMapColoumns) throws ErrorMessageDisplay, SQLException, IOException, PropertyVetoException {
|
||||
LinkedHashMap<Users, Float> usertimes;
|
||||
int Points = 0;
|
||||
int index = 0;
|
||||
LinkedHashMap<String, Users> HM = new LinkedHashMap();
|
||||
List<Users> tempusers;
|
||||
/*
|
||||
AllMapColoumns roughly 58 itterations currently
|
||||
LeaderBoard around 1500(?) right now
|
||||
*/
|
||||
for (int i = 0; i < LeaderBoard.size(); i++) {
|
||||
HM.put(LeaderBoard.get(i).getSteamID(), LeaderBoard.get(i));
|
||||
}
|
||||
for (int i = 0; i < AllMapColoumns.size(); i++) {
|
||||
usertimes = DataMapper.GetMapTimes(ConvertPageNameToDBName(AllMapColoumns.get(i).getMapName()), LeaderBoard, HM);
|
||||
tempusers = new ArrayList(usertimes.keySet());
|
||||
for (int j = 0; j < tempusers.size(); j++) {
|
||||
Points = ConvertPositionToPoints(j, tempusers.size(), Points);
|
||||
Users user = HM.get(tempusers.get(j).getSteamID());
|
||||
if (user != null) {
|
||||
index = LeaderBoard.indexOf(user);
|
||||
LeaderBoard.get(index).setPlayerPoints(LeaderBoard.get(index).getPlayerPoints() + Points);
|
||||
}
|
||||
}
|
||||
}
|
||||
LeaderBoard.sort(Comparator.comparing(Users::getPlayerPoints).reversed());
|
||||
for (int i = 0; i < LeaderBoard.size(); i++) {
|
||||
LeaderBoard.get(i).setRank(i + 1);
|
||||
}
|
||||
return LeaderBoard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated @param LeaderBoard
|
||||
* @param AllMapColoumns
|
||||
* @return
|
||||
* @throws ErrorMessageDisplay
|
||||
* @throws SQLException
|
||||
* @throws IOException
|
||||
* @throws PropertyVetoException
|
||||
*/
|
||||
public static List<Users> getPlayerPointsAndRankUpdates(List<Users> LeaderBoard, List<MapBoard> AllMapColoumns) throws ErrorMessageDisplay, SQLException, IOException, PropertyVetoException {
|
||||
LinkedHashMap<Users, Float> usertimes;
|
||||
int Points = 0;
|
||||
int index = 0;
|
||||
LinkedHashMap<String, Users> HM = new LinkedHashMap();
|
||||
List<Users> tempusers;
|
||||
for (int i = 0; i < LeaderBoard.size(); i++) {
|
||||
HM.put(LeaderBoard.get(i).getSteamID(), LeaderBoard.get(i));
|
||||
}
|
||||
//grab ingame players and currently played map, only update those
|
||||
//this means max 64 players can get updated and only stages on one map
|
||||
MapBoard map = DataMapper.getCurrentMap();
|
||||
List<MapBoard> MapLvls = DataMapper.getCurrentMapLevels(map);
|
||||
List<String> IngamePlayersSteamID = DataMapper.getHlstatsxIngamePlayerSteamID();
|
||||
List<Users> IngamePlayers = ConvertSteam3ToSteam2(IngamePlayersSteamID, HM);
|
||||
for (int i = 0; i < MapLvls.size(); i++) {
|
||||
usertimes = DataMapper.GetMapTimes(ConvertPageNameToDBName(MapLvls.get(i).getMapName()), IngamePlayers, HM);
|
||||
tempusers = new ArrayList(usertimes.keySet());
|
||||
for (int j = 0; j < tempusers.size(); j++) {
|
||||
Points = ConvertPositionToPoints(j, tempusers.size(), Points);
|
||||
Users user = HM.get(tempusers.get(j).getSteamID());
|
||||
if (user != null) {
|
||||
index = LeaderBoard.indexOf(user);
|
||||
LeaderBoard.get(index).setPlayerPoints(LeaderBoard.get(index).getPlayerPoints() + Points);
|
||||
}
|
||||
}
|
||||
}
|
||||
LeaderBoard.sort(Comparator.comparing(Users::getPlayerPoints).reversed());
|
||||
for (int i = 0; i < LeaderBoard.size(); i++) {
|
||||
LeaderBoard.get(i).setRank(i + 1);
|
||||
}
|
||||
return LeaderBoard;
|
||||
}
|
||||
|
||||
public static int GetAdmin(String name, String psw) throws ErrorMessageDisplay {
|
||||
return DataMapper.GetAdmin(name, psw);
|
||||
}
|
||||
|
||||
public static void DeleteMapEntry(String map, String SteamID) throws ErrorMessageDisplay {
|
||||
map = ConvertPageNameToDBName(map);
|
||||
//throw new ErrorMessageDisplay("failed in logicfacade. map: " + map + " steam: " + SteamID);
|
||||
DataMapper.DeleteMapEntry(map, SteamID);
|
||||
}
|
||||
|
||||
private static String ConvertPageNameToDBName(String map) throws ErrorMessageDisplay {
|
||||
StringBuilder sb;
|
||||
int Stage = 0;
|
||||
int l_iLength = map.length() - 1; //maybe -1
|
||||
if (Character.isDigit(map.charAt(l_iLength)) && map.contains("Stage:")) {
|
||||
while (Character.isDigit(map.charAt(l_iLength))) {
|
||||
l_iLength--;
|
||||
}
|
||||
l_iLength++;
|
||||
if (l_iLength < map.length()) {
|
||||
Stage = Integer.valueOf(map.substring(l_iLength, map.length()));
|
||||
}
|
||||
l_iLength -= 8;
|
||||
sb = new StringBuilder();
|
||||
sb = sb.append(map.substring(0, l_iLength)).append("S").append(Stage);
|
||||
map = sb.toString();
|
||||
}
|
||||
//throw new ErrorMessageDisplay("failed in logicfacade. ConvertPageNameToDBName: " + map);
|
||||
return map;
|
||||
}
|
||||
|
||||
private static List<Users> ConvertSteam3ToSteam2(List<String> IngamePlayersSteamID, Map<String, Users> HM) {
|
||||
List<Users> IngamePlayers = new ArrayList();
|
||||
String Convert3To64To2 = "";
|
||||
for (int i = 0; i < IngamePlayersSteamID.size(); i++) {
|
||||
if (IngamePlayersSteamID.get(i).contains("U")) {
|
||||
Convert3To64To2 = convertCommunityIdToSteamId(convertSteamIdToCommunityId(IngamePlayersSteamID.get(i)));
|
||||
} else {
|
||||
Convert3To64To2 = IngamePlayersSteamID.get(i);
|
||||
}
|
||||
Users user = HM.get(Convert3To64To2);
|
||||
if (user != null) {
|
||||
IngamePlayers.add(user);
|
||||
}
|
||||
}
|
||||
return IngamePlayers;
|
||||
}
|
||||
|
||||
public static String convertCommunityIdToSteamId(long communityId) {
|
||||
long steamId1 = communityId % 2;
|
||||
long steamId2 = communityId - 76561197960265728L;
|
||||
steamId2 = (steamId2 - steamId1) / 2;
|
||||
return "STEAM_0:" + steamId1 + ":" + steamId2;
|
||||
}
|
||||
|
||||
public static Map<String, String> getAllAdmins() throws ErrorMessageDisplay {
|
||||
Map<String, String> HM = DataMapper.getAllAdmins();
|
||||
return HM;
|
||||
}
|
||||
|
||||
public static void createAdmin(String name, String password, String role) throws ErrorMessageDisplay {
|
||||
DataMapper.createAdmin(name, password, role);
|
||||
}
|
||||
|
||||
public static List<MapBoard> getAllMapValues(List<MapBoard> AllMapColoumns, List<Users> LeaderBoard) throws ErrorMessageDisplay {
|
||||
List<MapBoard> AllMapColoumnsToDB = new ArrayList();
|
||||
List<MapValues> mvListnull = new ArrayList();
|
||||
MapBoard maps;
|
||||
Map<String, Users> HM = new HashMap();
|
||||
List<MapBoard> allMapBoards = new ArrayList();
|
||||
LinkedHashMap<Users, Float> MapRelatedHashMap;
|
||||
List<Users> HashmaprelatedUsers;
|
||||
List<Float> HashmaprelatedFloats;
|
||||
int MapPoints = 0;
|
||||
for (int i = 0; i < AllMapColoumns.size(); i++) {
|
||||
maps = new MapBoard(ConvertPageNameToDBName(AllMapColoumns.get(i).getMapName()), mvListnull);
|
||||
AllMapColoumnsToDB.add(maps);
|
||||
}
|
||||
for (int i = 0; i < LeaderBoard.size(); i++) {
|
||||
HM.put(LeaderBoard.get(i).getSteamID(), LeaderBoard.get(i));
|
||||
}
|
||||
// something goes wrong here as in retrieving maps
|
||||
for (int i = 0; i < AllMapColoumns.size(); i++) {
|
||||
List<MapValues> mvList = new ArrayList();
|
||||
MapRelatedHashMap = new LinkedHashMap(DataMapper.GetMapRelatedTimes(AllMapColoumnsToDB.get(i), LeaderBoard, HM));
|
||||
HashmaprelatedUsers = new ArrayList(MapRelatedHashMap.keySet());
|
||||
HashmaprelatedFloats = new ArrayList(MapRelatedHashMap.values());
|
||||
|
||||
for (int j = 0; j < MapRelatedHashMap.size(); j++) {
|
||||
MapPoints = ConvertPositionToPoints(j, HashmaprelatedUsers.size(), MapPoints);
|
||||
MapValues mv1 = new MapValues(j, HashmaprelatedUsers.get(j), HashmaprelatedFloats.get(j), MapPoints);
|
||||
mvList.add(mv1);
|
||||
}
|
||||
maps = new MapBoard(AllMapColoumns.get(i).getMapName(), mvList);
|
||||
allMapBoards.add(maps);
|
||||
/*
|
||||
if (i > 45) {
|
||||
throw new ErrorMessageDisplay("map: " + allMapBoards.get(i).getMapName()
|
||||
+ " time: " + allMapBoards.get(i).getMapvalues().get(0).getTime() + " allMapBoards size: " + allMapBoards.size()
|
||||
+ " allMapBoards mapvalues size: " + allMapBoards.get(i).getMapvalues().size() + " allMapBoards.get(i).getMapvalues().get(0).getUser().getName(): " + allMapBoards.get(i).getMapvalues().get(0).getUser().getName()); //getMapvalues().get(0) is trobuel
|
||||
}
|
||||
*/
|
||||
}
|
||||
return allMapBoards;
|
||||
}
|
||||
|
||||
public static List<MapBoard> getPlayerRelatedMapBoard(List<MapBoard> mapBoard, Users user) throws ErrorMessageDisplay {
|
||||
List<MapBoard> newMapBoard = new ArrayList();
|
||||
int index = 0;
|
||||
for (int j = 0; j < mapBoard.size(); j++) {
|
||||
for (int i = 0; i < mapBoard.get(j).getMapvalues().size(); i++) {
|
||||
if (mapBoard.get(j).getMapvalues().get(i).getUser().equals(user)) {
|
||||
newMapBoard.add(mapBoard.get(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
//throw new ErrorMessageDisplay("newMapBoard size: " + newMapBoard.size() + " mapBoard size: " + mapBoard.size());
|
||||
return newMapBoard;
|
||||
}
|
||||
|
||||
public static List<Integer> getPlayerPositions(List<MapBoard> PlayerRelatedMapBoard, Users user) {
|
||||
List<Integer> PlayerPositions = new ArrayList();
|
||||
int index = 0;
|
||||
for (int i = 0; i < PlayerRelatedMapBoard.size(); i++) {
|
||||
for (int j = 0; j < PlayerRelatedMapBoard.get(i).getMapvalues().size(); j++) {
|
||||
if (PlayerRelatedMapBoard.get(i).getMapvalues().get(j).getUser().equals(user)) {
|
||||
PlayerPositions.add(PlayerRelatedMapBoard.get(i).getMapvalues().get(j).getPosition());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return PlayerPositions;
|
||||
}
|
||||
|
||||
public static int getMapIndex(List<MapBoard> mapBoard, String map) throws ErrorMessageDisplay {
|
||||
int index = 0;
|
||||
for (int i = 0; i < mapBoard.size(); i++) {
|
||||
if (mapBoard.get(i).getMapName().equals(map)) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//throw new ErrorMessageDisplay("getMapIndex: " + index + " map: " + map + " mapBoard.get(i).getMapName(): " + mapBoard.get(0).getMapName());
|
||||
return index;
|
||||
}
|
||||
|
||||
public static List<UserBanners> getUserBanners(List<Users> PlayerLeaderBoard) throws ErrorMessageDisplay {
|
||||
List<String> ConvertedID = new ArrayList();
|
||||
for (int i = 0; i < PlayerLeaderBoard.size(); i++) {
|
||||
ConvertedID.add(Long.toString(convertSteamIdToCommunityId(PlayerLeaderBoard.get(i).getSteamID())));
|
||||
}
|
||||
List<UserBanners> UBList = DataMapper.getUserbanners(PlayerLeaderBoard, ConvertedID);
|
||||
Collections.sort(UBList, (o1, o2) -> o1.getUser().getRank() - o2.getUser().getRank());
|
||||
/*
|
||||
throw new ErrorMessageDisplay("UBList 0: " + UBList.get(0).getUser().getName()
|
||||
+ " UBlist 1: " + UBList.get(1).getUser().getName() + " PlayerLeaderBoard 0: " + PlayerLeaderBoard.get(0).getName() + " PlayerLeaderBoard 1: "
|
||||
+ PlayerLeaderBoard.get(1).getName() + " UBlist size: " + UBList.size() + " PlayerLeaderBoard size: " + PlayerLeaderBoard.size());
|
||||
*/
|
||||
return UBList;
|
||||
}
|
||||
|
||||
public static List<Users> getPlayertimeAmount(List<Users> PlayerLeaderBoard, List<MapBoard> mapBoard) {
|
||||
boolean test = false;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (PlayerLeaderBoard.get(i).getTimes() > 0) {
|
||||
test = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!test) {
|
||||
for (int i = 0; i < mapBoard.size(); i++) {
|
||||
for (int j = 0; j < mapBoard.get(i).getMapvalues().size(); j++) {
|
||||
int index = PlayerLeaderBoard.indexOf(mapBoard.get(i).getMapvalues().get(j).getUser());
|
||||
PlayerLeaderBoard.get(index).setTimes(PlayerLeaderBoard.get(index).getTimes() + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return PlayerLeaderBoard;
|
||||
}
|
||||
|
||||
public static LinkedHashMap<Integer, RecentTimes> getRecentTimes(ConcurrentMap<Integer, Users> UserCacheTimeAmount1, ConcurrentMap<Integer, MapBoard> mpb) throws ErrorMessageDisplay {
|
||||
List<RecentTimes> RT = DataMapper.getRecentTimes();
|
||||
RT = MapNameUpdateRecentTimes(RT);
|
||||
List<Users> userlist = new ArrayList(UserCacheTimeAmount1.values());
|
||||
List<MapBoard> mpblist = new ArrayList(mpb.values());
|
||||
LinkedHashMap<Integer, RecentTimes> LHM = new LinkedHashMap();
|
||||
for (int i = 0; i < RT.size(); i++) {
|
||||
String RTSteamID = RT.get(i).getMYSQLSteamID();
|
||||
int index = userlist.indexOf(UserCacheTimeAmount1.entrySet().stream().filter(e -> e.getValue().getSteamID().equals(RTSteamID)).findFirst().get().getValue());
|
||||
Users user = userlist.get(index);
|
||||
RT.get(i).setUser(user);
|
||||
String mapname = RT.get(i).getMYSQLStage();
|
||||
index = mpblist.indexOf(mpb.entrySet().stream().filter(e -> e.getValue().getMapName().equals(mapname)).findFirst().get().getValue());
|
||||
int index2 = -1;
|
||||
if (mpblist.get(index).getMapvalues().stream().filter(e -> e.getUser().getSteamID()
|
||||
.equals(user.getSteamID())).findFirst().isPresent()) {
|
||||
index2 = mpblist.get(index).getMapvalues().indexOf(mpblist.get(index)
|
||||
.getMapvalues().stream().filter(e -> e.getUser().getSteamID().equals(user.getSteamID())).findFirst().get());
|
||||
}
|
||||
if (index2 != -1) {
|
||||
if (mpblist.get(index).getMapvalues().get(index2).getUser() == null) {
|
||||
throw new ErrorMessageDisplay("user is also null!");
|
||||
}
|
||||
float test = mpblist.get(index).getMapvalues().get(index2).getTime();
|
||||
float newtime = test;
|
||||
try {
|
||||
int minutesval = (((int) RT.get(i).getMYSQLOldTime()) * 60);
|
||||
float secondsval = (RT.get(i).getMYSQLOldTime() - (int) RT.get(i).getMYSQLOldTime()) * 100;
|
||||
int newminutesval = (((int) newtime) * 60);
|
||||
float newsecondsval = (newtime - (int) newtime) * 100;
|
||||
float improvedTime = (minutesval + secondsval) - (newminutesval + newsecondsval);
|
||||
minutesval = (int) improvedTime / 60;
|
||||
secondsval = (improvedTime - (minutesval * 60));
|
||||
secondsval *= 0.01;
|
||||
improvedTime = minutesval + secondsval;
|
||||
//174,999 - 50,1 = 124.899 / 60 = 2 * 60 = 120. 124.899 - 120 = 4.899 * 0.01 = 0.04899 + 2 = 2.04899.
|
||||
// 2 minutes and 4 seconds, 8.99 milliseconds
|
||||
RT.get(i).setImprovedTime(improvedTime);
|
||||
} catch (Exception ex) {
|
||||
throw new ErrorMessageDisplay("getRecentTimes: " + ex.getMessage() + " mapname: " + mapname + " user: " + user.getName() + " index: " + index);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < RT.size(); i++) {
|
||||
LHM.put(i, RT.get(i));
|
||||
}
|
||||
return LHM;
|
||||
}
|
||||
|
||||
public boolean containsSteamID(final List<Users> list, final String name) {
|
||||
return list.stream().map(Users::getSteamID).filter(name::equals).findFirst().isPresent();
|
||||
}
|
||||
|
||||
public static int ConvertPositionToPoints(int Position, int PlayerCount, int Points) {
|
||||
float li = 0;
|
||||
li = PlayerCount - Position;
|
||||
Points = (int) Math.floor((li / PlayerCount) * 100);
|
||||
return Points;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package FunctionLayer;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class MapBoard {
|
||||
|
||||
private String mapName;
|
||||
private List<MapValues> mapvalues;
|
||||
|
||||
public String getMapName() {
|
||||
return mapName;
|
||||
}
|
||||
|
||||
public void setMapName(String mapName) {
|
||||
this.mapName = mapName;
|
||||
}
|
||||
|
||||
public List<MapValues> getMapvalues() {
|
||||
return mapvalues;
|
||||
}
|
||||
|
||||
public void setMapvalues(List<MapValues> mapvalues) {
|
||||
this.mapvalues = mapvalues;
|
||||
}
|
||||
|
||||
public MapBoard(String mapName, List<MapValues> mapvalues) {
|
||||
this.mapName = mapName;
|
||||
this.mapvalues = mapvalues;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package FunctionLayer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class MapValues {
|
||||
private int position;
|
||||
private Users user;
|
||||
private float time;
|
||||
private int mapPoints;
|
||||
|
||||
public MapValues(int position, Users user, float time, int mapPoints) {
|
||||
this.position = position;
|
||||
this.user = user;
|
||||
this.time = time;
|
||||
this.mapPoints = mapPoints;
|
||||
}
|
||||
|
||||
public int getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setPosition(int position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public Users getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(Users user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public float getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(float time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public int getMapPoints() {
|
||||
return mapPoints;
|
||||
}
|
||||
|
||||
public void setMapPoints(int mapPoints) {
|
||||
this.mapPoints = mapPoints;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package FunctionLayer;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class Maps {
|
||||
|
||||
private String name;
|
||||
private int Points;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getPoints() {
|
||||
return Points;
|
||||
}
|
||||
|
||||
public void setPoints(int Points) {
|
||||
this.Points = Points;
|
||||
}
|
||||
|
||||
public Maps(String name, int Points) {
|
||||
this.name = name;
|
||||
this.Points = Points;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package FunctionLayer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class RecentTimes {
|
||||
|
||||
private String MYSQLSteamID;
|
||||
private String MYSQLStage;
|
||||
private float MYSQLOldTime;
|
||||
private Users user;
|
||||
private float improvedTime;
|
||||
//in jsp use user object for displaying avatar, steam id, link to user site, improvedtime for showing improved time, stage for displaying what stage on what map
|
||||
|
||||
public RecentTimes(String MYSQLSteamID, String MYSQLStage, float MYSQLOldTime, Users user, float improvedTime) {
|
||||
this.MYSQLSteamID = MYSQLSteamID;
|
||||
this.MYSQLStage = MYSQLStage;
|
||||
this.MYSQLOldTime = MYSQLOldTime;
|
||||
this.user = user;
|
||||
this.improvedTime = improvedTime;
|
||||
}
|
||||
|
||||
public String getMYSQLSteamID() {
|
||||
return MYSQLSteamID;
|
||||
}
|
||||
|
||||
public void setMYSQLSteamID(String MYSQLSteamID) {
|
||||
this.MYSQLSteamID = MYSQLSteamID;
|
||||
}
|
||||
|
||||
public String getMYSQLStage() {
|
||||
return MYSQLStage;
|
||||
}
|
||||
|
||||
public void setMYSQLStage(String MYSQLStage) {
|
||||
this.MYSQLStage = MYSQLStage;
|
||||
}
|
||||
|
||||
public float getMYSQLOldTime() {
|
||||
return MYSQLOldTime;
|
||||
}
|
||||
|
||||
public void setMYSQLOldTime(float MYSQLOldTime) {
|
||||
this.MYSQLOldTime = MYSQLOldTime;
|
||||
}
|
||||
|
||||
public Users getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(Users user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public float getImprovedTime() {
|
||||
return improvedTime;
|
||||
}
|
||||
|
||||
public void setImprovedTime(float improvedTime) {
|
||||
this.improvedTime = improvedTime;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package FunctionLayer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class UserBanners {
|
||||
|
||||
private List<Integer> UrlBanners;
|
||||
private Users user;
|
||||
|
||||
public UserBanners(List<Integer> UrlBanners, Users user) {
|
||||
this.UrlBanners = UrlBanners;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public List<Integer> getUrlBanners() {
|
||||
return UrlBanners;
|
||||
}
|
||||
|
||||
public void setUrlBanners(List<Integer> UrlBanners) {
|
||||
this.UrlBanners = UrlBanners;
|
||||
}
|
||||
|
||||
public Users getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(Users user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof UserBanners) {
|
||||
UserBanners p = (UserBanners) o;
|
||||
return this.user.equals(p.getUser());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package FunctionLayer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class Users {
|
||||
private String steamID;
|
||||
private String name;
|
||||
private String Avatar;
|
||||
private int Rank;
|
||||
private int PlayerPoints;
|
||||
private int Times;
|
||||
|
||||
public Users(String steamID, String name, String Avatar, int Rank, int PlayerPoints, int Times) {
|
||||
this.steamID = steamID;
|
||||
this.name = name;
|
||||
this.Avatar = Avatar;
|
||||
this.Rank = Rank;
|
||||
this.PlayerPoints = PlayerPoints;
|
||||
this.Times = Times;
|
||||
}
|
||||
|
||||
public String getSteamID() {
|
||||
return steamID;
|
||||
}
|
||||
|
||||
public void setSteamID(String steamID) {
|
||||
this.steamID = steamID;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return Avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String Avatar) {
|
||||
this.Avatar = Avatar;
|
||||
}
|
||||
|
||||
public int getRank() {
|
||||
return Rank;
|
||||
}
|
||||
|
||||
public void setRank(int Rank) {
|
||||
this.Rank = Rank;
|
||||
}
|
||||
|
||||
public int getPlayerPoints() {
|
||||
return PlayerPoints;
|
||||
}
|
||||
|
||||
public void setPlayerPoints(int PlayerPoints) {
|
||||
this.PlayerPoints = PlayerPoints;
|
||||
}
|
||||
|
||||
public int getTimes() {
|
||||
return Times;
|
||||
}
|
||||
|
||||
public void setTimes(int Times) {
|
||||
this.Times = Times;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package Presentation;
|
||||
|
||||
import FunctionLayer.ErrorMessageDisplay;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class AdminLogin extends Command {
|
||||
@Override
|
||||
String execute(HttpServletRequest request, HttpServletResponse response) throws ErrorMessageDisplay {
|
||||
|
||||
return "AdminLogin";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package Presentation;
|
||||
|
||||
import FunctionLayer.ErrorMessageDisplay;
|
||||
import FunctionLayer.LogicFacade;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class Authenticatelogin extends Command {
|
||||
|
||||
@Override
|
||||
String execute(HttpServletRequest request, HttpServletResponse response) throws ErrorMessageDisplay {
|
||||
String name = request.getParameter("uname");
|
||||
String psw = request.getParameter("psw");
|
||||
int VerifyAdmin = LogicFacade.GetAdmin(name, psw);
|
||||
if (VerifyAdmin > 0) {
|
||||
HttpSession session = request.getSession();
|
||||
session.setAttribute("VerifyAdmin", VerifyAdmin);
|
||||
session.setAttribute("AdminName", name);
|
||||
if (VerifyAdmin < 2) {
|
||||
return "Content";
|
||||
} else {
|
||||
Map <String, String> HM = LogicFacade.getAllAdmins();
|
||||
session.setAttribute("adminMap", HM);
|
||||
return "AdminPage";
|
||||
}
|
||||
}
|
||||
return "Content";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package Presentation;
|
||||
|
||||
import FunctionLayer.ErrorMessageDisplay;
|
||||
import java.util.HashMap;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
abstract class Command {
|
||||
|
||||
private static HashMap<String, Command> commands;
|
||||
|
||||
private static void initCommands() {
|
||||
commands = new HashMap();
|
||||
commands.put("SessionAttributeHandler", new SessionAttributeHandler());
|
||||
commands.put("mapfnfo", new MapInfo());
|
||||
commands.put("playerinfo", new PlayerInfo());
|
||||
commands.put("adminLogin", new AdminLogin());
|
||||
commands.put("Authenticatelogin", new Authenticatelogin());
|
||||
commands.put("DeleteEntry", new DeleteIndex());
|
||||
commands.put("CreateAdmin", new CreateAdmin());
|
||||
//add methods here for the controller
|
||||
}
|
||||
|
||||
static Command from(HttpServletRequest request) throws ErrorMessageDisplay {
|
||||
String commandName = request.getParameter("command");
|
||||
if (commands == null) {
|
||||
initCommands();
|
||||
}
|
||||
return commands.getOrDefault(commandName, new SessionAttributeHandler());
|
||||
}
|
||||
|
||||
abstract String execute(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ErrorMessageDisplay;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package Presentation;
|
||||
|
||||
import FunctionLayer.ErrorMessageDisplay;
|
||||
import FunctionLayer.LogicFacade;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class CreateAdmin extends Command {
|
||||
|
||||
@Override
|
||||
String execute(HttpServletRequest request, HttpServletResponse response) throws ErrorMessageDisplay {
|
||||
HttpSession session = request.getSession();
|
||||
String name = request.getParameter("name");
|
||||
String password = request.getParameter("psw1");
|
||||
String role = request.getParameter("Role");
|
||||
LogicFacade.createAdmin(name, password, role);
|
||||
Map<String, String> HM = LogicFacade.getAllAdmins();
|
||||
session.setAttribute("adminMap", HM);
|
||||
return "AdminPage";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package Presentation;
|
||||
|
||||
import FunctionLayer.Caching.GACaching;
|
||||
import FunctionLayer.ErrorMessageDisplay;
|
||||
import FunctionLayer.LogicFacade;
|
||||
import FunctionLayer.MapBoard;
|
||||
import FunctionLayer.RecentTimes;
|
||||
import FunctionLayer.UserBanners;
|
||||
import FunctionLayer.Users;
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class DeleteIndex extends Command {
|
||||
|
||||
@Override
|
||||
String execute(HttpServletRequest request, HttpServletResponse response) throws ErrorMessageDisplay {
|
||||
//throw new ErrorMessageDisplay("reached delete indes");
|
||||
HttpSession session = request.getSession();
|
||||
String playermap = (String) request.getParameter("PlayerRelatedMap");
|
||||
String SteamId = request.getParameter("DeleteIndexSteamID");
|
||||
LogicFacade.DeleteMapEntry(playermap, SteamId);
|
||||
try {
|
||||
GACaching.instance.UpdateDeletedEntries();
|
||||
} catch (SQLException | IOException | PropertyVetoException ex) {
|
||||
Logger.getLogger(DeleteIndex.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
List<MapBoard> mapBoard = GACaching.instance.getAllMapValues();
|
||||
List<RecentTimes> recentTimes = GACaching.instance.getAllRecentTimes();
|
||||
List<UserBanners> UB = GACaching.instance.getUserBanners();
|
||||
List<Users> PlayerLeaderBoard = GACaching.instance.getAllPlayerValues();
|
||||
session.setAttribute("LeaderBoard", PlayerLeaderBoard);
|
||||
session.setAttribute("MapBoard", mapBoard);
|
||||
session.setAttribute("UserBanners", UB);
|
||||
session.setAttribute("RecentTimes", recentTimes);
|
||||
return "Content";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package Presentation;
|
||||
|
||||
import FunctionLayer.MapBoard;
|
||||
import FunctionLayer.ErrorMessageDisplay;
|
||||
import FunctionLayer.LogicFacade;
|
||||
import FunctionLayer.UserBanners;
|
||||
import FunctionLayer.Users;
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class DisplayContent extends Command {
|
||||
|
||||
@Override
|
||||
String execute(HttpServletRequest request, HttpServletResponse response) throws ErrorMessageDisplay {
|
||||
try {
|
||||
HttpSession session = request.getSession();
|
||||
List<Users> PlayerLeaderBoard = (List<Users>) session.getAttribute("LeaderBoard");
|
||||
List<MapBoard> mapBoard = (List<MapBoard>) session.getAttribute("MapBoard");
|
||||
boolean firsttime = session.getAttribute("first") != null;
|
||||
PlayerLeaderBoard = LogicFacade.GetAllUsersNameSteamIdAvatar(PlayerLeaderBoard);
|
||||
List<Users> UpdateDBAvatars = PlayerLeaderBoard;
|
||||
List<UserBanners> UB = (List<UserBanners>) session.getAttribute("UserBanners");;
|
||||
if (mapBoard == null) {
|
||||
mapBoard = LogicFacade.GetAllMapColoumns();
|
||||
}
|
||||
PlayerLeaderBoard = LogicFacade.getPlayerPointsAndRank(PlayerLeaderBoard, mapBoard, firsttime);
|
||||
mapBoard = LogicFacade.getAllMapValues(mapBoard, PlayerLeaderBoard);
|
||||
if (UB == null) {
|
||||
UB = LogicFacade.getUserBanners(PlayerLeaderBoard);
|
||||
}
|
||||
PlayerLeaderBoard = LogicFacade.getPlayertimeAmount(PlayerLeaderBoard, mapBoard);
|
||||
if (mapBoard.size() < 1) {
|
||||
throw new ErrorMessageDisplay("No maps available, call jenz mapBoard size: " + mapBoard.size() + " other: " + mapBoard.get(0).getMapvalues().size());
|
||||
}
|
||||
session.setAttribute("first", firsttime);
|
||||
session.setAttribute("LeaderBoard", PlayerLeaderBoard);
|
||||
session.setAttribute("MapBoard", mapBoard);
|
||||
session.setAttribute("UserBanners", UB);
|
||||
Thread t = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
try {
|
||||
LogicFacade.UpdatePlayerAvatarsToDB(UpdateDBAvatars);
|
||||
Thread.sleep(1000 * 60 * 180);
|
||||
} catch (IOException | InterruptedException | ErrorMessageDisplay ex) {
|
||||
Logger.getLogger(DisplayContent.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
t.start();
|
||||
} catch (SQLException | IOException | PropertyVetoException ex) {
|
||||
Logger.getLogger(DisplayContent.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return "Content";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package Presentation;
|
||||
|
||||
import FunctionLayer.ErrorMessageDisplay;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.ServletContextListener;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebListener;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @webServlet should be initiated once on beginning, FrontController is the URL, when applied on tomcat having URL wrong breaks session objects
|
||||
*/
|
||||
@WebServlet(name = "FrontController", urlPatterns = {"/FrontController"})
|
||||
public class FrontController extends HttpServlet {
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
try {
|
||||
Command action = Command.from(request);
|
||||
String view = action.execute(request, response);
|
||||
request.getRequestDispatcher("/WEB-INF/" + view + ".jsp").forward(request, response);
|
||||
} catch (ErrorMessageDisplay ex) {
|
||||
request.setAttribute("error", ex.getMessage());
|
||||
request.getRequestDispatcher("/WEB-INF/test.jsp").forward(request, response);
|
||||
}
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* Handles the HTTP <code>GET</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the HTTP <code>POST</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package Presentation;
|
||||
|
||||
import FunctionLayer.ErrorMessageDisplay;
|
||||
import FunctionLayer.LogicFacade;
|
||||
import FunctionLayer.MapBoard;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class MapInfo extends Command {
|
||||
|
||||
@Override
|
||||
String execute(HttpServletRequest request, HttpServletResponse response) throws ErrorMessageDisplay {
|
||||
HttpSession session = request.getSession(false);
|
||||
if (session != null) {
|
||||
List<MapBoard> mapBoard = (List<MapBoard>) session.getAttribute("MapBoard");
|
||||
String map = (String) request.getParameter("mapname");
|
||||
int index = LogicFacade.getMapIndex(mapBoard, map);
|
||||
request.setAttribute("SpecificMapIndex", index);
|
||||
return "MapInfo";
|
||||
} else {
|
||||
return "SessionTimeoutRedirect";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package Presentation;
|
||||
|
||||
import FunctionLayer.ErrorMessageDisplay;
|
||||
import FunctionLayer.LogicFacade;
|
||||
import FunctionLayer.MapBoard;
|
||||
import FunctionLayer.Users;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class PlayerInfo extends Command {
|
||||
|
||||
@Override
|
||||
String execute(HttpServletRequest request, HttpServletResponse response) throws ErrorMessageDisplay {
|
||||
HttpSession session = request.getSession();
|
||||
if (session != null) {
|
||||
String PlayerIndexSteamID = request.getParameter("player");
|
||||
List<Users> users = (List<Users>) session.getAttribute("LeaderBoard");
|
||||
List<MapBoard> mapBoard = (List<MapBoard>) session.getAttribute("MapBoard");
|
||||
Users user = LogicFacade.getUser(PlayerIndexSteamID, users, mapBoard);
|
||||
List<MapBoard> PlayerRelatedMapBoard = LogicFacade.getPlayerRelatedMapBoard(mapBoard, user);
|
||||
String SteamID64 = Long.toString(LogicFacade.convertSteamIdToCommunityId(user.getSteamID()));
|
||||
List<Integer> PlayerPositions = LogicFacade.getPlayerPositions(PlayerRelatedMapBoard, user);
|
||||
request.setAttribute("CommunityID", SteamID64);
|
||||
request.setAttribute("user", user);
|
||||
request.setAttribute("PlayerRelatedMapBoard", PlayerRelatedMapBoard);
|
||||
request.setAttribute("positions", PlayerPositions);
|
||||
//throw new ErrorMessageDisplay("PlayerRelatedMapBoard size: " + PlayerRelatedMapBoard.size());
|
||||
return "PlayerInfo";
|
||||
} else {
|
||||
return "SessionTimeoutRedirect";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package Presentation;
|
||||
|
||||
import FunctionLayer.RecentTimes;
|
||||
import FunctionLayer.Caching.GACaching;
|
||||
import FunctionLayer.ErrorMessageDisplay;
|
||||
import FunctionLayer.MapBoard;
|
||||
import FunctionLayer.UserBanners;
|
||||
import FunctionLayer.Users;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class SessionAttributeHandler extends Command {
|
||||
|
||||
/**
|
||||
* SessionAttributeHandler redirects all required calls to clients
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws ErrorMessageDisplay
|
||||
*/
|
||||
@Override
|
||||
String execute(HttpServletRequest request, HttpServletResponse response) throws ErrorMessageDisplay {
|
||||
HttpSession session = request.getSession();
|
||||
GACaching.instance.Initialization();
|
||||
List<MapBoard> mapBoard = GACaching.instance.getAllMapValues();
|
||||
List<RecentTimes> recentTimes = GACaching.instance.getAllRecentTimes();
|
||||
List<UserBanners> UB = GACaching.instance.getUserBanners();
|
||||
List<Users> PlayerLeaderBoard = GACaching.instance.getAllPlayerValues();
|
||||
if (mapBoard.size() < 1) {
|
||||
throw new ErrorMessageDisplay("No maps available, call jenz");
|
||||
}
|
||||
session.setAttribute("LeaderBoard", PlayerLeaderBoard);
|
||||
session.setAttribute("MapBoard", mapBoard);
|
||||
session.setAttribute("UserBanners", UB);
|
||||
session.setAttribute("RecentTimes", recentTimes);
|
||||
return "Content";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
# DEFAULT CACHE REGION
|
||||
jcs.default=DC
|
||||
jcs.default.cacheattributes=org.apache.commons.jcs.engine.CompositeCacheAttributes
|
||||
jcs.default.cacheattributes.MaxObjects=1000
|
||||
jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache
|
||||
jcs.default.cacheattributes.UseMemoryShrinker=false
|
||||
jcs.default.cacheattributes.MaxMemoryIdleTime=3600
|
||||
jcs.default.cacheattributes.ShrinkerInterval=60
|
||||
jcs.default.elementattributes=org.apache.commons.jcs.engine.ElementAttributes
|
||||
jcs.default.elementattributes.IsEternal=false
|
||||
jcs.default.elementattributes.MaxLife=21600
|
||||
jcs.default.elementattributes.IdleTime=1800
|
||||
jcs.default.elementattributes.IsSpool=true
|
||||
jcs.default.elementattributes.IsRemote=true
|
||||
jcs.default.elementattributes.IsLateral=true
|
||||
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Context path="/mavenproject1"/>
|
||||
@@ -0,0 +1,49 @@
|
||||
<%--
|
||||
Document : AdminLogin
|
||||
Created on : 08-11-2018, 21:08:22
|
||||
Author : install1
|
||||
--%>
|
||||
|
||||
<%@page contentType="text/html" pageEncoding="windows-1252"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||||
<title>Admin Login</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="text-center">
|
||||
<button type="button" class="btn btn-info" onclick="GetFrontPage()">Overview</button>
|
||||
<br>
|
||||
<br>
|
||||
<form id="1112" name="Authenticatelogin" action="FrontController" method="POST">
|
||||
<input type="hidden" name="command" value="Authenticatelogin">
|
||||
<div class="container">
|
||||
<label for="uname"><b>Username</b></label>
|
||||
<input type="text" placeholder="Enter Username" name="uname" required>
|
||||
<label for="psw"><b>Password</b></label>
|
||||
<input type="password" placeholder="Enter Password" name="psw" required>
|
||||
<button class="btn btn-primary" onclick="AuthenticateLogin()" >Login</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<SCRIPT LANGUAGE="JavaScript">
|
||||
function GetFrontPage()
|
||||
{
|
||||
document.getElementById('1111').submit();
|
||||
}
|
||||
function AuthenticateLogin()
|
||||
{
|
||||
document.getElementById('1112').submit();
|
||||
}
|
||||
</SCRIPT>
|
||||
<form id="1111" name="SessionAttributeHandler" action="FrontController" method="POST">
|
||||
<input type="hidden" name="command" value="SessionAttributeHandler">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,95 @@
|
||||
<%--
|
||||
Document : AdminPage
|
||||
Created on : 13-11-2018, 22:35:37
|
||||
Author : install1
|
||||
--%>
|
||||
|
||||
<%@page import="java.util.List"%>
|
||||
<%@page import="java.util.Map"%>
|
||||
<%@page contentType="text/html" pageEncoding="windows-1252"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
|
||||
<title>Administration Page</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="text-center">
|
||||
<button type="button" class="btn btn-info" onclick="GetFrontPage();">Overview</button>
|
||||
<br>
|
||||
<br>
|
||||
</div>
|
||||
<div align="center">
|
||||
<button class="btn btn-primary" onclick="CreateAdminFunc();" >Create Admin</button>
|
||||
</div>
|
||||
<form id="1111" name="CreateAdmin" action="FrontController" method="POST">
|
||||
<input type="hidden" name="command" value="CreateAdmin">
|
||||
<div class="container">
|
||||
<label for="name"><b>Username</b></label>
|
||||
<input type="text" placeholder="Enter Username" name="name" required>
|
||||
<label for="psw1"><b>Password</b></label>
|
||||
<input type="password" placeholder="Enter Password" name="psw1" required>
|
||||
<label for="role"><b>Role</b></label>
|
||||
<select name="Role" form="1111">
|
||||
<option value="Tech">Tech</option>
|
||||
<option value="Global Admin">Global Admin</option>
|
||||
<option value="Admin">Admin</option>
|
||||
</select>
|
||||
<br>
|
||||
</div>
|
||||
</form>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm">
|
||||
<%
|
||||
Map<String, String> map = (Map) session.getAttribute("adminMap");
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
%>
|
||||
<div align="center">
|
||||
<span href="#" class="fake-link" >
|
||||
<div>
|
||||
<%
|
||||
out.println(entry.getKey());
|
||||
|
||||
%>
|
||||
</div>
|
||||
<div>
|
||||
<% out.println(entry.getValue());
|
||||
%>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
<br>
|
||||
<%
|
||||
}
|
||||
|
||||
%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<style>
|
||||
.fake-link {
|
||||
color: #007bff;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
<SCRIPT LANGUAGE="JavaScript">
|
||||
function CreateAdminFunc()
|
||||
{
|
||||
document.getElementById('1111').submit();
|
||||
}
|
||||
function GetFrontPage()
|
||||
{
|
||||
document.getElementById('1112').submit();
|
||||
}
|
||||
</SCRIPT>
|
||||
<form id="1112" name="SessionAttributeHandler" action="FrontController" method="POST">
|
||||
<input type="hidden" name="command" value="SessionAttributeHandler">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,259 @@
|
||||
<%--
|
||||
Document : index
|
||||
Created on : 21-10-2018, 14:28:06
|
||||
Author : install1
|
||||
--%>
|
||||
<%@page import="java.text.DecimalFormat"%>
|
||||
<%@page import="FunctionLayer.RecentTimes"%>
|
||||
<%@page import="java.util.Collections"%>
|
||||
<%@page import="FunctionLayer.UserBanners"%>
|
||||
<%@page import="FunctionLayer.MapBoard"%>
|
||||
<%@page import="FunctionLayer.Users"%>
|
||||
<%@page import="java.util.List"%>
|
||||
<%@page contentType="text/html" pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Maptimers</title>
|
||||
</head>
|
||||
<body>
|
||||
<% String AdminName = (String) session.getAttribute("AdminName");
|
||||
if (AdminName != null) {
|
||||
%>
|
||||
<h1>You are logged in as: <%=AdminName%> </h1>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<button type="button" class="btn btn-warning" onclick="AdminLogin()">Admin login</button>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="text-center">
|
||||
<button type="button" class="btn btn-primary" onclick="DisplayMaps()">Maps</button>
|
||||
<button type="button" class="btn btn-success" onclick="DisplayPlayers()">Players</button>
|
||||
<button type="button" class="btn btn-secondary" onclick="RecentTimes()">Recent Times</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="text-center">
|
||||
<div id="MapDiv">
|
||||
<%
|
||||
List<MapBoard> AllMapColoumns = (List<MapBoard>) session.getAttribute("MapBoard");
|
||||
if (AllMapColoumns != null) {
|
||||
for (int i = 0; i < AllMapColoumns.size(); i++) {
|
||||
%>
|
||||
<button id="<%=AllMapColoumns.get(i).getMapName()%>" class="list-group-item list-group-item-action" onclick="GetMapPage(this.id);" style="border: none" > <span href="#" class="fake-link" ><%out.print(AllMapColoumns.get(i).getMapName());%></span>
|
||||
</button>
|
||||
<%
|
||||
}
|
||||
} else { %>
|
||||
<li class="list-group-item disabled">No map Entries, call jenz!</li>
|
||||
<% } %>
|
||||
</div>
|
||||
<div id="RecentDiv">
|
||||
<%
|
||||
List<RecentTimes> recentTimes = (List<RecentTimes>) session.getAttribute("RecentTimes");
|
||||
if (recentTimes != null) {
|
||||
for (int i = 0; i < recentTimes.size(); i++) {
|
||||
%>
|
||||
<button class="list-group-item list-group-item-action" id="<%=recentTimes.get(i).getUser().getSteamID()%>" style="border: none" onclick="GetplayerPage(this.id);">
|
||||
<span href="#" class="fake-link" >
|
||||
<div>
|
||||
<%out.print(recentTimes.get(i).getUser().getSteamID());%>
|
||||
</div>
|
||||
<div>
|
||||
<%out.print(recentTimes.get(i).getUser().getName());%>
|
||||
</div>
|
||||
<div>
|
||||
<img src="<%out.println(recentTimes.get(i).getUser().getAvatar()); %>">
|
||||
</div>
|
||||
<div>
|
||||
<%out.print(recentTimes.get(i).getMYSQLStage());%>
|
||||
</div>
|
||||
<div>
|
||||
<%
|
||||
float fdefault = recentTimes.get(i).getImprovedTime();
|
||||
int MinuteAdjusterImproved = (int) fdefault;
|
||||
float secondsAdjusterImproved = Float.valueOf(String.format("%.2f", (fdefault - MinuteAdjusterImproved) * 100));
|
||||
out.print("\nImproved by: 0" + MinuteAdjusterImproved + ":"
|
||||
+ secondsAdjusterImproved);
|
||||
%>
|
||||
</div>
|
||||
<div>
|
||||
<%
|
||||
//00:56.4
|
||||
float newAdjustedTime = (((int) recentTimes.get(i).getMYSQLOldTime()) * 60
|
||||
+ ((recentTimes.get(i).getMYSQLOldTime() - (int) recentTimes.get(i).getMYSQLOldTime()) * 100))
|
||||
- (MinuteAdjusterImproved * 60 + secondsAdjusterImproved);
|
||||
int newMinuteTime = (int) newAdjustedTime / 60;
|
||||
float SecondsAdjusterNewTime = Float.valueOf(String.format("%.2f", newAdjustedTime - (newMinuteTime * 60)));
|
||||
out.print("New Time: 0" + newMinuteTime + ":" + SecondsAdjusterNewTime);
|
||||
%>
|
||||
</div>
|
||||
</span>
|
||||
</button>
|
||||
<% }
|
||||
}
|
||||
%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="PlayerDiv">
|
||||
<% List<UserBanners> UB = (List<UserBanners>) session.getAttribute("UserBanners");
|
||||
List<Users> PlayerLeaderBoard = (List<Users>) session.getAttribute("LeaderBoard");
|
||||
int UBIndex = 0;
|
||||
if (PlayerLeaderBoard != null && UB != null) {
|
||||
// out.println("UB size: " + UB.size());
|
||||
for (int j = 0; j < PlayerLeaderBoard.size(); j++) {
|
||||
%>
|
||||
<button class="list-group-item list-group-item-action" id="<%=PlayerLeaderBoard.get(j).getSteamID()%>" style="border: none" onclick="GetplayerPage(this.id);"><span href="#" class="fake-link" >
|
||||
<div class="container" id="Players">
|
||||
<div class="row d-flex justify-content-between">
|
||||
<div>
|
||||
<%out.print(PlayerLeaderBoard.get(j).getSteamID());%>
|
||||
</div>
|
||||
<div>
|
||||
<%out.print(PlayerLeaderBoard.get(j).getName());%>
|
||||
</div>
|
||||
<div>
|
||||
<%out.print("Rank: " + PlayerLeaderBoard.get(j).getRank());%>
|
||||
</div>
|
||||
<div>
|
||||
<%out.print("Points: " + PlayerLeaderBoard.get(j).getPlayerPoints());%>
|
||||
</div>
|
||||
<div>
|
||||
<%out.print("Times: " + PlayerLeaderBoard.get(j).getTimes());%>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row d-flex justify-content-between">
|
||||
<div>
|
||||
<div class="d-flex justify-content-between" id="Players">
|
||||
<%
|
||||
String img = "";
|
||||
if (UBIndex < UB.size() && UB.get(UBIndex).getUser().equals(PlayerLeaderBoard.get(j))) {
|
||||
for (int i = 0; i < UB.get(UBIndex).getUrlBanners().size(); i++) {
|
||||
switch (UB.get(UBIndex).getUrlBanners().get(i)) {
|
||||
case 25: {
|
||||
img = "https://unloze.com/images/badges/Event-Manager.png";
|
||||
break;
|
||||
}
|
||||
case 19: {
|
||||
img = "https://unloze.com/images/badges/Discord-Manager.png";
|
||||
break;
|
||||
}
|
||||
case 15: {
|
||||
img = "https://unloze.com/images/badges/Event-Winner.png";
|
||||
break;
|
||||
}
|
||||
case 12: {
|
||||
img = "https://unloze.com/images/badges/VIP.png";
|
||||
break;
|
||||
}
|
||||
case 11: {
|
||||
img = "https://unloze.com/images/badges/Global-Admin.png";
|
||||
break;
|
||||
}
|
||||
case 10: {
|
||||
img = "https://unloze.com/images/badges/Leader.png";
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
img = "https://unloze.com/images/badges/Tech-Staff.png";
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
img = "https://unloze.com/images/badges/Admin.png";
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
img = "https://unloze.com/images/badges/Mapper.png";
|
||||
break;
|
||||
}
|
||||
}
|
||||
%>
|
||||
<div >
|
||||
<img src="<%out.println(img); %>">
|
||||
</div>
|
||||
<%
|
||||
}
|
||||
UBIndex++;
|
||||
}
|
||||
%>
|
||||
</div>
|
||||
</div>
|
||||
<div class="float-right" >
|
||||
<img src="<%out.println(PlayerLeaderBoard.get(j).getAvatar()); %>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</span> </button>
|
||||
<% }
|
||||
|
||||
} else {
|
||||
%>
|
||||
<li class="list-group-item disabled">No Player Entries</li>
|
||||
<% }%>
|
||||
</div>
|
||||
<SCRIPT LANGUAGE="JavaScript">
|
||||
function GetMapPage(count)
|
||||
{
|
||||
document.getElementById("mapindexes").value = count;
|
||||
document.getElementById('1111').submit();
|
||||
}
|
||||
function GetplayerPage(count)
|
||||
{
|
||||
document.getElementById("playerindex").value = count;
|
||||
document.getElementById('1112').submit();
|
||||
}
|
||||
function AdminLogin()
|
||||
{
|
||||
document.getElementById('1113').submit();
|
||||
}
|
||||
$('#PlayerDiv').hide();
|
||||
function DisplayMaps() {
|
||||
$('#PlayerDiv').hide();
|
||||
$('#RecentDiv').hide();
|
||||
$('#MapDiv').show();
|
||||
}
|
||||
function DisplayPlayers()
|
||||
{
|
||||
$('#PlayerDiv').show();
|
||||
$('#MapDiv').hide();
|
||||
$('#RecentDiv').hide();
|
||||
}
|
||||
function RecentTimes()
|
||||
{
|
||||
$('#PlayerDiv').hide();
|
||||
$('#MapDiv').hide();
|
||||
$('#RecentDiv').show();
|
||||
}
|
||||
|
||||
</SCRIPT>
|
||||
<form id="1111" name="mapfnfo" action="FrontController" method="POST">
|
||||
<input type="hidden" name="command" value="mapfnfo">
|
||||
<input type="hidden" name="mapname" id='mapindexes' value=''>
|
||||
</form>
|
||||
<form id="1112" name="playerinfo" action="FrontController" method="POST">
|
||||
<input type="hidden" name="command" value="playerinfo">
|
||||
<input type="hidden" name="player" id='playerindex' value=''>
|
||||
</form>
|
||||
<form id="1113" name="adminLogin" action="FrontController" method="POST">
|
||||
<input type="hidden" name="command" value="adminLogin">
|
||||
</form>
|
||||
<style>
|
||||
.fake-link {
|
||||
color: #007bff;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,205 @@
|
||||
<%--
|
||||
Document : Mapdetails
|
||||
Created on : 23-10-2018, 14:12:31
|
||||
Author : install1
|
||||
--%>
|
||||
|
||||
<%@page import="FunctionLayer.UserBanners"%>
|
||||
<%@page import="FunctionLayer.MapBoard"%>
|
||||
<%@page import="java.text.DecimalFormat"%>
|
||||
<%@page import="java.math.BigDecimal"%>
|
||||
<%@page import="java.util.List"%>
|
||||
<%@page import="java.util.List"%>
|
||||
<%@page import="java.util.Iterator"%>
|
||||
<%@page import="java.util.Map"%>
|
||||
<%@page import="FunctionLayer.Users"%>
|
||||
<%@page contentType="text/html" pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>LeaderBoards</title>
|
||||
</head>
|
||||
<body>
|
||||
<% String AdminName = (String) request.getSession().getAttribute("AdminName");
|
||||
if (AdminName != null) {
|
||||
%>
|
||||
<h1>You are logged in as: <%=AdminName%> </h1>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm">
|
||||
<div align="center">
|
||||
<button type="button" class="btn btn-info" onclick="GetFrontPage()">Overview</button>
|
||||
</div>
|
||||
<br>
|
||||
<br>
|
||||
<%
|
||||
List<UserBanners> UB = (List<UserBanners>) session.getAttribute("UserBanners");
|
||||
List<MapBoard> mapBoard = (List<MapBoard>) session.getAttribute("MapBoard");
|
||||
//might not find mapname as parameter
|
||||
int index = (Integer) request.getAttribute("SpecificMapIndex");
|
||||
String map = (String) request.getParameter("mapname");
|
||||
String VerifyAdmins = session.getAttribute("VerifyAdmin") == null ? "0" : String.valueOf(session.getAttribute("VerifyAdmin"));
|
||||
int VerifyAdmin = Integer.valueOf(VerifyAdmins);
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
df.setMaximumFractionDigits(1);
|
||||
out.println("<H2 align=\"center\">" + map + "</h2>");
|
||||
if (mapBoard != null) {
|
||||
for (int i = 0; i < mapBoard.get(index).getMapvalues().size(); i++) {
|
||||
%>
|
||||
<button id="<%=mapBoard.get(index).getMapvalues().get(i).getUser().getSteamID()%>" style="border: none" onclick="GetplayerPage(this.id);"
|
||||
class="list-group-item list-group-item-action" >
|
||||
<span href="#" class="fake-link" >
|
||||
<div class="row d-flex justify-content-between">
|
||||
<div> <%out.println(mapBoard.get(index).getMapvalues().get(i).getUser().getSteamID());%></div>
|
||||
<div> <%out.println(mapBoard.get(index).getMapvalues().get(i).getUser().getName());%></div>
|
||||
<div><%out.println("Rank: " + mapBoard.get(index).getMapvalues().get(i).getUser().getRank());%></div>
|
||||
<div>
|
||||
<%out.println("Points: " + mapBoard.get(index).getMapvalues().get(i).getUser().getPlayerPoints());%>
|
||||
</div>
|
||||
<div>
|
||||
<%out.println("Times: " + mapBoard.get(index).getMapvalues().get(i).getUser().getTimes());%>
|
||||
</div>
|
||||
<div>
|
||||
<%out.println("Map Position: " + (i + 1)); %>
|
||||
</div>
|
||||
<div> <%out.println("Time: " + "0" + (long) (mapBoard.get(index).getMapvalues().get(i).getTime())
|
||||
+ ":" + (df.format((mapBoard.get(index).getMapvalues().get(i).getTime() - (long) (mapBoard.get(index).getMapvalues().get(i).getTime())) * 100)));%>
|
||||
</div>
|
||||
<div>
|
||||
<%out.println("Map Points: " + mapBoard.get(index).getMapvalues().get(i).getMapPoints() + "/100");%>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div align="center">
|
||||
<img src="<%out.println(mapBoard.get(index).getMapvalues().get(i).getUser().getAvatar()); %>">
|
||||
</div>
|
||||
<%
|
||||
String img = ""; //userlist.indexOf(UserCacheTimeAmount1.entrySet().stream().filter(e -> e.getValue().getSteamID().equals(RTSteamID)).findFirst().get().getValue());
|
||||
Users user = mapBoard.get(index).getMapvalues().get(i).getUser();
|
||||
int mbIndex = -1;
|
||||
for (int j = 0; j < UB.size(); j++) {
|
||||
if (UB.get(j).getUser().equals(user)) {
|
||||
mbIndex = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (mbIndex > 0) {
|
||||
for (int j = 0; j < UB.get(mbIndex).getUrlBanners().size(); j++) {
|
||||
switch (UB.get(mbIndex).getUrlBanners().get(j)) {
|
||||
case 25: {
|
||||
img = "https://unloze.com/images/badges/Event-Manager.png";
|
||||
break;
|
||||
}
|
||||
case 19: {
|
||||
img = "https://unloze.com/images/badges/Discord-Manager.png";
|
||||
break;
|
||||
}
|
||||
case 15: {
|
||||
img = "https://unloze.com/images/badges/Event-Winner.png";
|
||||
break;
|
||||
}
|
||||
case 12: {
|
||||
img = "https://unloze.com/images/badges/VIP.png";
|
||||
break;
|
||||
}
|
||||
case 11: {
|
||||
img = "https://unloze.com/images/badges/Global-Admin.png";
|
||||
break;
|
||||
}
|
||||
case 10: {
|
||||
img = "https://unloze.com/images/badges/Leader.png";
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
img = "https://unloze.com/images/badges/Tech-Staff.png";
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
img = "https://unloze.com/images/badges/Admin.png";
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
img = "https://unloze.com/images/badges/Mapper.png";
|
||||
break;
|
||||
}
|
||||
}
|
||||
%>
|
||||
<div align="center">
|
||||
<div >
|
||||
<img src="<%out.println(img);%>">
|
||||
</div>
|
||||
</div>
|
||||
<% }
|
||||
}
|
||||
%>
|
||||
</span> </button>
|
||||
<%
|
||||
if (VerifyAdmin > 0) {
|
||||
%>
|
||||
<div align="center">
|
||||
<button value="<%out.print(mapBoard.get(index).getMapName());%>" id="<%=mapBoard.get(index).getMapvalues().get(i).getUser().getSteamID()%>" style="border: none" onclick="removeentry(this.id, this.value);" >
|
||||
<span href="#" class="fake-link" >
|
||||
<div class="d-flex justify-content-between">
|
||||
<div>
|
||||
<%out.println("Delete Entry");%>
|
||||
</div>
|
||||
</div>
|
||||
</span> </button>
|
||||
</div>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<br>
|
||||
<br>
|
||||
<% }
|
||||
}
|
||||
%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<style>
|
||||
.fake-link {
|
||||
color: #007bff;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
<SCRIPT LANGUAGE="JavaScript">
|
||||
function GetplayerPage(count)
|
||||
{
|
||||
document.getElementById("playerindex").value = count;
|
||||
document.getElementById('1111').submit();
|
||||
}
|
||||
function GetFrontPage()
|
||||
{
|
||||
document.getElementById('1112').submit();
|
||||
}
|
||||
function removeentry(steamID, map)
|
||||
{
|
||||
document.getElementById("PlayerRelatedMap").value = map;
|
||||
document.getElementById("SteamID").value = steamID;
|
||||
document.getElementById('1113').submit();
|
||||
}
|
||||
</SCRIPT>
|
||||
<form id="1111" name="playerinfo" action="FrontController" method="POST">
|
||||
<input type="hidden" name="command" value="playerinfo">
|
||||
<input type="hidden" name="player" id='playerindex' value=''>
|
||||
</form>
|
||||
<form id="1112" name="SessionAttributeHandler" action="FrontController" method="POST">
|
||||
<input type="hidden" name="command" value="SessionAttributeHandler">
|
||||
</form>
|
||||
<form id="1113" name="DeleteEntry" action="FrontController" method="POST">
|
||||
<input type="hidden" name="command" value="DeleteEntry">
|
||||
<input type="hidden" name="DeleteIndexSteamID" id='SteamID' value=''>
|
||||
<input type="hidden" name="PlayerRelatedMap" id='PlayerRelatedMap' value=''>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,329 @@
|
||||
<%--
|
||||
Document : PlayerInfo
|
||||
Created on : 04-11-2018, 20:57:35
|
||||
Author : install1
|
||||
--%>
|
||||
|
||||
<%@page import="java.util.ArrayList"%>
|
||||
<%@page import="FunctionLayer.RecentTimes"%>
|
||||
<%@page import="FunctionLayer.UserBanners"%>
|
||||
<%@page import="FunctionLayer.MapBoard"%>
|
||||
<%@page import="java.text.DecimalFormat"%>
|
||||
<%@page import="java.util.List"%>
|
||||
<%@page import="FunctionLayer.Users"%>
|
||||
<%@page contentType="text/html" pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Player Stats</title>
|
||||
</head>
|
||||
<body>
|
||||
<div align="center">
|
||||
<div id="overview" class="btn btn-info overviewclass" >Overview</div>
|
||||
</div>
|
||||
<%
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
List<RecentTimes> recentTimes = (List<RecentTimes>) session.getAttribute("RecentTimes");
|
||||
List<UserBanners> UB = (List<UserBanners>) session.getAttribute("UserBanners");
|
||||
List<MapBoard> DifferentiateMapBoard = (List<MapBoard>) session.getAttribute("MapBoard");
|
||||
String VerifyAdmins = session.getAttribute("VerifyAdmin") == null ? "0" : String.valueOf(session.getAttribute("VerifyAdmin"));
|
||||
int VerifyAdmin = Integer.valueOf(VerifyAdmins);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String SteamID64 = (String) request.getAttribute("CommunityID");
|
||||
if (SteamID64 != null) {
|
||||
sb.append("https://steamcommunity.com/profiles/").append(SteamID64);
|
||||
} else {
|
||||
sb.append("https://steamcommunity.com/profiles/");
|
||||
}
|
||||
List<Integer> PlayerPositions = (List<Integer>) request.getAttribute("positions");
|
||||
Users user = (Users) request.getAttribute("user");
|
||||
List<MapBoard> PlayerRelatedMapBoard = (List<MapBoard>) request.getAttribute("PlayerRelatedMapBoard");
|
||||
df.setMaximumFractionDigits(1);
|
||||
if (user != null && recentTimes != null) {
|
||||
%>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm">
|
||||
<div align="center" class="fake-2">
|
||||
<br>
|
||||
<br>
|
||||
<a target="_blank" href="<%out.println(sb.toString());%>">
|
||||
<button style="border: none"
|
||||
class="list-group-item list-group-item-action" >
|
||||
<span class="fake-link" >
|
||||
<div> <%out.println(user.getName());%></div>
|
||||
<div> <%out.println(user.getSteamID());%></div>
|
||||
<div>
|
||||
<img src="<%out.println(user.getAvatar()); %>">
|
||||
</div>
|
||||
<div>
|
||||
<% out.print("Rank: " + user.getRank()); %>
|
||||
</div>
|
||||
<div>
|
||||
<% out.print("Points: " + user.getPlayerPoints()); %>
|
||||
</div>
|
||||
<div>
|
||||
<% out.print("Times: " + user.getTimes()); %>
|
||||
</div>
|
||||
<%
|
||||
String img = "";
|
||||
int UBIndex = 0;
|
||||
while (UB.size() > UBIndex) {
|
||||
if (UB.get(UBIndex).getUser().equals(user)) {
|
||||
break;
|
||||
}
|
||||
UBIndex++;
|
||||
}
|
||||
if (UBIndex < UB.size()) {
|
||||
for (int i = 0; i < UB.get(UBIndex).getUrlBanners().size(); i++) {
|
||||
switch (UB.get(UBIndex).getUrlBanners().get(i)) {
|
||||
case 25: {
|
||||
img = "https://unloze.com/images/badges/Event-Manager.png";
|
||||
break;
|
||||
}
|
||||
case 19: {
|
||||
img = "https://unloze.com/images/badges/Discord-Manager.png";
|
||||
break;
|
||||
}
|
||||
case 15: {
|
||||
img = "https://unloze.com/images/badges/Event-Winner.png";
|
||||
break;
|
||||
}
|
||||
case 12: {
|
||||
img = "https://unloze.com/images/badges/VIP.png";
|
||||
break;
|
||||
}
|
||||
case 11: {
|
||||
img = "https://unloze.com/images/badges/Global-Admin.png";
|
||||
break;
|
||||
}
|
||||
case 10: {
|
||||
img = "https://unloze.com/images/badges/Leader.png";
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
img = "https://unloze.com/images/badges/Tech-Staff.png";
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
img = "https://unloze.com/images/badges/Admin.png";
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
img = "https://unloze.com/images/badges/Mapper.png";
|
||||
break;
|
||||
}
|
||||
}
|
||||
%>
|
||||
<div>
|
||||
<img src="<%out.println(img);%>">
|
||||
</div>
|
||||
<% }
|
||||
}
|
||||
%>
|
||||
</span> </button>
|
||||
</a>
|
||||
</div>
|
||||
<%
|
||||
for (int i = 0; i < PlayerRelatedMapBoard.size(); i++) {
|
||||
%>
|
||||
<div align="center" class="group">
|
||||
<div class="element" data-id="<%=PlayerRelatedMapBoard.get(i).getMapName()%>" >
|
||||
<span href="#" class="fake-link" >
|
||||
<%out.println(" Map " + PlayerRelatedMapBoard.get(i).getMapName());%>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<span class="fake-2" >
|
||||
<div align="center">
|
||||
<%out.println("Map Position: " + (PlayerRelatedMapBoard.get(i).getMapvalues().get(PlayerPositions.get(i)).getPosition() + 1)); %>
|
||||
</div>
|
||||
<div align="center"> <%out.println("Time: 0" + (int) Math.floor(PlayerRelatedMapBoard.get(i).getMapvalues().get(PlayerPositions.get(i)).getTime())
|
||||
+ ":" + (df.format((PlayerRelatedMapBoard.get(i).getMapvalues().get(PlayerPositions.get(i)).getTime() - Math.floor(PlayerRelatedMapBoard.get(i).getMapvalues().get(PlayerPositions.get(i)).getTime())) * 100)));%></div>
|
||||
<div align="center"> <%out.println("Map Points: " + PlayerRelatedMapBoard.get(i).getMapvalues().get(PlayerPositions.get(i)).getMapPoints() + "/100"); %></div>
|
||||
</span>
|
||||
<%
|
||||
if (VerifyAdmin > 0) {
|
||||
%>
|
||||
<div align="center">
|
||||
<button value="<%out.print(user.getSteamID());%>" id="<%out.print(PlayerRelatedMapBoard.get(i).getMapName());%>" onclick="DeleteEntryFunc(this.value, this.id)" >
|
||||
<span href="#" class="fake-link" >
|
||||
<%out.println("Delete Entry");%>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<br>
|
||||
<br>
|
||||
<%
|
||||
}
|
||||
}
|
||||
%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="header">
|
||||
<div class="leftH" id="leftHDiv" >
|
||||
<div id="lefth1">
|
||||
<% String AdminName = (String) request.getSession().getAttribute("AdminName");
|
||||
if (AdminName != null) {
|
||||
%>
|
||||
<h1>You are logged in as: <%=AdminName%> </h1>
|
||||
<%
|
||||
} %>
|
||||
<h1>Recently improved times: </h1>
|
||||
</div>
|
||||
<%
|
||||
for (int i = 0; i < recentTimes.size(); i++) {
|
||||
if (recentTimes.get(i).getUser().equals(user)) {
|
||||
%>
|
||||
<div>
|
||||
<%out.print("\n" + recentTimes.get(i).getMYSQLStage()); %>
|
||||
</div>
|
||||
<div>
|
||||
<%
|
||||
float fdefault = recentTimes.get(i).getImprovedTime();
|
||||
int MinuteAdjusterImproved = (int) fdefault;
|
||||
float secondsAdjusterImproved = Float.valueOf(String.format("%.2f", (fdefault - MinuteAdjusterImproved) * 100));
|
||||
out.print("\nImproved by: 0" + MinuteAdjusterImproved + ":"
|
||||
+ secondsAdjusterImproved);
|
||||
%>
|
||||
</div>
|
||||
<br>
|
||||
<%
|
||||
}
|
||||
}
|
||||
%>
|
||||
</div>
|
||||
</div>
|
||||
<div class="header">
|
||||
<div class="rightH group1" id="rightHDiv" >
|
||||
<div id="righth1">
|
||||
<h1>Maps with no time yet:</h1>
|
||||
</div>
|
||||
<%
|
||||
List<MapBoard> feex = new ArrayList(PlayerRelatedMapBoard);
|
||||
List<MapBoard> feex1 = new ArrayList(DifferentiateMapBoard);
|
||||
feex1.removeAll(feex);
|
||||
for (int i = 0; i < feex1.size(); i++) {
|
||||
%>
|
||||
<div class="element1" id="<%=feex1.get(i).getMapName()%>" >
|
||||
<span href="#" class="fake-link2" >
|
||||
<%out.print("\n" + feex1.get(i).getMapName()); %>
|
||||
</span>
|
||||
</div>
|
||||
<br>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
</div>
|
||||
</div>
|
||||
<style>
|
||||
.fake-link {
|
||||
color: #007bff;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
z-index: 3;
|
||||
}
|
||||
.fake-link2 {
|
||||
color: #007bff;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
z-index: 3;
|
||||
}
|
||||
.fake-2{
|
||||
position: relative;
|
||||
z-index: 3;
|
||||
}
|
||||
.fake-2 a{
|
||||
display:inline-block;
|
||||
width: 300px;
|
||||
}
|
||||
.overviewclass{
|
||||
position: relative;
|
||||
z-index: 3;
|
||||
}
|
||||
.header {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
top: 0px;
|
||||
}
|
||||
.leftH {
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
float: left;
|
||||
top: 0px;
|
||||
}
|
||||
.rightH {
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
float: right;
|
||||
top: 0px;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
</script>
|
||||
<script>
|
||||
$("#overview").click(function () {
|
||||
document.getElementById('1112').submit();
|
||||
});
|
||||
$('.group1 .element1').click(function () {
|
||||
id1 = $(this).attr('id');
|
||||
document.getElementById("mapindexes1").value = id1;
|
||||
document.getElementById('1114').submit();
|
||||
});
|
||||
$('.group .element').click(function () {
|
||||
id = $(this).attr('data-id');
|
||||
document.getElementById("mapindexes").value = id;
|
||||
document.getElementById('1111').submit();
|
||||
});
|
||||
function DeleteEntryFunc(steamID, map)
|
||||
{
|
||||
document.getElementById("PlayerRelatedMap").value = map;
|
||||
document.getElementById("SteamID").value = steamID;
|
||||
document.getElementById('1113').submit();
|
||||
}
|
||||
$("#leftHDiv").css({
|
||||
position: 'relative',
|
||||
right: '-150px'
|
||||
});
|
||||
$("#lefth1").css({
|
||||
position: 'relative',
|
||||
right: '125px'
|
||||
});
|
||||
$("#rightHDiv").css({
|
||||
position: 'relative',
|
||||
});
|
||||
$("#righth1").css({
|
||||
position: 'relative',
|
||||
});
|
||||
</script>
|
||||
<form id="1111" name="mapfnfo" action="FrontController" method="POST">
|
||||
<input type="hidden" name="command" value="mapfnfo">
|
||||
<input type="hidden" name="mapname" id='mapindexes' value=''>
|
||||
</form>
|
||||
<form id="1112" name="SessionAttributeHandler" action="FrontController" method="POST">
|
||||
<input type="hidden" name="command" value="SessionAttributeHandler">
|
||||
</form>
|
||||
<form id="1113" name="DeleteEntry" action="FrontController" method="POST">
|
||||
<input type="hidden" name="command" value="DeleteEntry">
|
||||
<input type="hidden" name="DeleteIndexSteamID" id='SteamID' value=''>
|
||||
<input type="hidden" name="PlayerRelatedMap" id='PlayerRelatedMap' value=''>
|
||||
</form>
|
||||
<form id="1114" name="mapfnfo" action="FrontController" method="POST">
|
||||
<input type="hidden" name="command" value="mapfnfo">
|
||||
<input type="hidden" name="mapname" id='mapindexes1' value=''>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,21 @@
|
||||
<%--
|
||||
Document : SessionTimeoutRedirect
|
||||
Created on : 08-11-2018, 17:49:13
|
||||
Author : install1
|
||||
--%>
|
||||
|
||||
<%@page contentType="text/html" pageEncoding="windows-1252"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||||
<title>TimeoutHandling</title>
|
||||
</head>
|
||||
<body>
|
||||
<form name="DisplayContent" action="FrontController" method="POST">
|
||||
<input type="hidden" name="command" value="SessionAttributeHandler">
|
||||
Loading Avatars, please wait 20-30 seconds...
|
||||
</form>
|
||||
<SCRIPT LANGUAGE="JavaScript">document.forms[0].submit();</SCRIPT>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,31 @@
|
||||
<%--
|
||||
Document : test
|
||||
Created on : 25-10-2018, 15:39:27
|
||||
Author : install1
|
||||
--%>
|
||||
|
||||
<%@page contentType="text/html" pageEncoding="windows-1252"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||||
<title>JSP Page</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Backup nothingness</h1>
|
||||
<% String error = (String) request.getAttribute("error");
|
||||
if (error != null) {
|
||||
out.println("<H2>Error!!</h2>");
|
||||
out.println(error);
|
||||
} else {
|
||||
%>
|
||||
<form name="DisplayContent" action="FrontController" method="POST">
|
||||
<input type="hidden" name="command" value="SessionAttributeHandler">
|
||||
<input type="submit" />
|
||||
</form>
|
||||
<SCRIPT LANGUAGE="JavaScript">document.forms[0].submit();</SCRIPT>
|
||||
</body>
|
||||
<% }
|
||||
%>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,22 @@
|
||||
<%--
|
||||
Document : dummy
|
||||
Created on : 21-10-2018, 17:07:46
|
||||
Author : install1
|
||||
--%>
|
||||
|
||||
<%@page contentType="text/html" pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta http-equiv="refresh" action="1;FrontController">
|
||||
<title>StartPoint</title>
|
||||
</head>
|
||||
<body>
|
||||
<form name="SessionAttributeHandler" action="FrontController" method="POST">
|
||||
<input type="hidden" name="command" value="SessionAttributeHandler">
|
||||
Loading Avatars, please wait 20-30 seconds...
|
||||
</form>
|
||||
<SCRIPT LANGUAGE="JavaScript">document.forms[0].submit();</SCRIPT>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user