mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-24 19:45:43 +01:00
Change API method naming to be more consistent
This commit is contained in:
parent
4b222c914b
commit
2574a06b87
@ -143,7 +143,7 @@ public interface DungeonsAPI extends Plugin {
|
|||||||
*
|
*
|
||||||
* @return a cache of the player groups
|
* @return a cache of the player groups
|
||||||
*/
|
*/
|
||||||
Registry<String, PlayerGroup> getPlayerGroupCache();
|
Registry<String, PlayerGroup> getGroupCache();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes DungeonsXL track external group and synchronize them with its own groups.
|
* Makes DungeonsXL track external group and synchronize them with its own groups.
|
||||||
|
@ -245,12 +245,12 @@ public abstract class GroupAdapter<T> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (dGroup != null) {
|
if (dGroup != null) {
|
||||||
dGroup.removePlayer(player, false);
|
dGroup.removeMember(player, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dGroup = getDungeonGroup(eGroup);
|
dGroup = getDungeonGroup(eGroup);
|
||||||
if (dGroup != null && !dGroup.getMembers().contains(player)) {
|
if (dGroup != null && !dGroup.getMembers().contains(player)) {
|
||||||
dGroup.addPlayer(player);
|
dGroup.addMember(player);
|
||||||
} else {
|
} else {
|
||||||
dGroup = createDungeonGroup(eGroup);
|
dGroup = createDungeonGroup(eGroup);
|
||||||
}
|
}
|
||||||
|
@ -219,12 +219,12 @@ public interface PlayerGroup {
|
|||||||
/**
|
/**
|
||||||
* Adds a player to the group.
|
* Adds a player to the group.
|
||||||
* <p>
|
* <p>
|
||||||
* The default implemenation calls {@link #addPlayer(Player, boolean)} with messages set to true.
|
* The default implemenation calls {@link #addMember(Player, boolean)} with messages set to true.
|
||||||
*
|
*
|
||||||
* @param player the player to add
|
* @param player the player to add
|
||||||
*/
|
*/
|
||||||
default void addPlayer(Player player) {
|
default void addMember(Player player) {
|
||||||
addPlayer(player, true);
|
addMember(player, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -233,17 +233,17 @@ public interface PlayerGroup {
|
|||||||
* @param player the player to add
|
* @param player the player to add
|
||||||
* @param message if messages shall be sent
|
* @param message if messages shall be sent
|
||||||
*/
|
*/
|
||||||
void addPlayer(Player player, boolean message);
|
void addMember(Player player, boolean message);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a player from the group.
|
* Removes a player from the group.
|
||||||
* <p>
|
* <p>
|
||||||
* The default implemenation calls {@link #removePlayer(Player, boolean)} with messages set to true.
|
* The default implemenation calls {@link #removeMember(Player, boolean)} with messages set to true.
|
||||||
*
|
*
|
||||||
* @param player the player to add
|
* @param player the player to add
|
||||||
*/
|
*/
|
||||||
default void removePlayer(Player player) {
|
default void removeMember(Player player) {
|
||||||
addPlayer(player, true);
|
addMember(player, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -252,7 +252,7 @@ public interface PlayerGroup {
|
|||||||
* @param player the player to add
|
* @param player the player to add
|
||||||
* @param message if messages shall be sent
|
* @param message if messages shall be sent
|
||||||
*/
|
*/
|
||||||
void removePlayer(Player player, boolean message);
|
void removeMember(Player player, boolean message);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a PlayerCollection of the players who are invited to join the group but did not yet do so.
|
* Returns a PlayerCollection of the players who are invited to join the group but did not yet do so.
|
||||||
|
@ -529,7 +529,7 @@ public class DungeonsXL extends DREPlugin implements DungeonsAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Registry<String, PlayerGroup> getPlayerGroupCache() {
|
public Registry<String, PlayerGroup> getGroupCache() {
|
||||||
return playerGroupCache;
|
return playerGroupCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,13 +358,13 @@ public class Announcer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (group != null && group.getMembers().contains(player)) {
|
if (group != null && group.getMembers().contains(player)) {
|
||||||
group.removePlayer(player);
|
group.removeMember(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dGroup != null && pGroup == null) {
|
if (dGroup != null && pGroup == null) {
|
||||||
if (dGroup.getMembers().size() < maxPlayersPerGroup) {
|
if (dGroup.getMembers().size() < maxPlayersPerGroup) {
|
||||||
dGroup.addPlayer(player);
|
dGroup.addMember(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (dGroup == null && pGroup == null) {
|
} else if (dGroup == null && pGroup == null) {
|
||||||
@ -409,7 +409,7 @@ public class Announcer {
|
|||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
|
|
||||||
DGroup dGroup = dGroups.get(groupCount);
|
DGroup dGroup = dGroups.get(groupCount);
|
||||||
if (!plugin.getPlayerGroupCache().contains(dGroup)) {
|
if (!plugin.getGroupCache().contains(dGroup)) {
|
||||||
dGroups.set(groupCount, null);
|
dGroups.set(groupCount, null);
|
||||||
|
|
||||||
} else if (dGroup != null) {
|
} else if (dGroup != null) {
|
||||||
|
@ -48,8 +48,8 @@ public class EnterCommand extends DCommand {
|
|||||||
Player captain = (Player) sender;
|
Player captain = (Player) sender;
|
||||||
String targetName = args.length == 3 ? args[2] : args[1];
|
String targetName = args.length == 3 ? args[2] : args[1];
|
||||||
|
|
||||||
PlayerGroup joining = args.length == 3 ? plugin.getPlayerGroupCache().get(args[1]) : plugin.getPlayerGroup(captain);
|
PlayerGroup joining = args.length == 3 ? plugin.getGroupCache().get(args[1]) : plugin.getPlayerGroup(captain);
|
||||||
PlayerGroup target = plugin.getPlayerGroupCache().get(targetName);
|
PlayerGroup target = plugin.getGroupCache().get(targetName);
|
||||||
|
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
Player targetPlayer = Bukkit.getPlayer(targetName);
|
Player targetPlayer = Bukkit.getPlayer(targetName);
|
||||||
|
@ -64,7 +64,7 @@ public class EscapeCommand extends DCommand {
|
|||||||
} else {
|
} else {
|
||||||
PlayerGroup dGroup = plugin.getPlayerGroup(player);
|
PlayerGroup dGroup = plugin.getPlayerGroup(player);
|
||||||
if (dGroup != null) {
|
if (dGroup != null) {
|
||||||
dGroup.removePlayer(player);
|
dGroup.removeMember(player);
|
||||||
MessageUtil.sendMessage(player, DMessage.CMD_LEAVE_SUCCESS.getMessage());
|
MessageUtil.sendMessage(player, DMessage.CMD_LEAVE_SUCCESS.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -90,15 +90,15 @@ public class GroupCommand extends DCommand {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
} else if (args[1].equalsIgnoreCase("disband") && DPermission.hasPermission(sender, DPermission.GROUP_ADMIN)) {
|
} else if (args[1].equalsIgnoreCase("disband") && DPermission.hasPermission(sender, DPermission.GROUP_ADMIN)) {
|
||||||
disbandGroup((DGroup) plugin.getPlayerGroupCache().get(args[2]), args[2]);
|
disbandGroup((DGroup) plugin.getGroupCache().get(args[2]), args[2]);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else if (args[1].equalsIgnoreCase("join")) {
|
} else if (args[1].equalsIgnoreCase("join")) {
|
||||||
joinGroup((DGroup) plugin.getPlayerGroupCache().get(args[2]));
|
joinGroup((DGroup) plugin.getGroupCache().get(args[2]));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else if (args[1].equalsIgnoreCase("show") && DPermission.hasPermission(sender, DPermission.GROUP_ADMIN)) {
|
} else if (args[1].equalsIgnoreCase("show") && DPermission.hasPermission(sender, DPermission.GROUP_ADMIN)) {
|
||||||
DGroup group = (DGroup) plugin.getPlayerGroupCache().get(args[2]);
|
DGroup group = (DGroup) plugin.getGroupCache().get(args[2]);
|
||||||
Player player = Bukkit.getPlayer(args[2]);
|
Player player = Bukkit.getPlayer(args[2]);
|
||||||
if (group == null && player != null) {
|
if (group == null && player != null) {
|
||||||
group = (DGroup) plugin.getPlayerGroup(player);
|
group = (DGroup) plugin.getPlayerGroup(player);
|
||||||
@ -117,7 +117,7 @@ public class GroupCommand extends DCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.getPlayerGroupCache().get(args[2]) != null) {
|
if (plugin.getGroupCache().get(args[2]) != null) {
|
||||||
MessageUtil.sendMessage(sender, DMessage.ERROR_NAME_IN_USE.getMessage(args[2]));
|
MessageUtil.sendMessage(sender, DMessage.ERROR_NAME_IN_USE.getMessage(args[2]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -213,7 +213,7 @@ public class GroupCommand extends DCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dGroup.addPlayer(player);
|
dGroup.addMember(player);
|
||||||
dGroup.removeInvitedPlayer(player, true);
|
dGroup.removeInvitedPlayer(player, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +229,7 @@ public class GroupCommand extends DCommand {
|
|||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
if (dGroup.getMembers().contains(toKick)) {
|
if (dGroup.getMembers().contains(toKick)) {
|
||||||
dGroup.removePlayer(toKick);
|
dGroup.removeMember(toKick);
|
||||||
MessageUtil.sendMessage(sender, DMessage.GROUP_KICKED_PLAYER.getMessage(sender.getName(), args[2], dGroup.getName()));
|
MessageUtil.sendMessage(sender, DMessage.GROUP_KICKED_PLAYER.getMessage(sender.getName(), args[2], dGroup.getName()));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -83,7 +83,7 @@ public class LeaveCommand extends DCommand {
|
|||||||
if (dPlayer instanceof DInstancePlayer) {
|
if (dPlayer instanceof DInstancePlayer) {
|
||||||
((DInstancePlayer) dPlayer).leave();
|
((DInstancePlayer) dPlayer).leave();
|
||||||
} else {
|
} else {
|
||||||
dGroup.removePlayer(player);
|
dGroup.removeMember(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageUtil.sendMessage(player, DMessage.CMD_LEAVE_SUCCESS.getMessage());
|
MessageUtil.sendMessage(player, DMessage.CMD_LEAVE_SUCCESS.getMessage());
|
||||||
|
@ -68,7 +68,7 @@ public class LivesCommand extends DCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GamePlayer gamePlayer = (GamePlayer) globalPlayer;
|
GamePlayer gamePlayer = (GamePlayer) globalPlayer;
|
||||||
PlayerGroup group = gamePlayer != null ? gamePlayer.getGroup() : plugin.getPlayerGroupCache().get(args[1]);
|
PlayerGroup group = gamePlayer != null ? gamePlayer.getGroup() : plugin.getGroupCache().get(args[1]);
|
||||||
if (gamePlayer != null) {
|
if (gamePlayer != null) {
|
||||||
MessageUtil.sendMessage(sender, DMessage.CMD_LIVES_PLAYER.getMessage(gamePlayer.getName(), gamePlayer.getLives() == -1 ? DMessage.MISC_UNLIMITED.getMessage() : String.valueOf(gamePlayer.getLives())));
|
MessageUtil.sendMessage(sender, DMessage.CMD_LIVES_PLAYER.getMessage(gamePlayer.getName(), gamePlayer.getLives() == -1 ? DMessage.MISC_UNLIMITED.getMessage() : String.valueOf(gamePlayer.getLives())));
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public class PlayCommand extends DCommand {
|
|||||||
DGroupCreateEvent event = new DGroupCreateEvent(group, player, DGroupCreateEvent.Cause.COMMAND);
|
DGroupCreateEvent event = new DGroupCreateEvent(group, player, DGroupCreateEvent.Cause.COMMAND);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
plugin.getPlayerGroupCache().remove(group);
|
plugin.getGroupCache().remove(group);
|
||||||
group = null;
|
group = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ public class GroupSign extends JoinSign {
|
|||||||
update();
|
update();
|
||||||
|
|
||||||
} else if (topSign.getLine(0).equals(DMessage.SIGN_GLOBAL_JOIN_GROUP.getMessage())) {
|
} else if (topSign.getLine(0).equals(DMessage.SIGN_GLOBAL_JOIN_GROUP.getMessage())) {
|
||||||
group.addPlayer(player);
|
group.addMember(player);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ public class LeaveSign extends GlobalProtection {
|
|||||||
} else {
|
} else {
|
||||||
PlayerGroup group = plugin.getPlayerGroup(player);
|
PlayerGroup group = plugin.getPlayerGroup(player);
|
||||||
if (group != null) {
|
if (group != null) {
|
||||||
group.removePlayer(player);
|
group.removeMember(player);
|
||||||
MessageUtil.sendMessage(player, DMessage.PLAYER_LEAVE_GROUP.getMessage());
|
MessageUtil.sendMessage(player, DMessage.PLAYER_LEAVE_GROUP.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -387,7 +387,7 @@ public class DGamePlayer extends DInstancePlayer implements GamePlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (getGroup() != null) {
|
if (getGroup() != null) {
|
||||||
dGroup.removePlayer(getPlayer(), message);
|
dGroup.removeMember(getPlayer(), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game != null && finished && game.hasRewards()) {
|
if (game != null && finished && game.hasRewards()) {
|
||||||
|
@ -97,11 +97,11 @@ public class DGroup implements PlayerGroup {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
dPlayers = plugin.getPlayerCache();
|
dPlayers = plugin.getPlayerCache();
|
||||||
|
|
||||||
plugin.getPlayerGroupCache().add(name, this);
|
plugin.getGroupCache().add(name, this);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
setLeader(player);
|
setLeader(player);
|
||||||
addPlayer(player);
|
addMember(player);
|
||||||
|
|
||||||
playing = false;
|
playing = false;
|
||||||
floorCount = 0;
|
floorCount = 0;
|
||||||
@ -121,7 +121,7 @@ public class DGroup implements PlayerGroup {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
dPlayers = plugin.getPlayerCache();
|
dPlayers = plugin.getPlayerCache();
|
||||||
|
|
||||||
plugin.getPlayerGroupCache().add(name, this);
|
plugin.getGroupCache().add(name, this);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent((DGlobalPlayer) dPlayers.get(captain), true, this);
|
DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent((DGlobalPlayer) dPlayers.get(captain), true, this);
|
||||||
@ -134,7 +134,7 @@ public class DGroup implements PlayerGroup {
|
|||||||
|
|
||||||
for (Player player : players) {
|
for (Player player : players) {
|
||||||
if (!this.players.contains(player)) {
|
if (!this.players.contains(player)) {
|
||||||
addPlayer(player);
|
addMember(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ public class DGroup implements PlayerGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPlayer(Player player, boolean message) {
|
public void addMember(Player player, boolean message) {
|
||||||
DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent((DGlobalPlayer) dPlayers.getGamePlayer(player), false, this);
|
DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent((DGlobalPlayer) dPlayers.getGamePlayer(player), false, this);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
@ -221,12 +221,12 @@ public class DGroup implements PlayerGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removePlayer(Player player) {
|
public void removeMember(Player player) {
|
||||||
removePlayer(player, true);
|
removeMember(player, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removePlayer(Player player, boolean message) {
|
public void removeMember(Player player, boolean message) {
|
||||||
players.remove(player.getUniqueId());
|
players.remove(player.getUniqueId());
|
||||||
plugin.getGlobalProtectionCache().updateGroupSigns(this);
|
plugin.getGlobalProtectionCache().updateGroupSigns(this);
|
||||||
|
|
||||||
@ -649,7 +649,7 @@ public class DGroup implements PlayerGroup {
|
|||||||
public void delete() {
|
public void delete() {
|
||||||
Game game = getGame();
|
Game game = getGame();
|
||||||
|
|
||||||
plugin.getPlayerGroupCache().remove(this);
|
plugin.getGroupCache().remove(this);
|
||||||
|
|
||||||
if (game != null) {
|
if (game != null) {
|
||||||
game.removeGroup(this);
|
game.removeGroup(this);
|
||||||
|
@ -416,7 +416,7 @@ public class DPlayerListener implements Listener {
|
|||||||
|
|
||||||
if (!(dPlayer instanceof InstancePlayer)) {
|
if (!(dPlayer instanceof InstancePlayer)) {
|
||||||
if (dGroup != null) {
|
if (dGroup != null) {
|
||||||
dGroup.removePlayer(player);
|
dGroup.removeMember(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (dPlayer instanceof GamePlayer) {
|
} else if (dPlayer instanceof GamePlayer) {
|
||||||
|
@ -67,7 +67,7 @@ public class PartiesAdapter extends GroupAdapter<Party> implements Listener {
|
|||||||
@Override
|
@Override
|
||||||
public PlayerGroup createDungeonGroup(Party eGroup) {
|
public PlayerGroup createDungeonGroup(Party eGroup) {
|
||||||
PlayerGroup dGroup = dxl.createGroup(Bukkit.getPlayer(eGroup.getLeader()), eGroup.getName());
|
PlayerGroup dGroup = dxl.createGroup(Bukkit.getPlayer(eGroup.getLeader()), eGroup.getName());
|
||||||
eGroup.getMembers().forEach(uuid -> dGroup.addPlayer(Bukkit.getPlayer(uuid), false));
|
eGroup.getMembers().forEach(uuid -> dGroup.addMember(Bukkit.getPlayer(uuid), false));
|
||||||
groups.put(dGroup, new ExternalGroupData<>(eGroup, false));
|
groups.put(dGroup, new ExternalGroupData<>(eGroup, false));
|
||||||
return dGroup;
|
return dGroup;
|
||||||
}
|
}
|
||||||
@ -163,7 +163,7 @@ public class PartiesAdapter extends GroupAdapter<Party> implements Listener {
|
|||||||
if (dGroup != null) {
|
if (dGroup != null) {
|
||||||
dGroup.delete();
|
dGroup.delete();
|
||||||
}
|
}
|
||||||
if (dxl.getPlayerGroupCache().get(event.getNewPartyName()) != null) {
|
if (dxl.getGroupCache().get(event.getNewPartyName()) != null) {
|
||||||
MessageUtil.sendMessage(getPlayer(event.getPartyPlayer()), DMessage.ERROR_NAME_IN_USE.getMessage(event.getNewPartyName()));
|
MessageUtil.sendMessage(getPlayer(event.getPartyPlayer()), DMessage.ERROR_NAME_IN_USE.getMessage(event.getNewPartyName()));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -189,7 +189,7 @@ public class PartiesAdapter extends GroupAdapter<Party> implements Listener {
|
|||||||
Player player = getPlayer(event.getPartyPlayer());
|
Player player = getPlayer(event.getPartyPlayer());
|
||||||
PlayerGroup group = dxl.getPlayerGroup(player);
|
PlayerGroup group = dxl.getPlayerGroup(player);
|
||||||
if (group != null) {
|
if (group != null) {
|
||||||
group.removePlayer(player);
|
group.removeMember(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTask(dxl);
|
}.runTask(dxl);
|
||||||
|
Loading…
Reference in New Issue
Block a user