Skip to content

Commit

Permalink
Bump dependencies, bump version, fix minor stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Kakifrucht committed Apr 28, 2022
1 parent 7bf1691 commit 74c1cbe
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 35 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Current features
- Sends list containing every available command per client
- Checks if client has permission
- Sends correct usage and description
- When calling !help *querypassword* highest available group will be granted (can be disabled)
- When calling !help *querypassword* the highest available group will be granted (can be disabled)
- !rank (*not on master branch*)
- Automatic retrieval of ranks after querying Halfminer REST API for privileges
- Removes old server group, even if a different identity was used
Expand Down
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>de.halfminer</groupId>
<artifactId>HalfminerBot</artifactId>
<name>Halfminer Bot</name>
<version>1.4.2</version>
<version>1.4.3</version>
<packaging>jar</packaging>

<properties>
Expand Down Expand Up @@ -74,32 +74,32 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.32</version>
<version>1.7.36</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.16.0</version>
<version>2.17.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.16.0</version>
<version>2.17.2</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.1.1-jre</version>
<version>31.1-jre</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.7</version>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.29</version>
<version>1.30</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/halfminer/hmbot/BotListeners.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.slf4j.LoggerFactory;

/**
* Event listeners for bot. Passes commands to {@link CommandDispatcher} and contacts the client on server/channel join.
* Event listeners for bot. Passes command to {@link CommandDispatcher} and contacts the client on server/channel join.
*/
class BotListeners extends TS3EventAdapter {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/halfminer/hmbot/StateHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public interface StateHolder {
String getVersion();

/**
* Reload the bots config.
* Reload the configuration.
*
* @return true if config was reloaded, false if it couldn't be read or no changes were made to it
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/halfminer/hmbot/cmd/CmdChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void run() throws InvalidCommandException {

private void createChannel() {

// move if user has channel already
// move if user has a channel already
if (client.moveToChannel(clientId)) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/halfminer/hmbot/cmd/CmdHelp.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* - Sends list containing every available command per client
* - Checks if client has permission
* - Sends correct usage and description
* - When calling !help < querypassword> highest available group will be granted (can be disabled)
* - When calling !help < querypassword> the highest available group will be granted (can be disabled)
*/
class CmdHelp extends Command {

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/halfminer/hmbot/cmd/CommandEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ enum CommandEnum {
CHANNEL (CmdChannel.class),
HELP (CmdHelp.class);

private Class<?> aClass;
private final Class<?> aClass;

CommandEnum(Class aClass) {
CommandEnum(Class<?> aClass) {
this.aClass = aClass;
}

Expand Down
7 changes: 4 additions & 3 deletions src/main/java/de/halfminer/hmbot/config/YamlConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.yaml.snakeyaml.Yaml;

import java.io.*;
import java.nio.file.Files;
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -73,7 +74,7 @@ private void loadYaml() throws ConfigurationException {
configParsed = defaultParsed;

try (InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(fileName);
OutputStream outputStream = new FileOutputStream(configFile)) {
OutputStream outputStream = Files.newOutputStream(configFile.toPath())) {

// manually copy file
byte[] buffer = new byte[1024];
Expand Down Expand Up @@ -102,7 +103,7 @@ private void loadYaml() throws ConfigurationException {
if (loaded == null || loaded instanceof Map) {
try {
//noinspection unchecked
configParsed = loaded != null ? (Map) loaded : Collections.emptyMap();
configParsed = loaded != null ? (Map<String, Object>) loaded : Collections.emptyMap();
logger.info("Configuration file {} loaded successfully", configFile.getName());
} catch (ClassCastException e) {
throw new ConfigurationException("Config file is in invalid format", e);
Expand Down Expand Up @@ -154,7 +155,7 @@ private Object get(String path, Map<String, Object> getFrom) {
while (separator.meetsLength(currentIndex + 2)) {
Object checkIfSubsection = currentSection.get(separator.getArgument(currentIndex));
if (checkIfSubsection instanceof Map) {
currentSection = (Map) checkIfSubsection;
currentSection = (Map<?, ?>) checkIfSubsection;
} else {
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/halfminer/hmbot/storage/ClientMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ void reload() {

Object loaded = new Yaml().load(reader);
if (loaded instanceof Map) {
for (Map.Entry o : ((Map<?, ?>) loaded).entrySet()) {
for (Map.Entry<?, ?> o : ((Map<?, ?>) loaded).entrySet()) {
if (o.getValue() instanceof Map) {
Map<?, ?> currentMap = (Map) o.getValue();
Map<?, ?> currentMap = (Map<?, ?>) o.getValue();
int databaseId = (int) o.getKey();
int channelID = (Integer) currentMap.get("channelID");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class DefaultHalfClient extends BotClass implements HalfClient {
private HalfGroup group;

/**
* Counts how many clients with this clients database/unique ID are online, as there can be multiple connections.
* Counts how many clients with this database/unique ID are online, as there can be multiple connections.
*/
private int onlineCount = 0;
private final Map<Class, Long> commandCooldown = new ConcurrentHashMap<>();
private final Map<Class<?>, Long> commandCooldown = new ConcurrentHashMap<>();

private int channelId = Integer.MIN_VALUE;

Expand All @@ -40,7 +40,7 @@ public boolean hasPermission(String permission) {
}

@Override
public long getCooldown(Class commandClass) {
public long getCooldown(Class<?> commandClass) {
clearCommandCooldown();
if (!hasPermission("cmd.bypass.cooldown") && commandCooldown.containsKey(commandClass)) {
return commandCooldown.get(commandClass) - (System.currentTimeMillis() / 1000);
Expand All @@ -49,7 +49,7 @@ public long getCooldown(Class commandClass) {
}

@Override
public void addCooldown(Class commandClass, int cooldownSeconds) {
public void addCooldown(Class<?> commandClass, int cooldownSeconds) {
commandCooldown.put(commandClass, (System.currentTimeMillis() / 1000) + cooldownSeconds);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/halfminer/hmbot/storage/DefaultStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void configWasReloaded() {

// load groups and their permissions from config
groups.clear();
Map<?, ?> groupYamlMap = (Map) config.get("groups", Map.class);
Map<?, ?> groupYamlMap = (Map<?, ?>) config.get("groups", Map.class);
for (Map.Entry<?, ?> entry : groupYamlMap.entrySet()) {

if (entry.getKey() instanceof String
Expand All @@ -44,7 +44,7 @@ public void configWasReloaded() {
int talkPower = (Integer) entry.getValue();
Set<String> permissions = new HashSet<>();

List<?> permissionsObj = (List) config.get("permissions." + groupName, List.class);
List<?> permissionsObj = (List<?>) config.get("permissions." + groupName, List.class);
if (permissionsObj != null) {
for (Object o : permissionsObj) {
permissions.add(String.valueOf(o).toLowerCase());
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/halfminer/hmbot/storage/HalfClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ public interface HalfClient {

boolean hasPermission(String permission);

long getCooldown(Class commandClass);
long getCooldown(Class<?> commandClass);

void addCooldown(Class commandClass, int cooldownSeconds);
void addCooldown(Class<?> commandClass, int cooldownSeconds);

void setChannelId(int channelId);

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/halfminer/hmbot/task/ExecutorScheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class ExecutorScheduler implements Scheduler {

private ScheduledExecutorService service;
private Map<Task, ScheduledFuture> registeredTasks;
private Map<Task, ScheduledFuture<?>> registeredTasks;

private List<Task> allTasks;

Expand Down Expand Up @@ -63,7 +63,7 @@ private void updateTaskRegister(Task task) {

if (registeredTasks.containsKey(task)) {

ScheduledFuture registeredTask = registeredTasks.get(task);
ScheduledFuture<?> registeredTask = registeredTasks.get(task);
if (task.shouldRegisterTask()) {
// check if period was changed and re-register if required
if (task.shouldReregisterTask()) {
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/de/halfminer/hmbot/util/MessageBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ public void sendMessage(int clientId) {
}
}

public void broadcastMessage(boolean log) {
broadcastMessage(log, 0);
}

public void broadcastMessage(boolean log, int minimumTalkPower) {
String messageToBroadcast = returnMessage();
if (messageToBroadcast.length() > 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#HalfminerBot configuration
#Server address to connect to, can be a domain name or IP address
#Server-address to connect to, can be a domain name or IP address
host: 'localhost'
#Whether the bot will connect via SSH, recommended if running the bot over the internet, SSH adds a minor overhead
#Changes to this value won't be taken into account when reloading the bot via *!bot reload*, use *!bot restart* instead
Expand Down Expand Up @@ -60,7 +60,7 @@ groups:
#Key is the groups name (can be changed) and value is talk power requirement
#You can add as many groups as you like, but they cannot have the same talk power
#WARNING: Enable the "skip" flag for talk power on the group permission setup screen, to ensure that client/channel
# talk power does not accidentally overwrite the value and puts the client in a higher group after a reload
# talk power does not accidentally overwrite the value and puts the client in a higher group after reloading
admin: 100
moderator: 50
donator: 10
Expand Down

0 comments on commit 74c1cbe

Please sign in to comment.