Merge remote-tracking branch 'origin/master'
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Dieser Commit ist enthalten in:
Commit
56e70a4cb2
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.inventory;
|
package de.steamwar.inventory;
|
||||||
|
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
|
import de.steamwar.sql.NodeMember;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import de.steamwar.sql.SchematicType;
|
import de.steamwar.sql.SchematicType;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
@ -52,6 +53,9 @@ public class SchematicSelector {
|
|||||||
@Getter
|
@Getter
|
||||||
private boolean singleDirOpen;
|
private boolean singleDirOpen;
|
||||||
private boolean sdoTrigger = false;
|
private boolean sdoTrigger = false;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private int depth = 0;
|
||||||
private Sorting sorting = Sorting.NAME;
|
private Sorting sorting = Sorting.NAME;
|
||||||
private boolean invertSorting = false;
|
private boolean invertSorting = false;
|
||||||
|
|
||||||
@ -81,12 +85,13 @@ public class SchematicSelector {
|
|||||||
|
|
||||||
if(sdoTrigger) {
|
if(sdoTrigger) {
|
||||||
sdoTrigger = false;
|
sdoTrigger = false;
|
||||||
|
openList(nodes.get(0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SWListInv.SWListEntry<SchematicNode>> list = new ArrayList<>();
|
List<SWListInv.SWListEntry<SchematicNode>> list = new ArrayList<>();
|
||||||
|
|
||||||
if(parent != null) {
|
if(depth != 0) {
|
||||||
list.add(new SWListInv.SWListEntry<>(new SWItem(Material.ARROW, Core.MESSAGE.parse("SCHEM_SELECTOR_BACK", player), clickType -> {}), null));
|
list.add(new SWListInv.SWListEntry<>(new SWItem(Material.ARROW, Core.MESSAGE.parse("SCHEM_SELECTOR_BACK", player), clickType -> {}), null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +142,32 @@ public class SchematicSelector {
|
|||||||
|
|
||||||
private void handleClick(SchematicNode node, SchematicNode parent) {
|
private void handleClick(SchematicNode node, SchematicNode parent) {
|
||||||
if(node == null) {
|
if(node == null) {
|
||||||
|
depth--;
|
||||||
|
if(!singleDirOpen) {
|
||||||
|
if(NodeMember.getNodeMember(parent.getId(), user.getId()) != null) {
|
||||||
|
openList(null);
|
||||||
|
} else {
|
||||||
openList(getParent(parent));
|
openList(getParent(parent));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SchematicNode currentParent = parent;
|
||||||
|
boolean isMember = false;
|
||||||
|
do {
|
||||||
|
sdoTrigger = false;
|
||||||
|
if(NodeMember.getNodeMember(currentParent.getId(), user.getId()) != null) {
|
||||||
|
isMember = true;
|
||||||
|
}
|
||||||
|
currentParent = getParent(currentParent);
|
||||||
|
if(currentParent == null)
|
||||||
|
break;
|
||||||
|
getSchematicList(currentParent);
|
||||||
|
} while (sdoTrigger);
|
||||||
|
if(isMember || NodeMember.getNodeMember(parent.getId(), user.getId()) != null) {
|
||||||
|
openList(null);
|
||||||
|
} else {
|
||||||
|
openList(currentParent);
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(node.isDir()) {
|
if(node.isDir()) {
|
||||||
@ -147,6 +177,7 @@ public class SchematicSelector {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
filter.reset();
|
filter.reset();
|
||||||
|
depth++;
|
||||||
openList(node);
|
openList(node);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -245,7 +276,7 @@ public class SchematicSelector {
|
|||||||
inv.setItem(1, Material.PLAYER_HEAD, Core.MESSAGE.parse("SCHEM_SELECTOR_FILTER_OWNER", player), ownerCallback);
|
inv.setItem(1, Material.PLAYER_HEAD, Core.MESSAGE.parse("SCHEM_SELECTOR_FILTER_OWNER", player), ownerCallback);
|
||||||
} else {
|
} else {
|
||||||
SteamwarUser tUser = SteamwarUser.get(filter.getOwner());
|
SteamwarUser tUser = SteamwarUser.get(filter.getOwner());
|
||||||
SWItem item = SWItem.getPlayerSkull(user.getUserName());
|
SWItem item = SWItem.getPlayerSkull(tUser.getUserName());
|
||||||
item.setName(Core.MESSAGE.parse("SCHEM_SELECTOR_FILTER_OWNER", player));
|
item.setName(Core.MESSAGE.parse("SCHEM_SELECTOR_FILTER_OWNER", player));
|
||||||
item.setEnchanted(true);
|
item.setEnchanted(true);
|
||||||
item.setLore(Collections.singletonList(Core.MESSAGE.parse("SCHEM_SELECTOR_FILTER_OWNER_SEARCH", player, tUser.getUserName())));
|
item.setLore(Collections.singletonList(Core.MESSAGE.parse("SCHEM_SELECTOR_FILTER_OWNER_SEARCH", player, tUser.getUserName())));
|
||||||
@ -261,7 +292,7 @@ public class SchematicSelector {
|
|||||||
} else {
|
} else {
|
||||||
List<SWListInv.SWListEntry<SchematicType>> types = new ArrayList<>();
|
List<SWListInv.SWListEntry<SchematicType>> types = new ArrayList<>();
|
||||||
SchematicType.values().forEach(schematicType -> {
|
SchematicType.values().forEach(schematicType -> {
|
||||||
types.add(new SWListInv.SWListEntry<>(new SWItem(SWItem.getMaterial("STONE_BUTTON"), "§e" + schematicType.name(), Collections.emptyList(), schematicType.fightType(), n -> {}), schematicType));
|
types.add(new SWListInv.SWListEntry<>(new SWItem(schematicType.getMaterial(), "§e" + schematicType.name(), Collections.emptyList(), schematicType.fightType(), n -> {}), schematicType));
|
||||||
});
|
});
|
||||||
SWListInv<SchematicType> listInv = new SWListInv<>(player, Core.MESSAGE.parse("SCHEM_SELECTOR_FILTER_SEL_TYPE", player), types, (clickType1, schematicType) -> {
|
SWListInv<SchematicType> listInv = new SWListInv<>(player, Core.MESSAGE.parse("SCHEM_SELECTOR_FILTER_SEL_TYPE", player), types, (clickType1, schematicType) -> {
|
||||||
filter.setType(schematicType);
|
filter.setType(schematicType);
|
||||||
@ -272,9 +303,9 @@ public class SchematicSelector {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if(filter.getType() == null) {
|
if(filter.getType() == null) {
|
||||||
inv.setItem(2, SWItem.getMaterial("STONE_BUTTON"), Core.MESSAGE.parse("SCHEM_SELECTOR_FILTER_TYPE", player), schemTypeCallback);
|
inv.setItem(2, SchematicType.Normal.getMaterial(), Core.MESSAGE.parse("SCHEM_SELECTOR_FILTER_TYPE", player), schemTypeCallback);
|
||||||
} else {
|
} else {
|
||||||
inv.setItem(2, SWItem.getMaterial("STONE_BUTTON"), Core.MESSAGE.parse("SCHEM_SELECTOR_FILTER_TYPE", player), Collections.singletonList(Core.MESSAGE.parse("SCHEM_SELECTOR_FILTER_TYPE_SEARCH", player, filter.getType().name())), true, schemTypeCallback);
|
inv.setItem(2, filter.getType().getMaterial(), Core.MESSAGE.parse("SCHEM_SELECTOR_FILTER_TYPE", player), Collections.singletonList(Core.MESSAGE.parse("SCHEM_SELECTOR_FILTER_TYPE_SEARCH", player, filter.getType().name())), true, schemTypeCallback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,7 +354,7 @@ public class SchematicSelector {
|
|||||||
nodes.removeIf(node -> !node.isDir());
|
nodes.removeIf(node -> !node.isDir());
|
||||||
}
|
}
|
||||||
if(target.target == Target.SCHEMATIC_TYPE) {
|
if(target.target == Target.SCHEMATIC_TYPE) {
|
||||||
nodes.removeIf(node -> node.isDir() || !node.getType().equals(target.type.toDB()));
|
nodes.removeIf(node -> node.isDir() || !node.getSchemtype().equals(target.type));
|
||||||
}
|
}
|
||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
@ -342,7 +373,12 @@ public class SchematicSelector {
|
|||||||
case SCHEMATIC_TYPE:
|
case SCHEMATIC_TYPE:
|
||||||
nodes.addAll(SchematicNode.getAccessibleSchematicsOfTypeInParent(user.getId(), target.type.toDB(), parent==null?0:parent.getId()));
|
nodes.addAll(SchematicNode.getAccessibleSchematicsOfTypeInParent(user.getId(), target.type.toDB(), parent==null?0:parent.getId()));
|
||||||
if(target.rank >= 0) {
|
if(target.rank >= 0) {
|
||||||
nodes.removeIf(node -> node.getRank() > target.rank);
|
nodes.removeIf(node -> {
|
||||||
|
if(node.isDir()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return node.getRank() > target.rank;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -350,7 +386,6 @@ public class SchematicSelector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(singleDirOpen && nodes.size() == 1 && nodes.get(0).isDir()) {
|
if(singleDirOpen && nodes.size() == 1 && nodes.get(0).isDir()) {
|
||||||
openList(nodes.get(0));
|
|
||||||
sdoTrigger = true;
|
sdoTrigger = true;
|
||||||
}
|
}
|
||||||
return nodes;
|
return nodes;
|
||||||
@ -471,7 +506,7 @@ public class SchematicSelector {
|
|||||||
return o1.getSchemtype().name().compareTo(o2.getSchemtype().name());
|
return o1.getSchemtype().name().compareTo(o2.getSchemtype().name());
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
LAST_UPDATED(Material.CLOCK, "SCHEM_SELECTOR_SORTING_UPDATE", Comparator.comparing(SchematicNode::getLastUpdate));
|
LAST_UPDATED(SWItem.getMaterial("WATCH"), "SCHEM_SELECTOR_SORTING_UPDATE", Comparator.comparing(SchematicNode::getLastUpdate));
|
||||||
|
|
||||||
private final Material mat;
|
private final Material mat;
|
||||||
private final String name;
|
private final String name;
|
||||||
|
@ -23,22 +23,23 @@ import java.io.InputStream;
|
|||||||
import java.sql.Blob;
|
import java.sql.Blob;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class Fight {
|
public class Fight {
|
||||||
private Fight(){}
|
private Fight(){}
|
||||||
|
|
||||||
private static final SQL.Statement create = new SQL.Statement("INSERT INTO Fight (GameMode, Server, Arena, StartTime, Duration, BlueLeader, RedLeader, BlueSchem, RedSchem, Win, WinCondition) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
private static final SQL.Statement create = new SQL.Statement("INSERT INTO Fight (GameMode, Server, StartTime, Duration, BlueLeader, RedLeader, BlueSchem, RedSchem, Win, WinCondition, ReplayLock) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
private static final SQL.Statement lastId = new SQL.Statement("SELECT LAST_INSERT_ID() AS FightID");
|
private static final SQL.Statement lastId = new SQL.Statement("SELECT LAST_INSERT_ID() AS FightID");
|
||||||
private static final SQL.Statement getReplay = new SQL.Statement("SELECT Replay FROM Fight WHERE FightID = ?");
|
private static final SQL.Statement getReplay = new SQL.Statement("SELECT Replay FROM Fight WHERE FightID = ?");
|
||||||
private static final SQL.Statement setReplay = new SQL.Statement("UPDATE Fight SET Replay = ? WHERE FightID = ?");
|
private static final SQL.Statement setReplay = new SQL.Statement("UPDATE Fight SET Replay = ? WHERE FightID = ?");
|
||||||
|
|
||||||
public static int create(String gamemode, String arena, Timestamp starttime, int duration, int blueleader, int redleader, Integer blueschem, Integer redschem, int win, String wincondition){
|
public static int create(String gamemode, String server, Timestamp starttime, int duration, int blueleader, int redleader, Integer blueschem, Integer redschem, int win, String wincondition){
|
||||||
return create(gamemode, arena, null, starttime, duration, blueleader, redleader, blueschem, redschem, win, wincondition);
|
return create(gamemode, server, starttime, duration, blueleader, redleader, blueschem, redschem, win, wincondition, Timestamp.from(Instant.now()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int create(String gamemode, String server, String arena, Timestamp starttime, int duration, int blueleader, int redleader, Integer blueschem, Integer redschem, int win, String wincondition){
|
public static int create(String gamemode, String server, Timestamp starttime, int duration, int blueleader, int redleader, Integer blueschem, Integer redschem, int win, String wincondition, Timestamp replayLock){
|
||||||
create.update(gamemode, server, arena, starttime, duration, blueleader, redleader, blueschem, redschem, win, wincondition);
|
create.update(gamemode, server, starttime, duration, blueleader, redleader, blueschem, redschem, win, wincondition, replayLock);
|
||||||
return lastId.select(rs -> {
|
return lastId.select(rs -> {
|
||||||
rs.next();
|
rs.next();
|
||||||
return rs.getInt("FightID");
|
return rs.getInt("FightID");
|
||||||
|
@ -34,6 +34,7 @@ import java.sql.SQLException;
|
|||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
@ -488,13 +489,14 @@ public class SchematicNode {
|
|||||||
StringBuilder builder = new StringBuilder(getName());
|
StringBuilder builder = new StringBuilder(getName());
|
||||||
SchematicNode currentNode = this;
|
SchematicNode currentNode = this;
|
||||||
if (currentNode.isDir()) builder.append("/");
|
if (currentNode.isDir()) builder.append("/");
|
||||||
while (currentNode.getParentNode() != null) {
|
final Set<NodeMember> nodeMembers = NodeMember.getSchematics(user.getId());
|
||||||
|
AtomicInteger i = new AtomicInteger();
|
||||||
|
i.set(currentNode.getId());
|
||||||
|
while (currentNode.getParentNode() != null && nodeMembers.stream().noneMatch(nodeMember -> nodeMember.getNode() == i.get())) {
|
||||||
currentNode = currentNode.getParentNode();
|
currentNode = currentNode.getParentNode();
|
||||||
|
i.set(currentNode.getId());
|
||||||
builder.insert(0, split)
|
builder.insert(0, split)
|
||||||
.insert(0, currentNode.getName());
|
.insert(0, currentNode.getName());
|
||||||
if (currentNode.getMembers().stream().anyMatch(member -> member.getMember() == user.getId())) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren