Dieser Commit ist enthalten in:
Ursprung
42c95f0ee8
Commit
55e4419d1b
@ -35,4 +35,5 @@ public class PacketIdManager {
|
|||||||
//0x2(X) Server Information System
|
//0x2(X) Server Information System
|
||||||
public static final byte I_AM_A_LOBBY = 0x20;
|
public static final byte I_AM_A_LOBBY = 0x20;
|
||||||
public static final byte FIGHT_INFO = 0x21;
|
public static final byte FIGHT_INFO = 0x21;
|
||||||
|
public static final byte FIGHT_ENDS = 0x22;
|
||||||
}
|
}
|
||||||
|
73
SpigotCore_Main/src/de/steamwar/comms/packets/FightEndsPacket.java
Normale Datei
73
SpigotCore_Main/src/de/steamwar/comms/packets/FightEndsPacket.java
Normale Datei
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* 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.comms.packets;
|
||||||
|
|
||||||
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
|
import de.steamwar.comms.PacketIdManager;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
public class FightEndsPacket extends SpigotPacket {
|
||||||
|
|
||||||
|
private byte win;
|
||||||
|
private int blueSchem;
|
||||||
|
private int redSchem;
|
||||||
|
private List<Integer> bluePlayers;
|
||||||
|
private List<Integer> redPlayers;
|
||||||
|
|
||||||
|
public FightEndsPacket(ByteArrayDataInput byteArrayDataInput) {
|
||||||
|
win = byteArrayDataInput.readByte();
|
||||||
|
blueSchem = byteArrayDataInput.readInt();
|
||||||
|
redSchem = byteArrayDataInput.readInt();
|
||||||
|
int blueSize = byteArrayDataInput.readInt();
|
||||||
|
for (int i = 0; i < blueSize; i++) {
|
||||||
|
bluePlayers.add(byteArrayDataInput.readInt());
|
||||||
|
}
|
||||||
|
int redSize = byteArrayDataInput.readInt();
|
||||||
|
for (int i = 0; i < redSize; i++) {
|
||||||
|
redPlayers.add(byteArrayDataInput.readInt());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getName() {
|
||||||
|
return PacketIdManager.FIGHT_ENDS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeVars(ByteArrayDataOutput byteArrayDataOutput) {
|
||||||
|
byteArrayDataOutput.writeByte(win);
|
||||||
|
byteArrayDataOutput.writeInt(blueSchem);
|
||||||
|
byteArrayDataOutput.writeInt(redSchem);
|
||||||
|
byteArrayDataOutput.writeInt(bluePlayers.size());
|
||||||
|
for (int i : bluePlayers) {
|
||||||
|
byteArrayDataOutput.writeInt(i);
|
||||||
|
}
|
||||||
|
byteArrayDataOutput.writeInt(redPlayers.size());
|
||||||
|
for (int i : redPlayers) {
|
||||||
|
byteArrayDataOutput.writeInt(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,32 +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.sql;
|
|
||||||
|
|
||||||
public class Elo {
|
|
||||||
private Elo(){}
|
|
||||||
|
|
||||||
public static int getElo(int userId, String gameMode){
|
|
||||||
return Provider.impl.getElo(userId, gameMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setElo(int userId, String gameMode, int elo){
|
|
||||||
Provider.impl.setElo(userId, gameMode, elo);
|
|
||||||
}
|
|
||||||
}
|
|
@ -39,9 +39,6 @@ public interface Provider {
|
|||||||
List<CheckedSchematic> getLastDeclinedOfNode(int node);
|
List<CheckedSchematic> getLastDeclinedOfNode(int node);
|
||||||
List<CheckedSchematic> getLastDelined(int schemOwner);
|
List<CheckedSchematic> getLastDelined(int schemOwner);
|
||||||
|
|
||||||
int getElo(int userId, String gameMode);
|
|
||||||
void setElo(int userId, String gameMode, int elo);
|
|
||||||
|
|
||||||
Event getEvent(int eventID);
|
Event getEvent(int eventID);
|
||||||
EventFight getEventFight(int fightID);
|
EventFight getEventFight(int fightID);
|
||||||
void setEventFightResult(EventFight fight, int winner);
|
void setEventFightResult(EventFight fight, int winner);
|
||||||
|
@ -84,22 +84,6 @@ public class SQLProvider implements Provider {
|
|||||||
return (calendar.get(Calendar.YEAR) * 3 + yearIndex);
|
return (calendar.get(Calendar.YEAR) * 3 + yearIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Statement getElo = new Statement("SELECT Elo FROM Elo WHERE UserID = ? AND GameMode = ? AND Season = ?");
|
|
||||||
@Override
|
|
||||||
public int getElo(int userId, String gameMode) {
|
|
||||||
return getElo.select(rs -> {
|
|
||||||
if(rs.next())
|
|
||||||
return rs.getInt("Elo");
|
|
||||||
return 1000;
|
|
||||||
}, userId, gameMode, getCurrentSeason());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Statement setElo = new Statement("UPDATE Elo SET Elo = ? WHERE Season = ? AND UserID = ? AND GameMode = ?");
|
|
||||||
@Override
|
|
||||||
public void setElo(int userId, String gameMode, int elo) {
|
|
||||||
setElo.update(elo, getCurrentSeason(), userId, gameMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Statement getEvent = new Statement("SELECT * FROM Event WHERE EventID = ?");
|
private static final Statement getEvent = new Statement("SELECT * FROM Event WHERE EventID = ?");
|
||||||
@Override
|
@Override
|
||||||
public Event getEvent(int eventID) {
|
public Event getEvent(int eventID) {
|
||||||
|
@ -64,14 +64,6 @@ public class StandaloneProvider implements Provider {
|
|||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getElo(int userId, String gameMode) {
|
|
||||||
return 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setElo(int userId, String gameMode, int elo) {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Event getEvent(int eventID) {
|
public Event getEvent(int eventID) {
|
||||||
return new Event(eventID, "DummyEvent", Timestamp.from(Instant.now()), Timestamp.from(Instant.now()), 6, false, false);
|
return new Event(eventID, "DummyEvent", Timestamp.from(Instant.now()), Timestamp.from(Instant.now()), 6, false, false);
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren