* 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.
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
New features for 2.0.5
New features for 2.0.06 (6/27/2017)
---------------------
* ftc_settings.xml file:
* Lets you define custom commands for the player list's right-click dropdown.
* Saves a history of your servers with a a descriptive name for the server address.
* Define "favorite" command buttons for new "Commands" tab.
* "Reason" input dialog for applicable commands (any command that has a $REASON wildcard).
* Fixed encoding glitch that causes special characters not to show up.
* (For Coders) Maven build script will now generate a Windows EXE file.
* (For Coders) Minor cleanup & updates to take advantage of JDK/JRE 8 features and syntax.

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>
<groupId>me.StevenLawson</groupId>
<artifactId>FreedomTelnetClient</artifactId>
<version>2.0.5</version>
<version>2.0.06</version>
<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>
<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>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
@ -30,34 +121,50 @@
</execution>
</executions>
</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>
</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>

View file

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

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2012-2014 Steven Lawson
* Copyright (C) 2012-2017 Steven Lawson
*
* This file is part of FreedomTelnetClient.
*
@ -19,7 +19,6 @@
package me.StevenLawson.BukkitTelnetClient;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collection;
import javax.swing.JButton;
@ -31,16 +30,12 @@ public class BTC_FavoriteButtonsPanel extends JPanel
{
super.setLayout(new GridBagLayout());
final ActionListener actionListener = new ActionListener()
{
@Override
public void actionPerformed(final ActionEvent event)
final ActionListener actionListener = event ->
{
if (BukkitTelnetClient.mainPanel != null)
{
BukkitTelnetClient.mainPanel.getConnectionManager().sendDelayedCommand(event.getActionCommand(), true, 100);
}
}
};
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.
*
@ -30,7 +30,6 @@ import javax.swing.Timer;
import javax.swing.table.AbstractTableModel;
import javax.swing.text.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
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)
{
SwingUtilities.invokeLater(new Runnable()
{
@Override
public void run()
SwingUtilities.invokeLater(() ->
{
if (isTelnetError && chkIgnoreErrors.isSelected())
{
return;
// Do Nothing
}
else
{
final StyledDocument styledDocument = mainOutput.getStyledDocument();
int startLength = styledDocument.getLength();
@ -146,7 +143,7 @@ public class BTC_MainPanel extends javax.swing.JFrame
{
styledDocument.insertString(
styledDocument.getLength(),
message.getMessage() + SystemUtils.LINE_SEPARATOR,
message.getMessage() + System.lineSeparator(),
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);
final Timer timer = new Timer(10, new ActionListener()
{
@Override
public void actionPerformed(ActionEvent ae)
{
vScroll.setValue(vScroll.getMaximum());
}
});
final Timer timer = new Timer(10, event -> vScroll.setValue(vScroll.getMaximum()));
timer.setRepeats(false);
timer.start();
}
@ -241,10 +231,7 @@ public class BTC_MainPanel extends javax.swing.JFrame
public final void updatePlayerList(final String selectedPlayerName)
{
EventQueue.invokeLater(new Runnable()
{
@Override
public void run()
EventQueue.invokeLater(() ->
{
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();
final ActionListener popupAction = new ActionListener()
{
@Override
public void actionPerformed(ActionEvent actionEvent)
final ActionListener popupAction = actionEvent ->
{
Object _source = actionEvent.getSource();
if (_source instanceof PlayerListPopupItem_Command)
@ -377,7 +360,6 @@ public class BTC_MainPanel extends javax.swing.JFrame
}
}
}
}
};
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.
*

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2012-2014 Steven Lawson
* Copyright (C) 2012-2017 Steven Lawson
*
* 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.
*
@ -18,14 +18,17 @@
*/
package me.StevenLawson.BukkitTelnetClient;
import java.io.InputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.SwingUtilities;
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 BTC_MainPanel mainPanel = null;
public static BTC_ConfigLoader config = new BTC_ConfigLoader();
@ -36,14 +39,10 @@ public class BukkitTelnetClient
findAndSetLookAndFeel("Windows");
java.awt.EventQueue.invokeLater(new Runnable()
{
@Override
public void run()
SwingUtilities.invokeLater(() ->
{
mainPanel = new BTC_MainPanel();
mainPanel.setup();
}
});
}
@ -100,4 +99,19 @@ public class BukkitTelnetClient
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.
*

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2012-2014 Steven Lawson
* Copyright (C) 2012-2017 Steven Lawson
*
* 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.
*
@ -57,7 +57,7 @@ public class FavoriteButtonEntry extends ConfigEntry
{
public FavoriteButtonEntryList()
{
super(new ArrayList<FavoriteButtonEntry>(), FavoriteButtonEntry.class);
super(new ArrayList<>(), FavoriteButtonEntry.class);
}
@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.
*

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2012-2014 Steven Lawson
* Copyright (C) 2012-2017 Steven Lawson
*
* 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.
*
@ -86,7 +86,7 @@ public class PlayerCommandEntry extends ConfigEntry
{
public PlayerCommandEntryList()
{
super(new ArrayList<PlayerCommandEntry>(), PlayerCommandEntry.class);
super(new ArrayList<>(), PlayerCommandEntry.class);
}
@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.
*
@ -207,13 +207,6 @@ public class PlayerInfo
public static Comparator<PlayerInfo> getComparator()
{
return new Comparator<PlayerInfo>()
{
@Override
public int compare(PlayerInfo a, PlayerInfo b)
{
return a.getName().compareTo(b.getName());
}
};
return (PlayerInfo a, PlayerInfo b) -> 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.
*
@ -121,7 +121,7 @@ public class ServerEntry extends ConfigEntry
{
public ServerEntryList()
{
super(new HashSet<ServerEntry>(), ServerEntry.class);
super(new HashSet<>(), ServerEntry.class);
}
@Override