From 65c93d30188e07a723be60d74de942c58e00ba63 Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 26 Feb 2021 19:34:16 +0100 Subject: [PATCH] switching from double to strings and adding settings file --- .../src/main/java/DTO/MapBoardDTO.java | 24 +++++++------------ .../src/main/java/DTO/MapValuesDTO.java | 6 ++--- .../src/main/java/DTO/PlayerMapBoardDTO.java | 6 ++--- .../main/java/DataMapper/DBCPDataSource.java | 6 ++--- .../main/java/DataMapper/DBCPDataSource2.java | 6 ++--- .../main/java/DataMapper/DataMapperCalls.java | 6 ++--- .../src/main/java/DataMapper/settings.java | 20 ++++++++++++++++ .../src/main/java/entity/MapValues.java | 11 +++++---- .../src/main/java/facade/Facade.java | 19 ++++++++------- 9 files changed, 58 insertions(+), 46 deletions(-) create mode 100644 RaceTimer/racetimer_endpoints/src/main/java/DataMapper/settings.java diff --git a/RaceTimer/racetimer_endpoints/src/main/java/DTO/MapBoardDTO.java b/RaceTimer/racetimer_endpoints/src/main/java/DTO/MapBoardDTO.java index 81bfe4c5..f8e307c5 100644 --- a/RaceTimer/racetimer_endpoints/src/main/java/DTO/MapBoardDTO.java +++ b/RaceTimer/racetimer_endpoints/src/main/java/DTO/MapBoardDTO.java @@ -21,8 +21,7 @@ public class MapBoardDTO { private String name; private String avatar; private int mapPoint; - private int mapTimeMinutes; - private float mapTimeSeconds; + private String mapTime; private int position; private List badgesUrls = new ArrayList(); @@ -34,8 +33,7 @@ public class MapBoardDTO { this.name = name; this.avatar = avatar; this.mapPoint = mapvalue.getMapPoints(); - this.mapTimeMinutes = (int) Math.floor(mapvalue.getTime()); - this.mapTimeSeconds = (float) (mapvalue.getTime() - Math.floor(mapvalue.getTime())) * 100; + this.mapTime = mapvalue.getTime(); this.position = mapvalue.getPosition(); } @@ -71,22 +69,16 @@ public class MapBoardDTO { this.mapPoint = mapPoint; } - public int getMapTimeMinutes() { - return mapTimeMinutes; + public String getMapTime() { + return mapTime; } - public void setMapTimeMinutes(int mapTimeMinutes) { - this.mapTimeMinutes = mapTimeMinutes; - } - - public float getMapTimeSeconds() { - return mapTimeSeconds; - } - - public void setMapTimeSeconds(float mapTimeSeconds) { - this.mapTimeSeconds = mapTimeSeconds; + public void setMapTime(String mapTime) { + this.mapTime = mapTime; } + + public int getPosition() { return position; } diff --git a/RaceTimer/racetimer_endpoints/src/main/java/DTO/MapValuesDTO.java b/RaceTimer/racetimer_endpoints/src/main/java/DTO/MapValuesDTO.java index 323fdf14..ad95d043 100644 --- a/RaceTimer/racetimer_endpoints/src/main/java/DTO/MapValuesDTO.java +++ b/RaceTimer/racetimer_endpoints/src/main/java/DTO/MapValuesDTO.java @@ -15,7 +15,7 @@ public class MapValuesDTO { private int position; private String playerSteamID; - private float time; + private String time; private int mapPoints; public int getPosition() { @@ -34,11 +34,11 @@ public class MapValuesDTO { this.playerSteamID = playerSteamID; } - public float getTime() { + public String getTime() { return time; } - public void setTime(float time) { + public void setTime(String time) { this.time = time; } diff --git a/RaceTimer/racetimer_endpoints/src/main/java/DTO/PlayerMapBoardDTO.java b/RaceTimer/racetimer_endpoints/src/main/java/DTO/PlayerMapBoardDTO.java index d3fd740e..ca91a2a4 100644 --- a/RaceTimer/racetimer_endpoints/src/main/java/DTO/PlayerMapBoardDTO.java +++ b/RaceTimer/racetimer_endpoints/src/main/java/DTO/PlayerMapBoardDTO.java @@ -24,8 +24,7 @@ public class PlayerMapBoardDTO { private String mapname; private int mapstage; private int mapPoint; - private int mapTimeMinutes; - private float mapTimeSeconds; + private String mapTime; private int position; public PlayerMapBoardDTO() { @@ -38,8 +37,7 @@ public class PlayerMapBoardDTO { public void addMapValues(MapValues mapvalue, String mapName, int stage) { this.steamID = mapvalue.getPlayerSteamID(); this.mapPoint = mapvalue.getMapPoints(); - this.mapTimeMinutes = (int) Math.floor(mapvalue.getTime()); - this.mapTimeSeconds = (float) (mapvalue.getTime() - Math.floor(mapvalue.getTime())) * 100; + this.mapTime = mapvalue.getTime(); this.position = mapvalue.getPosition(); this.mapname = mapName; this.mapstage = stage; diff --git a/RaceTimer/racetimer_endpoints/src/main/java/DataMapper/DBCPDataSource.java b/RaceTimer/racetimer_endpoints/src/main/java/DataMapper/DBCPDataSource.java index 32450674..251f52e6 100644 --- a/RaceTimer/racetimer_endpoints/src/main/java/DataMapper/DBCPDataSource.java +++ b/RaceTimer/racetimer_endpoints/src/main/java/DataMapper/DBCPDataSource.java @@ -22,9 +22,9 @@ public class DBCPDataSource { 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.setUsername("unloze_racetimer_css"); - ds.setPassword("dfhasFEb234dfsnFEEJSfFEJdfap"); + ds.setUrl(settings.racetimerURL); + ds.setUsername(settings.racetimerUser); + ds.setPassword(settings.racetimerPassword); ds.setMaxTotal(-1); ds.setMinIdle(5); ds.setMaxIdle(-1); diff --git a/RaceTimer/racetimer_endpoints/src/main/java/DataMapper/DBCPDataSource2.java b/RaceTimer/racetimer_endpoints/src/main/java/DataMapper/DBCPDataSource2.java index 7bbc3348..e02c4a24 100644 --- a/RaceTimer/racetimer_endpoints/src/main/java/DataMapper/DBCPDataSource2.java +++ b/RaceTimer/racetimer_endpoints/src/main/java/DataMapper/DBCPDataSource2.java @@ -22,9 +22,9 @@ public class DBCPDataSource2 { 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.setUsername("XenforoWebTimer"); - ds.setPassword("FNF#)(EFHFSNj23n4nfdsfbFE"); + ds.setUrl(settings.forumURL); + ds.setUsername(settings.forumUser); + ds.setPassword(settings.forumPassword); ds.setMaxTotal(-1); ds.setMinIdle(5); ds.setMaxIdle(-1); diff --git a/RaceTimer/racetimer_endpoints/src/main/java/DataMapper/DataMapperCalls.java b/RaceTimer/racetimer_endpoints/src/main/java/DataMapper/DataMapperCalls.java index 0d96bc4d..2c766022 100644 --- a/RaceTimer/racetimer_endpoints/src/main/java/DataMapper/DataMapperCalls.java +++ b/RaceTimer/racetimer_endpoints/src/main/java/DataMapper/DataMapperCalls.java @@ -41,8 +41,8 @@ public class DataMapperCalls { //System.out.println("player dataMapper: " + player.getName() + "\nsteamid: " + player.getSteamID()); int i = 3; while (i < fetchSize) { - double specificDouble = result.getDouble(i); - if (specificDouble > 0.000) { + String specificTime = result.getString(i); + if (!specificTime.equals("0.000")) { String columnLabel = result.getMetaData().getColumnLabel(i); if (!allMapBoards.keySet().contains(columnLabel)) { allMapBoards.put(columnLabel, new MapBoard(columnLabel)); @@ -50,7 +50,7 @@ public class DataMapperCalls { timesCounter++; MapValues mapValue = new MapValues(); mapValue.setPlayerSteamID(player.getSteamID()); - mapValue.setTime((float) specificDouble); + mapValue.setTime(specificTime); allMapBoards.get(columnLabel).getMapvalues().add(mapValue); } i++; diff --git a/RaceTimer/racetimer_endpoints/src/main/java/DataMapper/settings.java b/RaceTimer/racetimer_endpoints/src/main/java/DataMapper/settings.java new file mode 100644 index 00000000..9229de8e --- /dev/null +++ b/RaceTimer/racetimer_endpoints/src/main/java/DataMapper/settings.java @@ -0,0 +1,20 @@ +/* + * 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 DataMapper; + +/** + * + * @author Christian + */ +public class settings { + static String racetimerURL = "jdbc:mysql://localhost:3306/unloze_racetimer_css?useLegacyDatetimeCode=false&serverTimezone=UTC"; + static String racetimerUser = "unloze_racetimer_css"; + static String racetimerPassword = "foj342ronfeanfu32ruhfbb324"; + + static String forumURL = "jdbc:mysql://51.15.159.31:3306/unloze_forum?useLegacyDatetimeCode=false&serverTimezone=UTC"; + static String forumUser = "unloze_webtimer"; + static String forumPassword = "fn124FNFobn324FBEFn234"; +} diff --git a/RaceTimer/racetimer_endpoints/src/main/java/entity/MapValues.java b/RaceTimer/racetimer_endpoints/src/main/java/entity/MapValues.java index 706c0a96..b8995c29 100644 --- a/RaceTimer/racetimer_endpoints/src/main/java/entity/MapValues.java +++ b/RaceTimer/racetimer_endpoints/src/main/java/entity/MapValues.java @@ -40,7 +40,7 @@ public class MapValues implements Serializable { private String playerSteamID; @Basic(optional = false) @NotNull - private float time; + private String time; @Basic(optional = false) @NotNull private int mapPoints; @@ -75,12 +75,12 @@ public class MapValues implements Serializable { this.playerSteamID = steamID; } - public float getTime() { + public String getTime() { return time; } - - public void setTime(float time) { - this.time = time; + + public void setTime(String specificTime) { + this.time = specificTime; } public int getMapPoints() { @@ -123,5 +123,6 @@ public class MapValues implements Serializable { public String toString() { return "entity.MapValues[ id=" + id + " ]"; } + } diff --git a/RaceTimer/racetimer_endpoints/src/main/java/facade/Facade.java b/RaceTimer/racetimer_endpoints/src/main/java/facade/Facade.java index 60e3596f..83eed583 100644 --- a/RaceTimer/racetimer_endpoints/src/main/java/facade/Facade.java +++ b/RaceTimer/racetimer_endpoints/src/main/java/facade/Facade.java @@ -274,28 +274,28 @@ public class Facade { String bannerURL = ""; if (bannerID == 2) { bannerName = "User"; - bannerURL = "https://unloze.com/images/badges/User.png"; + bannerURL = "https://unloze.com/images/badges/Member_Badge.png"; } else if (bannerID == 6) { bannerName = "Mapper"; - bannerURL = "https://unloze.com/images/badges/Mapper.png"; + bannerURL = "https://unloze.com/images/badges/Mapper_Badge.png"; } else if (bannerID == 7) { bannerName = "Admin"; - bannerURL = "https://unloze.com/images/badges/Admin.png"; + bannerURL = "https://unloze.com/images/badges/Admin_Badge.png"; } else if (bannerID == 8) { bannerName = "Technical Staff"; - bannerURL = "https://unloze.com/images/badges/Tech-Staff.png"; + bannerURL = "https://unloze.com/images/badges/Senior-Developer_Badge.png"; } else if (bannerID == 10) { bannerName = "Leader"; - bannerURL = "https://unloze.com/images/badges/Leader.png"; + bannerURL = "https://unloze.com/images/badges/Leader_Badge.png"; } else if (bannerID == 11) { bannerName = "Global Admin"; - bannerURL = "https://unloze.com/images/badges/Global-Admin.png"; + bannerURL = "https://unloze.com/images/badges/Senior-Admin_Badge.png"; } else if (bannerID == 12) { bannerName = "VIP"; - bannerURL = "https://unloze.com/images/badges/VIP.png"; + bannerURL = "https://unloze.com/images/badges/VIP_Badge.png"; } else if (bannerID == 13) { bannerName = "Trial Admin"; - bannerURL = "https://unloze.com/images/badges/Trial_Admin.png"; + bannerURL = "https://unloze.com/images/badges/Junior-Admin_Badge.png"; } else if (bannerID == 15) { bannerName = "Event Winner"; bannerURL = "https://unloze.com/images/badges/Event-Winner.png"; @@ -304,7 +304,7 @@ public class Facade { bannerURL = "https://unloze.com/images/badges/Discord-Manager.png"; } else if (bannerID == 21) { bannerName = "Retired Admin"; - bannerURL = "https://unloze.com/images/badges/Retired-Admin.png"; + bannerURL = "https://unloze.com/images/badges/Retired-Admin_Badge.png"; } else if (bannerID == 25) { bannerName = "Event Manager"; bannerURL = "https://unloze.com/images/badges/Event-Manager.png"; @@ -400,6 +400,7 @@ public class Facade { for (MapBoard mapboard : mapboards) { //System.out.println("mapName: " + mapboard.getMapName()); List mapvalues = new ArrayList(mapboard.getMapvalues()); + mapvalues.sort(Comparator.comparing(MapValues::getTime)); mapBoardCache.get(mapboard.getMapName()).setMapvalues(mapvalues); }