Fix tests. Added coops and trusted to team GUI view.
This commit is contained in:
parent
3907cba08f
commit
0c4a4ba862
|
@ -289,8 +289,8 @@ public class IslandTeamGUI {
|
||||||
if (island == null) {
|
if (island == null) {
|
||||||
return this.getBlankBackground();
|
return this.getBlankBackground();
|
||||||
}
|
}
|
||||||
|
int minimumRank = RanksManager.getInstance().getRankUpValue(RanksManager.VISITOR_RANK); // Get the rank above Visitor.
|
||||||
Optional<User> opMember = island.getMemberSet().stream().map(User::getInstance)
|
Optional<User> opMember = island.getMemberSet(minimumRank).stream().map(User::getInstance)
|
||||||
.filter((User usr) -> rankView == RanksManager.OWNER_RANK || island.getRank(usr) == rankView) // If rankView is owner then show all ranks
|
.filter((User usr) -> rankView == RanksManager.OWNER_RANK || island.getRank(usr) == rankView) // If rankView is owner then show all ranks
|
||||||
.sorted(Comparator.comparingInt((User usr) -> island.getRank(usr)).reversed()) // Show owner on left, then descending ranks
|
.sorted(Comparator.comparingInt((User usr) -> island.getRank(usr)).reversed()) // Show owner on left, then descending ranks
|
||||||
.skip(slot.slot()) // Get the head for this slot
|
.skip(slot.slot()) // Get the head for this slot
|
||||||
|
|
|
@ -118,7 +118,8 @@ public class IslandTeamInviteGUI {
|
||||||
|
|
||||||
private PanelItem createNextButton(ItemTemplateRecord template, TemplatedPanel.ItemSlot slot) {
|
private PanelItem createNextButton(ItemTemplateRecord template, TemplatedPanel.ItemSlot slot) {
|
||||||
checkTemplate(template);
|
checkTemplate(template);
|
||||||
long count = itic.getWorld().getPlayers().stream().filter(player -> user.getPlayer().canSee(player))
|
System.out.println(itc);
|
||||||
|
long count = itc.getWorld().getPlayers().stream().filter(player -> user.getPlayer().canSee(player))
|
||||||
.filter(player -> !player.equals(user.getPlayer())).count();
|
.filter(player -> !player.equals(user.getPlayer())).count();
|
||||||
if (count > page * PER_PAGE) {
|
if (count > page * PER_PAGE) {
|
||||||
// We need to show a next button
|
// We need to show a next button
|
||||||
|
@ -172,14 +173,14 @@ public class IslandTeamInviteGUI {
|
||||||
*/
|
*/
|
||||||
private PanelItem createProspectButton(ItemTemplateRecord template, TemplatedPanel.ItemSlot slot) {
|
private PanelItem createProspectButton(ItemTemplateRecord template, TemplatedPanel.ItemSlot slot) {
|
||||||
// Player issuing the command must have an island
|
// Player issuing the command must have an island
|
||||||
Island island = plugin.getIslands().getPrimaryIsland(itic.getWorld(), user.getUniqueId());
|
Island island = plugin.getIslands().getPrimaryIsland(itc.getWorld(), user.getUniqueId());
|
||||||
if (island == null) {
|
if (island == null) {
|
||||||
return this.getBlankBackground();
|
return this.getBlankBackground();
|
||||||
}
|
}
|
||||||
if (page < 0) {
|
if (page < 0) {
|
||||||
page = 0;
|
page = 0;
|
||||||
}
|
}
|
||||||
return itic.getWorld().getPlayers().stream().filter(player -> user.getPlayer().canSee(player))
|
return itc.getWorld().getPlayers().stream().filter(player -> user.getPlayer().canSee(player))
|
||||||
.filter(player -> this.searchName.isBlank() ? true
|
.filter(player -> this.searchName.isBlank() ? true
|
||||||
: player.getName().toLowerCase().contains(searchName.toLowerCase()))
|
: player.getName().toLowerCase().contains(searchName.toLowerCase()))
|
||||||
.filter(player -> !player.equals(user.getPlayer())).skip(slot.slot() + page * PER_PAGE).findFirst()
|
.filter(player -> !player.equals(user.getPlayer())).skip(slot.slot() + page * PER_PAGE).findFirst()
|
||||||
|
@ -213,33 +214,33 @@ public class IslandTeamInviteGUI {
|
||||||
user.closeInventory();
|
user.closeInventory();
|
||||||
if (itic.canExecute(user, itic.getLabel(), List.of(player.getName()))) {
|
if (itic.canExecute(user, itic.getLabel(), List.of(player.getName()))) {
|
||||||
plugin.log("Invite sent to: " + player.getName() + " by " + user.getName() + " to join island in "
|
plugin.log("Invite sent to: " + player.getName() + " by " + user.getName() + " to join island in "
|
||||||
+ itic.getWorld().getName());
|
+ itc.getWorld().getName());
|
||||||
itic.execute(user, itic.getLabel(), List.of(player.getName()));
|
itic.execute(user, itic.getLabel(), List.of(player.getName()));
|
||||||
} else {
|
} else {
|
||||||
plugin.log("Invite failed: " + player.getName() + " by " + user.getName() + " to join island in "
|
plugin.log("Invite failed: " + player.getName() + " by " + user.getName() + " to join island in "
|
||||||
+ itic.getWorld().getName());
|
+ itc.getWorld().getName());
|
||||||
}
|
}
|
||||||
} else if (clickType.equals(ClickType.RIGHT)) {
|
} else if (clickType.equals(ClickType.RIGHT)) {
|
||||||
user.closeInventory();
|
user.closeInventory();
|
||||||
if (this.itc.getCoopCommand().canExecute(user, itic.getLabel(), List.of(player.getName()))) {
|
if (this.itc.getCoopCommand().canExecute(user, itic.getLabel(), List.of(player.getName()))) {
|
||||||
plugin.log("Coop: " + player.getName() + " cooped " + user.getName() + " to island in "
|
plugin.log("Coop: " + player.getName() + " cooped " + user.getName() + " to island in "
|
||||||
+ itic.getWorld().getName());
|
+ itc.getWorld().getName());
|
||||||
this.itc.getCoopCommand().execute(user, itic.getLabel(), List.of(player.getName()));
|
this.itc.getCoopCommand().execute(user, itic.getLabel(), List.of(player.getName()));
|
||||||
} else {
|
} else {
|
||||||
plugin.log(
|
plugin.log(
|
||||||
"Coop failed: " + player.getName() + "'s coop to " + user.getName() + " failed for island in "
|
"Coop failed: " + player.getName() + "'s coop to " + user.getName() + " failed for island in "
|
||||||
+ itic.getWorld().getName());
|
+ itc.getWorld().getName());
|
||||||
}
|
}
|
||||||
} else if (clickType.equals(ClickType.SHIFT_LEFT)) {
|
} else if (clickType.equals(ClickType.SHIFT_LEFT)) {
|
||||||
user.closeInventory();
|
user.closeInventory();
|
||||||
if (this.itc.getTrustCommand().canExecute(user, itic.getLabel(), List.of(player.getName()))) {
|
if (this.itc.getTrustCommand().canExecute(user, itic.getLabel(), List.of(player.getName()))) {
|
||||||
plugin.log("Trust: " + player.getName() + " trusted " + user.getName() + " to island in "
|
plugin.log("Trust: " + player.getName() + " trusted " + user.getName() + " to island in "
|
||||||
+ itic.getWorld().getName());
|
+ itc.getWorld().getName());
|
||||||
this.itc.getTrustCommand().execute(user, itic.getLabel(), List.of(player.getName()));
|
this.itc.getTrustCommand().execute(user, itic.getLabel(), List.of(player.getName()));
|
||||||
} else {
|
} else {
|
||||||
plugin.log("Trust failed: " + player.getName() + "'s trust failed for " + user.getName()
|
plugin.log("Trust failed: " + player.getName() + "'s trust failed for " + user.getName()
|
||||||
+ " for island in "
|
+ " for island in "
|
||||||
+ itic.getWorld().getName());
|
+ itc.getWorld().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -132,6 +132,7 @@ public class IslandTeamInviteCommandTest extends RanksManagerBeforeClassTest {
|
||||||
// Parent command has no aliases
|
// Parent command has no aliases
|
||||||
when(ic.getSubCommandAliases()).thenReturn(new HashMap<>());
|
when(ic.getSubCommandAliases()).thenReturn(new HashMap<>());
|
||||||
when(ic.getWorld()).thenReturn(world);
|
when(ic.getWorld()).thenReturn(world);
|
||||||
|
when(ic.getPlugin()).thenReturn(plugin);
|
||||||
|
|
||||||
// Island
|
// Island
|
||||||
islandUUID = UUID.randomUUID();
|
islandUUID = UUID.randomUUID();
|
||||||
|
|
Loading…
Reference in New Issue