-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c7b210d
Showing
22 changed files
with
1,510 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<img src="https://i.imgur.com/8CSt94n.png" alt="Logo" align="right"> | ||
<div align="center"> | ||
<h1>It's dangerous to go alone</h1> | ||
<h3>Unite in shining armor is here! Depend on me to save developers from supporting multiple party plugins.</h3> | ||
</div> | ||
|
||
Download | ||
--- | ||
|
||
Available for download on SpigotMC: https://www.spigotmc.org/resources/unite.95217/ | ||
|
||
Usage | ||
--- | ||
|
||
Documentation can be found in the Wiki: https://github.com/PikaMug/Unite/wiki/Getting-started | ||
|
||
Recommended | ||
--- | ||
|
||
Need a party plugin? We recommend [Parties](https://github.com/AlessioDP/Parties) by @AlessioDP (not sponsored) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?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> | ||
|
||
<groupId>me.pikamug.unite</groupId> | ||
<artifactId>Unite</artifactId> | ||
<version>1.0.0</version> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<repositories> | ||
<repository> | ||
<id>spigot-repo</id> | ||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> | ||
</repository> | ||
<repository> | ||
<!-- Parties --> | ||
<id>alessiodp-repo</id> | ||
<url>https://repo.alessiodp.com/releases/</url> | ||
</repository> | ||
<repository> | ||
<!-- DungeonsXL --> | ||
<id>jitpack.io</id> | ||
<url>https://jitpack.io</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.bukkit</groupId> | ||
<artifactId>bukkit</artifactId> | ||
<version>1.13.2-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jetbrains</groupId> | ||
<artifactId>annotations</artifactId> | ||
<version>21.0.1</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.alessiodp.parties</groupId> | ||
<artifactId>parties-bukkit</artifactId> | ||
<version>3.1.8</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.github.PikaMug</groupId> | ||
<artifactId>DungeonsXL-Dummy</artifactId> | ||
<version>377c3a340e</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<defaultGoal>clean install</defaultGoal> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>8</source> | ||
<target>8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
<sourceDirectory>${basedir}/src/main/java</sourceDirectory> | ||
<resources> | ||
<resource> | ||
<directory>${basedir}/src/main/resources/</directory> | ||
<filtering>true</filtering> | ||
<includes> | ||
<include>plugin.yml</include> | ||
</includes> | ||
</resource> | ||
</resources> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package me.pikamug.unite; | ||
|
||
import me.pikamug.unite.api.objects.PartyProvider; | ||
import me.pikamug.unite.api.objects.plugins.PartyProvider_DungeonsXL; | ||
import me.pikamug.unite.api.objects.plugins.PartyProvider_Parties; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.plugin.Plugin; | ||
import org.bukkit.plugin.ServicePriority; | ||
import org.bukkit.plugin.ServicesManager; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Objects; | ||
import java.util.logging.Logger; | ||
|
||
public class Unite extends JavaPlugin { | ||
private static Unite instance; | ||
private static Logger log; | ||
private ServicesManager servicesManager; | ||
|
||
@Override | ||
public void onEnable() { | ||
instance = this; | ||
log = this.getLogger(); | ||
servicesManager = getServer().getServicesManager(); | ||
|
||
hookProviders(); | ||
|
||
Objects.requireNonNull(getCommand("unite")).setExecutor(this); | ||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
getServer().getServicesManager().unregisterAll(this); | ||
} | ||
|
||
@Override | ||
public boolean onCommand(CommandSender sender, @NotNull Command command, @NotNull String commandLabel, String[] args) { | ||
if (!sender.hasPermission("unite.admin")) { | ||
sender.sendMessage("You do not have permission to use that command!"); | ||
return true; | ||
} | ||
|
||
sender.sendMessage("Unite v" + this.getDescription().getVersion() + " Commands:"); | ||
sender.sendMessage(" /unite - Displays information about Unite"); | ||
return true; | ||
} | ||
|
||
public static Unite getInstance() { | ||
return instance; | ||
} | ||
|
||
public void hookProviders() { | ||
hookProvider("Parties", PartyProvider_Parties.class, ServicePriority.Highest, "com.alessiodp.parties.api.interfaces.PartiesAPI"); | ||
hookProvider("DungeonsXL", PartyProvider_DungeonsXL.class, ServicePriority.High, "de.erethon.dungeonsxl.DungeonsXL"); | ||
} | ||
|
||
private void hookProvider(String name, Class<? extends PartyProvider> hookClass, ServicePriority priority, String...packages) { | ||
try { | ||
if (packagesExists(packages)) { | ||
PartyProvider partyProvider = hookClass.getConstructor(Plugin.class).newInstance(this); | ||
servicesManager.register(PartyProvider.class, partyProvider, this, priority); | ||
log.info(String.format("[Party] %s found: %s", name, partyProvider.isPluginEnabled() ? "Loaded" : "Waiting")); | ||
} | ||
} catch (Exception e) { | ||
log.severe(String.format("[Party] There was an error hooking %s - check to make sure you're using a compatible version!", name)); | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
/** | ||
* Determines if all packages in a String array are within the classpath. | ||
* @param packages String array of package names to check | ||
* @return true if successful | ||
*/ | ||
private static boolean packagesExists(String...packages) { | ||
try { | ||
for (String pkg : packages) { | ||
Class.forName(pkg); | ||
} | ||
return true; | ||
} catch (Exception e) { | ||
return false; | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/me/pikamug/unite/api/events/PartyCreateEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package me.pikamug.unite.api.events; | ||
|
||
import me.pikamug.unite.api.interfaces.PartyEvent; | ||
import org.bukkit.event.Event; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.UUID; | ||
|
||
public abstract class PartyCreateEvent extends Event implements PartyEvent { | ||
private static final HandlerList HANDLERS = new HandlerList(); | ||
|
||
public PartyCreateEvent(boolean async) { | ||
super(async); | ||
} | ||
|
||
public @NotNull HandlerList getHandlers() { | ||
return HANDLERS; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return HANDLERS; | ||
} | ||
|
||
public abstract UUID getCreator(); | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/me/pikamug/unite/api/events/PartyDeleteEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package me.pikamug.unite.api.events; | ||
|
||
import me.pikamug.unite.api.interfaces.PartyEvent; | ||
import org.bukkit.event.Event; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.UUID; | ||
|
||
public abstract class PartyDeleteEvent extends Event implements PartyEvent { | ||
private static final HandlerList HANDLERS = new HandlerList(); | ||
|
||
public PartyDeleteEvent(boolean async) { | ||
super(async); | ||
} | ||
|
||
public @NotNull HandlerList getHandlers() { | ||
return HANDLERS; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return HANDLERS; | ||
} | ||
|
||
public abstract UUID getDisbander(); | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/me/pikamug/unite/api/events/PartyJoinEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package me.pikamug.unite.api.events; | ||
|
||
import me.pikamug.unite.api.interfaces.PartyEvent; | ||
import org.bukkit.event.Event; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.UUID; | ||
|
||
public abstract class PartyJoinEvent extends Event implements PartyEvent { | ||
private static final HandlerList HANDLERS = new HandlerList(); | ||
|
||
public PartyJoinEvent(boolean async) { | ||
super(async); | ||
} | ||
|
||
public @NotNull HandlerList getHandlers() { | ||
return HANDLERS; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return HANDLERS; | ||
} | ||
|
||
public abstract UUID getPlayer(); | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/me/pikamug/unite/api/events/PartyLeaveEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package me.pikamug.unite.api.events; | ||
|
||
import me.pikamug.unite.api.interfaces.PartyEvent; | ||
import org.bukkit.event.Event; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.UUID; | ||
|
||
public abstract class PartyLeaveEvent extends Event implements PartyEvent { | ||
private static final HandlerList HANDLERS = new HandlerList(); | ||
|
||
public PartyLeaveEvent(boolean async) { | ||
super(async); | ||
} | ||
|
||
public @NotNull HandlerList getHandlers() { | ||
return HANDLERS; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return HANDLERS; | ||
} | ||
|
||
public abstract UUID getPlayer(); | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/me/pikamug/unite/api/events/dungeonsxl/PartyCreateEvent_DungeonsXL.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package me.pikamug.unite.api.events.dungeonsxl; | ||
|
||
import de.erethon.dungeonsxl.api.event.group.GroupCreateEvent; | ||
import me.pikamug.unite.api.events.PartyCreateEvent; | ||
import me.pikamug.unite.api.objects.PartyProvider; | ||
import org.bukkit.event.Event; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
public class PartyCreateEvent_DungeonsXL extends PartyCreateEvent { | ||
private final PartyProvider partyProvider; | ||
private final GroupCreateEvent event; | ||
|
||
public PartyCreateEvent_DungeonsXL(PartyProvider partyProvider, Event event, boolean async) { | ||
super(async); | ||
this.partyProvider = partyProvider; | ||
this.event = (GroupCreateEvent) event; | ||
} | ||
|
||
@Override | ||
public @NotNull Event getPluginEvent() { | ||
return event; | ||
} | ||
|
||
@Override | ||
public PartyProvider getPartyProvider() { | ||
return partyProvider; | ||
} | ||
|
||
@Override | ||
public UUID getCreator() { | ||
return Objects.requireNonNull(event.getCreator()).getUniqueId(); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/me/pikamug/unite/api/events/dungeonsxl/PartyDeleteEvent_DungeonsXL.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package me.pikamug.unite.api.events.dungeonsxl; | ||
|
||
import de.erethon.dungeonsxl.api.event.group.GroupDisbandEvent; | ||
import me.pikamug.unite.api.events.PartyDeleteEvent; | ||
import me.pikamug.unite.api.objects.PartyProvider; | ||
import org.bukkit.event.Event; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
public class PartyDeleteEvent_DungeonsXL extends PartyDeleteEvent { | ||
private final PartyProvider partyProvider; | ||
private final GroupDisbandEvent event; | ||
|
||
public PartyDeleteEvent_DungeonsXL(PartyProvider partyProvider, Event event, boolean async) { | ||
super(async); | ||
this.partyProvider = partyProvider; | ||
this.event = (GroupDisbandEvent) event; | ||
} | ||
|
||
@Override | ||
public @NotNull Event getPluginEvent() { | ||
return event; | ||
} | ||
|
||
@Override | ||
public PartyProvider getPartyProvider() { | ||
return partyProvider; | ||
} | ||
|
||
@Override | ||
public UUID getDisbander() { | ||
return Objects.requireNonNull(event.getDisbander()).getUniqueId(); | ||
} | ||
} |
Oops, something went wrong.