SteamWar/BauSystem
Archiviert
13
0

Add Trace Record System

Dieser Commit ist enthalten in:
jojo 2020-12-16 16:27:08 +01:00
Ursprung 3cc70f1f71
Commit 599c6049be
13 geänderte Dateien mit 297 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -20,7 +20,7 @@
package de.steamwar.bausystem; package de.steamwar.bausystem;
import de.steamwar.bausystem.commands.*; import de.steamwar.bausystem.commands.*;
import de.steamwar.bausystem.tracer.ExplodeListener; import de.steamwar.bausystem.tracer.record.ExplodeListener;
import de.steamwar.bausystem.world.*; import de.steamwar.bausystem.world.*;
import de.steamwar.core.CommandRemover; import de.steamwar.core.CommandRemover;
import de.steamwar.core.Core; import de.steamwar.core.Core;
@ -120,6 +120,7 @@ public class BauSystem extends JavaPlugin implements Listener {
Bukkit.getPluginManager().registerEvents(new RegionListener(), this); Bukkit.getPluginManager().registerEvents(new RegionListener(), this);
Bukkit.getPluginManager().registerEvents(new ScriptListener(), this); Bukkit.getPluginManager().registerEvents(new ScriptListener(), this);
Bukkit.getPluginManager().registerEvents(new BauScoreboard(), this); Bukkit.getPluginManager().registerEvents(new BauScoreboard(), this);
// Bukkit.getPluginManager().registerEvents(new ExplodeListener(), this);
Bukkit.getPluginManager().registerEvents(new ExplodeListener(), this); Bukkit.getPluginManager().registerEvents(new ExplodeListener(), this);
Bukkit.getPluginManager().registerEvents(new ClipboardListener(), this); Bukkit.getPluginManager().registerEvents(new ClipboardListener(), this);
new AFKStopper(); new AFKStopper();

Datei anzeigen

@ -21,7 +21,7 @@ package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.tracer.RecordManager; import de.steamwar.bausystem.tracer.record.RecordManager;
import de.steamwar.bausystem.tracer.TraceManager; import de.steamwar.bausystem.tracer.TraceManager;
import de.steamwar.bausystem.world.Welt; import de.steamwar.bausystem.world.Welt;
import org.bukkit.command.Command; import org.bukkit.command.Command;

Datei anzeigen

@ -19,7 +19,7 @@
package de.steamwar.bausystem.commands; package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.tracer.RecordManager; import de.steamwar.bausystem.tracer.record.RecordManager;
import de.steamwar.bausystem.tracer.RecordStatus; import de.steamwar.bausystem.tracer.RecordStatus;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

Datei anzeigen

@ -1,5 +1,25 @@
/*
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.bausystem.tracer; package de.steamwar.bausystem.tracer;
import de.steamwar.bausystem.tracer.record.RecordManager;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;

Datei anzeigen

@ -0,0 +1,43 @@
/*
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.bausystem.tracer;
import org.bukkit.entity.Entity;
import org.bukkit.util.Vector;
public class Position {
private Vector location;
private Vector vector;
public Position(Entity entity) {
location = entity.getLocation().toVector();
vector = entity.getVelocity();
}
@Override
public String toString() {
return "Position{" +
"location=" + location +
", vector=" + vector +
'}';
}
}

Datei anzeigen

@ -1,3 +1,22 @@
/*
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.bausystem.tracer; package de.steamwar.bausystem.tracer;
public enum RecordStatus { public enum RecordStatus {

Datei anzeigen

@ -1,3 +1,22 @@
/*
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.bausystem.tracer; package de.steamwar.bausystem.tracer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

Datei anzeigen

@ -1,3 +1,22 @@
/*
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.bausystem.tracer; package de.steamwar.bausystem.tracer;
import de.steamwar.core.Core; import de.steamwar.core.Core;

Datei anzeigen

@ -0,0 +1,34 @@
/*
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.bausystem.tracer.record;
import org.bukkit.entity.TNTPrimed;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class DataHolder {
public static Map<TNTPrimed, RecordTrace> recordTraceMap = new HashMap<>();
public static List<RecordTrace> finished = new ArrayList<>();
}

Datei anzeigen

@ -0,0 +1,58 @@
/*
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.bausystem.tracer.record;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
public class ExplodeListener implements Listener {
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
if (!(event.getEntity() instanceof TNTPrimed)) return;
TNTPrimed tntPrimed = (TNTPrimed) event.getEntity();
RecordManager.tntExplode();
if (!RecordManager.getRecordStatus().isTracing()) {
return;
}
explode(tntPrimed);
}
static void add(TNTPrimed tntPrimed) {
get(tntPrimed).add(tntPrimed);
}
static void explode(TNTPrimed tntPrimed) {
get(tntPrimed).explode(tntPrimed);
DataHolder.finished.add(DataHolder.recordTraceMap.remove(tntPrimed));
}
private static RecordTrace get(TNTPrimed tntPrimed) {
if (!DataHolder.recordTraceMap.containsKey(tntPrimed)) {
DataHolder.recordTraceMap.put(tntPrimed, new RecordTrace(tntPrimed));
}
return DataHolder.recordTraceMap.get(tntPrimed);
}
}

Datei anzeigen

@ -1,7 +1,28 @@
package de.steamwar.bausystem.tracer; /*
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.bausystem.tracer.record;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.commands.CommandTPSLimiter; import de.steamwar.bausystem.commands.CommandTPSLimiter;
import de.steamwar.bausystem.tracer.RecordStatus;
import de.steamwar.bausystem.tracer.TraceManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
@ -55,7 +76,7 @@ public class RecordManager {
if (recorder != null) return; if (recorder != null) return;
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
recorder = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> { recorder = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> {
world.getEntitiesByClass(TNTPrimed.class).forEach(TraceManager::tntAdd); world.getEntitiesByClass(TNTPrimed.class).forEach(ExplodeListener::add);
recordAutoStop(); recordAutoStop();
}, 1, 1); }, 1, 1);
} }

Datei anzeigen

@ -0,0 +1,57 @@
/*
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.bausystem.tracer.record;
import de.steamwar.bausystem.tracer.Position;
import org.bukkit.entity.TNTPrimed;
import java.util.ArrayList;
import java.util.List;
public class RecordTrace {
private Position startPosition;
private Position explosionPosition;
private List<Position> positionList = new ArrayList<>(160);
public RecordTrace(TNTPrimed tntPrimed) {
startPosition = new Position(tntPrimed);
}
public RecordTrace add(TNTPrimed tntPrimed) {
positionList.add(new Position(tntPrimed));
return this;
}
public RecordTrace explode(TNTPrimed tntPrimed) {
explosionPosition = new Position(tntPrimed);
return this;
}
@Override
public String toString() {
return "RecordTrace{" +
"startPosition=" + startPosition +
", explosionPosition=" + explosionPosition +
", positionList=" + positionList +
'}';
}
}

Datei anzeigen

@ -22,7 +22,7 @@ package de.steamwar.bausystem.world;
import de.steamwar.bausystem.commands.CommandFreeze; import de.steamwar.bausystem.commands.CommandFreeze;
import de.steamwar.bausystem.commands.CommandTNT; import de.steamwar.bausystem.commands.CommandTNT;
import de.steamwar.bausystem.commands.CommandTPSLimiter; import de.steamwar.bausystem.commands.CommandTPSLimiter;
import de.steamwar.bausystem.tracer.RecordManager; import de.steamwar.bausystem.tracer.record.RecordManager;
import de.steamwar.bausystem.tracer.TraceManager; import de.steamwar.bausystem.tracer.TraceManager;
import de.steamwar.core.TPSWatcher; import de.steamwar.core.TPSWatcher;
import de.steamwar.scoreboard.SWScoreboard; import de.steamwar.scoreboard.SWScoreboard;