SteamWar/SpigotCore
Archiviert
13
0

Remove deprecated APIs
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Lixfel 2021-11-01 12:34:21 +01:00
Ursprung be01ffee4e
Commit c9a82832c0
6 geänderte Dateien mit 7 neuen und 195 gelöschten Zeilen

Datei anzeigen

@ -1,51 +0,0 @@
/*
*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 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.core;
import java.util.concurrent.Callable;
public class VersionedCallable<T> {
private Callable<T> callable;
private int minVersion;
public VersionedCallable(Callable<T> callable, int minVersion) {
this.callable = callable;
this.minVersion = minVersion;
}
@Deprecated
public static <T> T call(VersionedCallable<T>... versionedCallables) {
for (int i = versionedCallables.length - 1; i >= 0; i--) {
VersionedCallable<T> versionedCallable = versionedCallables[i];
if (Core.getVersion() >= versionedCallable.minVersion) {
try {
return versionedCallable.callable.call();
} catch (Exception e) {
throw new RuntimeException("Could not run version dependent code", e);
}
}
}
throw new SecurityException();
}
}

Datei anzeigen

@ -1,45 +0,0 @@
/*
*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 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.core;
public class VersionedRunnable {
private Runnable runnable;
private int minVersion;
public VersionedRunnable(Runnable runnable, int minVersion) {
this.runnable = runnable;
this.minVersion = minVersion;
}
@Deprecated
public static void call(VersionedRunnable... versionedRunnables) {
for (int i = versionedRunnables.length - 1; i >= 0; i--) {
VersionedRunnable versionedRunnable = versionedRunnables[i];
if (Core.getVersion() >= versionedRunnable.minVersion) {
versionedRunnable.runnable.run();
return;
}
}
}
}

Datei anzeigen

@ -30,8 +30,8 @@ public class BauweltMember{
private final int bauweltID; private final int bauweltID;
private final int memberID; private final int memberID;
private boolean worldEdit; private final boolean worldEdit;
private boolean world; private final boolean world;
private static final List<BauweltMember> members = new ArrayList<>(); private static final List<BauweltMember> members = new ArrayList<>();
@ -39,36 +39,14 @@ public class BauweltMember{
members.clear(); members.clear();
} }
private BauweltMember(int ownerID, int memberID, boolean worldEdit, boolean world, boolean updateDB){ private BauweltMember(int ownerID, int memberID, boolean worldEdit, boolean world) {
bauweltID = ownerID; bauweltID = ownerID;
this.memberID = memberID; this.memberID = memberID;
this.worldEdit = worldEdit; this.worldEdit = worldEdit;
this.world = world; this.world = world;
if(updateDB)
updateDB();
members.add(this); members.add(this);
} }
public BauweltMember(int ownerID, int memberID, boolean worldEdit, boolean world){
this(ownerID, memberID, worldEdit, world, true);
}
public BauweltMember(UUID ownerID, UUID memberID, boolean worldEdit, boolean world){
this(SteamwarUser.get(ownerID).getId(), SteamwarUser.get(memberID).getId(), worldEdit, world, true);
}
@Deprecated
public void remove(){
SQL.update("DELETE FROM BauweltMember WHERE BauweltID = ? AND MemberID = ?", bauweltID, memberID);
members.remove(this);
}
@Deprecated
private void updateDB(){
SQL.update("INSERT INTO BauweltMember (BauweltID, MemberID, WorldEdit, World) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE WorldEdit = VALUES(WorldEdit), World = VALUES(World)",
bauweltID, memberID, worldEdit, world);
}
public static BauweltMember getBauMember(UUID ownerID, UUID memberID){ public static BauweltMember getBauMember(UUID ownerID, UUID memberID){
return getBauMember(SteamwarUser.get(ownerID).getId(), SteamwarUser.get(memberID).getId()); return getBauMember(SteamwarUser.get(ownerID).getId(), SteamwarUser.get(memberID).getId());
} }
@ -80,7 +58,7 @@ public class BauweltMember{
return getMember.select(rs -> { return getMember.select(rs -> {
if(!rs.next()) if(!rs.next())
return null; return null;
return new BauweltMember(ownerID, memberID, rs.getBoolean("WorldEdit"), rs.getBoolean("World"), false); return new BauweltMember(ownerID, memberID, rs.getBoolean("WorldEdit"), rs.getBoolean("World"));
}, ownerID, memberID); }, ownerID, memberID);
} }
@ -92,7 +70,7 @@ public class BauweltMember{
return getMembers.select(rs -> { return getMembers.select(rs -> {
List<BauweltMember> members = new ArrayList<>(); List<BauweltMember> members = new ArrayList<>();
while(rs.next()) while(rs.next())
members.add(new BauweltMember(bauweltID, rs.getInt("MemberID"), rs.getBoolean("WorldEdit"), rs.getBoolean("World"), false)); members.add(new BauweltMember(bauweltID, rs.getInt("MemberID"), rs.getBoolean("WorldEdit"), rs.getBoolean("World")));
return members; return members;
}, bauweltID); }, bauweltID);
} }
@ -109,19 +87,7 @@ public class BauweltMember{
return worldEdit; return worldEdit;
} }
@Deprecated
public void setWorldEdit(boolean worldEdit) {
this.worldEdit = worldEdit;
updateDB();
}
public boolean isWorld() { public boolean isWorld() {
return world; return world;
} }
@Deprecated
public void setWorld(boolean world) {
this.world = world;
updateDB();
}
} }

Datei anzeigen

@ -36,32 +36,13 @@ public class CheckedSchematic {
private final Timestamp endTime; private final Timestamp endTime;
private final String declineReason; private final String declineReason;
private CheckedSchematic(String schemName, int schemOwner, int validator, Timestamp startTime, Timestamp endTime, String declineReason, boolean insertDB){ private CheckedSchematic(String schemName, int schemOwner, int validator, Timestamp startTime, Timestamp endTime, String declineReason){
this.schemName = schemName; this.schemName = schemName;
this.schemOwner = schemOwner; this.schemOwner = schemOwner;
this.validator = validator; this.validator = validator;
this.startTime = startTime; this.startTime = startTime;
this.endTime = endTime; this.endTime = endTime;
this.declineReason = declineReason; this.declineReason = declineReason;
if(insertDB)
insertDB();
}
@Deprecated
public CheckedSchematic(String schemName, int schemOwner, int validator, Timestamp startTime, Timestamp endTime, String declineReason){
this(schemName, schemOwner, validator, startTime, endTime, declineReason, true);
}
@Deprecated
public CheckedSchematic(String schemName, UUID schemOwner, UUID validator, Timestamp startTime, Timestamp endTime, String declineReason){
this(schemName, SteamwarUser.get(schemOwner).getId(), SteamwarUser.get(validator).getId(), startTime, endTime, declineReason, true);
}
@Deprecated
private void insertDB(){
SQL.update("INSERT INTO CheckedSchematic" +
" (SchemName, SchemOwner, Validator, StartTime, EndTime, DeclineReason) VALUES (?, ?, ?, ?, ?, ?)",
schemName, schemOwner, validator, startTime, endTime, declineReason);
} }
public static List<CheckedSchematic> getLastDeclined(UUID schemOwner){ public static List<CheckedSchematic> getLastDeclined(UUID schemOwner){
@ -72,16 +53,11 @@ public class CheckedSchematic {
return checkHistory.select(rs -> { return checkHistory.select(rs -> {
List<CheckedSchematic> history = new ArrayList<>(); List<CheckedSchematic> history = new ArrayList<>();
while(rs.next()) while(rs.next())
history.add(new CheckedSchematic(rs.getString("SchemName"), schemOwner, rs.getInt("Validator"), rs.getTimestamp("StartTime"), rs.getTimestamp("EndTime"), rs.getString("DeclineReason"), false)); history.add(new CheckedSchematic(rs.getString("SchemName"), schemOwner, rs.getInt("Validator"), rs.getTimestamp("StartTime"), rs.getTimestamp("EndTime"), rs.getString("DeclineReason")));
return history; return history;
}, schemOwner); }, schemOwner);
} }
@Deprecated
public void remove() {
SQL.update("DELETE FROM CheckedSchematic WHERE SchemOwner = ? AND SchemName = ?", schemOwner, schemName);
}
public String getSchemName() { public String getSchemName() {
return schemName; return schemName;
} }

Datei anzeigen

@ -20,8 +20,6 @@
package de.steamwar.sql; package de.steamwar.sql;
import java.io.InputStream; import java.io.InputStream;
import java.sql.Blob;
import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -45,15 +43,6 @@ public class Fight {
}); });
} }
@Deprecated
public static InputStream getReplay(int fightID) {
return getReplay.select(rs -> {
rs.next();
Blob replay = rs.getBlob("Replay");
return replay.getBinaryStream();
}, fightID);
}
public static void getReplay(int fightID, Consumer<InputStream> reader) { public static void getReplay(int fightID, Consumer<InputStream> reader) {
getReplay.select(rs -> { getReplay.select(rs -> {
rs.next(); rs.next();
@ -62,17 +51,6 @@ public class Fight {
}, fightID); }, fightID);
} }
@Deprecated
public static void setReplay(int fightID, byte[] data) {
Blob blob = SQL.blob();
try {
blob.setBytes(1, data);
} catch (SQLException e) {
throw new SecurityException(e);
}
setReplay.update(blob, fightID);
}
public static void setReplay(int fightID, InputStream data) { public static void setReplay(int fightID, InputStream data) {
setReplay.update(data, fightID); setReplay.update(data, fightID);
} }

Datei anzeigen

@ -90,18 +90,6 @@ public class PersonalKit {
}, userID, gamemode); }, userID, gamemode);
} }
@Deprecated
public static boolean nameInUse(int userID, String gamemode, String name) {
ResultSet set = SQL.select("SELECT COUNT(*) AS Count FROM PersonalKit WHERE UserID = ? AND GameMode = ? AND Name = ?", userID, gamemode, name);
try {
if(!set.next())
return true;
return set.getInt("Count") > 0;
} catch (SQLException e) {
throw new SecurityException("Failed loading personal kit", e);
}
}
public ItemStack[] getInventory(){ public ItemStack[] getInventory(){
YamlConfiguration config = YamlConfiguration.loadConfiguration(new StringReader(inventory)); YamlConfiguration config = YamlConfiguration.loadConfiguration(new StringReader(inventory));
return Objects.requireNonNull(config.getList("Inventory")).toArray(new ItemStack[0]); return Objects.requireNonNull(config.getList("Inventory")).toArray(new ItemStack[0]);