forked from SteamWar/SteamWar
merge upstream
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.sql;
|
||||
|
||||
import de.steamwar.sql.internal.SQLConfig;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.File;
|
||||
@@ -250,6 +251,11 @@ public final class GameModeConfig<M, W> {
|
||||
Times = new TimesConfig(loader.with("Times"));
|
||||
// Arena would be here to be in config order but needs Schematic.Size and EnterStages loaded afterwards
|
||||
Schematic = new SchematicConfig<>(loader.with("Schematic"));
|
||||
for (int i = 0; i < Schematic.Limited.size(); i++) {
|
||||
if (Schematic.Limited.get(i).Materials.isEmpty()) {
|
||||
SQLConfig.impl.getLogger().warning(file.getName() + ": Schematic.Limited[" + i + "] matches no blocks, check its 'Materials' entry");
|
||||
}
|
||||
}
|
||||
GameName = loader.getString("GameName", defaultGameName.apply(file));
|
||||
ActiveMonths = loader.getIntList("ActiveMonths");
|
||||
TeamChatPrefix = loader.getString("TeamChatPrefix", "+");
|
||||
@@ -719,7 +725,10 @@ public final class GameModeConfig<M, W> {
|
||||
public final double MaxDesignBlastResistance;
|
||||
|
||||
/**
|
||||
* List of limited block materials
|
||||
* List of limited block materials<br/>
|
||||
* Every inventory block is counted towards exactly one rule: a filled block towards a rule whose
|
||||
* {@link BlockRule#Content} allows all of its items, an empty block towards a rule without
|
||||
* {@link BlockRule#Content}. Empty inventory blocks without such a rule are unlimited.
|
||||
*
|
||||
* @implSpec {@link SQLWrapper#getInventoryMaterials)} are all disallowed by default to have any content but are unlimited in number.
|
||||
* @implSpec Any Block that has more Blast Resistance than {@link #MaxBlastResistance} will be defaulted to 0.
|
||||
@@ -775,18 +784,13 @@ public final class GameModeConfig<M, W> {
|
||||
}
|
||||
|
||||
public boolean isInventory(M material) {
|
||||
return Limited.stream()
|
||||
.filter(rule -> rule.Materials.contains(material))
|
||||
.anyMatch(rule -> rule.Content.loaded);
|
||||
return SQLWrapper.impl.getInventoryMaterials().contains(material) || Limited.stream().anyMatch(rule -> rule.Content.loaded && rule.Materials.contains(material));
|
||||
}
|
||||
|
||||
public Integer getItemAmount(M material, M item) {
|
||||
public List<BlockRule<M>> getRules(M material) {
|
||||
return Limited.stream()
|
||||
.filter(rule -> rule.Materials.contains(material))
|
||||
.filter(rule -> rule.Content.Items.contains(item))
|
||||
.mapToInt(rule -> rule.Content.Amount)
|
||||
.max()
|
||||
.orElse(0);
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@ToString
|
||||
|
||||
@@ -46,7 +46,7 @@ public interface SQLWrapper<M> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Every inventory material - the {@code all} group usable in {@code GameModeConfig}'s
|
||||
* Every inventory material - the {@code inventory} group usable in {@code GameModeConfig}'s
|
||||
* {@code Limited}. Expected to be a superset of {@link #getStorageMaterials()}.
|
||||
*/
|
||||
default Set<M> getInventoryMaterials() {
|
||||
|
||||
@@ -307,12 +307,12 @@ class SteamwarUser(id: EntityID<Int>) : IntEntity(id) {
|
||||
punishments[punishment] = Punishment.createPunishment(this@SteamwarUser.id.value, from, punishment, reason, time, perma)
|
||||
}
|
||||
|
||||
fun setLocale(locale: Locale?, manualeLocale: Boolean) {
|
||||
fun setLocale(locale: Locale?, manualLocale: Boolean) {
|
||||
if (locale == null || (this.manualLocale && !manualLocale)) return
|
||||
|
||||
useDb {
|
||||
this@SteamwarUser.locale = locale
|
||||
this@SteamwarUser.manualLocale = manualeLocale
|
||||
this@SteamwarUser.manualLocale = manualLocale
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user