Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stylextv/gsigns-api
🔓🍀 A simple API for the GSigns plugin.
https://github.com/stylextv/gsigns-api
Last synced: 25 days ago
JSON representation
🔓🍀 A simple API for the GSigns plugin.
- Host: GitHub
- URL: https://github.com/stylextv/gsigns-api
- Owner: stylextv
- Created: 2020-10-12T18:29:01.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2020-11-22T08:13:26.000Z (about 4 years ago)
- Last Synced: 2024-10-14T06:36:01.151Z (2 months ago)
- Language: Java
- Size: 81.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
🔓 Source code of the GSigns-API, made with love in Java.
## What is it?
GSigns-API is a lightweight api for the plugin GSigns that allows the creation and removal of signs.
> The github page of the plugin can be found [here](https://github.com/StylexTV/GSigns/).## Including
To include this api in your own plugin, download the [latest release](https://github.com/StylexTV/GSigns-API/releases/) and add the following line to your `plugin.yml`:
```bash
depend: [GSigns]
```## Implementing GSigns
Implementing GSigns is quite simple. It requires getting the GSigns-API service from the Bukkit ServiceManager. See the example below:
```java
package com.example.plugin;import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;import de.stylextv.gs.api.GSignsAPI;
public class Main extends JavaPlugin {
private GSignsAPI gSignsAPI;
private UUID signUid;
@Override
public void onEnable() {
if(!setupGSignsAPI()) {
System.out.println(getDescription().getName()+" - Disabled due to no GSigns dependency found!");
getServer().getPluginManager().disablePlugin(this);
return;
}
new BukkitRunnable() {
@Override
public void run() {
World w = Bukkit.getWorld("world");
String code = "{bg-url:https://raw.githubusercontent.com/StylexTV/GSigns/master/showcase/socials/cover.png,dith:false}";
signUid = gSignsAPI.createSign(code, new Location(w, -402, 100, -43), new Location(w, -395, 97, -43));
}
}.runTaskLater(this, 5);
}
@Override
public void onDisable() {
if(signUid != null) {
gSignsAPI.removeSign(signUid);
}
}
private boolean setupGSignsAPI() {
if(getServer().getPluginManager().getPlugin("GSigns") == null) {
return false;
}
RegisteredServiceProvider rsp = getServer().getServicesManager().getRegistration(GSignsAPI.class);
if(rsp == null) {
return false;
}
gSignsAPI = rsp.getProvider();
return gSignsAPI != null;
}
}
```