Added a logger instance LOGGER to all classes
This commit is contained in:
parent
a9b75c95ea
commit
4f44ab2f3b
@ -1,6 +1,12 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class Ghost extends Passenger {
|
public class Ghost extends Passenger {
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
protected boolean isOG; //true if the Ghost is the original ghost.
|
protected boolean isOG; //true if the Ghost is the original ghost.
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,12 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class GhostNPC extends Ghost {
|
public class GhostNPC extends Ghost {
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new GhostNPC. Should be used at game start or if a HumanNPC is turned into a ghost.
|
* Creates a new GhostNPC. Should be used at game start or if a HumanNPC is turned into a ghost.
|
||||||
|
|||||||
@ -1,8 +1,13 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||||
import ch.unibas.dmi.dbis.cs108.multiplayer.server.ClientHandler;
|
import ch.unibas.dmi.dbis.cs108.multiplayer.server.ClientHandler;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class GhostPlayer extends Ghost {
|
public class GhostPlayer extends Ghost {
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new GhostPlayer. Should be used at game start or if a HumanPlayer is turned into a
|
* Creates a new GhostPlayer. Should be used at game start or if a HumanPlayer is turned into a
|
||||||
|
|||||||
@ -1,5 +1,11 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class Human extends Passenger {
|
public class Human extends Passenger {
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,12 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class HumanNPC extends Human {
|
public class HumanNPC extends Human {
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new HumanNPC.
|
* Creates a new HumanNPC.
|
||||||
|
|||||||
@ -1,8 +1,13 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||||
import ch.unibas.dmi.dbis.cs108.multiplayer.server.ClientHandler;
|
import ch.unibas.dmi.dbis.cs108.multiplayer.server.ClientHandler;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class HumanPlayer extends Human {
|
public class HumanPlayer extends Human {
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new GhostPlayer. Should be used at game start or if a HumanPlayer is turned into a
|
* Creates a new GhostPlayer. Should be used at game start or if a HumanPlayer is turned into a
|
||||||
|
|||||||
@ -1,8 +1,13 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
package ch.unibas.dmi.dbis.cs108.Klassenstruktur;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||||
import ch.unibas.dmi.dbis.cs108.multiplayer.server.ClientHandler;
|
import ch.unibas.dmi.dbis.cs108.multiplayer.server.ClientHandler;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class Passenger {
|
public class Passenger {
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
protected int position; //the player's Cabin number (0 to 5)
|
protected int position; //the player's Cabin number (0 to 5)
|
||||||
protected String name; //the player's Name
|
protected String name; //the player's Name
|
||||||
|
|||||||
@ -1,9 +1,12 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.Spiellogikentwurf;
|
package ch.unibas.dmi.dbis.cs108.Spiellogikentwurf;
|
||||||
|
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||||
import org.apache.logging.log4j.*;
|
import org.apache.logging.log4j.*;
|
||||||
|
|
||||||
public class Game {
|
public class Game {
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can be extended for optional Game-settings
|
* Can be extended for optional Game-settings
|
||||||
|
|||||||
@ -1,9 +1,14 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.Spiellogikentwurf;
|
package ch.unibas.dmi.dbis.cs108.Spiellogikentwurf;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||||
import ch.unibas.dmi.dbis.cs108.Klassenstruktur.Human;
|
import ch.unibas.dmi.dbis.cs108.Klassenstruktur.Human;
|
||||||
import ch.unibas.dmi.dbis.cs108.Klassenstruktur.Passenger;
|
import ch.unibas.dmi.dbis.cs108.Klassenstruktur.Passenger;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class GameFunctions {
|
public class GameFunctions {
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can be extended for optional Game-settings
|
* Can be extended for optional Game-settings
|
||||||
|
|||||||
@ -1,14 +1,20 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.multiplayer.client;
|
package ch.unibas.dmi.dbis.cs108.multiplayer.client;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||||
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.ClientPinger;
|
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.ClientPinger;
|
||||||
|
|
||||||
|
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
public class Client {
|
public class Client {
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
private Socket socket;
|
private Socket socket;
|
||||||
private BufferedReader in;
|
private BufferedReader in;
|
||||||
|
|||||||
@ -1,8 +1,13 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.multiplayer.client;
|
package ch.unibas.dmi.dbis.cs108.multiplayer.client;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||||
import ch.unibas.dmi.dbis.cs108.multiplayer.server.ClientHandler;
|
import ch.unibas.dmi.dbis.cs108.multiplayer.server.ClientHandler;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class JClientProtocolParser {
|
public class JClientProtocolParser {
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by the client to parse an incoming protocol message.
|
* Used by the client to parse an incoming protocol message.
|
||||||
|
|||||||
@ -1,6 +1,12 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.multiplayer.client;
|
package ch.unibas.dmi.dbis.cs108.multiplayer.client;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class MessageFormatter {
|
public class MessageFormatter {
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes a given Message and reformats it to where the JServerProtocolParser.parse() method can
|
* Takes a given Message and reformats it to where the JServerProtocolParser.parse() method can
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.multiplayer.helpers;
|
package ch.unibas.dmi.dbis.cs108.multiplayer.helpers;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a ping to the server ("CPING") every 2 seconds and checks if it has gotten a pingback. The
|
* Sends a ping to the server ("CPING") every 2 seconds and checks if it has gotten a pingback. The
|
||||||
@ -10,6 +13,8 @@ import java.net.Socket;
|
|||||||
* how the client receives and parses messages.
|
* how the client receives and parses messages.
|
||||||
*/
|
*/
|
||||||
public class ClientPinger implements Runnable {
|
public class ClientPinger implements Runnable {
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
private boolean gotPingBack; //should be set to true when client gets a pingback.
|
private boolean gotPingBack; //should be set to true when client gets a pingback.
|
||||||
private boolean isConnected; //set to true unless the ClientPinger detects a connection loss.
|
private boolean isConnected; //set to true unless the ClientPinger detects a connection loss.
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.multiplayer.helpers;
|
package ch.unibas.dmi.dbis.cs108.multiplayer.helpers;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a ping to the client ("SPING") every 2 seconds and checks if it has gotten a pingback. The
|
* Sends a ping to the client ("SPING") every 2 seconds and checks if it has gotten a pingback. The
|
||||||
@ -10,6 +13,8 @@ import java.net.Socket;
|
|||||||
* how the server receives and parses messages.
|
* how the server receives and parses messages.
|
||||||
*/
|
*/
|
||||||
public class ServerPinger implements Runnable {
|
public class ServerPinger implements Runnable {
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
private boolean gotPingBack; //should be set to true (via setGotPingBack) as soon as the server gets a pingback.
|
private boolean gotPingBack; //should be set to true (via setGotPingBack) as soon as the server gets a pingback.
|
||||||
private boolean isConnected; //set to true unless the ServerPinger detects a connection loss.
|
private boolean isConnected; //set to true unless the ServerPinger detects a connection loss.
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.multiplayer.server;
|
package ch.unibas.dmi.dbis.cs108.multiplayer.server;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is built to contain the usernames of all players in a single string. This allows a
|
* This class is built to contain the usernames of all players in a single string. This allows a
|
||||||
* duplicate check (ClientHandler) when a new player chooses a name: does the string with all
|
* duplicate check (ClientHandler) when a new player chooses a name: does the string with all
|
||||||
@ -8,6 +12,8 @@ package ch.unibas.dmi.dbis.cs108.multiplayer.server;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class AllClientNames {
|
public class AllClientNames {
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
static StringBuilder names = new StringBuilder();
|
static StringBuilder names = new StringBuilder();
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,17 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.multiplayer.server;
|
package ch.unibas.dmi.dbis.cs108.multiplayer.server;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||||
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.ServerPinger;
|
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.ServerPinger;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class ClientHandler implements Runnable {
|
public class ClientHandler implements Runnable {
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
private String clientUserName;
|
private String clientUserName;
|
||||||
private BufferedWriter out;
|
private BufferedWriter out;
|
||||||
|
|||||||
@ -1,7 +1,13 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.multiplayer.server;
|
package ch.unibas.dmi.dbis.cs108.multiplayer.server;
|
||||||
|
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class JServerProtocolParser {
|
public class JServerProtocolParser {
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by the server (i.e. ClientHandler) to parse an incoming protocol message.
|
* Used by the server (i.e. ClientHandler) to parse an incoming protocol message.
|
||||||
|
|||||||
@ -1,9 +1,14 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.multiplayer.server;
|
package ch.unibas.dmi.dbis.cs108.multiplayer.server;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
public class NameGenerator {
|
public class NameGenerator {
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a random alteration of a Name by adding 4 numbers at the end of the Name that shall be
|
* Creates a random alteration of a Name by adding 4 numbers at the end of the Name that shall be
|
||||||
|
|||||||
@ -1,12 +1,17 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.multiplayer.server;
|
package ch.unibas.dmi.dbis.cs108.multiplayer.server;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class Server {
|
public class Server {
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
private static final int gamePort = 42069;
|
private static final int gamePort = 42069;
|
||||||
private HashSet<ClientHandler> connectedClients = new HashSet<>();
|
private HashSet<ClientHandler> connectedClients = new HashSet<>();
|
||||||
|
|||||||
Reference in New Issue
Block a user