Change API method naming to be more consistent

This commit is contained in:
Daniel Saukel 2020-04-01 16:21:14 +02:00
parent 4b222c914b
commit 2574a06b87
17 changed files with 43 additions and 43 deletions

View File

@ -143,7 +143,7 @@ public interface DungeonsAPI extends Plugin {
*
* @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.

View File

@ -245,12 +245,12 @@ public abstract class GroupAdapter<T> {
return;
}
if (dGroup != null) {
dGroup.removePlayer(player, false);
dGroup.removeMember(player, false);
return;
}
dGroup = getDungeonGroup(eGroup);
if (dGroup != null && !dGroup.getMembers().contains(player)) {
dGroup.addPlayer(player);
dGroup.addMember(player);
} else {
dGroup = createDungeonGroup(eGroup);
}

View File

@ -219,12 +219,12 @@ public interface PlayerGroup {
/**
* Adds a player to the group.
* <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
*/
default void addPlayer(Player player) {
addPlayer(player, true);
default void addMember(Player player) {
addMember(player, true);
}
/**
@ -233,17 +233,17 @@ public interface PlayerGroup {
* @param player the player to add
* @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.
* <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
*/
default void removePlayer(Player player) {
addPlayer(player, true);
default void removeMember(Player player) {
addMember(player, true);
}
/**
@ -252,7 +252,7 @@ public interface PlayerGroup {
* @param player the player to add
* @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.

View File

@ -529,7 +529,7 @@ public class DungeonsXL extends DREPlugin implements DungeonsAPI {
}
@Override
public Registry<String, PlayerGroup> getPlayerGroupCache() {
public Registry<String, PlayerGroup> getGroupCache() {
return playerGroupCache;
}

View File

@ -358,13 +358,13 @@ public class Announcer {
}
if (group != null && group.getMembers().contains(player)) {
group.removePlayer(player);
group.removeMember(player);
}
}
if (dGroup != null && pGroup == null) {
if (dGroup.getMembers().size() < maxPlayersPerGroup) {
dGroup.addPlayer(player);
dGroup.addMember(player);
}
} else if (dGroup == null && pGroup == null) {
@ -409,7 +409,7 @@ public class Announcer {
List<String> lore = new ArrayList<>();
DGroup dGroup = dGroups.get(groupCount);
if (!plugin.getPlayerGroupCache().contains(dGroup)) {
if (!plugin.getGroupCache().contains(dGroup)) {
dGroups.set(groupCount, null);
} else if (dGroup != null) {

View File

@ -48,8 +48,8 @@ public class EnterCommand extends DCommand {
Player captain = (Player) sender;
String targetName = args.length == 3 ? args[2] : args[1];
PlayerGroup joining = args.length == 3 ? plugin.getPlayerGroupCache().get(args[1]) : plugin.getPlayerGroup(captain);
PlayerGroup target = plugin.getPlayerGroupCache().get(targetName);
PlayerGroup joining = args.length == 3 ? plugin.getGroupCache().get(args[1]) : plugin.getPlayerGroup(captain);
PlayerGroup target = plugin.getGroupCache().get(targetName);
if (target == null) {
Player targetPlayer = Bukkit.getPlayer(targetName);

View File

@ -64,7 +64,7 @@ public class EscapeCommand extends DCommand {
} else {
PlayerGroup dGroup = plugin.getPlayerGroup(player);
if (dGroup != null) {
dGroup.removePlayer(player);
dGroup.removeMember(player);
MessageUtil.sendMessage(player, DMessage.CMD_LEAVE_SUCCESS.getMessage());
return;
}

View File

@ -90,15 +90,15 @@ public class GroupCommand extends DCommand {
return;
} 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;
} else if (args[1].equalsIgnoreCase("join")) {
joinGroup((DGroup) plugin.getPlayerGroupCache().get(args[2]));
joinGroup((DGroup) plugin.getGroupCache().get(args[2]));
return;
} 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]);
if (group == null && player != null) {
group = (DGroup) plugin.getPlayerGroup(player);
@ -117,7 +117,7 @@ public class GroupCommand extends DCommand {
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]));
return;
}
@ -213,7 +213,7 @@ public class GroupCommand extends DCommand {
return;
}
dGroup.addPlayer(player);
dGroup.addMember(player);
dGroup.removeInvitedPlayer(player, true);
}
@ -229,7 +229,7 @@ public class GroupCommand extends DCommand {
if (!event.isCancelled()) {
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()));
} else {

View File

@ -83,7 +83,7 @@ public class LeaveCommand extends DCommand {
if (dPlayer instanceof DInstancePlayer) {
((DInstancePlayer) dPlayer).leave();
} else {
dGroup.removePlayer(player);
dGroup.removeMember(player);
}
MessageUtil.sendMessage(player, DMessage.CMD_LEAVE_SUCCESS.getMessage());

View File

@ -68,7 +68,7 @@ public class LivesCommand extends DCommand {
}
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) {
MessageUtil.sendMessage(sender, DMessage.CMD_LIVES_PLAYER.getMessage(gamePlayer.getName(), gamePlayer.getLives() == -1 ? DMessage.MISC_UNLIMITED.getMessage() : String.valueOf(gamePlayer.getLives())));

View File

@ -72,7 +72,7 @@ public class PlayCommand extends DCommand {
DGroupCreateEvent event = new DGroupCreateEvent(group, player, DGroupCreateEvent.Cause.COMMAND);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
plugin.getPlayerGroupCache().remove(group);
plugin.getGroupCache().remove(group);
group = null;
}
}

View File

@ -159,7 +159,7 @@ public class GroupSign extends JoinSign {
update();
} else if (topSign.getLine(0).equals(DMessage.SIGN_GLOBAL_JOIN_GROUP.getMessage())) {
group.addPlayer(player);
group.addMember(player);
update();
}
}

View File

@ -99,7 +99,7 @@ public class LeaveSign extends GlobalProtection {
} else {
PlayerGroup group = plugin.getPlayerGroup(player);
if (group != null) {
group.removePlayer(player);
group.removeMember(player);
MessageUtil.sendMessage(player, DMessage.PLAYER_LEAVE_GROUP.getMessage());
}
}

View File

@ -387,7 +387,7 @@ public class DGamePlayer extends DInstancePlayer implements GamePlayer {
}
if (getGroup() != null) {
dGroup.removePlayer(getPlayer(), message);
dGroup.removeMember(getPlayer(), message);
}
if (game != null && finished && game.hasRewards()) {

View File

@ -97,11 +97,11 @@ public class DGroup implements PlayerGroup {
this.plugin = plugin;
dPlayers = plugin.getPlayerCache();
plugin.getPlayerGroupCache().add(name, this);
plugin.getGroupCache().add(name, this);
this.name = name;
setLeader(player);
addPlayer(player);
addMember(player);
playing = false;
floorCount = 0;
@ -121,7 +121,7 @@ public class DGroup implements PlayerGroup {
this.plugin = plugin;
dPlayers = plugin.getPlayerCache();
plugin.getPlayerGroupCache().add(name, this);
plugin.getGroupCache().add(name, this);
this.name = name;
DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent((DGlobalPlayer) dPlayers.get(captain), true, this);
@ -134,7 +134,7 @@ public class DGroup implements PlayerGroup {
for (Player player : players) {
if (!this.players.contains(player)) {
addPlayer(player);
addMember(player);
}
}
@ -204,7 +204,7 @@ public class DGroup implements PlayerGroup {
}
@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);
Bukkit.getPluginManager().callEvent(event);
@ -221,12 +221,12 @@ public class DGroup implements PlayerGroup {
}
@Override
public void removePlayer(Player player) {
removePlayer(player, true);
public void removeMember(Player player) {
removeMember(player, true);
}
@Override
public void removePlayer(Player player, boolean message) {
public void removeMember(Player player, boolean message) {
players.remove(player.getUniqueId());
plugin.getGlobalProtectionCache().updateGroupSigns(this);
@ -649,7 +649,7 @@ public class DGroup implements PlayerGroup {
public void delete() {
Game game = getGame();
plugin.getPlayerGroupCache().remove(this);
plugin.getGroupCache().remove(this);
if (game != null) {
game.removeGroup(this);

View File

@ -416,7 +416,7 @@ public class DPlayerListener implements Listener {
if (!(dPlayer instanceof InstancePlayer)) {
if (dGroup != null) {
dGroup.removePlayer(player);
dGroup.removeMember(player);
}
} else if (dPlayer instanceof GamePlayer) {

View File

@ -67,7 +67,7 @@ public class PartiesAdapter extends GroupAdapter<Party> implements Listener {
@Override
public PlayerGroup createDungeonGroup(Party eGroup) {
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));
return dGroup;
}
@ -163,7 +163,7 @@ public class PartiesAdapter extends GroupAdapter<Party> implements Listener {
if (dGroup != null) {
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()));
event.setCancelled(true);
return;
@ -189,7 +189,7 @@ public class PartiesAdapter extends GroupAdapter<Party> implements Listener {
Player player = getPlayer(event.getPartyPlayer());
PlayerGroup group = dxl.getPlayerGroup(player);
if (group != null) {
group.removePlayer(player);
group.removeMember(player);
}
}
}.runTask(dxl);