forked from alkarinv/BattleArena
-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Showing
24 changed files
with
569 additions
and
29 deletions.
There are no files selected for viewing
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
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,10 @@ | ||
repositories { | ||
maven("https://repo.alessiodp.com/releases/") | ||
maven("https://simonsator.de/repo/") | ||
} | ||
|
||
dependencies { | ||
compileOnly("com.alessiodp.parties:parties-api:3.2.15") | ||
compileOnly("de.simonsator:Party-and-Friends-MySQL-Edition-Spigot-API:1.6.2-RELEASE") | ||
compileOnly("de.simonsator:spigot-party-api-for-party-and-friends:1.0.7-RELEASE") | ||
} |
33 changes: 33 additions & 0 deletions
33
...arty-integration/src/main/java/org/battleplugins/arena/module/party/PartyIntegration.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,33 @@ | ||
package org.battleplugins.arena.module.party; | ||
|
||
import org.battleplugins.arena.event.BattleArenaPostInitializeEvent; | ||
import org.battleplugins.arena.feature.party.Parties; | ||
import org.battleplugins.arena.module.ArenaModule; | ||
import org.battleplugins.arena.module.ArenaModuleInitializer; | ||
import org.battleplugins.arena.module.party.paf.PAFPartiesFeature; | ||
import org.battleplugins.arena.module.party.parties.PartiesPartiesFeature; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.event.EventHandler; | ||
|
||
/** | ||
* A module that allows for hooking into various party plugins. | ||
*/ | ||
@ArenaModule(id = PartyIntegration.ID, name = "Party", description = "Adds support for hooking into various Party plugins.", authors = "BattlePlugins") | ||
public class PartyIntegration implements ArenaModuleInitializer { | ||
public static final String ID = "party"; | ||
|
||
@EventHandler | ||
public void onPostInitialize(BattleArenaPostInitializeEvent event) { | ||
if (Bukkit.getPluginManager().isPluginEnabled("Spigot-Party-API-PAF")) { | ||
Parties.register(new PAFPartiesFeature()); | ||
|
||
event.getBattleArena().info("Parties for Friends (API) found. Using Spigot-Party-API-PAF for party integration."); | ||
} | ||
|
||
if (Bukkit.getPluginManager().isPluginEnabled("Parties")) { | ||
Parties.register(new PartiesPartiesFeature()); | ||
|
||
event.getBattleArena().info("Parties found. Using Parties for party integration."); | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...integration/src/main/java/org/battleplugins/arena/module/party/paf/PAFPartiesFeature.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,28 @@ | ||
package org.battleplugins.arena.module.party.paf; | ||
|
||
import de.simonsator.partyandfriends.spigot.api.pafplayers.PAFPlayer; | ||
import de.simonsator.partyandfriends.spigot.api.pafplayers.PAFPlayerManager; | ||
import de.simonsator.partyandfriends.spigot.api.party.PartyManager; | ||
import org.battleplugins.arena.feature.PluginFeature; | ||
import org.battleplugins.arena.feature.party.PartiesFeature; | ||
import org.battleplugins.arena.feature.party.Party; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.UUID; | ||
|
||
public class PAFPartiesFeature extends PluginFeature<PartiesFeature> implements PartiesFeature { | ||
|
||
public PAFPartiesFeature() { | ||
super("Spigot-Party-API-PAF"); | ||
} | ||
|
||
@Override | ||
public @Nullable Party getParty(UUID uuid) { | ||
PAFPlayer player = PAFPlayerManager.getInstance().getPlayer(uuid); | ||
if (player == null) { | ||
return null; | ||
} | ||
|
||
return new PAFParty(PartyManager.getInstance().getParty(player)); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...le/party-integration/src/main/java/org/battleplugins/arena/module/party/paf/PAFParty.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,28 @@ | ||
package org.battleplugins.arena.module.party.paf; | ||
|
||
import de.simonsator.partyandfriends.spigot.api.party.PlayerParty; | ||
import org.battleplugins.arena.feature.party.Party; | ||
import org.battleplugins.arena.feature.party.PartyMember; | ||
|
||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
public class PAFParty implements Party { | ||
private final PlayerParty impl; | ||
|
||
public PAFParty(PlayerParty impl) { | ||
this.impl = impl; | ||
} | ||
|
||
@Override | ||
public PartyMember getLeader() { | ||
return new PAFPartyMember(this.impl.getLeader()); | ||
} | ||
|
||
@Override | ||
public Set<PartyMember> getMembers() { | ||
return this.impl.getPlayers().stream() | ||
.map(PAFPartyMember::new) | ||
.collect(Collectors.toSet()); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...ty-integration/src/main/java/org/battleplugins/arena/module/party/paf/PAFPartyMember.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,31 @@ | ||
package org.battleplugins.arena.module.party.paf; | ||
|
||
import de.simonsator.partyandfriends.spigot.api.pafplayers.PAFPlayer; | ||
import de.simonsator.partyandfriends.spigot.api.party.PartyManager; | ||
import org.battleplugins.arena.feature.party.Party; | ||
import org.battleplugins.arena.feature.party.PartyMember; | ||
|
||
import java.util.UUID; | ||
|
||
public class PAFPartyMember implements PartyMember { | ||
private final PAFPlayer impl; | ||
|
||
public PAFPartyMember(PAFPlayer impl) { | ||
this.impl = impl; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return this.impl.getName(); | ||
} | ||
|
||
@Override | ||
public UUID getUniqueId() { | ||
return this.impl.getUniqueId(); | ||
} | ||
|
||
@Override | ||
public Party getParty() { | ||
return new PAFParty(PartyManager.getInstance().getParty(this.impl)); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...ion/src/main/java/org/battleplugins/arena/module/party/parties/PartiesPartiesFeature.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 org.battleplugins.arena.module.party.parties; | ||
|
||
import com.alessiodp.parties.api.Parties; | ||
import org.battleplugins.arena.feature.PluginFeature; | ||
import org.battleplugins.arena.feature.party.PartiesFeature; | ||
import org.battleplugins.arena.feature.party.Party; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.UUID; | ||
|
||
public class PartiesPartiesFeature extends PluginFeature<PartiesPartiesFeature> implements PartiesFeature { | ||
|
||
public PartiesPartiesFeature() { | ||
super("Parties"); | ||
} | ||
|
||
@Override | ||
public @Nullable Party getParty(UUID uuid) { | ||
com.alessiodp.parties.api.interfaces.Party party = Parties.getApi().getPartyOfPlayer(uuid); | ||
if (party == null) { | ||
return null; | ||
} | ||
|
||
return new PartiesParty(party); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...-integration/src/main/java/org/battleplugins/arena/module/party/parties/PartiesParty.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,46 @@ | ||
package org.battleplugins.arena.module.party.parties; | ||
|
||
import com.alessiodp.parties.api.Parties; | ||
import com.alessiodp.parties.api.interfaces.PartyPlayer; | ||
import org.battleplugins.arena.feature.party.Party; | ||
import org.battleplugins.arena.feature.party.PartyMember; | ||
|
||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
public class PartiesParty implements Party { | ||
private final com.alessiodp.parties.api.interfaces.Party impl; | ||
|
||
public PartiesParty(com.alessiodp.parties.api.interfaces.Party impl) { | ||
this.impl = impl; | ||
} | ||
|
||
@Override | ||
public PartyMember getLeader() { | ||
if (this.impl.getLeader() == null) { | ||
// Return the first member of the party if the leader is null | ||
Set<PartyMember> members = this.getMembers(); | ||
if (!members.isEmpty()) { | ||
return members.iterator().next(); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
PartyPlayer player = Parties.getApi().getPartyPlayer(this.impl.getLeader()); | ||
if (player == null) { | ||
return null; | ||
} | ||
|
||
return new PartiesPartyMember(player); | ||
} | ||
|
||
@Override | ||
public Set<PartyMember> getMembers() { | ||
return this.impl.getOnlineMembers() | ||
.stream() | ||
.filter(m -> !m.getPlayerUUID().equals(this.impl.getLeader())) | ||
.map(PartiesPartyMember::new) | ||
.collect(Collectors.toSet()); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...ration/src/main/java/org/battleplugins/arena/module/party/parties/PartiesPartyMember.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 org.battleplugins.arena.module.party.parties; | ||
|
||
import com.alessiodp.parties.api.Parties; | ||
import com.alessiodp.parties.api.interfaces.PartyPlayer; | ||
import org.battleplugins.arena.feature.party.Party; | ||
import org.battleplugins.arena.feature.party.PartyMember; | ||
|
||
import java.util.UUID; | ||
|
||
public class PartiesPartyMember implements PartyMember { | ||
private final PartyPlayer impl; | ||
|
||
public PartiesPartyMember(PartyPlayer impl) { | ||
this.impl = impl; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return this.impl.getName(); | ||
} | ||
|
||
@Override | ||
public UUID getUniqueId() { | ||
return this.impl.getPlayerUUID(); | ||
} | ||
|
||
@Override | ||
public Party getParty() { | ||
com.alessiodp.parties.api.interfaces.Party party = Parties.getApi().getPartyOfPlayer(this.impl.getPlayerUUID()); | ||
if (party == null) { | ||
return null; | ||
} | ||
|
||
return new PartiesParty(party); | ||
} | ||
} |
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
Oops, something went wrong.