SteamWar/FightSystem
Archiviert
13
1

RecordSystem (Beta) #199

Manuell gemergt
Lixfel hat 40 Commits von recordSystem nach master 2020-11-01 20:11:45 +01:00 zusammengeführt
3 geänderte Dateien mit 85 neuen und 13 gelöschten Zeilen
Nur Änderungen aus Commit bef28a99b2 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -0,0 +1,31 @@
/*
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.fightsystem.record;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock;
class RecordSystem_15 {
private RecordSystem_15(){}
static int blockToId(Block block){
return net.minecraft.server.v1_15_R1.Block.REGISTRY_ID.getId(((CraftBlock)block).getNMS());
}
}

Datei anzeigen

@ -0,0 +1,31 @@
/*
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.fightsystem.record;
import org.bukkit.block.Block;
class RecordSystem_8 {
private RecordSystem_8(){}
@SuppressWarnings("deprecation")
static int blockToId(Block block){
return block.getTypeId() << 4 + block.getData();
}
}

Datei anzeigen

@ -19,16 +19,15 @@
package de.steamwar.fightsystem.record;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.sql.SteamwarUser;
import net.minecraft.server.v1_15_R1.BlockPosition;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@ -164,22 +163,24 @@ public class RecordSystem {
spawnEntity(e);
}
public static synchronized void blockChange(BlockPosition pos, int blockState){
int shortX = pos.getX() - Config.ArenaMinX;
int shortZ = pos.getZ() - Config.ArenaMinZ;
public static synchronized void blockChange(Block block){
int blockState = blockToId(block);
int shortX = block.getX() - Config.ArenaMinX;
int shortZ = block.getZ() - Config.ArenaMinZ;
if((short)blockState == blockState && shortX > 0 && shortX < 256 && shortZ > 0 && shortZ < 256){
//Short block packet
Recorder.rByte(0x33);
Recorder.rByte(shortX);
Recorder.rByte(pos.getY());
Recorder.rByte(block.getY());
Recorder.rByte(shortZ);
Recorder.rShort((short)blockState);
}else{
//Block packet
Recorder.rByte(0x30);
Recorder.rInt(pos.getX());
Recorder.rByte(pos.getY());
Recorder.rInt(pos.getZ());
Recorder.rInt(block.getX());
Recorder.rByte(block.getY());
Recorder.rInt(block.getZ());
Recorder.rInt(blockState);
}
Recorder.flush();
@ -269,10 +270,6 @@ public class RecordSystem {
Recorder.flush();
}
public static synchronized void blockChange(Block block){
blockChange(((CraftBlock)block).getPosition(), net.minecraft.server.v1_15_R1.Block.REGISTRY_ID.getId(((CraftBlock)block).getNMS()));
}
private static void checkWorldState(){
tick();
@ -290,4 +287,17 @@ public class RecordSystem {
entityMoves(e);
entitySpeed(e);
}
private static int blockToId(Block block){
switch(Core.getVersion()){
case 8:
case 9:
case 10:
case 12:
return RecordSystem_8.blockToId(block);
case 15:
default:
return RecordSystem_15.blockToId(block);
}
}
}