Compare commits
176 Commits
backend-sy
...
feature/hi
| Author | SHA1 | Date | |
|---|---|---|---|
| 2d172ffe6b | |||
| 3bfac2d1cf | |||
| ac24bc4f5b | |||
| c38777158a | |||
| 2bc295c620 | |||
| 88cc06560e | |||
| 566a7deee3 | |||
| ea07766460 | |||
| 9c5b7712cb | |||
| 84b14b8c3d | |||
| abeb269368 | |||
| fc002abf37 | |||
| 09f9a8ce32 | |||
| d0d353b24d | |||
| 52828c8b4e | |||
| 01efb9fce5 | |||
| 8b636a11ee | |||
| 8ca1cf9b5c | |||
| ad4304d7b0 | |||
| e5e931d331 | |||
| ed87197681 | |||
| e6e475e4bb | |||
| daa69dc22b | |||
| d011ffa536 | |||
| 4798b16015 | |||
| f4c9ce512e | |||
| bfe9c7559e | |||
| 394e043db3 | |||
| d2a6ccc46b | |||
| ccd992f1db | |||
| fa0a9a5c23 | |||
| fa6b75e2aa | |||
| f2073db1e8 | |||
| 5fe62d67d9 | |||
| 524ce0c579 | |||
| 3685d662fb | |||
| 19344b9f48 | |||
| 3d3c70845e | |||
| 797f3a3158 | |||
| 4b1680967a | |||
| 361c86c99e | |||
| 613cb76edb | |||
| 1231fa5c47 | |||
| 06a7d9c7fc | |||
| 21d628b338 | |||
| 56d34f0311 | |||
| 4322547106 | |||
| 43a582edd8 | |||
| d4eabfe9b2 | |||
| bfbb017c8f | |||
| 5a7349b5a6 | |||
| ef91313c29 | |||
| ba2297ca9a | |||
| ba843633d7 | |||
| 3b43ad3587 | |||
| 26a45fabb1 | |||
| f8bb69e829 | |||
| b74b73b871 | |||
| b695a7e089 | |||
| 464d7c85bd | |||
| 285882be70 | |||
| 50780ad9bd | |||
| bbd2bcae35 | |||
| a3801790a4 | |||
| b14c39683a | |||
| 0a3ae7117d | |||
| 830ca93105 | |||
| 06333d634e | |||
| ecb9571624 | |||
| 9e0e339277 | |||
| 06de120fe1 | |||
| 30db0bb718 | |||
| 0a4dccd95a | |||
| 5550aa4930 | |||
| 811bd00ed2 | |||
| bc371df796 | |||
| 144975d977 | |||
| 0763e4b189 | |||
| 38b061c12c | |||
| 91a41ccd3f | |||
| 576ce891f6 | |||
| 7aff9f08d0 | |||
| 13ef131401 | |||
| 56680119e2 | |||
| 6a5507321e | |||
| 01d9532aa6 | |||
| c49a212c05 | |||
| e6196251a6 | |||
| 698f917828 | |||
| ad87ad7495 | |||
| 6a78499193 | |||
| d55556cb47 | |||
| 4f24adf9fd | |||
| 94e3eed6df | |||
| 8a43809322 | |||
| 8fb10c9266 | |||
| fb518efe63 | |||
| 598daadd33 | |||
| 0287881e33 | |||
| a6b703b821 | |||
| 43cca3376e | |||
| 7e61db5e58 | |||
| c9b4e6ab45 | |||
| 314aaf7a76 | |||
| e98f53bbab | |||
| 7dc9da549c | |||
| 3bb84d0dcc | |||
| 3d0e5fc28d | |||
| 5e5bfedb52 | |||
| ef19959eb2 | |||
| ae15e16dae | |||
| 9a506a34f8 | |||
| 6822dc796f | |||
| 8427ae36f2 | |||
| 7f41559647 | |||
| 4e70a675c2 | |||
| 96daa2c861 | |||
| 45646b6ba3 | |||
| 8d1b15b019 | |||
| 2e91a5a582 | |||
| 018b9a971f | |||
| 70d0f179cc | |||
| 2166096ba5 | |||
| 3a13fc7bb9 | |||
| 01f55c4309 | |||
| d968187750 | |||
| 9e629d09a8 | |||
| d14022e69e | |||
| 6623e9d808 | |||
| 9279d9cd8e | |||
| b7963f2fe6 | |||
| 3f88ea1e57 | |||
| 8076f31a19 | |||
| 33e9b3409f | |||
| e7803dcf82 | |||
| cf52b50333 | |||
| 297aa6151d | |||
| 14be3a8e3b | |||
| 1c1e2e2efe | |||
| e30eb35792 | |||
| e94f273e21 | |||
| c76648e630 | |||
| a943dd6014 | |||
| 0d7776ec6f | |||
| 7db1d80988 | |||
| 50bd18bae7 | |||
| 89a55996fc | |||
| f494729b89 | |||
| bcabce8b23 | |||
| 376da2028b | |||
| b6cfaf8135 | |||
| 5daee0f589 | |||
| 43663ea099 | |||
| 9d1b0063b9 | |||
| e706044f44 | |||
| 332daec716 | |||
| 2daca017c2 | |||
| 7edd72ac27 | |||
| 1355b57a93 | |||
| e04f0d4ad1 | |||
| 79a6c93f8f | |||
| e36bbfd2a7 | |||
| 65cb544b64 | |||
| 8a22afab63 | |||
| caae9542f4 | |||
| 4104c60f6b | |||
| 69260a9b73 | |||
| 4fb6505aef | |||
| bb2f7cf0c1 | |||
| 8516c8e536 | |||
| 066f06a6e3 | |||
| 78e176b55e | |||
| 86a10b3e97 | |||
| d01efffb6a | |||
| eac0390dd3 | |||
| 933e2119ef |
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.utils;
|
package de.steamwar.bausystem.utils;
|
||||||
|
|
||||||
import de.steamwar.bausystem.region.GlobalRegion;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
||||||
import de.steamwar.bausystem.utils.tps.TPSFreezeUtils;
|
import de.steamwar.bausystem.utils.tps.TPSFreezeUtils;
|
||||||
import de.steamwar.bausystem.utils.tps.TPSLimitUtils;
|
import de.steamwar.bausystem.utils.tps.TPSLimitUtils;
|
||||||
@ -46,7 +46,7 @@ public class TickManager15 implements TickManager, Listener {
|
|||||||
if (currentlyStepping) {
|
if (currentlyStepping) {
|
||||||
currentlyStepping = false;
|
currentlyStepping = false;
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||||
BossBarService.instance.remove(player, GlobalRegion.getInstance(), "TickStep");
|
BossBarService.instance.remove(player, Region.getGlobalRegion(), "TickStep");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
TPSWarpUtils.warp(tickRate);
|
TPSWarpUtils.warp(tickRate);
|
||||||
|
|||||||
@ -35,7 +35,6 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -44,10 +43,11 @@ import java.util.Optional;
|
|||||||
public class NMSWrapper21 implements NMSWrapper {
|
public class NMSWrapper21 implements NMSWrapper {
|
||||||
|
|
||||||
private static final Reflection.Field<ServerPlayerGameMode> playerInteractManager = Reflection.getField(ServerPlayer.class, null, ServerPlayerGameMode.class);
|
private static final Reflection.Field<ServerPlayerGameMode> playerInteractManager = Reflection.getField(ServerPlayer.class, null, ServerPlayerGameMode.class);
|
||||||
|
private static final Reflection.Field<GameType> playerGameMode = Reflection.getField(ServerPlayerGameMode.class, GameType.class, 0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInternalGameMode(Player player, GameMode gameMode) {
|
public void setInternalGameMode(Player player, GameMode gameMode) {
|
||||||
playerInteractManager.get(((CraftPlayer) player).getHandle()).changeGameModeForPlayer(GameType.byId(gameMode.getValue()), PlayerGameModeChangeEvent.Cause.UNKNOWN, null);
|
playerGameMode.set(playerInteractManager.get(((CraftPlayer) player).getHandle()), GameType.byId(gameMode.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -66,7 +66,7 @@ public class NMSWrapper21 implements NMSWrapper {
|
|||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Reflection.Field<ClientboundGameEventPacket.Type> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, ClientboundGameEventPacket.Type.class, 12);
|
private static final Reflection.Field<ClientboundGameEventPacket.Type> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, ClientboundGameEventPacket.Type.class, 14);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGameStateChangeReason(Object packet) {
|
public void setGameStateChangeReason(Object packet) {
|
||||||
|
|||||||
@ -25,7 +25,7 @@ PAGE_LIST=§e Page ({0}/{1}) »»
|
|||||||
LIST_PREVIOUS_PAGE=§ePrevious page
|
LIST_PREVIOUS_PAGE=§ePrevious page
|
||||||
LIST_NEXT_PAGE=§eNext page
|
LIST_NEXT_PAGE=§eNext page
|
||||||
# Permissions
|
# Permissions
|
||||||
NO_PERMISSION=You are not allowed to use that here
|
NO_PERMISSION=§7You are not allowed to use that here
|
||||||
SPECTATOR=§fSpectator
|
SPECTATOR=§fSpectator
|
||||||
# Scoreboard
|
# Scoreboard
|
||||||
SCOREBOARD_TIME=Time
|
SCOREBOARD_TIME=Time
|
||||||
@ -137,7 +137,9 @@ BAU_INFO_ITEM_LORE_FIRE=§7Fire§8: §e{0}
|
|||||||
BAU_INFO_ITEM_LORE_COLOR=§7Color§8: §e{0}
|
BAU_INFO_ITEM_LORE_COLOR=§7Color§8: §e{0}
|
||||||
BAU_INFO_ITEM_LORE_PROTECT=§7Protect§8: §e{0}
|
BAU_INFO_ITEM_LORE_PROTECT=§7Protect§8: §e{0}
|
||||||
BAU_INFO_ITEM_LORE_ITEMS=§7Items§8: §e{0}
|
BAU_INFO_ITEM_LORE_ITEMS=§7Items§8: §e{0}
|
||||||
BAU_INFO_ITEM_LORE_NO_GRAVITY = §8NoGravity§8: §e{0}
|
BAU_INFO_ITEM_LORE_NO_GRAVITY = §7NoGravity§8: §e{0}
|
||||||
|
BAU_INFO_ITEM_LORE_TESTBLOCK=§7Testblock§8: §e{0}
|
||||||
|
BAU_INFO_ITEM_LORE_CHANGED=§7Changed§8: §e{0}
|
||||||
BAU_INFO_COMMAND_HELP=§8/§ebauinfo §8- §7Information regarding this build server
|
BAU_INFO_COMMAND_HELP=§8/§ebauinfo §8- §7Information regarding this build server
|
||||||
BAU_INFO_COMMAND_OWNER=§7Owner§8: §e{0}
|
BAU_INFO_COMMAND_OWNER=§7Owner§8: §e{0}
|
||||||
BAU_INFO_COMMAND_MEMBER=§7{0} §8[§7{1}§8]§8: §e{2}
|
BAU_INFO_COMMAND_MEMBER=§7{0} §8[§7{1}§8]§8: §e{2}
|
||||||
@ -390,6 +392,12 @@ INVENTORY_FILL_HELP=§8/§einventoryfill §8- §7Toggles InventoryFill
|
|||||||
INVENTORY_FILL_INFO=§7Helps you fill containers by looking at them while sneaking and dropping the item. Or just scroll on a container to change the amount of the item inside.
|
INVENTORY_FILL_INFO=§7Helps you fill containers by looking at them while sneaking and dropping the item. Or just scroll on a container to change the amount of the item inside.
|
||||||
INVENTORY_FILL_ENABLE=§aInventoryFiller activated
|
INVENTORY_FILL_ENABLE=§aInventoryFiller activated
|
||||||
INVENTORY_FILL_DISABLE=§cInventoryFiller deactivated
|
INVENTORY_FILL_DISABLE=§cInventoryFiller deactivated
|
||||||
|
INVENTORY_FILL_GUI_NAME=Inventory Filler
|
||||||
|
INVENTORY_FILL_GUI_POWER=§ePower§8:§7 {0}
|
||||||
|
INVENTORY_FILL_GUI_TNT=§eTNT
|
||||||
|
# Ray Visualizer
|
||||||
|
RAY_VISUALIZER_ENABLE=§aRayVisualizer activated
|
||||||
|
RAY_VISUALIZER_DISABLE=§aRayVisualizer deactivated
|
||||||
# Killchecker
|
# Killchecker
|
||||||
KILLCHECKER_HELP_ENABLE=§8/§ekillchecker enable §8- §7Enables Killchecker / Recalculates kills
|
KILLCHECKER_HELP_ENABLE=§8/§ekillchecker enable §8- §7Enables Killchecker / Recalculates kills
|
||||||
KILLCHECKER_HELP_DISABLE=§8/§ekillchecker disable §8- §7Disables Killchecker
|
KILLCHECKER_HELP_DISABLE=§8/§ekillchecker disable §8- §7Disables Killchecker
|
||||||
@ -397,6 +405,7 @@ KILLCHECKER_INFO=§7Shows the overlaps of cannon kills in your build area.
|
|||||||
KILLCHECKER_INFO2=§7Only colorable blocks like Wool, Terractotta, Stained Glass and Concrete are counted.
|
KILLCHECKER_INFO2=§7Only colorable blocks like Wool, Terractotta, Stained Glass and Concrete are counted.
|
||||||
KILLCHECKER_ENABLE=§aKillchecker activated
|
KILLCHECKER_ENABLE=§aKillchecker activated
|
||||||
KILLCHECKER_DISABLE=§cKillchecker deactivated
|
KILLCHECKER_DISABLE=§cKillchecker deactivated
|
||||||
|
KILLCHECKER_NO_BUILD=§cThere is no Build Area in this Region
|
||||||
KILLCHECKER_BOSSBAR=§e§l{0} §7(§e{1}%§7) §e§l{2}§7 cannons
|
KILLCHECKER_BOSSBAR=§e§l{0} §7(§e{1}%§7) §e§l{2}§7 cannons
|
||||||
# BlockCounter
|
# BlockCounter
|
||||||
BLOCK_COUNTER_HELP_TOGGLE=§8/§eblockcounter §8- §7Toggle on/off
|
BLOCK_COUNTER_HELP_TOGGLE=§8/§eblockcounter §8- §7Toggle on/off
|
||||||
@ -731,12 +740,10 @@ REGION_ITEM_RESET=§eReset
|
|||||||
REGION_ITEM_TESTBLOCK=§eDummy
|
REGION_ITEM_TESTBLOCK=§eDummy
|
||||||
REGION_ITEM_TNT_OFF=§7TNT: §eDeactivated
|
REGION_ITEM_TNT_OFF=§7TNT: §eDeactivated
|
||||||
REGION_ITEM_TNT_ONLY_TB=§7TNT: §eonly dummy
|
REGION_ITEM_TNT_ONLY_TB=§7TNT: §eonly dummy
|
||||||
REGION_ITEM_TNT_ONLY_BUILD=§7TNT: §eonly build
|
|
||||||
REGION_ITEM_TNT_ON=§7TNT: §eActivated
|
REGION_ITEM_TNT_ON=§7TNT: §eActivated
|
||||||
REGION_ITEM_SELECTOR_TITLE=Tnt Mode
|
REGION_ITEM_SELECTOR_TITLE=Tnt Mode
|
||||||
REGION_ITEM_SELECTOR_ON=§eActivate
|
REGION_ITEM_SELECTOR_ON=§eActivate
|
||||||
REGION_ITEM_SELECTOR_ONLY_TB=§eonly dummy
|
REGION_ITEM_SELECTOR_ONLY_TB=§eonly dummy
|
||||||
REGION_ITEM_SELECTOR_ONLY_BUILD=§eonly build
|
|
||||||
REGION_ITEM_SELECTOR_OFF=§eDeactivate
|
REGION_ITEM_SELECTOR_OFF=§eDeactivate
|
||||||
#Region
|
#Region
|
||||||
REGION_COLOR_HELP_COLOR=§8/§ecolor §8[§7Color§8] §8- §7Sets the color of the region
|
REGION_COLOR_HELP_COLOR=§8/§ecolor §8[§7Color§8] §8- §7Sets the color of the region
|
||||||
@ -933,7 +940,6 @@ SELECT_HELP=§8/§eselect §8[§7RegionsTyp§8] §8- §7Select a region type
|
|||||||
SELECT_EXTENSION_HELP=§8/§eselect §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Select a region type with or without extension
|
SELECT_EXTENSION_HELP=§8/§eselect §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Select a region type with or without extension
|
||||||
SELECT_GLOBAL_REGION=§cThe global region cannot be selected
|
SELECT_GLOBAL_REGION=§cThe global region cannot be selected
|
||||||
SELECT_NO_TYPE=§cThis region has no {0}
|
SELECT_NO_TYPE=§cThis region has no {0}
|
||||||
SELECT_NO_EXTENSION=§cThis region has no extension
|
|
||||||
SELECT_MESSAGE=§7WorldEdit selection set to {0}, {1}, {2} and {3}, {4}, {5}
|
SELECT_MESSAGE=§7WorldEdit selection set to {0}, {1}, {2} and {3}, {4}, {5}
|
||||||
SKULL_HELP=§8/§eskull §8[§eplayer§8] §8-§7 Receive a player head
|
SKULL_HELP=§8/§eskull §8[§eplayer§8] §8-§7 Receive a player head
|
||||||
SKULL_INVALID=§cInvalid player name
|
SKULL_INVALID=§cInvalid player name
|
||||||
|
|||||||
@ -25,7 +25,7 @@ PAGE_LIST=§e Seite ({0}/{1}) »»
|
|||||||
LIST_PREVIOUS_PAGE=§eVorherige Seite
|
LIST_PREVIOUS_PAGE=§eVorherige Seite
|
||||||
LIST_NEXT_PAGE=§eNächste Seite
|
LIST_NEXT_PAGE=§eNächste Seite
|
||||||
# Permission
|
# Permission
|
||||||
NO_PERMISSION=Du darfst dies hier nicht nutzen
|
NO_PERMISSION=§7Du darfst dies hier nicht nutzen
|
||||||
SPECTATOR=§fZuschauer
|
SPECTATOR=§fZuschauer
|
||||||
# Scoreboard
|
# Scoreboard
|
||||||
SCOREBOARD_TIME=Uhrzeit
|
SCOREBOARD_TIME=Uhrzeit
|
||||||
@ -119,12 +119,9 @@ BACKUP_LORE=§eKlicken zum Laden
|
|||||||
BAU_COMMAND_HELP_INFO=§8/§ebau info §8- §7Alias für §8/§ebauinfo
|
BAU_COMMAND_HELP_INFO=§8/§ebau info §8- §7Alias für §8/§ebauinfo
|
||||||
BAU_INFO_ITEM_NAME=§eBau-Management
|
BAU_INFO_ITEM_NAME=§eBau-Management
|
||||||
## This is used in BauInfoBauGuiItem.java
|
## This is used in BauInfoBauGuiItem.java
|
||||||
BAU_INFO_ITEM_LORE_TNT=§7TNT§8: §e{0}
|
|
||||||
BAU_INFO_ITEM_LORE_FREEZE=§7Freeze§8: §e{0}
|
|
||||||
BAU_INFO_ITEM_LORE_DAMAGE=§7Damage§8: §e{0}
|
|
||||||
BAU_INFO_ITEM_LORE_FIRE=§7Feuer§8: §e{0}
|
BAU_INFO_ITEM_LORE_FIRE=§7Feuer§8: §e{0}
|
||||||
BAU_INFO_ITEM_LORE_COLOR=§7Farbe§8: §e{0}
|
BAU_INFO_ITEM_LORE_COLOR=§7Farbe§8: §e{0}
|
||||||
BAU_INFO_ITEM_LORE_PROTECT=§7Protect§8: §e{0}
|
BAU_INFO_ITEM_LORE_CHANGED=§7Verändert§8: §e{0}
|
||||||
BAU_INFO_COMMAND_HELP=§8/§ebauinfo §8- §7Gibt Informationen über den Bau
|
BAU_INFO_COMMAND_HELP=§8/§ebauinfo §8- §7Gibt Informationen über den Bau
|
||||||
BAU_INFO_COMMAND_OWNER=§7Besitzer§8: §e{0}
|
BAU_INFO_COMMAND_OWNER=§7Besitzer§8: §e{0}
|
||||||
BAU_INFO_COMMAND_MEMBER=§7{0} §8[§7{1}§8]§8: §e{2}
|
BAU_INFO_COMMAND_MEMBER=§7{0} §8[§7{1}§8]§8: §e{2}
|
||||||
@ -350,8 +347,11 @@ SMART_PLACE_DISABLE=§cSmartPlace deaktiviert
|
|||||||
# InventoryFiller
|
# InventoryFiller
|
||||||
INVENTORY_FILL_HELP=§8/§einventoryfill §8- §7Toggled InventoryFill
|
INVENTORY_FILL_HELP=§8/§einventoryfill §8- §7Toggled InventoryFill
|
||||||
INVENTORY_FILL_INFO=§7Hilft dir, Behälter zu füllen, indem du sie beim sneaken ansiehst und den Gegenstand fallen lässt. Oder scrolle einfach auf einen Behälter, um die Menge des gehaltenen Gegenstandes darin zu ändern.
|
INVENTORY_FILL_INFO=§7Hilft dir, Behälter zu füllen, indem du sie beim sneaken ansiehst und den Gegenstand fallen lässt. Oder scrolle einfach auf einen Behälter, um die Menge des gehaltenen Gegenstandes darin zu ändern.
|
||||||
INVENTORY_FILL_ENABLE=§aInventoryFiller activated
|
INVENTORY_FILL_ENABLE=§aInventoryFiller aktiviert
|
||||||
INVENTORY_FILL_DISABLE=§cInventoryFiller deactivated
|
INVENTORY_FILL_DISABLE=§cInventoryFiller deaktiviert
|
||||||
|
# Ray Visualizer
|
||||||
|
RAY_VISUALIZER_ENABLE=§aRayVisualizer aktiviert
|
||||||
|
RAY_VISUALIZER_DISABLE=§aRayVisualizer deaktiviert
|
||||||
# Killchecker
|
# Killchecker
|
||||||
KILLCHECKER_HELP_ENABLE=§8/§ekillchecker enable §8- §7Aktiviert Killchecker / Berechnet kills neu
|
KILLCHECKER_HELP_ENABLE=§8/§ekillchecker enable §8- §7Aktiviert Killchecker / Berechnet kills neu
|
||||||
KILLCHECKER_HELP_DISABLE=§8/§ekillchecker disable §8- §7Deaktiviert Killchecker
|
KILLCHECKER_HELP_DISABLE=§8/§ekillchecker disable §8- §7Deaktiviert Killchecker
|
||||||
@ -359,6 +359,7 @@ KILLCHECKER_INFO=§7Zeigt Überlappungen der Kanonen Kills im Baubereich an.
|
|||||||
KILLCHECKER_INFO2=§7Nur farbige Blöcke wie Wolle, Terracotta, Stained Glass und Concrete wird gezählt.
|
KILLCHECKER_INFO2=§7Nur farbige Blöcke wie Wolle, Terracotta, Stained Glass und Concrete wird gezählt.
|
||||||
KILLCHECKER_ENABLE=§aKillchecker aktiviert
|
KILLCHECKER_ENABLE=§aKillchecker aktiviert
|
||||||
KILLCHECKER_DISABLE=§cKillchecker deaktiviert
|
KILLCHECKER_DISABLE=§cKillchecker deaktiviert
|
||||||
|
KILLCHECKER_NO_BUILD=§cEs gibt keinen Baubereich in dieser Region
|
||||||
KILLCHECKER_BOSSBAR=§e§l{0} §7(§e{1}%§7) §e§l{2}§7 Kanonnen
|
KILLCHECKER_BOSSBAR=§e§l{0} §7(§e{1}%§7) §e§l{2}§7 Kanonnen
|
||||||
# BlockCounter
|
# BlockCounter
|
||||||
BLOCK_COUNTER_HELP_TOGGLE=§8/§eblockcounter §8- §7Wechsel zwischen an und aus
|
BLOCK_COUNTER_HELP_TOGGLE=§8/§eblockcounter §8- §7Wechsel zwischen an und aus
|
||||||
@ -677,12 +678,10 @@ REGION_ITEM_RESET=§eReset
|
|||||||
REGION_ITEM_TESTBLOCK=§eTestblock
|
REGION_ITEM_TESTBLOCK=§eTestblock
|
||||||
REGION_ITEM_TNT_OFF=§7TNT: §eAusgeschaltet
|
REGION_ITEM_TNT_OFF=§7TNT: §eAusgeschaltet
|
||||||
REGION_ITEM_TNT_ONLY_TB=§7TNT: §enur Testblock
|
REGION_ITEM_TNT_ONLY_TB=§7TNT: §enur Testblock
|
||||||
REGION_ITEM_TNT_ONLY_BUILD=§7TNT: §enur Baubereich
|
|
||||||
REGION_ITEM_TNT_ON=§7TNT: §eEingeschaltet
|
REGION_ITEM_TNT_ON=§7TNT: §eEingeschaltet
|
||||||
REGION_ITEM_SELECTOR_TITLE=Tnt Modus
|
REGION_ITEM_SELECTOR_TITLE=Tnt Modus
|
||||||
REGION_ITEM_SELECTOR_ON=§eEinschalten
|
REGION_ITEM_SELECTOR_ON=§eEinschalten
|
||||||
REGION_ITEM_SELECTOR_ONLY_TB=§enur Testblock
|
REGION_ITEM_SELECTOR_ONLY_TB=§enur Testblock
|
||||||
REGION_ITEM_SELECTOR_ONLY_BUILD=§enur Baubereich
|
|
||||||
REGION_ITEM_SELECTOR_OFF=§eAusschalten
|
REGION_ITEM_SELECTOR_OFF=§eAusschalten
|
||||||
#Region
|
#Region
|
||||||
REGION_COLOR_HELP_COLOR=§8/§ecolor §8[§7Color§8] §8- §7Setze die Farbe der Region
|
REGION_COLOR_HELP_COLOR=§8/§ecolor §8[§7Color§8] §8- §7Setze die Farbe der Region
|
||||||
@ -874,7 +873,6 @@ SELECT_HELP=§8/§eselect §8[§7RegionsTyp§8] §8- §7Wähle einen RegionsTyp
|
|||||||
SELECT_EXTENSION_HELP=§8/§eselect §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Wähle einen RegionsTyp aus mit oder ohne Extension
|
SELECT_EXTENSION_HELP=§8/§eselect §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Wähle einen RegionsTyp aus mit oder ohne Extension
|
||||||
SELECT_GLOBAL_REGION=§cDie globale Region kannst du nicht auswählen
|
SELECT_GLOBAL_REGION=§cDie globale Region kannst du nicht auswählen
|
||||||
SELECT_NO_TYPE=§cDiese Region hat keinen {0}
|
SELECT_NO_TYPE=§cDiese Region hat keinen {0}
|
||||||
SELECT_NO_EXTENSION=§cDiese Region hat keine Ausfahrmaße
|
|
||||||
SELECT_MESSAGE=§7WorldEdit auswahl auf {0}, {1}, {2} und {3}, {4}, {5} gesetzt
|
SELECT_MESSAGE=§7WorldEdit auswahl auf {0}, {1}, {2} und {3}, {4}, {5} gesetzt
|
||||||
SKULL_HELP=§8/§eskull §8[§eSpieler§8] §8-§7 Gibt einen SpielerKopf
|
SKULL_HELP=§8/§eskull §8[§eSpieler§8] §8-§7 Gibt einen SpielerKopf
|
||||||
SKULL_INVALID=§cUngültiger Spieler
|
SKULL_INVALID=§cUngültiger Spieler
|
||||||
|
|||||||
@ -32,9 +32,7 @@ import de.steamwar.bausystem.features.tracer.TraceManager;
|
|||||||
import de.steamwar.bausystem.features.tracer.TraceRecorder;
|
import de.steamwar.bausystem.features.tracer.TraceRecorder;
|
||||||
import de.steamwar.bausystem.features.world.BauScoreboard;
|
import de.steamwar.bausystem.features.world.BauScoreboard;
|
||||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||||
import de.steamwar.bausystem.region.loader.PrototypeLoader;
|
import de.steamwar.bausystem.region.RegionSystem;
|
||||||
import de.steamwar.bausystem.region.loader.RegionLoader;
|
|
||||||
import de.steamwar.bausystem.region.loader.Updater;
|
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
import de.steamwar.bausystem.utils.TickListener;
|
import de.steamwar.bausystem.utils.TickListener;
|
||||||
import de.steamwar.bausystem.utils.TickManager;
|
import de.steamwar.bausystem.utils.TickManager;
|
||||||
@ -42,6 +40,7 @@ import de.steamwar.bausystem.worlddata.WorldData;
|
|||||||
import de.steamwar.command.AbstractValidator;
|
import de.steamwar.command.AbstractValidator;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.SWCommandUtils;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
|
import de.steamwar.core.CRIUSleepEvent;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.core.WorldEditRendererCUIEditor;
|
import de.steamwar.core.WorldEditRendererCUIEditor;
|
||||||
import de.steamwar.linkage.LinkedInstance;
|
import de.steamwar.linkage.LinkedInstance;
|
||||||
@ -56,6 +55,7 @@ import lombok.Getter;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@ -74,7 +74,7 @@ import java.util.function.Consumer;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class BauSystem extends JavaPlugin {
|
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;
|
||||||
@ -95,6 +95,8 @@ public class BauSystem extends JavaPlugin {
|
|||||||
instance = this;
|
instance = this;
|
||||||
SWUtils.setBausystem(instance);
|
SWUtils.setBausystem(instance);
|
||||||
|
|
||||||
|
RegionSystem.INSTANCE.load();
|
||||||
|
/*
|
||||||
try {
|
try {
|
||||||
PrototypeLoader.load();
|
PrototypeLoader.load();
|
||||||
RegionLoader.load();
|
RegionLoader.load();
|
||||||
@ -107,6 +109,7 @@ public class BauSystem extends JavaPlugin {
|
|||||||
|
|
||||||
new Updater(PrototypeLoader.file, PrototypeLoader::load);
|
new Updater(PrototypeLoader.file, PrototypeLoader::load);
|
||||||
new Updater(RegionLoader.file, RegionLoader::load);
|
new Updater(RegionLoader.file, RegionLoader::load);
|
||||||
|
*/
|
||||||
|
|
||||||
SWCommandUtils.addValidator(Player.class, validator(Permission.BUILD));
|
SWCommandUtils.addValidator(Player.class, validator(Permission.BUILD));
|
||||||
SWCommandUtils.addValidator(CommandSender.class, validator(Permission.BUILD));
|
SWCommandUtils.addValidator(CommandSender.class, validator(Permission.BUILD));
|
||||||
@ -211,6 +214,11 @@ public class BauSystem extends JavaPlugin {
|
|||||||
new WorldEditRendererCUIEditor();
|
new WorldEditRendererCUIEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onCRIUSleep(CRIUSleepEvent event) {
|
||||||
|
RegionSystem.INSTANCE.save();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
instances.forEach((aClass, o) -> {
|
instances.forEach((aClass, o) -> {
|
||||||
@ -223,6 +231,7 @@ public class BauSystem extends JavaPlugin {
|
|||||||
});
|
});
|
||||||
|
|
||||||
WorldData.write();
|
WorldData.write();
|
||||||
|
RegionSystem.INSTANCE.save();
|
||||||
Config.getInstance().saveAll();
|
Config.getInstance().saveAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,11 +21,9 @@ package de.steamwar.bausystem;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.config.BauServer;
|
import de.steamwar.bausystem.config.BauServer;
|
||||||
import de.steamwar.bausystem.features.world.BauMemberUpdate;
|
import de.steamwar.bausystem.features.world.BauMemberUpdate;
|
||||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
|
||||||
import de.steamwar.sql.BauweltMember;
|
import de.steamwar.sql.BauweltMember;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|||||||
@ -24,7 +24,6 @@ import de.steamwar.command.PreviousArguments;
|
|||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.MinVersion;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|||||||
@ -24,8 +24,6 @@ import de.steamwar.bausystem.Permission;
|
|||||||
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.bausystem.utils.ItemUtils;
|
import de.steamwar.bausystem.utils.ItemUtils;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
@ -33,8 +31,6 @@ import lombok.Getter;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.data.type.Chest;
|
import org.bukkit.block.data.type.Chest;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -43,9 +39,9 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
|
|||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.io.File;
|
import java.util.Arrays;
|
||||||
import java.text.SimpleDateFormat;
|
import java.util.HashMap;
|
||||||
import java.util.*;
|
import java.util.Map;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class AutostartListener implements Listener {
|
public class AutostartListener implements Listener {
|
||||||
@ -106,11 +102,11 @@ public class AutostartListener implements Listener {
|
|||||||
|
|
||||||
public void activate(Player player) {
|
public void activate(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region.isGlobal()) {
|
if (region.getType().isGlobal()) {
|
||||||
BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO_REGION", player);
|
BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO_REGION", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!region.hasType(RegionType.TESTBLOCK)) {
|
if (region.getTestblockArea().isEmpty()) {
|
||||||
BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO_REGION", player);
|
BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO_REGION", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -131,20 +127,12 @@ public class AutostartListener implements Listener {
|
|||||||
event.blockList().forEach(block -> {
|
event.blockList().forEach(block -> {
|
||||||
Region region = Region.getRegion(block.getLocation());
|
Region region = Region.getRegion(block.getLocation());
|
||||||
if (!regionStartTime.containsKey(region)) return;
|
if (!regionStartTime.containsKey(region)) return;
|
||||||
if (!region.hasType(RegionType.TESTBLOCK)) return;
|
if (!region.getTestblockArea().inRegion(block.getLocation(), true)) return;
|
||||||
if (!region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) return;
|
|
||||||
long tickDiff = TPSUtils.currentRealTick.get() - regionStartTime.remove(region);
|
long tickDiff = TPSUtils.currentRealTick.get() - regionStartTime.remove(region);
|
||||||
long preFightDurationInSeconds = getPreFightDurationInSeconds(region);
|
long preFightDurationInSeconds = region.getGameModeConfig().getTimes().getPreFightDuration();
|
||||||
RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT1", tickDiff);
|
RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT1", tickDiff);
|
||||||
RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT2", preFightDurationInSeconds, ((preFightDurationInSeconds * 20) - tickDiff));
|
RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT2", preFightDurationInSeconds, ((preFightDurationInSeconds * 20) - tickDiff));
|
||||||
RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT3");
|
RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT3");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getPreFightDurationInSeconds(Region region) {
|
|
||||||
File file = region.gameModeConfig();
|
|
||||||
if (file == null) return 30;
|
|
||||||
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
|
||||||
return config.getInt("Times.PreFightDuration", 30);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,31 +19,23 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.backup;
|
package de.steamwar.bausystem.features.backup;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.bausystem.region.Color;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
import de.steamwar.bausystem.region.RegionBackups;
|
||||||
|
import de.steamwar.bausystem.region.flags.ChangedMode;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
import de.steamwar.command.PreviousArguments;
|
||||||
import de.steamwar.bausystem.region.tags.Tag;
|
|
||||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.SWCommandUtils;
|
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.inventory.SWListInv;
|
import de.steamwar.inventory.SWListInv;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.File;
|
import java.util.*;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
@ -54,7 +46,7 @@ public class BackupCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static boolean checkGlobalRegion(Region region, Player p) {
|
static boolean checkGlobalRegion(Region region, Player p) {
|
||||||
if (region.isGlobal()) {
|
if (region.getType().isGlobal()) {
|
||||||
BauSystem.MESSAGE.send("BACKUP_REGION_NO_REGION", p);
|
BauSystem.MESSAGE.send("BACKUP_REGION_NO_REGION", p);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -67,11 +59,12 @@ public class BackupCommand extends SWCommand {
|
|||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!region.get(Tag.CHANGED)) {
|
if (region.getFlags().get(Flag.CHANGED).isWithDefault(ChangedMode.NO_CHANGE)) {
|
||||||
BauSystem.MESSAGE.send("BACKUP_CREATE_NO_CHANGE", p);
|
BauSystem.MESSAGE.send("BACKUP_CREATE_NO_CHANGE", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (region.backup()) {
|
Optional<RegionBackups.Backup> backup = region.getBackups().create(RegionBackups.BackupType.MANUAL);
|
||||||
|
if (backup.isPresent()) {
|
||||||
BauSystem.MESSAGE.send("BACKUP_CREATE_SUCCESS", p);
|
BauSystem.MESSAGE.send("BACKUP_CREATE_SUCCESS", p);
|
||||||
} else {
|
} else {
|
||||||
BauSystem.MESSAGE.send("BACKUP_CREATE_FAILURE", p);
|
BauSystem.MESSAGE.send("BACKUP_CREATE_FAILURE", p);
|
||||||
@ -79,25 +72,12 @@ public class BackupCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "load", description = "BACKUP_HELP_LOAD")
|
@Register(value = "load", description = "BACKUP_HELP_LOAD")
|
||||||
public void backupLoad(@Validator("owner") Player p, @Mapper("backupName") String backupName) {
|
public void backupLoad(@Validator("owner") Player p, @Mapper("backup") @ErrorMessage("BACKUP_LOAD_FAILURE") RegionBackups.Backup backup) {
|
||||||
Region region = Region.getRegion(p.getLocation());
|
if (backup.load()) {
|
||||||
if (checkGlobalRegion(region, p)) {
|
BauSystem.MESSAGE.send("BACKUP_LOAD", p);
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
File backupFile = region.getBackupFile(backupName.replace('_', ' '));
|
|
||||||
if (backupFile == null) {
|
|
||||||
BauSystem.MESSAGE.send("BACKUP_LOAD_FAILURE", p);
|
BauSystem.MESSAGE.send("BACKUP_LOAD_FAILURE", p);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
EditSession editSession = new PasteBuilder(new PasteBuilder.FileProvider(backupFile))
|
|
||||||
.pastePoint(region.getMinPoint().add(region.getPrototype().getSizeX() / 2, 0, region.getPrototype().getSizeZ() / 2))
|
|
||||||
.minPoint(region.getMinPoint())
|
|
||||||
.maxPoint(region.getMaxPoint())
|
|
||||||
.waterLevel(region.getWaterLevel())
|
|
||||||
.run();
|
|
||||||
region.remember(editSession);
|
|
||||||
BauSystem.MESSAGE.send("BACKUP_LOAD", p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "list", description = "BACKUP_HELP_LIST")
|
@Register(value = "list", description = "BACKUP_HELP_LIST")
|
||||||
@ -106,10 +86,10 @@ public class BackupCommand extends SWCommand {
|
|||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<String> backups = listBackup(p);
|
List<RegionBackups.Backup> backups = listBackup(p);
|
||||||
BauSystem.MESSAGE.send("BACKUP_LIST_HEAD", p, backups.size());
|
BauSystem.MESSAGE.send("BACKUP_LIST_HEAD", p, backups.size());
|
||||||
backups.forEach(s -> {
|
backups.forEach(backup -> {
|
||||||
BauSystem.MESSAGE.send("BACKUP_LIST_ENTRY", p, "/backup load " + s, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/backup load " + s), s);
|
BauSystem.MESSAGE.send("BACKUP_LIST_ENTRY", p, "/backup load " + backup.getName(), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/backup load " + backup.getName()), backup.getName());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,34 +99,44 @@ public class BackupCommand extends SWCommand {
|
|||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<String> backups = listBackup(p);
|
List<RegionBackups.Backup> backups = listBackup(p);
|
||||||
List<SWListInv.SWListEntry<String>> swListEntries = new ArrayList<>();
|
List<SWListInv.SWListEntry<RegionBackups.Backup>> swListEntries = new ArrayList<>();
|
||||||
List<String> lore = Arrays.asList(BauSystem.MESSAGE.parse("BACKUP_LORE", p));
|
List<String> lore = Arrays.asList(BauSystem.MESSAGE.parse("BACKUP_LORE", p));
|
||||||
for (int i = 0; i < backups.size(); i++) {
|
for (int i = 0; i < backups.size(); i++) {
|
||||||
String s = backups.get(i);
|
RegionBackups.Backup backup = backups.get(i);
|
||||||
SWItem swItem = new SWItem(Material.BRICK, BauSystem.MESSAGE.parse("BACKUP_ITEM_NAME", p, s), lore, false, clickType -> {});
|
SWItem swItem = new SWItem(Material.BRICK, BauSystem.MESSAGE.parse("BACKUP_ITEM_NAME", p, backup.getName()), lore, false, clickType -> {});
|
||||||
swItem.getItemStack().setAmount(i + 1);
|
swItem.getItemStack().setAmount(i + 1);
|
||||||
swListEntries.add(new SWListInv.SWListEntry<>(swItem, s));
|
swListEntries.add(new SWListInv.SWListEntry<>(swItem, backup));
|
||||||
}
|
}
|
||||||
SWListInv<String> swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("BACKUP_INV_NAME", p), swListEntries, (clickType, s) -> {
|
SWListInv<RegionBackups.Backup> swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("BACKUP_INV_NAME", p), swListEntries, (clickType, s) -> {
|
||||||
p.getOpenInventory().close();
|
p.getOpenInventory().close();
|
||||||
p.performCommand("backup load " + s);
|
backupLoad(p, s);
|
||||||
});
|
});
|
||||||
swListInv.open();
|
swListInv.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mapper(value = "backupName", local = true)
|
@Mapper(value = "backup", local = true)
|
||||||
public TypeMapper<String> backupMapper() {
|
public TypeMapper<RegionBackups.Backup> backupMapper() {
|
||||||
return SWCommandUtils.createMapper(s -> s, (commandSender, s) -> listBackup((Player) commandSender));
|
return new TypeMapper<>() {
|
||||||
|
@Override
|
||||||
|
public RegionBackups.Backup map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||||
|
return Region.getRegion(((Player) commandSender).getLocation()).getBackups().get(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||||
|
return listBackup((Player) sender).stream().map(RegionBackups.Backup::getName).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> listBackup(Player p) {
|
private List<RegionBackups.Backup> listBackup(Player p) {
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return region.listBackup().stream().map(s -> s.substring(0, s.length() - 6).replace(' ', '_')).collect(Collectors.toList());
|
return region.getBackups().list();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.config.BauServer;
|
import de.steamwar.bausystem.config.BauServer;
|
||||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||||
|
import de.steamwar.bausystem.region.FlagOptional;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
@ -56,15 +57,10 @@ public class BauInfoBauGuiItem extends BauGuiItem {
|
|||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
List<String> stringList = new ArrayList<>();
|
List<String> stringList = new ArrayList<>();
|
||||||
for (Flag flag : Flag.getFlags()) {
|
for (Flag flag : Flag.getFlags()) {
|
||||||
if (flag == Flag.PROTECT && region.getFloorLevel() == 0) {
|
if (!region.getFlags().has(flag).isApplicable()) continue;
|
||||||
continue;
|
FlagOptional<?> value = region.getFlags().get(flag);
|
||||||
}
|
if (value.isPresent()) {
|
||||||
if (flag == Flag.ITEMS && Core.getVersion() < 19) {
|
stringList.add(BauSystem.MESSAGE.parse("BAU_INFO_ITEM_LORE_" + flag.name(), player, BauSystem.MESSAGE.parse(value.getWithDefault().getChatValue(), player)));
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Flag.Value<?> value = region.get(flag);
|
|
||||||
if (value != null) {
|
|
||||||
stringList.add(BauSystem.MESSAGE.parse("BAU_INFO_ITEM_LORE_" + flag.name(), player, BauSystem.MESSAGE.parse(value.getChatValue(), player)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
itemStack.setLore(stringList);
|
itemStack.setLore(stringList);
|
||||||
|
|||||||
@ -19,13 +19,11 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.bau;
|
package de.steamwar.bausystem.features.bau;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.command.PreviousArguments;
|
import de.steamwar.command.PreviousArguments;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.techhider.TechHider;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package de.steamwar.bausystem.features.bau;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.config.BauServer;
|
import de.steamwar.bausystem.config.BauServer;
|
||||||
|
import de.steamwar.bausystem.region.FlagOptional;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
@ -30,12 +31,10 @@ public class InfoCommand extends SWCommand {
|
|||||||
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_OWNER", p, SteamwarUser.get(bauServer.getOwnerID()).getUserName());
|
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_OWNER", p, SteamwarUser.get(bauServer.getOwnerID()).getUserName());
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
for (Flag flag : Flag.getFlags()) {
|
for (Flag flag : Flag.getFlags()) {
|
||||||
if (flag == Flag.PROTECT && region.getFloorLevel() == 0) {
|
if (!region.getFlags().has(flag).isApplicable()) continue;
|
||||||
continue;
|
FlagOptional<?> value = region.getFlags().get(flag);
|
||||||
}
|
if (value.isPresent()) {
|
||||||
Flag.Value<?> value = region.get(flag);
|
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_FLAG", p, BauSystem.MESSAGE.parse(flag.getChatValue(), p), BauSystem.MESSAGE.parse(value.getWithDefault().getChatValue(), p));
|
||||||
if (value != null) {
|
|
||||||
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_FLAG", p, BauSystem.MESSAGE.parse(flag.getChatValue(), p), BauSystem.MESSAGE.parse(value.getChatValue(), p));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.features.cannon.depth.Depth;
|
import de.steamwar.bausystem.features.cannon.depth.Depth;
|
||||||
import de.steamwar.bausystem.features.cannon.depth.DepthManager;
|
import de.steamwar.bausystem.features.cannon.depth.DepthManager;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.TNTPrimed;
|
import org.bukkit.entity.TNTPrimed;
|
||||||
@ -85,8 +84,8 @@ public class CannonDetector implements Listener {
|
|||||||
grouped.forEach((cannonKey, tntPrimeds) -> {
|
grouped.forEach((cannonKey, tntPrimeds) -> {
|
||||||
if (tntPrimeds.size() <= 5) return;
|
if (tntPrimeds.size() <= 5) return;
|
||||||
Region region = Region.getRegion(tntPrimeds.get(0).getLocation());
|
Region region = Region.getRegion(tntPrimeds.get(0).getLocation());
|
||||||
if (region.isGlobal()) return;
|
if (region.getType().isGlobal()) return;
|
||||||
if (!region.hasType(RegionType.TESTBLOCK)) return;
|
if (region.getTestblockArea().isEmpty()) return;
|
||||||
Depth depth = new Depth(region);
|
Depth depth = new Depth(region);
|
||||||
DepthManager.init(tntPrimeds, depth);
|
DepthManager.init(tntPrimeds, depth);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -22,7 +22,6 @@ package de.steamwar.bausystem.features.cannon;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.entity.TNTPrimed;
|
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|||||||
@ -23,8 +23,6 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.configplayer.Config;
|
import de.steamwar.bausystem.configplayer.Config;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
@ -50,7 +48,7 @@ public class Depth {
|
|||||||
|
|
||||||
public void update(List<Block> blocks) {
|
public void update(List<Block> blocks) {
|
||||||
List<Block> blocksList = blocks.stream()
|
List<Block> blocksList = blocks.stream()
|
||||||
.filter(block -> region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION))
|
.filter(block -> region.getTestblockArea().inRegion(block.getLocation(), true))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
tntCount++;
|
tntCount++;
|
||||||
for (Block block : blocksList) {
|
for (Block block : blocksList) {
|
||||||
|
|||||||
@ -29,12 +29,11 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
import java.util.stream.Collectors;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class DesignEndStone {
|
public class DesignEndStone {
|
||||||
|
|
||||||
@ -44,18 +43,26 @@ public class DesignEndStone {
|
|||||||
private REntityServer entityServer = new REntityServer();
|
private REntityServer entityServer = new REntityServer();
|
||||||
private List<REntity> entities = new ArrayList<>();
|
private List<REntity> entities = new ArrayList<>();
|
||||||
private Set<Location> locations = new HashSet<>();
|
private Set<Location> locations = new HashSet<>();
|
||||||
private boolean wsOrAs;
|
private Set<Material> limited;
|
||||||
private double maxBlastResistance;
|
private boolean calculateFromBottom;
|
||||||
|
|
||||||
public DesignEndStone(Region region) {
|
public DesignEndStone(Region region) {
|
||||||
this.minX = region.getMinPointBuild().getX();
|
this.minX = region.getBuildArea().getMinPoint(false).getX();
|
||||||
this.minY = region.getMinPointBuild().getY();
|
this.minY = region.getBuildArea().getMinPoint(false).getY();
|
||||||
this.minZ = region.getMinPointBuild().getZ();
|
this.minZ = region.getBuildArea().getMinPoint(false).getZ();
|
||||||
this.maxX = region.getMaxPointBuild().getX();
|
this.maxX = region.getBuildArea().getMaxPoint(false).getX();
|
||||||
this.maxY = region.getMaxPointBuild().getY();
|
this.maxY = region.getBuildArea().getMaxPoint(false).getY();
|
||||||
this.maxZ = region.getMaxPointBuild().getZ();
|
this.maxZ = region.getBuildArea().getMaxPoint(false).getZ();
|
||||||
wsOrAs = region.getName().startsWith("ws") || region.getName().startsWith("as");
|
|
||||||
maxBlastResistance = wsOrAs ? 6.1 : 9.0;
|
limited = region.getGameModeConfig()
|
||||||
|
.getSchematic()
|
||||||
|
.getLimited()
|
||||||
|
.entrySet()
|
||||||
|
.stream()
|
||||||
|
.filter(entry -> entry.getValue() == 0)
|
||||||
|
.flatMap(entry -> entry.getKey().stream())
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
calculateFromBottom = region.getGameModeConfig().getArena().isNoFloor();
|
||||||
|
|
||||||
entityServer.setCallback((player, rEntity, entityAction) -> {
|
entityServer.setCallback((player, rEntity, entityAction) -> {
|
||||||
if (entityAction != REntityServer.EntityAction.ATTACK) return;
|
if (entityAction != REntityServer.EntityAction.ATTACK) return;
|
||||||
@ -76,7 +83,7 @@ public class DesignEndStone {
|
|||||||
calc(minX, minY, maxZ, maxX, maxY, maxZ, 0, 0, -1, maxZ - minZ);
|
calc(minX, minY, maxZ, maxX, maxY, maxZ, 0, 0, -1, maxZ - minZ);
|
||||||
calc(minX, minY, minZ, minX, maxY, maxZ, 1, 0, 0, maxX - minX);
|
calc(minX, minY, minZ, minX, maxY, maxZ, 1, 0, 0, maxX - minX);
|
||||||
calc(maxX, minY, minZ, maxX, maxY, maxZ, -1, 0, 0, maxX - minX);
|
calc(maxX, minY, minZ, maxX, maxY, maxZ, -1, 0, 0, maxX - minX);
|
||||||
if (wsOrAs) {
|
if (calculateFromBottom) {
|
||||||
calc(minX, minY, minZ, maxX, minY, maxZ, 0, 1, 0, maxY - minY + 1);
|
calc(minX, minY, minZ, maxX, minY, maxZ, 0, 1, 0, maxY - minY + 1);
|
||||||
} else {
|
} else {
|
||||||
int airBlocks = 0;
|
int airBlocks = 0;
|
||||||
@ -106,7 +113,7 @@ public class DesignEndStone {
|
|||||||
int cz = z + step * dirZ;
|
int cz = z + step * dirZ;
|
||||||
Material material = WORLD.getBlockAt(cx, cy, cz).getType();
|
Material material = WORLD.getBlockAt(cx, cy, cz).getType();
|
||||||
|
|
||||||
if (material != Material.WATER && material != Material.LAVA && material.getBlastResistance() >= maxBlastResistance) {
|
if (material != Material.WATER && material != Material.LAVA && limited.contains(material)) {
|
||||||
Location location = new Location(WORLD, cx + 0.5, cy, cz + 0.5);
|
Location location = new Location(WORLD, cx + 0.5, cy, cz + 0.5);
|
||||||
if (!locations.add(location)) break;
|
if (!locations.add(location)) break;
|
||||||
RFallingBlockEntity entity = new RFallingBlockEntity(entityServer, location, Material.RED_STAINED_GLASS);
|
RFallingBlockEntity entity = new RFallingBlockEntity(entityServer, location, Material.RED_STAINED_GLASS);
|
||||||
|
|||||||
@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.design.endstone;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
@ -49,7 +48,11 @@ public class DesignEndStoneCommand extends SWCommand implements Listener {
|
|||||||
@Register(description = "DESIGN_ENDSTONE_COMMAND_HELP")
|
@Register(description = "DESIGN_ENDSTONE_COMMAND_HELP")
|
||||||
public void genericCommand(@Validator Player player) {
|
public void genericCommand(@Validator Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (!region.hasType(RegionType.BUILD)) {
|
if (region.getBuildArea().isEmpty()) {
|
||||||
|
BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!region.getGameModeConfig().isLoaded()) {
|
||||||
BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player);
|
BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,12 +4,45 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.SWUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.configplayer.Config;
|
import de.steamwar.bausystem.configplayer.Config;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.inventory.SWInventory;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Barrel;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.block.Chest;
|
||||||
|
import org.bukkit.block.ShulkerBox;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class InventoryFillerCommand extends SWCommand {
|
public class InventoryFillerCommand extends SWCommand {
|
||||||
|
|
||||||
|
private static final Map<Integer, Integer> POWER_TO_FILLLEVEL = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
POWER_TO_FILLLEVEL.put(0, 0);
|
||||||
|
POWER_TO_FILLLEVEL.put(1, 1);
|
||||||
|
POWER_TO_FILLLEVEL.put(2, 1 * 64 + 60);
|
||||||
|
POWER_TO_FILLLEVEL.put(3, 3 * 64 + 55);
|
||||||
|
POWER_TO_FILLLEVEL.put(4, 5 * 64 + 51);
|
||||||
|
POWER_TO_FILLLEVEL.put(5, 7 * 64 + 46);
|
||||||
|
POWER_TO_FILLLEVEL.put(6, 9 * 64 + 42);
|
||||||
|
POWER_TO_FILLLEVEL.put(7, 11 * 64 + 37);
|
||||||
|
POWER_TO_FILLLEVEL.put(8, 13 * 64 + 32);
|
||||||
|
POWER_TO_FILLLEVEL.put(9, 15 * 64 + 28);
|
||||||
|
POWER_TO_FILLLEVEL.put(10, 17 * 64 + 23);
|
||||||
|
POWER_TO_FILLLEVEL.put(11, 19 * 64 + 19);
|
||||||
|
POWER_TO_FILLLEVEL.put(12, 21 * 64 + 14);
|
||||||
|
POWER_TO_FILLLEVEL.put(13, 23 * 64 + 10);
|
||||||
|
POWER_TO_FILLLEVEL.put(14, 25 * 64 + 5);
|
||||||
|
POWER_TO_FILLLEVEL.put(15, 27 * 64 + 0);
|
||||||
|
}
|
||||||
|
|
||||||
public InventoryFillerCommand() {
|
public InventoryFillerCommand() {
|
||||||
super("inventoryfill");
|
super("inventoryfill");
|
||||||
}
|
}
|
||||||
@ -21,8 +54,116 @@ public class InventoryFillerCommand extends SWCommand {
|
|||||||
if (!inventoryFill) {
|
if (!inventoryFill) {
|
||||||
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("INVENTORY_FILL_ENABLE", player));
|
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("INVENTORY_FILL_ENABLE", player));
|
||||||
BauSystem.MESSAGE.send("INVENTORY_FILL_INFO", player);
|
BauSystem.MESSAGE.send("INVENTORY_FILL_INFO", player);
|
||||||
}else {
|
} else {
|
||||||
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("INVENTORY_FILL_DISABLE", player));
|
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("INVENTORY_FILL_DISABLE", player));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Register("gui")
|
||||||
|
public void gui(Player player) {
|
||||||
|
SWInventory inventory = new SWInventory(player, 18, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_NAME", player));
|
||||||
|
inventory.setItem(0, new SWItem(Material.REDSTONE, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 0)).setAmount(1));
|
||||||
|
inventory.setItem(1, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 1)).setAmount(1));
|
||||||
|
inventory.setItem(2, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 2)).setAmount(2));
|
||||||
|
inventory.setItem(3, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 3)).setAmount(3));
|
||||||
|
inventory.setItem(4, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 4)).setAmount(4));
|
||||||
|
inventory.setItem(5, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 5)).setAmount(5));
|
||||||
|
inventory.setItem(6, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 6)).setAmount(6));
|
||||||
|
inventory.setItem(7, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 7)).setAmount(7));
|
||||||
|
inventory.setItem(8, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 8)).setAmount(8));
|
||||||
|
inventory.setItem(9, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 9)).setAmount(9));
|
||||||
|
inventory.setItem(10, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 10)).setAmount(10));
|
||||||
|
inventory.setItem(11, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 11)).setAmount(11));
|
||||||
|
inventory.setItem(12, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 12)).setAmount(12));
|
||||||
|
inventory.setItem(13, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 13)).setAmount(13));
|
||||||
|
inventory.setItem(14, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 14)).setAmount(14));
|
||||||
|
inventory.setItem(15, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 15)).setAmount(15));
|
||||||
|
inventory.setItem(17, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_TNT", player)));
|
||||||
|
|
||||||
|
for (int i = 0; i < 16; i++) {
|
||||||
|
inventory.setEventCallback(i, inventoryClickEvent -> {
|
||||||
|
selectInventoryType(player, inventoryClickEvent.getCurrentItem().getItemMeta().getDisplayName(), Material.DANDELION, POWER_TO_FILLLEVEL.get(inventoryClickEvent.getCurrentItem().getAmount()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
inventory.setEventCallback(17, inventoryClickEvent -> {
|
||||||
|
selectInventoryType(player, inventoryClickEvent.getCurrentItem().getItemMeta().getDisplayName(), Material.TNT, POWER_TO_FILLLEVEL.get(15));
|
||||||
|
});
|
||||||
|
|
||||||
|
inventory.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Material[] SHULKER_BOX_MATERIALS = new Material[]{
|
||||||
|
Material.SHULKER_BOX,
|
||||||
|
Material.WHITE_SHULKER_BOX,
|
||||||
|
Material.LIGHT_GRAY_SHULKER_BOX,
|
||||||
|
Material.GRAY_SHULKER_BOX,
|
||||||
|
Material.BLACK_SHULKER_BOX,
|
||||||
|
Material.BROWN_SHULKER_BOX,
|
||||||
|
Material.RED_SHULKER_BOX,
|
||||||
|
Material.ORANGE_SHULKER_BOX,
|
||||||
|
Material.YELLOW_SHULKER_BOX,
|
||||||
|
Material.LIME_SHULKER_BOX,
|
||||||
|
Material.GREEN_SHULKER_BOX,
|
||||||
|
Material.CYAN_SHULKER_BOX,
|
||||||
|
Material.LIGHT_BLUE_SHULKER_BOX,
|
||||||
|
Material.BLUE_SHULKER_BOX,
|
||||||
|
Material.PURPLE_SHULKER_BOX,
|
||||||
|
Material.MAGENTA_SHULKER_BOX,
|
||||||
|
Material.PINK_SHULKER_BOX
|
||||||
|
};
|
||||||
|
|
||||||
|
private void selectInventoryType(Player player, String name, Material material, int count) {
|
||||||
|
ItemStack[] itemStacks = new ItemStack[27];
|
||||||
|
int index = 0;
|
||||||
|
int amount = count;
|
||||||
|
while (amount > 0) {
|
||||||
|
ItemStack stack;
|
||||||
|
if (amount > 64) {
|
||||||
|
stack = new ItemStack(material, 64);
|
||||||
|
amount -= 64;
|
||||||
|
} else {
|
||||||
|
stack = new ItemStack(material, amount);
|
||||||
|
amount = 0;
|
||||||
|
}
|
||||||
|
itemStacks[index++] = stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
SWInventory inventory = new SWInventory(player, 27, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_NAME", player));
|
||||||
|
int i = 0;
|
||||||
|
for (Material type : SHULKER_BOX_MATERIALS) {
|
||||||
|
inventory.setItemEvent(i++, generateFilledInventory(name, type, itemStacks), inventoryClickEvent -> {
|
||||||
|
SWUtils.giveItemToPlayer(player, inventoryClickEvent.getCurrentItem());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
inventory.setItemEvent(27 - 6, generateFilledInventory(name, Material.CHEST, itemStacks), inventoryClickEvent -> {
|
||||||
|
SWUtils.giveItemToPlayer(player, inventoryClickEvent.getCurrentItem());
|
||||||
|
});
|
||||||
|
inventory.setItemEvent(27 - 4, generateFilledInventory(name, Material.BARREL, itemStacks), inventoryClickEvent -> {
|
||||||
|
SWUtils.giveItemToPlayer(player, inventoryClickEvent.getCurrentItem());
|
||||||
|
});
|
||||||
|
inventory.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ItemStack generateFilledInventory(String name, Material material, ItemStack[] itemStacks) {
|
||||||
|
ItemStack itemStack = new ItemStack(material);
|
||||||
|
BlockStateMeta meta = (BlockStateMeta) itemStack.getItemMeta();
|
||||||
|
BlockState state = meta.getBlockState();
|
||||||
|
|
||||||
|
if (state instanceof ShulkerBox box) {
|
||||||
|
box.getInventory().setContents(itemStacks);
|
||||||
|
box.update();
|
||||||
|
meta.setBlockState(box);
|
||||||
|
} else if (state instanceof Chest chest) {
|
||||||
|
chest.getInventory().setContents(itemStacks);
|
||||||
|
chest.update();
|
||||||
|
meta.setBlockState(chest);
|
||||||
|
} else if (state instanceof Barrel barrel) {
|
||||||
|
barrel.getInventory().setContents(itemStacks);
|
||||||
|
barrel.update();
|
||||||
|
meta.setBlockState(barrel);
|
||||||
|
}
|
||||||
|
meta.setDisplayName(name);
|
||||||
|
itemStack.setItemMeta(meta);
|
||||||
|
return itemStack;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class KillcheckerCommand extends SWCommand implements Listener {
|
public class KillcheckerCommand extends SWCommand implements Listener {
|
||||||
@ -57,6 +56,10 @@ public class KillcheckerCommand extends SWCommand implements Listener {
|
|||||||
@Register(value = "enable", description = "KILLCHECKER_HELP_ENABLE")
|
@Register(value = "enable", description = "KILLCHECKER_HELP_ENABLE")
|
||||||
public void genericCommand(@Validator Player player, @OptionalValue("-outline") @StaticValue(value = {"-area", "-outline"}, allowISE = true) boolean onlyOutline) {
|
public void genericCommand(@Validator Player player, @OptionalValue("-outline") @StaticValue(value = {"-area", "-outline"}, allowISE = true) boolean onlyOutline) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
|
if (region.getBuildArea().isEmpty()) {
|
||||||
|
BauSystem.MESSAGE.send("KILLCHECKER_NO_BUILD", player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
KillcheckerVisualizer killcheckerVisualizer = visualizers.computeIfAbsent(region, region1 -> new KillcheckerVisualizer(region1, bossBarService));
|
KillcheckerVisualizer killcheckerVisualizer = visualizers.computeIfAbsent(region, region1 -> new KillcheckerVisualizer(region1, bossBarService));
|
||||||
killcheckerVisualizer.recalc();
|
killcheckerVisualizer.recalc();
|
||||||
killcheckerVisualizer.show(player, onlyOutline);
|
killcheckerVisualizer.show(player, onlyOutline);
|
||||||
|
|||||||
@ -22,8 +22,6 @@ package de.steamwar.bausystem.features.killchecker;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.region.Point;
|
import de.steamwar.bausystem.region.Point;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
||||||
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
||||||
import de.steamwar.entity.REntity;
|
import de.steamwar.entity.REntity;
|
||||||
@ -75,8 +73,8 @@ public class KillcheckerVisualizer {
|
|||||||
|
|
||||||
public KillcheckerVisualizer(Region region, BossBarService bossBarService) {
|
public KillcheckerVisualizer(Region region, BossBarService bossBarService) {
|
||||||
this.region = region;
|
this.region = region;
|
||||||
this.minPoint = region.getMinPoint(RegionType.BUILD, RegionExtensionType.NORMAL);
|
this.minPoint = region.getBuildArea().getMinPoint(false);
|
||||||
this.maxPoint = region.getMaxPoint(RegionType.BUILD, RegionExtensionType.NORMAL);
|
this.maxPoint = region.getBuildArea().getMaxPoint(false);
|
||||||
|
|
||||||
yArea = (maxPoint.getX() - minPoint.getX()) * (maxPoint.getZ() - minPoint.getZ());
|
yArea = (maxPoint.getX() - minPoint.getX()) * (maxPoint.getZ() - minPoint.getZ());
|
||||||
zArea = (maxPoint.getX() - minPoint.getX()) * (maxPoint.getY() - minPoint.getY());
|
zArea = (maxPoint.getX() - minPoint.getX()) * (maxPoint.getY() - minPoint.getY());
|
||||||
|
|||||||
@ -73,7 +73,7 @@ public class Loader implements Listener {
|
|||||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance());
|
Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance());
|
||||||
|
|
||||||
BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
|
BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
|
||||||
if (stage != Stage.RUNNING) return;
|
if (stage != Stage.RUNNING && stage != Stage.SINGLE) return;
|
||||||
if(!Permission.BUILD.hasPermission(p)) return;
|
if(!Permission.BUILD.hasPermission(p)) return;
|
||||||
if (waitTime > 0) {
|
if (waitTime > 0) {
|
||||||
waitTime--;
|
waitTime--;
|
||||||
@ -149,13 +149,16 @@ public class Loader implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean setTicksBetweenShots(int delay) {
|
public boolean setTicksBetweenShots(int delay) {
|
||||||
if (elements.size() == 0) return false;
|
if (elements.isEmpty()) return false;
|
||||||
LoaderElement loaderElement = elements.get(elements.size() - 1);
|
LoaderElement loaderElement = elements.get(elements.size() - 1);
|
||||||
if (loaderElement instanceof LoaderWait) {
|
if (loaderElement instanceof LoaderWait) {
|
||||||
((LoaderWait) loaderElement).setDelay(delay);
|
((LoaderWait) loaderElement).setDelay(delay);
|
||||||
return true;
|
} else {
|
||||||
|
LoaderWait loaderWait = new LoaderWait(delay);
|
||||||
|
elements.add(loaderWait);
|
||||||
|
pause();
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTicksBetweenBlocks(int delay) {
|
public void setTicksBetweenBlocks(int delay) {
|
||||||
|
|||||||
@ -44,7 +44,6 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
public class LoaderRecorder implements Listener {
|
public class LoaderRecorder implements Listener {
|
||||||
|
|
||||||
|
|||||||
@ -22,8 +22,6 @@ package de.steamwar.bausystem.features.loadtimer;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -158,7 +156,7 @@ public class Loadtimer implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onTntExplode(EntityExplodeEvent event) {
|
public void onTntExplode(EntityExplodeEvent event) {
|
||||||
if (region.inRegion(event.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION) && stage == Stage.IGNITION) {
|
if (region.getBuildArea().inRegion(event.getLocation(), true) && stage == Stage.IGNITION) {
|
||||||
stage = Stage.END;
|
stage = Stage.END;
|
||||||
explode = TPSUtils.currentRealTick.get();
|
explode = TPSUtils.currentRealTick.get();
|
||||||
print();
|
print();
|
||||||
|
|||||||
@ -39,7 +39,7 @@ public class LoadtimerCommand extends SWCommand {
|
|||||||
@Register(value = "start", description = {"LOADTIMER_HELP_START_2", "LOADTIMER_HELP_START_3"})
|
@Register(value = "start", description = {"LOADTIMER_HELP_START_2", "LOADTIMER_HELP_START_3"})
|
||||||
public void start(@Validator Player p, TimerMode mode) {
|
public void start(@Validator Player p, TimerMode mode) {
|
||||||
Region r = Region.getRegion(p.getLocation());
|
Region r = Region.getRegion(p.getLocation());
|
||||||
if (r.isGlobal()) return;
|
if (r.getType().isGlobal()) return;
|
||||||
if (!Loadtimer.hasTimer(r))
|
if (!Loadtimer.hasTimer(r))
|
||||||
Loadtimer.createLoadtimer(r, mode == TimerMode.HALF);
|
Loadtimer.createLoadtimer(r, mode == TimerMode.HALF);
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ public class LoadtimerCommand extends SWCommand {
|
|||||||
@Register(value = "stop", description = "LOADTIMER_HELP_STOP")
|
@Register(value = "stop", description = "LOADTIMER_HELP_STOP")
|
||||||
public void stop(@Validator Player p) {
|
public void stop(@Validator Player p) {
|
||||||
Region r = Region.getRegion(p.getLocation());
|
Region r = Region.getRegion(p.getLocation());
|
||||||
if (r.isGlobal()) return;
|
if (r.getType().isGlobal()) return;
|
||||||
if (Loadtimer.hasTimer(r))
|
if (Loadtimer.hasTimer(r))
|
||||||
Loadtimer.getTimer(r).delete();
|
Loadtimer.getTimer(r).delete();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,7 +46,7 @@ public class LoadtimerGuiItem extends BauGuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(Player player) {
|
public ItemStack getItem(Player player) {
|
||||||
Region r = Region.getRegion(player.getLocation());
|
Region r = Region.getRegion(player.getLocation());
|
||||||
if (r.isGlobal())
|
if (r.getType().isGlobal())
|
||||||
return new SWItem(Material.BOWL, BauSystem.MESSAGE.parse("LOADTIMER_GUI_GLOBAL", player)).getItemStack();
|
return new SWItem(Material.BOWL, BauSystem.MESSAGE.parse("LOADTIMER_GUI_GLOBAL", player)).getItemStack();
|
||||||
if (Loadtimer.hasTimer(r)) {
|
if (Loadtimer.hasTimer(r)) {
|
||||||
return new SWItem(Material.BOW, BauSystem.MESSAGE.parse("LOADTIMER_GUI_STOP", player)).getItemStack();
|
return new SWItem(Material.BOW, BauSystem.MESSAGE.parse("LOADTIMER_GUI_STOP", player)).getItemStack();
|
||||||
@ -58,7 +58,7 @@ public class LoadtimerGuiItem extends BauGuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public boolean click(ClickType click, Player p) {
|
public boolean click(ClickType click, Player p) {
|
||||||
Region r = Region.getRegion(p.getLocation());
|
Region r = Region.getRegion(p.getLocation());
|
||||||
if (r.isGlobal()) return false;
|
if (r.getType().isGlobal()) return false;
|
||||||
if (Loadtimer.hasTimer(r)) {
|
if (Loadtimer.hasTimer(r)) {
|
||||||
p.performCommand("lt stop");
|
p.performCommand("lt stop");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -20,7 +20,6 @@
|
|||||||
package de.steamwar.bausystem.features.observer;
|
package de.steamwar.bausystem.features.observer;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|||||||
@ -0,0 +1,207 @@
|
|||||||
|
/*
|
||||||
|
* 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.features.rayvisualizer;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
|
import de.steamwar.bausystem.SWUtils;
|
||||||
|
import de.steamwar.bausystem.configplayer.Config;
|
||||||
|
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.entity.CRay;
|
||||||
|
import de.steamwar.entity.REntityServer;
|
||||||
|
import de.steamwar.linkage.Linked;
|
||||||
|
import de.steamwar.linkage.MinVersion;
|
||||||
|
import org.bukkit.*;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.TNTPrimed;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.util.RayTraceResult;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Linked
|
||||||
|
@MinVersion(20)
|
||||||
|
public class RayVisualizerCommand extends SWCommand implements Listener {
|
||||||
|
|
||||||
|
private BlockData VISIBLE = Material.LIME_CONCRETE.createBlockData();
|
||||||
|
private BlockData BLOCKED = Material.RED_CONCRETE.createBlockData();
|
||||||
|
|
||||||
|
private class CRayData {
|
||||||
|
private CRay[] rays = new CRay[27 * 400];
|
||||||
|
private boolean[] used = new boolean[27 * 400];
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
for (int i = 0; i < 27 * 400; i++) {
|
||||||
|
if (!used[i] && rays[i] != null) {
|
||||||
|
rays[i].die();
|
||||||
|
rays[i] = null;
|
||||||
|
}
|
||||||
|
used[i] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean locEquals(Location loc1, Location loc2) {
|
||||||
|
if ((long)(loc1.getX() * 1000) != (long)(loc2.getX() * 1000)) return false;
|
||||||
|
if ((long)(loc1.getY() * 1000) != (long)(loc2.getY() * 1000)) return false;
|
||||||
|
if ((long)(loc1.getZ() * 1000) != (long)(loc2.getZ() * 1000)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CRay get(Location from, Location to) {
|
||||||
|
for (int i = 0; i < rays.length; i++) {
|
||||||
|
if (rays[i] != null && locEquals(from, rays[i].getFrom()) && locEquals(to, rays[i].getTo())) {
|
||||||
|
used[i] = true;
|
||||||
|
return rays[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < rays.length; i++) {
|
||||||
|
if (rays[i] != null && locEquals(from, rays[i].getFrom()) && !used[i]) {
|
||||||
|
used[i] = true;
|
||||||
|
return rays[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < rays.length; i++) {
|
||||||
|
if (used[i]) continue;
|
||||||
|
CRay ray = rays[i];
|
||||||
|
if (ray != null) {
|
||||||
|
return ray;
|
||||||
|
}
|
||||||
|
ray = new CRay(server);
|
||||||
|
ray.setBlock(Material.LIME_CONCRETE.createBlockData());
|
||||||
|
ray.setWidth(1 / 32f);
|
||||||
|
rays[i] = ray;
|
||||||
|
used[i] = true;
|
||||||
|
return ray;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private CRayData rayData = new CRayData();
|
||||||
|
|
||||||
|
private final REntityServer server = new REntityServer();
|
||||||
|
private final World WORLD = Bukkit.getWorlds().get(0);
|
||||||
|
|
||||||
|
public RayVisualizerCommand() {
|
||||||
|
super("rayvisualizer");
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
|
||||||
|
if (server.getPlayers().isEmpty()) return;
|
||||||
|
List<TNTPrimed> primedList = WORLD.getEntitiesByClass(TNTPrimed.class)
|
||||||
|
.stream().toList();
|
||||||
|
rayData.reset();
|
||||||
|
if (primedList.isEmpty()) return;
|
||||||
|
calculateRays(primedList, primedList);
|
||||||
|
}, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void calculateRays(List<TNTPrimed> fromTNTs, List<TNTPrimed> toTNTs) {
|
||||||
|
for (TNTPrimed to : toTNTs) {
|
||||||
|
int hitting = 0;
|
||||||
|
int total = 0;
|
||||||
|
for (TNTPrimed from : fromTNTs) {
|
||||||
|
if (from == to) continue;
|
||||||
|
if (from.getFuseTicks() >= to.getFuseTicks()) continue;
|
||||||
|
if (to.getLocation().distanceSquared(from.getLocation()) > 25) continue;
|
||||||
|
if (!from.isInWater()) continue;
|
||||||
|
|
||||||
|
Location fromLoc = from.getLocation();
|
||||||
|
Location toLoc = to.getLocation().clone().add(-0.49, 0, -0.49);
|
||||||
|
|
||||||
|
final double minX = 0.5 * (1 - Math.floor(2 * 0.98 + 1) / (2 * 0.98 + 1));
|
||||||
|
final double minZ = 0.5 * (1 - Math.floor(2 * 0.98 + 1) / (2 * 0.98 + 1));
|
||||||
|
final double spacing = 0.98 / (2 * 0.98 + 1);
|
||||||
|
|
||||||
|
for (int dx = 0; dx < 3; dx++) {
|
||||||
|
for (int dy = 0; dy < 3; dy++) {
|
||||||
|
for (int dz = 0; dz < 3; dz++) {
|
||||||
|
Location end = toLoc.clone().add(minX + dx * spacing, 0 + dy * spacing, minZ + dz * spacing);
|
||||||
|
RayTraceResult result = fromLoc.getWorld().rayTraceBlocks(fromLoc, end.clone().subtract(fromLoc).toVector(), end.distance(fromLoc), FluidCollisionMode.NEVER, true);
|
||||||
|
CRay cRay = rayData.get(fromLoc, end);
|
||||||
|
if (cRay == null) continue;
|
||||||
|
cRay.setFrom(fromLoc);
|
||||||
|
cRay.setTo(end);
|
||||||
|
if (result != null && result.getHitBlock() != null) {
|
||||||
|
cRay.setBlock(BLOCKED);
|
||||||
|
} else {
|
||||||
|
cRay.setBlock(VISIBLE);
|
||||||
|
hitting++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
total += 27;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (total == 0) {
|
||||||
|
to.setCustomNameVisible(false);
|
||||||
|
} else {
|
||||||
|
int remainder = hitting % 27;
|
||||||
|
int whole = hitting / 27;
|
||||||
|
to.setCustomNameVisible(true);
|
||||||
|
to.setCustomName("§e" + whole + " " + remainder + "/27");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
|
boolean rayvisualizer = Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("rayvisualizer", false);
|
||||||
|
if (rayvisualizer) server.addPlayer(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
server.removePlayer(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBauMemberUpdate(BauMemberUpdateEvent event) {
|
||||||
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (Permission.BUILD.hasPermission(player)) {
|
||||||
|
boolean rayvisualizer = Config.getInstance().get(player).getPlainValueOrDefault("rayvisualizer", false);
|
||||||
|
if (rayvisualizer) server.addPlayer(player);
|
||||||
|
} else {
|
||||||
|
server.removePlayer(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void toggle(@Validator Player player) {
|
||||||
|
boolean rayvisualizer = Config.getInstance().get(player).getPlainValueOrDefault("rayvisualizer", false);
|
||||||
|
Config.getInstance().get(player).put("rayvisualizer", !rayvisualizer);
|
||||||
|
if (!rayvisualizer) {
|
||||||
|
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("RAY_VISUALIZER_ENABLE", player));
|
||||||
|
server.addPlayer(player);
|
||||||
|
} else {
|
||||||
|
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("RAY_VISUALIZER_DISABLE", player));
|
||||||
|
server.removePlayer(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -23,8 +23,8 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.config.BauServer;
|
import de.steamwar.bausystem.config.BauServer;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
|
import de.steamwar.bausystem.region.flags.ColorMode;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
import de.steamwar.bausystem.region.utils.RegionType;
|
||||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||||
@ -34,8 +34,6 @@ import de.steamwar.linkage.Linked;
|
|||||||
import de.steamwar.linkage.LinkedInstance;
|
import de.steamwar.linkage.LinkedInstance;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class ColorCommand extends SWCommand {
|
public class ColorCommand extends SWCommand {
|
||||||
|
|
||||||
@ -47,29 +45,31 @@ public class ColorCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "REGION_COLOR_HELP_COLOR")
|
@Register(description = "REGION_COLOR_HELP_COLOR")
|
||||||
public void genericColor(Player p, ColorMode color) {
|
public void genericColor(@Validator Player p, ColorMode color) {
|
||||||
genericColorSet(p, color, ColorizationType.LOCAL);
|
genericColorSet(p, color, ColorizationType.LOCAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "REGION_COLOR_HELP_COLOR_TYPE")
|
@Register(description = "REGION_COLOR_HELP_COLOR_TYPE")
|
||||||
public void genericColorSet(@Validator Player p, ColorMode color, ColorizationType colorizationType) {
|
public void genericColorSet(@Validator Player p, ColorMode color, ColorizationType colorizationType) {
|
||||||
if (colorizationType == ColorizationType.GLOBAL) {
|
if (colorizationType == ColorizationType.GLOBAL) {
|
||||||
Region.setGlobal(Flag.COLOR, color);
|
Region.getRegions().forEach(region -> {
|
||||||
|
region.getFlags().set(Flag.COLOR, color);
|
||||||
|
});
|
||||||
BauSystem.MESSAGE.send("REGION_COLOR_GLOBAL", p, BauSystem.MESSAGE.parse(color.getChatValue(), p));
|
BauSystem.MESSAGE.send("REGION_COLOR_GLOBAL", p, BauSystem.MESSAGE.parse(color.getChatValue(), p));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
if (region.isGlobal()) {
|
if (!region.getFlags().has(Flag.COLOR).isWritable()) {
|
||||||
BauSystem.MESSAGE.send("REGION_COLOR_NO_REGION", p);
|
BauSystem.MESSAGE.send("REGION_COLOR_NO_REGION", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
region.set(Flag.COLOR, color);
|
region.getFlags().set(Flag.COLOR, color);
|
||||||
try {
|
try {
|
||||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL)))
|
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile()))
|
||||||
.ignoreAir(true)
|
.ignoreAir(true)
|
||||||
.onlyColors(true)
|
.onlyColors(true)
|
||||||
.color(color.getColor());
|
.color(color);
|
||||||
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
region.getArea().reset(pasteBuilder, false);
|
||||||
RegionUtils.message(region, "REGION_REGION_COLORED");
|
RegionUtils.message(region, "REGION_REGION_COLORED");
|
||||||
RegionUtils.message(region, "REGION_REGION_COLORED_FAILED");
|
RegionUtils.message(region, "REGION_REGION_COLORED_FAILED");
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
@ -78,7 +78,7 @@ public class ColorCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void genericColorSet(Player p, ColorizationType colorizationType, ColorMode color) {
|
public void genericColorSet(@Validator Player p, ColorizationType colorizationType, ColorMode color) {
|
||||||
genericColorSet(p, color, colorizationType);
|
genericColorSet(p, color, colorizationType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,13 +19,11 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.region;
|
package de.steamwar.bausystem.features.region;
|
||||||
|
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
|
import de.steamwar.bausystem.region.flags.FireMode;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.FireMode;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -55,14 +53,12 @@ public class FireCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean toggle(Region region) {
|
private boolean toggle(Region region) {
|
||||||
switch (region.getPlain(Flag.FIRE, FireMode.class)) {
|
if (region.getFlags().get(Flag.FIRE).isWithDefault(FireMode.ALLOW)) {
|
||||||
case ALLOW:
|
region.getFlags().set(Flag.FIRE, FireMode.DENY);
|
||||||
region.set(Flag.FIRE, FireMode.DENY);
|
return true;
|
||||||
return true;
|
} else {
|
||||||
default:
|
region.getFlags().set(Flag.FIRE, FireMode.ALLOW);
|
||||||
case DENY:
|
return false;
|
||||||
region.set(Flag.FIRE, FireMode.ALLOW);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,8 +2,8 @@ package de.steamwar.bausystem.features.region;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
import de.steamwar.bausystem.region.flags.FireMode;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.FireMode;
|
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -17,12 +17,12 @@ public class FireListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFireDamage(BlockBurnEvent e) {
|
public void onFireDamage(BlockBurnEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).getPlain(Flag.FIRE, FireMode.class) == FireMode.DENY) e.setCancelled(true);
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FIRE).isWithDefault(FireMode.DENY)) e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFireSpread(BlockSpreadEvent e) {
|
public void onFireSpread(BlockSpreadEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).getPlain(Flag.FIRE, FireMode.class) == FireMode.DENY) e.setCancelled(true);
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FIRE).isWithDefault(FireMode.DENY)) e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -37,7 +37,7 @@ public class FireListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
if (region.get(Flag.FIRE) == Flag.FIRE.getDefaultValue()) return null;
|
if (region.getFlags().get(Flag.FIRE).isWithDefault(FireMode.DENY)) return null;
|
||||||
return "§e" + BauSystem.MESSAGE.parse(Flag.FIRE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.FIRE).getChatValue(), p);
|
return "§e" + BauSystem.MESSAGE.parse(Flag.FIRE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.FIRE).getWithDefault().getChatValue(), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,13 +19,11 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.region;
|
package de.steamwar.bausystem.features.region;
|
||||||
|
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
|
import de.steamwar.bausystem.region.flags.FreezeMode;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -55,14 +53,12 @@ public class FreezeCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean toggle(Region region) {
|
private boolean toggle(Region region) {
|
||||||
switch (region.getPlain(Flag.FREEZE, FreezeMode.class)) {
|
if (region.getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
case ACTIVE:
|
region.getFlags().set(Flag.FREEZE, FreezeMode.INACTIVE);
|
||||||
region.set(Flag.FREEZE, FreezeMode.INACTIVE);
|
return false;
|
||||||
return false;
|
} else {
|
||||||
default:
|
region.getFlags().set(Flag.FREEZE, FreezeMode.ACTIVE);
|
||||||
case INACTIVE:
|
return true;
|
||||||
region.set(Flag.FREEZE, FreezeMode.ACTIVE);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package de.steamwar.bausystem.features.region;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
|
import de.steamwar.bausystem.region.flags.FreezeMode;
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.core.TrickyTrialsWrapper;
|
import de.steamwar.core.TrickyTrialsWrapper;
|
||||||
@ -29,9 +29,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntitySpawn(EntitySpawnEvent e) {
|
public void onEntitySpawn(EntitySpawnEvent e) {
|
||||||
if (Region.getRegion(e.getLocation()).get(Flag.FREEZE) == FreezeMode.INACTIVE) {
|
if (Region.getRegion(e.getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
if (e.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) {
|
if (e.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) {
|
||||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
@ -43,8 +41,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockCanBuild(BlockCanBuildEvent e) {
|
public void onBlockCanBuild(BlockCanBuildEvent e) {
|
||||||
if (!e.isBuildable()) return;
|
if (!e.isBuildable()) return;
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.INACTIVE)
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return;
|
||||||
return;
|
|
||||||
if (e.getMaterial() == Material.TNT) {
|
if (e.getMaterial() == Material.TNT) {
|
||||||
e.setBuildable(false);
|
e.setBuildable(false);
|
||||||
e.getBlock().setType(Material.TNT, false);
|
e.getBlock().setType(Material.TNT, false);
|
||||||
@ -53,14 +50,14 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
|
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPhysicsEvent(BlockPhysicsEvent e) {
|
public void onPhysicsEvent(BlockPhysicsEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
if (e.getSourceBlock().getType() == Material.NOTE_BLOCK) {
|
if (e.getSourceBlock().getType() == Material.NOTE_BLOCK) {
|
||||||
BlockState state = e.getSourceBlock().getState();
|
BlockState state = e.getSourceBlock().getState();
|
||||||
NoteBlock noteBlock = (NoteBlock) state.getBlockData();
|
NoteBlock noteBlock = (NoteBlock) state.getBlockData();
|
||||||
@ -85,143 +82,44 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPistonExtend(BlockPistonExtendEvent e) {
|
public void onPistonExtend(BlockPistonExtendEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onNotePlay(NotePlayEvent event) {
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=45, z=98},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=44, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=97},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=99},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=97},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=96},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=99},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-108, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=45, z=98},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-104, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
|
||||||
|
|
||||||
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=49, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
////[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=102},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-108, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-104, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPistonRetract(BlockPistonRetractEvent e) {
|
public void onPistonRetract(BlockPistonRetractEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockGrow(BlockGrowEvent e) {
|
public void onBlockGrow(BlockGrowEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onRedstoneEvent(BlockRedstoneEvent e) {
|
public void onRedstoneEvent(BlockRedstoneEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setNewCurrent(e.getOldCurrent());
|
e.setNewCurrent(e.getOldCurrent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockDispense(BlockDispenseEvent e) {
|
public void onBlockDispense(BlockDispenseEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryMoveEvent(InventoryMoveItemEvent e) {
|
public void onInventoryMoveEvent(InventoryMoveItemEvent e) {
|
||||||
if (e.getDestination().getLocation() != null && Region.getRegion(e.getDestination().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (e.getDestination().getLocation() != null && Region.getRegion(e.getDestination().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
} else if (e.getSource().getLocation() != null && Region.getRegion(e.getSource().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
} else if (e.getSource().getLocation() != null && Region.getRegion(e.getSource().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -230,7 +128,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
public void onBlockBreak(BlockBreakEvent e) {
|
public void onBlockBreak(BlockBreakEvent e) {
|
||||||
if (Core.getVersion() < 19) return;
|
if (Core.getVersion() < 19) return;
|
||||||
if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return;
|
if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return;
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
e.getBlock().setType(Material.BARRIER, false);
|
e.getBlock().setType(Material.BARRIER, false);
|
||||||
e.getBlock().setType(Material.AIR, false);
|
e.getBlock().setType(Material.AIR, false);
|
||||||
@ -253,35 +151,35 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFluidLevelChange(FluidLevelChangeEvent e) {
|
public void onFluidLevelChange(FluidLevelChangeEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockSpread(BlockSpreadEvent e) {
|
public void onBlockSpread(BlockSpreadEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockFromTo(BlockFromToEvent e) {
|
public void onBlockFromTo(BlockFromToEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onSpongeAbsorb(SpongeAbsorbEvent e) {
|
public void onSpongeAbsorb(SpongeAbsorbEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockForm(BlockFormEvent e) {
|
public void onBlockForm(BlockFormEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -289,7 +187,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent e) {
|
public void onPlayerInteract(PlayerInteractEvent e) {
|
||||||
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
||||||
if (Region.getRegion(e.getClickedBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getClickedBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
Block block = e.getClickedBlock();
|
Block block = e.getClickedBlock();
|
||||||
if (block.getType() == Material.LEVER) {
|
if (block.getType() == Material.LEVER) {
|
||||||
Switch data = ((Switch) block.getBlockData());
|
Switch data = ((Switch) block.getBlockData());
|
||||||
@ -300,9 +198,9 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockFade(BlockFadeEvent event) {
|
public void onBlockFade(BlockFadeEvent e) {
|
||||||
if (Region.getRegion(event.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
event.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,7 +216,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
if (region.get(Flag.FREEZE) == Flag.FREEZE.getDefaultValue()) return null;
|
if (region.getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return null;
|
||||||
return "§e" + BauSystem.MESSAGE.parse(Flag.FREEZE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.FREEZE).getChatValue(), p);
|
return "§e" + BauSystem.MESSAGE.parse(Flag.FREEZE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.FREEZE).getWithDefault().getChatValue(), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,14 +19,11 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.region;
|
package de.steamwar.bausystem.features.region;
|
||||||
|
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.bausystem.region.GlobalRegion;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ItemMode;
|
import de.steamwar.bausystem.region.flags.ItemMode;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.MinVersion;
|
import de.steamwar.linkage.MinVersion;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -58,14 +55,12 @@ public class ItemsCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean toggle(Region region) {
|
private boolean toggle(Region region) {
|
||||||
switch (region.getPlain(Flag.ITEMS, ItemMode.class)) {
|
if (region.getFlags().get(Flag.ITEMS).isWithDefault(ItemMode.ACTIVE)) {
|
||||||
case ACTIVE:
|
region.getFlags().set(Flag.ITEMS, ItemMode.INACTIVE);
|
||||||
region.set(Flag.ITEMS, ItemMode.INACTIVE);
|
return false;
|
||||||
return false;
|
} else {
|
||||||
default:
|
region.getFlags().set(Flag.ITEMS, ItemMode.ACTIVE);
|
||||||
case INACTIVE:
|
return true;
|
||||||
region.set(Flag.ITEMS, ItemMode.ACTIVE);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ package de.steamwar.bausystem.features.region;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ItemMode;
|
import de.steamwar.bausystem.region.flags.ItemMode;
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.MinVersion;
|
import de.steamwar.linkage.MinVersion;
|
||||||
@ -35,13 +35,9 @@ import org.bukkit.event.entity.ItemSpawnEvent;
|
|||||||
@MinVersion(19)
|
@MinVersion(19)
|
||||||
public class ItemsListener implements Listener, ScoreboardElement {
|
public class ItemsListener implements Listener, ScoreboardElement {
|
||||||
|
|
||||||
private static ItemMode getMode(Region region) {
|
|
||||||
return region.getPlain(Flag.ITEMS, ItemMode.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onItemSpawn(ItemSpawnEvent event) {
|
public void onItemSpawn(ItemSpawnEvent event) {
|
||||||
if (getMode(Region.getRegion(event.getLocation())) == ItemMode.INACTIVE) {
|
if (Region.getRegion(event.getLocation()).getFlags().get(Flag.ITEMS).isWithDefault(ItemMode.INACTIVE)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,7 +54,7 @@ public class ItemsListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
if (region.get(Flag.ITEMS) == Flag.ITEMS.getDefaultValue()) return null;
|
if (region.getFlags().get(Flag.ITEMS).isWithDefault(ItemMode.INACTIVE)) return null;
|
||||||
return "§e" + BauSystem.MESSAGE.parse(Flag.ITEMS.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.ITEMS).getChatValue(), p);
|
return "§e" + BauSystem.MESSAGE.parse(Flag.ITEMS.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.ITEMS).getWithDefault().getChatValue(), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ package de.steamwar.bausystem.features.region;
|
|||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.NoGravityMode;
|
import de.steamwar.bausystem.region.flags.NoGravityMode;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -53,14 +53,12 @@ public class NoGravityCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean toggle(Region region) {
|
private boolean toggle(Region region) {
|
||||||
switch (region.getPlain(Flag.NO_GRAVITY, NoGravityMode.class)) {
|
if (region.getFlags().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.ACTIVE)) {
|
||||||
case ACTIVE:
|
region.getFlags().set(Flag.NO_GRAVITY, NoGravityMode.INACTIVE);
|
||||||
region.set(Flag.NO_GRAVITY, NoGravityMode.INACTIVE);
|
return false;
|
||||||
return false;
|
} else {
|
||||||
default:
|
region.getFlags().set(Flag.NO_GRAVITY, NoGravityMode.ACTIVE);
|
||||||
case INACTIVE:
|
return true;
|
||||||
region.set(Flag.NO_GRAVITY, NoGravityMode.ACTIVE);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ package de.steamwar.bausystem.features.region;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.NoGravityMode;
|
import de.steamwar.bausystem.region.flags.NoGravityMode;
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
@ -34,14 +34,10 @@ import org.bukkit.event.entity.EntitySpawnEvent;
|
|||||||
@Linked
|
@Linked
|
||||||
public class NoGravityListener implements Listener, ScoreboardElement {
|
public class NoGravityListener implements Listener, ScoreboardElement {
|
||||||
|
|
||||||
private static NoGravityMode getMode(Region region) {
|
|
||||||
return region.getPlain(Flag.NO_GRAVITY, NoGravityMode.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntitySpawn(EntitySpawnEvent event) {
|
public void onEntitySpawn(EntitySpawnEvent event) {
|
||||||
if (event.getEntityType() == EntityType.PLAYER) return;
|
if (event.getEntityType() == EntityType.PLAYER) return;
|
||||||
if (getMode(Region.getRegion(event.getLocation())) == NoGravityMode.ACTIVE) {
|
if (Region.getRegion(event.getLocation()).getFlags().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.ACTIVE)) {
|
||||||
event.getEntity().setGravity(false);
|
event.getEntity().setGravity(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,7 +54,7 @@ public class NoGravityListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
if (region.get(Flag.NO_GRAVITY) == Flag.NO_GRAVITY.getDefaultValue()) return null;
|
if (region.getFlags().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.INACTIVE)) return null;
|
||||||
return "§e" + BauSystem.MESSAGE.parse(Flag.NO_GRAVITY.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.NO_GRAVITY).getChatValue(), p);
|
return "§e" + BauSystem.MESSAGE.parse(Flag.NO_GRAVITY.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.NO_GRAVITY).getWithDefault().getChatValue(), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,13 +20,11 @@
|
|||||||
package de.steamwar.bausystem.features.region;
|
package de.steamwar.bausystem.features.region;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode;
|
import de.steamwar.bausystem.region.flags.ProtectMode;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -41,22 +39,18 @@ public class ProtectCommand extends SWCommand {
|
|||||||
public void genericProtectCommand(@Validator Player p) {
|
public void genericProtectCommand(@Validator Player p) {
|
||||||
Region region = regionCheck(p);
|
Region region = regionCheck(p);
|
||||||
if (region == null) return;
|
if (region == null) return;
|
||||||
switch (region.getPlain(Flag.PROTECT, ProtectMode.class)) {
|
if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.ACTIVE)) {
|
||||||
case ACTIVE:
|
region.getFlags().set(Flag.PROTECT, ProtectMode.INACTIVE);
|
||||||
region.set(Flag.PROTECT, ProtectMode.INACTIVE);
|
RegionUtils.actionBar(region, "REGION_PROTECT_DISABLE");
|
||||||
RegionUtils.actionBar(region, "REGION_PROTECT_DISABLE");
|
} else {
|
||||||
break;
|
region.getFlags().set(Flag.PROTECT, ProtectMode.ACTIVE);
|
||||||
default:
|
RegionUtils.actionBar(region, "REGION_PROTECT_ENABLE");
|
||||||
case INACTIVE:
|
|
||||||
region.set(Flag.PROTECT, ProtectMode.ACTIVE);
|
|
||||||
RegionUtils.actionBar(region, "REGION_PROTECT_ENABLE");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Region regionCheck(Player player) {
|
private Region regionCheck(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region.getFloorLevel() == 0) {
|
if (!region.getFlags().has(Flag.PROTECT).isApplicable()) {
|
||||||
BauSystem.MESSAGE.send("REGION_PROTECT_FALSE_REGION", player);
|
BauSystem.MESSAGE.send("REGION_PROTECT_FALSE_REGION", player);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
package de.steamwar.bausystem.features.region;
|
package de.steamwar.bausystem.features.region;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.region.Point;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode;
|
import de.steamwar.bausystem.region.flags.ProtectMode;
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -21,13 +22,11 @@ public class ProtectListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
private void explode(List<Block> blockList, Location location) {
|
private void explode(List<Block> blockList, Location location) {
|
||||||
Region region = Region.getRegion(location);
|
Region region = Region.getRegion(location);
|
||||||
if (region.getFloorLevel() == 0) {
|
if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.INACTIVE)) return;
|
||||||
return;
|
Point p1 = region.getBuildArea().getMinPoint(true);
|
||||||
}
|
Point p2 = region.getTestblockArea().getMinPoint(true);
|
||||||
if (region.getPlain(Flag.PROTECT, ProtectMode.class) == ProtectMode.INACTIVE) {
|
int floorLevel = Math.min(p1.getY(), p2.getY());
|
||||||
return;
|
blockList.removeIf(block -> block.getY() < floorLevel);
|
||||||
}
|
|
||||||
blockList.removeIf(block -> block.getY() < region.getFloorLevel());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -52,8 +51,7 @@ public class ProtectListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
if (region.getFloorLevel() == 0) return null;
|
if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.INACTIVE)) return null;
|
||||||
if (region.get(Flag.PROTECT) != Flag.PROTECT.getDefaultValue()) return null;
|
return "§e" + BauSystem.MESSAGE.parse(Flag.PROTECT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.PROTECT).getWithDefault().getChatValue(), p);
|
||||||
return "§e" + BauSystem.MESSAGE.parse(Flag.PROTECT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.PROTECT).getChatValue(), p);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,30 +32,20 @@ import de.steamwar.bausystem.region.Point;
|
|||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.bausystem.shared.Pair;
|
import de.steamwar.bausystem.shared.Pair;
|
||||||
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
||||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||||
import de.steamwar.command.PreviousArguments;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.LinkedInstance;
|
import de.steamwar.linkage.LinkedInstance;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class RegionCommand extends SWCommand {
|
public class RegionCommand extends SWCommand {
|
||||||
@ -71,7 +61,7 @@ public class RegionCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static boolean checkGlobalRegion(Region region, Player p) {
|
static boolean checkGlobalRegion(Region region, Player p) {
|
||||||
if (region.isGlobal()) {
|
if (region.getType().isGlobal()) {
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_NO_REGION", p);
|
BauSystem.MESSAGE.send("REGION_REGION_NO_REGION", p);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -83,7 +73,7 @@ public class RegionCommand extends SWCommand {
|
|||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
if (checkGlobalRegion(region, p)) return;
|
if (checkGlobalRegion(region, p)) return;
|
||||||
|
|
||||||
if (region.undo()) {
|
if (region.getHistory().undo()) {
|
||||||
RegionUtils.message(region, "REGION_REGION_UNDID");
|
RegionUtils.message(region, "REGION_REGION_UNDID");
|
||||||
} else {
|
} else {
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_NOTHING_UNDO", p);
|
BauSystem.MESSAGE.send("REGION_REGION_NOTHING_UNDO", p);
|
||||||
@ -97,7 +87,7 @@ public class RegionCommand extends SWCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (region.redo()) {
|
if (region.getHistory().redo()) {
|
||||||
RegionUtils.message(region, "REGION_REGION_REDID");
|
RegionUtils.message(region, "REGION_REGION_REDID");
|
||||||
} else {
|
} else {
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_NOTHING_REDO", p);
|
BauSystem.MESSAGE.send("REGION_REGION_NOTHING_REDO", p);
|
||||||
@ -110,10 +100,10 @@ public class RegionCommand extends SWCommand {
|
|||||||
if(checkGlobalRegion(region, p)) return;
|
if(checkGlobalRegion(region, p)) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL)))
|
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile()))
|
||||||
.ignoreAir(true)
|
.ignoreAir(true)
|
||||||
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||||
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
region.getArea().reset(pasteBuilder, false);
|
||||||
RegionUtils.message(region, "REGION_REGION_RESTORED");
|
RegionUtils.message(region, "REGION_REGION_RESTORED");
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p);
|
BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p);
|
||||||
@ -134,8 +124,8 @@ public class RegionCommand extends SWCommand {
|
|||||||
try {
|
try {
|
||||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node))
|
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node))
|
||||||
.ignoreAir(true)
|
.ignoreAir(true)
|
||||||
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||||
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
region.getArea().reset(pasteBuilder, false);
|
||||||
RegionUtils.message(region, "REGION_REGION_RESTORED");
|
RegionUtils.message(region, "REGION_REGION_RESTORED");
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p);
|
BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p);
|
||||||
@ -149,11 +139,11 @@ public class RegionCommand extends SWCommand {
|
|||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (region.getCopyPoint() == null) {
|
if (region.getBuildArea().isEmpty()) {
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p);
|
BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
p.teleport(region.getCopyPoint().toLocation(p, 0.5, 0, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND);
|
p.teleport(region.getBuildArea().getCopyPoint().toLocation(p, 0.5, 0, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND);
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_TP_COPY", p);
|
BauSystem.MESSAGE.send("REGION_REGION_TP_COPY", p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,70 +154,33 @@ public class RegionCommand extends SWCommand {
|
|||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (region.getTestBlockPoint() == null) {
|
if (region.getTestblockArea().isEmpty()) {
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p);
|
BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
p.teleport(region.getTestBlockPoint().toLocation(p, 0.5, 0, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND);
|
p.teleport(region.getTestblockArea().getCopyPoint().toLocation(p, 0.5, 0, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND);
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_TP_TEST_BLOCK", p);
|
BauSystem.MESSAGE.send("REGION_REGION_TP_TEST_BLOCK", p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "changeskin", description = "REGION_REGION_HELP_CHANGESKIN_INFO")
|
|
||||||
@Register("skin")
|
|
||||||
public void changeSkinCommand(Player p) {
|
|
||||||
Region region = Region.getRegion(p.getLocation());
|
|
||||||
if (checkGlobalRegion(region, p)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_INFO", p, region.getSkin());
|
|
||||||
String creator = region.getPrototype().getSkinMap().get(region.getSkin()).getCreator();
|
|
||||||
if (creator != null) {
|
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_INFO_CREATOR", p, creator);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = "changeskin", description = "REGION_REGION_HELP_CHANGESKIN")
|
|
||||||
@Register("skin")
|
|
||||||
public void changeSkinCommand(@Validator Player p, @Mapper("skinTypeMapper") String s) {
|
|
||||||
Region region = Region.getRegion(p.getLocation());
|
|
||||||
if (checkGlobalRegion(region, p)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!region.getPrototype().getSkinMap().containsKey(s)) {
|
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_UNKNOWN", p);
|
|
||||||
} else {
|
|
||||||
if (region.setSkin(s)) {
|
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_CHANGE", p, s);
|
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_CHANGE_UPDATE", p, BauSystem.MESSAGE.parse("REGION_REGION_CHANGESKIN_CHANGE_UPDATE_HOVER", p), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/reset"));
|
|
||||||
} else {
|
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_INVALID", p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = "copy", description = "REGION_REGION_HELP_COPY")
|
@Register(value = "copy", description = "REGION_REGION_HELP_COPY")
|
||||||
public void copyCommand(@Validator Player p, @OptionalValue("") @StaticValue(value = {"", "-e", "-s"}, allowISE = true) int option) {
|
public void copyCommand(@Validator Player p, @OptionalValue("") @StaticValue(value = {"", "-e", "-s"}, allowISE = true) int option) {
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!region.hasType(RegionType.BUILD)) {
|
if (region.getBuildArea().isEmpty()) {
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_NO_BUILD", p);
|
BauSystem.MESSAGE.send("REGION_REGION_NO_BUILD", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (region.getCopyPoint() == null) {
|
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Point minPoint = region.getMinPoint(RegionType.BUILD, RegionExtensionType.NORMAL);
|
Point minPoint = region.getBuildArea().getMinPoint(false);
|
||||||
Point maxPoint = region.getMaxPoint(RegionType.BUILD, RegionExtensionType.NORMAL);
|
Point maxPoint = region.getBuildArea().getMaxPoint(false);
|
||||||
switch (option) {
|
switch (option) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
minPoint = region.getMinPoint(RegionType.BUILD, RegionExtensionType.EXTENSION);
|
minPoint = region.getBuildArea().getMinPoint(true);
|
||||||
maxPoint = region.getMaxPoint(RegionType.BUILD, RegionExtensionType.EXTENSION);
|
maxPoint = region.getBuildArea().getMaxPoint(true);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
Pair<Location, Location> selection = WorldEditUtils.getSelection(p);
|
Pair<Location, Location> selection = WorldEditUtils.getSelection(p);
|
||||||
@ -238,7 +191,7 @@ public class RegionCommand extends SWCommand {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Clipboard clipboard = FlatteningWrapper.impl.copy(minPoint, maxPoint, region.getCopyPoint());
|
Clipboard clipboard = FlatteningWrapper.impl.copy(minPoint, maxPoint, region.getBuildArea().getCopyPoint());
|
||||||
WorldEdit.getInstance()
|
WorldEdit.getInstance()
|
||||||
.getSessionManager()
|
.getSessionManager()
|
||||||
.get(BukkitAdapter.adapt(p))
|
.get(BukkitAdapter.adapt(p))
|
||||||
@ -252,14 +205,10 @@ public class RegionCommand extends SWCommand {
|
|||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!region.hasType(RegionType.BUILD)) {
|
if (region.getBuildArea().isEmpty()) {
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_NO_BUILD", p);
|
BauSystem.MESSAGE.send("REGION_REGION_NO_BUILD", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (region.getCopyPoint() == null) {
|
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ClipboardHolder clipboardHolder = WorldEdit.getInstance()
|
ClipboardHolder clipboardHolder = WorldEdit.getInstance()
|
||||||
.getSessionManager()
|
.getSessionManager()
|
||||||
@ -287,13 +236,13 @@ public class RegionCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try (EditSession e = WorldEditUtils.getEditSession(p)) {
|
try (EditSession e = WorldEditUtils.getEditSession(p)) {
|
||||||
Operations.completeBlindly(clipboardHolder.createPaste(e).ignoreAirBlocks(ignoreAir).to(toBlockVector3(region.getCopyPoint())).build());
|
Operations.completeBlindly(clipboardHolder.createPaste(e).ignoreAirBlocks(ignoreAir).to(toBlockVector3(region.getBuildArea().getCopyPoint())).build());
|
||||||
WorldEditUtils.addToPlayer(p, e);
|
WorldEditUtils.addToPlayer(p, e);
|
||||||
|
|
||||||
if (selectPasted) {
|
if (selectPasted) {
|
||||||
Clipboard clipboard = clipboardHolder.getClipboards().get(0);
|
Clipboard clipboard = clipboardHolder.getClipboards().get(0);
|
||||||
BlockVector3 minPointSelection = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()).add(toBlockVector3(region.getCopyPoint()));
|
BlockVector3 minPointSelection = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()).add(toBlockVector3(region.getBuildArea().getCopyPoint()));
|
||||||
BlockVector3 maxPointSelection = clipboard.getRegion().getMaximumPoint().subtract(clipboard.getOrigin()).add(toBlockVector3(region.getCopyPoint()));
|
BlockVector3 maxPointSelection = clipboard.getRegion().getMaximumPoint().subtract(clipboard.getOrigin()).add(toBlockVector3(region.getBuildArea().getCopyPoint()));
|
||||||
FlatteningWrapper.impl.setSelection(p, Point.fromBlockVector3(minPointSelection), Point.fromBlockVector3(maxPointSelection));
|
FlatteningWrapper.impl.setSelection(p, Point.fromBlockVector3(minPointSelection), Point.fromBlockVector3(maxPointSelection));
|
||||||
}
|
}
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_PASTE_DONE", p);
|
BauSystem.MESSAGE.send("REGION_REGION_PASTE_DONE", p);
|
||||||
@ -303,25 +252,4 @@ public class RegionCommand extends SWCommand {
|
|||||||
private BlockVector3 toBlockVector3(Point point) {
|
private BlockVector3 toBlockVector3(Point point) {
|
||||||
return BlockVector3.at(point.getX(), point.getY(), point.getZ());
|
return BlockVector3.at(point.getX(), point.getY(), point.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Mapper(value = "skinTypeMapper", local = true)
|
|
||||||
private TypeMapper<String> skinTypeMapper() {
|
|
||||||
return new TypeMapper<String>() {
|
|
||||||
@Override
|
|
||||||
public List<String> tabCompletes(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
|
||||||
Player p = (Player) commandSender;
|
|
||||||
Region region = Region.getRegion(p.getLocation());
|
|
||||||
if (region.isGlobal()) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
return region.getPrototype().getSkinMap().keySet().stream().map(c -> c.replace(' ', '_')).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String map(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
|
||||||
return s.replace('_', ' ');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,8 @@ package de.steamwar.bausystem.features.region;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.tags.Tag;
|
import de.steamwar.bausystem.region.flags.ChangedMode;
|
||||||
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -180,13 +181,7 @@ public class RegionListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void tagChangedRegion(final Location location) {
|
private static void tagChangedRegion(final Location location) {
|
||||||
new BukkitRunnable() {
|
Region.getRegion(location).getFlags().set(Flag.CHANGED, ChangedMode.HAS_CHANGE);
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Region.getRegion(location).set(Tag.CHANGED);
|
|
||||||
}
|
|
||||||
}.runTaskAsynchronously(BauSystem.getInstance());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -20,12 +20,16 @@
|
|||||||
package de.steamwar.bausystem.features.region;
|
package de.steamwar.bausystem.features.region;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.region.GlobalRegion;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class RegionScoreboardElement implements ScoreboardElement {
|
public class RegionScoreboardElement implements ScoreboardElement {
|
||||||
|
|
||||||
@ -41,7 +45,10 @@ public class RegionScoreboardElement implements ScoreboardElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
if (GlobalRegion.getInstance() == region) return null;
|
if (region.getType().isGlobal()) return null;
|
||||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + region.getDisplayName();
|
if (!region.getGameModeConfig().isLoaded()) return null;
|
||||||
|
List<String> names = region.getGameModeConfig().getServer().getChatNames();
|
||||||
|
if (names.isEmpty()) return null;
|
||||||
|
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + names.get(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,13 +21,10 @@ package de.steamwar.bausystem.features.region;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.config.BauServer;
|
import de.steamwar.bausystem.config.BauServer;
|
||||||
import de.steamwar.bausystem.region.GlobalRegion;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
import de.steamwar.bausystem.region.RegionSystem;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
@ -55,12 +52,10 @@ public class ResetCommand extends SWCommand {
|
|||||||
Region region = regionCheck(p);
|
Region region = regionCheck(p);
|
||||||
if (region == null) return;
|
if (region == null) return;
|
||||||
try {
|
try {
|
||||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL)))
|
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile()))
|
||||||
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||||
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
region.getArea().reset(pasteBuilder, false);
|
||||||
for (Flag value : Flag.getResetFlags()) {
|
region.getFlags().clear();
|
||||||
region.set(value, value.getDefaultValue());
|
|
||||||
}
|
|
||||||
RegionUtils.message(region, "REGION_RESET_RESETED");
|
RegionUtils.message(region, "REGION_RESET_RESETED");
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
BauSystem.MESSAGE.send("REGION_RESET_ERROR", p);
|
BauSystem.MESSAGE.send("REGION_RESET_ERROR", p);
|
||||||
@ -88,8 +83,8 @@ public class ResetCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node))
|
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node))
|
||||||
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||||
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
region.getArea().reset(pasteBuilder, true);
|
||||||
RegionUtils.message(region, "REGION_RESET_RESETED");
|
RegionUtils.message(region, "REGION_RESET_RESETED");
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
BauSystem.MESSAGE.send("REGION_RESET_ERROR", p);
|
BauSystem.MESSAGE.send("REGION_RESET_ERROR", p);
|
||||||
@ -99,7 +94,7 @@ public class ResetCommand extends SWCommand {
|
|||||||
|
|
||||||
private Region regionCheck(Player player) {
|
private Region regionCheck(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region == GlobalRegion.getInstance()) {
|
if (region == RegionSystem.INSTANCE.getGlobalRegion()) {
|
||||||
BauSystem.MESSAGE.send("REGION_RESET_NO_REGION", player);
|
BauSystem.MESSAGE.send("REGION_RESET_NO_REGION", player);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,16 +20,14 @@
|
|||||||
package de.steamwar.bausystem.features.region;
|
package de.steamwar.bausystem.features.region;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.TNTMode;
|
import de.steamwar.bausystem.region.flags.TNTMode;
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
import de.steamwar.bausystem.region.flags.TestblockMode;
|
||||||
import de.steamwar.command.PreviousArguments;
|
import de.steamwar.command.PreviousArguments;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -74,9 +72,6 @@ public class TNTCommand extends SWCommand {
|
|||||||
case ONLY_TB:
|
case ONLY_TB:
|
||||||
requestedMessage = getTestblockEnableMessage();
|
requestedMessage = getTestblockEnableMessage();
|
||||||
break;
|
break;
|
||||||
case ONLY_BUILD:
|
|
||||||
requestedMessage = getBuildEnableMessage();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
tntToggle(region, tntMode, requestedMessage);
|
tntToggle(region, tntMode, requestedMessage);
|
||||||
}
|
}
|
||||||
@ -92,13 +87,12 @@ public class TNTCommand extends SWCommand {
|
|||||||
Map<String, TNTMode> tntModeMap = new HashMap<>(tntModeMapReduced);
|
Map<String, TNTMode> tntModeMap = new HashMap<>(tntModeMapReduced);
|
||||||
tntModeMap.put("testblock", TNTMode.ONLY_TB);
|
tntModeMap.put("testblock", TNTMode.ONLY_TB);
|
||||||
tntModeMap.put("tb", TNTMode.ONLY_TB);
|
tntModeMap.put("tb", TNTMode.ONLY_TB);
|
||||||
tntModeMap.put("build", TNTMode.ONLY_BUILD);
|
|
||||||
|
|
||||||
return new TypeMapper<TNTMode>() {
|
return new TypeMapper<>() {
|
||||||
@Override
|
@Override
|
||||||
public List<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
public List<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||||
Region region = Region.getRegion(((Player) sender).getLocation());
|
Region region = Region.getRegion(((Player) sender).getLocation());
|
||||||
if (region.hasType(RegionType.TESTBLOCK) && region.hasType(RegionType.BUILD)) {
|
if (region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
|
||||||
return new ArrayList<>(tntModeMap.keySet());
|
return new ArrayList<>(tntModeMap.keySet());
|
||||||
} else {
|
} else {
|
||||||
return new ArrayList<>(tntModeMapReduced.keySet());
|
return new ArrayList<>(tntModeMapReduced.keySet());
|
||||||
@ -108,7 +102,7 @@ public class TNTCommand extends SWCommand {
|
|||||||
@Override
|
@Override
|
||||||
public TNTMode map(CommandSender sender, PreviousArguments previousArguments, String s) {
|
public TNTMode map(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||||
Region region = Region.getRegion(((Player) sender).getLocation());
|
Region region = Region.getRegion(((Player) sender).getLocation());
|
||||||
if (region.hasType(RegionType.TESTBLOCK) && region.hasType(RegionType.BUILD)) {
|
if (region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
|
||||||
return tntModeMap.getOrDefault(s, null);
|
return tntModeMap.getOrDefault(s, null);
|
||||||
} else {
|
} else {
|
||||||
return tntModeMapReduced.getOrDefault(s, null);
|
return tntModeMapReduced.getOrDefault(s, null);
|
||||||
@ -134,24 +128,23 @@ public class TNTCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) {
|
private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) {
|
||||||
if (requestedMode != null && region.hasType(RegionType.TESTBLOCK) && region.hasType(RegionType.BUILD)) {
|
if (requestedMode != null && region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
|
||||||
region.set(Flag.TNT, requestedMode);
|
region.getFlags().set(Flag.TNT, requestedMode);
|
||||||
RegionUtils.actionBar(region, requestedMessage);
|
RegionUtils.actionBar(region, requestedMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (region.getPlain(Flag.TNT, TNTMode.class)) {
|
switch (region.getFlags().get(Flag.TNT).getWithDefault()) {
|
||||||
case ALLOW:
|
case ALLOW:
|
||||||
case ONLY_TB:
|
case ONLY_TB:
|
||||||
case ONLY_BUILD:
|
region.getFlags().set(Flag.TNT, TNTMode.DENY);
|
||||||
region.set(Flag.TNT, TNTMode.DENY);
|
|
||||||
RegionUtils.actionBar(region, getDisableMessage());
|
RegionUtils.actionBar(region, getDisableMessage());
|
||||||
break;
|
break;
|
||||||
case DENY:
|
case DENY:
|
||||||
if (region.hasType(RegionType.TESTBLOCK) && region.hasType(RegionType.BUILD)) {
|
if (region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
|
||||||
region.set(Flag.TNT, TNTMode.ONLY_TB);
|
region.getFlags().set(Flag.TNT, TNTMode.ONLY_TB);
|
||||||
RegionUtils.actionBar(region, getTestblockEnableMessage());
|
RegionUtils.actionBar(region, getTestblockEnableMessage());
|
||||||
} else {
|
} else {
|
||||||
region.set(Flag.TNT, TNTMode.ALLOW);
|
region.getFlags().set(Flag.TNT, TNTMode.ALLOW);
|
||||||
RegionUtils.actionBar(region, getEnableMessage());
|
RegionUtils.actionBar(region, getEnableMessage());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -23,9 +23,7 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.TNTMode;
|
import de.steamwar.bausystem.region.flags.TNTMode;
|
||||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -37,7 +35,6 @@ import org.bukkit.event.block.BlockExplodeEvent;
|
|||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class TNTListener implements Listener, ScoreboardElement {
|
public class TNTListener implements Listener, ScoreboardElement {
|
||||||
@ -45,27 +42,14 @@ public class TNTListener implements Listener, ScoreboardElement {
|
|||||||
private void explode(List<Block> blockList) {
|
private void explode(List<Block> blockList) {
|
||||||
blockList.removeIf(block -> {
|
blockList.removeIf(block -> {
|
||||||
Region region = Region.getRegion(block.getLocation());
|
Region region = Region.getRegion(block.getLocation());
|
||||||
TNTMode value = region.getPlain(Flag.TNT);
|
TNTMode value = region.getFlags().get(Flag.TNT).getWithDefault();
|
||||||
if (value == TNTMode.ALLOW) {
|
if (value == TNTMode.ALLOW) {
|
||||||
return false;
|
return false;
|
||||||
} else if (value == TNTMode.ONLY_TB) {
|
} else if (value == TNTMode.ONLY_TB) {
|
||||||
if (region.hasType(RegionType.BUILD) && region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.NORMAL)) {
|
if (region.getBuildArea().inRegion(block.getLocation(), true)) {
|
||||||
RegionUtils.actionBar(region, "REGION_TNT_BUILD_DESTROY");
|
RegionUtils.actionBar(region, "REGION_TNT_BUILD_DESTROY");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (region.hasType(RegionType.BUILD) && region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)) {
|
|
||||||
RegionUtils.actionBar(region, "REGION_TNT_BUILD_DESTROY");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else if (value == TNTMode.ONLY_BUILD) {
|
|
||||||
if (region.hasType(RegionType.TESTBLOCK) && region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.NORMAL)) {
|
|
||||||
RegionUtils.actionBar(region, "REGION_TNT_TB_DESTROY");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (region.hasType(RegionType.TESTBLOCK) && region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) {
|
|
||||||
RegionUtils.actionBar(region, "REGION_TNT_TB_DESTROY");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return value == TNTMode.DENY;
|
return value == TNTMode.DENY;
|
||||||
});
|
});
|
||||||
@ -93,6 +77,7 @@ public class TNTListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
return "§e" + BauSystem.MESSAGE.parse(Flag.TNT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.TNT).getChatValue(), p);
|
if (region.getFlags().get(Flag.TNT).isWithDefault(TNTMode.ALLOW)) return null;
|
||||||
|
return "§e" + BauSystem.MESSAGE.parse(Flag.TNT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.TNT).getWithDefault().getChatValue(), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,19 +20,16 @@
|
|||||||
package de.steamwar.bausystem.features.region;
|
package de.steamwar.bausystem.features.region;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.bausystem.config.BauServer;
|
import de.steamwar.bausystem.config.BauServer;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
import de.steamwar.bausystem.region.utils.RegionType;
|
||||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||||
import de.steamwar.command.PreviousArguments;
|
import de.steamwar.command.PreviousArguments;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.LinkedInstance;
|
import de.steamwar.linkage.LinkedInstance;
|
||||||
import de.steamwar.sql.Punishment;
|
import de.steamwar.sql.Punishment;
|
||||||
@ -43,10 +40,8 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -99,14 +94,14 @@ public class TestblockCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PasteBuilder.ClipboardProvider clipboardProvider = node == null ? new PasteBuilder.FileProvider(region.getResetFile(RegionType.TESTBLOCK)) : new PasteBuilder.SchematicProvider(node);
|
PasteBuilder.ClipboardProvider clipboardProvider = node == null ? new PasteBuilder.FileProvider(region.getTestblockArea().getResetFile()) : new PasteBuilder.SchematicProvider(node);
|
||||||
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider)
|
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider)
|
||||||
.ignoreAir(ignoreAir)
|
.ignoreAir(ignoreAir)
|
||||||
.onlyColors(onlyColors)
|
.onlyColors(onlyColors)
|
||||||
.removeTNT(removeTNT)
|
.removeTNT(removeTNT)
|
||||||
.removeWater(removeWater)
|
.removeWater(removeWater)
|
||||||
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||||
region.reset(pasteBuilder, RegionType.TESTBLOCK, regionExtensionType);
|
region.getTestblockArea().reset(pasteBuilder, regionExtensionType == RegionExtensionType.EXTENSION);
|
||||||
RegionUtils.message(region, "REGION_TB_DONE");
|
RegionUtils.message(region, "REGION_TB_DONE");
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
BauSystem.MESSAGE.send("REGION_TB_ERROR", p);
|
BauSystem.MESSAGE.send("REGION_TB_ERROR", p);
|
||||||
@ -159,7 +154,7 @@ public class TestblockCommand extends SWCommand {
|
|||||||
|
|
||||||
private Region regionCheck(Player player) {
|
private Region regionCheck(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (!region.hasType(RegionType.TESTBLOCK)) {
|
if (region.getTestblockArea().isEmpty()) {
|
||||||
BauSystem.MESSAGE.send("REGION_TB_NO_REGION", player);
|
BauSystem.MESSAGE.send("REGION_TB_NO_REGION", player);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,10 +22,9 @@ package de.steamwar.bausystem.features.region.items;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||||
import de.steamwar.bausystem.region.Color;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
import de.steamwar.bausystem.region.flags.ColorMode;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.inventory.SWListInv;
|
import de.steamwar.inventory.SWListInv;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
@ -45,7 +44,7 @@ public class ColorBauGuiItem extends BauGuiItem {
|
|||||||
super(2);
|
super(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Material mapColor(Color color) {
|
private static Material mapColor(ColorMode color) {
|
||||||
switch (color) {
|
switch (color) {
|
||||||
case RED:
|
case RED:
|
||||||
return Material.RED_CONCRETE;
|
return Material.RED_CONCRETE;
|
||||||
@ -85,17 +84,17 @@ public class ColorBauGuiItem extends BauGuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(Player player) {
|
public ItemStack getItem(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
ColorMode mode = region.getPlain(Flag.COLOR, ColorMode.class);
|
ColorMode mode = region.getFlags().get(Flag.COLOR).orElse(ColorMode.PINK);
|
||||||
return new SWItem(mapColor(mode.getColor()), BauSystem.MESSAGE.parse("REGION_ITEM_COLOR", player, BauSystem.MESSAGE.parse(mode.getChatValue(), player))).getItemStack();
|
return new SWItem(mapColor(mode), BauSystem.MESSAGE.parse("REGION_ITEM_COLOR", player, BauSystem.MESSAGE.parse(mode.getChatValue(), player))).getItemStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean click(ClickType click, Player p) {
|
public boolean click(ClickType click, Player p) {
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
ColorMode current = Region.getRegion(p.getLocation()).getPlain(Flag.COLOR, ColorMode.class);
|
ColorMode current = Region.getRegion(p.getLocation()).getFlags().get(Flag.COLOR).orElse(ColorMode.PINK);
|
||||||
List<SWListInv.SWListEntry<ColorMode>> items = new ArrayList<>();
|
List<SWListInv.SWListEntry<ColorMode>> items = new ArrayList<>();
|
||||||
for (ColorMode value : ColorMode.values()) {
|
for (ColorMode value : ColorMode.values()) {
|
||||||
items.add(new SWListInv.SWListEntry<>(new SWItem(mapColor(value.getColor()), (byte) 0, "§f" + BauSystem.MESSAGE.parse(value.getChatValue(), p), Collections.emptyList(), value == current, clickType -> {
|
items.add(new SWListInv.SWListEntry<>(new SWItem(mapColor(value), (byte) 0, "§f" + BauSystem.MESSAGE.parse(value.getChatValue(), p), Collections.emptyList(), value == current, clickType -> {
|
||||||
}), value));
|
}), value));
|
||||||
}
|
}
|
||||||
SWListInv<ColorMode> inv = new SWListInv<>(p, BauSystem.MESSAGE.parse("REGION_ITEM_COLOR_CHOOSE", p), items, (clickType, colorMode) -> {
|
SWListInv<ColorMode> inv = new SWListInv<>(p, BauSystem.MESSAGE.parse("REGION_ITEM_COLOR_CHOOSE", p), items, (clickType, colorMode) -> {
|
||||||
|
|||||||
@ -23,8 +23,8 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
import de.steamwar.bausystem.region.flags.FireMode;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.FireMode;
|
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -42,7 +42,10 @@ public class FireBauGuiItem extends BauGuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(Player player) {
|
public ItemStack getItem(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region.getPlain(Flag.FIRE, FireMode.class) == FireMode.ALLOW) {
|
if (!region.getFlags().has(Flag.FIRE).isApplicable()) {
|
||||||
|
return new SWItem(Material.BARRIER, "").getItemStack();
|
||||||
|
}
|
||||||
|
if (region.getFlags().get(Flag.FIRE).isWithDefault(FireMode.ALLOW)) {
|
||||||
return new SWItem(Material.FIRE_CHARGE, BauSystem.MESSAGE.parse("REGION_ITEM_FIRE_ALLOW", player)).getItemStack();
|
return new SWItem(Material.FIRE_CHARGE, BauSystem.MESSAGE.parse("REGION_ITEM_FIRE_ALLOW", player)).getItemStack();
|
||||||
} else {
|
} else {
|
||||||
return new SWItem(Material.FIREWORK_STAR, BauSystem.MESSAGE.parse("REGION_ITEM_FIRE_DISALLOW", player)).getItemStack();
|
return new SWItem(Material.FIREWORK_STAR, BauSystem.MESSAGE.parse("REGION_ITEM_FIRE_DISALLOW", player)).getItemStack();
|
||||||
|
|||||||
@ -24,7 +24,7 @@ import de.steamwar.bausystem.Permission;
|
|||||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
|
import de.steamwar.bausystem.region.flags.FreezeMode;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -42,7 +42,10 @@ public class FreezeBauGuiItem extends BauGuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(Player player) {
|
public ItemStack getItem(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region.getPlain(Flag.FREEZE, FreezeMode.class) == FreezeMode.ACTIVE) {
|
if (!region.getFlags().has(Flag.FREEZE).isApplicable()) {
|
||||||
|
return new SWItem(Material.BARRIER, "").getItemStack();
|
||||||
|
}
|
||||||
|
if (region.getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
return new SWItem(Material.GUNPOWDER, BauSystem.MESSAGE.parse("REGION_ITEM_FREEZE_ALLOW", player)).getItemStack();
|
return new SWItem(Material.GUNPOWDER, BauSystem.MESSAGE.parse("REGION_ITEM_FREEZE_ALLOW", player)).getItemStack();
|
||||||
} else {
|
} else {
|
||||||
return new SWItem(Material.REDSTONE, BauSystem.MESSAGE.parse("REGION_ITEM_FREEZE_DISALLOW", player)).getItemStack();
|
return new SWItem(Material.REDSTONE, BauSystem.MESSAGE.parse("REGION_ITEM_FREEZE_DISALLOW", player)).getItemStack();
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import de.steamwar.bausystem.SWUtils;
|
|||||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode;
|
import de.steamwar.bausystem.region.flags.ProtectMode;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -43,7 +43,10 @@ public class ProtectBauGuiItem extends BauGuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(Player player) {
|
public ItemStack getItem(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region.getPlain(Flag.PROTECT, ProtectMode.class) == ProtectMode.ACTIVE) {
|
if (!region.getFlags().has(Flag.PROTECT).isApplicable()) {
|
||||||
|
return new SWItem(Material.BARRIER, "").getItemStack();
|
||||||
|
}
|
||||||
|
if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.ACTIVE)) {
|
||||||
return SWUtils.setCustomModelData(new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_ALLOW", player)), 1).getItemStack();
|
return SWUtils.setCustomModelData(new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_ALLOW", player)), 1).getItemStack();
|
||||||
} else {
|
} else {
|
||||||
return SWUtils.setCustomModelData(new SWItem(Material.STONE, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_DISALLOW", player)), 1).getItemStack();
|
return SWUtils.setCustomModelData(new SWItem(Material.STONE, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_DISALLOW", player)), 1).getItemStack();
|
||||||
|
|||||||
@ -24,8 +24,7 @@ import de.steamwar.bausystem.Permission;
|
|||||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.TNTMode;
|
import de.steamwar.bausystem.region.flags.TNTMode;
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.inventory.SWInventory;
|
import de.steamwar.inventory.SWInventory;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
@ -43,13 +42,11 @@ public class TntBauGuiItem extends BauGuiItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(Player player) {
|
public ItemStack getItem(Player player) {
|
||||||
switch (Region.getRegion(player.getLocation()).getPlain(Flag.TNT, TNTMode.class)) {
|
switch (Region.getRegion(player.getLocation()).getFlags().get(Flag.TNT).getWithDefault()) {
|
||||||
case DENY:
|
case DENY:
|
||||||
return new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_OFF", player)).getItemStack();
|
return new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_OFF", player)).getItemStack();
|
||||||
case ONLY_TB:
|
case ONLY_TB:
|
||||||
return new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_ONLY_TB", player)).getItemStack();
|
return new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_ONLY_TB", player)).getItemStack();
|
||||||
case ONLY_BUILD:
|
|
||||||
return new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_ONLY_BUILD", player)).getItemStack();
|
|
||||||
default:
|
default:
|
||||||
return new SWItem(Material.TNT, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_ON", player)).getItemStack();
|
return new SWItem(Material.TNT, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_ON", player)).getItemStack();
|
||||||
}
|
}
|
||||||
@ -58,12 +55,12 @@ public class TntBauGuiItem extends BauGuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public boolean click(ClickType click, Player p) {
|
public boolean click(ClickType click, Player p) {
|
||||||
if (click == ClickType.LEFT) {
|
if (click == ClickType.LEFT) {
|
||||||
switch (Region.getRegion(p.getLocation()).getPlain(Flag.TNT, TNTMode.class)) {
|
switch (Region.getRegion(p.getLocation()).getFlags().get(Flag.TNT).getWithDefault()) {
|
||||||
case DENY:
|
case DENY:
|
||||||
updateTntMode(TNTMode.ALLOW, p);
|
updateTntMode(TNTMode.ALLOW, p);
|
||||||
break;
|
break;
|
||||||
case ALLOW:
|
case ALLOW:
|
||||||
if (Region.getRegion(p.getLocation()).hasType(RegionType.BUILD) && Region.getRegion(p.getLocation()).hasType(RegionType.TESTBLOCK)) {
|
if (!Region.getRegion(p.getLocation()).getBuildArea().isEmpty() && !Region.getRegion(p.getLocation()).getTestblockArea().isEmpty()) {
|
||||||
updateTntMode(TNTMode.ONLY_TB, p);
|
updateTntMode(TNTMode.ONLY_TB, p);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -77,15 +74,11 @@ public class TntBauGuiItem extends BauGuiItem {
|
|||||||
updateTntMode(TNTMode.ALLOW, p);
|
updateTntMode(TNTMode.ALLOW, p);
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
}));
|
}));
|
||||||
if (Region.getRegion(p.getLocation()).hasType(RegionType.BUILD) && Region.getRegion(p.getLocation()).hasType(RegionType.TESTBLOCK)) {
|
if (!Region.getRegion(p.getLocation()).getBuildArea().isEmpty() && !Region.getRegion(p.getLocation()).getTestblockArea().isEmpty()) {
|
||||||
selector.setItem(3, new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_ONLY_TB", p), clickType -> {
|
selector.setItem(3, new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_ONLY_TB", p), clickType -> {
|
||||||
updateTntMode(TNTMode.ONLY_TB, p);
|
updateTntMode(TNTMode.ONLY_TB, p);
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
}));
|
}));
|
||||||
selector.setItem(5, new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_ONLY_BUILD", p), clickType -> {
|
|
||||||
updateTntMode(TNTMode.ONLY_BUILD, p);
|
|
||||||
p.closeInventory();
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
selector.setItem(7, new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_OFF", p), clickType -> {
|
selector.setItem(7, new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_OFF", p), clickType -> {
|
||||||
updateTntMode(TNTMode.DENY, p);
|
updateTntMode(TNTMode.DENY, p);
|
||||||
@ -101,9 +94,6 @@ public class TntBauGuiItem extends BauGuiItem {
|
|||||||
case ONLY_TB:
|
case ONLY_TB:
|
||||||
p.performCommand("tnt tb");
|
p.performCommand("tnt tb");
|
||||||
break;
|
break;
|
||||||
case ONLY_BUILD:
|
|
||||||
p.performCommand("tnt build");
|
|
||||||
break;
|
|
||||||
case ALLOW:
|
case ALLOW:
|
||||||
p.performCommand("tnt on");
|
p.performCommand("tnt on");
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -22,7 +22,6 @@ package de.steamwar.bausystem.features.script;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.SWUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.features.script.lua.SteamWarPlatform;
|
import de.steamwar.bausystem.features.script.lua.SteamWarPlatform;
|
||||||
import de.steamwar.bausystem.utils.ItemUtils;
|
|
||||||
import de.steamwar.inventory.SWAnvilInv;
|
import de.steamwar.inventory.SWAnvilInv;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.inventory.SWListInv;
|
import de.steamwar.inventory.SWListInv;
|
||||||
|
|||||||
@ -28,7 +28,6 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.luaj.vm2.LuaValue;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|||||||
@ -153,7 +153,7 @@ public class EventListener implements Listener {
|
|||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
if(!Permission.BUILD.hasPermission(player)) continue;
|
if(!Permission.BUILD.hasPermission(player)) continue;
|
||||||
if (tntRegion.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) {
|
if (tntRegion.getArea().inRegion(player.getLocation(), false)) {
|
||||||
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTSpawn, LuaValue.NIL, event);
|
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTSpawn, LuaValue.NIL, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,11 +171,11 @@ public class EventListener implements Listener {
|
|||||||
table.set("y", event.getLocation().getY());
|
table.set("y", event.getLocation().getY());
|
||||||
table.set("z", event.getLocation().getZ());
|
table.set("z", event.getLocation().getZ());
|
||||||
|
|
||||||
boolean inBuild = event.blockList().stream().anyMatch(block -> tntRegion.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION));
|
boolean inBuild = event.blockList().stream().anyMatch(block -> tntRegion.getBuildArea().inRegion(block.getLocation(), true));
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
if(!Permission.BUILD.hasPermission(player)) continue;
|
if(!Permission.BUILD.hasPermission(player)) continue;
|
||||||
if (tntRegion.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) {
|
if (tntRegion.getArea().inRegion(player.getLocation(), false)) {
|
||||||
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplode, table, event);
|
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplode, table, event);
|
||||||
if (inBuild) {
|
if (inBuild) {
|
||||||
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplodeInBuild, table, event);
|
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplodeInBuild, table, event);
|
||||||
|
|||||||
@ -22,19 +22,14 @@ package de.steamwar.bausystem.features.script.lua;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
|
||||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.configplayer.Config;
|
|
||||||
import de.steamwar.bausystem.features.script.ScriptRunner;
|
import de.steamwar.bausystem.features.script.ScriptRunner;
|
||||||
import de.steamwar.bausystem.features.script.lua.libs.LuaLib;
|
import de.steamwar.bausystem.features.script.lua.libs.LuaLib;
|
||||||
import de.steamwar.bausystem.features.world.WorldEditListener;
|
import de.steamwar.bausystem.features.world.WorldEditListener;
|
||||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||||
import de.steamwar.inventory.SWAnvilInv;
|
import de.steamwar.inventory.SWAnvilInv;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -47,8 +42,6 @@ import org.luaj.vm2.LuaValue;
|
|||||||
import org.luaj.vm2.Varargs;
|
import org.luaj.vm2.Varargs;
|
||||||
import org.luaj.vm2.lib.*;
|
import org.luaj.vm2.lib.*;
|
||||||
|
|
||||||
import java.lang.reflect.Proxy;
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
|||||||
@ -20,19 +20,17 @@
|
|||||||
package de.steamwar.bausystem.features.script.lua.libs;
|
package de.steamwar.bausystem.features.script.lua.libs;
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.loader.Loader;
|
import de.steamwar.bausystem.features.loader.Loader;
|
||||||
import de.steamwar.bausystem.region.GlobalRegion;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.RegionSystem;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.FireMode;
|
import de.steamwar.bausystem.region.flags.*;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
|
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode;
|
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.TNTMode;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.luaj.vm2.LuaTable;
|
import org.luaj.vm2.LuaTable;
|
||||||
import org.luaj.vm2.LuaValue;
|
import org.luaj.vm2.LuaValue;
|
||||||
import org.luaj.vm2.lib.OneArgFunction;
|
import org.luaj.vm2.lib.OneArgFunction;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
@ -46,27 +44,29 @@ public class RegionLib implements LuaLib {
|
|||||||
private LuaTable create(Supplier<Region> region, Player player) {
|
private LuaTable create(Supplier<Region> region, Player player) {
|
||||||
LuaTable table = LuaValue.tableOf();
|
LuaTable table = LuaValue.tableOf();
|
||||||
|
|
||||||
table.set("name", getter(() -> region.get().getName()));
|
table.set("name", getter(() -> region.get().getID().toString()));
|
||||||
|
table.set("id", getter(() -> region.get().getID().toString()));
|
||||||
table.set("type", getter(() -> {
|
table.set("type", getter(() -> {
|
||||||
Region region1 = region.get();
|
Region rg = region.get();
|
||||||
if (region1 instanceof GlobalRegion) {
|
if (rg.getType().isGlobal()) {
|
||||||
return "global";
|
return "global";
|
||||||
} else {
|
|
||||||
return region1.getPrototype().getName();
|
|
||||||
}
|
}
|
||||||
|
List<String> chatNames = rg.getGameModeConfig().getServer().getChatNames();
|
||||||
|
if (chatNames.isEmpty()) {
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
return chatNames.get(0).toLowerCase();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
LuaValue tntLib = LuaValue.tableOf();
|
LuaValue tntLib = LuaValue.tableOf();
|
||||||
tntLib.set("mode", getter(() -> region.get().getPlain(Flag.TNT, TNTMode.class).name()));
|
tntLib.set("mode", getter(() -> region.get().getFlags().get(Flag.TNT).nameWithDefault()));
|
||||||
tntLib.set("enabled", getter(() -> region.get().getPlain(Flag.TNT, TNTMode.class) != TNTMode.DENY));
|
tntLib.set("enabled", getter(() -> region.get().getFlags().get(Flag.TNT).orElse(null) != TNTMode.DENY));
|
||||||
tntLib.set("onlyTb", getter(() -> region.get().getPlain(Flag.TNT, TNTMode.class) == TNTMode.ONLY_TB));
|
tntLib.set("onlyTb", getter(() -> region.get().getFlags().get(Flag.TNT).orElse(null) == TNTMode.ONLY_TB));
|
||||||
tntLib.set("onlyBuild", getter(() -> region.get().getPlain(Flag.TNT, TNTMode.class) == TNTMode.ONLY_BUILD));
|
|
||||||
|
|
||||||
table.set("tnt", tntLib);
|
table.set("tnt", tntLib);
|
||||||
|
|
||||||
table.set("fire", getter(() -> region.get().getPlain(Flag.FIRE, FireMode.class) == FireMode.ALLOW));
|
table.set("fire", getter(() -> region.get().getFlags().get(Flag.FIRE).orElse(null) == FireMode.ALLOW));
|
||||||
table.set("freeze", getter(() -> region.get().getPlain(Flag.FREEZE, FreezeMode.class) == FreezeMode.ACTIVE));
|
table.set("freeze", getter(() -> region.get().getFlags().get(Flag.FREEZE).orElse(null) == FreezeMode.ACTIVE));
|
||||||
table.set("protect", getter(() -> region.get().getPlain(Flag.PROTECT, ProtectMode.class) == ProtectMode.ACTIVE));
|
table.set("protect", getter(() -> region.get().getFlags().get(Flag.PROTECT).orElse(null) == ProtectMode.ACTIVE));
|
||||||
|
|
||||||
//LuaValue traceLib = LuaValue.tableOf();
|
//LuaValue traceLib = LuaValue.tableOf();
|
||||||
//traceLib.set("active", getter(() -> !region.get().isGlobal() && Recorder.INSTANCE.get(region.get()) instanceof ActiveTracer));
|
//traceLib.set("active", getter(() -> !region.get().isGlobal() && Recorder.INSTANCE.get(region.get()) instanceof ActiveTracer));
|
||||||
@ -79,16 +79,16 @@ public class RegionLib implements LuaLib {
|
|||||||
Loader loader = Loader.getLoader(player);
|
Loader loader = Loader.getLoader(player);
|
||||||
table.set("loader", getter(() -> loader == null ? "OFF" : loader.getStage().name()));
|
table.set("loader", getter(() -> loader == null ? "OFF" : loader.getStage().name()));
|
||||||
|
|
||||||
table.set("copyPoint", getter(() -> toPos(region.get().getCopyPoint())));
|
table.set("copyPoint", getter(() -> toPos(region.get().getBuildArea().getCopyPoint())));
|
||||||
table.set("minPointBuild", getter(() -> toPos(region.get().getMinPointBuild())));
|
table.set("minPointBuild", getter(() -> toPos(region.get().getBuildArea().getMinPoint(false))));
|
||||||
table.set("maxPointBuild", getter(() -> toPos(region.get().getMaxPointBuild())));
|
table.set("maxPointBuild", getter(() -> toPos(region.get().getBuildArea().getMinPoint(false))));
|
||||||
table.set("minPointBuildExtension", getter(() -> toPos(region.get().getMinPointBuildExtension())));
|
table.set("minPointBuildExtension", getter(() -> toPos(region.get().getBuildArea().getMinPoint(true))));
|
||||||
table.set("maxPointBuildExtension", getter(() -> toPos(region.get().getMaxPointBuildExtension())));
|
table.set("maxPointBuildExtension", getter(() -> toPos(region.get().getBuildArea().getMinPoint(true))));
|
||||||
table.set("testblockPoint", getter(() -> toPos(region.get().getTestBlockPoint())));
|
table.set("testblockPoint", getter(() -> toPos(region.get().getTestblockArea().getCopyPoint())));
|
||||||
table.set("minPointTestblock", getter(() -> toPos(region.get().getMinPointTestblock())));
|
table.set("minPointTestblock", getter(() -> toPos(region.get().getTestblockArea().getMinPoint(false))));
|
||||||
table.set("maxPointTestblock", getter(() -> toPos(region.get().getMaxPointTestblock())));
|
table.set("maxPointTestblock", getter(() -> toPos(region.get().getTestblockArea().getMinPoint(false))));
|
||||||
table.set("minPointTestblockExtension", getter(() -> toPos(region.get().getMinPointTestblockExtension())));
|
table.set("minPointTestblockExtension", getter(() -> toPos(region.get().getTestblockArea().getMinPoint(true))));
|
||||||
table.set("maxPointTestblockExtension", getter(() -> toPos(region.get().getMaxPointTestblockExtension())));
|
table.set("maxPointTestblockExtension", getter(() -> toPos(region.get().getTestblockArea().getMinPoint(true))));
|
||||||
|
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
@ -99,11 +99,11 @@ public class RegionLib implements LuaLib {
|
|||||||
table.set("get", new OneArgFunction() {
|
table.set("get", new OneArgFunction() {
|
||||||
@Override
|
@Override
|
||||||
public LuaValue call(LuaValue arg) {
|
public LuaValue call(LuaValue arg) {
|
||||||
return create(() -> Region.getREGION_MAP().get(arg.checkjstring()), player);
|
return create(() -> RegionSystem.INSTANCE.getRegion(UUID.fromString(arg.checkjstring())).orElse(RegionSystem.INSTANCE.getGlobalRegion()), player);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
table.set("list", getter(() -> LuaValue.listOf(Region.getREGION_MAP().values().stream().map(region -> create(() -> region, player)).toArray(LuaTable[]::new))));
|
table.set("list", getter(() -> LuaValue.listOf(RegionSystem.INSTANCE.getRegions().map(region -> create(() -> region, player)).toArray(LuaTable[]::new))));
|
||||||
|
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,9 +24,7 @@ import de.steamwar.bausystem.utils.ScoreboardElement;
|
|||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.luaj.vm2.LuaTable;
|
import org.luaj.vm2.LuaTable;
|
||||||
import org.luaj.vm2.LuaValue;
|
|
||||||
import org.luaj.vm2.Varargs;
|
import org.luaj.vm2.Varargs;
|
||||||
import org.luaj.vm2.lib.TwoArgFunction;
|
|
||||||
import org.luaj.vm2.lib.VarArgFunction;
|
import org.luaj.vm2.lib.VarArgFunction;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
|
|||||||
@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.script.lua.libs;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.features.loader.Loader;
|
|
||||||
import de.steamwar.bausystem.features.loader.LoaderRecorder;
|
import de.steamwar.bausystem.features.loader.LoaderRecorder;
|
||||||
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
|
|||||||
@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.script.lua.libs;
|
|||||||
|
|
||||||
import com.google.gson.*;
|
import com.google.gson.*;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
import de.steamwar.bausystem.region.RegionSystem;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.api.Disable;
|
import de.steamwar.linkage.api.Disable;
|
||||||
@ -74,7 +75,7 @@ public class StorageLib implements LuaLib, Enable, Disable {
|
|||||||
jsonObject.keySet().forEach(key -> {
|
jsonObject.keySet().forEach(key -> {
|
||||||
map.put(key, fromJson(jsonObject.get(key)));
|
map.put(key, fromJson(jsonObject.get(key)));
|
||||||
});
|
});
|
||||||
Region region = Region.getREGION_MAP().get(regionStorage.getName().substring(0, regionStorage.getName().length() - ".json".length()));
|
Region region = RegionSystem.INSTANCE.getRegion(UUID.fromString(regionStorage.getName().substring(0, regionStorage.getName().length() - ".json".length()))).orElse(null);
|
||||||
REGION_STORAGE.put(region, map);
|
REGION_STORAGE.put(region, map);
|
||||||
} catch (Exception e) {}
|
} catch (Exception e) {}
|
||||||
}
|
}
|
||||||
@ -143,7 +144,7 @@ public class StorageLib implements LuaLib, Enable, Disable {
|
|||||||
regionStorageDirectory.mkdirs();
|
regionStorageDirectory.mkdirs();
|
||||||
for (Map.Entry<Region, HashMap<String, LuaValue>> entry : REGION_STORAGE.entrySet()) {
|
for (Map.Entry<Region, HashMap<String, LuaValue>> entry : REGION_STORAGE.entrySet()) {
|
||||||
try {
|
try {
|
||||||
FileWriter fileWriter = new FileWriter(new File(regionStorageDirectory, entry.getKey().getName() + ".json"));
|
FileWriter fileWriter = new FileWriter(new File(regionStorageDirectory, entry.getKey().getID().toString() + ".json"));
|
||||||
gson.toJson(toJson(entry.getValue()), fileWriter);
|
gson.toJson(toJson(entry.getValue()), fileWriter);
|
||||||
fileWriter.close();
|
fileWriter.close();
|
||||||
} catch (IOException e) {}
|
} catch (IOException e) {}
|
||||||
|
|||||||
@ -54,7 +54,7 @@ public class ShieldPrintingCommand extends SWCommand implements Listener {
|
|||||||
@Register
|
@Register
|
||||||
public void genericCommand(@Validator Player player, ShieldPrintingState shieldPrintingState) {
|
public void genericCommand(@Validator Player player, ShieldPrintingState shieldPrintingState) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region.isGlobal()) {
|
if (region.getType().isGlobal()) {
|
||||||
BauSystem.MESSAGE.send("SHIELD_PRINTING_NO_REGION", player);
|
BauSystem.MESSAGE.send("SHIELD_PRINTING_NO_REGION", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -90,7 +90,7 @@ public class ShieldPrintingCommand extends SWCommand implements Listener {
|
|||||||
@Register("stop")
|
@Register("stop")
|
||||||
public void stopCommand(@Validator Player player) {
|
public void stopCommand(@Validator Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region.isGlobal()) {
|
if (region.getType().isGlobal()) {
|
||||||
BauSystem.MESSAGE.send("SHIELD_PRINTING_NO_REGION", player);
|
BauSystem.MESSAGE.send("SHIELD_PRINTING_NO_REGION", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ public class ShieldPrintingCommand extends SWCommand implements Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region.isGlobal()) {
|
if (region.getType().isGlobal()) {
|
||||||
messageSender.send("SHIELD_PRINTING_NO_REGION", player);
|
messageSender.send("SHIELD_PRINTING_NO_REGION", player);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.features.shieldprinting.BlockDataConfiguration;
|
import de.steamwar.bausystem.features.shieldprinting.BlockDataConfiguration;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.data.BlockData;
|
|
||||||
import org.bukkit.block.data.type.Piston;
|
import org.bukkit.block.data.type.Piston;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|||||||
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.simulator;
|
package de.steamwar.bausystem.features.simulator;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
|
import de.steamwar.Reflection;
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.SWUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
@ -40,10 +40,13 @@ import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
|||||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||||
import de.steamwar.bausystem.utils.ItemUtils;
|
import de.steamwar.bausystem.utils.ItemUtils;
|
||||||
import de.steamwar.bausystem.utils.RayTraceUtils;
|
import de.steamwar.bausystem.utils.RayTraceUtils;
|
||||||
|
import de.steamwar.data.CMDs;
|
||||||
import de.steamwar.entity.REntity;
|
import de.steamwar.entity.REntity;
|
||||||
import de.steamwar.entity.REntityServer;
|
import de.steamwar.entity.REntityServer;
|
||||||
import de.steamwar.entity.RFallingBlockEntity;
|
import de.steamwar.entity.RFallingBlockEntity;
|
||||||
import de.steamwar.inventory.SWAnvilInv;
|
import de.steamwar.inventory.SWAnvilInv;
|
||||||
|
import de.steamwar.inventory.SWInventory;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.MinVersion;
|
import de.steamwar.linkage.MinVersion;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@ -147,8 +150,23 @@ public class SimulatorCursor implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (LAST_SNEAKS.containsKey(player)) {
|
if (LAST_SNEAKS.containsKey(player)) {
|
||||||
cursorType.put(player, cursorType.getOrDefault(player, CursorType.TNT).switchType());
|
SWInventory swInventory = new SWInventory(player, 9, "Simulator Cursor");
|
||||||
calcCursor(player);
|
int slot = 2;
|
||||||
|
CursorType currentType = cursorType.getOrDefault(player, CursorType.TNT);
|
||||||
|
for (CursorType type : CursorType.values()) {
|
||||||
|
boolean selected = type == currentType;
|
||||||
|
SWItem swItem = new SWItem(selected ? type.material : type.nonSelectedMaterial, "§e" + type.name)
|
||||||
|
.setCustomModelData(selected ? 0 : CMDs.Simulator.NEW_PHASE)
|
||||||
|
.setLore(Collections.singletonList("§eClick to select"))
|
||||||
|
.setCallback(click -> {
|
||||||
|
cursorType.put(player, type);
|
||||||
|
calcCursor(player);
|
||||||
|
player.closeInventory();
|
||||||
|
});
|
||||||
|
swInventory.setItem(slot, swItem);
|
||||||
|
slot += 2;
|
||||||
|
}
|
||||||
|
swInventory.open();
|
||||||
} else {
|
} else {
|
||||||
LAST_SNEAKS.put(player, System.currentTimeMillis());
|
LAST_SNEAKS.put(player, System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
@ -331,25 +349,16 @@ public class SimulatorCursor implements Listener {
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum CursorType {
|
public enum CursorType {
|
||||||
TNT(Material.TNT, SimulatorCursor::getPosFree, "TNT", vector -> new TNTElement(vector).add(new TNTPhase())),
|
TNT(Material.TNT, Material.GUNPOWDER, SimulatorCursor::getPosFree, "TNT", vector -> new TNTElement(vector).add(new TNTPhase())),
|
||||||
REDSTONE_BLOCK(Material.REDSTONE_BLOCK, SimulatorCursor::getPosBlockAligned, "Redstone Block", vector -> new RedstoneElement(vector).add(new RedstonePhase())),
|
REDSTONE_BLOCK(Material.REDSTONE_BLOCK, Material.REDSTONE, SimulatorCursor::getPosBlockAligned, "Redstone Block", vector -> new RedstoneElement(vector).add(new RedstonePhase())),
|
||||||
OBSERVER(Material.OBSERVER, SimulatorCursor::getPosBlockAligned, "Observer", vector -> new ObserverElement(vector).add(new ObserverPhase())),
|
OBSERVER(Material.OBSERVER, Material.QUARTZ, SimulatorCursor::getPosBlockAligned, "Observer", vector -> new ObserverElement(vector).add(new ObserverPhase())),
|
||||||
;
|
;
|
||||||
|
|
||||||
private Material material;
|
private Material material;
|
||||||
|
private Material nonSelectedMaterial;
|
||||||
private BiFunction<Player, RayTraceUtils.RRayTraceResult, Vector> position;
|
private BiFunction<Player, RayTraceUtils.RRayTraceResult, Vector> position;
|
||||||
private String name;
|
private String name;
|
||||||
private Function<Vector, SimulatorElement<?>> elementFunction;
|
private Function<Vector, SimulatorElement<?>> elementFunction;
|
||||||
|
|
||||||
public CursorType switchType() {
|
|
||||||
if (this == TNT) {
|
|
||||||
return REDSTONE_BLOCK;
|
|
||||||
}
|
|
||||||
if (this == REDSTONE_BLOCK) {
|
|
||||||
return OBSERVER;
|
|
||||||
}
|
|
||||||
return TNT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|||||||
@ -33,7 +33,6 @@ import yapion.hierarchy.types.YAPIONObject;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
@ -25,8 +25,6 @@ import lombok.Setter;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import yapion.hierarchy.types.YAPIONObject;
|
import yapion.hierarchy.types.YAPIONObject;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import de.steamwar.bausystem.features.simulator.data.SimulatorPhase;
|
|||||||
import de.steamwar.bausystem.features.simulator.execute.SimulatorAction;
|
import de.steamwar.bausystem.features.simulator.execute.SimulatorAction;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
|
import de.steamwar.bausystem.region.flags.FreezeMode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@ -65,7 +65,7 @@ public final class TNTPhase extends SimulatorPhase {
|
|||||||
@Override
|
@Override
|
||||||
public void accept(World world) {
|
public void accept(World world) {
|
||||||
Location location = position.toLocation(world);
|
Location location = position.toLocation(world);
|
||||||
if (Region.getRegion(location).get(Flag.FREEZE) == FreezeMode.ACTIVE) return;
|
if (Region.getRegion(location).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) return;
|
||||||
TNTPrimed tnt = world.spawn(location, TNTPrimed.class);
|
TNTPrimed tnt = world.spawn(location, TNTPrimed.class);
|
||||||
if (!xJump) tnt.setVelocity(tnt.getVelocity().setX(0));
|
if (!xJump) tnt.setVelocity(tnt.getVelocity().setX(0));
|
||||||
if (!yJump) tnt.setVelocity(tnt.getVelocity().setY(0));
|
if (!yJump) tnt.setVelocity(tnt.getVelocity().setY(0));
|
||||||
|
|||||||
@ -45,7 +45,7 @@ public class StabDirection extends StabStep {
|
|||||||
@Override
|
@Override
|
||||||
protected void start() {
|
protected void start() {
|
||||||
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) {
|
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) {
|
||||||
e.setBlocks((com.sk89q.worldedit.regions.Region) new CuboidRegion(data.region.getMinPointTestblockExtension().toBlockVector3(), data.region.getMaxPointTestblockExtension().toBlockVector3()), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock());
|
e.setBlocks((com.sk89q.worldedit.regions.Region) new CuboidRegion(data.region.getTestblockArea().getMinPoint(true).toBlockVector3(), data.region.getTestblockArea().getMaxPoint(true).toBlockVector3()), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
Trace trace = TraceRecorder.instance.startRecording(data.region);
|
Trace trace = TraceRecorder.instance.startRecording(data.region);
|
||||||
|
|||||||
@ -19,12 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.simulator.execute;
|
package de.steamwar.bausystem.features.simulator.execute;
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.tracer.Trace;
|
|
||||||
import de.steamwar.bausystem.features.tracer.TraceRecorder;
|
import de.steamwar.bausystem.features.tracer.TraceRecorder;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||||
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
||||||
|
|
||||||
@ -38,9 +34,11 @@ public class StabFinalizer extends StabStep {
|
|||||||
protected void start() {
|
protected void start() {
|
||||||
try {
|
try {
|
||||||
PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard);
|
PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard);
|
||||||
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider)
|
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider);
|
||||||
.color(data.region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
if (data.region.getFlags().has(Flag.COLOR).isReadable()) {
|
||||||
data.region.reset(pasteBuilder, RegionType.TESTBLOCK, RegionExtensionType.EXTENSION);
|
pasteBuilder.color(data.region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||||
|
}
|
||||||
|
data.region.getTestblockArea().reset(pasteBuilder, true);
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
stop();
|
stop();
|
||||||
throw e;
|
throw e;
|
||||||
|
|||||||
@ -22,9 +22,6 @@ package de.steamwar.bausystem.features.simulator.execute;
|
|||||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
|
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||||
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -56,7 +53,8 @@ public class StabGenerator extends StabStep implements Listener {
|
|||||||
public void onEntityExplode(EntityExplodeEvent event) {
|
public void onEntityExplode(EntityExplodeEvent event) {
|
||||||
if (Region.getRegion(event.getEntity().getLocation()) == data.region) {
|
if (Region.getRegion(event.getEntity().getLocation()) == data.region) {
|
||||||
event.blockList().forEach(block -> {
|
event.blockList().forEach(block -> {
|
||||||
if (!data.region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) return;
|
if (!data.region.getTestblockArea().inRegion(block.getLocation(), true))
|
||||||
|
return;
|
||||||
int component = data.direction.component.apply(block.getLocation().toVector());
|
int component = data.direction.component.apply(block.getLocation().toVector());
|
||||||
destroyedBlocksPerSlice.computeIfAbsent(component, __ -> new HashSet<>())
|
destroyedBlocksPerSlice.computeIfAbsent(component, __ -> new HashSet<>())
|
||||||
.add(block.getLocation());
|
.add(block.getLocation());
|
||||||
@ -72,9 +70,11 @@ public class StabGenerator extends StabStep implements Listener {
|
|||||||
protected void start() {
|
protected void start() {
|
||||||
try {
|
try {
|
||||||
PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard);
|
PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard);
|
||||||
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider)
|
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider);
|
||||||
.color(data.region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
if (data.region.getFlags().has(Flag.COLOR).isReadable()) {
|
||||||
data.region.reset(pasteBuilder, RegionType.TESTBLOCK, RegionExtensionType.EXTENSION);
|
pasteBuilder.color(data.region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||||
|
}
|
||||||
|
data.region.getTestblockArea().reset(pasteBuilder, true);
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
stop();
|
stop();
|
||||||
throw e;
|
throw e;
|
||||||
|
|||||||
@ -72,7 +72,7 @@ public class StabSetup extends StabStep {
|
|||||||
if (TraceRecorder.instance.isAutoTraceEnabledInRegion(data.region)) {
|
if (TraceRecorder.instance.isAutoTraceEnabledInRegion(data.region)) {
|
||||||
TraceRecorder.instance.removeAutoTraceRegion(data.region);
|
TraceRecorder.instance.removeAutoTraceRegion(data.region);
|
||||||
}
|
}
|
||||||
data.clipboard = FlatteningWrapper.impl.copy(data.region.getMinPointTestblockExtension(), data.region.getMaxPointTestblockExtension(), data.region.getTestBlockPoint());
|
data.clipboard = FlatteningWrapper.impl.copy(data.region.getTestblockArea().getMinPoint(true), data.region.getTestblockArea().getMaxPoint(true), data.region.getTestblockArea().getCopyPoint());
|
||||||
|
|
||||||
new StabDirection(data);
|
new StabDirection(data);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,12 +20,10 @@
|
|||||||
package de.steamwar.bausystem.features.slaves.laufbau;
|
package de.steamwar.bausystem.features.slaves.laufbau;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.bausystem.SWUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.shared.Pair;
|
import de.steamwar.bausystem.shared.Pair;
|
||||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|||||||
@ -20,14 +20,12 @@
|
|||||||
package de.steamwar.bausystem.features.slaves.panzern;
|
package de.steamwar.bausystem.features.slaves.panzern;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.bausystem.SWUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.shared.Pair;
|
import de.steamwar.bausystem.shared.Pair;
|
||||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||||
import de.steamwar.command.PreviousArguments;
|
import de.steamwar.command.PreviousArguments;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|||||||
@ -19,11 +19,10 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.team;
|
package de.steamwar.bausystem.features.team;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.features.team.boundary.BoundaryViewer;
|
import de.steamwar.bausystem.features.team.boundary.BoundaryViewer;
|
||||||
import de.steamwar.bausystem.region.Prototype;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.command.PreviousArguments;
|
import de.steamwar.command.PreviousArguments;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
@ -69,14 +68,14 @@ public class SkinCommand extends SWCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
if (region.isGlobal()) {
|
if (region.getType().isGlobal()) {
|
||||||
BauSystem.MESSAGE.send("SKIN_NO_REGION", p);
|
BauSystem.MESSAGE.send("SKIN_NO_REGION", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String name = String.join(" ", names);
|
String name = String.join(" ", names);
|
||||||
File arenaFile = new File("sections19/" + name + "/" + typeKuerzel + "Arena.schem");
|
File arenaFile = new File("sections19/" + name + "/" + typeKuerzel + "Arena.schem");
|
||||||
File testblockFile = region.hasType(RegionType.TESTBLOCK) ? new File("sections19/" + name + "/" + typeKuerzel + "Testblock.schem") : null;
|
File testblockFile = !region.getTestblockArea().isEmpty() ? new File("sections19/" + name + "/" + typeKuerzel + "Testblock.schem") : null;
|
||||||
|
|
||||||
arenaFile.getParentFile().mkdirs();
|
arenaFile.getParentFile().mkdirs();
|
||||||
if (testblockFile != null) {
|
if (testblockFile != null) {
|
||||||
@ -91,9 +90,11 @@ public class SkinCommand extends SWCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Region.copy(region.getMinPoint(), region.getMaxPoint(), arenaFile);
|
EditSession editSession = region.getArea().copy(false);
|
||||||
|
// TODO: Save editSession to file
|
||||||
if (testblockFile != null) {
|
if (testblockFile != null) {
|
||||||
Region.copy(region.getMinPointTestblock(), region.getMaxPointTestblock(), testblockFile);
|
editSession = region.getTestblockArea().copy(false);
|
||||||
|
// TODO: Save editSession to file
|
||||||
}
|
}
|
||||||
|
|
||||||
YAPIONObject yapionObject = new YAPIONObject();
|
YAPIONObject yapionObject = new YAPIONObject();
|
||||||
@ -22,9 +22,7 @@ package de.steamwar.bausystem.features.team.boundary;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.region.Point;
|
import de.steamwar.bausystem.region.Point;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.core.TrickyParticleWrapper;
|
import de.steamwar.core.TrickyParticleWrapper;
|
||||||
import de.steamwar.core.TrickyTrialsWrapper;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
@ -48,22 +46,19 @@ public class BoundaryViewer implements Listener {
|
|||||||
}
|
}
|
||||||
viewers.forEach(player -> {
|
viewers.forEach(player -> {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region.isGlobal()) return;
|
if (region.getType().isGlobal()) return;
|
||||||
showRegion(region, player);
|
showRegion(region, player);
|
||||||
if (region.getLinkedRegion() != null) {
|
|
||||||
showRegion(region.getLinkedRegion(), player);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}, 20, 20);
|
}, 20, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showRegion(Region region, Player player) {
|
private void showRegion(Region region, Player player) {
|
||||||
drawCuboid(player, TrickyParticleWrapper.impl.getVillagerHappy(), region.getMinPoint(), region.getMaxPoint());
|
drawCuboid(player, TrickyParticleWrapper.impl.getVillagerHappy(), region.getArea().getMinPoint(false), region.getArea().getMaxPoint(false));
|
||||||
if (region.hasType(RegionType.TESTBLOCK)) {
|
if (!region.getTestblockArea().isEmpty()) {
|
||||||
drawCuboid(player, Particle.END_ROD, region.getMinPointTestblockExtension(), region.getMaxPointTestblockExtension());
|
drawCuboid(player, Particle.END_ROD, region.getTestblockArea().getMinPoint(true), region.getTestblockArea().getMaxPoint(true));
|
||||||
}
|
}
|
||||||
if (region.hasType(RegionType.BUILD)) {
|
if (!region.getBuildArea().isEmpty()) {
|
||||||
drawCuboid(player, Particle.END_ROD, region.getMinPointBuildExtension(), region.getMaxPointBuildExtension());
|
drawCuboid(player, Particle.END_ROD, region.getBuildArea().getMinPoint(true), region.getBuildArea().getMaxPoint(true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -63,32 +63,22 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE
|
|||||||
@Register(description = "TECHHIDER_HELP")
|
@Register(description = "TECHHIDER_HELP")
|
||||||
public void toggleHider(@Validator Player player) {
|
public void toggleHider(@Validator Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region.isGlobal()) {
|
if (region.getType().isGlobal()) {
|
||||||
BauSystem.MESSAGE.send("TECHHIDER_GLOBAL", player);
|
BauSystem.MESSAGE.send("TECHHIDER_GLOBAL", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<TechHider> techHider = techHiders.computeIfAbsent(region, rg -> {
|
Optional<TechHider> techHider = techHiders.computeIfAbsent(region, rg -> {
|
||||||
File file = rg.gameModeConfig();
|
if (!region.getGameModeConfig().getTechhider().isActive()) {
|
||||||
if (file == null) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
|
||||||
if (!config.getBoolean("Techhider.Active", false)) {
|
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
hidden.put(rg, new HashSet<>());
|
hidden.put(rg, new HashSet<>());
|
||||||
|
|
||||||
String obfuscateWith = config.getString("Techhider.ObfuscateWith", "end_stone");
|
TechHider current = new TechHider((p, cX, cY) -> {
|
||||||
Set<String> hiddenBlocks = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlocks")));
|
if (rg.getBuildArea().isChunkOutside(cX, cY)) return true;
|
||||||
Set<String> hiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities")));
|
|
||||||
|
|
||||||
TechHider current = new TechHider((TechHider.LocationEvaluator) (p, cX, cY) -> {
|
|
||||||
if (rg.buildChunkOutside(cX, cY)) return true;
|
|
||||||
return !hidden.get(rg).contains(p);
|
return !hidden.get(rg).contains(p);
|
||||||
}, Material.valueOf(obfuscateWith.toUpperCase()), hiddenBlocks.stream().map(String::toUpperCase).map(Material::valueOf).collect(Collectors.toSet()), hiddenBlockEntities);
|
}, region.getGameModeConfig().getTechhider().getObfuscateWith(), region.getGameModeConfig().getTechhider().getHiddenBlocks(), region.getGameModeConfig().getTechhider().getHiddenBlockEntities());
|
||||||
current.enable();
|
current.enable();
|
||||||
|
|
||||||
return Optional.of(current);
|
return Optional.of(current);
|
||||||
@ -105,7 +95,7 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE
|
|||||||
hidden.get(region).add(player);
|
hidden.get(region).add(player);
|
||||||
BauSystem.MESSAGE.sendPrefixless("TECHHIDER_ON", player, ChatMessageType.ACTION_BAR);
|
BauSystem.MESSAGE.sendPrefixless("TECHHIDER_ON", player, ChatMessageType.ACTION_BAR);
|
||||||
}
|
}
|
||||||
region.forEachChunk((x, z) -> {
|
region.getBuildArea().forEachChunk((x, z) -> {
|
||||||
CraftbukkitWrapper.impl.sendChunk(player, x, z);
|
CraftbukkitWrapper.impl.sendChunk(player, x, z);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,7 +24,6 @@ import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
|||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
|||||||
@ -20,8 +20,6 @@
|
|||||||
package de.steamwar.bausystem.features.testblock.blockcounter;
|
package de.steamwar.bausystem.features.testblock.blockcounter;
|
||||||
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -37,11 +35,13 @@ public class BlockCounterListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityExplode(EntityExplodeEvent event) {
|
public void onEntityExplode(EntityExplodeEvent event) {
|
||||||
Region region = Region.getRegion(event.getLocation());
|
Region region = Region.getRegion(event.getLocation());
|
||||||
if (region.isGlobal()) {
|
if (region.getType().isGlobal()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<Block> blockList = event.blockList();
|
List<Block> blockList = event.blockList();
|
||||||
blockList = blockList.stream().filter(block -> region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)).collect(Collectors.toList());
|
blockList = blockList.stream()
|
||||||
|
.filter(block -> region.getTestblockArea().inRegion(block.getLocation(), true))
|
||||||
|
.collect(Collectors.toList());
|
||||||
if (blockList.isEmpty()) {
|
if (blockList.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.SWUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||||
import de.steamwar.bausystem.region.GlobalRegion;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
import de.steamwar.bausystem.utils.TickEndEvent;
|
import de.steamwar.bausystem.utils.TickEndEvent;
|
||||||
@ -85,14 +84,14 @@ public class TPSSystem implements Listener {
|
|||||||
private void bossbar() {
|
private void bossbar() {
|
||||||
if ((TickManager.impl.isStepping() || TickManager.impl.isSprinting()) && TickManager.impl.getRemainingTicks() > 0) {
|
if ((TickManager.impl.isStepping() || TickManager.impl.isSprinting()) && TickManager.impl.getRemainingTicks() > 0) {
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||||
BauSystemBossbar bossbar = BossBarService.instance.get(player, GlobalRegion.getInstance(), "TickStep");
|
BauSystemBossbar bossbar = BossBarService.instance.get(player, Region.getGlobalRegion(), "TickStep");
|
||||||
bossbar.setColor(BarColor.YELLOW);
|
bossbar.setColor(BarColor.YELLOW);
|
||||||
bossbar.setTitle(BauSystem.MESSAGE.parse("TICK_BOSSBAR", player, TickManager.impl.getDoneTicks(), TickManager.impl.getTotalTicks()));
|
bossbar.setTitle(BauSystem.MESSAGE.parse("TICK_BOSSBAR", player, TickManager.impl.getDoneTicks(), TickManager.impl.getTotalTicks()));
|
||||||
bossbar.setProgress(TickManager.impl.getDoneTicks() / (double) TickManager.impl.getTotalTicks());
|
bossbar.setProgress(TickManager.impl.getDoneTicks() / (double) TickManager.impl.getTotalTicks());
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||||
BossBarService.instance.remove(player, GlobalRegion.getInstance(), "TickStep");
|
BossBarService.instance.remove(player, Region.getGlobalRegion(), "TickStep");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,8 +20,6 @@
|
|||||||
package de.steamwar.bausystem.features.tracer;
|
package de.steamwar.bausystem.features.tracer;
|
||||||
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@ -39,7 +37,7 @@ import java.util.Optional;
|
|||||||
*/
|
*/
|
||||||
@AllArgsConstructor(access = AccessLevel.PACKAGE)
|
@AllArgsConstructor(access = AccessLevel.PACKAGE)
|
||||||
@Getter
|
@Getter
|
||||||
public class TNTPoint{
|
public class TNTPoint {
|
||||||
/**
|
/**
|
||||||
* Unique number to identify records being of the same tnt
|
* Unique number to identify records being of the same tnt
|
||||||
*/
|
*/
|
||||||
@ -99,7 +97,7 @@ public class TNTPoint{
|
|||||||
* Constructor for object creation in trace recording
|
* Constructor for object creation in trace recording
|
||||||
*/
|
*/
|
||||||
protected TNTPoint(int tntId, TNTPrimed tnt, boolean explosion, boolean afterFirstExplosion, long ticksSinceStart,
|
protected TNTPoint(int tntId, TNTPrimed tnt, boolean explosion, boolean afterFirstExplosion, long ticksSinceStart,
|
||||||
List<TNTPoint> history, List<Block> destroyedBlocks) {
|
List<TNTPoint> history, List<Block> destroyedBlocks) {
|
||||||
this.tntId = tntId;
|
this.tntId = tntId;
|
||||||
this.explosion = explosion;
|
this.explosion = explosion;
|
||||||
if (Core.getVersion() > 15) {
|
if (Core.getVersion() > 15) {
|
||||||
@ -117,12 +115,10 @@ public class TNTPoint{
|
|||||||
boolean buildDestroy = false;
|
boolean buildDestroy = false;
|
||||||
boolean testblockDestroy = false;
|
boolean testblockDestroy = false;
|
||||||
for (Block destroyedBlock : destroyedBlocks) {
|
for (Block destroyedBlock : destroyedBlocks) {
|
||||||
if (Region.getRegion(destroyedBlock.getLocation()).inRegion(destroyedBlock.getLocation(), RegionType.BUILD,
|
if (Region.getRegion(destroyedBlock.getLocation()).getBuildArea().inRegion(destroyedBlock.getLocation(), true)) {
|
||||||
RegionExtensionType.EXTENSION)) {
|
|
||||||
buildDestroy = true;
|
buildDestroy = true;
|
||||||
}
|
}
|
||||||
if (Region.getRegion(destroyedBlock.getLocation()).inRegion(destroyedBlock.getLocation(),
|
if (Region.getRegion(destroyedBlock.getLocation()).getTestblockArea().inRegion(destroyedBlock.getLocation(), true)) {
|
||||||
RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) {
|
|
||||||
testblockDestroy = true;
|
testblockDestroy = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,12 +25,10 @@ import de.steamwar.bausystem.features.tracer.rendering.dynamicflags.AtFlag;
|
|||||||
import de.steamwar.bausystem.features.tracer.rendering.dynamicflags.IsolateFlag;
|
import de.steamwar.bausystem.features.tracer.rendering.dynamicflags.IsolateFlag;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.server.PluginEnableEvent;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package de.steamwar.bausystem.features.tracer;
|
package de.steamwar.bausystem.features.tracer;
|
||||||
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
import de.steamwar.bausystem.region.RegionSystem;
|
||||||
import lombok.Cleanup;
|
import lombok.Cleanup;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -17,7 +18,7 @@ public class TraceRepository {
|
|||||||
/**
|
/**
|
||||||
* Increment this when changing serialisation format
|
* Increment this when changing serialisation format
|
||||||
*/
|
*/
|
||||||
public static final int SERIALISATION_VERSION = 2;
|
public static final int SERIALISATION_VERSION = 3;
|
||||||
public static final int WRITE_TICK_DATA = 0b00000001;
|
public static final int WRITE_TICK_DATA = 0b00000001;
|
||||||
public static final int EXPLOSION = 0b00000010;
|
public static final int EXPLOSION = 0b00000010;
|
||||||
public static final int IN_WATER = 0b00000100;
|
public static final int IN_WATER = 0b00000100;
|
||||||
@ -30,8 +31,19 @@ public class TraceRepository {
|
|||||||
public static Trace readTrace(File recordsFile) {
|
public static Trace readTrace(File recordsFile) {
|
||||||
@Cleanup
|
@Cleanup
|
||||||
ObjectInputStream reader = new ObjectInputStream(new GZIPInputStream(new FileInputStream(recordsFile)));
|
ObjectInputStream reader = new ObjectInputStream(new GZIPInputStream(new FileInputStream(recordsFile)));
|
||||||
UUID uuid = UUID.fromString(reader.readUTF());
|
UUID uuid;
|
||||||
Region region = Region.getREGION_MAP().get(reader.readUTF());
|
try {
|
||||||
|
uuid = UUID.fromString(reader.readUTF());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Region region;
|
||||||
|
try {
|
||||||
|
region = RegionSystem.INSTANCE.getRegion(UUID.fromString(reader.readUTF())).orElse(null);
|
||||||
|
if (region == null) return null;
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
Date date = (Date) reader.readObject();
|
Date date = (Date) reader.readObject();
|
||||||
int serialisationVersion = reader.readInt();
|
int serialisationVersion = reader.readInt();
|
||||||
if (serialisationVersion != SERIALISATION_VERSION) {
|
if (serialisationVersion != SERIALISATION_VERSION) {
|
||||||
@ -46,7 +58,7 @@ public class TraceRepository {
|
|||||||
protected static void writeTrace(Trace trace, List<TNTPoint> records) {
|
protected static void writeTrace(Trace trace, List<TNTPoint> records) {
|
||||||
ObjectOutputStream outputStream = new ObjectOutputStream(new GZIPOutputStream(new FileOutputStream(trace.getRecordsSaveFile())));
|
ObjectOutputStream outputStream = new ObjectOutputStream(new GZIPOutputStream(new FileOutputStream(trace.getRecordsSaveFile())));
|
||||||
outputStream.writeUTF(trace.getUuid().toString());
|
outputStream.writeUTF(trace.getUuid().toString());
|
||||||
outputStream.writeUTF(trace.getRegion().getName());
|
outputStream.writeUTF(trace.getRegion().getID().toString());
|
||||||
outputStream.writeObject(trace.getDate());
|
outputStream.writeObject(trace.getDate());
|
||||||
outputStream.writeInt(SERIALISATION_VERSION);
|
outputStream.writeInt(SERIALISATION_VERSION);
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.SWUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.features.script.ScriptCommand;
|
|
||||||
import de.steamwar.bausystem.features.script.ScriptRunner;
|
import de.steamwar.bausystem.features.script.ScriptRunner;
|
||||||
import de.steamwar.bausystem.features.world.WorldEditListener;
|
import de.steamwar.bausystem.features.world.WorldEditListener;
|
||||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||||
@ -28,10 +27,12 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
import org.luaj.vm2.LuaValue;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.*;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|||||||
@ -20,9 +20,7 @@
|
|||||||
package de.steamwar.bausystem.features.util;
|
package de.steamwar.bausystem.features.util;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|||||||
@ -21,12 +21,8 @@ package de.steamwar.bausystem.features.util;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.SWUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.region.GlobalRegion;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionSelectionType;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -53,7 +49,7 @@ public class KillAllCommand extends SWCommand {
|
|||||||
public void genericCommand(@Validator Player player, RegionSelectionType regionSelectionType) {
|
public void genericCommand(@Validator Player player, RegionSelectionType regionSelectionType) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
AtomicLong count = new AtomicLong(0);
|
AtomicLong count = new AtomicLong(0);
|
||||||
if (regionSelectionType == RegionSelectionType.GLOBAL || GlobalRegion.getInstance() == region) {
|
if (regionSelectionType == RegionSelectionType.GLOBAL || region.getType().isGlobal()) {
|
||||||
WORLD.getEntities()
|
WORLD.getEntities()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(e -> !(e instanceof Player))
|
.filter(e -> !(e instanceof Player))
|
||||||
@ -66,7 +62,7 @@ public class KillAllCommand extends SWCommand {
|
|||||||
WORLD.getEntities()
|
WORLD.getEntities()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(e -> !(e instanceof Player))
|
.filter(e -> !(e instanceof Player))
|
||||||
.filter(e -> region.inRegion(e.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL))
|
.filter(e -> region.getArea().inRegion(e.getLocation(), false))
|
||||||
.forEach(entity -> {
|
.forEach(entity -> {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
count.incrementAndGet();
|
count.incrementAndGet();
|
||||||
@ -74,5 +70,4 @@ public class KillAllCommand extends SWCommand {
|
|||||||
RegionUtils.actionBar(region, "OTHER_KILLALL_REGION", count.get());
|
RegionUtils.actionBar(region, "OTHER_KILLALL_REGION", count.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,13 +21,9 @@ package de.steamwar.bausystem.features.util;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.entity.REntityServer;
|
import de.steamwar.entity.*;
|
||||||
import de.steamwar.entity.RFallingBlockEntity;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import lombok.AllArgsConstructor;
|
import de.steamwar.linkage.MinVersion;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.ToString;
|
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -37,118 +33,347 @@ import org.bukkit.block.PistonMoveReaction;
|
|||||||
import org.bukkit.block.TileState;
|
import org.bukkit.block.TileState;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.block.data.type.Piston;
|
import org.bukkit.block.data.type.Piston;
|
||||||
|
import org.bukkit.entity.Display;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.TextDisplay;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.*;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
|
@MinVersion(20)
|
||||||
public class PistonCalculator implements Listener {
|
public class PistonCalculator implements Listener {
|
||||||
|
|
||||||
|
private final Map<Player, Long> DEBOUNCE = new HashMap<>();
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
||||||
if (!event.hasItem() || event.getItem().getType() != Material.SLIME_BALL) return;
|
if (event.getItem() == null) {
|
||||||
|
} else if (event.getItem() != null && event.getItem().getType() == Material.SLIME_BALL) {
|
||||||
|
} else if (!event.getItem().getType().isBlock()) {
|
||||||
|
DEBOUNCE.put(event.getPlayer(), System.currentTimeMillis());
|
||||||
|
return;
|
||||||
|
} else return;
|
||||||
if (event.getClickedBlock() == null) return;
|
if (event.getClickedBlock() == null) return;
|
||||||
Block clickedBlock = event.getClickedBlock();
|
Block clickedBlock = event.getClickedBlock();
|
||||||
Material blockType = clickedBlock.getType();
|
Material blockType = clickedBlock.getType();
|
||||||
if (!(blockType == Material.PISTON || blockType == Material.STICKY_PISTON)) return;
|
if (!(blockType == Material.PISTON || blockType == Material.STICKY_PISTON)) return;
|
||||||
Piston piston = (Piston) clickedBlock.getBlockData();
|
if (System.currentTimeMillis() - DEBOUNCE.getOrDefault(event.getPlayer(), 0L) <= 200) return;
|
||||||
|
DEBOUNCE.put(event.getPlayer(), System.currentTimeMillis());
|
||||||
|
|
||||||
if (blockType == Material.PISTON && piston.isExtended()) {
|
Location location = event.getClickedBlock().getLocation();
|
||||||
BauSystem.MESSAGE.sendPrefixless("PISTON_INFO", event.getPlayer(), ChatMessageType.ACTION_BAR, "§a", 0);
|
if (pistOrders.containsKey(location)) {
|
||||||
|
PistOrder pistOrder = pistOrders.get(location);
|
||||||
|
if (pistOrder.server.getPlayers().contains(event.getPlayer())) {
|
||||||
|
pistOrder.server.removePlayer(event.getPlayer());
|
||||||
|
} else {
|
||||||
|
pistOrder.server.addPlayer(event.getPlayer());
|
||||||
|
}
|
||||||
|
if (pistOrder.server.getPlayers().isEmpty()) {
|
||||||
|
pistOrders.remove(location);
|
||||||
|
pistOrder.server.close();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean pulling = blockType == Material.STICKY_PISTON && (clickedBlock.getRelative(piston.getFacing()).getType() == Material.AIR || piston.isExtended());
|
PistOrder pistOrder = new PistOrder(clickedBlock);
|
||||||
|
pistOrder.calculate();
|
||||||
|
pistOrder.server.addPlayer(event.getPlayer());
|
||||||
|
pistOrders.put(location, pistOrder);
|
||||||
|
}
|
||||||
|
|
||||||
CalculationResult result = calc(clickedBlock, piston.getFacing(), (pulling ? piston.getFacing().getOppositeFace() : piston.getFacing()));
|
@EventHandler
|
||||||
result.entityServer.addPlayer(event.getPlayer());
|
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||||
BauSystem.MESSAGE.sendPrefixless("PISTON_INFO", event.getPlayer(), ChatMessageType.ACTION_BAR, result.unmovable ? "§c" : (result.tooMany ? "§e" : "§a"), result.amount);
|
if (pistOrders.isEmpty()) return;
|
||||||
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
|
movePistOrders(event.getDirection(), event.getBlocks());
|
||||||
|
pistOrders.values().forEach(PistOrder::calculate);
|
||||||
|
}, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||||
|
if (pistOrders.isEmpty()) return;
|
||||||
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
|
movePistOrders(event.getDirection(), event.getBlocks());
|
||||||
|
pistOrders.values().forEach(PistOrder::calculate);
|
||||||
|
}, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void movePistOrders(BlockFace direction, List<Block> blocks) {
|
||||||
|
Set<PistOrder> orders = new HashSet<>();
|
||||||
|
blocks.forEach(block -> {
|
||||||
|
PistOrder pistOrder = pistOrders.get(block.getLocation());
|
||||||
|
if (pistOrder == null) return;
|
||||||
|
pistOrders.remove(block.getLocation());
|
||||||
|
pistOrder.piston = pistOrder.piston.getRelative(direction);
|
||||||
|
orders.add(pistOrder);
|
||||||
|
});
|
||||||
|
orders.forEach(pistOrder -> {
|
||||||
|
pistOrders.put(pistOrder.piston.getLocation(), pistOrder);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
|
if (pistOrders.isEmpty()) return;
|
||||||
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
|
pistOrders.values().forEach(PistOrder::calculate);
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
|
if (pistOrders.isEmpty()) return;
|
||||||
|
if (pistOrders.containsKey(event.getBlock().getLocation())) {
|
||||||
|
PistOrder pistOrder = pistOrders.remove(event.getBlock().getLocation());
|
||||||
|
pistOrder.server.close();
|
||||||
|
}
|
||||||
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
|
pistOrders.values().forEach(PistOrder::calculate);
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
DEBOUNCE.remove(event.getPlayer());
|
||||||
|
|
||||||
|
Set<Location> toRemove = new HashSet<>();
|
||||||
|
pistOrders.forEach((location, pistOrder) -> {
|
||||||
|
pistOrder.server.removePlayer(event.getPlayer());
|
||||||
|
if (pistOrder.server.getPlayers().isEmpty()) {
|
||||||
|
toRemove.add(location);
|
||||||
|
pistOrder.server.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
toRemove.forEach(pistOrders::remove);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final BlockFace[] FACES = new BlockFace[]{BlockFace.UP, BlockFace.DOWN, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST};
|
private final BlockFace[] FACES = new BlockFace[]{BlockFace.UP, BlockFace.DOWN, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST};
|
||||||
|
|
||||||
private CalculationResult calc(Block origin, BlockFace facing, BlockFace direction) {
|
private final Map<Location, PistOrder> pistOrders = new HashMap<>();
|
||||||
Set<Block> blockSet = new HashSet<>();
|
|
||||||
Set<Location> unmovable = new HashSet<>();
|
|
||||||
|
|
||||||
Block calcOrigin = origin;
|
private final class PistOrder {
|
||||||
if (facing != direction) calcOrigin = origin.getRelative(facing, 3);
|
private Block piston;
|
||||||
|
private REntityServer server = new REntityServer();
|
||||||
|
|
||||||
List<Block> toCalc = new LinkedList<>();
|
private boolean pulling = false;
|
||||||
calcDirection(origin, null, calcOrigin, facing != direction ? origin.getRelative(facing) : null, facing, direction, blockSet, toCalc, unmovable);
|
private List<Location> movedBlocks = new ArrayList<>();
|
||||||
|
private List<Location> brokenBlocks = new ArrayList<>();
|
||||||
|
private Set<Location> immovableBlocks = new HashSet<>();
|
||||||
|
|
||||||
while (!toCalc.isEmpty()) {
|
public PistOrder(Block piston) {
|
||||||
Block current = toCalc.remove(0);
|
this.piston = piston;
|
||||||
blockSet.add(current);
|
}
|
||||||
|
|
||||||
Material type = current.getType();
|
public void calculate() {
|
||||||
if (type != Material.SLIME_BLOCK && type != Material.HONEY_BLOCK) continue;
|
movedBlocks.clear();
|
||||||
Material oppositeType = type == Material.SLIME_BLOCK ? Material.HONEY_BLOCK : Material.SLIME_BLOCK;
|
brokenBlocks.clear();
|
||||||
|
immovableBlocks.clear();
|
||||||
|
|
||||||
for (BlockFace face : FACES) {
|
if (piston.isEmpty()) {
|
||||||
Block block = current.getRelative(face);
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
if (block.getType().isAir()) continue;
|
server.close();
|
||||||
if (!isPiston(block) && (block.getPistonMoveReaction() == PistonMoveReaction.BLOCK || block.getPistonMoveReaction() == PistonMoveReaction.IGNORE || block.getPistonMoveReaction() == PistonMoveReaction.PUSH_ONLY || block.getState() instanceof TileState || block.getPistonMoveReaction() == PistonMoveReaction.BREAK)) continue;
|
pistOrders.remove(piston.getLocation());
|
||||||
if (block.getType() != oppositeType) {
|
}, 0);
|
||||||
if (!blockSet.contains(block)) toCalc.add(block);
|
return;
|
||||||
calcDirection(null, origin, block, null, facing, direction, blockSet, toCalc, unmovable);
|
}
|
||||||
|
|
||||||
|
BlockData blockData = piston.getBlockData();
|
||||||
|
if (!(blockData instanceof Piston)) return;
|
||||||
|
Piston pistonData = (Piston) blockData;
|
||||||
|
if (piston.getType() == Material.PISTON && pistonData.isExtended()) {
|
||||||
|
visualize();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pulling = piston.getType() == Material.STICKY_PISTON && (piston.getRelative(pistonData.getFacing()).getType() == Material.AIR || pistonData.isExtended());
|
||||||
|
|
||||||
|
calculate(piston, pistonData.getFacing(), (pulling ? pistonData.getFacing().getOppositeFace() : pistonData.getFacing()));
|
||||||
|
|
||||||
|
Collections.reverse(movedBlocks);
|
||||||
|
Collections.reverse(brokenBlocks);
|
||||||
|
|
||||||
|
visualize();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void calculate(Block origin, BlockFace facing, BlockFace direction) {
|
||||||
|
Block calcOrigin = origin;
|
||||||
|
if (facing != direction) calcOrigin = origin.getRelative(facing, 3);
|
||||||
|
|
||||||
|
List<Block> toCalc = new LinkedList<>();
|
||||||
|
calcDirection(origin, null, calcOrigin, facing != direction ? origin.getRelative(facing) : null, facing, direction, toCalc);
|
||||||
|
|
||||||
|
while (!toCalc.isEmpty()) {
|
||||||
|
Block current = toCalc.remove(0);
|
||||||
|
if (!movedBlocks.contains(current.getLocation())) {
|
||||||
|
movedBlocks.add(current.getLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
Material type = current.getType();
|
||||||
|
if (type != Material.SLIME_BLOCK && type != Material.HONEY_BLOCK) continue;
|
||||||
|
Material oppositeType = type == Material.SLIME_BLOCK ? Material.HONEY_BLOCK : Material.SLIME_BLOCK;
|
||||||
|
|
||||||
|
for (BlockFace face : FACES) {
|
||||||
|
Block block = current.getRelative(face);
|
||||||
|
if (block.getType().isAir()) continue;
|
||||||
|
if (isImmovable(block) || block.getPistonMoveReaction() == PistonMoveReaction.BREAK) continue;
|
||||||
|
if (face != direction || face == direction.getOppositeFace()) {
|
||||||
|
switch (block.getType()) {
|
||||||
|
case BLACK_GLAZED_TERRACOTTA:
|
||||||
|
case GRAY_GLAZED_TERRACOTTA:
|
||||||
|
case BLUE_GLAZED_TERRACOTTA:
|
||||||
|
case BROWN_GLAZED_TERRACOTTA:
|
||||||
|
case CYAN_GLAZED_TERRACOTTA:
|
||||||
|
case GREEN_GLAZED_TERRACOTTA:
|
||||||
|
case LIGHT_BLUE_GLAZED_TERRACOTTA:
|
||||||
|
case LIGHT_GRAY_GLAZED_TERRACOTTA:
|
||||||
|
case LIME_GLAZED_TERRACOTTA:
|
||||||
|
case MAGENTA_GLAZED_TERRACOTTA:
|
||||||
|
case ORANGE_GLAZED_TERRACOTTA:
|
||||||
|
case PINK_GLAZED_TERRACOTTA:
|
||||||
|
case PURPLE_GLAZED_TERRACOTTA:
|
||||||
|
case RED_GLAZED_TERRACOTTA:
|
||||||
|
case WHITE_GLAZED_TERRACOTTA:
|
||||||
|
case YELLOW_GLAZED_TERRACOTTA:
|
||||||
|
continue;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (block.getType() != oppositeType) {
|
||||||
|
if (!movedBlocks.contains(block.getLocation())) toCalc.add(block);
|
||||||
|
calcDirection(null, origin, block, null, facing, direction, toCalc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
movedBlocks.remove(origin.getLocation());
|
||||||
|
if (facing != direction) movedBlocks.remove(origin.getRelative(facing, 1).getLocation());
|
||||||
|
if (pulling) immovableBlocks.remove(origin.getRelative(facing).getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
blockSet.remove(origin);
|
private void calcDirection(Block origin, Block blockOrigin, Block calcOrigin, Block ignore, BlockFace facing, BlockFace direction, List<Block> toCalc) {
|
||||||
if (facing != direction) blockSet.remove(origin.getRelative(facing, 1));
|
for (int i = 1; i < 24; i++) {
|
||||||
|
Block block = calcOrigin.getRelative(direction, i);
|
||||||
REntityServer entityServer = new REntityServer();
|
if (block.equals(ignore)) return;
|
||||||
for (Location loc : unmovable) {
|
if (block.getPistonMoveReaction() == PistonMoveReaction.BREAK) {
|
||||||
RFallingBlockEntity rFallingBlockEntity = new RFallingBlockEntity(entityServer, loc.clone().add(0.5, 0, 0.5), Material.RED_STAINED_GLASS);
|
if (!brokenBlocks.contains(block.getLocation())) {
|
||||||
rFallingBlockEntity.setGlowing(true);
|
brokenBlocks.add(block.getLocation());
|
||||||
rFallingBlockEntity.setNoGravity(true);
|
}
|
||||||
rFallingBlockEntity.setInvisible(true);
|
return;
|
||||||
|
}
|
||||||
|
if (isImmovable(block)) {
|
||||||
|
immovableBlocks.add(block.getLocation());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (block.getType().isAir()) return;
|
||||||
|
if (facing == direction && block.equals(blockOrigin)) {
|
||||||
|
immovableBlocks.add(block.getLocation());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (facing != direction && (block.equals(origin) || block.getRelative(facing.getOppositeFace()).equals(origin)))
|
||||||
|
return;
|
||||||
|
if (!movedBlocks.contains(block.getLocation())) toCalc.add(block);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), entityServer::close, 20);
|
|
||||||
return new CalculationResult(blockSet.size(), blockSet.size() > 12, !unmovable.isEmpty(), entityServer);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void calcDirection(Block origin, Block blockOrigin, Block calcOrigin, Block ignore, BlockFace facing, BlockFace direction, Set<Block> blockSet, List<Block> toCalc, Set<Location> unmovable) {
|
private void visualize() {
|
||||||
for (int i = 1; i < 24; i++) {
|
server.getEntities().forEach(REntity::die);
|
||||||
Block block = calcOrigin.getRelative(direction, i);
|
|
||||||
if (block.equals(ignore)) return;
|
for (int i = 0; i < movedBlocks.size(); i++) {
|
||||||
if (block.getPistonMoveReaction() == PistonMoveReaction.BREAK) return;
|
Location location = movedBlocks.get(i);
|
||||||
if (!isPiston(block) && (block.getPistonMoveReaction() == PistonMoveReaction.BLOCK || block.getPistonMoveReaction() == PistonMoveReaction.IGNORE || block.getState() instanceof TileState)) {
|
int order = i + 1;
|
||||||
unmovable.add(block.getLocation());
|
|
||||||
return;
|
CCubedTextDisplay display = new CCubedTextDisplay(server, location);
|
||||||
|
display.setText("§e" + order);
|
||||||
|
display.setBackgroundColor(0);
|
||||||
|
display.setShadowed(false);
|
||||||
|
|
||||||
|
Set<BlockFace> toHide = Arrays.stream(FACES).filter(blockFace -> {
|
||||||
|
return movedBlocks.contains(location.clone().add(blockFace.getModX(), blockFace.getModY(), blockFace.getModZ()));
|
||||||
|
}).collect(Collectors.toSet());
|
||||||
|
display.hide(toHide);
|
||||||
}
|
}
|
||||||
if (block.getType().isAir()) return;
|
|
||||||
if (facing == direction && block.equals(blockOrigin)) {
|
for (int i = 0; i < brokenBlocks.size(); i++) {
|
||||||
unmovable.add(block.getLocation());
|
Location location = brokenBlocks.get(i);
|
||||||
return;
|
int order = i + 1;
|
||||||
|
|
||||||
|
RTextDisplay textDisplay = new RTextDisplay(server, location.clone().add(0.5, 0.4, 0.5));
|
||||||
|
textDisplay.setText("§c" + order);
|
||||||
|
textDisplay.setBillboard(Display.Billboard.CENTER);
|
||||||
|
textDisplay.setAlignment(TextDisplay.TextAlignment.CENTER);
|
||||||
|
textDisplay.setSeeThrough(true);
|
||||||
|
textDisplay.setBackgroundColor(0);
|
||||||
|
textDisplay.setShadowed(false);
|
||||||
|
textDisplay.setBrightness(new Display.Brightness(15, 15));
|
||||||
}
|
}
|
||||||
if (facing != direction && (block.equals(origin) || block.getRelative(facing.getOppositeFace()).equals(origin))) return;
|
|
||||||
if (!blockSet.contains(block)) toCalc.add(block);
|
for (Location location : immovableBlocks) {
|
||||||
|
CWireframe wireframe = new CWireframe(server);
|
||||||
|
wireframe.setPos1(location);
|
||||||
|
wireframe.setPos2(location);
|
||||||
|
wireframe.setWidth(1 / 32f);
|
||||||
|
wireframe.setBlock(Material.RED_CONCRETE.createBlockData());
|
||||||
|
}
|
||||||
|
|
||||||
|
CWireframe wireframe = new CWireframe(server);
|
||||||
|
wireframe.setPos1(piston.getLocation());
|
||||||
|
wireframe.setPos2(piston.getLocation());
|
||||||
|
if (!immovableBlocks.isEmpty()) {
|
||||||
|
wireframe.setBlock(Material.RED_CONCRETE.createBlockData());
|
||||||
|
} else if (movedBlocks.size() > 12) {
|
||||||
|
wireframe.setBlock(Material.YELLOW_CONCRETE.createBlockData());
|
||||||
|
} else {
|
||||||
|
wireframe.setBlock(Material.LIME_CONCRETE.createBlockData());
|
||||||
|
}
|
||||||
|
wireframe.setWidth(1 / 32f);
|
||||||
|
|
||||||
|
RTextDisplay textDisplay = new RTextDisplay(server, piston.getLocation().clone().add(0.5, 0.3, 0.5));
|
||||||
|
StringBuilder text = new StringBuilder();
|
||||||
|
if (pulling) {
|
||||||
|
text.append("§ePull\n");
|
||||||
|
} else {
|
||||||
|
text.append("§ePush\n");
|
||||||
|
}
|
||||||
|
text.append("§f").append(movedBlocks.size()).append(" §eBlocks");
|
||||||
|
textDisplay.setText(text.toString());
|
||||||
|
textDisplay.setBillboard(Display.Billboard.CENTER);
|
||||||
|
textDisplay.setAlignment(TextDisplay.TextAlignment.CENTER);
|
||||||
|
textDisplay.setSeeThrough(true);
|
||||||
|
textDisplay.setBackgroundColor(0);
|
||||||
|
textDisplay.setShadowed(false);
|
||||||
|
textDisplay.setBrightness(new Display.Brightness(15, 15));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPiston(Block block) {
|
private boolean isImmovable(Block block) {
|
||||||
|
if (block.isEmpty() || block.isLiquid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
BlockData blockData = block.getBlockData();
|
BlockData blockData = block.getBlockData();
|
||||||
if (blockData instanceof Piston) {
|
if (blockData instanceof Piston) {
|
||||||
return !((Piston) blockData).isExtended();
|
return ((Piston) blockData).isExtended();
|
||||||
|
}
|
||||||
|
if (block.getState() instanceof TileState) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
PistonMoveReaction reaction = block.getPistonMoveReaction();
|
||||||
|
if (reaction == PistonMoveReaction.IGNORE) return true;
|
||||||
|
if (reaction == PistonMoveReaction.BLOCK) return true;
|
||||||
|
switch (block.getType()) {
|
||||||
|
case OBSIDIAN:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
|
||||||
private static class CalculationResult {
|
|
||||||
private int amount;
|
|
||||||
private boolean tooMany;
|
|
||||||
private boolean unmovable;
|
|
||||||
private REntityServer entityServer;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,9 +22,11 @@ package de.steamwar.bausystem.features.util;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
|
import de.steamwar.linkage.MinVersion;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
|
@MinVersion(20)
|
||||||
public class PistonCalculatorCommand extends SWCommand {
|
public class PistonCalculatorCommand extends SWCommand {
|
||||||
|
|
||||||
public PistonCalculatorCommand() {
|
public PistonCalculatorCommand() {
|
||||||
|
|||||||
@ -0,0 +1,7 @@
|
|||||||
|
package de.steamwar.bausystem.features.util;
|
||||||
|
|
||||||
|
public enum RegionSelectionType {
|
||||||
|
LOCAL,
|
||||||
|
GLOBAL,
|
||||||
|
;
|
||||||
|
}
|
||||||
@ -1,14 +1,12 @@
|
|||||||
package de.steamwar.bausystem.features.util;
|
package de.steamwar.bausystem.features.util;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.bausystem.region.Point;
|
import de.steamwar.bausystem.region.Point;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
import de.steamwar.bausystem.region.utils.RegionType;
|
||||||
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -23,19 +21,15 @@ public class SelectCommand extends SWCommand {
|
|||||||
public void baurahmenCommand(@Validator Player p, RegionType regionType, @OptionalValue("NORMAL") RegionExtensionType regionExtensionType) {
|
public void baurahmenCommand(@Validator Player p, RegionType regionType, @OptionalValue("NORMAL") RegionExtensionType regionExtensionType) {
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
|
|
||||||
if (region.isGlobal()) {
|
if (region.getType().isGlobal()) {
|
||||||
BauSystem.MESSAGE.send("SELECT_GLOBAL_REGION", p);
|
BauSystem.MESSAGE.send("SELECT_GLOBAL_REGION", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!region.hasType(regionType)) {
|
if (!regionType.getHasType().test(region)) {
|
||||||
BauSystem.MESSAGE.send("SELECT_NO_TYPE", p, BauSystem.MESSAGE.parse(regionType.getChatValue(), p));
|
BauSystem.MESSAGE.send("SELECT_NO_TYPE", p, BauSystem.MESSAGE.parse(regionType.getChatValue(), p));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (regionExtensionType == RegionExtensionType.EXTENSION && !region.hasExtensionType(regionType)) {
|
|
||||||
BauSystem.MESSAGE.send("SELECT_NO_EXTENSION", p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setSelection(regionType, regionExtensionType, region, p);
|
setSelection(regionType, regionExtensionType, region, p);
|
||||||
}
|
}
|
||||||
@ -46,8 +40,8 @@ public class SelectCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setSelection(RegionType regionType, RegionExtensionType regionExtensionType, Region region, Player p) {
|
private void setSelection(RegionType regionType, RegionExtensionType regionExtensionType, Region region, Player p) {
|
||||||
Point minPoint = region.getMinPoint(regionType, regionExtensionType);
|
Point minPoint = regionType.getToMinPoint().apply(region, regionExtensionType.isExtension());
|
||||||
Point maxPoint = region.getMaxPoint(regionType, regionExtensionType);
|
Point maxPoint = regionType.getToMaxPoint().apply(region, regionExtensionType.isExtension());
|
||||||
|
|
||||||
FlatteningWrapper.impl.setSelection(p, minPoint, maxPoint);
|
FlatteningWrapper.impl.setSelection(p, minPoint, maxPoint);
|
||||||
BauSystem.MESSAGE.send("SELECT_MESSAGE", p, minPoint.getX(), minPoint.getY(), minPoint.getZ(), maxPoint.getX(), maxPoint.getY(), maxPoint.getZ());
|
BauSystem.MESSAGE.send("SELECT_MESSAGE", p, minPoint.getX(), minPoint.getY(), minPoint.getZ(), maxPoint.getX(), maxPoint.getY(), maxPoint.getZ());
|
||||||
|
|||||||
@ -20,8 +20,9 @@
|
|||||||
package de.steamwar.bausystem.features.util;
|
package de.steamwar.bausystem.features.util;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.*;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.features.util.KillAllCommand;
|
import de.steamwar.bausystem.features.util.KillAllCommand;
|
||||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||||
import de.steamwar.bausystem.region.utils.RegionSelectionType;
|
import de.steamwar.bausystem.features.util.RegionSelectionType;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.LinkedInstance;
|
import de.steamwar.linkage.LinkedInstance;
|
||||||
|
|||||||
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.warp;
|
package de.steamwar.bausystem.features.warp;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.region.RegionSystem;
|
||||||
import de.steamwar.bausystem.worlddata.WorldData;
|
import de.steamwar.bausystem.worlddata.WorldData;
|
||||||
import de.steamwar.core.Core;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -36,7 +36,7 @@ public class Warp {
|
|||||||
|
|
||||||
public static void enable() {
|
public static void enable() {
|
||||||
Warp worldSpawn = new Warp("WorldSpawn");
|
Warp worldSpawn = new Warp("WorldSpawn");
|
||||||
worldSpawn.setLocation(Bukkit.getWorlds().get(0).getSpawnLocation().clone().add(0.5, Core.getVersion() >= 20 ? 124 : 1, 0.5));
|
worldSpawn.setLocation(RegionSystem.INSTANCE.getWorldSpawn());
|
||||||
worldSpawn.setMat(Material.NETHER_STAR);
|
worldSpawn.setMat(Material.NETHER_STAR);
|
||||||
warpMap.put("WorldSpawn", worldSpawn);
|
warpMap.put("WorldSpawn", worldSpawn);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,13 +20,11 @@
|
|||||||
package de.steamwar.bausystem.features.warp;
|
package de.steamwar.bausystem.features.warp;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.bausystem.utils.ListChatView;
|
import de.steamwar.bausystem.utils.ListChatView;
|
||||||
import de.steamwar.bausystem.worlddata.WorldData;
|
import de.steamwar.bausystem.worlddata.WorldData;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.SWCommandUtils;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.api.Disable;
|
import de.steamwar.linkage.api.Disable;
|
||||||
import de.steamwar.linkage.api.Enable;
|
import de.steamwar.linkage.api.Enable;
|
||||||
|
|||||||
@ -91,11 +91,11 @@ public class WarpListener implements Listener {
|
|||||||
locations.put(warp.getName(), warp.getLocation());
|
locations.put(warp.getName(), warp.getLocation());
|
||||||
});
|
});
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
if (region.getCopyPoint() != null) {
|
if (!region.getBuildArea().isEmpty()) {
|
||||||
locations.put("Copy", region.getCopyPoint().toLocation(p).add(0.5, 0, 0.5));
|
locations.put("Copy", region.getBuildArea().getCopyPoint().toLocation(p).add(0.5, 0, 0.5));
|
||||||
}
|
}
|
||||||
if (region.getTestBlockPoint() != null) {
|
if (!region.getTestblockArea().isEmpty()) {
|
||||||
locations.put("TestBlock", region.getTestBlockPoint().toLocation(p).add(0.5, 0, 0.5));
|
locations.put("TestBlock", region.getTestblockArea().getCopyPoint().toLocation(p).add(0.5, 0, 0.5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@ package de.steamwar.bausystem.features.world;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.region.GlobalRegion;
|
import de.steamwar.bausystem.region.RegionSystem;
|
||||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||||
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
||||||
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
||||||
@ -75,7 +75,7 @@ public class BauMemberUpdate extends PacketHandler implements Listener {
|
|||||||
SPECTATORS.remove(player);
|
SPECTATORS.remove(player);
|
||||||
newBuilder.add(player);
|
newBuilder.add(player);
|
||||||
player.removePotionEffect(PotionEffectType.GLOWING);
|
player.removePotionEffect(PotionEffectType.GLOWING);
|
||||||
BossBarService.instance.remove(player, GlobalRegion.getInstance(), "spectator");
|
BossBarService.instance.remove(player, RegionSystem.INSTANCE.getGlobalRegion(), "spectator");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -94,7 +94,7 @@ public class BauMemberUpdate extends PacketHandler implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void showSpectatorNotice(Player player) {
|
private static void showSpectatorNotice(Player player) {
|
||||||
BauSystemBossbar bossbar = BossBarService.instance.get(player, GlobalRegion.getInstance(), "spectator");
|
BauSystemBossbar bossbar = BossBarService.instance.get(player, RegionSystem.INSTANCE.getGlobalRegion(), "spectator");
|
||||||
bossbar.setTitle(BauSystem.MESSAGE.parse("SPECTATOR", player));
|
bossbar.setTitle(BauSystem.MESSAGE.parse("SPECTATOR", player));
|
||||||
bossbar.setColor(BarColor.WHITE);
|
bossbar.setColor(BarColor.WHITE);
|
||||||
bossbar.setStyle(BarStyle.SOLID);
|
bossbar.setStyle(BarStyle.SOLID);
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
package de.steamwar.bausystem.features.world;
|
package de.steamwar.bausystem.features.world;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
|
||||||
import de.steamwar.bausystem.region.GlobalRegion;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
import de.steamwar.bausystem.region.flags.ColorMode;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
@ -101,8 +100,11 @@ public class BauScoreboard implements Listener {
|
|||||||
@Override
|
@Override
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (GlobalRegion.getInstance() == region) return "§eSteam§8War";
|
if (region.getType().isGlobal()) return "§eSteam§8War";
|
||||||
String colorCode = BauSystem.MESSAGE.parse(region.get(Flag.COLOR).getChatValue(), player).substring(0, 2);
|
String colorCode = "§e";
|
||||||
|
if (region.getFlags().has(Flag.COLOR).isReadable()) {
|
||||||
|
colorCode = "§" + region.getFlags().get(Flag.COLOR).orElse(ColorMode.PINK).getColorCode();
|
||||||
|
}
|
||||||
return colorCode + "■ §eSteam§8War " + colorCode + "■"; // ■
|
return colorCode + "■ §eSteam§8War " + colorCode + "■"; // ■
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -22,7 +22,6 @@ package de.steamwar.bausystem.features.world;
|
|||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.config.BauServer;
|
import de.steamwar.bausystem.config.BauServer;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.LinkedInstance;
|
import de.steamwar.linkage.LinkedInstance;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|||||||
@ -32,7 +32,6 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.checkerframework.checker.units.qual.min;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@ -28,7 +28,7 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
|||||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
import de.steamwar.bausystem.features.world.WorldEditListener;
|
import de.steamwar.bausystem.features.world.WorldEditListener;
|
||||||
import de.steamwar.bausystem.features.worldedit.utils.SpecialReplace;
|
import de.steamwar.bausystem.features.worldedit.utils.SpecialReplace;
|
||||||
import de.steamwar.bausystem.region.Color;
|
import de.steamwar.bausystem.region.flags.ColorMode;
|
||||||
import de.steamwar.bausystem.shared.Pair;
|
import de.steamwar.bausystem.shared.Pair;
|
||||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||||
import de.steamwar.command.PreviousArguments;
|
import de.steamwar.command.PreviousArguments;
|
||||||
@ -63,7 +63,7 @@ public class ColorReplaceCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register(description = "COLORREPLACE_HELP")
|
@Register(description = "COLORREPLACE_HELP")
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public void genericCommand(@Validator Player player, Pair<Integer, Color> from, Color to) {
|
public void genericCommand(@Validator Player player, Pair<Integer, ColorMode> from, ColorMode to) {
|
||||||
if (from.getValue() == to) {
|
if (from.getValue() == to) {
|
||||||
BukkitAdapter.adapt(player).printInfo(TranslatableComponent.of("worldedit.replace.replaced", new Component[]{TextComponent.of(0)}));
|
BukkitAdapter.adapt(player).printInfo(TranslatableComponent.of("worldedit.replace.replaced", new Component[]{TextComponent.of(0)}));
|
||||||
return;
|
return;
|
||||||
@ -89,23 +89,23 @@ public class ColorReplaceCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ClassMapper(value = Pair.class, local = true)
|
@ClassMapper(value = Pair.class, local = true)
|
||||||
public TypeMapper<Pair<Integer, Color>> typeMapper() {
|
public TypeMapper<Pair<Integer, ColorMode>> typeMapper() {
|
||||||
return new TypeMapper<Pair<Integer, Color>>() {
|
return new TypeMapper<Pair<Integer, ColorMode>>() {
|
||||||
@Override
|
@Override
|
||||||
public Pair<Integer, Color> map(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
public Pair<Integer, ColorMode> map(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
||||||
if (s.contains("%")) {
|
if (s.contains("%")) {
|
||||||
String[] split = s.split("%");
|
String[] split = s.split("%");
|
||||||
if (split.length != 2) {
|
if (split.length != 2) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Color color = Color.valueOf(split[1].toUpperCase());
|
ColorMode color = ColorMode.valueOf(split[1].toUpperCase());
|
||||||
try {
|
try {
|
||||||
return new Pair<>(Integer.parseInt(split[0]), color);
|
return new Pair<>(Integer.parseInt(split[0]), color);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new Pair<>(100, Color.valueOf(s.toUpperCase()));
|
return new Pair<>(100, ColorMode.valueOf(s.toUpperCase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -113,12 +113,12 @@ public class ColorReplaceCommand extends SWCommand {
|
|||||||
if (s.matches("[0-9].*")) {
|
if (s.matches("[0-9].*")) {
|
||||||
if (s.contains("%")) {
|
if (s.contains("%")) {
|
||||||
String sub = s.substring(0, s.indexOf("%") + 1);
|
String sub = s.substring(0, s.indexOf("%") + 1);
|
||||||
return Arrays.stream(Color.values()).map(Color::name).map(t -> sub + t.toLowerCase()).collect(Collectors.toSet());
|
return Arrays.stream(ColorMode.values()).map(ColorMode::name).map(t -> sub + t.toLowerCase()).collect(Collectors.toSet());
|
||||||
} else {
|
} else {
|
||||||
return Arrays.asList(s);
|
return Arrays.asList(s);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Arrays.stream(Color.values()).map(Color::name).map(String::toLowerCase).collect(Collectors.toSet());
|
return Arrays.stream(ColorMode.values()).map(ColorMode::name).map(String::toLowerCase).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -0,0 +1,194 @@
|
|||||||
|
/*
|
||||||
|
* 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.features.worldedit;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.region.Point;
|
||||||
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
||||||
|
import de.steamwar.core.WorldEditRenderer;
|
||||||
|
import de.steamwar.linkage.Linked;
|
||||||
|
import de.steamwar.linkage.MinVersion;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
@Linked
|
||||||
|
@MinVersion(20)
|
||||||
|
public class SelectAdjacent implements Listener {
|
||||||
|
|
||||||
|
private Vector[] FACES = {
|
||||||
|
new Vector(1, 0, 0),
|
||||||
|
new Vector(-1, 0, 0),
|
||||||
|
new Vector(0, 1, 0),
|
||||||
|
new Vector(0, -1, 0),
|
||||||
|
new Vector(0, 0, 1),
|
||||||
|
new Vector(0, 0, -1),
|
||||||
|
|
||||||
|
new Vector(1, 1, 0),
|
||||||
|
new Vector(1, -1, 0),
|
||||||
|
new Vector(1, 0, 1),
|
||||||
|
new Vector(1, 0, -1),
|
||||||
|
new Vector(-1, 1, 0),
|
||||||
|
new Vector(-1, -1, 0),
|
||||||
|
new Vector(-1, 0, 1),
|
||||||
|
new Vector(-1, 0, -1),
|
||||||
|
new Vector(0, 1, 1),
|
||||||
|
new Vector(0, 1, -1),
|
||||||
|
new Vector(0, -1, 1),
|
||||||
|
new Vector(0, -1, -1),
|
||||||
|
};
|
||||||
|
|
||||||
|
private Map<Player, Selector> selectors = new HashMap<>();
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
|
if (!event.hasItem()) return;
|
||||||
|
if (event.getItem().getType() != Material.WOODEN_AXE) return;
|
||||||
|
Selector selector = selectors.get(event.getPlayer());
|
||||||
|
if (selector != null) selector.cancel();
|
||||||
|
if (!event.getPlayer().isSneaking()) return;
|
||||||
|
if (event.getAction() != Action.LEFT_CLICK_BLOCK) return;
|
||||||
|
Material material = event.getPlayer().getInventory().getItemInOffHand().getType();
|
||||||
|
if (material.isAir()) {
|
||||||
|
selector = new Selector(event.getClickedBlock(), event.getPlayer(), __ -> true);
|
||||||
|
} else {
|
||||||
|
selector = new Selector(event.getClickedBlock(), event.getPlayer(), type -> type == material);
|
||||||
|
}
|
||||||
|
selectors.put(event.getPlayer(), selector);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
Selector selector = selectors.remove(event.getPlayer());
|
||||||
|
if (selector != null) selector.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Selector {
|
||||||
|
|
||||||
|
private static final int MAX_BLOCKS = 500_000;
|
||||||
|
|
||||||
|
private int minX;
|
||||||
|
private int minY;
|
||||||
|
private int minZ;
|
||||||
|
private int maxX;
|
||||||
|
private int maxY;
|
||||||
|
private int maxZ;
|
||||||
|
|
||||||
|
private BukkitTask bukkitTask;
|
||||||
|
private Predicate<Material> predicate;
|
||||||
|
private Set<Location> seen = new HashSet<>();
|
||||||
|
private Set<Location> toCalc = new HashSet<>();
|
||||||
|
|
||||||
|
private Region.Area area;
|
||||||
|
|
||||||
|
public Selector(Block block, Player player, Predicate<Material> predicate) {
|
||||||
|
this.predicate = predicate;
|
||||||
|
toCalc.add(block.getLocation());
|
||||||
|
minX = block.getX();
|
||||||
|
minY = block.getY();
|
||||||
|
minZ = block.getZ();
|
||||||
|
maxX = block.getX();
|
||||||
|
maxY = block.getY();
|
||||||
|
maxZ = block.getZ();
|
||||||
|
|
||||||
|
Region region = Region.getRegion(block.getLocation());
|
||||||
|
area = Region.Area.EMPTY;
|
||||||
|
if (region.getBuildArea().inRegion(block.getLocation(), true)) {
|
||||||
|
area = region.getBuildArea();
|
||||||
|
} else if (region.getTestblockArea().inRegion(block.getLocation(), true)) {
|
||||||
|
area = region.getTestblockArea();
|
||||||
|
} else if (region.getArea().inRegion(block.getLocation(), true)) {
|
||||||
|
area = region.getArea();
|
||||||
|
}
|
||||||
|
|
||||||
|
bukkitTask = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
|
||||||
|
run();
|
||||||
|
|
||||||
|
long volume = (long)(maxX - minX + 1) * (long)(maxY - minY + 1) * (long)(maxZ - minZ + 1);
|
||||||
|
player.sendTitle("", "§e" + volume + " §7Blocks", 0, 5, 0);
|
||||||
|
|
||||||
|
Point minPoint = new Point(minX, minY, minZ);
|
||||||
|
Point maxPoint = new Point(maxX, maxY, maxZ);
|
||||||
|
|
||||||
|
FlatteningWrapper.impl.setSelection(player, minPoint, maxPoint);
|
||||||
|
WorldEditRenderer.renderPlayer(player);
|
||||||
|
|
||||||
|
// boolean finished = toCalc.stream().allMatch(location -> {
|
||||||
|
// return location.getBlockX() >= minX && location.getBlockY() >= minY && location.getBlockZ() >= minZ &&
|
||||||
|
// location.getBlockX() <= maxX && location.getBlockY() <= maxY && location.getBlockZ() <= maxZ;
|
||||||
|
// });
|
||||||
|
|
||||||
|
if (toCalc.isEmpty() || seen.size() > MAX_BLOCKS) {
|
||||||
|
bukkitTask.cancel();
|
||||||
|
player.sendTitle("§aDone", "§e" + volume + " §7Blocks", 0, 20, 5);
|
||||||
|
}
|
||||||
|
}, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancel() {
|
||||||
|
bukkitTask.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void run() {
|
||||||
|
Set<Location> current = toCalc;
|
||||||
|
toCalc = new HashSet<>();
|
||||||
|
|
||||||
|
for (Location location : current) {
|
||||||
|
Block block = location.getBlock();
|
||||||
|
if (block.isEmpty() || block.isLiquid()) continue;
|
||||||
|
if (!predicate.test(block.getType())) continue;
|
||||||
|
seen.add(location);
|
||||||
|
if (!area.inRegion(block.getLocation(), true)) continue;
|
||||||
|
|
||||||
|
minX = Math.min(minX, location.getBlockX());
|
||||||
|
maxX = Math.max(maxX, location.getBlockX());
|
||||||
|
minY = Math.min(minY, location.getBlockY());
|
||||||
|
maxY = Math.max(maxY, location.getBlockY());
|
||||||
|
minZ = Math.min(minZ, location.getBlockZ());
|
||||||
|
maxZ = Math.max(maxZ, location.getBlockZ());
|
||||||
|
|
||||||
|
for (Vector face : FACES) {
|
||||||
|
Block next = block.getRelative(face.getBlockX(), face.getBlockY(), face.getBlockZ());
|
||||||
|
if (next.isEmpty() || next.isLiquid()) continue;
|
||||||
|
if (!predicate.test(next.getType())) continue;
|
||||||
|
Location loc = next.getLocation();
|
||||||
|
if (seen.contains(loc)) continue;
|
||||||
|
toCalc.add(loc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.xray;
|
package de.steamwar.bausystem.features.xray;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
|
import de.steamwar.Reflection;
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.features.techhider.TechHiderCommand;
|
import de.steamwar.bausystem.features.techhider.TechHiderCommand;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
@ -34,8 +34,6 @@ import de.steamwar.techhider.TechHider;
|
|||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -43,7 +41,6 @@ import org.bukkit.event.block.Action;
|
|||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
@ -64,30 +61,20 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen
|
|||||||
@Register(description = "XRAY_HELP")
|
@Register(description = "XRAY_HELP")
|
||||||
public void toggleHider(@Validator Player player) {
|
public void toggleHider(@Validator Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region.isGlobal()) {
|
if (region.getType().isGlobal()) {
|
||||||
BauSystem.MESSAGE.send("XRAY_GLOBAL", player);
|
BauSystem.MESSAGE.send("XRAY_GLOBAL", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<TechHider> techHider = techHiders.computeIfAbsent(region, rg -> {
|
Optional<TechHider> techHider = techHiders.computeIfAbsent(region, rg -> {
|
||||||
File file = rg.gameModeConfig();
|
if (!region.getGameModeConfig().getTechhider().isActive()) {
|
||||||
if (file == null) {
|
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
|
||||||
if (!config.getBoolean("Techhider.Active", false)) {
|
|
||||||
Set<Material> blocks = new HashSet<>(Arrays.asList(Material.END_STONE, Material.IRON_BLOCK));
|
|
||||||
xrayedBlocks.put(region, blocks);
|
|
||||||
return Optional.of(createXray(rg, blocks));
|
|
||||||
}
|
|
||||||
|
|
||||||
hidden.put(rg, new HashSet<>());
|
hidden.put(rg, new HashSet<>());
|
||||||
|
|
||||||
String obfuscateWith = config.getString("Techhider.ObfuscateWith", "end_stone");
|
Set<Material> blocks = new HashSet<>(Arrays.asList(region.getGameModeConfig().getTechhider().getObfuscateWith()));
|
||||||
|
if (blocks.contains(Material.END_STONE)) blocks.add(Material.END_STONE_BRICKS);
|
||||||
Set<Material> blocks = new HashSet<>(Arrays.asList(Material.getMaterial(obfuscateWith.toUpperCase())));
|
|
||||||
if (obfuscateWith.equals("end_stone")) blocks.add(Material.END_STONE_BRICKS);
|
|
||||||
xrayedBlocks.put(region, blocks);
|
xrayedBlocks.put(region, blocks);
|
||||||
return Optional.of(createXray(rg, blocks));
|
return Optional.of(createXray(rg, blocks));
|
||||||
});
|
});
|
||||||
@ -103,7 +90,7 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen
|
|||||||
hidden.get(region).add(player);
|
hidden.get(region).add(player);
|
||||||
BauSystem.MESSAGE.sendPrefixless("XRAY_ON", player, ChatMessageType.ACTION_BAR);
|
BauSystem.MESSAGE.sendPrefixless("XRAY_ON", player, ChatMessageType.ACTION_BAR);
|
||||||
}
|
}
|
||||||
region.forEachChunk((x, z) -> {
|
region.getBuildArea().forEachChunk((x, z) -> {
|
||||||
CraftbukkitWrapper.impl.sendChunk(player, x, z);
|
CraftbukkitWrapper.impl.sendChunk(player, x, z);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -149,7 +136,7 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen
|
|||||||
|
|
||||||
private TechHider createXray(Region rg, Set<Material> obfuscate) {
|
private TechHider createXray(Region rg, Set<Material> obfuscate) {
|
||||||
TechHider current = new TechHider((TechHider.LocationEvaluator) (p, cX, cY) -> {
|
TechHider current = new TechHider((TechHider.LocationEvaluator) (p, cX, cY) -> {
|
||||||
if (rg.buildChunkOutside(cX, cY)) return true;
|
if (rg.getBuildArea().isChunkOutside(cX, cY)) return true;
|
||||||
return !hidden.get(rg).contains(p);
|
return !hidden.get(rg).contains(p);
|
||||||
}, Material.STRUCTURE_VOID, obfuscate, new HashSet<>());
|
}, Material.STRUCTURE_VOID, obfuscate, new HashSet<>());
|
||||||
current.enable();
|
current.enable();
|
||||||
|
|||||||
@ -1,32 +1,14 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2021 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.region;
|
package de.steamwar.bausystem.region;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.region.tags.Tag;
|
import de.steamwar.bausystem.region.flags.ChangedMode;
|
||||||
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.api.Enable;
|
import de.steamwar.linkage.api.Enable;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class BackupScheduler implements Enable {
|
public class BackupScheduler implements Enable {
|
||||||
@ -39,24 +21,30 @@ public class BackupScheduler implements Enable {
|
|||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final Iterator<Region> regions = Region.getREGION_MAP().values().stream().filter(region -> region.get(Tag.CHANGED)).iterator();
|
Iterator<Region> regionsToBackup = RegionSystem.INSTANCE.getRegions()
|
||||||
BackupScheduler.this.doBackup(regions);
|
.filter(region -> region.getFlags().has(Flag.CHANGED).isReadable())
|
||||||
|
.filter(region -> region.getFlags().get(Flag.CHANGED).getWithDefault() == ChangedMode.HAS_CHANGE)
|
||||||
|
.iterator();
|
||||||
|
if (!regionsToBackup.hasNext()) return;
|
||||||
|
doBackup(regionsToBackup);
|
||||||
}
|
}
|
||||||
}.runTaskTimer(BauSystem.getInstance(), INITIAL, PERIOD);
|
}.runTaskTimer(BauSystem.getInstance(), INITIAL, PERIOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doBackup(final Iterator<Region> regionIterator) {
|
private void doBackup(Iterator<Region> regionsToBackup) {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!regionIterator.hasNext()) {
|
if (!regionsToBackup.hasNext()) {
|
||||||
this.cancel();
|
this.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Region region = regionIterator.next();
|
Region region = regionsToBackup.next();
|
||||||
if (region.backup()) {
|
Optional<RegionBackups.Backup> backup = region.getBackups()
|
||||||
region.remove(Tag.CHANGED);
|
.create(RegionBackups.BackupType.AUTOMATIC);
|
||||||
|
if (backup.isPresent()) {
|
||||||
|
region.getFlags().set(Flag.CHANGED, ChangedMode.NO_CHANGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskTimer(BauSystem.getInstance(), 0, 20 * 60);
|
}.runTaskTimer(BauSystem.getInstance(), 0, 20 * 60);
|
||||||
|
|||||||
@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2021 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.region;
|
|
||||||
|
|
||||||
public enum Color {
|
|
||||||
WHITE,
|
|
||||||
ORANGE,
|
|
||||||
MAGENTA,
|
|
||||||
LIGHT_BLUE,
|
|
||||||
YELLOW,
|
|
||||||
LIME,
|
|
||||||
PINK,
|
|
||||||
GRAY,
|
|
||||||
LIGHT_GRAY,
|
|
||||||
CYAN,
|
|
||||||
PURPLE,
|
|
||||||
BLUE,
|
|
||||||
BROWN,
|
|
||||||
GREEN,
|
|
||||||
RED,
|
|
||||||
BLACK;
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user