Commit ba31e6b0 authored by Nico Eckes's avatar Nico Eckes

Removed editor module, added player tab (WIP), removed ability to create duplicate entries

parent 7d1d0c3f
Pipeline #793 passed with stage
in 4 minutes and 32 seconds
......@@ -25,8 +25,8 @@ configurations {
}
dependencies {
embed group: 'org.yaml', name: 'snakeyaml', version: '1.17'
embed group: 'org.apache.commons', name: 'commons-vfs2-project', version: '2.2'
embed group: 'org.yaml', name: 'snakeyaml', version: '1.17'
embed group: 'org.apache.commons', name: 'commons-vfs2', version: '2.2'
embed group: 'commons-logging', name: 'commons-logging', version: '1.2'
compile 'org.jetbrains:annotations:13.0'
}
......
......@@ -4,7 +4,6 @@ import com.unitedworldminers.BaseIO.util.MessageUtils;
import com.unitedworldminers.BaseIO.util.SimpleCommand;
import com.unitedworldminers.permio.Config;
import com.unitedworldminers.permio.permissions.Permissions;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.server.MinecraftServer;
import org.jetbrains.annotations.NotNull;
......
......@@ -27,7 +27,6 @@ import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.stream.Collectors;
public abstract class ExtendedList<T> extends VBox {
......@@ -77,7 +76,7 @@ public abstract class ExtendedList<T> extends VBox {
String paste = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
if (paste == null) return;
for (T item: provideItem(paste.split("\n"))) {
if (item != null) items.add(item);
if (item != null && !items.contains(item)) items.add(item);
}
} catch (UnsupportedFlavorException | IOException ignored) {
......@@ -94,7 +93,7 @@ public abstract class ExtendedList<T> extends VBox {
public void setSource(ObservableList<T> source) {
items = source;
FilteredList<T> filteredItems = new FilteredList<>(items, t-> true);
list.setItems(filteredItems.sorted(comparator()));
list.setItems(filteredItems.sorted());
searchField.textProperty().addListener(obs -> {
String filter = searchField.getText();
......@@ -117,7 +116,7 @@ public abstract class ExtendedList<T> extends VBox {
addField.setStyle("-fx-text-fill: orange");
new Thread(()-> {
T item = provideItem(text)[0];
if (item == null) {
if (item == null || items.contains(item)) {
Platform.runLater(()->addField.setStyle("-fx-text-fill: red"));
return;
}
......@@ -129,8 +128,6 @@ public abstract class ExtendedList<T> extends VBox {
}
}
abstract Comparator<T> comparator();
abstract T[] provideItem(String... text);
abstract Node provideNode(T item);
......
package com.unitedworldminers.permio.editor.component;
import com.unitedworldminers.permio.editor.util.Utils;
import com.unitedworldminers.permio.editor.data.Group;
import com.unitedworldminers.permio.editor.util.Utils;
import javafx.scene.Node;
import javafx.scene.control.Label;
import java.util.Comparator;
public class GroupsList extends ExtendedList<Group> {
@Override
public void initialize() {
......@@ -15,11 +13,6 @@ public class GroupsList extends ExtendedList<Group> {
addField.setPromptText("New Group...");
}
@Override
Comparator<Group> comparator() {
return Comparator.comparing(g -> g.name);
}
@Override
Group[] provideItem(String... text) {
return Utils.transform(text, Group::new, Group[]::new);
......
......@@ -8,7 +8,6 @@ import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import org.jetbrains.annotations.NotNull;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Random;
import java.util.stream.Stream;
......@@ -40,11 +39,6 @@ public class PermissionList extends ExtendedList<String> {
addField.setPromptText("New Permission...");
}
@Override
Comparator<String> comparator() {
return Comparator.naturalOrder();
}
@Override
String[] provideItem(String... text) {
return text;
......
......@@ -20,14 +20,9 @@ public class PlayerList extends ExtendedList<Player> {
addField.setPromptText("New Player...");
}
@Override
Comparator<Player> comparator() {
return Comparator.comparing(p->p == null ? null : p.identity.uuid);
}
@Override
Player[] provideItem(String... text) {
return Utils.transform(PlayerProfile.query(text), Player::new, Player[]::new);
return Utils.transform(PlayerProfile.query(text), profile -> profile == null ? null : new Player(profile), Player[]::new);
}
@Override
......@@ -36,7 +31,7 @@ public class PlayerList extends ExtendedList<Player> {
}
private static class PlayerLabel extends HBox {
public PlayerLabel(Player player) {
PlayerLabel(Player player) {
Label name = new Label();
name.setPadding(new Insets(0,0,0,3));
name.textProperty().bind(player.identity.name);
......
......@@ -3,13 +3,14 @@ package com.unitedworldminers.permio.editor.data;
import javafx.beans.property.*;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
public class Group {
public class Group implements Comparable<Group> {
private static final String KEY_PREFIX = "prefix";
private static final String KEY_SUFFIX = "suffix";
private static final String KEY_PERMISSIONS = "permissions";
......@@ -55,4 +56,14 @@ public class Group {
result.put(KEY_SUFFIX, suffix.get());
return result;
}
@Override
public boolean equals(Object obj) {
return obj instanceof Group && name.equals(((Group) obj).name);
}
@Override
public int compareTo(@NotNull Group o) {
return name.compareTo(o.name);
}
}
......@@ -6,12 +6,11 @@ import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
public class Player {
public class Player implements Comparable<Player> {
private static final String KEY_PREFIX = "prefix";
private static final String KEY_SUFFIX = "suffix";
private static final String KEY_PERMISSIONS = "permissions";
......@@ -37,7 +36,7 @@ public class Player {
}
public Player(PlayerProfile identity) {
this.identity = identity;
this.identity = Objects.requireNonNull(identity);
}
@Override
......@@ -53,4 +52,14 @@ public class Player {
result.put(KEY_SUFFIX, suffix.get());
return result;
}
@Override
public boolean equals(Object obj) {
return obj instanceof Player && identity.uuid.equals(((Player) obj).identity.uuid);
}
@Override
public int compareTo(@NotNull Player o) {
return identity.uuid.compareTo(o.identity.uuid);
}
}
package com.unitedworldminers.permio.editor.screen;
import com.jcraft.jsch.*;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.layout.VBox;
......@@ -66,7 +65,7 @@ public class SftpDialog {
stage.close();
JSch jsch = new JSch();
/*JSch jsch = new JSch();
Session session = null;
try {
session = jsch.getSession(username.getText(), host.getText(), port.getValue());
......@@ -85,6 +84,6 @@ public class SftpDialog {
e.printStackTrace();
} catch (SftpException e) {
e.printStackTrace();
}
}*/
}
}
......@@ -14,9 +14,7 @@ import java.util.stream.Collectors;
public class Utils {
public static <T1, T2> T2[] transform(@NotNull T1[] array, @NotNull Function<T1, T2> transformer, @NotNull IntFunction<T2[]> generator) {
T2[] result = generator.apply(array.length);
for (int i = 0; i < array.length; i++) {
result[i] = transformer.apply(array[i]);
}
for (int i = 0; i < array.length; i++) result[i] = transformer.apply(array[i]);
return result;
}
......
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.121" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.unitedworldminers.permio.editor.screen.MainScreen">
<MenuBar fx:id="menuBar">
<Menu mnemonicParsing="false" onAction="#menuOpen" text="Load" />
......@@ -10,5 +15,10 @@
<Menu mnemonicParsing="false" onAction="#menuSave" text="Save" />
<Menu mnemonicParsing="false" onAction="#menuReload" text="Reload" />
</MenuBar>
<fx:include fx:id="groupsScreen" source="GroupsScreen.fxml" />
</VBox>
\ No newline at end of file
<TabPane prefHeight="200.0" prefWidth="200.0" side="LEFT" tabClosingPolicy="UNAVAILABLE" VBox.vgrow="SOMETIMES">
<Tab closable="false" text="Groups">
<fx:include VBox.vgrow="ALWAYS" fx:id="groupsScreen" source="GroupsScreen.fxml"/>
</Tab>
<Tab closable="false" text="Players" />
</TabPane>
</VBox>
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