* Fixed encoding glitch that causes special characters not to show up.

* Maven build script will now generate a Windows EXE file.
* Minor cleanup & updates to take advantage of JDK/JRE 8 features and syntax.
This commit is contained in:
StevenLawson 2017-06-27 21:47:41 -04:00
parent 930a4a37e6
commit 1408e4d09e
21 changed files with 283 additions and 225 deletions

Binary file not shown.

View file

@ -3,15 +3,13 @@ FreedomTelnetClient
FreedomTelnetClient (previously BukkitTelnetClient) is a telnet client for use with the BukkitTelnet and TotalFreedomMod CraftBukkit plugins. FreedomTelnetClient (previously BukkitTelnetClient) is a telnet client for use with the BukkitTelnet and TotalFreedomMod CraftBukkit plugins.
Grab the latest release binary (2.0.5) here: Grab the latest release binary (2.0.06) here:
https://github.com/StevenLawson/FreedomTelnetClient/releases/latest https://github.com/StevenLawson/FreedomTelnetClient/releases/latest
New features for 2.0.5 New features for 2.0.06 (6/27/2017)
--------------------- ---------------------
* ftc_settings.xml file: * Fixed encoding glitch that causes special characters not to show up.
* Lets you define custom commands for the player list's right-click dropdown. * (For Coders) Maven build script will now generate a Windows EXE file.
* Saves a history of your servers with a a descriptive name for the server address. * (For Coders) Minor cleanup & updates to take advantage of JDK/JRE 8 features and syntax.
* Define "favorite" command buttons for new "Commands" tab.
* "Reason" input dialog for applicable commands (any command that has a $REASON wildcard).

BIN
icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

View file

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>run</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals>
<properties>
<exec.args>-classpath %classpath me.StevenLawson.BukkitTelnetClient.BukkitTelnetClient</exec.args>
<exec.executable>java</exec.executable>
</properties>
</action>
</actions>

167
pom.xml
View file

@ -3,14 +3,105 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>me.StevenLawson</groupId> <groupId>me.StevenLawson</groupId>
<artifactId>FreedomTelnetClient</artifactId> <artifactId>FreedomTelnetClient</artifactId>
<version>2.0.5</version> <version>2.0.06</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>FreedomTelnetClient</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<version>${project.version}</version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20170516</version>
</dependency>
</dependencies>
<build> <build>
<plugins> <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<revisionOnScmFailure>true</revisionOnScmFailure>
</configuration>
<executions>
<execution>
<id>create-timestamp-date</id>
<phase>validate</phase>
<goals>
<goal>create-timestamp</goal>
</goals>
<configuration>
<timestampFormat>MM/dd/yyyy</timestampFormat>
<timestampPropertyName>timestampDate</timestampPropertyName>
</configuration>
</execution>
<execution>
<id>create-timestamp-combined</id>
<phase>validate</phase>
<goals>
<goal>create-timestamp</goal>
</goals>
<configuration>
<timestampFormat>MMddyy-HHmmss</timestampFormat>
<timestampPropertyName>timestampCombined</timestampPropertyName>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>write-project-properties</goal>
</goals>
<configuration>
<outputFile>${project.build.outputDirectory}/my.properties</outputFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>2.3</version> <version>2.4.3</version>
<executions> <executions>
<execution> <execution>
<phase>package</phase> <phase>package</phase>
@ -30,34 +121,50 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<version>1.7.18</version>
<executions>
<execution>
<id>l4j</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<dontWrapJar>false</dontWrapJar>
<headerType>gui</headerType>
<jar>${project.build.directory}/${project.build.finalName}-shaded.jar</jar>
<outfile>${project.build.directory}/${project.build.finalName}-${timestampCombined}.exe</outfile>
<errTitle></errTitle>
<cmdLine></cmdLine>
<chdir>.</chdir>
<priority>normal</priority>
<downloadUrl>http://java.com/download</downloadUrl>
<supportUrl></supportUrl>
<stayAlive>false</stayAlive>
<restartOnCrash>false</restartOnCrash>
<manifest></manifest>
<icon>icon.ico</icon>
<singleInstance>
<mutexName>${project.artifactId}</mutexName>
<windowTitle></windowTitle>
</singleInstance>
<jre>
<path>jre</path>
<bundledJre64Bit>false</bundledJre64Bit>
<bundledJreAsFallback>false</bundledJreAsFallback>
<minVersion>1.8.0_0</minVersion>
<maxVersion></maxVersion>
<jdkPreference>preferJre</jdkPreference>
<runtimeBits>64/32</runtimeBits>
</jre>
</configuration>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20140107</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<name>FreedomTelnetClient</name>
</project> </project>

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2012-2014 Steven Lawson * Copyright (C) 2012-2017 Steven Lawson
* *
* This file is part of FreedomTelnetClient. * This file is part of FreedomTelnetClient.
* *

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2012-2014 Steven Lawson * Copyright (C) 2012-2017 Steven Lawson
* *
* This file is part of FreedomTelnetClient. * This file is part of FreedomTelnetClient.
* *
@ -19,15 +19,13 @@
package me.StevenLawson.BukkitTelnetClient; package me.StevenLawson.BukkitTelnetClient;
import java.awt.Color; import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import javax.swing.Timer; import javax.swing.Timer;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.commons.net.telnet.TelnetClient; import org.apache.commons.net.telnet.TelnetClient;
@ -142,7 +140,7 @@ public class BTC_ConnectionManager
return; return;
} }
this.telnetClient.getOutputStream().write((text + "\r\n").getBytes()); this.telnetClient.getOutputStream().write((text + "\r\n").getBytes(StandardCharsets.UTF_8));
this.telnetClient.getOutputStream().flush(); this.telnetClient.getOutputStream().flush();
} }
catch (IOException ex) catch (IOException ex)
@ -153,15 +151,7 @@ public class BTC_ConnectionManager
public void sendDelayedCommand(final String text, final boolean verbose, final int delay) public void sendDelayedCommand(final String text, final boolean verbose, final int delay)
{ {
final Timer timer = new Timer(delay, new ActionListener() final Timer timer = new Timer(delay, event -> sendCommand(text, verbose));
{
@Override
public void actionPerformed(ActionEvent ae)
{
sendCommand(text, verbose);
}
});
timer.setRepeats(false); timer.setRepeats(false);
timer.start(); timer.start();
} }
@ -173,10 +163,7 @@ public class BTC_ConnectionManager
return; return;
} }
this.connectThread = new Thread(new Runnable() this.connectThread = new Thread(() ->
{
@Override
public void run()
{ {
final BTC_MainPanel btc = BukkitTelnetClient.mainPanel; final BTC_MainPanel btc = BukkitTelnetClient.mainPanel;
@ -189,7 +176,7 @@ public class BTC_ConnectionManager
btc.getTxtCommand().setEnabled(true); btc.getTxtCommand().setEnabled(true);
btc.getTxtCommand().requestFocusInWindow(); btc.getTxtCommand().requestFocusInWindow();
try (final BufferedReader reader = new BufferedReader(new InputStreamReader(telnetClient.getInputStream()))) try (final BufferedReader reader = new BufferedReader(new InputStreamReader(telnetClient.getInputStream(), StandardCharsets.UTF_8)))
{ {
String line; String line;
while ((line = reader.readLine()) != null) while ((line = reader.readLine()) != null)
@ -234,13 +221,12 @@ public class BTC_ConnectionManager
} }
catch (IOException ex) catch (IOException ex)
{ {
btc.writeToConsole(new BTC_ConsoleMessage(ex.getMessage() + SystemUtils.LINE_SEPARATOR + ExceptionUtils.getStackTrace(ex))); btc.writeToConsole(new BTC_ConsoleMessage(ex.getMessage() + System.lineSeparator() + ExceptionUtils.getStackTrace(ex)));
} }
finishDisconnect(); finishDisconnect();
BTC_ConnectionManager.this.connectThread = null; BTC_ConnectionManager.this.connectThread = null;
}
}); });
this.connectThread.start(); this.connectThread.start();
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2012-2014 Steven Lawson * Copyright (C) 2012-2017 Steven Lawson
* *
* This file is part of FreedomTelnetClient. * This file is part of FreedomTelnetClient.
* *

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2012-2014 Steven Lawson * Copyright (C) 2012-2017 Steven Lawson
* *
* This file is part of FreedomTelnetClient. * This file is part of FreedomTelnetClient.
* *
@ -19,7 +19,6 @@
package me.StevenLawson.BukkitTelnetClient; package me.StevenLawson.BukkitTelnetClient;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.Collection; import java.util.Collection;
import javax.swing.JButton; import javax.swing.JButton;
@ -31,16 +30,12 @@ public class BTC_FavoriteButtonsPanel extends JPanel
{ {
super.setLayout(new GridBagLayout()); super.setLayout(new GridBagLayout());
final ActionListener actionListener = new ActionListener() final ActionListener actionListener = event ->
{
@Override
public void actionPerformed(final ActionEvent event)
{ {
if (BukkitTelnetClient.mainPanel != null) if (BukkitTelnetClient.mainPanel != null)
{ {
BukkitTelnetClient.mainPanel.getConnectionManager().sendDelayedCommand(event.getActionCommand(), true, 100); BukkitTelnetClient.mainPanel.getConnectionManager().sendDelayedCommand(event.getActionCommand(), true, 100);
} }
}
}; };
int x = 0; int x = 0;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2012-2014 Steven Lawson * Copyright (C) 2012-2017 Steven Lawson
* *
* This file is part of FreedomTelnetClient. * This file is part of FreedomTelnetClient.
* *
@ -30,7 +30,6 @@ import javax.swing.Timer;
import javax.swing.table.AbstractTableModel; import javax.swing.table.AbstractTableModel;
import javax.swing.text.*; import javax.swing.text.*;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
public class BTC_MainPanel extends javax.swing.JFrame public class BTC_MainPanel extends javax.swing.JFrame
{ {
@ -128,16 +127,14 @@ public class BTC_MainPanel extends javax.swing.JFrame
private void writeToConsoleImmediately(final BTC_ConsoleMessage message, final boolean isTelnetError) private void writeToConsoleImmediately(final BTC_ConsoleMessage message, final boolean isTelnetError)
{ {
SwingUtilities.invokeLater(new Runnable() SwingUtilities.invokeLater(() ->
{
@Override
public void run()
{ {
if (isTelnetError && chkIgnoreErrors.isSelected()) if (isTelnetError && chkIgnoreErrors.isSelected())
{ {
return; // Do Nothing
} }
else
{
final StyledDocument styledDocument = mainOutput.getStyledDocument(); final StyledDocument styledDocument = mainOutput.getStyledDocument();
int startLength = styledDocument.getLength(); int startLength = styledDocument.getLength();
@ -146,7 +143,7 @@ public class BTC_MainPanel extends javax.swing.JFrame
{ {
styledDocument.insertString( styledDocument.insertString(
styledDocument.getLength(), styledDocument.getLength(),
message.getMessage() + SystemUtils.LINE_SEPARATOR, message.getMessage() + System.lineSeparator(),
StyleContext.getDefaultStyleContext().addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, message.getColor()) StyleContext.getDefaultStyleContext().addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, message.getColor())
); );
} }
@ -165,14 +162,7 @@ public class BTC_MainPanel extends javax.swing.JFrame
{ {
BTC_MainPanel.this.mainOutput.setCaretPosition(startLength); BTC_MainPanel.this.mainOutput.setCaretPosition(startLength);
final Timer timer = new Timer(10, new ActionListener() final Timer timer = new Timer(10, event -> vScroll.setValue(vScroll.getMaximum()));
{
@Override
public void actionPerformed(ActionEvent ae)
{
vScroll.setValue(vScroll.getMaximum());
}
});
timer.setRepeats(false); timer.setRepeats(false);
timer.start(); timer.start();
} }
@ -241,10 +231,7 @@ public class BTC_MainPanel extends javax.swing.JFrame
public final void updatePlayerList(final String selectedPlayerName) public final void updatePlayerList(final String selectedPlayerName)
{ {
EventQueue.invokeLater(new Runnable() EventQueue.invokeLater(() ->
{
@Override
public void run()
{ {
playerListTableModel.fireTableDataChanged(); playerListTableModel.fireTableDataChanged();
@ -263,7 +250,6 @@ public class BTC_MainPanel extends javax.swing.JFrame
} }
} }
} }
}
}); });
} }
@ -337,10 +323,7 @@ public class BTC_MainPanel extends javax.swing.JFrame
popup.addSeparator(); popup.addSeparator();
final ActionListener popupAction = new ActionListener() final ActionListener popupAction = actionEvent ->
{
@Override
public void actionPerformed(ActionEvent actionEvent)
{ {
Object _source = actionEvent.getSource(); Object _source = actionEvent.getSource();
if (_source instanceof PlayerListPopupItem_Command) if (_source instanceof PlayerListPopupItem_Command)
@ -377,7 +360,6 @@ public class BTC_MainPanel extends javax.swing.JFrame
} }
} }
} }
}
}; };
for (final PlayerCommandEntry command : BukkitTelnetClient.config.getCommands()) for (final PlayerCommandEntry command : BukkitTelnetClient.config.getCommands())

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2012-2014 Steven Lawson * Copyright (C) 2012-2017 Steven Lawson
* *
* This file is part of FreedomTelnetClient. * This file is part of FreedomTelnetClient.
* *

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2012-2014 Steven Lawson * Copyright (C) 2012-2017 Steven Lawson
* *
* This file is part of FreedomTelnetClient. * This file is part of FreedomTelnetClient.
* *

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2012-2014 Steven Lawson * Copyright (C) 2012-2017 Steven Lawson
* *
* This file is part of FreedomTelnetClient. * This file is part of FreedomTelnetClient.
* *
@ -18,14 +18,17 @@
*/ */
package me.StevenLawson.BukkitTelnetClient; package me.StevenLawson.BukkitTelnetClient;
import java.io.InputStream;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.swing.SwingUtilities;
public class BukkitTelnetClient public class BukkitTelnetClient
{ {
public static final String VERSION_STRING = "v2.0.5"; public static final String VERSION_STRING = getVersionString();
public static final Logger LOGGER = Logger.getLogger(BukkitTelnetClient.class.getName()); public static final Logger LOGGER = Logger.getLogger(BukkitTelnetClient.class.getName());
public static BTC_MainPanel mainPanel = null; public static BTC_MainPanel mainPanel = null;
public static BTC_ConfigLoader config = new BTC_ConfigLoader(); public static BTC_ConfigLoader config = new BTC_ConfigLoader();
@ -36,14 +39,10 @@ public class BukkitTelnetClient
findAndSetLookAndFeel("Windows"); findAndSetLookAndFeel("Windows");
java.awt.EventQueue.invokeLater(new Runnable() SwingUtilities.invokeLater(() ->
{
@Override
public void run()
{ {
mainPanel = new BTC_MainPanel(); mainPanel = new BTC_MainPanel();
mainPanel.setup(); mainPanel.setup();
}
}); });
} }
@ -100,4 +99,19 @@ public class BukkitTelnetClient
return annotation; return annotation;
} }
public static String getVersionString()
{
try (final InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("my.properties"))
{
final Properties properties = new Properties();
properties.load(inputStream);
return String.format("v%s", properties.getProperty("version"));
}
catch (Exception ex)
{
LOGGER.log(Level.SEVERE, null, ex);
}
return "Unknown";
}
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2012-2014 Steven Lawson * Copyright (C) 2012-2017 Steven Lawson
* *
* This file is part of FreedomTelnetClient. * This file is part of FreedomTelnetClient.
* *

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2012-2014 Steven Lawson * Copyright (C) 2012-2017 Steven Lawson
* *
* This file is part of FreedomTelnetClient. * This file is part of FreedomTelnetClient.
* *

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2012-2014 Steven Lawson * Copyright (C) 2012-2017 Steven Lawson
* *
* This file is part of FreedomTelnetClient. * This file is part of FreedomTelnetClient.
* *
@ -57,7 +57,7 @@ public class FavoriteButtonEntry extends ConfigEntry
{ {
public FavoriteButtonEntryList() public FavoriteButtonEntryList()
{ {
super(new ArrayList<FavoriteButtonEntry>(), FavoriteButtonEntry.class); super(new ArrayList<>(), FavoriteButtonEntry.class);
} }
@Override @Override

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2012-2014 Steven Lawson * Copyright (C) 2012-2017 Steven Lawson
* *
* This file is part of FreedomTelnetClient. * This file is part of FreedomTelnetClient.
* *

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2012-2014 Steven Lawson * Copyright (C) 2012-2017 Steven Lawson
* *
* This file is part of FreedomTelnetClient. * This file is part of FreedomTelnetClient.
* *

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2012-2014 Steven Lawson * Copyright (C) 2012-2017 Steven Lawson
* *
* This file is part of FreedomTelnetClient. * This file is part of FreedomTelnetClient.
* *
@ -86,7 +86,7 @@ public class PlayerCommandEntry extends ConfigEntry
{ {
public PlayerCommandEntryList() public PlayerCommandEntryList()
{ {
super(new ArrayList<PlayerCommandEntry>(), PlayerCommandEntry.class); super(new ArrayList<>(), PlayerCommandEntry.class);
} }
@Override @Override

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2012-2014 Steven Lawson * Copyright (C) 2012-2017 Steven Lawson
* *
* This file is part of FreedomTelnetClient. * This file is part of FreedomTelnetClient.
* *
@ -207,13 +207,6 @@ public class PlayerInfo
public static Comparator<PlayerInfo> getComparator() public static Comparator<PlayerInfo> getComparator()
{ {
return new Comparator<PlayerInfo>() return (PlayerInfo a, PlayerInfo b) -> a.getName().compareTo(b.getName());
{
@Override
public int compare(PlayerInfo a, PlayerInfo b)
{
return a.getName().compareTo(b.getName());
}
};
} }
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2012-2014 Steven Lawson * Copyright (C) 2012-2017 Steven Lawson
* *
* This file is part of FreedomTelnetClient. * This file is part of FreedomTelnetClient.
* *
@ -121,7 +121,7 @@ public class ServerEntry extends ConfigEntry
{ {
public ServerEntryList() public ServerEntryList()
{ {
super(new HashSet<ServerEntry>(), ServerEntry.class); super(new HashSet<>(), ServerEntry.class);
} }
@Override @Override