Commit cccfb57b authored by Nico Eckes's avatar Nico Eckes

Fixed unintended adding of new players to active group

parent 14cd1692
Pipeline #796 passed with stage
in 3 minutes and 20 seconds
......@@ -24,9 +24,7 @@ public class PlayerList extends ExtendedList<Player> {
Player[] provideItem(String... text) {
return Utils.transform(PlayerProfile.query(text), profile -> {
if (profile == null) return null; else {
Player p = new Player(profile);
p.group.set(GroupsScreen.activeGroup.get());
return p;
return new Player(profile);
}
}, Player[]::new);
}
......
package com.unitedworldminers.permio.editor.component;
import com.unitedworldminers.permio.editor.data.Group;
import com.unitedworldminers.permio.editor.data.Player;
import com.unitedworldminers.permio.editor.screen.GroupsScreen;
import com.unitedworldminers.permio.editor.screen.MainScreen;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
public class PlayerListForGroup extends PlayerList {
public final ObjectProperty<Group> displayingGroup = new SimpleObjectProperty<>();
public PlayerListForGroup() {
super();
displayingGroup.addListener((observable, oldValue, newValue) -> setSource(MainScreen.players.filtered(p -> newValue != null && newValue.equals(p.group.get()))));
}
@Override
void addItem(Player item) {
item.group.set(GroupsScreen.activeGroup.get());
super.addItem(item);
}
}
......@@ -3,6 +3,7 @@ package com.unitedworldminers.permio.editor.screen;
import com.unitedworldminers.permio.editor.component.GroupsList;
import com.unitedworldminers.permio.editor.component.PermissionList;
import com.unitedworldminers.permio.editor.component.PlayerList;
import com.unitedworldminers.permio.editor.component.PlayerListForGroup;
import com.unitedworldminers.permio.editor.data.Group;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
......@@ -19,7 +20,7 @@ public class GroupsScreen {
@FXML private TextField suffix;
@FXML private GroupsList groupsList;
@FXML private PermissionList permissions;
@FXML private PlayerList players;
@FXML private PlayerListForGroup players;
@FXML private VBox groupMeta;
public static final ObjectProperty<Group> activeGroup = new SimpleObjectProperty<>();
......@@ -50,16 +51,15 @@ public class GroupsScreen {
prefix.textProperty().unbindBidirectional(old.prefix);
suffix.textProperty().unbindBidirectional(old.suffix);
}
players.displayingGroup.set(now);
if (now != null) {
permissions.setSource(now.permissions);
players.setSource(MainScreen.players.filtered(p-> now.equals(p.group.get())));
inheritance.setItems(MainScreen.groups.filtered(g -> !g.isChildOf(now)));
inheritance.valueProperty().bindBidirectional(now.inherits);
prefix.textProperty().bindBidirectional(now.prefix);
suffix.textProperty().bindBidirectional(now.suffix);
} else {
permissions.setSource(FXCollections.observableArrayList());
players.setSource(FXCollections.observableArrayList());
inheritance.getItems().clear();
prefix.clear();
suffix.clear();
......
......@@ -16,7 +16,7 @@ public class PlayerProfileScreen {
@FXML private ImageView image;
public void setProfile(PlayerProfile profile) {
image.setImage(cache.computeIfAbsent("https://crafatar.com/renders/body/" + profile.uuid, Image::new));
image.setImage(cache.computeIfAbsent("https://crafatar.com/renders/body/" + profile.uuid, url -> new Image(url, true)));
name.setText(profile.name.get());
uuid.setText(profile.uuid.toString());
}
......
......@@ -10,6 +10,7 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.layout.HBox?>
<?import com.unitedworldminers.permio.editor.component.PlayerListForGroup?>
<SplitPane dividerPositions="0.3, 0.7" VBox.vgrow="ALWAYS" xmlns="http://javafx.com/javafx/8.0.121" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.unitedworldminers.permio.editor.screen.GroupsScreen">
<VBox>
<GroupsList fx:id="groupsList" VBox.vgrow="ALWAYS">
......@@ -32,5 +33,5 @@
</VBox>
</VBox>
<PermissionList fx:id="permissions" disable="true" />
<PlayerList fx:id="players" disable="true" />
<PlayerListForGroup fx:id="players" disable="true" />
</SplitPane>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment