forked from SteamWar/SteamWar
merge upstream
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2026 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package de.steamwar.network.packets.server;
|
||||
|
||||
import de.steamwar.network.packets.NetworkPacket;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* A chat message written on an arena. The arena only records it for the replay and never displays it.
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Getter
|
||||
public class ChatRecordPacket extends NetworkPacket {
|
||||
private static final long serialVersionUID = -4718360932583127458L;
|
||||
private int playerId;
|
||||
private String message;
|
||||
}
|
||||
@@ -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