mirror of
https://github.com/BenCodez/VotingPlugin.git
synced 2026-11-04 17:10:03 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f898d46c95
|
||
|
|
05c0c298ec
|
||
|
|
b6d0d224d8 | ||
|
|
26afe69a95 | ||
|
|
d38e70e012 | ||
|
|
12b77c50ce | ||
|
|
0fbcd8ca11 | ||
|
|
2e68f4e058 | ||
|
|
8b538ad86e | ||
|
|
1d4973f550 | ||
|
|
b13e4f9635 | ||
|
|
b075866f83 | ||
|
|
68896b32c3 | ||
|
|
8e81dc99c5 | ||
|
|
1b202f246f |
No files matched your search
@@ -0,0 +1 @@
|
||||
.gitea/CODEOWNERS linguist-detectable=false
|
||||
@@ -0,0 +1,3 @@
|
||||
# Pull requests request review from the eligible staff team(s).
|
||||
# One approval from either an Admin or Developer satisfies branch protection.
|
||||
* @trueog/Admins @trueog/Developers
|
||||
@@ -1,14 +0,0 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: BenCodez # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
#patreon: # Replace with a single Patreon username
|
||||
#open_collective: # Replace with a single Open Collective username
|
||||
#ko_fi: # Replace with a single Ko-fi username
|
||||
#tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
#community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
#liberapay: # Replace with a single Liberapay username
|
||||
#issuehunt: # Replace with a single IssueHunt username
|
||||
#lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||
#polar: # Replace with a single Polar username
|
||||
#buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
|
||||
custom: ["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YQBX25RTXJ5DG"]
|
||||
@@ -1,30 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Bug report for VotingPlugin
|
||||
title: ''
|
||||
labels: Possible Bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Versions**
|
||||
Plugin version and spigot version.
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots/Configs**
|
||||
If applicable, add screenshots to help explain your problem and/or configs relating to the issue.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea
|
||||
title: ''
|
||||
labels: Possible Feature
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
@@ -1,17 +0,0 @@
|
||||
---
|
||||
name: Question/Concerns
|
||||
about: Ask about a question or a concern about the plugin
|
||||
title: ''
|
||||
labels: Question/Concern
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Versions**
|
||||
Plugin version and spigot version
|
||||
|
||||
**Relevant information**
|
||||
Configs that relate to the issue in a pastebin.
|
||||
|
||||
**Context**
|
||||
Context about the question/concern
|
||||
@@ -1,11 +0,0 @@
|
||||
# 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: "maven" # See documentation for possible values
|
||||
directory: "/VotingPlugin/" # Location of package manifests
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
@@ -1,24 +0,0 @@
|
||||
name: Deploy Javadoc
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Deploy JavaDoc 🚀
|
||||
uses: MathieuSoysal/Javadoc-publisher.yml@main
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
javadoc-branch: gh-pages
|
||||
java-version: 17
|
||||
target-folder: ''
|
||||
project: maven # or gradle
|
||||
# subdirectories: moduleA moduleB #for subdirectories support, needs to be run with custom command
|
||||
custom-command: mvn -f VotingPlugin/pom.xml deploy -P javadoc javadoc:aggregate
|
||||
javadoc-source-folder: 'VotingPlugin/target/apidocs'
|
||||
@@ -1,27 +0,0 @@
|
||||
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
|
||||
#
|
||||
# You can adjust the behavior by modifying this file.
|
||||
# For more information, see:
|
||||
# https://github.com/actions/stale
|
||||
name: Mark stale issues and pull requests
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '19 16 * * *'
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- uses: actions/stale@v5
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
stale-issue-message: 'Stale issue message'
|
||||
stale-pr-message: 'Stale pull request message'
|
||||
stale-issue-label: 'no-issue-activity'
|
||||
stale-pr-label: 'no-pr-activity'
|
||||
@@ -0,0 +1,5 @@
|
||||
.gradle/
|
||||
.classpath
|
||||
.project
|
||||
.settings/
|
||||
build/
|
||||
@@ -1,9 +0,0 @@
|
||||
/bin/
|
||||
/target/
|
||||
/doc/
|
||||
/.idea/
|
||||
/*.iml
|
||||
/.settings/
|
||||
/.classpath
|
||||
/.factorypath
|
||||
/.apt_generated_tests/
|
||||
@@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>VotingPlugin</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,640 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>votingplugin</artifactId>
|
||||
<version>6.19.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
<github.global.server>github</github.global.server>
|
||||
<project.build.sourceEncoding>Cp1252</project.build.sourceEncoding>
|
||||
<build.number>NOTSET</build.number>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.release>8</maven.compiler.release>
|
||||
</properties>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
<include>bungee.yml</include>
|
||||
<include>votingpluginversion.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<testSourceDirectory>src/test/java</testSourceDirectory>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.m2e</groupId>
|
||||
<artifactId>lifecycle-mapping</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<configuration>
|
||||
<lifecycleMappingMetadata>
|
||||
<pluginExecutions>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-maven-plugin</artifactId>
|
||||
<versionRange>[1,)</versionRange>
|
||||
<goals>
|
||||
<goal>delombok</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
</pluginExecutions>
|
||||
</lifecycleMappingMetadata>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-maven-plugin</artifactId>
|
||||
<version>1.18.20.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>delombok</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>delombok</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<addOutputDirectory>false</addOutputDirectory>
|
||||
<outputDirectory>${project.basedir}/target/delombok</outputDirectory>
|
||||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<configuration>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<minimizeJar>false</minimizeJar>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>mysql-connector-java</artifact>
|
||||
<includes>
|
||||
<include>**</include>
|
||||
</includes>
|
||||
</filter>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.tcoded.folialib</pattern>
|
||||
<shadedPattern>
|
||||
${project.groupId}.votingplugin.simpleapi.folialib</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.bencodez.simpleapi</pattern>
|
||||
<shadedPattern>
|
||||
${project.groupId}.votingplugin.simpleapi</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.bencodez.advancedcore</pattern>
|
||||
<shadedPattern>
|
||||
${project.groupId}.votingplugin.advancedcore</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>net.pl3x.bukkit.chatapi</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>me.mrten.mysqlapi</pattern>
|
||||
<shadedPattern>
|
||||
${project.groupId}.votingplugin.mysqlapi</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.zaxxer.hikari</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.simpleapi.hikari</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>
|
||||
${project.groupId}.votingplugin.bstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>xyz.upperlevel.spigot</pattern>
|
||||
<shadedPattern>
|
||||
${project.groupId}.votingplugin.advancedcore.xyz.upperlevel.spigot</shadedPattern>
|
||||
</relocation>
|
||||
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<!-- Lets exclude google code, because the
|
||||
server already has this
|
||||
code in it (guava, etc) -->
|
||||
<excludes>
|
||||
<exclude>com.google.*:*</exclude>
|
||||
</excludes>
|
||||
</artifactSet>
|
||||
<minimizeJar>false</minimizeJar>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
<exclude>module-info.class</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"/>
|
||||
</transformers>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>maven-central</id>
|
||||
<url>https://oss.sonatype.org/content/groups/public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bungeecord-repo</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>velocity</id>
|
||||
<url>https://nexus.velocitypowered.com/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bencodez repo</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>placeholderapi</id>
|
||||
<url>
|
||||
https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>scarsz</id>
|
||||
<url>https://nexus.scarsz.me/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.21.8-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.38</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.21-R0.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.vexsoftware</groupId>
|
||||
<artifactId>nuvotifier-universal</artifactId>
|
||||
<version>2.7.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>be.maximvdw</groupId>
|
||||
<artifactId>mvdwplaceholderapi</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-api</artifactId>
|
||||
<version>3.1.2-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-velocity</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.11.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>3.7.19-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>5.12.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>5.15.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.discordsrv</groupId>
|
||||
<artifactId>discordsrv</artifactId>
|
||||
<version>1.30.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>default</id>
|
||||
<properties>
|
||||
<build.profile.id>default</build.profile.id>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.4.2</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
<finalName>${project.name}</finalName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>deploy-snapshot</id>
|
||||
<properties>
|
||||
<build.profile.id>dev-snapshot</build.profile.id>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>nexus</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>nexus</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-releases/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.4.2</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
<finalName>
|
||||
${project.name}</finalName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.coderplus.maven.plugins</groupId>
|
||||
<artifactId>copy-rename-maven-plugin</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-file</id>
|
||||
<phase>install</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceFile>
|
||||
${project.basedir}/target/${project.name}.jar</sourceFile>
|
||||
<destinationFile>
|
||||
${project.basedir}/target/${project.name}-${build.number}.jar</destinationFile>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.11.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<phase>deploy</phase>
|
||||
<configuration>
|
||||
<sourcepath>
|
||||
${project.basedir}/target/delombok</sourcepath>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>3.1.4</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.7.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-deploy</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>deploy</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<serverId>nexus</serverId>
|
||||
<nexusUrl>https://nexus.bencodez.com/nexus/</nexusUrl>
|
||||
<skipStaging>true</skipStaging>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>javadoc</id>
|
||||
<properties>
|
||||
<build.profile.id>javadoc</build.profile.id>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>internal.repo</id>
|
||||
<name>Temporary Staging Repository</name>
|
||||
<url>file://${project.build.directory}/mvn-repo</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.4.2</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
<finalName>${project.name}</finalName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.11.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<phase>deploy</phase>
|
||||
<configuration>
|
||||
<sourcepath>
|
||||
${project.basedir}/target/delombok</sourcepath>
|
||||
<outputDirectory>
|
||||
${project.basedir}/target/apidocs</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.coderplus.maven.plugins</groupId>
|
||||
<artifactId>copy-rename-maven-plugin</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-file</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceFile>
|
||||
${project.basedir}/target/${project.name}.jar</sourceFile>
|
||||
<destinationFile>
|
||||
${project.basedir}/target/${project.name}-${project.version}.jar</destinationFile>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>dev</id>
|
||||
<properties>
|
||||
<build.profile.id>dev</build.profile.id>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.4.2</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
<finalName>${project.name}</finalName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>install</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>
|
||||
${user.home}/Documents/Test_Server/plugins</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${basedir}/target</directory>
|
||||
<includes>
|
||||
<include>VotingPlugin.jar</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<overwrite>true</overwrite>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>deploy</id>
|
||||
<properties>
|
||||
<build.profile.id>deploy</build.profile.id>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>nexus</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>nexus</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-releases/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.4.2</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
<finalName>${project.name}</finalName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.coderplus.maven.plugins</groupId>
|
||||
<artifactId>copy-rename-maven-plugin</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-file</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceFile>
|
||||
${project.basedir}/target/${project.name}.jar</sourceFile>
|
||||
<destinationFile>
|
||||
${project.basedir}/target/${project.name}-${project.version}.jar</destinationFile>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.11.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<phase>deploy</phase>
|
||||
<configuration>
|
||||
<sourcepath>
|
||||
${project.basedir}/target/delombok</sourcepath>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>3.1.4</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.7.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-deploy</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>deploy</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<serverId>nexus</serverId>
|
||||
<nexusUrl>https://nexus.bencodez.com/nexus/</nexusUrl>
|
||||
<skipStaging>true</skipStaging>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
@@ -1,138 +0,0 @@
|
||||
VoteSites:
|
||||
# VoteSite key
|
||||
# Used for saving data for votesites
|
||||
# Use a short name if you can
|
||||
# No spaces or dots
|
||||
ExampleVoteSite:
|
||||
# Enable voteSite
|
||||
# If false, votesite will not be loaded by plugin
|
||||
# Default: false
|
||||
Enabled: false
|
||||
|
||||
# Display name of voting site
|
||||
Name: 'ExampleVoteSite'
|
||||
|
||||
# Priority of this site
|
||||
# Used for sorted list
|
||||
# High prority, higher on the list
|
||||
Priority: 5
|
||||
|
||||
# If true, voteside will be hidden from some GUI's, similar to being disabled
|
||||
Hidden: false
|
||||
|
||||
# The serviceName from the vote, has to be correct to work correctly
|
||||
# Gotten from voting on the site (will be in console/log)
|
||||
# Usually is the main part of the url(e.g. PlanetMinecraft.com), but not always
|
||||
# See console when you vote (it will notify you if the plugin didn't find a votingsite matching the service site
|
||||
ServiceSite: 'PlanetMinecraft.com'
|
||||
|
||||
# vote url for /vote
|
||||
# Format for this can be set in Config.yml
|
||||
# Do not include colors here
|
||||
# If you need to force a url set the url as this:
|
||||
# VoteURL: '[Text="ANY TEXT TO CLICK ON HERE",url="URLHERE"]'
|
||||
VoteURL: 'link to vote URL here, used in /vote'
|
||||
|
||||
# Time between votes in hours (used for /vote next)
|
||||
# Most sites are 24 hours
|
||||
VoteDelay: 24
|
||||
|
||||
# Use to have a minute votedelay
|
||||
# Must set a value on VoteDelay if you plan on only using this setting
|
||||
#VoteDelayMin: 30
|
||||
|
||||
# Require waiting until votedelay time has pasted in order to accept vote
|
||||
# Recommend: false
|
||||
WaitUntilVoteDelay: false
|
||||
|
||||
# Reset vote delay each day (for certain sites that do this)
|
||||
# Recommend: false
|
||||
VoteDelayDaily: false
|
||||
|
||||
# Replaces offset, set the exact hour based on server time
|
||||
# Include server time offset when setting this
|
||||
# 2 = 2 am server time
|
||||
# Use 1-24
|
||||
#VoteDelayDailyHour: 14
|
||||
|
||||
# If true, rewards can be executed offline (requires ForceOffline to be true in the reward)
|
||||
# Setting this to true will execute the reward offline while the player is offline
|
||||
# This basiclly disables offline voting if set to true, don't misinterpret this option
|
||||
ForceOffline: false
|
||||
|
||||
# Requrie a permission to view site in GUI
|
||||
# If empty or not set anyone can view (default)
|
||||
#PermissionToView: 'Perm.here'
|
||||
|
||||
# VoteSite Material for some GUI's
|
||||
# Removing this may result in an error, required on each site
|
||||
DisplayItem:
|
||||
Material: 'DIAMOND'
|
||||
Amount: 1
|
||||
|
||||
# Reward to run when cooldown ends for this votesite
|
||||
# Enable PerSiteCoolDownEvents in Config.yml to use this
|
||||
#CoolDownEndRewards:
|
||||
# Messages:
|
||||
# Player: '&aTime to go vote on site1'
|
||||
|
||||
# Rewards to give
|
||||
# https://github.com/BenCodez/AdvancedCore/wiki/Rewards
|
||||
Rewards:
|
||||
# Execute console commands
|
||||
Commands:
|
||||
- 'say hello'
|
||||
# Send player a message
|
||||
Messages:
|
||||
Player: 'You voted'
|
||||
# Site 2 example
|
||||
Site2:
|
||||
Enabled: false
|
||||
Name: 'Site2'
|
||||
ServiceSite: 'Crafty.gg'
|
||||
VoteURL: 'link to vote URL here, used in /vote'
|
||||
VoteDelay: 24
|
||||
DisplayItem:
|
||||
Material: 'DIAMOND'
|
||||
Amount: 1
|
||||
Rewards:
|
||||
Commands:
|
||||
- 'say hello'
|
||||
# Advanced example
|
||||
# 50% chance for reward1, if reward1 not given then 20% chance to get reward2, if reward2 not given then fallback
|
||||
AdvancedPriority:
|
||||
# Similar to priority, but no need to have to use reward files
|
||||
# Add requirements under each reward
|
||||
# Will go in order from list here and try to run each of the following rewards...
|
||||
# This name can be anything, but they need to be different
|
||||
Reward1:
|
||||
Chance: 50
|
||||
# Any other requirement here
|
||||
# If any requirement fails, the next reward will be attempted
|
||||
# Use permission requirement for rank based rewards
|
||||
#RequirePermission: true
|
||||
#Permission: 'permhere'
|
||||
Messages:
|
||||
Player: 'You got first reward'
|
||||
Reward2:
|
||||
Chance: 20
|
||||
Messages:
|
||||
Player: 'You got second reward'
|
||||
# Fallback, 100% chance, after other rewards fail chances
|
||||
Fallback:
|
||||
Messages:
|
||||
Player: 'You got unlucky'
|
||||
|
||||
# Give 1 diamond regardless of above
|
||||
Items:
|
||||
item1:
|
||||
Material: DIAMOND
|
||||
Amount: 1
|
||||
|
||||
Messages:
|
||||
Player: 'You voted'
|
||||
|
||||
# Reward for any site
|
||||
# Similar to AnySiteReward
|
||||
# This requires the site to be configured in order to get the reward.
|
||||
EverySiteReward: {}
|
||||
@@ -1,4 +0,0 @@
|
||||
time: '${timestamp}'
|
||||
profile: '${build.profile.id}'
|
||||
version: '${project.version}'
|
||||
buildnumber: '${build.number}'
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.bencodez.votingplugin.tests;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
public class HttpURLConnectionMock {
|
||||
|
||||
public static void setupMockHttpURLConnection(String playerName, int responseCode, String responseBody)
|
||||
throws Exception {
|
||||
// Mock URL and HttpURLConnection
|
||||
URL mockUrl = mock(URL.class);
|
||||
HttpURLConnection mockConnection = mock(HttpURLConnection.class);
|
||||
|
||||
when(mockUrl.openConnection()).thenReturn(mockConnection);
|
||||
when(mockConnection.getResponseCode()).thenReturn(responseCode);
|
||||
InputStream mockInputStream = new ByteArrayInputStream(responseBody.getBytes());
|
||||
when(mockConnection.getInputStream()).thenReturn(mockInputStream);
|
||||
|
||||
// When new URL is called, return the mocked URL
|
||||
// Note: This requires PowerMockito or a similar tool to mock the `new` keyword
|
||||
// Here, it's simplified and assumes the method uses a helper that can be mocked
|
||||
}
|
||||
}
|
||||
@@ -1,164 +0,0 @@
|
||||
|
||||
package com.bencodez.votingplugin.tests;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.MockedStatic;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import com.bencodez.advancedcore.api.user.UserManager;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.config.Config;
|
||||
import com.bencodez.votingplugin.config.SpecialRewardsConfig;
|
||||
import com.bencodez.votingplugin.data.ServerData;
|
||||
import com.bencodez.votingplugin.placeholders.PlaceHolders;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.voteparty.VoteParty;
|
||||
|
||||
public class VotePartyTest {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VoteParty voteParty;
|
||||
private VotingPluginUser user;
|
||||
private MockedStatic<Bukkit> mockedBukkit;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
plugin = Mockito.mock(VotingPluginMain.class);
|
||||
voteParty = Mockito.spy(new VoteParty(plugin)); // Use spy instead of mock
|
||||
user = Mockito.mock(VotingPluginUser.class);
|
||||
|
||||
// Mock the return values for getServerData, getSpecialRewardsConfig, and
|
||||
// getPlaceholders
|
||||
ServerData serverData = Mockito.mock(ServerData.class);
|
||||
SpecialRewardsConfig specialRewardsConfig = Mockito.mock(SpecialRewardsConfig.class);
|
||||
ConfigurationSection configSection = Mockito.mock(ConfigurationSection.class);
|
||||
Config configFile = Mockito.mock(Config.class);
|
||||
PlaceHolders placeHolders = Mockito.mock(PlaceHolders.class);
|
||||
UserManager userManager = Mockito.mock(UserManager.class);
|
||||
|
||||
when(plugin.getServerData()).thenReturn(serverData);
|
||||
when(plugin.getSpecialRewardsConfig()).thenReturn(specialRewardsConfig);
|
||||
when(plugin.getConfigFile()).thenReturn(configFile);
|
||||
when(plugin.getPlaceholders()).thenReturn(placeHolders);
|
||||
when(plugin.getUserManager()).thenReturn(userManager);
|
||||
when(serverData.getData()).thenReturn(configSection);
|
||||
|
||||
// Deregister existing static mock and create a new one
|
||||
if (mockedBukkit != null) {
|
||||
mockedBukkit.close();
|
||||
}
|
||||
mockedBukkit = Mockito.mockStatic(Bukkit.class);
|
||||
Server mockServer = Mockito.mock(Server.class);
|
||||
when(Bukkit.getServer()).thenReturn(mockServer);
|
||||
PluginManager mockPluginManager = Mockito.mock(PluginManager.class);
|
||||
when(mockServer.getPluginManager()).thenReturn(mockPluginManager);
|
||||
when(Bukkit.getPluginManager()).thenReturn(mockPluginManager);
|
||||
when(mockServer.getOnlinePlayers()).thenReturn(Collections.emptyList());
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
if (mockedBukkit != null) {
|
||||
mockedBukkit.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addTotal_IncrementsTotalVotes() {
|
||||
when(plugin.getServerData().getData().getInt("VoteParty.Total")).thenReturn(5);
|
||||
voteParty.addTotal(user);
|
||||
verify(plugin.getServerData().getData()).set("VoteParty.Total", 6);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void check_EnoughVotes_TriggersVoteParty() {
|
||||
when(plugin.getServerData().getData().getInt("VoteParty.Total")).thenReturn(10);
|
||||
when(plugin.getSpecialRewardsConfig().getVotePartyVotesRequired()).thenReturn(10);
|
||||
|
||||
voteParty.check(user, false);
|
||||
|
||||
verify(voteParty, times(1)).giveRewards(any(), eq(false));
|
||||
verify(Bukkit.getPluginManager()).callEvent(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void check_NotEnoughVotes_DoesNotTriggerVoteParty() {
|
||||
when(plugin.getServerData().getData().getInt("VoteParty.Total")).thenReturn(5);
|
||||
when(plugin.getSpecialRewardsConfig().getVotePartyVotesRequired()).thenReturn(10);
|
||||
|
||||
voteParty.check(user, false);
|
||||
|
||||
verify(voteParty, never()).giveRewards(any(), eq(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void commandVoteParty_VotePartyEnabled_SendsMessage() {
|
||||
CommandSender sender = Mockito.mock(CommandSender.class);
|
||||
when(plugin.getSpecialRewardsConfig().isVotePartyEnabled()).thenReturn(true);
|
||||
when(plugin.getConfigFile().getFormatCommandsVoteParty()).thenReturn(new ArrayList<>());
|
||||
|
||||
voteParty.commandVoteParty(sender);
|
||||
|
||||
verify(sender).sendMessage(any(String[].class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void commandVoteParty_VotePartyDisabled_SendsErrorMessage() {
|
||||
CommandSender sender = Mockito.mock(CommandSender.class);
|
||||
when(plugin.getSpecialRewardsConfig().isVotePartyEnabled()).thenReturn(false);
|
||||
|
||||
voteParty.commandVoteParty(sender);
|
||||
|
||||
verify(sender).sendMessage("§cVoteParty not enabled");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNeededVotes_ReturnsCorrectValue() {
|
||||
when(plugin.getServerData().getData().getInt("VoteParty.Total")).thenReturn(5);
|
||||
when(plugin.getSpecialRewardsConfig().getVotePartyVotesRequired()).thenReturn(10);
|
||||
|
||||
int neededVotes = voteParty.getNeededVotes();
|
||||
|
||||
assertEquals(5, neededVotes);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRandomPlayerName_ReturnsPlayerName() {
|
||||
Player player = Mockito.mock(Player.class);
|
||||
when(player.getName()).thenReturn("player1");
|
||||
when(Bukkit.getOnlinePlayers()).thenReturn((Collection) Collections.singletonList(player));
|
||||
|
||||
String playerName = voteParty.getRandomPlayerName();
|
||||
|
||||
assertEquals("player1", playerName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRandomPlayerName_NoPlayersOnline_ReturnsNoPlayer() {
|
||||
when(Bukkit.getOnlinePlayers()).thenReturn(Collections.emptyList());
|
||||
|
||||
String playerName = voteParty.getRandomPlayerName();
|
||||
|
||||
assertEquals("No Player", playerName);
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
package com.bencodez.votingplugin.tests;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.config.Config;
|
||||
import com.bencodez.votingplugin.config.ConfigVoteSites;
|
||||
import com.bencodez.votingplugin.data.ServerData;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
|
||||
public class VoteSiteTest {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
// Create a mock instance of VotingPluginMain.
|
||||
plugin = mock(VotingPluginMain.class);
|
||||
|
||||
// Create dummy stubs using Mockito for ConfigVoteSites.
|
||||
ConfigVoteSites dummyConfigVoteSites = mock(ConfigVoteSites.class);
|
||||
when(dummyConfigVoteSites.getVoteURL(anyString())).thenReturn("example.com");
|
||||
when(dummyConfigVoteSites.getServiceSite(anyString())).thenReturn("ServiceSite");
|
||||
when(dummyConfigVoteSites.getVoteDelay(anyString())).thenReturn(30.0);
|
||||
when(dummyConfigVoteSites.getVoteDelayMin(anyString())).thenReturn(15.0);
|
||||
when(dummyConfigVoteSites.getVoteSiteEnabled(anyString())).thenReturn(true);
|
||||
when(dummyConfigVoteSites.getPriority(anyString())).thenReturn(1);
|
||||
when(dummyConfigVoteSites.getDisplayName(anyString())).thenReturn("DisplayName");
|
||||
when(dummyConfigVoteSites.getItem(anyString())).thenReturn(null);
|
||||
// (Stub additional methods as needed)
|
||||
|
||||
// Create a dummy Config.
|
||||
Config dummyConfigFile = mock(Config.class);
|
||||
when(dummyConfigFile.isFormatCommandsVoteForceLinks()).thenReturn(true);
|
||||
when(dummyConfigFile.getFormatBroadCastMsg()).thenReturn("Broadcast: {player} voted on {sitename}");
|
||||
|
||||
// Create a dummy ServerData.
|
||||
ServerData dummyServerData = mock(ServerData.class);
|
||||
// Instead of casting Arrays.asList, wrap it in a new ArrayList.
|
||||
when(dummyServerData.getServiceSites())
|
||||
.thenReturn(new ArrayList<>(Arrays.asList("ServiceSite", "AnotherSite")));
|
||||
|
||||
// Stub the plugin methods to return our dummy configuration objects.
|
||||
when(plugin.getConfigVoteSites()).thenReturn(dummyConfigVoteSites);
|
||||
when(plugin.getConfigFile()).thenReturn(dummyConfigFile);
|
||||
when(plugin.getServerData()).thenReturn(dummyServerData);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitSetsValuesCorrectly() {
|
||||
// Construct a VoteSite with site name "site.test".
|
||||
VoteSite voteSite = new VoteSite(plugin, "site.test");
|
||||
|
||||
// The key is created by replacing dots with underscores.
|
||||
assertEquals("site_test", voteSite.getKey(), "Key should have dots replaced with underscores");
|
||||
|
||||
// The dummy config returns "DisplayName" for display name.
|
||||
assertEquals("DisplayName", voteSite.getDisplayName(), "Display name should be loaded from config");
|
||||
|
||||
// voteURL is loaded from dummy and should be "example.com"
|
||||
assertEquals("example.com", voteSite.getVoteURL(false), "VoteURL should be set from config");
|
||||
|
||||
// Service site, vote delays, and enabled flag are set as expected.
|
||||
assertEquals("ServiceSite", voteSite.getServiceSite(), "ServiceSite should be set from config");
|
||||
assertEquals(30.0, voteSite.getVoteDelay(), "VoteDelay should be set from config");
|
||||
assertEquals(15.0, voteSite.getVoteDelayMin(), "VoteDelayMin should be set from config");
|
||||
assertTrue(voteSite.isEnabled(), "VoteSite should be enabled");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetVoteURLJson() {
|
||||
VoteSite voteSite = new VoteSite(plugin, "site.test");
|
||||
// After init, voteURL is "example.com" (from dummy config)
|
||||
// In getVoteURL(true), if the format-forced links option is enabled,
|
||||
// and since "example.com" does not start with "http", the returned string
|
||||
// should be:
|
||||
// [Text="example.com",url="http://example.com"]
|
||||
String url = voteSite.getVoteURL(true);
|
||||
assertEquals("[Text=\"example.com\",url=\"http://example.com\"]", url,
|
||||
"JSON-formatted vote URL should be generated correctly");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadingDebugContainsExpectedValues() {
|
||||
VoteSite voteSite = new VoteSite(plugin, "site.test");
|
||||
String debug = voteSite.loadingDebug();
|
||||
assertTrue(debug.contains("site_test"), "Debug output should contain the key");
|
||||
assertTrue(debug.contains("DisplayName"), "Debug output should contain the display name");
|
||||
assertTrue(debug.contains("30.0"), "Debug output should contain the vote delay");
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
|
||||
package com.bencodez.votingplugin.tests;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalDataHandlerProxy;
|
||||
import com.bencodez.votingplugin.proxy.ProxyMysqlUserTable;
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginProxy;
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginProxyConfig;
|
||||
import com.bencodez.votingplugin.proxy.multiproxy.MultiProxyHandler;
|
||||
|
||||
public class VotingPluginProxyTest {
|
||||
|
||||
@InjectMocks
|
||||
private VotingPluginProxyTestImpl votingPluginProxy;
|
||||
|
||||
@Mock
|
||||
private ProxyMysqlUserTable proxyMySQL;
|
||||
|
||||
@Mock
|
||||
private VotingPluginProxyConfig config;
|
||||
|
||||
@Mock
|
||||
private GlobalDataHandlerProxy globalDataHandler;
|
||||
|
||||
@Mock
|
||||
private MultiProxyHandler multiProxyHandler;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
MockitoAnnotations.openMocks(this);
|
||||
votingPluginProxy.setProxyMySQL(proxyMySQL);
|
||||
votingPluginProxy.setGlobalDataHandler(globalDataHandler);
|
||||
votingPluginProxy.setMultiProxyHandler(multiProxyHandler);
|
||||
|
||||
// Mocking config methods
|
||||
when(config.getVotePartyEnabled()).thenReturn(true);
|
||||
when(config.getVotePartyVotesRequired()).thenReturn(5);
|
||||
when(config.getVotePartyIncreaseVotesRequired()).thenReturn(5);
|
||||
when(config.getBungeeManageTotals()).thenReturn(true);
|
||||
when(config.getPluginMessageEncryption()).thenReturn(false);
|
||||
when(config.getDebug()).thenReturn(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAddVoteParty() {
|
||||
// Initial votePartyVotes should be 0
|
||||
assertEquals(0, votingPluginProxy.getVotePartyVotes());
|
||||
|
||||
// Spy on the votingPluginProxy object
|
||||
VotingPluginProxy spyProxy = Mockito.spy(votingPluginProxy);
|
||||
doNothing().when(spyProxy).checkVoteParty();
|
||||
|
||||
// Add one vote party
|
||||
spyProxy.addCurrentVotePartyVotes(1);
|
||||
|
||||
// Verify that votePartyVotes increased by 1
|
||||
assertEquals(1, spyProxy.getVotePartyVotes());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
void testAddCurrentVotePartyVotes() {
|
||||
// Initial votePartyVotes should be 0
|
||||
assertEquals(0, votingPluginProxy.getVotePartyVotes());
|
||||
|
||||
// Add 3 votes
|
||||
votingPluginProxy.addCurrentVotePartyVotes(3);
|
||||
assertEquals(3, votingPluginProxy.getVotePartyVotes());
|
||||
|
||||
// Add 2 more votes
|
||||
votingPluginProxy.addCurrentVotePartyVotes(2);
|
||||
assertEquals(5, votingPluginProxy.getVotePartyVotes());
|
||||
}
|
||||
}
|
||||
-215
@@ -1,215 +0,0 @@
|
||||
package com.bencodez.votingplugin.tests;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import com.bencodez.simpleapi.sql.mysql.config.MysqlConfig;
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginProxy;
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginProxyConfig;
|
||||
|
||||
public class VotingPluginProxyTestImpl extends VotingPluginProxy {
|
||||
|
||||
@Override
|
||||
public void addNonVotedPlayer(String uuid, String playerName) {
|
||||
// Implementation for testing purposes
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcast(String message) {
|
||||
// Implementation for testing purposes
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getAllAvailableServers() {
|
||||
return new HashSet<>(Arrays.asList("Server1", "Server2"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VotingPluginProxyConfig getConfig() {
|
||||
return Mockito.mock(VotingPluginProxyConfig.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentPlayerServer(String player) {
|
||||
return "Server1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getDataFolderPlugin() {
|
||||
return new File(".");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProperName(String uuid, String playerName) {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUUID(String playerName) {
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginVersion() {
|
||||
return "1.0.0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVoteCacheCurrentVotePartyVotes() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getVoteCacheLastUpdated() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVoteCachePrevDay() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVoteCachePrevMonth() {
|
||||
return "January-2023";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVoteCachePrevWeek() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVoteCacheVotePartyIncreaseVotesRequired() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerOnline(String playerName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isServerValid(String server) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSomeoneOnlineServer(String server) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVoteCacheIgnoreTime() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runAsync(Runnable run) {
|
||||
run.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runConsoleCommand(String command) {
|
||||
// Mocked for testing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveVoteCacheFile() {
|
||||
// Mocked for testing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadCore(boolean mysql) {
|
||||
// Mocked for testing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String message) {
|
||||
// For testing, simply print the message
|
||||
System.out.println("LOG: " + message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logSevere(String message) {
|
||||
// For testing, simply print the severe message
|
||||
System.err.println("SEVERE: " + message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String message) {
|
||||
// For testing, simply print the warning message
|
||||
System.err.println("WARNING: " + message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String str) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPluginMessageData(String server, String channel, byte[] data, boolean queue) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoteCacheLastUpdated() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoteCachePrevDay(int day) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoteCachePrevMonth(String text) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoteCachePrevWeek(int week) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoteCacheVoteCacheIgnoreTime(boolean ignore) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoteCacheVotePartyCurrentVotes(int votes) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoteCacheVotePartyIncreaseVotesRequired(int votes) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScheduledExecutorService getScheduler() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MysqlConfig getVoteCacheMySQLConfig() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import org.gradle.jvm.toolchain.JvmVendorSpec
|
||||
|
||||
plugins {
|
||||
id("java")
|
||||
eclipse
|
||||
id("com.gradleup.shadow") version "8.3.9"
|
||||
}
|
||||
|
||||
group = "com.bencodez"
|
||||
version = "6.19.1-SNAPSHOT"
|
||||
description = "VotingPlugin"
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
vendor.set(JvmVendorSpec.GRAAL_VM)
|
||||
}
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url = uri("https://oss.sonatype.org/content/groups/public") }
|
||||
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") }
|
||||
maven { url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") }
|
||||
maven { url = uri("https://repo.papermc.io/repository/maven-public/") }
|
||||
maven {
|
||||
url = uri("https://nexus.velocitypowered.com/repository/maven-public/")
|
||||
content { includeGroup("com.velocitypowered") }
|
||||
}
|
||||
maven { url = uri("https://nexus.bencodez.com/repository/maven-public/") }
|
||||
maven { url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/") }
|
||||
maven { url = uri("https://nexus.scarsz.me/content/groups/public/") }
|
||||
maven { url = uri("https://repo.purpurmc.org/snapshots") }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT")
|
||||
compileOnly("org.projectlombok:lombok:1.18.38")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.38")
|
||||
compileOnly("net.md-5:bungeecord-api:1.21-R0.3")
|
||||
compileOnly("com.vexsoftware:nuvotifier-universal:2.7.2")
|
||||
compileOnly("be.maximvdw:mvdwplaceholderapi:3.1.1")
|
||||
compileOnly("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")
|
||||
implementation("org.bstats:bstats-velocity:3.1.0")
|
||||
compileOnly("me.clip:placeholderapi:2.11.6")
|
||||
implementation("com.bencodez:advancedcore:3.7.19-SNAPSHOT")
|
||||
compileOnly("com.discordsrv:discordsrv:1.30.0")
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
options.encoding = "Cp1252"
|
||||
}
|
||||
|
||||
val buildProfileId = (findProperty("buildProfile") ?: System.getenv("BUILD_PROFILE") ?: "default").toString()
|
||||
val buildNumber = (findProperty("buildNumber") ?: System.getenv("BUILD_NUMBER") ?: "NOTSET").toString()
|
||||
val timestamp = System.currentTimeMillis().toString()
|
||||
val apiVersion = "1.19"
|
||||
val resourceProps = mapOf(
|
||||
"name" to project.name,
|
||||
"version" to project.version.toString(),
|
||||
"apiVersion" to apiVersion,
|
||||
"timestamp" to timestamp,
|
||||
"build" to mapOf(
|
||||
"profile" to mapOf("id" to buildProfileId),
|
||||
"number" to buildNumber
|
||||
)
|
||||
)
|
||||
|
||||
tasks.processResources {
|
||||
filteringCharset = "Cp1252"
|
||||
inputs.properties(resourceProps)
|
||||
filesMatching(listOf("plugin.yml", "bungee.yml", "votingpluginversion.yml")) {
|
||||
expand(resourceProps)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.jar { enabled = false }
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
archiveBaseName.set("VotingPlugin")
|
||||
archiveVersion.set("")
|
||||
archiveClassifier.set("")
|
||||
mergeServiceFiles()
|
||||
exclude("META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA", "module-info.class")
|
||||
dependencies { exclude(dependency("com.google.*:.*")) }
|
||||
relocate("com.tcoded.folialib", "${project.group}.votingplugin.simpleapi.folialib")
|
||||
relocate("com.bencodez.simpleapi", "${project.group}.votingplugin.simpleapi")
|
||||
relocate("com.bencodez.advancedcore", "${project.group}.votingplugin.advancedcore")
|
||||
relocate("net.pl3x.bukkit.chatapi", "${project.group}.votingplugin")
|
||||
relocate("me.mrten.mysqlapi", "${project.group}.votingplugin.mysqlapi")
|
||||
relocate("com.zaxxer.hikari", "${project.group}.votingplugin.simpleapi.hikari")
|
||||
relocate("org.bstats", "${project.group}.votingplugin.bstats")
|
||||
relocate("xyz.upperlevel.spigot", "${project.group}.votingplugin.advancedcore.xyz.upperlevel.spigot")
|
||||
manifest { attributes(mapOf("paperweight-mappings-namespace" to "mojang")) }
|
||||
}
|
||||
|
||||
tasks.build { dependsOn(tasks.named("shadowJar")) }
|
||||
|
||||
tasks.register<Copy>("copyToTestServer") {
|
||||
dependsOn(tasks.named("shadowJar"))
|
||||
from(tasks.named("shadowJar"))
|
||||
into("${System.getProperty("user.home")}/Documents/Test_Server/plugins")
|
||||
}
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+7
@@ -0,0 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -0,0 +1,251 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH="\\\"\\\""
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
Vendored
+94
@@ -0,0 +1,94 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -0,0 +1,2 @@
|
||||
rootProject.name = "VotingPlugin"
|
||||
|
||||
File renamed without changes.
File renamed without changes.
+1791
-1772
File diff suppressed because it is too large.
Load diff
File renamed without changes.
File renamed without changes.
+11
-7
@@ -12,7 +12,6 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@@ -78,6 +77,9 @@ import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class CommandLoader.
|
||||
@@ -818,8 +820,10 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
sender.sendMessage(ChatColor.GREEN + "UUID of player " + ChatColor.DARK_GREEN + args[1]
|
||||
+ ChatColor.GREEN + " is: " + PlayerManager.getInstance().getUUID(args[1]));
|
||||
sender.sendMessage(Component.text("UUID of player ", NamedTextColor.GREEN)
|
||||
.append(Component.text(args[1], NamedTextColor.DARK_GREEN))
|
||||
.append(Component.text(" is: " + PlayerManager.getInstance().getUUID(args[1]),
|
||||
NamedTextColor.GREEN)));
|
||||
|
||||
}
|
||||
});
|
||||
@@ -830,11 +834,11 @@ public class CommandLoader {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
try {
|
||||
sender.sendMessage(ChatColor.GREEN + "PlayerName of player " + ChatColor.DARK_GREEN + args[1]
|
||||
+ ChatColor.GREEN + " is: "
|
||||
+ PlayerManager.getInstance().getPlayerName(
|
||||
sender.sendMessage(Component.text("PlayerName of player ", NamedTextColor.GREEN)
|
||||
.append(Component.text(args[1], NamedTextColor.DARK_GREEN))
|
||||
.append(Component.text(" is: " + PlayerManager.getInstance().getPlayerName(
|
||||
plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(args[1])),
|
||||
args[1]));
|
||||
args[1]), NamedTextColor.GREEN)));
|
||||
} catch (IllegalArgumentException e) {
|
||||
sendMessage(sender, "&cInvalid uuid");
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+6
-4
@@ -23,7 +23,8 @@ import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
public class VoteTopVoterPreviousMonths extends GUIHandler {
|
||||
|
||||
@@ -68,18 +69,19 @@ public class VoteTopVoterPreviousMonths extends GUIHandler {
|
||||
if (!yearMonthList.isEmpty()) {
|
||||
yearMonth = yearMonthList.get(0);
|
||||
}
|
||||
player.sendMessage(ChatColor.RED + "Can't open previous months, no data");
|
||||
player.sendMessage(Component.text("Can't open previous months, no data", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
if (yearMonthList.size() <= index) {
|
||||
player.sendMessage(ChatColor.RED + "Can't open previous months, no data for requested index");
|
||||
player.sendMessage(
|
||||
Component.text("Can't open previous months, no data for requested index", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
yearMonth = yearMonthList.get(index);
|
||||
|
||||
Set<Entry<TopVoterPlayer, Integer>> users = null;
|
||||
if (!plugin.getPreviousMonthsTopVoters().containsKey(yearMonth)) {
|
||||
player.sendMessage(ChatColor.RED + "Can't open previous months, no data");
|
||||
player.sendMessage(Component.text("Can't open previous months, no data", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
users = plugin.getPreviousMonthsTopVoters().get(yearMonth).entrySet();
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+5
-1
@@ -244,6 +244,10 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean disableAdvancedTab = false;
|
||||
|
||||
@ConfigDataBoolean(path = "DisableActionBar")
|
||||
@Getter
|
||||
private boolean disableActionBar = false;
|
||||
|
||||
@ConfigDataBoolean(path = "DisableCoolDownCheck")
|
||||
@Getter
|
||||
private boolean disableCoolDownCheck = false;
|
||||
@@ -306,7 +310,7 @@ public class Config extends YMLFile {
|
||||
|
||||
@ConfigDataBoolean(path = "Format.Commands.Vote.ForceLinks")
|
||||
@Getter
|
||||
private boolean formatCommandsVoteForceLinks = true;
|
||||
private boolean formatCommandsVoteForceLinks = false;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.LastVoted")
|
||||
@Getter
|
||||
+1
-2
@@ -7,7 +7,6 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@@ -213,7 +212,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
try {
|
||||
data.save(dFile);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe(ChatColor.RED + "Could not create VoteSites/" + siteName + ".yml!");
|
||||
plugin.getLogger().severe("Could not create VoteSites/" + siteName + ".yml!");
|
||||
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -352,7 +352,7 @@ public class GUI extends YMLFile {
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteURL.URLText")
|
||||
@Getter
|
||||
private String chestVoteURLURLText = "%VoteUrl%";
|
||||
private String chestVoteURLURLText = "&3&lVote at &b&l[Text=\"&b&l%VoteUrl%\",hover=\"&aClick to open %sitename%\",url=\"%VoteUrl%\"]";
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteURL.ViewAllUrlsButtonEnabled")
|
||||
@Getter
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,95 @@
|
||||
package com.bencodez.votingplugin.listeners;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
// Reports whether a player is currently inside a minigame.
|
||||
//
|
||||
// A minigame owns the player's inventory for the duration of a match and puts it back afterwards from a snapshot
|
||||
// it took on entry. A reward delivered in between lands in the match kit and is destroyed by that restore, with
|
||||
// the bank already marked as delivered, so rewards have to wait until the player is back on the SMP.
|
||||
//
|
||||
// Everything here is reflective and optional: no minigame is a dependency, and an absent or changed plugin simply
|
||||
// reports "not in a minigame" rather than breaking vote delivery.
|
||||
final class MinigameCheck {
|
||||
|
||||
private static final String SPLEEF_PLUGIN = "Spleef-OG";
|
||||
private static final String SPLEEF_API = "net.trueog.spleefog.api.SpleefAPI";
|
||||
private static final String SPLEGG_PLUGIN = "Splegg-OG";
|
||||
private static final String DUELS_PLUGIN = "Duels-OG";
|
||||
|
||||
private MinigameCheck() {
|
||||
}
|
||||
|
||||
static boolean inMinigame(Player player) {
|
||||
return player != null && (inSpleef(player) || inSplegg(player) || inDuel(player));
|
||||
}
|
||||
|
||||
private static boolean inSpleef(Player player) {
|
||||
Plugin plugin = enabled(SPLEEF_PLUGIN);
|
||||
if (plugin == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
Class<?> api = Class.forName(SPLEEF_API, true, plugin.getClass().getClassLoader());
|
||||
Method query = api.getMethod("isInSpleef", Player.class);
|
||||
return Boolean.TRUE.equals(query.invoke(null, player));
|
||||
} catch (ReflectiveOperationException | RuntimeException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Splegg keeps its games in worlds it owns rather than in the SMP worlds, so the player's world answers this.
|
||||
private static boolean inSplegg(Player player) {
|
||||
Plugin plugin = enabled(SPLEGG_PLUGIN);
|
||||
if (plugin == null) {
|
||||
return false;
|
||||
}
|
||||
String world = player.getWorld().getName();
|
||||
try {
|
||||
Object configured = plugin.getClass().getMethod("getInGameWorlds").invoke(plugin);
|
||||
if (configured instanceof List<?> worlds) {
|
||||
for (Object name : worlds) {
|
||||
if (name != null && world.equalsIgnoreCase(name.toString())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Object prefix = plugin.getClass().getMethod("getGameWorldPrefix").invoke(plugin);
|
||||
// Per-game worlds are named <prefix><gameId>-<map>.
|
||||
return prefix != null && !prefix.toString().isEmpty()
|
||||
&& world.toLowerCase(Locale.ROOT).startsWith(prefix.toString().toLowerCase(Locale.ROOT));
|
||||
} catch (ReflectiveOperationException | RuntimeException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean inDuel(Player player) {
|
||||
Plugin plugin = enabled(DUELS_PLUGIN);
|
||||
if (plugin == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
Object arenaManager = plugin.getClass().getMethod("getArenaManager").invoke(plugin);
|
||||
if (arenaManager == null) {
|
||||
return false;
|
||||
}
|
||||
Method query = arenaManager.getClass().getMethod("isInMatch", Player.class);
|
||||
query.setAccessible(true);
|
||||
return Boolean.TRUE.equals(query.invoke(arenaManager, player));
|
||||
} catch (ReflectiveOperationException | RuntimeException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static Plugin enabled(String name) {
|
||||
Plugin plugin = Bukkit.getPluginManager().getPlugin(name);
|
||||
return plugin != null && plugin.isEnabled() ? plugin : null;
|
||||
}
|
||||
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,143 @@
|
||||
package com.bencodez.votingplugin.listeners;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||
|
||||
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
|
||||
import com.bencodez.advancedcore.listeners.PlayerRewardEvent;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
// Rewards given outside survival in the main worlds get wiped by
|
||||
// GameModeInventories' per-gamemode XP/inventory swap or land in the wrong
|
||||
// context, so bank them until the player is eligible again.
|
||||
//
|
||||
// A minigame counts as ineligible even though it runs in survival in a main
|
||||
// world: Spleef, Splegg and Duels each swap the player's inventory for a match
|
||||
// kit and put the real one back from a snapshot afterwards, so anything handed
|
||||
// over in between is destroyed by that restore while the bank has already been
|
||||
// marked as delivered.
|
||||
public class SurvivalRewardGate implements Listener {
|
||||
|
||||
private static final Set<String> REWARD_WORLDS = Set.of("world", "world_nether", "world_the_end");
|
||||
private static final long NOTICE_THROTTLE_MILLIS = 30000L;
|
||||
private static final long SWEEP_INTERVAL_TICKS = 200L;
|
||||
|
||||
static boolean eligibleForRewards(Player player) {
|
||||
return player.getGameMode() == GameMode.SURVIVAL && REWARD_WORLDS.contains(player.getWorld().getName())
|
||||
&& !MinigameCheck.inMinigame(player);
|
||||
}
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final ConcurrentHashMap<UUID, Long> lastBankNotice = new ConcurrentHashMap<>();
|
||||
private final Set<UUID> banked = ConcurrentHashMap.newKeySet();
|
||||
private int sweepTask = -1;
|
||||
|
||||
public SurvivalRewardGate(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
// Leaving a minigame does not always change gamemode or world -- a duel or a spleef match a player walks out of
|
||||
// can end in survival in the same world it started in -- so a slow sweep backstops the event triggers. It only
|
||||
// looks at players who actually have something banked, so an idle server does no work.
|
||||
public void start() {
|
||||
sweepTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
|
||||
if (banked.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (UUID uuid : Set.copyOf(banked)) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if (player == null || !player.isOnline()) {
|
||||
banked.remove(uuid);
|
||||
continue;
|
||||
}
|
||||
if (eligibleForRewards(player)) {
|
||||
scheduleReplay(uuid);
|
||||
}
|
||||
}
|
||||
}, SWEEP_INTERVAL_TICKS, SWEEP_INTERVAL_TICKS);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (sweepTask != -1) {
|
||||
Bukkit.getScheduler().cancelTask(sweepTask);
|
||||
sweepTask = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Fires on an async thread; PlayerRewardEvent does not implement Cancellable
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerReward(PlayerRewardEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
AdvancedCoreUser user = event.getPlayer();
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
Player player = user.getPlayer();
|
||||
if (player == null) {
|
||||
// truly offline: stock offline handling applies
|
||||
return;
|
||||
}
|
||||
if (eligibleForRewards(player)) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
user.addOfflineRewards(event.getReward(), event.getRewardOptions().getPlaceholders());
|
||||
plugin.debug("Banked reward " + event.getReward().getRewardName() + " for " + user.getPlayerName()
|
||||
+ " until survival in a main world");
|
||||
banked.add(player.getUniqueId());
|
||||
notifyBanked(player);
|
||||
}
|
||||
|
||||
private void notifyBanked(Player player) {
|
||||
long now = System.currentTimeMillis();
|
||||
Long last = lastBankNotice.put(player.getUniqueId(), now);
|
||||
if (last != null && now - last < NOTICE_THROTTLE_MILLIS) {
|
||||
return;
|
||||
}
|
||||
plugin.getLogger().info(player.getName() + " has vote rewards banked until survival in a main world");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onGameModeChange(PlayerGameModeChangeEvent event) {
|
||||
if (event.getNewGameMode() != GameMode.SURVIVAL) {
|
||||
return;
|
||||
}
|
||||
scheduleReplay(event.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onWorldChange(PlayerChangedWorldEvent event) {
|
||||
scheduleReplay(event.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
private void scheduleReplay(UUID uuid) {
|
||||
// 1 tick later the change is applied and GameModeInventories' restore has settled
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if (player == null || !player.isOnline() || !eligibleForRewards(player)) {
|
||||
return;
|
||||
}
|
||||
banked.remove(uuid);
|
||||
// reward replay fires the async PlayerRewardEvent, so hop off the main thread
|
||||
plugin.getLoginTimer().execute(() -> {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
user.offVote();
|
||||
user.checkOfflineRewards();
|
||||
});
|
||||
}, 1L);
|
||||
}
|
||||
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,91 @@
|
||||
package com.bencodez.votingplugin.listeners;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.bencodez.advancedcore.api.rewards.Reward;
|
||||
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
|
||||
import com.bencodez.advancedcore.listeners.PlayerRewardEvent;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
|
||||
// Each full week of voting every day adds a bonus level on top of the per-site
|
||||
// EXPLevels reward, capping the streak credit at MAX_WEEKS; missing a day
|
||||
// resets the day streak and with it the bonus.
|
||||
public class WeekStreakExpBonus implements Listener {
|
||||
|
||||
private static final String SITE_REWARD_PREFIX = "VoteSites.";
|
||||
private static final String SITE_REWARD_SUFFIX = ".Rewards";
|
||||
private static final int BASE_LEVELS = 15;
|
||||
private static final int MAX_WEEKS = 52;
|
||||
private static final int DAYS_PER_WEEK = 7;
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
|
||||
public WeekStreakExpBonus(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
// Runs after SurvivalRewardGate (HIGHEST); a banked reward arrives cancelled
|
||||
// here and earns its bonus when the replay passes the gate
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerReward(PlayerRewardEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
Reward reward = event.getReward();
|
||||
if (reward == null || reward.getRewardName() == null) {
|
||||
return;
|
||||
}
|
||||
String name = reward.getRewardName();
|
||||
if (!name.startsWith(SITE_REWARD_PREFIX) || !name.endsWith(SITE_REWARD_SUFFIX)) {
|
||||
return;
|
||||
}
|
||||
AdvancedCoreUser acUser = event.getPlayer();
|
||||
if (acUser == null) {
|
||||
return;
|
||||
}
|
||||
Player player = acUser.getPlayer();
|
||||
if (player == null || !SurvivalRewardGate.eligibleForRewards(player)) {
|
||||
return;
|
||||
}
|
||||
final UUID uuid = player.getUniqueId();
|
||||
// async event; XP must change on the main thread
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
Player target = Bukkit.getPlayer(uuid);
|
||||
if (target == null || !target.isOnline() || !SurvivalRewardGate.eligibleForRewards(target)) {
|
||||
return;
|
||||
}
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(target);
|
||||
int dayStreak = user.getDayVoteStreak();
|
||||
int weeks = dayStreak / DAYS_PER_WEEK;
|
||||
int bonus = Math.min(weeks, MAX_WEEKS);
|
||||
if (bonus > 0) {
|
||||
target.giveExpLevels(bonus);
|
||||
plugin.debug("Week streak bonus: +" + bonus + " levels for " + target.getName());
|
||||
}
|
||||
target.sendMessage(MiniMessage.miniMessage().deserialize(buildMessage(dayStreak, weeks, bonus)));
|
||||
});
|
||||
}
|
||||
|
||||
private String buildMessage(int dayStreak, int weeks, int bonus) {
|
||||
int total = BASE_LEVELS + bonus;
|
||||
if (bonus > 0) {
|
||||
return "<green>+" + total + " XP levels <gray>(" + weeks
|
||||
+ " week streak <dark_gray>-</dark_gray> vote every day to keep it)";
|
||||
}
|
||||
if (dayStreak > 0) {
|
||||
return "<green>+" + total + " XP levels <gray>(" + dayStreak + "/" + DAYS_PER_WEEK
|
||||
+ " days to your first bonus level)";
|
||||
}
|
||||
return "<green>+" + total + " XP levels <gray>(vote every day for a week to earn bonus XP)";
|
||||
}
|
||||
|
||||
}
|
||||
+5
-3
@@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -18,6 +17,9 @@ import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -178,8 +180,8 @@ public class VoteSite {
|
||||
}
|
||||
|
||||
public String getVoteURLJsonStrip() {
|
||||
String url = ChatColor
|
||||
.stripColor(MessageAPI.colorize(PlaceholderUtils.parseJson(getVoteURL(false)).toPlainText()));
|
||||
String url = PlainTextComponentSerializer.plainText().serialize(LegacyComponentSerializer.legacySection()
|
||||
.deserialize(MessageAPI.colorize(PlaceholderUtils.parseJson(getVoteURL(false)).toPlainText())));
|
||||
if (!url.startsWith("http")) {
|
||||
if (!url.startsWith("www.")) {
|
||||
url = "https://www." + url;
|
||||
File renamed without changes.
Loaded 100 of 163 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user