SteamWar/SpigotCore
Archiviert
13
0

Remove deprecated APIs #125

Zusammengeführt
Lixfel hat 7 Commits von removeDeprecated nach master 2022-02-01 11:24:52 +01:00 zusammengeführt
6 geänderte Dateien mit 7 neuen und 195 gelöschten Zeilen
Nur Änderungen aus Commit c9a82832c0 werden angezeigt - Alle Commits anzeigen

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 memberID;
private boolean worldEdit;
private boolean world;
private final boolean worldEdit;
private final boolean world;
private static final List<BauweltMember> members = new ArrayList<>();
@ -39,36 +39,14 @@ public class BauweltMember{
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;
this.memberID = memberID;
this.worldEdit = worldEdit;
this.world = world;
if(updateDB)
updateDB();
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){
return getBauMember(SteamwarUser.get(ownerID).getId(), SteamwarUser.get(memberID).getId());
}
@ -80,7 +58,7 @@ public class BauweltMember{
return getMember.select(rs -> {
if(!rs.next())
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);
}
@ -92,7 +70,7 @@ public class BauweltMember{
return getMembers.select(rs -> {
List<BauweltMember> members = new ArrayList<>();
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;
}, bauweltID);
}
@ -109,19 +87,7 @@ public class BauweltMember{
return worldEdit;
}
@Deprecated
public void setWorldEdit(boolean worldEdit) {
this.worldEdit = worldEdit;
updateDB();
}
public boolean isWorld() {
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 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.schemOwner = schemOwner;
this.validator = validator;
this.startTime = startTime;
this.endTime = endTime;
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){
@ -72,16 +53,11 @@ public class CheckedSchematic {
return checkHistory.select(rs -> {
List<CheckedSchematic> history = new ArrayList<>();
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;
}, schemOwner);
}
@Deprecated
public void remove() {
SQL.update("DELETE FROM CheckedSchematic WHERE SchemOwner = ? AND SchemName = ?", schemOwner, schemName);
}
public String getSchemName() {
return schemName;
}

Datei anzeigen

@ -20,8 +20,6 @@
package de.steamwar.sql;
import java.io.InputStream;
import java.sql.Blob;
import java.sql.SQLException;
import java.sql.Timestamp;
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) {
getReplay.select(rs -> {
rs.next();
@ -62,17 +51,6 @@ public class Fight {
}, 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) {
setReplay.update(data, fightID);
}

Datei anzeigen

@ -90,18 +90,6 @@ public class PersonalKit {
}, 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(){
YamlConfiguration config = YamlConfiguration.loadConfiguration(new StringReader(inventory));
return Objects.requireNonNull(config.getList("Inventory")).toArray(new ItemStack[0]);