mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-03-08 09:27:16 +08:00
refactor: we don't need explicit types here
This commit is contained in:
parent
fcd409320d
commit
b5d0afd0fe
src/main/java/emu/grasscutter
command/commands
data/excels
game
friends
inventory
mail
player
systems
world
scripts
server/packet
utils
@ -25,7 +25,7 @@ public final class SendMailCommand implements CommandHandler {
|
||||
|
||||
// Key = User that is constructing the mail.
|
||||
private static final HashMap<Integer, MailBuilder> mailBeingConstructed =
|
||||
new HashMap<Integer, MailBuilder>();
|
||||
new HashMap<>();
|
||||
|
||||
// Yes this is awful and I hate it.
|
||||
@Override
|
||||
|
@ -46,7 +46,7 @@ public class EquipAffixData extends GameResource {
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
ArrayList<FightPropData> parsed = new ArrayList<FightPropData>(getAddProps().length);
|
||||
ArrayList<FightPropData> parsed = new ArrayList<>(getAddProps().length);
|
||||
for (FightPropData prop : getAddProps()) {
|
||||
if (prop.getPropType() != null && prop.getValue() != 0f) {
|
||||
prop.onLoad();
|
||||
|
@ -56,7 +56,7 @@ public class AvatarTalentData extends GameResource {
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
ArrayList<FightPropData> parsed = new ArrayList<FightPropData>(getAddProps().length);
|
||||
ArrayList<FightPropData> parsed = new ArrayList<>(getAddProps().length);
|
||||
for (FightPropData prop : getAddProps()) {
|
||||
if (prop.getPropType() != null || prop.getValue() == 0f) {
|
||||
prop.onLoad();
|
||||
|
@ -15,8 +15,8 @@ public class FriendsList extends BasePlayerManager {
|
||||
|
||||
public FriendsList(Player player) {
|
||||
super(player);
|
||||
this.friends = new Int2ObjectOpenHashMap<Friendship>();
|
||||
this.pendingFriends = new Int2ObjectOpenHashMap<Friendship>();
|
||||
this.friends = new Int2ObjectOpenHashMap<>();
|
||||
this.pendingFriends = new Int2ObjectOpenHashMap<>();
|
||||
}
|
||||
|
||||
public boolean hasLoaded() {
|
||||
|
@ -7,7 +7,7 @@ public class EquipInventoryTab implements InventoryTab {
|
||||
private final int maxCapacity;
|
||||
|
||||
public EquipInventoryTab(int maxCapacity) {
|
||||
this.items = new HashSet<GameItem>();
|
||||
this.items = new HashSet<>();
|
||||
this.maxCapacity = maxCapacity;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ public final class Mail {
|
||||
public Mail() {
|
||||
this(
|
||||
new MailContent(),
|
||||
new ArrayList<MailItem>(),
|
||||
new ArrayList<>(),
|
||||
(int) Instant.now().getEpochSecond()
|
||||
+ 604800); // TODO: add expire time to send mail command
|
||||
}
|
||||
|
@ -1204,7 +1204,7 @@ public class Player implements PlayerHook, FieldFetch {
|
||||
|
||||
public Map<String, MapMark> getMapMarks() {
|
||||
if (this.mapMarks == null) {
|
||||
this.mapMarks = new HashMap<String, MapMark>();
|
||||
this.mapMarks = new HashMap<>();
|
||||
}
|
||||
return mapMarks;
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ public class InventorySystem extends BaseGameSystem {
|
||||
int moraCost = 0;
|
||||
int expGain = 0;
|
||||
|
||||
List<GameItem> foodRelics = new ArrayList<GameItem>();
|
||||
List<GameItem> foodRelics = new ArrayList<>();
|
||||
for (long guid : foodRelicList) {
|
||||
// Add to delete queue
|
||||
GameItem food = player.getInventory().getItemByGuid(guid);
|
||||
@ -139,7 +139,7 @@ public class InventorySystem extends BaseGameSystem {
|
||||
}
|
||||
foodRelics.add(food);
|
||||
}
|
||||
List<ItemParamData> payList = new ArrayList<ItemParamData>();
|
||||
List<ItemParamData> payList = new ArrayList<>();
|
||||
for (ItemParam itemParam : list) {
|
||||
int amount =
|
||||
itemParam
|
||||
@ -347,7 +347,7 @@ public class InventorySystem extends BaseGameSystem {
|
||||
|
||||
// Get exp gain
|
||||
int expGain = 0, expGainFree = 0;
|
||||
List<GameItem> foodWeapons = new ArrayList<GameItem>();
|
||||
List<GameItem> foodWeapons = new ArrayList<>();
|
||||
for (long guid : foodWeaponGuidList) {
|
||||
GameItem food = player.getInventory().getItemByGuid(guid);
|
||||
if (food == null || !food.isDestroyable()) {
|
||||
@ -359,7 +359,7 @@ public class InventorySystem extends BaseGameSystem {
|
||||
}
|
||||
foodWeapons.add(food);
|
||||
}
|
||||
List<ItemParamData> payList = new ArrayList<ItemParamData>();
|
||||
List<ItemParamData> payList = new ArrayList<>();
|
||||
for (ItemParam param : itemParamList) {
|
||||
int amount =
|
||||
param.getCount(); // Previously this capped to inventory amount, but rejecting the payment
|
||||
|
@ -396,10 +396,10 @@ public class Scene {
|
||||
}
|
||||
|
||||
private static <T> List<List<T>> chopped(List<T> list, final int L) {
|
||||
List<List<T>> parts = new ArrayList<List<T>>();
|
||||
List<List<T>> parts = new ArrayList<>();
|
||||
final int N = list.size();
|
||||
for (int i = 0; i < N; i += L) {
|
||||
parts.add(new ArrayList<T>(list.subList(i, Math.min(N, i + L))));
|
||||
parts.add(new ArrayList<>(list.subList(i, Math.min(N, i + L))));
|
||||
}
|
||||
return parts;
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ public class SceneScriptManager {
|
||||
// If that trigger has been refreshed, ensure it does not get
|
||||
// deregistered anyway when the trigger completes its invocation.
|
||||
for (var triggerSet : currentTriggers.values()) {
|
||||
var toSave = new HashSet<SceneTrigger>(triggerSet);
|
||||
var toSave = new HashSet<>(triggerSet);
|
||||
toSave.retainAll(ongoingTriggers);
|
||||
toSave.forEach(t -> t.setPreserved(true));
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class HandlerBuyGoodsReq extends PacketHandler {
|
||||
}
|
||||
|
||||
List<ItemParamData> costs =
|
||||
new ArrayList<ItemParamData>(sg.getCostItemList()); // Can this even be null?
|
||||
new ArrayList<>(sg.getCostItemList()); // Can this even be null?
|
||||
costs.add(new ItemParamData(202, sg.getScoin()));
|
||||
costs.add(new ItemParamData(201, sg.getHcoin()));
|
||||
costs.add(new ItemParamData(203, sg.getMcoin()));
|
||||
|
@ -15,11 +15,11 @@ public class PacketMailChangeNotify extends BasePacket {
|
||||
public PacketMailChangeNotify(Player player, Mail message) {
|
||||
this(
|
||||
player,
|
||||
new ArrayList<Mail>() {
|
||||
{
|
||||
add(message);
|
||||
}
|
||||
});
|
||||
new ArrayList<>() {
|
||||
{
|
||||
add(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public PacketMailChangeNotify(Player player, List<Mail> mailList) {
|
||||
|
@ -261,22 +261,22 @@ public final class Language {
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Map<TextStrings, TextStrings> canonicalTextStrings = new HashMap<>();
|
||||
return new Int2ObjectOpenHashMap<TextStrings>(
|
||||
nameHashes
|
||||
.intStream()
|
||||
.boxed()
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
key -> key,
|
||||
key -> {
|
||||
TextStrings t =
|
||||
new TextStrings(
|
||||
IntStream.range(0, TextStrings.NUM_LANGUAGES)
|
||||
.mapToObj(i -> languageMaps.get(i).get((int) key))
|
||||
.collect(Collectors.toList()),
|
||||
key);
|
||||
return canonicalTextStrings.computeIfAbsent(t, x -> t);
|
||||
})));
|
||||
return new Int2ObjectOpenHashMap<>(
|
||||
nameHashes
|
||||
.intStream()
|
||||
.boxed()
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
key -> key,
|
||||
key -> {
|
||||
TextStrings t =
|
||||
new TextStrings(
|
||||
IntStream.range(0, TextStrings.NUM_LANGUAGES)
|
||||
.mapToObj(i -> languageMaps.get(i).get((int) key))
|
||||
.collect(Collectors.toList()),
|
||||
key);
|
||||
return canonicalTextStrings.computeIfAbsent(t, x -> t);
|
||||
})));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -4,7 +4,7 @@ import java.util.*;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class WeightedList<E> {
|
||||
private final NavigableMap<Double, E> map = new TreeMap<Double, E>();
|
||||
private final NavigableMap<Double, E> map = new TreeMap<>();
|
||||
private double total = 0;
|
||||
|
||||
public WeightedList() {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user