Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: DevDrizzy <[email protected]>
  • Loading branch information
DevDrizzy committed Dec 1, 2023
0 parents commit 004561d
Show file tree
Hide file tree
Showing 25 changed files with 3,236 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build with Maven

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
inputs:
logLevel:
description: 'Start Build'
required: true
default: 'warning'
tags:
required: false
description: 'Start Build'

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: mvn clean package
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# IntelliJ
.idea/
*.iml
*.iws

# Mac
.DS_Store

# Maven
log/
target/
dependency-reduced-pom.xml

# JRebel
rebel.xml
127 changes: 127 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# TablistAPI
Refine's TablistAPI | Custom

## Features
- Support for Custom Skins along with Dot Skins and Mob Skins
- Supports all spigot and client versions (1.7x to 1.20x).
- Lightweight with no performance overhead.
- Supports hex colors on supported versions.
- 1.7 clients have a 32 char limit whilst 1.8+ clients have a 48 char limit.
- Easy to use.

## Installing
You can either shade this repository into your plugin, or run it as a plugin by itself.

1. Clone this repository
2. Enter the directory: `cd TablistAPI`
3. Build & install with Maven: `mvn clean package install`

OR
```xml
<repositories>
<repository>
<id>refine-public</id>
<url>https://maven.refinedev.xyz/repository/refine-public/</url>
</repository>
</repositories>
```
Next, add TablistAPI to your project's dependencies via Maven

Add this to your `pom.xml` `<dependencies>`:
```xml
<dependency>
<groupId>xyz.refinedev.api</groupId>
<artifactId>TablistAPI</artifactId>
<version>2.1</version>
<scope>compile</scope>
</dependency>
```

## Usage
It requires PacketEvents to be shaded in the plugin you are using this with.
I recommend registering tablist after any other scoreboard related API is registered because
those APIs sometimes assign or override the player's scoreboard, which would be problematic here.

You can initiate and register a TablistAdapter using the following code:

```java
import xyz.refinedev.api.tablist.TablistHandler;
import xyz.refinedev.api.tablist.adapter.impl.ExampleAdapter;

import com.github.retrooper.packetevents.PacketEventsAPI;

public class ExamplePlugin extends JavaPlugin {

private TablistHandler tablistHandler;
private PacketEventsAPI<?> packetEvents;

@Override
public void onEnable() {
//this.packetEvents.init();
this.tablistHandler = new TablistHandler(plugin);
this.tablistHandler.init(this.packetEvents, new TeamsPacketListener(this.packetEvents));
this.tablistHandler.registerAdapter(new ExampleAdapter(tablist), 20L);
}
}
```

```java
import xyz.refinedev.api.tablist.adapter.TabAdapter;

public class TablistAdapter implements TabAdapter {

/**
* Get the tab header for a player.
*
* @param player the player
* @return string
*/
public String getHeader(Player player) { // String or you can use \n to use multiple lines
return "Example";
}

/**
* Get the tab player for a player.
*
* @param player the player
* @return string
*/
public String getFooter(Player player) { // String or you can use \n to use multiple lines
return "Example";
}

/**
* Get the tab lines for a player.
*
* @param player the player
* @return list of entries
*/
public List<TabEntry> getLines(Player player) { // Tab Entry contains the string, skin, slot and ping of the tablist slot
List<TabEntry> entries = new ArrayList<>();

List<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers());

for ( int i = 0; i < 80; i++ ) {
final int x = i % 4;
final int y = i / 4;

if (players.size() <= i) continue;

Player tabPlayer = players.get(i);
if (tabPlayer == null) continue;

entries.add(new TabEntry(x, y, tabPlayer.getDisplayName(), tabPlayer.spigot().getPing(), Skin.getPlayer(tabPlayer)));
}

return entries;
}
}
```

## Support
I don't plan on working on the API much, so don't expect support for bugs.
If you need help with implementation, feel free to ask in my discord.

## Disclaimer
Feel free to use this API in any project, just give credits. You are not allowed to sell or
claim ownership of this code. The code is provided as is and is property of Refine Development.
170 changes: 170 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>

<name>TablistAPI</name>
<url>https://github.com/RefineDevelopment/TablistAPI</url>
<description>Most Modern and Support Friendly Tablist API</description>

<organization>
<name>Refine Development</name>
<url>https://dsc.gg/refine</url>
</organization>

<groupId>xyz.refinedev.api</groupId>
<artifactId>TablistAPI</artifactId>
<version>2.1</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spigot.version>1.20.2-R0.1-SNAPSHOT</spigot.version>
</properties>

<repositories>
<repository>
<id>nms-repo</id>
<url>https://repo.codemc.io/repository/nms/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>refine-public</id>
<url>https://maven.refinedev.xyz/repository/public-repo/</url>
</repository>
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
</repository>
</repositories>

<distributionManagement>
<repository>
<id>refine-public</id>
<url>https://maven.refinedev.xyz/repository/public-repo/</url>
</repository>
</distributionManagement>

<dependencies>
<dependency>
<groupId>com.github.retrooper.packetevents</groupId>
<artifactId>spigot</artifactId>
<version>2.1.0</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</exclusion>
<exclusion>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
</exclusion>
</exclusions>
</dependency>

<!--Annotations-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
<type>jar</type>
<scope>provided</scope>
</dependency>

<!--Spigot-->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>${spigot.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>${spigot.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>fastutil</artifactId>
<version>8.5.12</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
<defaultGoal>clean install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<optimize>true</optimize>
<useIncrementalCompilation>false</useIncrementalCompilation>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
</path>
</annotationProcessorPaths>
<target>${maven.compiler.target}</target>
<source>${maven.compiler.source}</source>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.0</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<shadedArtifactAttached>false</shadedArtifactAttached>
<minimizeJar>true</minimizeJar>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</filter>
</filters>

<!-- Do it in a plugin -->
<!-- <relocations>-->
<!-- <relocation>-->
<!-- <pattern>com.github.retrooper</pattern>-->
<!-- <shadedPattern>xyz.refinedev.lib.com.github.retrooper</shadedPattern>-->
<!-- </relocation>-->
<!-- <relocation>-->
<!-- <pattern>io.github.retrooper</pattern>-->
<!-- <shadedPattern>xyz.refinedev.lib.io.github.retrooper</shadedPattern>-->
<!-- </relocation>-->
<!-- <relocation>-->
<!-- <pattern>net.kyori</pattern>-->
<!-- <shadedPattern>xyz.refinedev.lib.com.github.retrooper.libs.net.kyori</shadedPattern>-->
<!-- </relocation>-->
<!-- </relocations>-->

</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Loading

0 comments on commit 004561d

Please sign in to comment.