[Maven] FAWE

This commit is contained in:
Telesphoreo 2020-10-16 22:33:33 -05:00
parent d4d1000c16
commit bb33778fc9
4 changed files with 52 additions and 58 deletions

View File

@ -5,7 +5,7 @@
<groupId>me.totalfreedom</groupId> <groupId>me.totalfreedom</groupId>
<artifactId>TotalFreedomMod</artifactId> <artifactId>TotalFreedomMod</artifactId>
<version>2020.10</version> <version>2020.11</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>

View File

@ -7,6 +7,7 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
@ -103,7 +104,7 @@ public class CoreProtectBridge extends FreedomService
@Override @Override
public void run() public void run()
{ {
coreProtect.performRollback(86400, Arrays.asList(name), null, null, null, null, 0, null); coreProtect.performRollback(86400, Collections.singletonList(name), null, null, null, null, 0, null);
} }
}.runTaskAsynchronously(plugin); }.runTaskAsynchronously(plugin);
} }
@ -123,7 +124,7 @@ public class CoreProtectBridge extends FreedomService
@Override @Override
public void run() public void run()
{ {
coreProtect.performRestore(86400, Arrays.asList(name), null, null, null, null, 0, null); coreProtect.performRestore(86400, Collections.singletonList(name), null, null, null, null, 0, null);
} }
}.runTaskAsynchronously(plugin); }.runTaskAsynchronously(plugin);
} }

View File

@ -12,6 +12,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.util.FLog;
import net.coreprotect.CoreProtect; import net.coreprotect.CoreProtect;
import net.coreprotect.CoreProtectAPI; import net.coreprotect.CoreProtectAPI;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -24,7 +25,7 @@ import org.bukkit.block.data.BlockData;
public class FAWEBridge extends FreedomService public class FAWEBridge extends FreedomService
{ {
private CoreProtectAPI api; private final CoreProtectAPI api = plugin.cpb.getCoreProtectAPI();;
private World world = null; private World world = null;
private final Map<Map.Entry<String, EditSession>, Map<BlockVector3, String>> blocksBroken = new HashMap<>(); private final Map<Map.Entry<String, EditSession>, Map<BlockVector3, String>> blocksBroken = new HashMap<>();
private final Map<Map.Entry<String, EditSession>, Map.Entry<Pattern, List<BlockVector3>>> blocksPlaced = new HashMap<>(); private final Map<Map.Entry<String, EditSession>, Map.Entry<Pattern, List<BlockVector3>>> blocksPlaced = new HashMap<>();
@ -32,15 +33,10 @@ public class FAWEBridge extends FreedomService
@Override @Override
public void onStart() public void onStart()
{ {
api = ((CoreProtect)Bukkit.getPluginManager().getPlugin("CoreProtect")).getAPI();
/* /*
* Iterates over blocks placed by GenerationCommands (in the EditSession) and adds them to the CoreProtect logs. * Iterates over blocks placed by GenerationCommands (in the EditSession) and adds them to the CoreProtect logs.
*/ */
server.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() server.getScheduler().scheduleSyncRepeatingTask(plugin, () ->
{
@Override
public void run()
{ {
if (!(blocksBroken.isEmpty() && blocksPlaced.isEmpty())) if (!(blocksBroken.isEmpty() && blocksPlaced.isEmpty()))
{ {
@ -94,17 +90,14 @@ public class FAWEBridge extends FreedomService
blocksPlaced.values().forEach(collection -> collection.getValue().clear()); blocksPlaced.values().forEach(collection -> collection.getValue().clear());
} }
}
}, 0L, 40L); }, 0L, 40L);
} }
@Override @Override
public void onStop() public void onStop()
{ {
} }
public void logBlockEdit(String playerName, EditSession editSession, Pattern pattern, BlockVector3 blockVector3) public void logBlockEdit(String playerName, EditSession editSession, Pattern pattern, BlockVector3 blockVector3)
{ {
// Cache the world used for the next iterations to come. // Cache the world used for the next iterations to come.

View File

@ -60,7 +60,7 @@ public class WorldEditBridge extends FreedomService
{ {
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
com.sk89q.worldedit.entity.Player fuckyou = (com.sk89q.worldedit.entity.Player)bukkitPlayer; com.sk89q.worldedit.entity.Player fuckyou = bukkitPlayer;
session.undo(session.getBlockBag(fuckyou), fuckyou); session.undo(session.getBlockBag(fuckyou), fuckyou);
} }
} }