cleanup: use implicit generic type with diamond operator

This commit is contained in:
P0nk
2021-04-08 07:42:10 +02:00
parent 8aa44711e3
commit 5730b3b42d
35 changed files with 108 additions and 121 deletions

View File

@@ -21,6 +21,13 @@
*/
package client;
import net.server.Server;
import net.server.world.World;
import tools.DatabaseConnection;
import tools.FilePrinter;
import tools.MaplePacketCreator;
import tools.Pair;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -32,13 +39,6 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import net.server.Server;
import net.server.world.World;
import tools.DatabaseConnection;
import tools.FilePrinter;
import tools.MaplePacketCreator;
import tools.Pair;
/**
*
* @author Jay Estrella - Mr.Trash :3
@@ -49,7 +49,7 @@ public class MapleFamily {
private static final AtomicInteger familyIDCounter = new AtomicInteger();
private final int id, world;
private final Map<Integer, MapleFamilyEntry> members = new ConcurrentHashMap<Integer, MapleFamilyEntry>();
private final Map<Integer, MapleFamilyEntry> members = new ConcurrentHashMap<>();
private MapleFamilyEntry leader;
private String name;
private String preceptsMessage = "";
@@ -184,7 +184,7 @@ public class MapleFamily {
public static void loadAllFamilies() {
try(Connection con = DatabaseConnection.getConnection()) {
List<Pair<Pair<Integer, Integer>, MapleFamilyEntry>> unmatchedJuniors = new ArrayList<Pair<Pair<Integer, Integer>, MapleFamilyEntry>>(200); // <<world, seniorid> familyEntry>
List<Pair<Pair<Integer, Integer>, MapleFamilyEntry>> unmatchedJuniors = new ArrayList<>(200); // <<world, seniorid> familyEntry>
try(PreparedStatement psEntries = con.prepareStatement("SELECT * FROM family_character")) {
ResultSet rsEntries = psEntries.executeQuery();
while(rsEntries.next()) { // can be optimized
@@ -236,7 +236,7 @@ public class MapleFamily {
if(senior != null) {
familyEntry.setSenior(family.getEntryByID(seniorid), false);
} else {
if(seniorid > 0) unmatchedJuniors.add(new Pair<Pair<Integer, Integer>, MapleFamilyEntry>(new Pair<Integer, Integer>(world, seniorid), familyEntry));
if(seniorid > 0) unmatchedJuniors.add(new Pair<>(new Pair<>(world, seniorid), familyEntry));
}
familyEntry.setReputation(reputation);
familyEntry.setTodaysRep(todaysRep);

View File

@@ -21,14 +21,11 @@
*/
package client;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import server.quest.MapleQuest;
import tools.StringUtil;
import java.util.*;
/**
*
* @author Matze
@@ -61,8 +58,8 @@ public class MapleQuestStatus {
private short questID;
private Status status;
//private boolean updated; //maybe this can be of use for someone?
private final Map<Integer, String> progress = new LinkedHashMap<Integer, String>();
private final List<Integer> medalProgress = new LinkedList<Integer>();
private final Map<Integer, String> progress = new LinkedHashMap<>();
private final List<Integer> medalProgress = new LinkedList<>();
private int npc;
private long completionTime, expirationTime;
private int forfeited = 0, completed = 0;

View File

@@ -73,7 +73,7 @@ public class IdCommand extends Command {
if (!handbookDirectory.containsKey(type)) {
throw new IdTypeNotSupportedException();
}
itemMap.put(type, new HashMap<String, String>());
itemMap.put(type, new HashMap<>());
BufferedReader reader = new BufferedReader(new FileReader(handbookDirectory.get(type)));
String line;
while ((line = reader.readLine()) != null) {

View File

@@ -135,7 +135,7 @@ public enum ItemFactory {
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
Integer cid = rs.getInt("characterid");
items.add(new Pair<Item, Integer>(loadEquipFromResultSet(rs), cid));
items.add(new Pair<>(loadEquipFromResultSet(rs), cid));
}
}
}
@@ -295,7 +295,7 @@ public enum ItemFactory {
MapleInventoryType mit = MapleInventoryType.getByType(rs.getByte("inventorytype"));
if (mit.equals(MapleInventoryType.EQUIP) || mit.equals(MapleInventoryType.EQUIPPED)) {
items.add(new Pair<Item, MapleInventoryType>(loadEquipFromResultSet(rs), mit));
items.add(new Pair<>(loadEquipFromResultSet(rs), mit));
} else {
if (bundles > 0) {
int petid = rs.getInt("petid");

View File

@@ -36,8 +36,8 @@ import java.util.Map;
*/
public class PetDataFactory {
private static MapleDataProvider dataRoot = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/Item.wz"));
private static Map<String, PetCommand> petCommands = new HashMap<String, PetCommand>();
private static Map<Integer, Integer> petHunger = new HashMap<Integer, Integer>();
private static Map<String, PetCommand> petCommands = new HashMap<>();
private static Map<Integer, Integer> petHunger = new HashMap<>();
public static PetCommand getPetCommand(int petId, int skillId) {
PetCommand ret = petCommands.get(petId + "" + skillId);

View File

@@ -127,7 +127,7 @@ public class DueyProcessor {
}
private static void deletePackageFromInventoryDB(Connection con, int packageId) throws SQLException {
ItemFactory.DUEY.saveItems(new LinkedList<Pair<Item, MapleInventoryType>>(), packageId, con);
ItemFactory.DUEY.saveItems(new LinkedList<>(), packageId, con);
}
private static void removePackageFromDB(int packageId) {