SteamWar/FightSystem
Archiviert
13
1

Merge branch 'freezeWorld' of SteamWar/FightSystem into master

Dieser Commit ist enthalten in:
Lixfel 2020-01-07 20:30:01 +01:00 committet von Gitea
Commit c5e35e9580
2 geänderte Dateien mit 18 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -13,17 +13,12 @@ import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.IFightSystem;
import de.steamwar.sql.NoClipboardException; import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic; import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.scoreboard.Team; import org.bukkit.scoreboard.Team;
import java.io.IOException; import java.io.IOException;
@ -95,20 +90,10 @@ class FightTeam_8 {
} }
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1); EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
FreezeWorld freezer = new FreezeWorld();
Bukkit.getPluginManager().registerEvents(freezer, IFightSystem.getPlugin());
ClipboardHolder ch = new ClipboardHolder(clipboard, w.getWorldData()); ClipboardHolder ch = new ClipboardHolder(clipboard, w.getWorldData());
ch.setTransform(aT); ch.setTransform(aT);
Operations.completeBlindly(ch.createPaste(e, w.getWorldData()).to(v).build()); Operations.completeBlindly(ch.createPaste(e, w.getWorldData()).to(v).build());
e.flushQueue(); e.flushQueue();
HandlerList.unregisterAll(freezer);
return e; return e;
} }
static class FreezeWorld implements Listener{
@EventHandler
public void onBlockPhysicsEvent(BlockPhysicsEvent e){
e.setCancelled(true);
}
}
} }

Datei anzeigen

@ -4,6 +4,7 @@ import com.sk89q.worldedit.EditSession;
import de.steamwar.core.Core; import de.steamwar.core.Core;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.IFightSystem;
import de.steamwar.fightsystem.kit.KitManager; import de.steamwar.fightsystem.kit.KitManager;
import de.steamwar.fightsystem.utils.ColorConverter; import de.steamwar.fightsystem.utils.ColorConverter;
import de.steamwar.fightsystem.utils.FightScoreboard; import de.steamwar.fightsystem.utils.FightScoreboard;
@ -17,6 +18,10 @@ import org.bukkit.*;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.scoreboard.NameTagVisibility; import org.bukkit.scoreboard.NameTagVisibility;
import org.bukkit.scoreboard.Team; import org.bukkit.scoreboard.Team;
@ -242,6 +247,7 @@ public class FightTeam implements IFightTeam{
} }
private void pasteSchematic(){ private void pasteSchematic(){
FreezeWorld freezer = new FreezeWorld();
EditSession e; EditSession e;
try { try {
switch(Core.getVersion()){ switch(Core.getVersion()){
@ -271,6 +277,7 @@ public class FightTeam implements IFightTeam{
throw new SecurityException("Error pasting arena in schematic", ex); throw new SecurityException("Error pasting arena in schematic", ex);
} }
replaceTeamColor(e); replaceTeamColor(e);
HandlerList.unregisterAll(freezer);
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), this::teleportToSpawn,40); Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), this::teleportToSpawn,40);
} }
@ -406,4 +413,15 @@ public class FightTeam implements IFightTeam{
assert maximumHearts != 0; assert maximumHearts != 0;
return currentHearts / maximumHearts; return currentHearts / maximumHearts;
} }
private static class FreezeWorld implements Listener {
private FreezeWorld(){
Bukkit.getPluginManager().registerEvents(this, IFightSystem.getPlugin());
}
@EventHandler
public void onBlockPhysicsEvent(BlockPhysicsEvent e){
e.setCancelled(true);
}
}
} }