SteamWar/BauSystem2.0
Archiviert
12
0

Started Trace Refactoring

Laid out basic class structure
Dieser Commit ist enthalten in:
D4rkr34lm 2023-11-06 00:11:03 +01:00
Ursprung 5de070c90e
Commit 27a542590c
6 geänderte Dateien mit 227 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bausystem;
import com.comphenix.tinyprotocol.TinyProtocol; import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.bausystem.configplayer.Config; import de.steamwar.bausystem.configplayer.Config;
import de.steamwar.bausystem.features.tpslimit.TPSFreezeUtils; import de.steamwar.bausystem.features.tpslimit.TPSFreezeUtils;
import de.steamwar.bausystem.features.tracer2.TraceManager;
import de.steamwar.bausystem.features.world.RamUsage; import de.steamwar.bausystem.features.world.RamUsage;
import de.steamwar.bausystem.linkage.LinkageUtils; import de.steamwar.bausystem.linkage.LinkageUtils;
import de.steamwar.bausystem.region.loader.PrototypeLoader; import de.steamwar.bausystem.region.loader.PrototypeLoader;
@ -50,6 +51,11 @@ public class BauSystem extends JavaPlugin implements Listener {
// This should be treated as final! // This should be treated as final!
public static Message MESSAGE; public static Message MESSAGE;
/*
* Plugin wide availeble data
*/
public static final TraceManager TRACES = new TraceManager();
@Getter @Getter
private static BauSystem instance; private static BauSystem instance;

Datei anzeigen

@ -0,0 +1,84 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 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.bausystem.features.tracer2;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.Region;
import de.steamwar.linkage.Linked;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.TNTPrimeEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@Linked
public class Recorder {
private final Map<Region, Trace> activeTraces = new HashMap<>();
private final Map<Region, Set<TNTPrimed>> trackedTNT = new HashMap<>();
/** Starts a recording at the given region
*
* @param region region to be recorded
*/
public void startRecording(Region region){
Trace trace = new Trace(region);
activeTraces.put(region, trace);
BauSystem.TRACES.add(trace);
}
/** Stops the recording at the given region
*
* @param region region to stop recording
*/
public void stopRecording(Region region){
activeTraces.remove(region);
}
/** Internal methode to record all tracked TNT Entities
*
*/
private void record(){
}
/** Eventhandler for TNTs beeing spawn.
* Registers newly spawn to be traced if reqired
* @param event
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onTNTPrimed(EntitySpawnEvent event){
}
/** Event for TNTs exploding
* Unregisters TNTs from beeing traced on explode
* @param event
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onTNTExplode(EntityExplodeEvent event){
}
}

Datei anzeigen

@ -0,0 +1,23 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 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.bausystem.features.tracer2;
public class TNTRecord {
}

Datei anzeigen

@ -0,0 +1,35 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 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.bausystem.features.tracer2;
import de.steamwar.bausystem.region.Region;
import java.util.HashSet;
import java.util.Set;
public class Trace {
private final Region region;
private final Set<TNTRecord> records = new HashSet<>();
public Trace (Region region){
this.region = region;
}
}

Datei anzeigen

@ -0,0 +1,23 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 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.bausystem.features.tracer2;
public class TraceCommand {
}

Datei anzeigen

@ -0,0 +1,56 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 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.bausystem.features.tracer2;
import java.util.HashMap;
import java.util.Map;
public class TraceManager {
private final Map<Integer, Trace> traces = new HashMap<>();
private int currOpenId = 0;
/** Adds a new trace to the global record
*
* @param trace Trace to be added
* @return id of the newly added trace
*/
public int add(Trace trace){
int id = currOpenId;
traces.put(id, trace);
currOpenId++;
return id;
}
/** Removes the trace with the given id
*
* @param id Id of the trace to be removed
*/
public void remove(int id){
traces.remove(id);
}
/** Clears all traces
*
*/
public void clear(){
traces.clear();
currOpenId = 1;
}
}