Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Melhorias diversas #1

Merged
merged 19 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Make sure to follow these instructions:

**Platform on which you run NuVotifier**: <!-- Either Bukkit, Sponge, BungeeCord, or Velocity. -->

**Version of NuVotifier**:
**Version of NuVotifier**:

```
<!--
Expand All @@ -57,15 +57,16 @@ Velocity: Use /velocity plugins from in-game and hover over "nuvotifier"
```

**Relevant log**: <!-- Paste the log on https://gist.github.com/, replace this with link -->

### Details

**Description**
**Description**
<!-- Replace this with a brief summary of the bug. -->

**Steps to reproduce**
**Steps to reproduce**
<!-- Replace this with exactly what you did to cause the bug. -->

**Expected behavior**
**Expected behavior**
<!-- Replace this with what you expected to happen. -->

```
Expand Down
20 changes: 20 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "gradle" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
time: "12:00"
timezone: "America/Sao_Paulo"
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
time: "12:00"
timezone: "America/Sao_Paulo"
36 changes: 36 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build and Upload

on:
push:
branches: [ "master", "dev/*" ]
workflow_dispatch:

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
check-latest: true
cache: gradle
- name: Run chmod to make gradlew executable
run: chmod +x ./gradlew
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build with Gradle
run: ./gradlew shadowJar
- name: Upload Plugin
uses: actions/upload-artifact@v4.4.0
with:
name: NuVotifier
path: |
universal/build/libs/*.jar
velocity/build/libs/*.jar
bukkit/build/libs/*.jar
58 changes: 29 additions & 29 deletions api/src/main/java/com/vexsoftware/votifier/model/Vote.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,6 @@ public Vote(Vote vote) {
vote.getAdditionalData() == null ? null : vote.getAdditionalData().clone());
}

private static String getTimestamp(JsonElement object) {
try {
return Long.toString(object.getAsLong());
} catch (Exception e) {
return object.getAsString();
}
}

public Vote(JsonObject jsonObject) {
this(jsonObject.get("serviceName").getAsString(),
jsonObject.get("username").getAsString(),
Expand All @@ -95,6 +87,14 @@ public Vote(JsonObject jsonObject) {
additionalData = Base64.getDecoder().decode(jsonObject.get("additionalData").getAsString());
}

private static String getTimestamp(JsonElement object) {
try {
return Long.toString(object.getAsLong());
} catch (Exception e) {
return object.getAsString();
}
}

@Override
public String toString() {
String data;
Expand All @@ -108,6 +108,15 @@ public String toString() {
+ " additionalData:" + data + ")";
}

/**
* Gets the serviceName.
*
* @return The serviceName
*/
public String getServiceName() {
return serviceName;
}

/**
* Sets the serviceName.
*
Expand All @@ -119,12 +128,12 @@ public void setServiceName(String serviceName) {
}

/**
* Gets the serviceName.
* Gets the username.
*
* @return The serviceName
* @return The username
*/
public String getServiceName() {
return serviceName;
public String getUsername() {
return username;
}

/**
Expand All @@ -138,12 +147,12 @@ public void setUsername(String username) {
}

/**
* Gets the username.
* Gets the address.
*
* @return The username
* @return The address
*/
public String getUsername() {
return username;
public String getAddress() {
return address;
}

/**
Expand All @@ -157,12 +166,12 @@ public void setAddress(String address) {
}

/**
* Gets the address.
* Gets the time stamp.
*
* @return The address
* @return The time stamp
*/
public String getAddress() {
return address;
public String getTimeStamp() {
return timeStamp;
}

/**
Expand All @@ -175,15 +184,6 @@ public void setTimeStamp(String timeStamp) {
this.timeStamp = timeStamp;
}

/**
* Gets the time stamp.
*
* @return The time stamp
*/
public String getTimeStamp() {
return timeStamp;
}

/**
* Returns additional data sent with the vote, if it exists.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import com.google.gson.JsonObject;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

public class VoteTest {
@Test
Expand Down
6 changes: 4 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ plugins {
id("net.kyori.blossom") version "1.2.0" apply false
}

logger.lifecycle("""
logger.lifecycle(
"""
*******************************************
You are building NuVotifier!
If you encounter trouble:
Expand All @@ -14,7 +15,8 @@ logger.lifecycle("""

Output files will be in [subproject]/build/libs
*******************************************
""")
"""
)


applyRootArtifactoryConfig()
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repositories {
dependencies {
implementation(gradleApi())
implementation("org.ajoberstar.grgit:grgit-gradle:4.1.1")
implementation("gradle.plugin.com.github.johnrengelman:shadow:7.1.2")
implementation("com.gradleup.shadow:shadow-gradle-plugin:8.3.1")
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.27.1")
implementation("org.spongepowered:spongegradle-plugin-development:2.0.0")
implementation("net.fabricmc:fabric-loom:1.0-SNAPSHOT")
Expand Down
2 changes: 0 additions & 2 deletions buildSrc/src/main/kotlin/CommonConfig.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.repositories
import org.gradle.kotlin.dsl.the

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/PlatformConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fun Project.applyPlatformAndCoreConfiguration(javaRelease: Int = 8) {
}

fun Project.applyShadowConfiguration() {
apply(plugin = "com.github.johnrengelman.shadow")
apply(plugin = "com.gradleup.shadow")
tasks.named<ShadowJar>("shadowJar") {
archiveClassifier.set("dist")
dependencies {
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ object Versions {
const val FINDBUGS = "3.0.2"
const val NETTYIO = "4.1.72.Final"
const val GSON = "2.9.0"
const val VELOCITY = "3.1.0"
const val VELOCITY = "3.3.0-SNAPSHOT"
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import com.vexsoftware.votifier.cmd.NVReloadCmd;
import com.vexsoftware.votifier.cmd.TestVoteCmd;
import com.vexsoftware.votifier.forwarding.BukkitPluginMessagingForwardingSink;
import com.vexsoftware.votifier.support.forwarding.ForwardedVoteListener;
import com.vexsoftware.votifier.support.forwarding.ForwardingVoteSink;
import com.vexsoftware.votifier.model.Vote;
import com.vexsoftware.votifier.model.VotifierEvent;
import com.vexsoftware.votifier.net.VotifierServerBootstrap;
Expand All @@ -33,6 +31,8 @@
import com.vexsoftware.votifier.platform.LoggingAdapter;
import com.vexsoftware.votifier.platform.VotifierPlugin;
import com.vexsoftware.votifier.platform.scheduler.VotifierScheduler;
import com.vexsoftware.votifier.support.forwarding.ForwardedVoteListener;
import com.vexsoftware.votifier.support.forwarding.ForwardingVoteSink;
import com.vexsoftware.votifier.util.IOUtil;
import com.vexsoftware.votifier.util.KeyCreator;
import com.vexsoftware.votifier.util.TokenUtil;
Expand Down Expand Up @@ -235,7 +235,8 @@ private boolean loadAndBind() {
}

this.bootstrap = new VotifierServerBootstrap(host, port, this, disablev1);
this.bootstrap.start(error -> {});
this.bootstrap.start(error -> {
});
} else {
getLogger().info("------------------------------------------------------------------------------");
getLogger().info("Your Votifier port is less than 0, so we assume you do NOT want to start the");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.vexsoftware.votifier.forwarding;

import com.vexsoftware.votifier.NuVotifierBukkit;
import com.vexsoftware.votifier.support.forwarding.AbstractPluginMessagingForwardingSink;
import com.vexsoftware.votifier.support.forwarding.ForwardedVoteListener;
import org.apache.commons.lang.Validate;
Expand All @@ -16,6 +15,8 @@
*/
public class BukkitPluginMessagingForwardingSink extends AbstractPluginMessagingForwardingSink implements PluginMessageListener {

private final Plugin p;
private final String channel;
public BukkitPluginMessagingForwardingSink(Plugin p, String channel, ForwardedVoteListener listener) {
super(listener);
Validate.notNull(channel, "Channel cannot be null.");
Expand All @@ -24,9 +25,6 @@ public BukkitPluginMessagingForwardingSink(Plugin p, String channel, ForwardedVo
this.p = p;
}

private final Plugin p;
private final String channel;

@Override
public void halt() {
Bukkit.getMessenger().unregisterIncomingPluginChannel(p, channel, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ public VotifierEvent(final Vote vote) {
/**
* Constructs a vote event that encapsulated the given vote record.
*
* @param vote vote record
* @param vote vote record
* @param async whether the event will be fired asynchronously
*/
public VotifierEvent(final Vote vote, final boolean async) {
super(async);
this.vote = vote;
}

public static HandlerList getHandlerList() {
return handlers;
}

/**
* Return the encapsulated vote record.
*
Expand All @@ -54,8 +58,4 @@ public Vote getVote() {
public HandlerList getHandlers() {
return handlers;
}

public static HandlerList getHandlerList() {
return handlers;
}
}
2 changes: 1 addition & 1 deletion bukkit/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Votifier
main: com.vexsoftware.votifier.NuVotifierBukkit
version: "${internalVersion}"
description: A plugin that gets notified when votes are made for the server on toplists.
authors: [Ichbinjoe, blakeman8192, Kramer, tuxed]
authors: [ Ichbinjoe, blakeman8192, Kramer, tuxed ]
api-version: 1.13

commands:
Expand Down
Loading