Trace Refactor #233
@ -27,8 +27,8 @@ version '1.0'
|
|||||||
|
|
||||||
compileJava.options.encoding = 'UTF-8'
|
compileJava.options.encoding = 'UTF-8'
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 17
|
||||||
targetCompatibility = 1.8
|
targetCompatibility = 17
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main {
|
main {
|
||||||
|
23
BauSystem_15/src/de/steamwar/bausystem/utils/TickListener15.java
Normale Datei
23
BauSystem_15/src/de/steamwar/bausystem/utils/TickListener15.java
Normale Datei
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.utils;
|
||||||
|
|
||||||
|
public class TickListener15 implements TickListener {
|
||||||
|
}
|
@ -27,8 +27,8 @@ version '1.0'
|
|||||||
|
|
||||||
compileJava.options.encoding = 'UTF-8'
|
compileJava.options.encoding = 'UTF-8'
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 17
|
||||||
targetCompatibility = 1.8
|
targetCompatibility = 17
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main {
|
main {
|
||||||
|
@ -27,8 +27,8 @@ version '1.0'
|
|||||||
|
|
||||||
compileJava.options.encoding = 'UTF-8'
|
compileJava.options.encoding = 'UTF-8'
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 17
|
||||||
targetCompatibility = 1.8
|
targetCompatibility = 17
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main {
|
main {
|
||||||
@ -51,6 +51,7 @@ dependencies {
|
|||||||
implementation project(":BauSystem_Main")
|
implementation project(":BauSystem_Main")
|
||||||
|
|
||||||
compileOnly 'org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT'
|
compileOnly 'org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT'
|
||||||
|
compileOnly 'io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT'
|
||||||
compileOnly 'it.unimi.dsi:fastutil:8.5.6'
|
compileOnly 'it.unimi.dsi:fastutil:8.5.6'
|
||||||
compileOnly 'com.mojang:datafixerupper:4.0.26'
|
compileOnly 'com.mojang:datafixerupper:4.0.26'
|
||||||
compileOnly 'io.netty:netty-all:4.1.68.Final'
|
compileOnly 'io.netty:netty-all:4.1.68.Final'
|
||||||
|
51
BauSystem_19/src/de/steamwar/bausystem/utils/TickListener19.java
Normale Datei
51
BauSystem_19/src/de/steamwar/bausystem/utils/TickListener19.java
Normale Datei
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.utils;
|
||||||
|
|
||||||
|
import com.destroystokyo.paper.event.server.ServerTickEndEvent;
|
||||||
|
import com.destroystokyo.paper.event.server.ServerTickStartEvent;
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.features.tpslimit.TPSFreezeUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
public class TickListener19 implements TickListener, Listener {
|
||||||
|
|
||||||
|
private boolean tickStartRan = false;
|
||||||
|
|
||||||
|
public TickListener19() {
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onServerTickStart(ServerTickStartEvent event) {
|
||||||
|
if (TPSFreezeUtils.isFrozen()) return;
|
||||||
|
Bukkit.getPluginManager().callEvent(new TickStartEvent());
|
||||||
|
tickStartRan = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onServerTickEnd(ServerTickEndEvent event) {
|
||||||
|
if (!tickStartRan) return;
|
||||||
|
Bukkit.getPluginManager().callEvent(new TickEndEvent());
|
||||||
|
tickStartRan = false;
|
||||||
|
}
|
||||||
|
}
|
@ -27,8 +27,8 @@ version '1.0'
|
|||||||
|
|
||||||
compileJava.options.encoding = 'UTF-8'
|
compileJava.options.encoding = 'UTF-8'
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 17
|
||||||
targetCompatibility = 1.8
|
targetCompatibility = 17
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main {
|
main {
|
||||||
|
@ -27,8 +27,8 @@ version '1.0'
|
|||||||
|
|
||||||
compileJava.options.encoding = 'UTF-8'
|
compileJava.options.encoding = 'UTF-8'
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 17
|
||||||
targetCompatibility = 1.8
|
targetCompatibility = 17
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main {
|
main {
|
||||||
|
@ -35,6 +35,6 @@ public class ScoreboardElement_GENERIC implements LinkageType {
|
|||||||
@Override
|
@Override
|
||||||
public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) {
|
public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) {
|
||||||
buildPlan.addImport("de.steamwar.bausystem.features.world.BauScoreboard");
|
buildPlan.addImport("de.steamwar.bausystem.features.world.BauScoreboard");
|
||||||
methodBuilder.addLine("BauScoreboard.ELEMENTS.add(" + s + ");");
|
methodBuilder.addLine("BauScoreboard.addElement(" + s + ");");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,8 @@ version '1.0'
|
|||||||
|
|
||||||
compileJava.options.encoding = 'UTF-8'
|
compileJava.options.encoding = 'UTF-8'
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 17
|
||||||
targetCompatibility = 1.8
|
targetCompatibility = 17
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main {
|
main {
|
||||||
|
@ -27,6 +27,10 @@ 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
|
||||||
|
NO_PERMISSION = You are not allowed to use that here
|
||||||
|
SPECTATOR = §fSpectator
|
||||||
|
|
||||||
# Scoreboard
|
# Scoreboard
|
||||||
SCOREBOARD_TIME = Time
|
SCOREBOARD_TIME = Time
|
||||||
SCOREBOARD_REGION = Region
|
SCOREBOARD_REGION = Region
|
||||||
@ -40,6 +44,11 @@ SCOREBOARD_TRACE_TICKS = Ticks
|
|||||||
SCOREBOARD_TECHHIDER = TechHider§8: §aOn
|
SCOREBOARD_TECHHIDER = TechHider§8: §aOn
|
||||||
SCOREBOARD_XRAY = XRay§8: §aOn
|
SCOREBOARD_XRAY = XRay§8: §aOn
|
||||||
|
|
||||||
|
SCOREBOARD_LOCK_TEAM = Bau Lock§8: §eTeam
|
||||||
|
SCOREBOARD_LOCK_TEAM_AND_SERVERTEAM = Bau Lock§8: §e(Server) Team
|
||||||
|
SCOREBOARD_LOCK_SERVERTEAM = Bau Lock§8: §eServer Team
|
||||||
|
SCOREBOARD_LOCK_NOBODY = Bau Lock§8: §cNobody
|
||||||
|
|
||||||
# Flags
|
# Flags
|
||||||
FLAG_COLOR = Color
|
FLAG_COLOR = Color
|
||||||
FLAG_TNT = TNT
|
FLAG_TNT = TNT
|
||||||
@ -116,7 +125,6 @@ BACKUP_HELP_LOAD=§8/§ebackup load §8[§7BackupName§8] §8- §7Load a region
|
|||||||
BACKUP_HELP_LIST=§8/§ebackup list §8- §7List all region backups
|
BACKUP_HELP_LIST=§8/§ebackup list §8- §7List all region backups
|
||||||
BACKUP_HELP_GUI=§8/§ebackup gui §8- §7Open the backup GUI
|
BACKUP_HELP_GUI=§8/§ebackup gui §8- §7Open the backup GUI
|
||||||
BACKUP_REGION_NO_REGION=§cYou are not inside any region
|
BACKUP_REGION_NO_REGION=§cYou are not inside any region
|
||||||
BACKUP_NO_PERMS=§You do not have permission to use the backup system
|
|
||||||
BACKUP_CREATE_SUCCESS=§7Backup created
|
BACKUP_CREATE_SUCCESS=§7Backup created
|
||||||
BACKUP_CREATE_FAILURE=§cBackup failed
|
BACKUP_CREATE_FAILURE=§cBackup failed
|
||||||
BACKUP_CREATE_NO_CHANGE=§7No changes to save
|
BACKUP_CREATE_NO_CHANGE=§7No changes to save
|
||||||
@ -130,11 +138,6 @@ BACKUP_LORE=§eClick to load
|
|||||||
|
|
||||||
# Bau
|
# Bau
|
||||||
BAU_COMMAND_HELP_INFO = §8/§ebau info §8- §7Alias for §8/§ebauinfo
|
BAU_COMMAND_HELP_INFO = §8/§ebau info §8- §7Alias for §8/§ebauinfo
|
||||||
BAU_COMMAND_HELP_TOGGLEWE = §8/§ebau togglewe §8[§7Player§8] §8- §7Edit the WorldEdit permissions of a player
|
|
||||||
BAU_COMMAND_HELP_TOGGLEWORLD = §8/§ebau toggleworld §8[§7Player§8] §8- §7Edit the World permissions of a player
|
|
||||||
BAU_UNKNOWN_PLAYER = §cUnknown Player
|
|
||||||
BAU_NO_PLAYER = §cThe player is no member of your world!
|
|
||||||
BAU_NO_WORLD = §cThis is not your world!
|
|
||||||
|
|
||||||
BAU_INFO_ITEM_NAME = §eBau-Management
|
BAU_INFO_ITEM_NAME = §eBau-Management
|
||||||
## This is used in BauInfoBauGuiItem.java
|
## This is used in BauInfoBauGuiItem.java
|
||||||
@ -147,12 +150,7 @@ BAU_INFO_ITEM_LORE_ITEMS = §7Items§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 = §7Member §8[§7{0}§8]§8: §e
|
BAU_INFO_COMMAND_MEMBER = §7{0} §8[§7{1}§8]§8: §e{2}
|
||||||
BAU_INFO_MEMBER_INFO = §e{0}§8[{1}§8,{2}§8] §8
|
|
||||||
BAU_INFO_MEMBER_WE_ALLOW = §aWE
|
|
||||||
BAU_INFO_MEMBER_WE_DISALLOW = §cWE
|
|
||||||
BAU_INFO_MEMBER_WORLD_ALLOW = §aW
|
|
||||||
BAU_INFO_MEMBER_WORLD_DISALLOW = §cW
|
|
||||||
BAU_INFO_COMMAND_FLAG = §7{0}§8: §7{1}
|
BAU_INFO_COMMAND_FLAG = §7{0}§8: §7{1}
|
||||||
BAU_INFO_COMMAND_TPS = §7TPS§8:§e
|
BAU_INFO_COMMAND_TPS = §7TPS§8:§e
|
||||||
|
|
||||||
@ -211,11 +209,6 @@ HOTBAR_INVENTORY=Standard hotbar
|
|||||||
# GUI
|
# GUI
|
||||||
GUI_EDITOR_ITEM_NAME=§eGui editor
|
GUI_EDITOR_ITEM_NAME=§eGui editor
|
||||||
GUI_NAME=Bau GUI
|
GUI_NAME=Bau GUI
|
||||||
GUI_NO_PERMISSION=§cYou do not have enough permissions for this
|
|
||||||
GUI_NO_OWNER=§cYou are not the owner of this World
|
|
||||||
GUI_NO_WORLD=§cYou do not have permissions to change the World
|
|
||||||
GUI_NO_WORLDEDIT=§cYou do not have permissions to use WorldEdit
|
|
||||||
GUI_NO_MEMBER=§cYou need to be a member of this World
|
|
||||||
GUI_ITEM_LORE1=§7Use this item to open the bau gui
|
GUI_ITEM_LORE1=§7Use this item to open the bau gui
|
||||||
GUI_ITEM_LORE2=§7or press swap hands twice.
|
GUI_ITEM_LORE2=§7or press swap hands twice.
|
||||||
GUI_EDITOR_TITLE=Bau GUI Editor
|
GUI_EDITOR_TITLE=Bau GUI Editor
|
||||||
@ -266,7 +259,6 @@ SHIELD_PRINTING_HELP_STEP_7 = §87. §7Apply the shield printing with §8/§eshi
|
|||||||
|
|
||||||
SHIELD_PRINTING_NO_REGION = §cYou are not in a region.
|
SHIELD_PRINTING_NO_REGION = §cYou are not in a region.
|
||||||
SHIELD_PRINTING_NOT_RUNNING = §cThe shield printing is not running.
|
SHIELD_PRINTING_NOT_RUNNING = §cThe shield printing is not running.
|
||||||
SHIELD_PRINTING_DISALLOWED = §cYou are not allowed to use shield printing here.
|
|
||||||
SHIELD_PRINTING_BOSSBAR = §fMovements: {0}
|
SHIELD_PRINTING_BOSSBAR = §fMovements: {0}
|
||||||
SHIELD_PRINTING_BOSSBAR_COPIED = §fMovements: {0} Copied: {1}
|
SHIELD_PRINTING_BOSSBAR_COPIED = §fMovements: {0} Copied: {1}
|
||||||
|
|
||||||
@ -303,7 +295,6 @@ SIMULATOR_CHANGE_HELP = §8/§esimulator change §8-§7 Change your simulator wa
|
|||||||
SIMULATOR_DELETE_HELP = §8/§esimulator delete §8[§7name§8] §8-§7 Deletes the simulator
|
SIMULATOR_DELETE_HELP = §8/§esimulator delete §8[§7name§8] §8-§7 Deletes the simulator
|
||||||
SIMULATOR_START_HELP = §8/§esimulator start §8[§7name§8] §8-§7 Starts the simulator
|
SIMULATOR_START_HELP = §8/§esimulator start §8[§7name§8] §8-§7 Starts the simulator
|
||||||
SIMULATOR_COPY_HELP = §8/§esimulator copy §8[§7to-copy§8] §8[§7name§8] §8-§7 Copy the simulator
|
SIMULATOR_COPY_HELP = §8/§esimulator copy §8[§7to-copy§8] §8[§7name§8] §8-§7 Copy the simulator
|
||||||
SIMULATOR_NO_PERMS = §cYou are not allowed to use the simulator here
|
|
||||||
|
|
||||||
SIMULATOR_GUI_ITEM_NAME = §eTNT Simulator
|
SIMULATOR_GUI_ITEM_NAME = §eTNT Simulator
|
||||||
|
|
||||||
@ -313,6 +304,7 @@ SIMULATOR_GUI_CREATE_SIM = §eCreate simulator
|
|||||||
SIMULATOR_GUI_CREATE_SIM_GUI = Create simulator
|
SIMULATOR_GUI_CREATE_SIM_GUI = Create simulator
|
||||||
SIMULATOR_NAME_ALREADY_EXISTS = §cSimulator already exists
|
SIMULATOR_NAME_ALREADY_EXISTS = §cSimulator already exists
|
||||||
SIMULATOR_NAME_INVALID = §cInvalid name
|
SIMULATOR_NAME_INVALID = §cInvalid name
|
||||||
|
SIMULATOR_ERROR_COPY = §cCopy failed
|
||||||
SIMULATOR_NOT_EXISTS = §cSimulator does not exist
|
SIMULATOR_NOT_EXISTS = §cSimulator does not exist
|
||||||
SIMULATOR_CREATE = §aSimulator created
|
SIMULATOR_CREATE = §aSimulator created
|
||||||
SIMULATOR_EDIT_LOCATION = §7Edit position
|
SIMULATOR_EDIT_LOCATION = §7Edit position
|
||||||
@ -328,7 +320,7 @@ SIMULATOR_WAND_LORE_1 = §eRight click §8- §7Adds a position
|
|||||||
SIMULATOR_WAND_LORE_2 = §eSneaking §8- §7Free movement
|
SIMULATOR_WAND_LORE_2 = §eSneaking §8- §7Free movement
|
||||||
SIMULATOR_WAND_LORE_3 = §eLeft click §8- §7Start the simulation
|
SIMULATOR_WAND_LORE_3 = §eLeft click §8- §7Start the simulation
|
||||||
SIMULATOR_WAND_LORE_4 = §eRight click in air §8- §7Opens the gui
|
SIMULATOR_WAND_LORE_4 = §eRight click in air §8- §7Opens the gui
|
||||||
SIMULATOR_WAND_LORE_5 = §eOffhand §8- §7Simulator preview
|
SIMULATOR_WAND_LORE_5 = §eDouble Sneak §8- §7Swap between TNT and Redstone Block
|
||||||
|
|
||||||
SIMULATOR_REGION_FROZEN = §cSimulator cannot be used inside frozen regions
|
SIMULATOR_REGION_FROZEN = §cSimulator cannot be used inside frozen regions
|
||||||
|
|
||||||
@ -481,7 +473,6 @@ TPSLIMIT_GUI_ITEM_NAME = §eTPS limiter
|
|||||||
TPSLIMIT_GUI_ITEM_LORE = §7Currently: §e{0}
|
TPSLIMIT_GUI_ITEM_LORE = §7Currently: §e{0}
|
||||||
TPSLIMIT_ANVIL_GUI = New TPS limit
|
TPSLIMIT_ANVIL_GUI = New TPS limit
|
||||||
TPSLIMIT_CURRENT = §7Current TPS limit§8: §e{0}
|
TPSLIMIT_CURRENT = §7Current TPS limit§8: §e{0}
|
||||||
TPSLIMIT_NO_PERMS = §cYou are not allowed to use the TPS-Limiter here
|
|
||||||
TPSLIMIT_SET = §eSet TPS limit to {0}
|
TPSLIMIT_SET = §eSet TPS limit to {0}
|
||||||
TPSLIMIT_FROZEN = §eTPS frozen
|
TPSLIMIT_FROZEN = §eTPS frozen
|
||||||
|
|
||||||
@ -573,7 +564,6 @@ LOADER_PAUSED=§7The Loader is now paused.
|
|||||||
LOADER_SMALL_TIME=§cThe wait time is too small
|
LOADER_SMALL_TIME=§cThe wait time is too small
|
||||||
LOADER_NEW_TIME=§7The wait time is now: {0}
|
LOADER_NEW_TIME=§7The wait time is now: {0}
|
||||||
LOADER_NEW_LOAD_TIME=§7The action wait time is now: {0}
|
LOADER_NEW_LOAD_TIME=§7The action wait time is now: {0}
|
||||||
LOADER_PERMS=§cYou are not allowed to use the Loader here
|
|
||||||
|
|
||||||
LOADER_NOTHING_RECORDED=§cYou have not recorded anything yet!
|
LOADER_NOTHING_RECORDED=§cYou have not recorded anything yet!
|
||||||
LOADER_GUI_TITLE=Loader GUI
|
LOADER_GUI_TITLE=Loader GUI
|
||||||
@ -693,7 +683,6 @@ OTHER_CLEAR_HELP_PLAYER=§8/§eclear §8[§7Player§8] §8- §7Clears a player i
|
|||||||
OTHER_CLEAR_CLEARED=Your inventory was cleared.
|
OTHER_CLEAR_CLEARED=Your inventory was cleared.
|
||||||
OTHER_CLEAR_FROM=Your invetnory was cleared by {0}.
|
OTHER_CLEAR_FROM=Your invetnory was cleared by {0}.
|
||||||
OTHER_CLEAR_TO=The inventory of {0} §7was cleared.
|
OTHER_CLEAR_TO=The inventory of {0} §7was cleared.
|
||||||
OTHER_CLEAR_NO_PERMS=§cYou are not allowed to clear other's inventory here.
|
|
||||||
OTHER_DECLUTTER_HELP=§8/§edeclutter §8- §7Organise your inventory
|
OTHER_DECLUTTER_HELP=§8/§edeclutter §8- §7Organise your inventory
|
||||||
OTHER_DECLUTTER_DONE=§aYour inventory was organised.
|
OTHER_DECLUTTER_DONE=§aYour inventory was organised.
|
||||||
OTHER_GAMEMODE_UNKNOWN=§cUnknown gamemode.
|
OTHER_GAMEMODE_UNKNOWN=§cUnknown gamemode.
|
||||||
@ -709,7 +698,6 @@ OTHER_TELEPORT_SELF_2=§cBlocks left to travel: 0; ETA: 0:00
|
|||||||
OTHER_TELEPORT_SELF_3=§cA little Movement is important.
|
OTHER_TELEPORT_SELF_3=§cA little Movement is important.
|
||||||
OTHER_TELEPORT_SELF_4=§cFor such a distance?
|
OTHER_TELEPORT_SELF_4=§cFor such a distance?
|
||||||
OTHER_TIME_HELP=§8/§etime §8<§7Time 0=Morining§8, §76000=Midday§8, §718000=Midnight§8> - §7Sets the time on the Build
|
OTHER_TIME_HELP=§8/§etime §8<§7Time 0=Morining§8, §76000=Midday§8, §718000=Midnight§8> - §7Sets the time on the Build
|
||||||
OTHER_TIME_NO_PERM=§cYou are not allowed to change the time here
|
|
||||||
OTHER_TIME_INVALID=§cPlease input a time between 0 and 24000
|
OTHER_TIME_INVALID=§cPlease input a time between 0 and 24000
|
||||||
OTHER_TIME_RESULT=§7§oWhooosh
|
OTHER_TIME_RESULT=§7§oWhooosh
|
||||||
OTHER_TPS_HEAD = §7TPS: 1s 10s 1m 5m 10m
|
OTHER_TPS_HEAD = §7TPS: 1s 10s 1m 5m 10m
|
||||||
@ -775,17 +763,6 @@ MATERIAL_FLAMMABLE=§8- §eFlammable block
|
|||||||
MATERIAL_BURNABLE=§8- §eBurnable block
|
MATERIAL_BURNABLE=§8- §eBurnable block
|
||||||
MATERIAL_WATERLOGGABLE=§8- §eWaterloggable block
|
MATERIAL_WATERLOGGABLE=§8- §eWaterloggable block
|
||||||
MATERIAL_UNMOVABLE=§8- §eUnmovable block
|
MATERIAL_UNMOVABLE=§8- §eUnmovable block
|
||||||
# Redstonetester
|
|
||||||
RT_HELP=§8/§eredstonetester §8-§7 Gives you the redstone tester
|
|
||||||
RT_GIVEN=§7Measure the time between activation of components
|
|
||||||
RT_ITEM_NAME=§eRedstonetester
|
|
||||||
RT_ITEM_LORE_1=§eLeftclick block §8-§7 Sets the 1. Position
|
|
||||||
RT_ITEM_LORE_2=§eRightclick block §8-§7 Sets the 2. Position
|
|
||||||
RT_ITEM_LORE_3=§eShift-rightclick in air §8-§7 Reset
|
|
||||||
RT_LOC=§8: §e{0} {1} {2}
|
|
||||||
RT_INVALID_LOC=§cUnknown Position
|
|
||||||
RT_RESULT=§7Difference§8: §e{0}§7 Ticks §8,§7 R-Ticks §e{1}
|
|
||||||
RT_ACTIVATE=§7Positions deleted§8.
|
|
||||||
# Region Items
|
# Region Items
|
||||||
REGION_ITEM_COLOR=§7Color: §e{0}
|
REGION_ITEM_COLOR=§7Color: §e{0}
|
||||||
REGION_ITEM_COLOR_CHOOSE=Choose color
|
REGION_ITEM_COLOR_CHOOSE=Choose color
|
||||||
@ -811,24 +788,18 @@ REGION_COLOR_HELP_COLOR=§8/§ecolor §8[§7Color§8] §8- §7Sets the color of
|
|||||||
REGION_COLOR_HELP_COLOR_TYPE=§8/§ecolor §8[§7Color§8] §8[§7Type§8] §8- §7Sets the color of the region or globally
|
REGION_COLOR_HELP_COLOR_TYPE=§8/§ecolor §8[§7Color§8] §8[§7Type§8] §8- §7Sets the color of the region or globally
|
||||||
REGION_COLOR_GLOBAL=§7All regions color set to §e{0}
|
REGION_COLOR_GLOBAL=§7All regions color set to §e{0}
|
||||||
REGION_COLOR_NO_REGION=§cYou are currently not in any region
|
REGION_COLOR_NO_REGION=§cYou are currently not in any region
|
||||||
REGION_COLOR_NO_PERMS=§cThis is not your world!
|
|
||||||
REGION_FIRE_HELP=§8/§efire §8- §7Toggle fire damage
|
REGION_FIRE_HELP=§8/§efire §8- §7Toggle fire damage
|
||||||
REGION_FIRE_NO_PERMS=§cYou are not allowed to toggle fire damage here
|
|
||||||
REGION_FIRE_ENABLED=§cFire damage deactivated in this region
|
REGION_FIRE_ENABLED=§cFire damage deactivated in this region
|
||||||
REGION_FIRE_DISABLED=§aFire damage activated in this region
|
REGION_FIRE_DISABLED=§aFire damage activated in this region
|
||||||
REGION_FREEZE_HELP=§8/§efreeze §8- §7Toggle Freeze
|
REGION_FREEZE_HELP=§8/§efreeze §8- §7Toggle Freeze
|
||||||
REGION_FREEZE_NO_PERMS=§cYou are not allowed to freeze this world
|
|
||||||
REGION_FREEZE_ENABLED=§cRegion frozen
|
REGION_FREEZE_ENABLED=§cRegion frozen
|
||||||
REGION_FREEZE_DISABLED=§aRegion thawed
|
REGION_FREEZE_DISABLED=§aRegion thawed
|
||||||
REGION_ITEMS_HELP=§8/§eitems §8- §7Toggle Items
|
REGION_ITEMS_HELP=§8/§eitems §8- §7Toggle Items
|
||||||
REGION_ITEMS_NO_PERMS=§cYou are not allowed to toggle items in this world
|
|
||||||
REGION_ITEMS_ENABLED=§aItems enabled in this region
|
REGION_ITEMS_ENABLED=§aItems enabled in this region
|
||||||
REGION_ITEMS_DISABLED_GLOBAL=§cItems disabled in this world
|
|
||||||
REGION_ITEMS_DISABLED=§cItems disabled in this region
|
REGION_ITEMS_DISABLED=§cItems disabled in this region
|
||||||
REGION_PROTECT_HELP=§8/§eprotect §8- §7Protect the region
|
REGION_PROTECT_HELP=§8/§eprotect §8- §7Protect the region
|
||||||
REGION_PROTECT_DISABLE=§cProtection disabled
|
REGION_PROTECT_DISABLE=§cProtection disabled
|
||||||
REGION_PROTECT_ENABLE=§aProtection enabled
|
REGION_PROTECT_ENABLE=§aProtection enabled
|
||||||
REGION_PROTECT_NO_PERMS=§cYou are not allowed to protect the floor here
|
|
||||||
REGION_PROTECT_FALSE_REGION=§cYou are not currently in a (M)WG-region
|
REGION_PROTECT_FALSE_REGION=§cYou are not currently in a (M)WG-region
|
||||||
REGION_REGION_HELP_UNDO=§8/§eregion undo §8- §7undo the last 20 /testblock or /reset
|
REGION_REGION_HELP_UNDO=§8/§eregion undo §8- §7undo the last 20 /testblock or /reset
|
||||||
REGION_REGION_HELP_REDO=§8/§eregion redo §8- §7redo the last 20 §8/§7rg undo
|
REGION_REGION_HELP_REDO=§8/§eregion redo §8- §7redo the last 20 §8/§7rg undo
|
||||||
@ -836,8 +807,6 @@ REGION_REGION_HELP_RESTORE=§8/§eregion restore §8- §7Resets the region, with
|
|||||||
REGION_REGION_HELP_RESTORE_SCHEMATIC=§8/§eregion restore §8[§7Schematic§8] §8- §7Resets the region, withoout removing your builds
|
REGION_REGION_HELP_RESTORE_SCHEMATIC=§8/§eregion restore §8[§7Schematic§8] §8- §7Resets the region, withoout removing your builds
|
||||||
REGION_REGION_HELP_COPYPOINT=§8/§eregion copypoint §8- §7Teleport to the regions copy point
|
REGION_REGION_HELP_COPYPOINT=§8/§eregion copypoint §8- §7Teleport to the regions copy point
|
||||||
REGION_REGION_HELP_TESTBLOCKPOINT=§8/§eregion testblockpoint §8- §7Teleport to the regions dummy point
|
REGION_REGION_HELP_TESTBLOCKPOINT=§8/§eregion testblockpoint §8- §7Teleport to the regions dummy point
|
||||||
REGION_REGION_HELP_CHANGETYPE_INFO=§8/§eregion changetype §8- §7Returns the region type
|
|
||||||
REGION_REGION_HELP_CHANGETYPE=§8/§eregion changetype §8[§7Type§8] §8- §8Sets the region type
|
|
||||||
REGION_REGION_HELP_CHANGESKIN_INFO=§8/§eregion changeskin §8- §7Returns the region skin
|
REGION_REGION_HELP_CHANGESKIN_INFO=§8/§eregion changeskin §8- §7Returns the region skin
|
||||||
REGION_REGION_HELP_CHANGESKIN=§8/§eregion changeskin §8[§7Skin§8] §8- §8Sets the region skin
|
REGION_REGION_HELP_CHANGESKIN=§8/§eregion changeskin §8[§7Skin§8] §8- §8Sets the region skin
|
||||||
REGION_REGION_NOTHING_UNDO=§cNothing left to undo
|
REGION_REGION_NOTHING_UNDO=§cNothing left to undo
|
||||||
@ -853,13 +822,6 @@ REGION_REGION_TP_COPY=§7Teleported to the copy point
|
|||||||
REGION_REGION_TP_TEST_BLOCK=§7Teleported to the tesblock
|
REGION_REGION_TP_TEST_BLOCK=§7Teleported to the tesblock
|
||||||
REGION_REGION_TP_UNKNOWN=§cUndefined teleport point
|
REGION_REGION_TP_UNKNOWN=§cUndefined teleport point
|
||||||
REGION_REGION_NO_REGION=§cYou are not inside any region
|
REGION_REGION_NO_REGION=§cYou are not inside any region
|
||||||
REGION_REGION_NO_PERMS=§cYou are not allowed to change the region
|
|
||||||
REGION_REGION_CHANGETYPE_INFO=§7RRegion type is §e{0}
|
|
||||||
REGION_REGION_CHANGETYPE_UNKNOWN=§cRegion type is invalid
|
|
||||||
REGION_REGION_CHANGETYPE_INVALID=§cRegion type is not allowed here
|
|
||||||
REGION_REGION_CHANGETYPE_CHANGE=§7Region type changed to §e{0}
|
|
||||||
REGION_REGION_CHANGETYPE_CHANGE_UPDATE=§7Click §e§lHERE §7to change the region type
|
|
||||||
REGION_REGION_CHANGETYPE_CHANGE_UPDATE_HOVER=§8/§ereset
|
|
||||||
REGION_REGION_CHANGESKIN_INFO=§7Region skin is §e{0}
|
REGION_REGION_CHANGESKIN_INFO=§7Region skin is §e{0}
|
||||||
REGION_REGION_CHANGESKIN_INFO_CREATOR=§7Skin created by §e{0}
|
REGION_REGION_CHANGESKIN_INFO_CREATOR=§7Skin created by §e{0}
|
||||||
REGION_REGION_CHANGESKIN_UNKNOWN=§cRegion skin is invalid
|
REGION_REGION_CHANGESKIN_UNKNOWN=§cRegion skin is invalid
|
||||||
@ -871,7 +833,6 @@ REGION_RESET_HELP_RESET=§8/§ereset §8- §7Resets the region
|
|||||||
REGION_RESET_HELP_SCHEMATIC=§8/§ereset §8[§7Schematic§8] §8- §7Resets the region using a schematic
|
REGION_RESET_HELP_SCHEMATIC=§8/§ereset §8[§7Schematic§8] §8- §7Resets the region using a schematic
|
||||||
REGION_RESET_RESETED=§7Region reset
|
REGION_RESET_RESETED=§7Region reset
|
||||||
REGION_RESET_ERROR=§cError reseting the region
|
REGION_RESET_ERROR=§cError reseting the region
|
||||||
REGION_RESET_NO_PERMS=§cYou are not allowed to reset the region here
|
|
||||||
REGION_RESET_NO_REGION=§cYou are currently not in any region
|
REGION_RESET_NO_REGION=§cYou are currently not in any region
|
||||||
REGION_TB_HELP_RESET=§8/§etestblock §8- §7Reset the dummy
|
REGION_TB_HELP_RESET=§8/§etestblock §8- §7Reset the dummy
|
||||||
REGION_TB_HELP_RESET_EXTENSION=§8/§etestblock §8[§7ExtensionType§8] §8- §7Reset the dummy
|
REGION_TB_HELP_RESET_EXTENSION=§8/§etestblock §8[§7ExtensionType§8] §8- §7Reset the dummy
|
||||||
@ -879,7 +840,6 @@ REGION_TB_HELP_SCHEMATIC=§8/§etestblock §8[§7Schematic§8] §8- §7Reset the
|
|||||||
REGION_TB_HELP_SCHEMATIC_EXTENSION=§8/§etestblock §8[§7Schematic§8] §8[§7ExtensionType§8] §8- §7Reset the dummy using a schematic
|
REGION_TB_HELP_SCHEMATIC_EXTENSION=§8/§etestblock §8[§7Schematic§8] §8[§7ExtensionType§8] §8- §7Reset the dummy using a schematic
|
||||||
REGION_TB_DONE=§7Dummy reset
|
REGION_TB_DONE=§7Dummy reset
|
||||||
REGION_TB_ERROR=§cError resetting the dummy
|
REGION_TB_ERROR=§cError resetting the dummy
|
||||||
REGION_TB_NO_PERMS=§cYou are not allowed to reset the dummy here
|
|
||||||
REGION_TB_NO_REGION=§cYou are currently not in any region
|
REGION_TB_NO_REGION=§cYou are currently not in any region
|
||||||
REGION_TB_NO_SCHEMSHARING=§cYou currently cannot share schematics until {0}.
|
REGION_TB_NO_SCHEMSHARING=§cYou currently cannot share schematics until {0}.
|
||||||
REGION_TB_NO_SCHEMRECEIVING=§cThe Owner of this build server cannot receive any schematics until {0}.
|
REGION_TB_NO_SCHEMRECEIVING=§cThe Owner of this build server cannot receive any schematics until {0}.
|
||||||
@ -889,11 +849,10 @@ REGION_TNT_ON=§aTNT-Damage activated
|
|||||||
REGION_TNT_OFF=§cTNT-Damage deactivated
|
REGION_TNT_OFF=§cTNT-Damage deactivated
|
||||||
REGION_TNT_TB=§aTNT-Damage activated outside the building area
|
REGION_TNT_TB=§aTNT-Damage activated outside the building area
|
||||||
REGION_TNT_BUILD=§aTNT-Damage activated outside the testblok area
|
REGION_TNT_BUILD=§aTNT-Damage activated outside the testblok area
|
||||||
REGION_TNT_NO_PERMS=§cYou are not allowed to toggle tnt damage here
|
|
||||||
REGION_TNT_BUILD_DESTROY=§cAn explosion would have destroyed blocks in the building area
|
REGION_TNT_BUILD_DESTROY=§cAn explosion would have destroyed blocks in the building area
|
||||||
REGION_TNT_TB_DESTROY=§cAn explosion would have destroyed blocks in the testblock area
|
REGION_TNT_TB_DESTROY=§cAn explosion would have destroyed blocks in the testblock area
|
||||||
|
|
||||||
AFK_KICK_MESSAGE=§cNothing happened on this server for 5 minutes.
|
AFK_KICK_MESSAGE=§cNothing happened on this server for 15 minutes.
|
||||||
AFK_WARNING_MESSAGE=§cThis server will stop in one minute if you remain inactive
|
AFK_WARNING_MESSAGE=§cThis server will stop in one minute if you remain inactive
|
||||||
|
|
||||||
SKIN_HELP = §8/§eskin §8[§7Shortform§8] §8[§7Creator§8|§epublic§8] §8[§7Name...§8] §8- §7Creates the skin schematic. Use 'public' as creator to have no creator, then copy the message to YoyoNow by clicking
|
SKIN_HELP = §8/§eskin §8[§7Shortform§8] §8[§7Creator§8|§epublic§8] §8[§7Name...§8] §8- §7Creates the skin schematic. Use 'public' as creator to have no creator, then copy the message to YoyoNow by clicking
|
||||||
@ -908,7 +867,6 @@ PANZERN_PREPARE1 = §71. Check, if barrels reach until border of armor.
|
|||||||
PANZERN_PREPARE2 = §72. Carpet on the floor in walkways helps with armoring.
|
PANZERN_PREPARE2 = §72. Carpet on the floor in walkways helps with armoring.
|
||||||
PANZERN_PREPARE3 = §73. Shieldtechnology should be encased.
|
PANZERN_PREPARE3 = §73. Shieldtechnology should be encased.
|
||||||
PANZERN_PREPARE4 = §74. Standing in the region that is being armored can improve armoring.
|
PANZERN_PREPARE4 = §74. Standing in the region that is being armored can improve armoring.
|
||||||
PANZERN_NO_PERM = §cYou are not allowed to use the armoring system here
|
|
||||||
PANZERN_NO_WORLDEDIT = §cYou have no WorldEdit selcetion
|
PANZERN_NO_WORLDEDIT = §cYou have no WorldEdit selcetion
|
||||||
PANZERN_PROGRESS = §e{0} §7Blocks left, §e{1} §7Blocks per second, §e{2} §7block delta
|
PANZERN_PROGRESS = §e{0} §7Blocks left, §e{1} §7Blocks per second, §e{2} §7block delta
|
||||||
PANZERN_DONE = §aDone
|
PANZERN_DONE = §aDone
|
||||||
@ -918,7 +876,6 @@ LAUFBAU_HELP = §8/§elaufbau §8[§7smallest§8|§7blastresistant§8] §8- §7B
|
|||||||
LAUFBAU_HELP_SETTINGS = §8/§elaufbau settings §8- §7Opens the settings GUI
|
LAUFBAU_HELP_SETTINGS = §8/§elaufbau settings §8- §7Opens the settings GUI
|
||||||
LAUFBAU_PREPARE1 = §71. Trace the cannons as often as necessary, in all modes.
|
LAUFBAU_PREPARE1 = §71. Trace the cannons as often as necessary, in all modes.
|
||||||
LAUFBAU_PREPARE2 = §72. Try to delete all fails from the traces.
|
LAUFBAU_PREPARE2 = §72. Try to delete all fails from the traces.
|
||||||
LAUFBAU_NO_PERM = §cYou are not allowed to use the barrel building system here
|
|
||||||
LAUFBAU_NO_WORLDEDIT = §cYou don't have a WorldEdit selection
|
LAUFBAU_NO_WORLDEDIT = §cYou don't have a WorldEdit selection
|
||||||
LAUFBAU_STATE_FILTERING_TRACES = Filtering traces
|
LAUFBAU_STATE_FILTERING_TRACES = Filtering traces
|
||||||
LAUFBAU_STATE_PROCESSING_TRACES = Connnecting traces
|
LAUFBAU_STATE_PROCESSING_TRACES = Connnecting traces
|
||||||
@ -1030,7 +987,6 @@ LAUFBAU_TILT_PARTIAL = §8-§7 Tilt partial
|
|||||||
# UTILS
|
# UTILS
|
||||||
SELECT_HELP = §8/§eselect §8[§7RegionsTyp§8] §8- §7Select a region type
|
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_NO_PERMS = §cYou are not allowed to use the slection tool here
|
|
||||||
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_NO_EXTENSION = §cThis region has no extension
|
||||||
@ -1084,7 +1040,6 @@ PISTON_HELP_3 = §7Count is yellow, if too many blocks are present.
|
|||||||
PISTON_INFO = §7Moved Blocks {0}{1}§8/§712
|
PISTON_INFO = §7Moved Blocks {0}{1}§8/§712
|
||||||
|
|
||||||
# Warp
|
# Warp
|
||||||
WARP_DISALLOWED = §cYou are not allowed to use the warp here
|
|
||||||
WARP_LOC_X = §7X§8: §e{0}
|
WARP_LOC_X = §7X§8: §e{0}
|
||||||
WARP_LOC_Y = §7Y§8: §e{0}
|
WARP_LOC_Y = §7Y§8: §e{0}
|
||||||
WARP_LOC_Z = §7Z§8: §e{0}
|
WARP_LOC_Z = §7Z§8: §e{0}
|
||||||
@ -1110,12 +1065,9 @@ WARP_HELP_LIST=§8/§ewarp list §8- §7List all warps
|
|||||||
|
|
||||||
# WORLD
|
# WORLD
|
||||||
STOP_HELP = §8/§estop §8- §7Stops the server
|
STOP_HELP = §8/§estop §8- §7Stops the server
|
||||||
STOP_NO_PERMS = §cYou do not have the permission to stop the server
|
|
||||||
STOP_MESSAGE = §eServer is stopping
|
STOP_MESSAGE = §eServer is stopping
|
||||||
WORLD_EDIT_NO_PERMS = §cYou do not have the permission to use WorldEdit
|
|
||||||
|
|
||||||
KICKALL_HELP = §8/§ekickall §8- §7Kick all players from the server except the owner
|
KICKALL_HELP = §8/§ekickall §8- §7Kick all players from the server except the owner
|
||||||
KICKALL_NO_PERM = §cThis is not your world!
|
|
||||||
|
|
||||||
# Techhider
|
# Techhider
|
||||||
TECHHIDER_HELP = §8/§etechhider §8- §7Toggle Techhider
|
TECHHIDER_HELP = §8/§etechhider §8- §7Toggle Techhider
|
||||||
|
@ -27,6 +27,10 @@ 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
|
||||||
|
NO_PERMISSION = Du darfst dies hier nicht nutzen
|
||||||
|
SPECTATOR = §fZuschauer
|
||||||
|
|
||||||
# Scoreboard
|
# Scoreboard
|
||||||
SCOREBOARD_TIME = Uhrzeit
|
SCOREBOARD_TIME = Uhrzeit
|
||||||
SCOREBOARD_REGION = Region
|
SCOREBOARD_REGION = Region
|
||||||
@ -40,6 +44,11 @@ SCOREBOARD_TRACE_TICKS = Ticks
|
|||||||
SCOREBOARD_TECHHIDER = TechHider§8: §aAn
|
SCOREBOARD_TECHHIDER = TechHider§8: §aAn
|
||||||
SCOREBOARD_XRAY = XRay§8: §aAn
|
SCOREBOARD_XRAY = XRay§8: §aAn
|
||||||
|
|
||||||
|
SCOREBOARD_LOCK_TEAM = Bau Lock§8: §eTeam
|
||||||
|
SCOREBOARD_LOCK_TEAM_AND_SERVERTEAM = Bau Lock§8: §e(Server-) Team
|
||||||
|
SCOREBOARD_LOCK_SERVERTEAM = Bau Lock§8: §eServerteam
|
||||||
|
SCOREBOARD_LOCK_NOBODY = Bau Lock§8: §cNiemand
|
||||||
|
|
||||||
# Flags
|
# Flags
|
||||||
FLAG_COLOR = Color
|
FLAG_COLOR = Color
|
||||||
FLAG_TNT = TNT
|
FLAG_TNT = TNT
|
||||||
@ -115,7 +124,6 @@ BACKUP_HELP_LOAD=§8/§ebackup load §8[§7BackupName§8] §8- §7 Lade ein Back
|
|||||||
BACKUP_HELP_LIST=§8/§ebackup list §8- §7Liste alle Backups der Region auf
|
BACKUP_HELP_LIST=§8/§ebackup list §8- §7Liste alle Backups der Region auf
|
||||||
BACKUP_HELP_GUI=§8/§ebackup gui §8- §7Öffne die Backups in einer GUI
|
BACKUP_HELP_GUI=§8/§ebackup gui §8- §7Öffne die Backups in einer GUI
|
||||||
BACKUP_REGION_NO_REGION=§cDu bist in keiner Region
|
BACKUP_REGION_NO_REGION=§cDu bist in keiner Region
|
||||||
BACKUP_NO_PERMS=§cDu darfst hier nicht das Backup System verwenden
|
|
||||||
BACKUP_CREATE_SUCCESS=§7Das Backup wurde erstellt
|
BACKUP_CREATE_SUCCESS=§7Das Backup wurde erstellt
|
||||||
BACKUP_CREATE_FAILURE=§cDas Backup erstellen ist schiefgegangen
|
BACKUP_CREATE_FAILURE=§cDas Backup erstellen ist schiefgegangen
|
||||||
BACKUP_CREATE_NO_CHANGE=§7Die Region hat keine Veränderung
|
BACKUP_CREATE_NO_CHANGE=§7Die Region hat keine Veränderung
|
||||||
@ -129,11 +137,6 @@ BACKUP_LORE=§eKlicken zum Laden
|
|||||||
|
|
||||||
# Bau
|
# Bau
|
||||||
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_COMMAND_HELP_TOGGLEWE = §8/§ebau togglewe §8[§7Player§8] §8- §7Editiere die WorldEdit Rechte eines Spielers
|
|
||||||
BAU_COMMAND_HELP_TOGGLEWORLD = §8/§ebau toggleworld §8[§7Player§8] §8- §7Editiere die Welt Rechte eines Spielers
|
|
||||||
BAU_UNKNOWN_PLAYER = §cUnbekannter Spieler
|
|
||||||
BAU_NO_PLAYER = §cDer Spieler ist kein Mitglied deiner Welt!
|
|
||||||
BAU_NO_WORLD = §cDies ist nicht deine Welt!
|
|
||||||
|
|
||||||
BAU_INFO_ITEM_NAME = §eBau-Management
|
BAU_INFO_ITEM_NAME = §eBau-Management
|
||||||
## This is used in BauInfoBauGuiItem.java
|
## This is used in BauInfoBauGuiItem.java
|
||||||
@ -146,12 +149,7 @@ BAU_INFO_ITEM_LORE_PROTECT = §7Protect§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 = §7Mitglieder §8[§7{0}§8]§8: §e
|
BAU_INFO_COMMAND_MEMBER = §7{0} §8[§7{1}§8]§8: §e{2}
|
||||||
BAU_INFO_MEMBER_INFO = §e{0}§8[{1}§8,{2}§8] §8
|
|
||||||
BAU_INFO_MEMBER_WE_ALLOW = §aWE
|
|
||||||
BAU_INFO_MEMBER_WE_DISALLOW = §cWE
|
|
||||||
BAU_INFO_MEMBER_WORLD_ALLOW = §aW
|
|
||||||
BAU_INFO_MEMBER_WORLD_DISALLOW = §cW
|
|
||||||
BAU_INFO_COMMAND_FLAG = §7{0}§8: §7{1}
|
BAU_INFO_COMMAND_FLAG = §7{0}§8: §7{1}
|
||||||
BAU_INFO_COMMAND_TPS = §7TPS§8:§e
|
BAU_INFO_COMMAND_TPS = §7TPS§8:§e
|
||||||
|
|
||||||
@ -210,11 +208,6 @@ HOTBAR_INVENTORY=Standard Hotbar
|
|||||||
# GUI
|
# GUI
|
||||||
GUI_EDITOR_ITEM_NAME=§eGui Editor
|
GUI_EDITOR_ITEM_NAME=§eGui Editor
|
||||||
GUI_NAME=Bau GUI
|
GUI_NAME=Bau GUI
|
||||||
GUI_NO_PERMISSION=§cDu hast nicht genug Rechte um dies zu tun
|
|
||||||
GUI_NO_OWNER=§cDas ist nicht deine Bauwelt
|
|
||||||
GUI_NO_WORLD=§cDu darfst hier die Welt nicht einstellen
|
|
||||||
GUI_NO_WORLDEDIT=§cDu darfst hier kein Worldedit benutzen
|
|
||||||
GUI_NO_MEMBER=§cDu musst ein Member der Bauwelt sein
|
|
||||||
GUI_ITEM_LORE1=§7Du kannst dieses Item zum Öffnen der BauGUI nutzen
|
GUI_ITEM_LORE1=§7Du kannst dieses Item zum Öffnen der BauGUI nutzen
|
||||||
GUI_ITEM_LORE2=§7oder Doppel F (Swap hands) drücken.
|
GUI_ITEM_LORE2=§7oder Doppel F (Swap hands) drücken.
|
||||||
GUI_EDITOR_TITLE=Bau GUI Editor
|
GUI_EDITOR_TITLE=Bau GUI Editor
|
||||||
@ -258,7 +251,6 @@ SHIELD_PRINTING_HELP_STEP_7 = §87. §7Wende das gedruckte mit §8/§eshieldprin
|
|||||||
|
|
||||||
SHIELD_PRINTING_NO_REGION = §cDu bist in keiner Region.
|
SHIELD_PRINTING_NO_REGION = §cDu bist in keiner Region.
|
||||||
SHIELD_PRINTING_NOT_RUNNING = §cShield printing ist nicht aktiv.
|
SHIELD_PRINTING_NOT_RUNNING = §cShield printing ist nicht aktiv.
|
||||||
SHIELD_PRINTING_DISALLOWED = §cDu darfst Shield printing nicht benutzen.
|
|
||||||
SHIELD_PRINTING_BOSSBAR = §fBewegungen: {0}
|
SHIELD_PRINTING_BOSSBAR = §fBewegungen: {0}
|
||||||
SHIELD_PRINTING_BOSSBAR_COPIED = §fBewegungen: {0} Kopiert: {1}
|
SHIELD_PRINTING_BOSSBAR_COPIED = §fBewegungen: {0} Kopiert: {1}
|
||||||
|
|
||||||
@ -295,7 +287,6 @@ SIMULATOR_CHANGE_HELP = §8/§esimulator change §8-§7 Wechsel zu einem anderen
|
|||||||
SIMULATOR_DELETE_HELP = §8/§esimulator delete §8[§7name§8] §8-§7 Löscht den Simulator
|
SIMULATOR_DELETE_HELP = §8/§esimulator delete §8[§7name§8] §8-§7 Löscht den Simulator
|
||||||
SIMULATOR_START_HELP = §8/§esimulator start §8[§7name§8] §8-§7 Startet die Simulation
|
SIMULATOR_START_HELP = §8/§esimulator start §8[§7name§8] §8-§7 Startet die Simulation
|
||||||
SIMULATOR_COPY_HELP = §8/§esimulator copy §8[§7to-copy§8] §8[§7name§8] §8-§7 Kopiert einen Simulator
|
SIMULATOR_COPY_HELP = §8/§esimulator copy §8[§7to-copy§8] §8[§7name§8] §8-§7 Kopiert einen Simulator
|
||||||
SIMULATOR_NO_PERMS = §cDu darfst hier nicht den Simulator nutzen
|
|
||||||
|
|
||||||
SIMULATOR_GUI_ITEM_NAME = §eTNT Simulator
|
SIMULATOR_GUI_ITEM_NAME = §eTNT Simulator
|
||||||
|
|
||||||
@ -305,6 +296,7 @@ SIMULATOR_GUI_CREATE_SIM = §eSimulator erstellen
|
|||||||
SIMULATOR_GUI_CREATE_SIM_GUI = Simulator erstellen
|
SIMULATOR_GUI_CREATE_SIM_GUI = Simulator erstellen
|
||||||
SIMULATOR_NAME_ALREADY_EXISTS = §cSimulator existiert bereits
|
SIMULATOR_NAME_ALREADY_EXISTS = §cSimulator existiert bereits
|
||||||
SIMULATOR_NAME_INVALID = §cUngültiger Name
|
SIMULATOR_NAME_INVALID = §cUngültiger Name
|
||||||
|
SIMULATOR_ERROR_COPY = §cFehler beim kopieren
|
||||||
SIMULATOR_NOT_EXISTS = §cSimulator existiert nicht
|
SIMULATOR_NOT_EXISTS = §cSimulator existiert nicht
|
||||||
SIMULATOR_CREATE = §aSimulator erstellt
|
SIMULATOR_CREATE = §aSimulator erstellt
|
||||||
SIMULATOR_EDIT_LOCATION = §7Editiere Positionen
|
SIMULATOR_EDIT_LOCATION = §7Editiere Positionen
|
||||||
@ -320,7 +312,7 @@ SIMULATOR_WAND_LORE_1 = §eRechtsklick §8- §7Füge eine Position hinzu
|
|||||||
SIMULATOR_WAND_LORE_2 = §eSneaken §8- §7Freie Bewegung
|
SIMULATOR_WAND_LORE_2 = §eSneaken §8- §7Freie Bewegung
|
||||||
SIMULATOR_WAND_LORE_3 = §eLinksklick §8- §7Starte die Simulation
|
SIMULATOR_WAND_LORE_3 = §eLinksklick §8- §7Starte die Simulation
|
||||||
SIMULATOR_WAND_LORE_4 = §eRechtsklick Luft §8- §7Öffne die GUI
|
SIMULATOR_WAND_LORE_4 = §eRechtsklick Luft §8- §7Öffne die GUI
|
||||||
SIMULATOR_WAND_LORE_5 = §eOffhand §8- §7Simulator Vorschau
|
SIMULATOR_WAND_LORE_5 = §eDoppel Shift §8- §7Wechsel zwischen TNT und Redstone Block
|
||||||
|
|
||||||
SIMULATOR_REGION_FROZEN = §cSimulator kann nicht in eingefrorenen Regionen genutzt werden
|
SIMULATOR_REGION_FROZEN = §cSimulator kann nicht in eingefrorenen Regionen genutzt werden
|
||||||
|
|
||||||
@ -450,7 +442,6 @@ TPSLIMIT_GUI_ITEM_NAME = §eTPS Limiter
|
|||||||
TPSLIMIT_GUI_ITEM_LORE = §7Aktuell: §e{0}
|
TPSLIMIT_GUI_ITEM_LORE = §7Aktuell: §e{0}
|
||||||
TPSLIMIT_ANVIL_GUI = Neues TPS Limit
|
TPSLIMIT_ANVIL_GUI = Neues TPS Limit
|
||||||
TPSLIMIT_CURRENT = §7Jetziges TPS limit§8: §e{0}
|
TPSLIMIT_CURRENT = §7Jetziges TPS limit§8: §e{0}
|
||||||
TPSLIMIT_NO_PERMS = §cDu darfst hier nicht den TPS-Limiter nutzen
|
|
||||||
TPSLIMIT_SET = §eTPS limit auf {0} gesetzt.
|
TPSLIMIT_SET = §eTPS limit auf {0} gesetzt.
|
||||||
TPSLIMIT_FROZEN = §eTPS eingefroren.
|
TPSLIMIT_FROZEN = §eTPS eingefroren.
|
||||||
|
|
||||||
@ -542,7 +533,6 @@ LOADER_PAUSED=§7Der Loader ist nun pausiert.
|
|||||||
LOADER_SMALL_TIME=§cDie Wartezeit ist zu klein
|
LOADER_SMALL_TIME=§cDie Wartezeit ist zu klein
|
||||||
LOADER_NEW_TIME=§7Die Schusswartezeit ist nun: {0}
|
LOADER_NEW_TIME=§7Die Schusswartezeit ist nun: {0}
|
||||||
LOADER_NEW_LOAD_TIME=§7Die Setzwartezeit ist nun: {0}
|
LOADER_NEW_LOAD_TIME=§7Die Setzwartezeit ist nun: {0}
|
||||||
LOADER_PERMS=§cDu darfst hier nicht den Detonator nutzen
|
|
||||||
|
|
||||||
LOADER_NOTHING_RECORDED=§cEs wurden keine Elemente aufgenommen!
|
LOADER_NOTHING_RECORDED=§cEs wurden keine Elemente aufgenommen!
|
||||||
LOADER_GUI_TITLE=Loader Einstellungen
|
LOADER_GUI_TITLE=Loader Einstellungen
|
||||||
@ -661,7 +651,6 @@ OTHER_CLEAR_HELP_PLAYER=§8/§eclear §8[§7Player§8] §8- §7Leere ein Spieler
|
|||||||
OTHER_CLEAR_CLEARED=Dein Inventar wurde geleert.
|
OTHER_CLEAR_CLEARED=Dein Inventar wurde geleert.
|
||||||
OTHER_CLEAR_FROM=Dein Inventar wurde von {0} §7geleert.
|
OTHER_CLEAR_FROM=Dein Inventar wurde von {0} §7geleert.
|
||||||
OTHER_CLEAR_TO=Das Inventar von {0} §7wurde geleert.
|
OTHER_CLEAR_TO=Das Inventar von {0} §7wurde geleert.
|
||||||
OTHER_CLEAR_NO_PERMS=§cDu darfst hier keine fremden Inventare leeren.
|
|
||||||
OTHER_DECLUTTER_HELP=§8/§edeclutter §8- §7Räume dein Inventar auf
|
OTHER_DECLUTTER_HELP=§8/§edeclutter §8- §7Räume dein Inventar auf
|
||||||
OTHER_DECLUTTER_DONE=§aDein Inventar wurde aufgeräumt.
|
OTHER_DECLUTTER_DONE=§aDein Inventar wurde aufgeräumt.
|
||||||
OTHER_GAMEMODE_UNKNOWN=§cUnbekannter Spielmodus.
|
OTHER_GAMEMODE_UNKNOWN=§cUnbekannter Spielmodus.
|
||||||
@ -677,7 +666,6 @@ OTHER_TELEPORT_SELF_2=§cNoch zu reisende Blöcke: 0; ETA: 0:00
|
|||||||
OTHER_TELEPORT_SELF_3=§cEin wenig bewegung muss ein.
|
OTHER_TELEPORT_SELF_3=§cEin wenig bewegung muss ein.
|
||||||
OTHER_TELEPORT_SELF_4=§cFür eine solche Distanz?
|
OTHER_TELEPORT_SELF_4=§cFür eine solche Distanz?
|
||||||
OTHER_TIME_HELP=§8/§etime §8<§7Zeit 0=Morgen§8, §76000=Mittag§8, §718000=Mitternacht§8> - §7Setzt die Zeit auf dem Bau
|
OTHER_TIME_HELP=§8/§etime §8<§7Zeit 0=Morgen§8, §76000=Mittag§8, §718000=Mitternacht§8> - §7Setzt die Zeit auf dem Bau
|
||||||
OTHER_TIME_NO_PERM=§cDu darfst hier nicht die Zeit ändern
|
|
||||||
OTHER_TIME_INVALID=§cBitte gib eine Zahl zwischen 0 und 24000 an
|
OTHER_TIME_INVALID=§cBitte gib eine Zahl zwischen 0 und 24000 an
|
||||||
OTHER_TIME_RESULT=§7§oWhooosh
|
OTHER_TIME_RESULT=§7§oWhooosh
|
||||||
OTHER_TPS_HEAD = §7TPS: 1s 10s 1m 5m 10m
|
OTHER_TPS_HEAD = §7TPS: 1s 10s 1m 5m 10m
|
||||||
@ -739,17 +727,6 @@ MATERIAL_INTERACTABLE=§8- §eInterargierbarer Block
|
|||||||
MATERIAL_FLAMMABLE=§8- §eFlammbarer Block
|
MATERIAL_FLAMMABLE=§8- §eFlammbarer Block
|
||||||
MATERIAL_BURNABLE=§8- §eBrennbarer Block
|
MATERIAL_BURNABLE=§8- §eBrennbarer Block
|
||||||
MATERIAL_WATERLOGGABLE=§8- §eWasserspeicherbarer Block
|
MATERIAL_WATERLOGGABLE=§8- §eWasserspeicherbarer Block
|
||||||
# Redstonetester
|
|
||||||
RT_HELP=§8/§eredstonetester §8-§7 Gibt den RedstoneTester
|
|
||||||
RT_GIVEN=§7Messe die Zeit zwischen der Aktivierung zweier Redstone Komponenten
|
|
||||||
RT_ITEM_NAME=§eRedstonetester
|
|
||||||
RT_ITEM_LORE_1=§eLinksklick Block §8-§7 Setzt die 1. Position
|
|
||||||
RT_ITEM_LORE_2=§eRechtsklick Block §8-§7 Setzt die 2. Position
|
|
||||||
RT_ITEM_LORE_3=§eShift-Rechtsklick Luft §8-§7 Zurücksetzten
|
|
||||||
RT_LOC=§8: §e{0} {1} {2}
|
|
||||||
RT_INVALID_LOC=§cUnbekannte Position
|
|
||||||
RT_RESULT=§7Differenz§8: §e{0}§7 Ticks §8,§7 R-Ticks §e{1}
|
|
||||||
RT_ACTIVATE=§7Positionen gelöscht§8.
|
|
||||||
# Region Items
|
# Region Items
|
||||||
REGION_ITEM_COLOR=§7Color: §e{0}
|
REGION_ITEM_COLOR=§7Color: §e{0}
|
||||||
REGION_ITEM_COLOR_CHOOSE=Farbe Wählen
|
REGION_ITEM_COLOR_CHOOSE=Farbe Wählen
|
||||||
@ -775,24 +752,18 @@ REGION_COLOR_HELP_COLOR=§8/§ecolor §8[§7Color§8] §8- §7Setze die Farbe de
|
|||||||
REGION_COLOR_HELP_COLOR_TYPE=§8/§ecolor §8[§7Color§8] §8[§7Type§8] §8- §7Setze die Farbe der Region oder Global
|
REGION_COLOR_HELP_COLOR_TYPE=§8/§ecolor §8[§7Color§8] §8[§7Type§8] §8- §7Setze die Farbe der Region oder Global
|
||||||
REGION_COLOR_GLOBAL=§7Alle Regions farben auf §e{0}§7 gesetzt
|
REGION_COLOR_GLOBAL=§7Alle Regions farben auf §e{0}§7 gesetzt
|
||||||
REGION_COLOR_NO_REGION=§cDu befindest dich derzeit in keiner Region
|
REGION_COLOR_NO_REGION=§cDu befindest dich derzeit in keiner Region
|
||||||
REGION_COLOR_NO_PERMS=§cDies ist nicht deine Welt!
|
|
||||||
REGION_FIRE_HELP=§8/§efire §8- §7Toggle Feuerschaden
|
REGION_FIRE_HELP=§8/§efire §8- §7Toggle Feuerschaden
|
||||||
REGION_FIRE_NO_PERMS=§cDu darfst hier nicht Feuerschaden (de-)aktivieren
|
|
||||||
REGION_FIRE_ENABLED=§cRegions Feuerschaden deaktiviert
|
REGION_FIRE_ENABLED=§cRegions Feuerschaden deaktiviert
|
||||||
REGION_FIRE_DISABLED=§aRegions Feuerschaden aktiviert
|
REGION_FIRE_DISABLED=§aRegions Feuerschaden aktiviert
|
||||||
REGION_FREEZE_HELP=§8/§efreeze §8- §7Toggle Freeze
|
REGION_FREEZE_HELP=§8/§efreeze §8- §7Toggle Freeze
|
||||||
REGION_FREEZE_NO_PERMS=§cDu darfst diese Welt nicht einfrieren
|
|
||||||
REGION_FREEZE_ENABLED=§cRegion eingefroren
|
REGION_FREEZE_ENABLED=§cRegion eingefroren
|
||||||
REGION_FREEZE_DISABLED=§aRegion aufgetaut
|
REGION_FREEZE_DISABLED=§aRegion aufgetaut
|
||||||
REGION_ITEMS_HELP=§8/§eitems §8- §7Toggle Items
|
REGION_ITEMS_HELP=§8/§eitems §8- §7Toggle Items
|
||||||
REGION_ITEMS_NO_PERMS=§cDu darfst hier nicht Items (de-)aktivieren
|
|
||||||
REGION_ITEMS_ENABLED=§aItems aktiviert in dieser Region
|
REGION_ITEMS_ENABLED=§aItems aktiviert in dieser Region
|
||||||
REGION_ITEMS_DISABLED=§cItems deaktiviert in dieser Region
|
REGION_ITEMS_DISABLED=§cItems deaktiviert in dieser Region
|
||||||
REGION_ITEMS_DISABLED_GLOBAL=§cItems sind auf dem Server deaktiviert.
|
|
||||||
REGION_PROTECT_HELP=§8/§eprotect §8- §7Schütze die Region
|
REGION_PROTECT_HELP=§8/§eprotect §8- §7Schütze die Region
|
||||||
REGION_PROTECT_DISABLE=§cBoden Schutz aufgehoben
|
REGION_PROTECT_DISABLE=§cBoden Schutz aufgehoben
|
||||||
REGION_PROTECT_ENABLE=§aBoden geschützt
|
REGION_PROTECT_ENABLE=§aBoden geschützt
|
||||||
REGION_PROTECT_NO_PERMS=§cDu darfst hier nicht den Boden schützen
|
|
||||||
REGION_PROTECT_FALSE_REGION=§cDu befindest dich derzeit in keiner (M)WG-Region
|
REGION_PROTECT_FALSE_REGION=§cDu befindest dich derzeit in keiner (M)WG-Region
|
||||||
REGION_REGION_HELP_UNDO=§8/§eregion undo §8- §7Mache die letzten 20 /testblock oder /reset rückgängig
|
REGION_REGION_HELP_UNDO=§8/§eregion undo §8- §7Mache die letzten 20 /testblock oder /reset rückgängig
|
||||||
REGION_REGION_HELP_REDO=§8/§eregion redo §8- §7Wiederhole die letzten 20 §8/§7rg undo
|
REGION_REGION_HELP_REDO=§8/§eregion redo §8- §7Wiederhole die letzten 20 §8/§7rg undo
|
||||||
@ -800,8 +771,6 @@ REGION_REGION_HELP_RESTORE=§8/§eregion restore §8- §7Setzte die Region zurü
|
|||||||
REGION_REGION_HELP_RESTORE_SCHEMATIC=§8/§eregion restore §8[§7Schematic§8] §8- §7Setzte die Region zurück, ohne das Gebaute zu löschen
|
REGION_REGION_HELP_RESTORE_SCHEMATIC=§8/§eregion restore §8[§7Schematic§8] §8- §7Setzte die Region zurück, ohne das Gebaute zu löschen
|
||||||
REGION_REGION_HELP_COPYPOINT=§8/§eregion copypoint §8- §7Teleportiere dich zum Regions Kopierpunkt
|
REGION_REGION_HELP_COPYPOINT=§8/§eregion copypoint §8- §7Teleportiere dich zum Regions Kopierpunkt
|
||||||
REGION_REGION_HELP_TESTBLOCKPOINT=§8/§eregion testblockpoint §8- §7Teleportiere dich zum Regions Testblockpunkt
|
REGION_REGION_HELP_TESTBLOCKPOINT=§8/§eregion testblockpoint §8- §7Teleportiere dich zum Regions Testblockpunkt
|
||||||
REGION_REGION_HELP_CHANGETYPE_INFO=§8/§eregion changetype §8- §7Gebe den Regions Type aus
|
|
||||||
REGION_REGION_HELP_CHANGETYPE=§8/§eregion changetype §8[§7Type§8] §8- §8Setzte den Regions Type
|
|
||||||
REGION_REGION_HELP_CHANGESKIN_INFO=§8/§eregion changeskin §8- §7Gebe den Regions Skin aus
|
REGION_REGION_HELP_CHANGESKIN_INFO=§8/§eregion changeskin §8- §7Gebe den Regions Skin aus
|
||||||
REGION_REGION_HELP_CHANGESKIN=§8/§eregion changeskin §8[§7Skin§8] §8- §8Setzte den Regions Skin
|
REGION_REGION_HELP_CHANGESKIN=§8/§eregion changeskin §8[§7Skin§8] §8- §8Setzte den Regions Skin
|
||||||
REGION_REGION_NOTHING_UNDO=§cNichts zum rückgängig machen
|
REGION_REGION_NOTHING_UNDO=§cNichts zum rückgängig machen
|
||||||
@ -817,13 +786,6 @@ REGION_REGION_TP_COPY=§7Zum Kopierpunkt teleportiert
|
|||||||
REGION_REGION_TP_TEST_BLOCK=§7Zum Testblock teleportiert
|
REGION_REGION_TP_TEST_BLOCK=§7Zum Testblock teleportiert
|
||||||
REGION_REGION_TP_UNKNOWN=§cNicht definierter Teleportierpunkt
|
REGION_REGION_TP_UNKNOWN=§cNicht definierter Teleportierpunkt
|
||||||
REGION_REGION_NO_REGION=§cDu bist in keiner Region
|
REGION_REGION_NO_REGION=§cDu bist in keiner Region
|
||||||
REGION_REGION_NO_PERMS=§cDu darfst hier nicht die Region verändern
|
|
||||||
REGION_REGION_CHANGETYPE_INFO=§7Regions Type ist §e{0}
|
|
||||||
REGION_REGION_CHANGETYPE_UNKNOWN=§cRegions Type ist nicht valide
|
|
||||||
REGION_REGION_CHANGETYPE_INVALID=§cRegions Type ist nicht erlaubt hier
|
|
||||||
REGION_REGION_CHANGETYPE_CHANGE=§7Regions Type ist auf §e{0}§7 geändert
|
|
||||||
REGION_REGION_CHANGETYPE_CHANGE_UPDATE=§7Klicke §e§lHIER §7um den Type anzuwenden
|
|
||||||
REGION_REGION_CHANGETYPE_CHANGE_UPDATE_HOVER=§8/§ereset
|
|
||||||
REGION_REGION_CHANGESKIN_INFO=§7Regions Skin ist §e{0}
|
REGION_REGION_CHANGESKIN_INFO=§7Regions Skin ist §e{0}
|
||||||
REGION_REGION_CHANGESKIN_INFO_CREATOR=§7Skin erstellt von §e{0}
|
REGION_REGION_CHANGESKIN_INFO_CREATOR=§7Skin erstellt von §e{0}
|
||||||
REGION_REGION_CHANGESKIN_UNKNOWN=§cRegions Skin ist nicht valide
|
REGION_REGION_CHANGESKIN_UNKNOWN=§cRegions Skin ist nicht valide
|
||||||
@ -835,7 +797,6 @@ REGION_RESET_HELP_RESET=§8/§ereset §8- §7Setzte die Region zurück
|
|||||||
REGION_RESET_HELP_SCHEMATIC=§8/§ereset §8[§7Schematic§8] §8- §7Setzte die Region mit einer Schematic zurück
|
REGION_RESET_HELP_SCHEMATIC=§8/§ereset §8[§7Schematic§8] §8- §7Setzte die Region mit einer Schematic zurück
|
||||||
REGION_RESET_RESETED=§7Region zurückgesetzt
|
REGION_RESET_RESETED=§7Region zurückgesetzt
|
||||||
REGION_RESET_ERROR=§cFehler beim Zurücksetzen der Region
|
REGION_RESET_ERROR=§cFehler beim Zurücksetzen der Region
|
||||||
REGION_RESET_NO_PERMS=§cDu darfst hier nicht die Region zurücksetzen
|
|
||||||
REGION_RESET_NO_REGION=§cDu befindest dich derzeit in keiner Region
|
REGION_RESET_NO_REGION=§cDu befindest dich derzeit in keiner Region
|
||||||
REGION_TB_HELP_RESET=§8/§etestblock §8- §7Setzte den Testblock zurück
|
REGION_TB_HELP_RESET=§8/§etestblock §8- §7Setzte den Testblock zurück
|
||||||
REGION_TB_HELP_RESET_EXTENSION=§8/§etestblock §8[§7ExtensionType§8] §8- §7Setzte den Testblock zurück
|
REGION_TB_HELP_RESET_EXTENSION=§8/§etestblock §8[§7ExtensionType§8] §8- §7Setzte den Testblock zurück
|
||||||
@ -843,7 +804,6 @@ REGION_TB_HELP_SCHEMATIC=§8/§etestblock §8[§7Schematic§8] §8- §7Setzte de
|
|||||||
REGION_TB_HELP_SCHEMATIC_EXTENSION=§8/§etestblock §8[§7Schematic§8] §8[§7ExtensionType§8] §8- §7Setzte den Testblock mit einer Schematic zurück
|
REGION_TB_HELP_SCHEMATIC_EXTENSION=§8/§etestblock §8[§7Schematic§8] §8[§7ExtensionType§8] §8- §7Setzte den Testblock mit einer Schematic zurück
|
||||||
REGION_TB_DONE=§7Testblock zurückgesetzt
|
REGION_TB_DONE=§7Testblock zurückgesetzt
|
||||||
REGION_TB_ERROR=§cFehler beim Zurücksetzen des Testblocks
|
REGION_TB_ERROR=§cFehler beim Zurücksetzen des Testblocks
|
||||||
REGION_TB_NO_PERMS=§cDu darfst hier nicht den Testblock zurücksetzen
|
|
||||||
REGION_TB_NO_REGION=§cDu befindest dich derzeit in keiner Region
|
REGION_TB_NO_REGION=§cDu befindest dich derzeit in keiner Region
|
||||||
REGION_TB_NO_SCHEMSHARING=§cDu kannst aktuell keine Schematics teilen bis {0}.
|
REGION_TB_NO_SCHEMSHARING=§cDu kannst aktuell keine Schematics teilen bis {0}.
|
||||||
REGION_TB_NO_SCHEMRECEIVING=§cDer Besitzer dieses Bauservers kann keine Schematics erhalten bis {0}.
|
REGION_TB_NO_SCHEMRECEIVING=§cDer Besitzer dieses Bauservers kann keine Schematics erhalten bis {0}.
|
||||||
@ -852,10 +812,9 @@ REGION_TNT_HELP_MODE=§8/§etnt §8[§7Mode§8] §8- §7Setzte das TNT verhalten
|
|||||||
REGION_TNT_ON=§aTNT-Schaden aktiviert
|
REGION_TNT_ON=§aTNT-Schaden aktiviert
|
||||||
REGION_TNT_OFF=§cTNT-Schaden deaktiviert
|
REGION_TNT_OFF=§cTNT-Schaden deaktiviert
|
||||||
REGION_TNT_TB=§aTNT-Schaden außerhalb Baurahmen aktiviert
|
REGION_TNT_TB=§aTNT-Schaden außerhalb Baurahmen aktiviert
|
||||||
REGION_TNT_NO_PERMS=§cDu darfst hier nicht TNT-Schaden (de-)aktivieren
|
|
||||||
REGION_TNT_BUILD_DESTROY=§cEine Explosion hätte Blöcke im Baubereich zerstört
|
REGION_TNT_BUILD_DESTROY=§cEine Explosion hätte Blöcke im Baubereich zerstört
|
||||||
REGION_TNT_TB_DESTROY=§cEine Explosion hätte Blöcke im Testblockbereich zerstört
|
REGION_TNT_TB_DESTROY=§cEine Explosion hätte Blöcke im Testblockbereich zerstört
|
||||||
AFK_KICK_MESSAGE=§cAuf diesem Server ist seit 5 Minuten nichts passiert.
|
AFK_KICK_MESSAGE=§cAuf diesem Server ist seit 15 Minuten nichts passiert.
|
||||||
AFK_WARNING_MESSAGE=§cDieser Server wird bei weiterer Inaktivität in einer Minute gestoppt
|
AFK_WARNING_MESSAGE=§cDieser Server wird bei weiterer Inaktivität in einer Minute gestoppt
|
||||||
|
|
||||||
SKIN_HELP = §8/§eskin §8[§7Kuerzel§8] §8[§7Creator§8|§epublic§8] §8[§7Name...§8] §8- §7Erstellt die Skin Schematics. 'public' als Creator nutzen für keinen Creator, danach die nachricht an YoyoNow kopieren (mit Click kopieren)
|
SKIN_HELP = §8/§eskin §8[§7Kuerzel§8] §8[§7Creator§8|§epublic§8] §8[§7Name...§8] §8- §7Erstellt die Skin Schematics. 'public' als Creator nutzen für keinen Creator, danach die nachricht an YoyoNow kopieren (mit Click kopieren)
|
||||||
@ -870,7 +829,6 @@ PANZERN_PREPARE1 = §71. Gucke nochmal nach, ob Läufe auch bis zur Panzergrenze
|
|||||||
PANZERN_PREPARE2 = §72. Teppich in Gänge auf dem Boden vereinfacht das panzern.
|
PANZERN_PREPARE2 = §72. Teppich in Gänge auf dem Boden vereinfacht das panzern.
|
||||||
PANZERN_PREPARE3 = §73. Schildtechnik sollte explizit eingeschlossen sein.
|
PANZERN_PREPARE3 = §73. Schildtechnik sollte explizit eingeschlossen sein.
|
||||||
PANZERN_PREPARE4 = §74. Innerhalb der zu panzernden Region zu stehen, beim Befehlausführen kann das Panzern verbessern.
|
PANZERN_PREPARE4 = §74. Innerhalb der zu panzernden Region zu stehen, beim Befehlausführen kann das Panzern verbessern.
|
||||||
PANZERN_NO_PERM = §cDu darfst hier nicht das Panzern System verwenden
|
|
||||||
PANZERN_NO_WORLDEDIT = §cDu hast keine WorldEdit Selection
|
PANZERN_NO_WORLDEDIT = §cDu hast keine WorldEdit Selection
|
||||||
PANZERN_PROGRESS = §e{0} §7Blöcke übrig, §e{1} §7Blöcke pro Sekunde, §e{2} §7Block Delta
|
PANZERN_PROGRESS = §e{0} §7Blöcke übrig, §e{1} §7Blöcke pro Sekunde, §e{2} §7Block Delta
|
||||||
PANZERN_DONE = §aZuende gepanzert
|
PANZERN_DONE = §aZuende gepanzert
|
||||||
@ -880,7 +838,6 @@ LAUFBAU_HELP = §8/§elaufbau §8[§7smallest§8|§7blastresistant§8] §8- §7B
|
|||||||
LAUFBAU_HELP_SETTINGS = §8/§elaufbau settings §8- §7Öffnet die Settings GUI
|
LAUFBAU_HELP_SETTINGS = §8/§elaufbau settings §8- §7Öffnet die Settings GUI
|
||||||
LAUFBAU_PREPARE1 = §71. Trace die Kanonen so oft wie nötig, in allen Modi.
|
LAUFBAU_PREPARE1 = §71. Trace die Kanonen so oft wie nötig, in allen Modi.
|
||||||
LAUFBAU_PREPARE2 = §72. Versuche alle Fails aus dem Trace zu löschen.
|
LAUFBAU_PREPARE2 = §72. Versuche alle Fails aus dem Trace zu löschen.
|
||||||
LAUFBAU_NO_PERM = §cDu darfst hier nicht das Laufbau System verwenden
|
|
||||||
LAUFBAU_NO_WORLDEDIT = §cDu hast keine WorldEdit Selection
|
LAUFBAU_NO_WORLDEDIT = §cDu hast keine WorldEdit Selection
|
||||||
LAUFBAU_STATE_FILTERING_TRACES = Traces filtern
|
LAUFBAU_STATE_FILTERING_TRACES = Traces filtern
|
||||||
LAUFBAU_STATE_PROCESSING_TRACES = Traces verbinden
|
LAUFBAU_STATE_PROCESSING_TRACES = Traces verbinden
|
||||||
@ -988,7 +945,6 @@ LAUFBAU_TILT_PARTIAL = §8-§7 Neigung teilweise
|
|||||||
# UTILS
|
# UTILS
|
||||||
SELECT_HELP = §8/§eselect §8[§7RegionsTyp§8] §8- §7Wähle einen RegionsTyp aus
|
SELECT_HELP = §8/§eselect §8[§7RegionsTyp§8] §8- §7Wähle einen RegionsTyp aus
|
||||||
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_NO_PERMS = §cDu darfst hier nicht den Select Befehl verwenden
|
|
||||||
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_NO_EXTENSION = §cDiese Region hat keine Ausfahrmaße
|
||||||
@ -1040,7 +996,6 @@ PISTON_HELP_3 = §7Die Anzahl ist Gelb, wenn zu viele Blöcke vorhanden sind.
|
|||||||
PISTON_INFO = §7Bewegte Blöcke {0}{1}§8/§712
|
PISTON_INFO = §7Bewegte Blöcke {0}{1}§8/§712
|
||||||
|
|
||||||
# Warp
|
# Warp
|
||||||
WARP_DISALLOWED = §cDu darfst hier nicht das Warp System nutzen
|
|
||||||
WARP_LOC_X = §7X§8: §e{0}
|
WARP_LOC_X = §7X§8: §e{0}
|
||||||
WARP_LOC_Y = §7Y§8: §e{0}
|
WARP_LOC_Y = §7Y§8: §e{0}
|
||||||
WARP_LOC_Z = §7Z§8: §e{0}
|
WARP_LOC_Z = §7Z§8: §e{0}
|
||||||
@ -1066,12 +1021,9 @@ WARP_HELP_LIST=§8/§ewarp list §8- §7Liste alle Warp-Punkt auf
|
|||||||
|
|
||||||
# WORLD
|
# WORLD
|
||||||
STOP_HELP = §8/§estop §8- §7Stoppt den Server
|
STOP_HELP = §8/§estop §8- §7Stoppt den Server
|
||||||
STOP_NO_PERMS = §cDu hast keine Rechte den Server zu stoppen
|
|
||||||
STOP_MESSAGE = §eDer Server wird gestoppt
|
STOP_MESSAGE = §eDer Server wird gestoppt
|
||||||
WORLD_EDIT_NO_PERMS = §cDu darfst hier kein WorldEdit benutzen
|
|
||||||
|
|
||||||
KICKALL_HELP = §8/§ekickall §8- §7Kickt alle Spieler vom Server außer den Owner
|
KICKALL_HELP = §8/§ekickall §8- §7Kickt alle Spieler vom Server außer den Owner
|
||||||
KICKALL_NO_PERM = §cDies ist nicht deine Welt!
|
|
||||||
|
|
||||||
# Techhider
|
# Techhider
|
||||||
TECHHIDER_HELP = §8/§etechhider §8- §7Techhider umschalten
|
TECHHIDER_HELP = §8/§etechhider §8- §7Techhider umschalten
|
||||||
|
@ -22,16 +22,19 @@ package de.steamwar.bausystem;
|
|||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import de.steamwar.bausystem.configplayer.Config;
|
import de.steamwar.bausystem.configplayer.Config;
|
||||||
import de.steamwar.bausystem.features.tpslimit.TPSFreezeUtils;
|
import de.steamwar.bausystem.features.tpslimit.TPSFreezeUtils;
|
||||||
import de.steamwar.bausystem.features.world.RamUsage;
|
|
||||||
import de.steamwar.bausystem.linkage.LinkageUtils;
|
import de.steamwar.bausystem.linkage.LinkageUtils;
|
||||||
import de.steamwar.bausystem.region.loader.PrototypeLoader;
|
import de.steamwar.bausystem.region.loader.PrototypeLoader;
|
||||||
import de.steamwar.bausystem.region.loader.RegionLoader;
|
import de.steamwar.bausystem.region.loader.RegionLoader;
|
||||||
import de.steamwar.bausystem.region.loader.Updater;
|
import de.steamwar.bausystem.region.loader.Updater;
|
||||||
|
import de.steamwar.bausystem.utils.TickListener;
|
||||||
import de.steamwar.bausystem.worlddata.WorldData;
|
import de.steamwar.bausystem.worlddata.WorldData;
|
||||||
|
import de.steamwar.command.AbstractValidator;
|
||||||
|
import de.steamwar.command.SWCommandUtils;
|
||||||
import de.steamwar.message.Message;
|
import de.steamwar.message.Message;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -53,12 +56,8 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
@Getter
|
@Getter
|
||||||
private static BauSystem instance;
|
private static BauSystem instance;
|
||||||
|
|
||||||
private World world;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
world = Bukkit.getWorlds().get(0);
|
|
||||||
|
|
||||||
// LOGGER
|
// LOGGER
|
||||||
fixLogging();
|
fixLogging();
|
||||||
|
|
||||||
@ -79,25 +78,26 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
new Updater(PrototypeLoader.file, PrototypeLoader::load);
|
new Updater(PrototypeLoader.file, PrototypeLoader::load);
|
||||||
new Updater(RegionLoader.file, RegionLoader::load);
|
new Updater(RegionLoader.file, RegionLoader::load);
|
||||||
|
|
||||||
LinkageUtils.link();
|
SWCommandUtils.addValidator(Player.class, validator(Permission.BUILD));
|
||||||
RamUsage.init();
|
SWCommandUtils.addValidator(CommandSender.class, validator(Permission.BUILD));
|
||||||
|
SWCommandUtils.addValidator("supervisor", validator(Permission.SUPERVISOR));
|
||||||
|
SWCommandUtils.addValidator("owner", validator(Permission.OWNER));
|
||||||
|
|
||||||
// This could disable any watchdog stuff. We need to investigate if this is a problem.
|
LinkageUtils.link();
|
||||||
/*
|
TickListener.impl.init();
|
||||||
Thread thread = new Thread(() -> {
|
|
||||||
while (true) {
|
|
||||||
WatchdogThread.tick();
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private <T extends CommandSender> AbstractValidator<T, ?> validator(Permission permission) {
|
||||||
|
return (commandSender, object, messageSender) -> {
|
||||||
|
if (commandSender instanceof Player) {
|
||||||
|
if (permission.hasPermission((Player) commandSender)) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
});
|
messageSender.send("NO_PERMISSION");
|
||||||
thread.setName("WatchdogThread ticker");
|
return false;
|
||||||
thread.setDaemon(true);
|
}
|
||||||
thread.start();
|
return true;
|
||||||
*/
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,43 +20,77 @@
|
|||||||
package de.steamwar.bausystem;
|
package de.steamwar.bausystem;
|
||||||
|
|
||||||
import de.steamwar.bausystem.config.BauServer;
|
import de.steamwar.bausystem.config.BauServer;
|
||||||
import de.steamwar.command.CommandMetaData;
|
import de.steamwar.bausystem.features.world.BauMemberUpdate;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||||
import de.steamwar.sql.BauweltMember;
|
import de.steamwar.sql.BauweltMember;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.util.HashSet;
|
||||||
import java.lang.annotation.Retention;
|
import java.util.Set;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum Permission {
|
public enum Permission {
|
||||||
|
|
||||||
WORLD(BauweltMember::isWorld),
|
OWNER(bauweltMember -> false),
|
||||||
WORLDEDIT(BauweltMember::isWorldEdit),
|
SUPERVISOR(bauweltMember -> {
|
||||||
MEMBER(bauweltMember -> true),
|
return bauweltMember.isSupervisor();
|
||||||
OWNER(bauweltMember -> false);
|
}),
|
||||||
|
BUILD(bauweltMember -> {
|
||||||
|
if (isTempOnlySpectator(bauweltMember)) return false;
|
||||||
|
return bauweltMember.isBuild() || SUPERVISOR.permissionPredicate.test(bauweltMember);
|
||||||
|
}),
|
||||||
|
/**
|
||||||
|
* Only used for {@link BauMemberUpdate}
|
||||||
|
*/
|
||||||
|
REAL_SPECTATOR(bauweltMember -> {
|
||||||
|
return !bauweltMember.isBuild() && !bauweltMember.isSupervisor();
|
||||||
|
}),
|
||||||
|
/**
|
||||||
|
* Primarily used for {@link de.steamwar.bausystem.linkage.specific.GuiItem}
|
||||||
|
*/
|
||||||
|
MEMBER(bauweltMember -> {
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
private static final Set<Integer> TEMP_ONLY_SPECTATOR = new HashSet<>();
|
||||||
|
|
||||||
|
private static boolean isTempOnlySpectator(BauweltMember bauweltMember) {
|
||||||
|
return TEMP_ONLY_SPECTATOR.contains(bauweltMember.getMemberID());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isTempOnlySpectator(Player player) {
|
||||||
|
return TEMP_ONLY_SPECTATOR.contains(SteamwarUser.get(player.getUniqueId()).getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void forceOnlySpectator(Player player) {
|
||||||
|
TEMP_ONLY_SPECTATOR.add(SteamwarUser.get(player.getUniqueId()).getId());
|
||||||
|
BauMemberUpdate.baumemberUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only used by {@link BauMemberUpdate}
|
||||||
|
*/
|
||||||
|
public static void removeForceOnlySpectator(Player player) {
|
||||||
|
TEMP_ONLY_SPECTATOR.remove(SteamwarUser.get(player.getUniqueId()).getId());
|
||||||
|
}
|
||||||
|
|
||||||
private final Predicate<BauweltMember> permissionPredicate;
|
private final Predicate<BauweltMember> permissionPredicate;
|
||||||
|
|
||||||
|
public boolean hasPermission(BauweltMember bauweltMember) {
|
||||||
|
if (bauweltMember == null) return false;
|
||||||
|
return permissionPredicate.test(bauweltMember);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasPermission(Player member) {
|
public boolean hasPermission(Player member) {
|
||||||
if (member.getUniqueId().equals(BauServer.getInstance().getOwner())) {
|
if (SteamwarUser.get(member.getUniqueId()).getId() == BauServer.getInstance().getOwnerID()) {
|
||||||
return true;
|
return this != REAL_SPECTATOR;
|
||||||
}
|
}
|
||||||
|
BauweltMember bauweltMember = BauweltMember.getBauMember(BauServer.getInstance().getOwner(), member.getUniqueId());
|
||||||
BauweltMember bauMember = BauweltMember.getBauMember(BauServer.getInstance().getOwner(), member.getUniqueId());
|
if (bauweltMember == null) return this == REAL_SPECTATOR;
|
||||||
if (bauMember == null) {
|
return permissionPredicate.test(bauweltMember);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return permissionPredicate.test(bauMember);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean hasPermission(Player member, Permission permission) {
|
|
||||||
return permission.hasPermission(member);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -97,7 +97,7 @@ public class Config implements Listener {
|
|||||||
|
|
||||||
public void saveAll() {
|
public void saveAll() {
|
||||||
playerConfigurations.forEach((uuid, yapionObject) -> {
|
playerConfigurations.forEach((uuid, yapionObject) -> {
|
||||||
String string = yapionObject.toYAPION(new StringOutput()).getResult();
|
String string = yapionObject.toYAPION(new StringOutput()).getResult().replaceAll("\\+", "\\");
|
||||||
UserConfig.updatePlayerConfig(uuid, "bausystem", string);
|
UserConfig.updatePlayerConfig(uuid, "bausystem", string);
|
||||||
});
|
});
|
||||||
playerConfigurations.clear();
|
playerConfigurations.clear();
|
||||||
@ -112,7 +112,7 @@ public class Config implements Listener {
|
|||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
if (playerConfigurations.containsKey(uuid)) {
|
if (playerConfigurations.containsKey(uuid)) {
|
||||||
YAPIONObject yapionObject = playerConfigurations.get(uuid);
|
YAPIONObject yapionObject = playerConfigurations.get(uuid);
|
||||||
String string = yapionObject.toYAPION(new StringOutput()).getResult();
|
String string = yapionObject.toYAPION(new StringOutput()).getResult().replaceAll("\\\\+", "\\\\");
|
||||||
UserConfig.updatePlayerConfig(uuid, "bausystem", string);
|
UserConfig.updatePlayerConfig(uuid, "bausystem", string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public class AttributeRemoveCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register({"all"})
|
@Register({"all"})
|
||||||
@Register({"*"})
|
@Register({"*"})
|
||||||
public void genericCommand(Player player) {
|
public void genericCommand(@Validator Player player) {
|
||||||
ItemStack itemStack = player.getInventory().getItemInMainHand();
|
ItemStack itemStack = player.getInventory().getItemInMainHand();
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
itemMeta.setLore(new ArrayList<>());
|
itemMeta.setLore(new ArrayList<>());
|
||||||
@ -53,7 +53,7 @@ public class AttributeRemoveCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "ATTRIBUTE_REMOVE_COMMAND_HELP")
|
@Register(description = "ATTRIBUTE_REMOVE_COMMAND_HELP")
|
||||||
public void genericCommand(Player player, @Mapper("attribute") String attribute) {
|
public void genericCommand(@Validator Player player, @Mapper("attribute") String attribute) {
|
||||||
ItemStack itemStack = player.getInventory().getItemInMainHand();
|
ItemStack itemStack = player.getInventory().getItemInMainHand();
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
if (itemMeta == null) {
|
if (itemMeta == null) {
|
||||||
|
@ -41,7 +41,7 @@ public class AttributesCopyCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void genericCommand(Player player) {
|
public void genericCommand(@Validator Player player) {
|
||||||
Block block = player.getTargetBlockExact(8, FluidCollisionMode.ALWAYS);
|
Block block = player.getTargetBlockExact(8, FluidCollisionMode.ALWAYS);
|
||||||
if (block == null) return;
|
if (block == null) return;
|
||||||
ItemStack mainHand = player.getInventory().getItemInMainHand();
|
ItemStack mainHand = player.getInventory().getItemInMainHand();
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.bausystem.features.attributescopy;
|
package de.steamwar.bausystem.features.attributescopy;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -40,6 +41,7 @@ public class AttributesPlaceListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
|
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
ItemStack itemStack = event.getItemInHand();
|
ItemStack itemStack = event.getItemInHand();
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
if (itemMeta == null) return;
|
if (itemMeta == null) return;
|
||||||
|
@ -32,7 +32,7 @@ public class AutoStartCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "AUTOSTART_COMMAND_HELP")
|
@Register(description = "AUTOSTART_COMMAND_HELP")
|
||||||
public void genericCommand(Player p) {
|
public void genericCommand(@Validator Player p) {
|
||||||
SWUtils.giveItemToPlayer(p, AutostartListener.getWandItem(p));
|
SWUtils.giveItemToPlayer(p, AutostartListener.getWandItem(p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,6 @@ public class AutoStartGuiItem extends BauGuiItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Permission permission() {
|
public Permission permission() {
|
||||||
return Permission.MEMBER;
|
return Permission.BUILD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.bausystem.features.autostart;
|
package de.steamwar.bausystem.features.autostart;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
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;
|
||||||
@ -29,6 +30,7 @@ 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;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
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.FileConfiguration;
|
||||||
@ -66,6 +68,7 @@ public class AutostartListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
|
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
if (!ItemUtils.isItem(event.getItem(), "autostart")) {
|
if (!ItemUtils.isItem(event.getItem(), "autostart")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,6 +78,12 @@ public class AutostartListener implements Listener {
|
|||||||
if (event.getClickedBlock().getBlockData() instanceof Chest) {
|
if (event.getClickedBlock().getBlockData() instanceof Chest) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (event.getClickedBlock().getType() == Material.BEDROCK) {
|
||||||
|
event.getClickedBlock().setType(Material.SLIME_BLOCK);
|
||||||
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
|
event.getClickedBlock().setType(Material.BEDROCK, false);
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
activate(event.getPlayer());
|
activate(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,6 +92,7 @@ public class AutostartListener implements Listener {
|
|||||||
if (!(event.getPlayer() instanceof Player)) {
|
if (!(event.getPlayer() instanceof Player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(!Permission.BUILD.hasPermission((Player) event.getPlayer())) return;
|
||||||
if (!ItemUtils.isItem(event.getPlayer().getInventory().getItemInMainHand(), "autostart")) {
|
if (!ItemUtils.isItem(event.getPlayer().getInventory().getItemInMainHand(), "autostart")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class BackupCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "create", description = "BACKUP_HELP_CREATE")
|
@Register(value = "create", description = "BACKUP_HELP_CREATE")
|
||||||
public void backupCreate(@Validator Player p) {
|
public void backupCreate(@Validator("owner") Player p) {
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
return;
|
return;
|
||||||
@ -79,7 +79,7 @@ public class BackupCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "load", description = "BACKUP_HELP_LOAD")
|
@Register(value = "load", description = "BACKUP_HELP_LOAD")
|
||||||
public void backupLoad(@Validator Player p, @Mapper("backupName") String backupName) {
|
public void backupLoad(@Validator("owner") Player p, @Mapper("backupName") String backupName) {
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
return;
|
return;
|
||||||
@ -130,7 +130,7 @@ public class BackupCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
SWListInv<String> swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("BACKUP_INV_NAME", p), swListEntries, (clickType, s) -> {
|
SWListInv<String> swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("BACKUP_INV_NAME", p), swListEntries, (clickType, s) -> {
|
||||||
p.getOpenInventory().close();
|
p.getOpenInventory().close();
|
||||||
backupLoad(p, s);
|
p.performCommand("backup load " + s);
|
||||||
});
|
});
|
||||||
swListInv.open();
|
swListInv.open();
|
||||||
}
|
}
|
||||||
@ -140,13 +140,6 @@ public class BackupCommand extends SWCommand {
|
|||||||
return SWCommandUtils.createMapper(s -> s, (commandSender, s) -> listBackup((Player) commandSender));
|
return SWCommandUtils.createMapper(s -> s, (commandSender, s) -> listBackup((Player) commandSender));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ClassValidator(value = Player.class, local = true)
|
|
||||||
public TypeValidator<Player> backupValidator() {
|
|
||||||
return (commandSender, player, messageSender) -> {
|
|
||||||
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLDEDIT), "BACKUP_NO_PERMS");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> listBackup(Player p) {
|
private List<String> listBackup(Player p) {
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
|
@ -1,41 +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.features.bau;
|
|
||||||
|
|
||||||
import de.steamwar.command.SWCommand;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import de.steamwar.linkage.LinkedInstance;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class BauCommand extends SWCommand {
|
|
||||||
|
|
||||||
@LinkedInstance
|
|
||||||
public InfoCommand infoCommand;
|
|
||||||
|
|
||||||
public BauCommand() {
|
|
||||||
super("bau", "b", "gs");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = "info", description = "BAU_COMMAND_HELP_INFO")
|
|
||||||
public void infoCommand(Player p) {
|
|
||||||
infoCommand.sendBauInfo(p);
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.features.bau;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
|
import de.steamwar.command.PreviousArguments;
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.command.TypeMapper;
|
||||||
|
import de.steamwar.linkage.Linked;
|
||||||
|
import de.steamwar.techhider.TechHider;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Linked
|
||||||
|
public class ForceSpectatorCommand extends SWCommand {
|
||||||
|
|
||||||
|
public ForceSpectatorCommand() {
|
||||||
|
super("forcespectator");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void forceSpectator(@Validator("supervisor") Player player, @Mapper("builder") Player other) {
|
||||||
|
Permission.forceOnlySpectator(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Mapper("builder")
|
||||||
|
public TypeMapper<Player> spectatorMapper() {
|
||||||
|
return new TypeMapper<>() {
|
||||||
|
@Override
|
||||||
|
public Player map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||||
|
Player player = Bukkit.getPlayer(s);
|
||||||
|
if (player == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (Permission.BUILD.hasPermission(player) && !Permission.SUPERVISOR.hasPermission(player)) {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||||
|
return Bukkit.getOnlinePlayers().stream()
|
||||||
|
.filter(Permission.BUILD::hasPermission)
|
||||||
|
.filter(player -> !Permission.SUPERVISOR.hasPermission(player))
|
||||||
|
.map(Player::getName)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package de.steamwar.bausystem.features.bau;
|
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.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.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
@ -12,7 +13,7 @@ import de.steamwar.sql.BauweltMember;
|
|||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class InfoCommand extends SWCommand {
|
public class InfoCommand extends SWCommand {
|
||||||
@ -24,17 +25,8 @@ public class InfoCommand extends SWCommand {
|
|||||||
super("bauinfo");
|
super("bauinfo");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(help = true)
|
@Register(description = "BAU_INFO_COMMAND_HELP")
|
||||||
public void genericHelp(Player p, String... args) {
|
|
||||||
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_HELP", p);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register
|
|
||||||
public void genericCommand(Player p) {
|
public void genericCommand(Player p) {
|
||||||
sendBauInfo(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendBauInfo(Player p) {
|
|
||||||
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()) {
|
||||||
@ -47,18 +39,28 @@ public class InfoCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Permission.BUILD.hasPermission(p)) {
|
||||||
List<BauweltMember> members = BauweltMember.getMembers(bauServer.getOwnerID());
|
List<BauweltMember> members = BauweltMember.getMembers(bauServer.getOwnerID());
|
||||||
StringBuilder membermessage = new StringBuilder();
|
Map<Permission, List<BauweltMember>> memberByPermission = new HashMap<>();
|
||||||
membermessage.append(BauSystem.MESSAGE.parsePrefixed("BAU_INFO_COMMAND_MEMBER", p, members.size()));
|
members.forEach(member -> {
|
||||||
|
if (Permission.SUPERVISOR.hasPermission(member)) {
|
||||||
for (BauweltMember member : members) {
|
memberByPermission.computeIfAbsent(Permission.SUPERVISOR, __ -> new ArrayList<>()).add(member);
|
||||||
membermessage.append(BauSystem.MESSAGE.parse("BAU_INFO_MEMBER_INFO", p,
|
} else if (Permission.BUILD.hasPermission(member)) {
|
||||||
SteamwarUser.get(member.getMemberID()).getUserName(),
|
memberByPermission.computeIfAbsent(Permission.BUILD, __ -> new ArrayList<>()).add(member);
|
||||||
member.isWorldEdit() ? BauSystem.MESSAGE.parse("BAU_INFO_MEMBER_WE_ALLOW", p) : BauSystem.MESSAGE.parse("BAU_INFO_MEMBER_WE_DISALLOW", p),
|
} else {
|
||||||
member.isWorld() ? BauSystem.MESSAGE.parse("BAU_INFO_MEMBER_WORLD_ALLOW", p) : BauSystem.MESSAGE.parse("BAU_INFO_MEMBER_WORLD_DISALLOW", p)
|
memberByPermission.computeIfAbsent(Permission.MEMBER, __ -> new ArrayList<>()).add(member);
|
||||||
));
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
List<BauweltMember> supervisor = memberByPermission.getOrDefault(Permission.SUPERVISOR, Collections.emptyList());
|
||||||
|
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_MEMBER", p, "§eSupervisor", supervisor.size(), supervisor.isEmpty() ? "§8<none>" : joining(supervisor));
|
||||||
|
|
||||||
|
List<BauweltMember> builder = memberByPermission.getOrDefault(Permission.BUILD, Collections.emptyList());
|
||||||
|
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_MEMBER", p, "§6Builder", builder.size(), builder.isEmpty() ? "§8<none>" : joining(builder));
|
||||||
|
|
||||||
|
List<BauweltMember> spectator = memberByPermission.getOrDefault(Permission.MEMBER, Collections.emptyList());
|
||||||
|
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_MEMBER", p, "§7Spectator", spectator.size(), spectator.isEmpty() ? "§8<none>" : joining(spectator));
|
||||||
}
|
}
|
||||||
p.sendMessage(membermessage.toString());
|
|
||||||
|
|
||||||
StringBuilder tpsMessage = new StringBuilder();
|
StringBuilder tpsMessage = new StringBuilder();
|
||||||
tpsMessage.append(BauSystem.MESSAGE.parsePrefixed("BAU_INFO_COMMAND_TPS", p));
|
tpsMessage.append(BauSystem.MESSAGE.parsePrefixed("BAU_INFO_COMMAND_TPS", p));
|
||||||
@ -69,4 +71,16 @@ public class InfoCommand extends SWCommand {
|
|||||||
tpsMessage.append(" ").append(TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES));
|
tpsMessage.append(" ").append(TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES));
|
||||||
p.sendMessage(tpsMessage.toString());
|
p.sendMessage(tpsMessage.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String joining(List<BauweltMember> bauweltMembers) {
|
||||||
|
StringBuilder st = new StringBuilder();
|
||||||
|
for (int i = 0; i < bauweltMembers.size(); i++) {
|
||||||
|
if (i != 0) {
|
||||||
|
st.append("§8, ");
|
||||||
|
}
|
||||||
|
st.append("§7");
|
||||||
|
st.append(SteamwarUser.get(bauweltMembers.get(i).getMemberID()).getUserName());
|
||||||
|
}
|
||||||
|
return st.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,6 @@ public class CountingwandGuiItem extends BauGuiItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Permission permission() {
|
public Permission permission() {
|
||||||
return Permission.WORLDEDIT;
|
return Permission.MEMBER;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -44,7 +44,6 @@ 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 List<Player> players = new ArrayList<>();
|
|
||||||
|
|
||||||
public DesignEndStone(Region region) {
|
public DesignEndStone(Region region) {
|
||||||
this.minX = region.getMinPointBuild().getX();
|
this.minX = region.getMinPointBuild().getX();
|
||||||
@ -95,12 +94,10 @@ public class DesignEndStone {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void toggle(Player player) {
|
public void toggle(Player player) {
|
||||||
if (players.contains(player)) {
|
if (entityServer.getPlayers().contains(player)) {
|
||||||
players.remove(player);
|
|
||||||
entityServer.removePlayer(player);
|
entityServer.removePlayer(player);
|
||||||
BauSystem.MESSAGE.sendPrefixless("DESIGN_ENDSTONE_DISABLE", player, ChatMessageType.ACTION_BAR);
|
BauSystem.MESSAGE.sendPrefixless("DESIGN_ENDSTONE_DISABLE", player, ChatMessageType.ACTION_BAR);
|
||||||
} else {
|
} else {
|
||||||
players.add(player);
|
|
||||||
entityServer.addPlayer(player);
|
entityServer.addPlayer(player);
|
||||||
calc();
|
calc();
|
||||||
BauSystem.MESSAGE.sendPrefixless("DESIGN_ENDSTONE_ENABLE", player, ChatMessageType.ACTION_BAR);
|
BauSystem.MESSAGE.sendPrefixless("DESIGN_ENDSTONE_ENABLE", player, ChatMessageType.ACTION_BAR);
|
||||||
@ -108,7 +105,7 @@ public class DesignEndStone {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean removePlayer(Player player) {
|
public boolean removePlayer(Player player) {
|
||||||
players.remove(player);
|
entityServer.removePlayer(player);
|
||||||
return players.isEmpty();
|
return entityServer.getPlayers().isEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ 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.region.utils.RegionType;
|
||||||
|
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;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -33,6 +34,7 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
|||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
@ -45,7 +47,7 @@ public class DesignEndStoneCommand extends SWCommand implements Listener {
|
|||||||
private Map<Region, DesignEndStone> designEndStoneMap = new HashMap<>();
|
private Map<Region, DesignEndStone> designEndStoneMap = new HashMap<>();
|
||||||
|
|
||||||
@Register(description = "DESIGN_ENDSTONE_COMMAND_HELP")
|
@Register(description = "DESIGN_ENDSTONE_COMMAND_HELP")
|
||||||
public void genericCommand(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.hasType(RegionType.BUILD)) {
|
||||||
BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player);
|
BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player);
|
||||||
@ -56,14 +58,20 @@ public class DesignEndStoneCommand extends SWCommand implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
Region region = Region.getRegion(event.getPlayer().getLocation());
|
disableDesignEndStone(event.getPlayer());
|
||||||
DesignEndStone designEndStone = designEndStoneMap.get(region);
|
|
||||||
if (designEndStone == null) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (designEndStone.removePlayer(event.getPlayer())) {
|
|
||||||
designEndStoneMap.remove(region);
|
@EventHandler
|
||||||
|
public void onBauMemberUpdate(BauMemberUpdateEvent event) {
|
||||||
|
event.getNewSpectator().forEach(this::disableDesignEndStone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void disableDesignEndStone(Player player) {
|
||||||
|
new HashSet<>(designEndStoneMap.entrySet()).forEach(regionDesignEndStoneEntry -> {
|
||||||
|
if (regionDesignEndStoneEntry.getValue().removePlayer(player)) {
|
||||||
|
designEndStoneMap.remove(regionDesignEndStoneEntry.getKey());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -47,6 +47,6 @@ public class DetonatorBauGuiItem extends BauGuiItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Permission permission() {
|
public Permission permission() {
|
||||||
return Permission.MEMBER;
|
return Permission.BUILD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,12 +58,12 @@ public class DetonatorCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "wand", description = "DETONATOR_HELP_WAND")
|
@Register(value = "wand", description = "DETONATOR_HELP_WAND")
|
||||||
public void giveWand(Player p) {
|
public void giveWand(@Validator Player p) {
|
||||||
SWUtils.giveItemToPlayer(p, getWAND(p));
|
SWUtils.giveItemToPlayer(p, getWAND(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "click", description = "DETONATOR_HELP_CLICK")
|
@Register(value = "click", description = "DETONATOR_HELP_CLICK")
|
||||||
public void clickDetonator(Player p) {
|
public void clickDetonator(@Validator Player p) {
|
||||||
Detonator.activateDetonator(new ItemStorage(p));
|
Detonator.activateDetonator(new ItemStorage(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.bausystem.features.detonator;
|
package de.steamwar.bausystem.features.detonator;
|
||||||
|
|
||||||
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.features.detonator.storage.DetonatorStorage;
|
import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage;
|
||||||
import de.steamwar.bausystem.features.detonator.storage.ItemStorage;
|
import de.steamwar.bausystem.features.detonator.storage.ItemStorage;
|
||||||
@ -65,6 +66,7 @@ public class DetonatorListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
|
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
if (Detonator.isDetonator(p.getInventory().getItemInMainHand())) {
|
if (Detonator.isDetonator(p.getInventory().getItemInMainHand())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -75,6 +77,7 @@ public class DetonatorListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
|
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
if (!Detonator.isDetonator(event.getItem())) {
|
if (!Detonator.isDetonator(event.getItem())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -89,7 +92,7 @@ public class DetonatorListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
if (!Detonator.isDetonator(event.getPlayer().getInventory().getItemInMainHand())) {
|
if (!Permission.BUILD.hasPermission(event.getPlayer()) ||!Detonator.isDetonator(event.getPlayer().getInventory().getItemInMainHand())) {
|
||||||
if (Detonator.hasActiveDetonatorShow(event.getPlayer())) {
|
if (Detonator.hasActiveDetonatorShow(event.getPlayer())) {
|
||||||
Detonator.hideDetonator(event.getPlayer());
|
Detonator.hideDetonator(event.getPlayer());
|
||||||
}
|
}
|
||||||
@ -110,6 +113,7 @@ public class DetonatorListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerItemHeld(PlayerItemHeldEvent event) {
|
public void onPlayerItemHeld(PlayerItemHeldEvent event) {
|
||||||
|
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
if (Detonator.isDetonator(event.getPlayer().getInventory().getItemInMainHand())) {
|
if (Detonator.isDetonator(event.getPlayer().getInventory().getItemInMainHand())) {
|
||||||
HAS_UPDATED.add(event.getPlayer());
|
HAS_UPDATED.add(event.getPlayer());
|
||||||
}
|
}
|
||||||
@ -117,6 +121,7 @@ public class DetonatorListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
|
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
|
||||||
|
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
if (Detonator.isDetonator(event.getMainHandItem()) || Detonator.isDetonator(event.getOffHandItem())) {
|
if (Detonator.isDetonator(event.getMainHandItem()) || Detonator.isDetonator(event.getOffHandItem())) {
|
||||||
HAS_UPDATED.add(event.getPlayer());
|
HAS_UPDATED.add(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ public class BauGUI {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
BauSystem.MESSAGE.send("GUI_NO_PERMISSION", p);
|
BauSystem.MESSAGE.send("NO_PERMISSION", p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -108,26 +108,13 @@ public class BauGUI {
|
|||||||
if (!permission.hasPermission(p)) {
|
if (!permission.hasPermission(p)) {
|
||||||
List<String> lore = meta.getLore();
|
List<String> lore = meta.getLore();
|
||||||
if (lore == null) {
|
if (lore == null) {
|
||||||
lore = Collections.singletonList(BauSystem.MESSAGE.parse(permissionString(permission), p));
|
lore = Collections.singletonList(BauSystem.MESSAGE.parse("NO_PERMISSION", p));
|
||||||
} else {
|
} else {
|
||||||
lore.add(BauSystem.MESSAGE.parse(permissionString(permission), p));
|
lore.add(BauSystem.MESSAGE.parse("NO_PERMISSION", p));
|
||||||
}
|
}
|
||||||
meta.setLore(lore);
|
meta.setLore(lore);
|
||||||
}
|
}
|
||||||
itemStack.setItemMeta(meta);
|
itemStack.setItemMeta(meta);
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String permissionString(Permission permission) {
|
|
||||||
switch (permission) {
|
|
||||||
case OWNER:
|
|
||||||
return "GUI_NO_OWNER";
|
|
||||||
case WORLD:
|
|
||||||
return "GUI_NO_WORLD";
|
|
||||||
case WORLDEDIT:
|
|
||||||
return "GUI_NO_WORLDEDIT";
|
|
||||||
default:
|
|
||||||
return "GUI_NO_MEMBER";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public class HotbarCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "load", description = "HOTBAR_HELP_LOAD")
|
@Register(value = "load", description = "HOTBAR_HELP_LOAD")
|
||||||
public void loadHotbar(Player p) {
|
public void loadHotbar(@Validator Player p) {
|
||||||
DefaultHotbar.setHotbar(p);
|
DefaultHotbar.setHotbar(p);
|
||||||
BauSystem.MESSAGE.send("HOTBAR_LOADED", p);
|
BauSystem.MESSAGE.send("HOTBAR_LOADED", p);
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.hotbar;
|
package de.steamwar.bausystem.features.hotbar;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -30,6 +31,7 @@ public class HotbarListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
if (allNull(event.getPlayer().getInventory().getContents()) && allNull(event.getPlayer().getInventory().getArmorContents())) {
|
if (allNull(event.getPlayer().getInventory().getContents()) && allNull(event.getPlayer().getInventory().getArmorContents())) {
|
||||||
DefaultHotbar.setHotbar(event.getPlayer());
|
DefaultHotbar.setHotbar(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.bausystem.features.inventoryfiller;
|
package de.steamwar.bausystem.features.inventoryfiller;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.configplayer.Config;
|
import de.steamwar.bausystem.configplayer.Config;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
@ -38,6 +39,7 @@ public class InventoryFiller implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||||
|
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("inventoryfill", false)) return;
|
if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("inventoryfill", false)) return;
|
||||||
if (!event.getPlayer().isSneaking()) return;
|
if (!event.getPlayer().isSneaking()) return;
|
||||||
Block block = event.getPlayer().getTargetBlockExact(5);
|
Block block = event.getPlayer().getTargetBlockExact(5);
|
||||||
@ -59,6 +61,7 @@ public class InventoryFiller implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerItemHeld(PlayerItemHeldEvent event) {
|
public void onPlayerItemHeld(PlayerItemHeldEvent event) {
|
||||||
|
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("inventoryfill", false)) return;
|
if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("inventoryfill", false)) return;
|
||||||
if (!event.getPlayer().isSneaking()) return;
|
if (!event.getPlayer().isSneaking()) return;
|
||||||
ItemStack itemStack = event.getPlayer().getInventory().getItemInMainHand();
|
ItemStack itemStack = event.getPlayer().getInventory().getItemInMainHand();
|
||||||
|
@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.killchecker;
|
|||||||
|
|
||||||
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.utils.BauMemberUpdateEvent;
|
||||||
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
@ -54,7 +55,7 @@ public class KillcheckerCommand extends SWCommand implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "enable", description = "KILLCHECKER_HELP_ENABLE")
|
@Register(value = "enable", description = "KILLCHECKER_HELP_ENABLE")
|
||||||
public void genericCommand(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());
|
||||||
KillcheckerVisualizer killcheckerVisualizer = visualizers.computeIfAbsent(region, region1 -> new KillcheckerVisualizer(region1, bossBarService));
|
KillcheckerVisualizer killcheckerVisualizer = visualizers.computeIfAbsent(region, region1 -> new KillcheckerVisualizer(region1, bossBarService));
|
||||||
killcheckerVisualizer.recalc();
|
killcheckerVisualizer.recalc();
|
||||||
@ -74,16 +75,22 @@ public class KillcheckerCommand extends SWCommand implements Listener {
|
|||||||
BauSystem.MESSAGE.send("KILLCHECKER_DISABLE", player);
|
BauSystem.MESSAGE.send("KILLCHECKER_DISABLE", player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBauMemberUpdate(BauMemberUpdateEvent event) {
|
||||||
|
event.getNewSpectator().forEach(this::hide);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
Player player = event.getPlayer();
|
hide(event.getPlayer());
|
||||||
Set<Region> regions = new HashSet<>();
|
}
|
||||||
visualizers.forEach((region, visualizer) -> {
|
|
||||||
if (visualizer.disconnect(player)) {
|
private void hide(Player player) {
|
||||||
regions.add(region);
|
new HashSet<>(visualizers.entrySet()).forEach(regionKillcheckerVisualizerEntry -> {
|
||||||
|
if (regionKillcheckerVisualizerEntry.getValue().hide(player)) {
|
||||||
|
visualizers.remove(regionKillcheckerVisualizerEntry.getKey());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
regions.forEach(visualizers::remove);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void recalc(Block block) {
|
private void recalc(Block block) {
|
||||||
|
@ -57,9 +57,6 @@ public class KillcheckerVisualizer {
|
|||||||
private final int zArea;
|
private final int zArea;
|
||||||
private final int xArea;
|
private final int xArea;
|
||||||
|
|
||||||
private final Set<Player> players = new HashSet<>();
|
|
||||||
private final Set<Player> areaPlayers = new HashSet<>();
|
|
||||||
|
|
||||||
private final Region region;
|
private final Region region;
|
||||||
private final BossBarService bossBarService;
|
private final BossBarService bossBarService;
|
||||||
|
|
||||||
@ -261,7 +258,7 @@ public class KillcheckerVisualizer {
|
|||||||
double zPercent = xCount / (double) zArea;
|
double zPercent = xCount / (double) zArea;
|
||||||
percent = (xPercent + yPercent + zPercent) / 3;
|
percent = (xPercent + yPercent + zPercent) / 3;
|
||||||
kills = zKills + yKills + xKills;
|
kills = zKills + yKills + xKills;
|
||||||
players.forEach(this::updateBossBar);
|
outline.getPlayers().forEach(this::updateBossBar);
|
||||||
|
|
||||||
Set<Point> pointSet = new HashSet<>(killCount.keySet());
|
Set<Point> pointSet = new HashSet<>(killCount.keySet());
|
||||||
Set<Point> outlinePointsCacheLast = new HashSet<>(outlinePointsCache);
|
Set<Point> outlinePointsCacheLast = new HashSet<>(outlinePointsCache);
|
||||||
@ -356,40 +353,21 @@ public class KillcheckerVisualizer {
|
|||||||
return new Cuboid(minX, minY, minZ, maxX, maxY, maxZ);
|
return new Cuboid(minX, minY, minZ, maxX, maxY, maxZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean show(Player player, boolean onlyOutline) {
|
public void show(Player player, boolean onlyOutline) {
|
||||||
outline.addPlayer(player);
|
outline.addPlayer(player);
|
||||||
if (!onlyOutline) {
|
if (!onlyOutline) {
|
||||||
inner.addPlayer(player);
|
inner.addPlayer(player);
|
||||||
areaPlayers.add(player);
|
} else {
|
||||||
} else if (areaPlayers.contains(player)) {
|
|
||||||
inner.removePlayer(player);
|
inner.removePlayer(player);
|
||||||
areaPlayers.remove(player);
|
|
||||||
}
|
}
|
||||||
updateBossBar(player);
|
updateBossBar(player);
|
||||||
return players.add(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hide(Player player) {
|
public boolean hide(Player player) {
|
||||||
outline.removePlayer(player);
|
outline.removePlayer(player);
|
||||||
if (areaPlayers.contains(player)) {
|
|
||||||
inner.removePlayer(player);
|
inner.removePlayer(player);
|
||||||
}
|
|
||||||
players.remove(player);
|
|
||||||
areaPlayers.remove(player);
|
|
||||||
bossBarService.remove(player, region, "killchecker");
|
bossBarService.remove(player, region, "killchecker");
|
||||||
if (players.isEmpty()) {
|
if (outline.getPlayers().isEmpty() && inner.getPlayers().isEmpty()) {
|
||||||
outline.close();
|
|
||||||
inner.close();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean disconnect(Player player) {
|
|
||||||
players.remove(player);
|
|
||||||
areaPlayers.remove(player);
|
|
||||||
bossBarService.remove(player, region, "killchecker");
|
|
||||||
if (players.isEmpty()) {
|
|
||||||
outline.close();
|
outline.close();
|
||||||
inner.close();
|
inner.close();
|
||||||
return true;
|
return true;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.bausystem.features.loader;
|
package de.steamwar.bausystem.features.loader;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.features.loader.elements.LoaderElement;
|
import de.steamwar.bausystem.features.loader.elements.LoaderElement;
|
||||||
import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement;
|
import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement;
|
||||||
import de.steamwar.bausystem.features.loader.elements.impl.LoaderTNT;
|
import de.steamwar.bausystem.features.loader.elements.impl.LoaderTNT;
|
||||||
@ -70,6 +71,7 @@ public class Loader implements Listener {
|
|||||||
|
|
||||||
BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
|
BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
|
||||||
if (stage != Stage.RUNNING) return;
|
if (stage != Stage.RUNNING) return;
|
||||||
|
if(!Permission.BUILD.hasPermission(p)) return;
|
||||||
if (waitTime > 0) {
|
if (waitTime > 0) {
|
||||||
waitTime--;
|
waitTime--;
|
||||||
return;
|
return;
|
||||||
|
@ -21,13 +21,16 @@ package de.steamwar.bausystem.features.loader;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
|
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
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;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class LoaderCommand extends SWCommand {
|
public class LoaderCommand extends SWCommand implements Listener {
|
||||||
|
|
||||||
public LoaderCommand() {
|
public LoaderCommand() {
|
||||||
super("loader");
|
super("loader");
|
||||||
@ -102,10 +105,12 @@ public class LoaderCommand extends SWCommand {
|
|||||||
loader.setTicksBetweenBlocks(delay);
|
loader.setTicksBetweenBlocks(delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ClassValidator(value = Player.class, local = true)
|
@EventHandler
|
||||||
public TypeValidator<Player> loaderValidator() {
|
public void onBauMemberUpdate(BauMemberUpdateEvent event) {
|
||||||
return (commandSender, player, messageSender) -> {
|
event.getNewSpectator().forEach(player -> {
|
||||||
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "LOADER_PERMS");
|
Loader loader = Loader.getLoader(player);
|
||||||
};
|
if (loader == null) return;
|
||||||
|
loader.stop();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,8 @@ import org.bukkit.inventory.EquipmentSlot;
|
|||||||
import java.util.HashMap;
|
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.Consumer;
|
||||||
|
|
||||||
public class LoaderRecorder implements Listener {
|
public class LoaderRecorder implements Listener {
|
||||||
|
|
||||||
@ -124,53 +126,10 @@ public class LoaderRecorder implements Listener {
|
|||||||
|
|
||||||
addWaitTime(false);
|
addWaitTime(false);
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
Material type = block.getType();
|
getLoaderInteractionElement(block, (loaderInteractionElement, s) -> {
|
||||||
switch (type) {
|
loaderElementList.add(loaderInteractionElement);
|
||||||
case COMPARATOR:
|
message(s);
|
||||||
loaderElementList.add(new LoaderComparator(block.getLocation()));
|
});
|
||||||
message("LOADER_BUTTON_COMPARATOR");
|
|
||||||
break;
|
|
||||||
case REPEATER:
|
|
||||||
loaderElementList.add(new LoaderRepeater(block.getLocation()));
|
|
||||||
message("LOADER_BUTTON_REPEATER");
|
|
||||||
break;
|
|
||||||
case NOTE_BLOCK:
|
|
||||||
loaderElementList.add(new LoaderNoteBlock(block.getLocation()));
|
|
||||||
message("LOADER_BUTTON_NOTEBLOCK");
|
|
||||||
break;
|
|
||||||
case LEVER:
|
|
||||||
loaderElementList.add(new LoaderLever(block.getLocation()));
|
|
||||||
message("LOADER_BUTTON_SWITCH");
|
|
||||||
break;
|
|
||||||
case DAYLIGHT_DETECTOR:
|
|
||||||
loaderElementList.add(new LoaderDaylightDetector(block.getLocation()));
|
|
||||||
message("LOADER_BUTTON_DAYLIGHT_DETECTOR");
|
|
||||||
break;
|
|
||||||
case LECTERN:
|
|
||||||
loaderElementList.add(new LoaderLectern(block.getLocation()));
|
|
||||||
message("LOADER_BUTTON_LECTERN");
|
|
||||||
break;
|
|
||||||
case IRON_TRAPDOOR:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (type.name().endsWith("_TRAPDOOR")) {
|
|
||||||
loaderElementList.add(new LoaderOpenable(block.getLocation(), "LOADER_BUTTON_TRAPDOOR", type));
|
|
||||||
message("LOADER_BUTTON_TRAPDOOR");
|
|
||||||
} else if (type.name().endsWith("_DOOR")) {
|
|
||||||
loaderElementList.add(new LoaderOpenable(block.getLocation(), "LOADER_BUTTON_DOOR", type));
|
|
||||||
message("LOADER_BUTTON_DOOR");
|
|
||||||
} else if (type.name().endsWith("FENCE_GATE")) {
|
|
||||||
loaderElementList.add(new LoaderOpenable(block.getLocation(), "LOADER_BUTTON_FENCEGATE", type));
|
|
||||||
message("LOADER_BUTTON_FENCEGATE");
|
|
||||||
} else if (type.name().endsWith("STONE_BUTTON")) {
|
|
||||||
loaderElementList.add(new LoaderTicks(block.getLocation(), "LOADER_BUTTON_STONE_BUTTON", type, 20));
|
|
||||||
message("LOADER_BUTTON_STONE_BUTTON");
|
|
||||||
} else if (type.name().endsWith("BUTTON")) {
|
|
||||||
loaderElementList.add(new LoaderTicks(block.getLocation(), "LOADER_BUTTON_WOOD_BUTTON", type, 30));
|
|
||||||
message("LOADER_BUTTON_WOOD_BUTTON");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Location, Long> blockSet = new HashMap<>();
|
private Map<Location, Long> blockSet = new HashMap<>();
|
||||||
@ -226,6 +185,46 @@ public class LoaderRecorder implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void getLoaderInteractionElement(Block block, BiConsumer<LoaderInteractionElement<?>, String> consumer) {
|
||||||
|
Material type = block.getType();
|
||||||
|
switch (type) {
|
||||||
|
case COMPARATOR:
|
||||||
|
consumer.accept(new LoaderComparator(block.getLocation()), "LOADER_BUTTON_COMPARATOR");
|
||||||
|
break;
|
||||||
|
case REPEATER:
|
||||||
|
consumer.accept(new LoaderRepeater(block.getLocation()), "LOADER_BUTTON_REPEATER");
|
||||||
|
break;
|
||||||
|
case NOTE_BLOCK:
|
||||||
|
consumer.accept(new LoaderNoteBlock(block.getLocation()), "LOADER_BUTTON_NOTEBLOCK");
|
||||||
|
break;
|
||||||
|
case LEVER:
|
||||||
|
consumer.accept(new LoaderLever(block.getLocation()), "LOADER_BUTTON_SWITCH");
|
||||||
|
break;
|
||||||
|
case DAYLIGHT_DETECTOR:
|
||||||
|
consumer.accept(new LoaderDaylightDetector(block.getLocation()), "LOADER_BUTTON_DAYLIGHT_DETECTOR");
|
||||||
|
break;
|
||||||
|
case LECTERN:
|
||||||
|
consumer.accept(new LoaderLectern(block.getLocation()), "LOADER_BUTTON_LECTERN");
|
||||||
|
break;
|
||||||
|
case IRON_TRAPDOOR:
|
||||||
|
case IRON_DOOR:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (type.name().endsWith("_TRAPDOOR")) {
|
||||||
|
consumer.accept(new LoaderOpenable(block.getLocation(), "LOADER_BUTTON_TRAPDOOR", type), "LOADER_BUTTON_TRAPDOOR");
|
||||||
|
} else if (type.name().endsWith("_DOOR")) {
|
||||||
|
consumer.accept(new LoaderOpenable(block.getLocation(), "LOADER_BUTTON_DOOR", type), "LOADER_BUTTON_DOOR");
|
||||||
|
} else if (type.name().endsWith("FENCE_GATE")) {
|
||||||
|
consumer.accept(new LoaderOpenable(block.getLocation(), "LOADER_BUTTON_FENCEGATE", type), "LOADER_BUTTON_FENCEGATE");
|
||||||
|
} else if (type.name().endsWith("STONE_BUTTON")) {
|
||||||
|
consumer.accept(new LoaderTicks(block.getLocation(), "LOADER_BUTTON_STONE_BUTTON", type, 20), "LOADER_BUTTON_STONE_BUTTON");
|
||||||
|
} else if (type.name().endsWith("BUTTON")) {
|
||||||
|
consumer.accept(new LoaderTicks(block.getLocation(), "LOADER_BUTTON_WOOD_BUTTON", type, 30), "LOADER_BUTTON_WOOD_BUTTON");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void message(String type) {
|
private void message(String type) {
|
||||||
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("LOADER_MESSAGE_INTERACT", player, BauSystem.MESSAGE.parse(type, player), loaderElementList.size()));
|
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("LOADER_MESSAGE_INTERACT", player, BauSystem.MESSAGE.parse(type, player), loaderElementList.size()));
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.bausystem.features.loader;
|
package de.steamwar.bausystem.features.loader;
|
||||||
|
|
||||||
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.utils.ScoreboardElement;
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
@ -40,6 +41,7 @@ public class LoaderScoreboardElement implements ScoreboardElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
|
if(!Permission.BUILD.hasPermission(p)) return null;
|
||||||
Loader loader = Loader.getLoader(p);
|
Loader loader = Loader.getLoader(p);
|
||||||
if (loader == null) return null;
|
if (loader == null) return null;
|
||||||
if (loader.getStage() == Loader.Stage.RUNNING) {
|
if (loader.getStage() == Loader.Stage.RUNNING) {
|
||||||
|
@ -32,12 +32,12 @@ public class LoadtimerCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "start", description = "LOADTIMER_HELP_START_1")
|
@Register(value = "start", description = "LOADTIMER_HELP_START_1")
|
||||||
public void start(Player p) {
|
public void start(@Validator Player p) {
|
||||||
start(p, TimerMode.HALF);
|
start(p, TimerMode.HALF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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(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.isGlobal()) return;
|
||||||
if (!Loadtimer.hasTimer(r))
|
if (!Loadtimer.hasTimer(r))
|
||||||
@ -45,7 +45,7 @@ public class LoadtimerCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "stop", description = "LOADTIMER_HELP_STOP")
|
@Register(value = "stop", description = "LOADTIMER_HELP_STOP")
|
||||||
public void stop(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.isGlobal()) return;
|
||||||
if (Loadtimer.hasTimer(r))
|
if (Loadtimer.hasTimer(r))
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
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;
|
||||||
@ -46,13 +47,13 @@ public class ObserverTracerCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "delete", description = "OBSERVER_HELP_DELETE")
|
@Register(value = "delete", description = "OBSERVER_HELP_DELETE")
|
||||||
public void delete(Player p) {
|
public void delete(@Validator Player p) {
|
||||||
ObserverTracerListener.observerTracerMap.remove(p);
|
ObserverTracerListener.observerTracerMap.remove(p);
|
||||||
BauSystem.MESSAGE.send("OBSERVER_DELETE", p);
|
BauSystem.MESSAGE.send("OBSERVER_DELETE", p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "retrace", description = "OBSERVER_HELP_RETRACE")
|
@Register(value = "retrace", description = "OBSERVER_HELP_RETRACE")
|
||||||
public void retrace(Player p) {
|
public void retrace(@Validator Player p) {
|
||||||
if (ObserverTracerListener.observerTracerMap.containsKey(p)) {
|
if (ObserverTracerListener.observerTracerMap.containsKey(p)) {
|
||||||
BauSystem.MESSAGE.send("OBSERVER_RETRACE_NO_TRACE", p);
|
BauSystem.MESSAGE.send("OBSERVER_RETRACE_NO_TRACE", p);
|
||||||
return;
|
return;
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
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.bausystem.utils.BauMemberUpdateEvent;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -55,6 +57,7 @@ public class ObserverTracerListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
|
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
if (!enabled.contains(event.getPlayer())) {
|
if (!enabled.contains(event.getPlayer())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -87,6 +90,11 @@ public class ObserverTracerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBauMemberUpdate(BauMemberUpdateEvent event) {
|
||||||
|
event.getNewSpectator().forEach(observerTracerMap::remove);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
enabled.add(event.getPlayer());
|
enabled.add(event.getPlayer());
|
||||||
|
@ -85,7 +85,7 @@ public class ColorCommand extends SWCommand {
|
|||||||
@ClassValidator(value = Player.class, local = true)
|
@ClassValidator(value = Player.class, local = true)
|
||||||
public TypeValidator<Player> validator() {
|
public TypeValidator<Player> validator() {
|
||||||
return (commandSender, player, messageSender) -> {
|
return (commandSender, player, messageSender) -> {
|
||||||
return !messageSender.send(!bauServer.getOwner().equals(player.getUniqueId()), "REGION_COLOR_NO_PERMS");
|
return !messageSender.send(!bauServer.getOwner().equals(player.getUniqueId()), "NO_PERMISSION");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,10 +46,6 @@ public class FireCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getNoPermMessage() {
|
|
||||||
return "REGION_FIRE_NO_PERMS";
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getEnableMessage() {
|
private String getEnableMessage() {
|
||||||
return "REGION_FIRE_ENABLED";
|
return "REGION_FIRE_ENABLED";
|
||||||
}
|
}
|
||||||
@ -69,11 +65,4 @@ public class FireCommand extends SWCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ClassValidator(value = Player.class, local = true)
|
|
||||||
public TypeValidator<Player> validator() {
|
|
||||||
return (commandSender, player, messageSender) -> {
|
|
||||||
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), getNoPermMessage());
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -46,10 +46,6 @@ public class FreezeCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getNoPermMessage() {
|
|
||||||
return "REGION_FREEZE_NO_PERMS";
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getEnableMessage(){
|
private String getEnableMessage(){
|
||||||
return "REGION_FREEZE_ENABLED";
|
return "REGION_FREEZE_ENABLED";
|
||||||
}
|
}
|
||||||
@ -69,11 +65,4 @@ public class FreezeCommand extends SWCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ClassValidator(value = Player.class, local = true)
|
|
||||||
public TypeValidator<Player> validator() {
|
|
||||||
return (commandSender, player, messageSender) -> {
|
|
||||||
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), getNoPermMessage());
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -49,10 +49,6 @@ public class ItemsCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getNoPermMessage() {
|
|
||||||
return "REGION_ITEMS_NO_PERMS";
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getEnableMessage(){
|
private String getEnableMessage(){
|
||||||
return "REGION_ITEMS_ENABLED";
|
return "REGION_ITEMS_ENABLED";
|
||||||
}
|
}
|
||||||
@ -72,11 +68,4 @@ public class ItemsCommand extends SWCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ClassValidator(value = Player.class, local = true)
|
|
||||||
public TypeValidator<Player> validator() {
|
|
||||||
return (commandSender, player, messageSender) -> {
|
|
||||||
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), getNoPermMessage());
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -54,13 +54,6 @@ public class ProtectCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ClassValidator(value = Player.class, local = true)
|
|
||||||
public TypeValidator<Player> validator() {
|
|
||||||
return (commandSender, player, messageSender) -> {
|
|
||||||
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLDEDIT), "REGION_PROTECT_NO_PERMS");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
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.getFloorLevel() == 0) {
|
||||||
|
@ -71,7 +71,7 @@ public class RegionCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "undo", description = "REGION_REGION_HELP_UNDO")
|
@Register(value = "undo", description = "REGION_REGION_HELP_UNDO")
|
||||||
public void undoCommand(@Validator("WORLD_EDIT") Player p) {
|
public void undoCommand(@Validator Player p) {
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
if (checkGlobalRegion(region, p)) return;
|
if (checkGlobalRegion(region, p)) return;
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ public class RegionCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "redo", description = "REGION_REGION_HELP_REDO")
|
@Register(value = "redo", description = "REGION_REGION_HELP_REDO")
|
||||||
public void redoCommand(@Validator("WORLD_EDIT") Player p) {
|
public void redoCommand(@Validator Player p) {
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
return;
|
return;
|
||||||
@ -97,7 +97,7 @@ public class RegionCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "restore", description = "REGION_REGION_HELP_RESTORE")
|
@Register(value = "restore", description = "REGION_REGION_HELP_RESTORE")
|
||||||
public void genericRestoreCommand(@Validator("WORLD_EDIT") Player p) {
|
public void genericRestoreCommand(@Validator Player p) {
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
if(checkGlobalRegion(region, p)) return;
|
if(checkGlobalRegion(region, p)) return;
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ public class RegionCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "restore", description = "REGION_REGION_HELP_RESTORE_SCHEMATIC")
|
@Register(value = "restore", description = "REGION_REGION_HELP_RESTORE_SCHEMATIC")
|
||||||
public void schematicRestoreCommand(@Validator("WORLD_EDIT") Player p, SchematicNode node) {
|
public void schematicRestoreCommand(@Validator Player p, SchematicNode node) {
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
if (checkGlobalRegion(region, p)) return;
|
if (checkGlobalRegion(region, p)) return;
|
||||||
|
|
||||||
@ -164,36 +164,6 @@ public class RegionCommand extends SWCommand {
|
|||||||
BauSystem.MESSAGE.send("REGION_REGION_TP_TEST_BLOCK", p);
|
BauSystem.MESSAGE.send("REGION_REGION_TP_TEST_BLOCK", p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "changetype", description = "REGION_REGION_HELP_CHANGETYPE_INFO")
|
|
||||||
@Register("type")
|
|
||||||
public void changeTypeCommand(Player p) {
|
|
||||||
Region region = Region.getRegion(p.getLocation());
|
|
||||||
if (checkGlobalRegion(region, p)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGETYPE_INFO", p, region.getPrototype().getDisplayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = "changetype", description = "REGION_REGION_HELP_CHANGETYPE")
|
|
||||||
@Register("type")
|
|
||||||
public void changeTypeCommand(@Validator("WORLD") Player p, @Mapper("regionTypeMapper") String s) {
|
|
||||||
Region region = Region.getRegion(p.getLocation());
|
|
||||||
if (checkGlobalRegion(region, p)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Prototype prototype = Prototype.getByDisplayName(s);
|
|
||||||
if (prototype == null) {
|
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGETYPE_UNKNOWN", p);
|
|
||||||
} else {
|
|
||||||
if (region.setPrototype(prototype)) {
|
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGETYPE_CHANGE", p, s);
|
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGETYPE_CHANGE_UPDATE", p, BauSystem.MESSAGE.parse("REGION_REGION_CHANGETYPE_CHANGE_UPDATE_HOVER", p), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/reset"));
|
|
||||||
} else {
|
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGETYPE_INVALID", p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = "changeskin", description = "REGION_REGION_HELP_CHANGESKIN_INFO")
|
@Register(value = "changeskin", description = "REGION_REGION_HELP_CHANGESKIN_INFO")
|
||||||
@Register("skin")
|
@Register("skin")
|
||||||
public void changeSkinCommand(Player p) {
|
public void changeSkinCommand(Player p) {
|
||||||
@ -210,7 +180,7 @@ public class RegionCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register(value = "changeskin", description = "REGION_REGION_HELP_CHANGESKIN")
|
@Register(value = "changeskin", description = "REGION_REGION_HELP_CHANGESKIN")
|
||||||
@Register("skin")
|
@Register("skin")
|
||||||
public void changeSkinCommand(@Validator("WORLD") Player p, @Mapper("skinTypeMapper") String s) {
|
public void changeSkinCommand(@Validator Player p, @Mapper("skinTypeMapper") String s) {
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
return;
|
return;
|
||||||
@ -227,26 +197,6 @@ public class RegionCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mapper(value = "regionTypeMapper", local = true)
|
|
||||||
private TypeMapper<String> regionTypeMapper() {
|
|
||||||
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.getPrototypes().stream().map(Prototype::getByName).map(Prototype::getDisplayName).map(c -> c.replace(' ', '_')).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String map(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
|
||||||
return s.replace('_', ' ');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Mapper(value = "skinTypeMapper", local = true)
|
@Mapper(value = "skinTypeMapper", local = true)
|
||||||
private TypeMapper<String> skinTypeMapper() {
|
private TypeMapper<String> skinTypeMapper() {
|
||||||
return new TypeMapper<String>() {
|
return new TypeMapper<String>() {
|
||||||
@ -266,18 +216,4 @@ public class RegionCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Validator(value = "WORLD", local = true)
|
|
||||||
public TypeValidator<Player> worldValidator() {
|
|
||||||
return (commandSender, player, messageSender) -> {
|
|
||||||
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "REGION_REGION_NO_PERMS");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Validator(value = "WORLD_EDIT", local = true)
|
|
||||||
public TypeValidator<Player> worldEditValidator() {
|
|
||||||
return (commandSender, player, messageSender) -> {
|
|
||||||
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLDEDIT), "REGION_REGION_NO_PERMS");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -97,13 +97,6 @@ public class ResetCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ClassValidator(value = Player.class, local = true)
|
|
||||||
public TypeValidator<Player> validator() {
|
|
||||||
return (commandSender, player, messageSender) -> {
|
|
||||||
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "REGION_RESET_NO_PERMS");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
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 == GlobalRegion.getInstance()) {
|
||||||
|
@ -157,11 +157,4 @@ public class TNTCommand extends SWCommand {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ClassValidator(value = Player.class, local = true)
|
|
||||||
public TypeValidator<Player> validator() {
|
|
||||||
return (commandSender, player, messageSender) -> {
|
|
||||||
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "REGION_TNT_NO_PERMS");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -157,11 +157,6 @@ public class TestblockCommand extends SWCommand {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ClassValidator(value = Player.class, local = true)
|
|
||||||
public TypeValidator<Player> validator() {
|
|
||||||
return (commandSender, player, messageSender) -> !messageSender.send(!Permission.hasPermission(player, Permission.WORLDEDIT), "REGION_TB_NO_PERMS");
|
|
||||||
}
|
|
||||||
|
|
||||||
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.hasType(RegionType.TESTBLOCK)) {
|
||||||
|
@ -57,6 +57,6 @@ public class FireBauGuiItem extends BauGuiItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Permission permission() {
|
public Permission permission() {
|
||||||
return Permission.WORLD;
|
return Permission.BUILD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,6 @@ public class FreezeBauGuiItem extends BauGuiItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Permission permission() {
|
public Permission permission() {
|
||||||
return Permission.WORLD;
|
return Permission.BUILD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,6 @@ public class ProtectBauGuiItem extends BauGuiItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Permission permission() {
|
public Permission permission() {
|
||||||
return Permission.WORLDEDIT;
|
return Permission.BUILD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,6 @@ public class ResetBauGuiItem extends BauGuiItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Permission permission() {
|
public Permission permission() {
|
||||||
return Permission.WORLDEDIT;
|
return Permission.BUILD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,6 @@ public class TestblockBauGuiItem extends BauGuiItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Permission permission() {
|
public Permission permission() {
|
||||||
return Permission.WORLDEDIT;
|
return Permission.BUILD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,6 +116,6 @@ public class TntBauGuiItem extends BauGuiItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Permission permission() {
|
public Permission permission() {
|
||||||
return Permission.WORLD;
|
return Permission.BUILD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class ScriptCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void genericCommand(Player player) {
|
public void genericCommand(@Validator Player player) {
|
||||||
ScriptGUI.open(player);
|
ScriptGUI.open(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.script;
|
package de.steamwar.bausystem.features.script;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
|
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||||
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -42,6 +44,8 @@ public class ScriptListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onLeftClick(PlayerInteractEvent event) {
|
public void onLeftClick(PlayerInteractEvent event) {
|
||||||
|
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
|
|
||||||
ItemStack item = event.getItem();
|
ItemStack item = event.getItem();
|
||||||
if (item == null || FlatteningWrapper.impl.isNoBook(item) || item.getItemMeta() == null) {
|
if (item == null || FlatteningWrapper.impl.isNoBook(item) || item.getItemMeta() == null) {
|
||||||
return;
|
return;
|
||||||
@ -68,6 +72,13 @@ public class ScriptListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
ScriptRunner.updateGlobalScript(event.getPlayer());
|
ScriptRunner.updateGlobalScript(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBauMemberUpdate(BauMemberUpdateEvent event) {
|
||||||
|
event.getNewSpectator().forEach(ScriptRunner::remove);
|
||||||
|
event.getNewBuilder().forEach(ScriptRunner::updateGlobalScript);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.script.event;
|
package de.steamwar.bausystem.features.script.event;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.features.script.ScriptRunner;
|
import de.steamwar.bausystem.features.script.ScriptRunner;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -41,6 +42,7 @@ public class CommandListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||||
|
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
String[] split = event.getMessage().split(" ");
|
String[] split = event.getMessage().split(" ");
|
||||||
if (calledCommands.getOrDefault(event.getPlayer(), new HashSet<>()).contains(split[0])) {
|
if (calledCommands.getOrDefault(event.getPlayer(), new HashSet<>()).contains(split[0])) {
|
||||||
return;
|
return;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.bausystem.features.script.event;
|
package de.steamwar.bausystem.features.script.event;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.features.script.ScriptRunner;
|
import de.steamwar.bausystem.features.script.ScriptRunner;
|
||||||
import de.steamwar.bausystem.features.script.lua.SteamWarGlobalLuaPlugin;
|
import de.steamwar.bausystem.features.script.lua.SteamWarGlobalLuaPlugin;
|
||||||
import de.steamwar.bausystem.features.script.lua.libs.StorageLib;
|
import de.steamwar.bausystem.features.script.lua.libs.StorageLib;
|
||||||
@ -64,17 +65,20 @@ public class EventListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.SelfJoin, LuaValue.NIL, event);
|
ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.SelfJoin, LuaValue.NIL, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
StorageLib.removePlayer(event.getPlayer());
|
StorageLib.removePlayer(event.getPlayer());
|
||||||
|
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.SelfLeave, LuaValue.NIL, event);
|
ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.SelfLeave, LuaValue.NIL, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
|
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
|
||||||
|
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
if (LAST_FS.containsKey(event.getPlayer())) {
|
if (LAST_FS.containsKey(event.getPlayer())) {
|
||||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.DoubleSwap, LuaValue.NIL, event);
|
ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.DoubleSwap, LuaValue.NIL, event);
|
||||||
@ -86,6 +90,7 @@ public class EventListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
|
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
LuaTable table = new LuaTable();
|
LuaTable table = new LuaTable();
|
||||||
table.set("x", event.getBlock().getX());
|
table.set("x", event.getBlock().getX());
|
||||||
table.set("y", event.getBlock().getY());
|
table.set("y", event.getBlock().getY());
|
||||||
@ -96,6 +101,7 @@ public class EventListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
|
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
LuaTable table = new LuaTable();
|
LuaTable table = new LuaTable();
|
||||||
table.set("x", event.getBlock().getX());
|
table.set("x", event.getBlock().getX());
|
||||||
table.set("y", event.getBlock().getY());
|
table.set("y", event.getBlock().getY());
|
||||||
@ -108,6 +114,7 @@ public class EventListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
|
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
if (ignore.remove(event.getPlayer())) {
|
if (ignore.remove(event.getPlayer())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -125,6 +132,7 @@ public class EventListener implements Listener {
|
|||||||
table.set("blockY", event.getClickedBlock().getY());
|
table.set("blockY", event.getClickedBlock().getY());
|
||||||
table.set("blockZ", event.getClickedBlock().getZ());
|
table.set("blockZ", event.getClickedBlock().getZ());
|
||||||
table.set("blockFace", event.getBlockFace().name());
|
table.set("blockFace", event.getBlockFace().name());
|
||||||
|
table.set("blockType", event.getClickedBlock().getType().name());
|
||||||
} else {
|
} else {
|
||||||
table.set("hasBlock", LuaValue.valueOf(false));
|
table.set("hasBlock", LuaValue.valueOf(false));
|
||||||
}
|
}
|
||||||
@ -144,6 +152,7 @@ public class EventListener implements Listener {
|
|||||||
Region tntRegion = Region.getRegion(event.getLocation());
|
Region tntRegion = Region.getRegion(event.getLocation());
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
if(!Permission.BUILD.hasPermission(player)) continue;
|
||||||
if (tntRegion.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) {
|
if (tntRegion.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) {
|
||||||
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTSpawn, LuaValue.NIL, event);
|
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTSpawn, LuaValue.NIL, event);
|
||||||
}
|
}
|
||||||
@ -165,6 +174,7 @@ public class EventListener implements Listener {
|
|||||||
boolean inBuild = event.blockList().stream().anyMatch(block -> tntRegion.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION));
|
boolean inBuild = event.blockList().stream().anyMatch(block -> tntRegion.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION));
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
if(!Permission.BUILD.hasPermission(player)) continue;
|
||||||
if (tntRegion.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) {
|
if (tntRegion.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) {
|
||||||
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplode, table, event);
|
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplode, table, event);
|
||||||
if (inBuild) {
|
if (inBuild) {
|
||||||
@ -176,6 +186,7 @@ public class EventListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||||
|
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
ignore.add(event.getPlayer());
|
ignore.add(event.getPlayer());
|
||||||
LuaTable table = new LuaTable();
|
LuaTable table = new LuaTable();
|
||||||
table.set("type", event.getItemDrop().getItemStack().getType().name());
|
table.set("type", event.getItemDrop().getItemStack().getType().name());
|
||||||
@ -185,6 +196,7 @@ public class EventListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onEntityDeath(EntityDeathEvent event) {
|
public void onEntityDeath(EntityDeathEvent event) {
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
if(!Permission.BUILD.hasPermission(player)) continue;
|
||||||
LuaTable table = new LuaTable();
|
LuaTable table = new LuaTable();
|
||||||
table.set("type", event.getEntityType().name());
|
table.set("type", event.getEntityType().name());
|
||||||
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.EntityDeath, table, event);
|
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.EntityDeath, table, event);
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.bausystem.features.script.event;
|
package de.steamwar.bausystem.features.script.event;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.features.script.ScriptRunner;
|
import de.steamwar.bausystem.features.script.ScriptRunner;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.api.Plain;
|
import de.steamwar.linkage.api.Plain;
|
||||||
@ -36,6 +37,7 @@ public class HotkeyListener implements PluginMessageListener, Plain {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
||||||
|
if(!Permission.BUILD.hasPermission(player)) return;
|
||||||
if (!channel.equals("sw:hotkeys")) return;
|
if (!channel.equals("sw:hotkeys")) return;
|
||||||
if (message.length < 5) return;
|
if (message.length < 5) return;
|
||||||
int action = message[4] & 0xFF;
|
int action = message[4] & 0xFF;
|
||||||
|
@ -22,15 +22,21 @@ 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.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -39,11 +45,10 @@ import org.luaj.vm2.LuaFunction;
|
|||||||
import org.luaj.vm2.LuaTable;
|
import org.luaj.vm2.LuaTable;
|
||||||
import org.luaj.vm2.LuaValue;
|
import org.luaj.vm2.LuaValue;
|
||||||
import org.luaj.vm2.Varargs;
|
import org.luaj.vm2.Varargs;
|
||||||
import org.luaj.vm2.lib.OneArgFunction;
|
import org.luaj.vm2.lib.*;
|
||||||
import org.luaj.vm2.lib.ThreeArgFunction;
|
|
||||||
import org.luaj.vm2.lib.TwoArgFunction;
|
|
||||||
import org.luaj.vm2.lib.VarArgFunction;
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
@ -102,14 +107,7 @@ public class SteamWarLuaPlugin extends TwoArgFunction {
|
|||||||
double x = arg1.checkdouble();
|
double x = arg1.checkdouble();
|
||||||
double y = arg2.checkdouble();
|
double y = arg2.checkdouble();
|
||||||
double z = arg3.checkdouble();
|
double z = arg3.checkdouble();
|
||||||
|
return pos(x, y, z);
|
||||||
Location loc = new Location(player.getWorld(), x, y, z);
|
|
||||||
|
|
||||||
return tableOf(new LuaValue[] {
|
|
||||||
valueOf("x"), valueOf(loc.getBlockX()),
|
|
||||||
valueOf("y"), valueOf(loc.getBlockY()),
|
|
||||||
valueOf("z"), valueOf(loc.getBlockZ())
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
env.set("exec", new VarArgFunction() {
|
env.set("exec", new VarArgFunction() {
|
||||||
@ -122,6 +120,7 @@ public class SteamWarLuaPlugin extends TwoArgFunction {
|
|||||||
return LuaValue.NIL;
|
return LuaValue.NIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
command = preprocessEvent.getMessage().substring(1);
|
||||||
Bukkit.getLogger().log(Level.INFO, player.getName() + " dispatched command: " + command);
|
Bukkit.getLogger().log(Level.INFO, player.getName() + " dispatched command: " + command);
|
||||||
String[] commandSplit = command.split(" ");
|
String[] commandSplit = command.split(" ");
|
||||||
if (!commandSplit[0].equals("select") && hasFAWE && WorldEditListener.isWorldEditCommand("/" + commandSplit[0])) {
|
if (!commandSplit[0].equals("select") && hasFAWE && WorldEditListener.isWorldEditCommand("/" + commandSplit[0])) {
|
||||||
@ -166,11 +165,86 @@ public class SteamWarLuaPlugin extends TwoArgFunction {
|
|||||||
env.set("rawget", NIL);
|
env.set("rawget", NIL);
|
||||||
env.set("rawlen", NIL);
|
env.set("rawlen", NIL);
|
||||||
env.set("rawset", NIL);
|
env.set("rawset", NIL);
|
||||||
env.set("setmetatable", NIL);
|
|
||||||
env.set("xpcall", NIL);
|
env.set("xpcall", NIL);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static LuaTable pos(double x, double y, double z) {
|
||||||
|
LuaTable position = new LuaTable();
|
||||||
|
position.set("x", x);
|
||||||
|
position.set("y", y);
|
||||||
|
position.set("z", z);
|
||||||
|
|
||||||
|
position.set("add", new OneArgFunction() {
|
||||||
|
@Override
|
||||||
|
public LuaValue call(LuaValue luaValue) {
|
||||||
|
LuaTable table = luaValue.checktable();
|
||||||
|
double dx = table.get("x").checkdouble();
|
||||||
|
double dy = table.get("y").checkdouble();
|
||||||
|
double dz = table.get("z").checkdouble();
|
||||||
|
return pos(x + dx, y + dy, z + dz);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
position.set("subtract", new OneArgFunction() {
|
||||||
|
@Override
|
||||||
|
public LuaValue call(LuaValue luaValue) {
|
||||||
|
LuaTable table = luaValue.checktable();
|
||||||
|
double dx = table.get("x").checkdouble();
|
||||||
|
double dy = table.get("y").checkdouble();
|
||||||
|
double dz = table.get("z").checkdouble();
|
||||||
|
return pos(x - dx, y - dy, z - dz);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
position.set("addX", new OneArgFunction() {
|
||||||
|
@Override
|
||||||
|
public LuaValue call(LuaValue luaValue) {
|
||||||
|
return pos(x + luaValue.checkdouble(), y, z);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
position.set("subtractX", new OneArgFunction() {
|
||||||
|
@Override
|
||||||
|
public LuaValue call(LuaValue luaValue) {
|
||||||
|
return pos(x - luaValue.checkdouble(), y, z);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
position.set("addY", new OneArgFunction() {
|
||||||
|
@Override
|
||||||
|
public LuaValue call(LuaValue luaValue) {
|
||||||
|
return pos(x, y + luaValue.checkdouble(), z);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
position.set("subtractY", new OneArgFunction() {
|
||||||
|
@Override
|
||||||
|
public LuaValue call(LuaValue luaValue) {
|
||||||
|
return pos(x, y - luaValue.checkdouble(), z);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
position.set("addZ", new OneArgFunction() {
|
||||||
|
@Override
|
||||||
|
public LuaValue call(LuaValue luaValue) {
|
||||||
|
return pos(x, y, z + luaValue.checkdouble());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
position.set("subtractZ", new OneArgFunction() {
|
||||||
|
@Override
|
||||||
|
public LuaValue call(LuaValue luaValue) {
|
||||||
|
return pos(x, y, z - luaValue.checkdouble());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
position.set("blockPos", new ZeroArgFunction() {
|
||||||
|
@Override
|
||||||
|
public LuaValue call() {
|
||||||
|
Location location = new Location(Bukkit.getWorlds().get(0), x, y, z);
|
||||||
|
return pos(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
public static String varArgsToString(Varargs args) {
|
public static String varArgsToString(Varargs args) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
for (int i = 1; i <= args.narg(); i++) {
|
for (int i = 1; i <= args.narg(); i++) {
|
||||||
@ -192,7 +266,7 @@ public class SteamWarLuaPlugin extends TwoArgFunction {
|
|||||||
class Print extends VarArgFunction {
|
class Print extends VarArgFunction {
|
||||||
@Override
|
@Override
|
||||||
public Varargs invoke(Varargs args) {
|
public Varargs invoke(Varargs args) {
|
||||||
player.sendMessage(varArgsToString(args));
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', varArgsToString(args)));
|
||||||
return LuaValue.NIL;
|
return LuaValue.NIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.script.lua.libs;
|
package de.steamwar.bausystem.features.script.lua.libs;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.region.Point;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.luaj.vm2.*;
|
import org.luaj.vm2.*;
|
||||||
@ -69,6 +70,15 @@ public interface LuaLib {
|
|||||||
return de.steamwar.bausystem.features.script.lua.SteamWarLuaPlugin.varArgsToString(varargs);
|
return de.steamwar.bausystem.features.script.lua.SteamWarLuaPlugin.varArgsToString(varargs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default LuaTable toPos(Point point) {
|
||||||
|
if (point == null) return LuaTable.tableOf();
|
||||||
|
return LuaValue.tableOf(new LuaValue[] {
|
||||||
|
LuaValue.valueOf("x"), LuaValue.valueOf(point.getX()),
|
||||||
|
LuaValue.valueOf("y"), LuaValue.valueOf(point.getY()),
|
||||||
|
LuaValue.valueOf("z"), LuaValue.valueOf(point.getZ())
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
default Class<? extends LuaLib> parent() {
|
default Class<? extends LuaLib> parent() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,11 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.script.lua.libs;
|
package de.steamwar.bausystem.features.script.lua.libs;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.script.lua.SteamWarLuaPlugin;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.luaj.vm2.LuaTable;
|
import org.luaj.vm2.LuaTable;
|
||||||
@ -43,6 +45,12 @@ public class PlayerLib implements LuaLib {
|
|||||||
table.set("chat", new Print(player));
|
table.set("chat", new Print(player));
|
||||||
table.set("actionbar", new SendActionbar(player));
|
table.set("actionbar", new SendActionbar(player));
|
||||||
|
|
||||||
|
table.set("pos", getter(() -> {
|
||||||
|
return SteamWarLuaPlugin.pos(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ());
|
||||||
|
}));
|
||||||
|
table.set("blockPos", getter(() -> {
|
||||||
|
return SteamWarLuaPlugin.pos(player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ());
|
||||||
|
}));
|
||||||
table.set("x", getterAndSetter("x", () -> player.getLocation().getX(), x -> {
|
table.set("x", getterAndSetter("x", () -> player.getLocation().getX(), x -> {
|
||||||
Location location = player.getLocation();
|
Location location = player.getLocation();
|
||||||
location.setX(x);
|
location.setX(x);
|
||||||
@ -93,7 +101,7 @@ public class PlayerLib implements LuaLib {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Varargs invoke(Varargs args) {
|
public Varargs invoke(Varargs args) {
|
||||||
player.sendMessage(varArgsToString(args));
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', varArgsToString(args)));
|
||||||
return LuaValue.NIL;
|
return LuaValue.NIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -107,7 +115,7 @@ public class PlayerLib implements LuaLib {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Varargs invoke(Varargs args) {
|
public Varargs invoke(Varargs args) {
|
||||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(varArgsToString(args)));
|
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', varArgsToString(args))));
|
||||||
return LuaValue.NIL;
|
return LuaValue.NIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,17 @@ 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("minPointBuild", getter(() -> toPos(region.get().getMinPointBuild())));
|
||||||
|
table.set("maxPointBuild", getter(() -> toPos(region.get().getMaxPointBuild())));
|
||||||
|
table.set("minPointBuildExtension", getter(() -> toPos(region.get().getMinPointBuildExtension())));
|
||||||
|
table.set("maxPointBuildExtension", getter(() -> toPos(region.get().getMaxPointBuildExtension())));
|
||||||
|
table.set("testblockPoint", getter(() -> toPos(region.get().getTestBlockPoint())));
|
||||||
|
table.set("minPointTestblock", getter(() -> toPos(region.get().getMinPointTestblock())));
|
||||||
|
table.set("maxPointTestblock", getter(() -> toPos(region.get().getMaxPointTestblock())));
|
||||||
|
table.set("minPointTestblockExtension", getter(() -> toPos(region.get().getMinPointTestblockExtension())));
|
||||||
|
table.set("maxPointTestblockExtension", getter(() -> toPos(region.get().getMaxPointTestblockExtension())));
|
||||||
|
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 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.script.lua.libs;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.world.BauScoreboard;
|
||||||
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
|
import de.steamwar.linkage.Linked;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.luaj.vm2.LuaTable;
|
||||||
|
import org.luaj.vm2.LuaValue;
|
||||||
|
import org.luaj.vm2.Varargs;
|
||||||
|
import org.luaj.vm2.lib.TwoArgFunction;
|
||||||
|
import org.luaj.vm2.lib.VarArgFunction;
|
||||||
|
|
||||||
|
@Linked
|
||||||
|
public class ScoreboardLib implements LuaLib {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name() {
|
||||||
|
return "scoreboard";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LuaTable get(Player player) {
|
||||||
|
LuaTable luaTable = new LuaTable();
|
||||||
|
|
||||||
|
LuaTable groups = new LuaTable();
|
||||||
|
for (ScoreboardElement.ScoreboardGroup group : ScoreboardElement.ScoreboardGroup.values()) {
|
||||||
|
groups.set(group.name(), group.ordinal());
|
||||||
|
}
|
||||||
|
luaTable.set("group", groups);
|
||||||
|
|
||||||
|
luaTable.set("element", new VarArgFunction() {
|
||||||
|
@Override
|
||||||
|
public Varargs invoke(Varargs varargs) {
|
||||||
|
if (varargs.narg() < 2) {
|
||||||
|
return NIL;
|
||||||
|
}
|
||||||
|
String elementKey = varargs.arg(1).checkjstring();
|
||||||
|
ScoreboardElement.ScoreboardGroup elementGroup = ScoreboardElement.ScoreboardGroup.values()[varargs.arg(2).checkint()];
|
||||||
|
int priority = varargs.narg() > 2 ? varargs.arg(2).checkint() : Integer.MAX_VALUE;
|
||||||
|
|
||||||
|
return new VarArgFunction() {
|
||||||
|
@Override
|
||||||
|
public Varargs invoke(Varargs args) {
|
||||||
|
if (args.narg() == 0) {
|
||||||
|
BauScoreboard.setAdditionalElement(player, elementKey, elementGroup, priority, null);
|
||||||
|
} else {
|
||||||
|
BauScoreboard.setAdditionalElement(player, elementKey, elementGroup, priority, args.arg1().checkjstring());
|
||||||
|
}
|
||||||
|
return NIL;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return luaTable;
|
||||||
|
}
|
||||||
|
}
|
@ -20,11 +20,15 @@
|
|||||||
package de.steamwar.bausystem.features.script.lua.libs;
|
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.features.loader.Loader;
|
||||||
|
import de.steamwar.bausystem.features.loader.LoaderRecorder;
|
||||||
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
||||||
import de.steamwar.core.TPSWatcher;
|
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.luaj.vm2.LuaString;
|
import org.luaj.vm2.LuaString;
|
||||||
import org.luaj.vm2.LuaTable;
|
import org.luaj.vm2.LuaTable;
|
||||||
@ -46,10 +50,14 @@ public class ServerLib implements LuaLib {
|
|||||||
public LuaTable get(Player player) {
|
public LuaTable get(Player player) {
|
||||||
LuaTable serverLib = LuaValue.tableOf();
|
LuaTable serverLib = LuaValue.tableOf();
|
||||||
serverLib.set("time", getter(() -> new SimpleDateFormat(BauSystem.MESSAGE.parse("TIME", player)).format(Calendar.getInstance().getTime())));
|
serverLib.set("time", getter(() -> new SimpleDateFormat(BauSystem.MESSAGE.parse("TIME", player)).format(Calendar.getInstance().getTime())));
|
||||||
|
serverLib.set("onlinePlayerCount", getter(Bukkit.getOnlinePlayers()::size));
|
||||||
serverLib.set("ticks", getter(TPSUtils.currentTick));
|
serverLib.set("ticks", getter(TPSUtils.currentTick));
|
||||||
serverLib.set("getBlockAt", new OneArgFunction() {
|
serverLib.set("getBlockAt", new OneArgFunction() {
|
||||||
@Override
|
@Override
|
||||||
public LuaValue call(LuaValue arg1) {
|
public LuaValue call(LuaValue arg1) {
|
||||||
|
if (!Permission.SUPERVISOR.hasPermission(player)) {
|
||||||
|
return LuaValue.NIL;
|
||||||
|
}
|
||||||
LuaTable pos = arg1.checktable();
|
LuaTable pos = arg1.checktable();
|
||||||
return valueOf(player.getWorld().getBlockAt(pos.get("x").checkint(), pos.get("y").checkint(), pos.get("z").checkint()).getType().name());
|
return valueOf(player.getWorld().getBlockAt(pos.get("x").checkint(), pos.get("y").checkint(), pos.get("z").checkint()).getType().name());
|
||||||
}
|
}
|
||||||
@ -57,6 +65,9 @@ public class ServerLib implements LuaLib {
|
|||||||
serverLib.set("setBlockAt", new TwoArgFunction() {
|
serverLib.set("setBlockAt", new TwoArgFunction() {
|
||||||
@Override
|
@Override
|
||||||
public LuaValue call(LuaValue arg1, LuaValue arg2) {
|
public LuaValue call(LuaValue arg1, LuaValue arg2) {
|
||||||
|
if (!Permission.SUPERVISOR.hasPermission(player)) {
|
||||||
|
return LuaValue.NIL;
|
||||||
|
}
|
||||||
LuaTable pos = arg1.checktable();
|
LuaTable pos = arg1.checktable();
|
||||||
LuaString material = arg2.checkstring();
|
LuaString material = arg2.checkstring();
|
||||||
Material mat = SWItem.getMaterial(material.tojstring());
|
Material mat = SWItem.getMaterial(material.tojstring());
|
||||||
@ -67,17 +78,19 @@ public class ServerLib implements LuaLib {
|
|||||||
return NIL;
|
return NIL;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
serverLib.set("interactAt", new OneArgFunction() {
|
||||||
LuaValue tpsLib = LuaValue.tableOf();
|
@Override
|
||||||
tpsLib.set("oneSecond", getter(() -> TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_SECOND)));
|
public LuaValue call(LuaValue arg1) {
|
||||||
tpsLib.set("tenSecond", getter(() -> TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_SECONDS)));
|
LuaTable pos = arg1.checktable();
|
||||||
tpsLib.set("oneMinute", getter(() -> TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_MINUTE)));
|
Block block = player.getWorld().getBlockAt(pos.get("x").checkint(), pos.get("y").checkint(), pos.get("z").checkint());
|
||||||
tpsLib.set("fiveMinute", getter(() -> TPSWatcher.getTPS(TPSWatcher.TPSType.FIVE_MINUTES)));
|
LoaderRecorder.getLoaderInteractionElement(block, (loaderInteractionElement, s) -> {
|
||||||
tpsLib.set("tenMinute", getter(() -> TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES)));
|
loaderInteractionElement.execute(aLong -> {
|
||||||
tpsLib.set("current", getter(TPSWatcher::getTPS));
|
// Ignore
|
||||||
// tpsLib.set("limit", getter(TPSLimitUtils::getCurrentTPSLimit));
|
});
|
||||||
|
});
|
||||||
serverLib.set("tps", tpsLib);
|
return NIL;
|
||||||
|
}
|
||||||
|
});
|
||||||
return serverLib;
|
return serverLib;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,14 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.script.lua.libs;
|
package de.steamwar.bausystem.features.script.lua.libs;
|
||||||
|
|
||||||
|
import com.google.gson.*;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
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.Enable;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
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;
|
||||||
@ -29,15 +35,173 @@ import org.luaj.vm2.lib.OneArgFunction;
|
|||||||
import org.luaj.vm2.lib.TwoArgFunction;
|
import org.luaj.vm2.lib.TwoArgFunction;
|
||||||
import org.luaj.vm2.lib.VarArgFunction;
|
import org.luaj.vm2.lib.VarArgFunction;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class StorageLib implements LuaLib {
|
public class StorageLib implements LuaLib, Enable, Disable {
|
||||||
|
|
||||||
|
private final Gson gson = new Gson();
|
||||||
|
private final File storageDirectory = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "script_storage");
|
||||||
|
|
||||||
private static final HashMap<String, LuaValue> GLOBAL_STORAGE = new HashMap<>();
|
private static final HashMap<String, LuaValue> GLOBAL_STORAGE = new HashMap<>();
|
||||||
private static final HashMap<Player, HashMap<String, LuaValue>> PLAYER_STORAGE = new HashMap<>();
|
private static final HashMap<UUID, HashMap<String, LuaValue>> PLAYER_STORAGE = new HashMap<>();
|
||||||
private static final HashMap<Region, HashMap<String, LuaValue>> REGION_STORAGE = new HashMap<>();
|
private static final HashMap<Region, HashMap<String, LuaValue>> REGION_STORAGE = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
|
if (Core.getVersion() <= 15) return;
|
||||||
|
if (!storageDirectory.exists()) storageDirectory.mkdirs();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JsonObject jsonObject = JsonParser.parseReader(new FileReader(new File(storageDirectory, "global.json"))).getAsJsonObject();
|
||||||
|
jsonObject.keySet().forEach(key -> {
|
||||||
|
GLOBAL_STORAGE.put(key, fromJson(jsonObject.get(key)));
|
||||||
|
});
|
||||||
|
} catch (Exception e) {}
|
||||||
|
|
||||||
|
File regionStorageDirectory = new File(storageDirectory, "region");
|
||||||
|
regionStorageDirectory.mkdirs();
|
||||||
|
for (File regionStorage : regionStorageDirectory.listFiles()) {
|
||||||
|
try {
|
||||||
|
JsonObject jsonObject = JsonParser.parseReader(new FileReader(regionStorage)).getAsJsonObject();
|
||||||
|
HashMap<String, LuaValue> map = new HashMap<>();
|
||||||
|
jsonObject.keySet().forEach(key -> {
|
||||||
|
map.put(key, fromJson(jsonObject.get(key)));
|
||||||
|
});
|
||||||
|
Region region = Region.getREGION_MAP().get(regionStorage.getName().substring(0, regionStorage.getName().length() - ".json".length()));
|
||||||
|
REGION_STORAGE.put(region, map);
|
||||||
|
} catch (Exception e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
File playerStorageDirectory = new File(storageDirectory, "player");
|
||||||
|
playerStorageDirectory.mkdirs();
|
||||||
|
for (File playerStorage : playerStorageDirectory.listFiles()) {
|
||||||
|
try {
|
||||||
|
JsonObject jsonObject = JsonParser.parseReader(new FileReader(playerStorage)).getAsJsonObject();
|
||||||
|
HashMap<String, LuaValue> map = new HashMap<>();
|
||||||
|
jsonObject.keySet().forEach(key -> {
|
||||||
|
map.put(key, fromJson(jsonObject.get(key)));
|
||||||
|
});
|
||||||
|
SteamwarUser steamwarUser = SteamwarUser.get(Integer.parseInt(playerStorage.getName().substring(0, playerStorage.getName().length() - ".json".length())));
|
||||||
|
PLAYER_STORAGE.put(steamwarUser.getUUID(), map);
|
||||||
|
} catch (Exception e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private LuaValue fromJson(JsonElement jsonElement) {
|
||||||
|
if (jsonElement.isJsonNull()) {
|
||||||
|
return LuaValue.NIL;
|
||||||
|
}
|
||||||
|
if (jsonElement.isJsonPrimitive()) {
|
||||||
|
JsonPrimitive jsonPrimitive = jsonElement.getAsJsonPrimitive();
|
||||||
|
if (jsonPrimitive.isBoolean()) {
|
||||||
|
return LuaValue.valueOf(jsonPrimitive.getAsBoolean());
|
||||||
|
}
|
||||||
|
if (jsonPrimitive.isNumber()) {
|
||||||
|
try {
|
||||||
|
return LuaValue.valueOf(jsonPrimitive.getAsInt());
|
||||||
|
} catch (NumberFormatException e) {}
|
||||||
|
try {
|
||||||
|
return LuaValue.valueOf(jsonPrimitive.getAsDouble());
|
||||||
|
} catch (NumberFormatException e) {}
|
||||||
|
}
|
||||||
|
if (jsonPrimitive.isString()) {
|
||||||
|
return LuaValue.valueOf(jsonPrimitive.getAsString());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (jsonElement.isJsonObject()) {
|
||||||
|
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||||
|
LuaTable luaTable = new LuaTable();
|
||||||
|
jsonObject.keySet().forEach(string -> {
|
||||||
|
LuaValue value = fromJson(jsonObject.get(string));
|
||||||
|
if (value == null) return;
|
||||||
|
luaTable.set(string, value);
|
||||||
|
});
|
||||||
|
return luaTable;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
if (Core.getVersion() <= 15) return;
|
||||||
|
if (!storageDirectory.exists()) storageDirectory.mkdirs();
|
||||||
|
try {
|
||||||
|
FileWriter fileWriter = new FileWriter(new File(storageDirectory, "global.json"));
|
||||||
|
gson.toJson(toJson(GLOBAL_STORAGE), fileWriter);
|
||||||
|
fileWriter.close();
|
||||||
|
} catch (IOException e) {}
|
||||||
|
|
||||||
|
File regionStorageDirectory = new File(storageDirectory, "region");
|
||||||
|
regionStorageDirectory.mkdirs();
|
||||||
|
for (Map.Entry<Region, HashMap<String, LuaValue>> entry : REGION_STORAGE.entrySet()) {
|
||||||
|
try {
|
||||||
|
FileWriter fileWriter = new FileWriter(new File(regionStorageDirectory, entry.getKey().getName() + ".json"));
|
||||||
|
gson.toJson(toJson(entry.getValue()), fileWriter);
|
||||||
|
fileWriter.close();
|
||||||
|
} catch (IOException e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
File playerStorageDirectory = new File(storageDirectory, "player");
|
||||||
|
playerStorageDirectory.mkdirs();
|
||||||
|
for (Map.Entry<UUID, HashMap<String, LuaValue>> entry : PLAYER_STORAGE.entrySet()) {
|
||||||
|
try {
|
||||||
|
FileWriter fileWriter = new FileWriter(new File(playerStorageDirectory, SteamwarUser.get(entry.getKey()).getId() + ".json"));
|
||||||
|
gson.toJson(toJson(entry.getValue()), fileWriter);
|
||||||
|
fileWriter.close();
|
||||||
|
} catch (IOException e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private JsonObject toJson(HashMap<String, LuaValue> valueMap) {
|
||||||
|
JsonObject jsonObject = new JsonObject();
|
||||||
|
valueMap.forEach((string, luaValue) -> {
|
||||||
|
JsonElement value = toJson(luaValue);
|
||||||
|
if (value == null) return;
|
||||||
|
jsonObject.add(string, value);
|
||||||
|
});
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JsonElement toJson(LuaValue luaValue) {
|
||||||
|
if (luaValue.isnil()) {
|
||||||
|
return JsonNull.INSTANCE;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return new JsonPrimitive(luaValue.checkboolean());
|
||||||
|
} catch (Exception e) {}
|
||||||
|
try {
|
||||||
|
return new JsonPrimitive(luaValue.checkint());
|
||||||
|
} catch (Exception e) {}
|
||||||
|
try {
|
||||||
|
return new JsonPrimitive(luaValue.checkdouble());
|
||||||
|
} catch (Exception e) {}
|
||||||
|
|
||||||
|
if (luaValue.isstring()) {
|
||||||
|
return new JsonPrimitive(luaValue.tojstring());
|
||||||
|
}
|
||||||
|
if (luaValue.istable()) {
|
||||||
|
LuaTable luaTable = luaValue.checktable();
|
||||||
|
JsonObject jsonObject = new JsonObject();
|
||||||
|
for (LuaValue key : luaTable.keys()) {
|
||||||
|
JsonElement value = toJson(luaTable.get(key));
|
||||||
|
if (value == null) continue;
|
||||||
|
try {
|
||||||
|
jsonObject.add(key.checkjstring(), value);
|
||||||
|
} catch (Exception e) {}
|
||||||
|
}
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public String name() {
|
||||||
return "storage";
|
return "storage";
|
||||||
@ -92,7 +256,7 @@ public class StorageLib implements LuaLib {
|
|||||||
storageLib.set("global", global);
|
storageLib.set("global", global);
|
||||||
|
|
||||||
LuaTable playerStorage = new LuaTable();
|
LuaTable playerStorage = new LuaTable();
|
||||||
HashMap<String, LuaValue> playerStorageMap = PLAYER_STORAGE.computeIfAbsent(player, k -> new HashMap<>());
|
HashMap<String, LuaValue> playerStorageMap = PLAYER_STORAGE.computeIfAbsent(player.getUniqueId(), k -> new HashMap<>());
|
||||||
playerStorage.set("get", new OneArgFunction() {
|
playerStorage.set("get", new OneArgFunction() {
|
||||||
@Override
|
@Override
|
||||||
public LuaValue call(LuaValue arg) {
|
public LuaValue call(LuaValue arg) {
|
||||||
@ -137,34 +301,38 @@ public class StorageLib implements LuaLib {
|
|||||||
storageLib.set("player", playerStorage);
|
storageLib.set("player", playerStorage);
|
||||||
|
|
||||||
LuaTable regionStorage = new LuaTable();
|
LuaTable regionStorage = new LuaTable();
|
||||||
HashMap<String, LuaValue> regionStorageMap = REGION_STORAGE.computeIfAbsent(Region.getRegion(player.getLocation()), k -> new HashMap<>());
|
|
||||||
regionStorage.set("get", new OneArgFunction() {
|
regionStorage.set("get", new OneArgFunction() {
|
||||||
@Override
|
@Override
|
||||||
public LuaValue call(LuaValue arg) {
|
public LuaValue call(LuaValue arg) {
|
||||||
|
HashMap<String, LuaValue> regionStorageMap = REGION_STORAGE.computeIfAbsent(Region.getRegion(player.getLocation()), k -> new HashMap<>());
|
||||||
return regionStorageMap.getOrDefault(arg.checkjstring(), NIL);
|
return regionStorageMap.getOrDefault(arg.checkjstring(), NIL);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
regionStorage.set("set", new TwoArgFunction() {
|
regionStorage.set("set", new TwoArgFunction() {
|
||||||
@Override
|
@Override
|
||||||
public LuaValue call(LuaValue arg1, LuaValue arg2) {
|
public LuaValue call(LuaValue arg1, LuaValue arg2) {
|
||||||
|
HashMap<String, LuaValue> regionStorageMap = REGION_STORAGE.computeIfAbsent(Region.getRegion(player.getLocation()), k -> new HashMap<>());
|
||||||
return regionStorageMap.put(arg1.checkjstring(), arg2);
|
return regionStorageMap.put(arg1.checkjstring(), arg2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
regionStorage.set("has", new OneArgFunction() {
|
regionStorage.set("has", new OneArgFunction() {
|
||||||
@Override
|
@Override
|
||||||
public LuaValue call(LuaValue arg) {
|
public LuaValue call(LuaValue arg) {
|
||||||
|
HashMap<String, LuaValue> regionStorageMap = REGION_STORAGE.computeIfAbsent(Region.getRegion(player.getLocation()), k -> new HashMap<>());
|
||||||
return valueOf(regionStorageMap.containsKey(arg.checkjstring()));
|
return valueOf(regionStorageMap.containsKey(arg.checkjstring()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
regionStorage.set("remove", new OneArgFunction() {
|
regionStorage.set("remove", new OneArgFunction() {
|
||||||
@Override
|
@Override
|
||||||
public LuaValue call(LuaValue arg) {
|
public LuaValue call(LuaValue arg) {
|
||||||
|
HashMap<String, LuaValue> regionStorageMap = REGION_STORAGE.computeIfAbsent(Region.getRegion(player.getLocation()), k -> new HashMap<>());
|
||||||
return regionStorageMap.remove(arg.checkjstring());
|
return regionStorageMap.remove(arg.checkjstring());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
regionStorage.set("accessor", new OneArgFunction() {
|
regionStorage.set("accessor", new OneArgFunction() {
|
||||||
@Override
|
@Override
|
||||||
public LuaValue call(LuaValue arg) {
|
public LuaValue call(LuaValue arg) {
|
||||||
|
HashMap<String, LuaValue> regionStorageMap = REGION_STORAGE.computeIfAbsent(Region.getRegion(player.getLocation()), k -> new HashMap<>());
|
||||||
String key = arg.checkjstring();
|
String key = arg.checkjstring();
|
||||||
return new VarArgFunction() {
|
return new VarArgFunction() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 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.script.lua.libs;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.tpslimit.TPSSystem;
|
||||||
|
import de.steamwar.core.TPSWatcher;
|
||||||
|
import de.steamwar.linkage.Linked;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.luaj.vm2.LuaTable;
|
||||||
|
|
||||||
|
@Linked
|
||||||
|
public class TpsLib implements LuaLib {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends LuaLib> parent() {
|
||||||
|
return ServerLib.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name() {
|
||||||
|
return "tps";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LuaTable get(Player player) {
|
||||||
|
LuaTable tpsLib = new LuaTable();
|
||||||
|
tpsLib.set("oneSecond", getter(() -> TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_SECOND)));
|
||||||
|
tpsLib.set("tenSecond", getter(() -> TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_SECONDS)));
|
||||||
|
tpsLib.set("oneMinute", getter(() -> TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_MINUTE)));
|
||||||
|
tpsLib.set("fiveMinute", getter(() -> TPSWatcher.getTPS(TPSWatcher.TPSType.FIVE_MINUTES)));
|
||||||
|
tpsLib.set("tenMinute", getter(() -> TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES)));
|
||||||
|
tpsLib.set("current", getter(TPSWatcher::getTPS));
|
||||||
|
tpsLib.set("limit", getter(TPSSystem.getInstance()::getCurrentTPSLimit));
|
||||||
|
return tpsLib;
|
||||||
|
}
|
||||||
|
}
|
@ -20,8 +20,10 @@
|
|||||||
package de.steamwar.bausystem.features.shieldprinting;
|
package de.steamwar.bausystem.features.shieldprinting;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.features.shieldprinting.impl.*;
|
import de.steamwar.bausystem.features.shieldprinting.impl.*;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
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;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
@ -43,6 +45,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
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.event.block.BlockCanBuildEvent;
|
||||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
@ -259,18 +262,14 @@ public class ShieldPrinting implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
if (event.getClickedBlock() == null) return;
|
updateBossbar(event.getPlayer());
|
||||||
if (event.getItem() == null) return;
|
|
||||||
if (Region.getRegion(event.getClickedBlock().getLocation()) != region) return;
|
|
||||||
Vector vector = event.getClickedBlock().getLocation().toVector();
|
|
||||||
if (!shieldMap.containsKey(vector)) return;
|
|
||||||
event.getClickedBlock().setType(Material.AIR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onBauMemberUpdate(BauMemberUpdateEvent event) {
|
||||||
updateBossbar(event.getPlayer());
|
event.getNewSpectator().forEach(player -> BossBarService.instance.remove(player, region, "shieldprinting"));
|
||||||
|
event.getNewBuilder().forEach(this::updateBossbar);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBossbars() {
|
private void updateBossbars() {
|
||||||
|
@ -26,9 +26,7 @@ import de.steamwar.command.SWCommand;
|
|||||||
import de.steamwar.command.TypeValidator;
|
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;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -108,8 +106,8 @@ public class ShieldPrintingCommand extends SWCommand implements Listener {
|
|||||||
@ClassValidator(value = Player.class, local = true)
|
@ClassValidator(value = Player.class, local = true)
|
||||||
public TypeValidator<Player> validator() {
|
public TypeValidator<Player> validator() {
|
||||||
return (commandSender, player, messageSender) -> {
|
return (commandSender, player, messageSender) -> {
|
||||||
if (!Permission.hasPermission(player, Permission.WORLD)) {
|
if (!Permission.BUILD.hasPermission(player)) {
|
||||||
messageSender.send("SHIELD_PRINTING_DISALLOWED", player);
|
messageSender.send("NO_PERMISSION", player);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
@ -120,20 +118,4 @@ public class ShieldPrintingCommand extends SWCommand implements Listener {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
|
||||||
if (event.getClickedBlock() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Region region = Region.getRegion(event.getClickedBlock().getLocation());
|
|
||||||
if (region.isGlobal()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ShieldPrinting shieldPrinting = SHIELD_PRINTING_MAP.get(region);
|
|
||||||
if (shieldPrinting == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
shieldPrinting.onPlayerInteract(event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,92 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.simulator;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@UtilityClass
|
|
||||||
public class OrderUtils {
|
|
||||||
|
|
||||||
private final List<Material> activationOrder = new ArrayList<>();
|
|
||||||
|
|
||||||
private final Map<Material, String> nameMap = new HashMap<>();
|
|
||||||
|
|
||||||
static {
|
|
||||||
add(Material.REPEATER, "SIMULATOR_TNT_SPAWN_ACTIVATED_WITH_REPEATER");
|
|
||||||
add(Material.OBSERVER, "SIMULATOR_TNT_SPAWN_ACTIVATED_WITH_OBSERVER");
|
|
||||||
add(Material.COMPARATOR, "SIMULATOR_TNT_SPAWN_ACTIVATED_WITH_COMPARATOR");
|
|
||||||
}
|
|
||||||
|
|
||||||
public Material next(Material material) {
|
|
||||||
int index = activationOrder.indexOf(material);
|
|
||||||
if (index == -1) {
|
|
||||||
return activationOrder.get(0);
|
|
||||||
}
|
|
||||||
if (index + 1 >= activationOrder.size()) {
|
|
||||||
return activationOrder.get(0);
|
|
||||||
}
|
|
||||||
return activationOrder.get(index + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Material previous(Material material) {
|
|
||||||
int index = activationOrder.indexOf(material);
|
|
||||||
if (index == -1) {
|
|
||||||
return activationOrder.get(0);
|
|
||||||
}
|
|
||||||
if (index - 1 < 0) {
|
|
||||||
return activationOrder.get(activationOrder.size() - 1);
|
|
||||||
}
|
|
||||||
return activationOrder.get(index - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> orderList(Material material, Player player) {
|
|
||||||
List<String> lore = new ArrayList<>();
|
|
||||||
for (Material m : activationOrder) {
|
|
||||||
String element = BauSystem.MESSAGE.parse(name(m), player);
|
|
||||||
if (m == material) {
|
|
||||||
lore.add(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ACTIVE", player, element));
|
|
||||||
} else {
|
|
||||||
lore.add(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_INACTIVE", player, element));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return lore;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int order(Material material) {
|
|
||||||
return activationOrder.indexOf(material);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String name(Material material) {
|
|
||||||
return nameMap.getOrDefault(material, "SIMULATOR_TNT_SPAWN_ACTIVATED_WITH_UNKNOWN");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void add(Material material, String name) {
|
|
||||||
activationOrder.add(material);
|
|
||||||
nameMap.put(material, name);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is a part of the SteamWar software.
|
* This file is a part of the SteamWar software.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2021 SteamWar.de-Serverteam
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -55,6 +55,6 @@ public class SimulatorBauGuiItem extends BauGuiItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Permission permission() {
|
public Permission permission() {
|
||||||
return Permission.WORLD;
|
return Permission.BUILD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is a part of the SteamWar software.
|
* This file is a part of the SteamWar software.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2022 SteamWar.de-Serverteam
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -22,105 +22,78 @@ package de.steamwar.bausystem.features.simulator;
|
|||||||
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.simulator.gui.SimulatorSelectionGUI;
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
import de.steamwar.bausystem.utils.ItemUtils;
|
import de.steamwar.bausystem.features.simulator.execute.SimulatorExecutor;
|
||||||
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.command.TypeValidator;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
|
import de.steamwar.linkage.LinkedInstance;
|
||||||
|
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 java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
|
@MinVersion(19)
|
||||||
public class SimulatorCommand extends SWCommand {
|
public class SimulatorCommand extends SWCommand {
|
||||||
|
|
||||||
|
@LinkedInstance
|
||||||
|
public SimulatorCursor simulatorCursor;
|
||||||
|
|
||||||
public SimulatorCommand() {
|
public SimulatorCommand() {
|
||||||
super("simulator", "sim");
|
super("sim", "simulator");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "SIMULATOR_HELP")
|
@Register(description = "SIMULATOR_HELP")
|
||||||
public void genericCommand(@Validator Player p) {
|
public void genericCommand(@Validator Player p) {
|
||||||
SimulatorCursor.hide(p, null);
|
|
||||||
SWUtils.giveItemToPlayer(p, SimulatorStorage.getWand(p));
|
SWUtils.giveItemToPlayer(p, SimulatorStorage.getWand(p));
|
||||||
|
simulatorCursor.calcCursor(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "change", description = "SIMULATOR_CHANGE_HELP")
|
@Register(value = "change", description = "SIMULATOR_CHANGE_HELP")
|
||||||
public void change(@Validator Player p) {
|
public void change(@Validator Player p) {
|
||||||
ItemStack itemStack = p.getInventory().getItemInMainHand();
|
if (!SimulatorCursor.isSimulatorItem(p.getInventory().getItemInMainHand()) && !SimulatorCursor.isSimulatorItem(p.getInventory().getItemInOffHand())) {
|
||||||
if (!ItemUtils.isItem(itemStack, "simulator")) {
|
|
||||||
BauSystem.MESSAGE.send("SIMULATOR_NO_SIM_IN_HAND", p);
|
BauSystem.MESSAGE.send("SIMULATOR_NO_SIM_IN_HAND", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SimulatorSelectionGUI.open(p, itemStack);
|
SimulatorStorage.openSimulatorSelector(p);
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = "create", description = "SIMULATOR_CREATE_HELP")
|
|
||||||
public void create(@Validator Player p, String name) {
|
|
||||||
createSimulator(p, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean createSimulator(Player p, String name) {
|
|
||||||
if (SimulatorStorage.getSimulatorNames().contains(name)) {
|
|
||||||
BauSystem.MESSAGE.send("SIMULATOR_NAME_ALREADY_EXISTS", p);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!name.matches("[a-zA-Z_0-9-]+")) {
|
|
||||||
BauSystem.MESSAGE.send("SIMULATOR_NAME_INVALID", p);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
SimulatorStorage.createNewSimulator(name);
|
|
||||||
BauSystem.MESSAGE.send("SIMULATOR_CREATE", p);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = "delete", description = "SIMULATOR_DELETE_HELP")
|
|
||||||
public void delete(@Validator Player p, @Mapper("simulators") String name) {
|
|
||||||
if (!SimulatorStorage.getSimulatorNames().contains(name)) {
|
|
||||||
BauSystem.MESSAGE.send("SIMULATOR_NOT_EXISTS", p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SimulatorStorage.delete(name);
|
|
||||||
BauSystem.MESSAGE.send("SIMULATOR_DELETED", p);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = "start", description = "SIMULATOR_START_HELP")
|
|
||||||
public void start(@Validator Player p, @Mapper("simulators") String name) {
|
|
||||||
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(name);
|
|
||||||
if (tntSimulator == null) {
|
|
||||||
BauSystem.MESSAGE.send("SIMULATOR_NOT_EXISTS", p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
tntSimulator.start(p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "copy", description = "SIMULATOR_COPY_HELP")
|
@Register(value = "copy", description = "SIMULATOR_COPY_HELP")
|
||||||
public void copy(@Validator Player p, @Mapper("simulators") String toCopy, String name) {
|
public void copy(@Validator Player p, @ErrorMessage("SIMULATOR_NOT_EXISTS") Simulator simulator, String name) {
|
||||||
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(toCopy);
|
|
||||||
if (tntSimulator == null) {
|
|
||||||
BauSystem.MESSAGE.send("SIMULATOR_NOT_EXISTS", p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (SimulatorStorage.getSimulator(name) != null) {
|
if (SimulatorStorage.getSimulator(name) != null) {
|
||||||
BauSystem.MESSAGE.send("SIMULATOR_NAME_ALREADY_EXISTS", p);
|
BauSystem.MESSAGE.send("SIMULATOR_NAME_ALREADY_EXISTS", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SimulatorStorage.copySimulator(tntSimulator, name);
|
if (!name.matches("[a-zA-Z_0-9-]+")) {
|
||||||
|
BauSystem.MESSAGE.send("SIMULATOR_NAME_INVALID", p);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!SimulatorStorage.copy(simulator, name)) {
|
||||||
|
BauSystem.MESSAGE.send("SIMULATOR_ERROR_COPY", p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mapper("simulators")
|
@Register(value = "delete", description = "SIMULATOR_DELETE_HELP")
|
||||||
public TypeMapper<String> allSimulators() {
|
public void delete(@Validator Player p, @ErrorMessage("SIMULATOR_NOT_EXISTS") Simulator simulator) {
|
||||||
return new TypeMapper<String>() {
|
SimulatorStorage.delete(simulator);
|
||||||
@Override
|
BauSystem.MESSAGE.send("SIMULATOR_DELETED", p);
|
||||||
public String map(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
|
||||||
if (SimulatorStorage.getSimulatorNames().contains(s)) {
|
|
||||||
return s;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Register(value = "start", description = "SIMULATOR_START_HELP")
|
||||||
|
public void start(@Validator Player p, @ErrorMessage("SIMULATOR_NOT_EXISTS") Simulator simulator) {
|
||||||
|
SimulatorExecutor.run(simulator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ClassMapper(value = Simulator.class, local = true)
|
||||||
|
public TypeMapper<Simulator> allSimulators() {
|
||||||
|
return new TypeMapper<>() {
|
||||||
|
@Override
|
||||||
|
public Simulator map(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
||||||
|
return SimulatorStorage.getSimulator(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -129,11 +102,4 @@ public class SimulatorCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ClassValidator(value = Player.class, local = true)
|
|
||||||
public TypeValidator<Player> validator() {
|
|
||||||
return (commandSender, player, messageSender) -> {
|
|
||||||
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "SIMULATOR_NO_PERMS");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is a part of the SteamWar software.
|
* This file is a part of the SteamWar software.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2022 SteamWar.de-Serverteam
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -19,89 +19,230 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.simulator;
|
package de.steamwar.bausystem.features.simulator;
|
||||||
|
|
||||||
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement;
|
import de.steamwar.bausystem.Permission;
|
||||||
|
import de.steamwar.bausystem.SWUtils;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.observer.ObserverElement;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.observer.ObserverPhase;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.redstone.RedstonePhase;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
|
||||||
|
import de.steamwar.bausystem.features.simulator.execute.SimulatorExecutor;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.SimulatorGroupGui;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.SimulatorGui;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||||
|
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||||
|
import de.steamwar.bausystem.utils.ItemUtils;
|
||||||
import de.steamwar.bausystem.utils.RayTraceUtils;
|
import de.steamwar.bausystem.utils.RayTraceUtils;
|
||||||
|
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 lombok.experimental.UtilityClass;
|
import de.steamwar.inventory.SWAnvilInv;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import de.steamwar.linkage.Linked;
|
||||||
|
import de.steamwar.linkage.MinVersion;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.player.*;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.function.BiFunction;
|
||||||
import java.util.Map;
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@UtilityClass
|
@Linked
|
||||||
public class SimulatorCursor {
|
@MinVersion(19)
|
||||||
|
public class SimulatorCursor implements Listener {
|
||||||
|
|
||||||
private static final World WORLD = Bukkit.getWorlds().get(0);
|
private final World WORLD = Bukkit.getWorlds().get(0);
|
||||||
private Map<Player, REntityServer> rEntityServerMap = new HashMap<>();
|
private Class<?> position = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInPosition");
|
||||||
|
private Class<?> look = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInLook");
|
||||||
|
private Class<?> positionLook = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInPositionLook");
|
||||||
|
|
||||||
public void show(Player player, TNTSimulator tntSimulator, RayTraceUtils.RRayTraceResult result) {
|
private Map<Player, CursorType> cursorType = Collections.synchronizedMap(new HashMap<>());
|
||||||
REntityServer cursor = rEntityServerMap.get(player);
|
private Map<Player, REntityServer> cursors = Collections.synchronizedMap(new HashMap<>());
|
||||||
|
private final Set<Player> calculating = new HashSet<>();
|
||||||
|
|
||||||
if (cursor != null)
|
public static boolean isSimulatorItem(ItemStack itemStack) {
|
||||||
cursor.close();
|
return ItemUtils.isItem(itemStack, "simulator");
|
||||||
|
}
|
||||||
|
|
||||||
tntSimulator.show(player);
|
public SimulatorCursor() {
|
||||||
|
BiFunction<Player, Object, Object> function = (player, object) -> {
|
||||||
|
calcCursor(player);
|
||||||
|
return object;
|
||||||
|
};
|
||||||
|
TinyProtocol.instance.addFilter(position, function);
|
||||||
|
TinyProtocol.instance.addFilter(look, function);
|
||||||
|
TinyProtocol.instance.addFilter(positionLook, function);
|
||||||
|
}
|
||||||
|
|
||||||
if (result == null)
|
@EventHandler
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
|
calcCursor(event.getPlayer());
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||||
|
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
|
calcCursor(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerItemHeld(PlayerItemHeldEvent event) {
|
||||||
|
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
|
calcCursor(event.getPlayer());
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBauMemberUpdate(BauMemberUpdateEvent event) {
|
||||||
|
event.getChanged().forEach(this::calcCursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
cursorType.remove(event.getPlayer());
|
||||||
|
cursors.remove(event.getPlayer());
|
||||||
|
synchronized (calculating) {
|
||||||
|
calculating.remove(event.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Map<Player, Long> LAST_SNEAKS = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
|
||||||
|
long millis = System.currentTimeMillis();
|
||||||
|
LAST_SNEAKS.entrySet().removeIf(entry -> millis - entry.getValue() > 200);
|
||||||
|
}, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
|
||||||
|
if (!event.isSneaking()) return;
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (!isSimulatorItem(player.getInventory().getItemInMainHand()) && !isSimulatorItem(player.getInventory().getItemInOffHand())) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
if (LAST_SNEAKS.containsKey(player)) {
|
||||||
|
cursorType.put(player, cursorType.getOrDefault(player, CursorType.TNT).switchType());
|
||||||
|
calcCursor(player);
|
||||||
|
} else {
|
||||||
|
LAST_SNEAKS.put(player, System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (result.getHitEntity() != null) {
|
public void calcCursor(Player player) {
|
||||||
List<SimulatorElement> elements = tntSimulator.getEntity(result.getHitEntity());
|
synchronized (calculating) {
|
||||||
|
if (calculating.contains(player)) return;
|
||||||
|
calculating.add(player);
|
||||||
|
}
|
||||||
|
if (!Permission.BUILD.hasPermission(player) || (!isSimulatorItem(player.getInventory().getItemInMainHand()) && !isSimulatorItem(player.getInventory().getItemInOffHand()))) {
|
||||||
|
if (removeCursor(player) || SimulatorWatcher.show(null, player)) {
|
||||||
|
SWUtils.sendToActionbar(player, "");
|
||||||
|
}
|
||||||
|
synchronized (calculating) {
|
||||||
|
calculating.remove(player);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Simulator simulator = SimulatorStorage.getSimulator(player);
|
||||||
|
SimulatorWatcher.show(simulator, player);
|
||||||
|
|
||||||
cursor = new REntityServer();
|
List<REntity> entities = SimulatorWatcher.getEntitiesOfSimulator(simulator);
|
||||||
RFallingBlockEntity entity = new RFallingBlockEntity(cursor, (elements.isEmpty() ? getPos(player, result) : elements.get(0).getPosition()).toLocation(WORLD), Material.TNT);
|
RayTraceUtils.RRayTraceResult rayTraceResult = RayTraceUtils.traceREntity(player, player.getLocation(), entities);
|
||||||
entity.setNoGravity(true);
|
if (rayTraceResult == null) {
|
||||||
entity.setGlowing(true);
|
removeCursor(player);
|
||||||
cursor.addPlayer(player);
|
if (simulator == null) {
|
||||||
rEntityServerMap.put(player, cursor);
|
SWUtils.sendToActionbar(player, "§eSelect Simulator");
|
||||||
BauSystem.MESSAGE.sendPrefixless("SIMULATOR_POSITION_EDIT", player, ChatMessageType.ACTION_BAR);
|
} else {
|
||||||
|
SWUtils.sendToActionbar(player, "§eOpen Simulator");
|
||||||
|
}
|
||||||
|
synchronized (calculating) {
|
||||||
|
calculating.remove(player);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SimulatorStorage.getSimulator(player.getInventory().getItemInOffHand()) != null && result.getHitPosition().distanceSquared(player.getLocation().toVector()) < 25) {
|
showCursor(player, rayTraceResult, simulator != null);
|
||||||
return;
|
synchronized (calculating) {
|
||||||
|
calculating.remove(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor = new REntityServer();
|
private synchronized boolean removeCursor(Player player) {
|
||||||
RFallingBlockEntity entity = new RFallingBlockEntity(cursor, getPos(player, result).toLocation(WORLD), Material.TNT);
|
REntityServer entityServer = cursors.get(player);
|
||||||
entity.setNoGravity(true);
|
boolean hadCursor = entityServer != null && !entityServer.getEntities().isEmpty();
|
||||||
cursor.addPlayer(player);
|
if (entityServer != null) {
|
||||||
rEntityServerMap.put(player, cursor);
|
entityServer.getEntities().forEach(REntity::die);
|
||||||
BauSystem.MESSAGE.sendPrefixless("SIMULATOR_POSITION_ADD", player, ChatMessageType.ACTION_BAR);
|
}
|
||||||
|
return hadCursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hide(Player player) {
|
private synchronized void showCursor(Player player, RayTraceUtils.RRayTraceResult rayTraceResult, boolean hasSimulatorSelected) {
|
||||||
REntityServer cursor = rEntityServerMap.get(player);
|
REntityServer entityServer = cursors.computeIfAbsent(player, __ -> {
|
||||||
if (cursor == null) return;
|
REntityServer rEntityServer = new REntityServer();
|
||||||
|
rEntityServer.addPlayer(player);
|
||||||
cursor.close();
|
return rEntityServer;
|
||||||
SimulatorStorage.getSimulatorNames().forEach(s -> {
|
|
||||||
SimulatorStorage.getSimulator(s).hide(player);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
CursorType type = cursorType.getOrDefault(player, CursorType.TNT);
|
||||||
|
REntity hitEntity = rayTraceResult.getHitEntity();
|
||||||
|
Location location = hitEntity != null ? new Vector(hitEntity.getX(), hitEntity.getY(), hitEntity.getZ()).toLocation(WORLD) :
|
||||||
|
type.position.apply(player, rayTraceResult).toLocation(WORLD);
|
||||||
|
|
||||||
|
Material material = hitEntity != null ? Material.GLASS : type.getMaterial();
|
||||||
|
List<RFallingBlockEntity> entities = entityServer.getEntitiesByType(RFallingBlockEntity.class);
|
||||||
|
entities.removeIf(rFallingBlockEntity -> {
|
||||||
|
if (rFallingBlockEntity.getMaterial() != material) {
|
||||||
|
rFallingBlockEntity.die();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
rFallingBlockEntity.move(location);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
if (entities.isEmpty()) {
|
||||||
|
RFallingBlockEntity rFallingBlockEntity = new RFallingBlockEntity(entityServer, location, material);
|
||||||
|
rFallingBlockEntity.setNoGravity(true);
|
||||||
|
if (material == Material.GLASS) {
|
||||||
|
rFallingBlockEntity.setGlowing(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hide(Player player, TNTSimulator tntSimulator) {
|
if (hasSimulatorSelected) {
|
||||||
REntityServer cursor = rEntityServerMap.get(player);
|
if (hitEntity != null) {
|
||||||
|
SWUtils.sendToActionbar(player, "§eEdit Position");
|
||||||
if (cursor != null)
|
} else {
|
||||||
cursor.close();
|
SWUtils.sendToActionbar(player, "§eAdd new " + type.name);
|
||||||
|
}
|
||||||
if (tntSimulator != null) {
|
} else {
|
||||||
tntSimulator.hide(player);
|
SWUtils.sendToActionbar(player, "§eCreate new Simulator");
|
||||||
}
|
}
|
||||||
rEntityServerMap.remove(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector getPos(Player player, RayTraceUtils.RRayTraceResult result) {
|
public static Vector getPosFree(Player player, RayTraceUtils.RRayTraceResult result) {
|
||||||
Vector pos = result.getHitPosition();
|
Vector pos = result.getHitPosition();
|
||||||
|
|
||||||
BlockFace face = result.getHitBlockFace();
|
BlockFace face = result.getHitBlockFace();
|
||||||
@ -140,4 +281,177 @@ public class SimulatorCursor {
|
|||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Vector getPosBlockAligned(Player player, RayTraceUtils.RRayTraceResult result) {
|
||||||
|
Vector pos = result.getHitPosition();
|
||||||
|
|
||||||
|
BlockFace face = result.getHitBlockFace();
|
||||||
|
if (face != null) {
|
||||||
|
switch (face) {
|
||||||
|
case DOWN:
|
||||||
|
pos.setY(pos.getY() - 0.98);
|
||||||
|
break;
|
||||||
|
case EAST:
|
||||||
|
pos.setX(pos.getX() + 0.49);
|
||||||
|
break;
|
||||||
|
case WEST:
|
||||||
|
pos.setX(pos.getX() - 0.49);
|
||||||
|
break;
|
||||||
|
case NORTH:
|
||||||
|
pos.setZ(pos.getZ() - 0.49);
|
||||||
|
break;
|
||||||
|
case SOUTH:
|
||||||
|
pos.setZ(pos.getZ() + 0.49);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pos.setX(pos.getBlockX() + 0.5);
|
||||||
|
if (pos.getY() - pos.getBlockY() != 0 && face == BlockFace.UP) {
|
||||||
|
pos.setY(pos.getBlockY() + 1.0);
|
||||||
|
} else {
|
||||||
|
pos.setY(pos.getBlockY());
|
||||||
|
}
|
||||||
|
pos.setZ(pos.getBlockZ() + 0.5);
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum CursorType {
|
||||||
|
TNT(Material.TNT, 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())),
|
||||||
|
OBSERVER(Material.OBSERVER, SimulatorCursor::getPosBlockAligned, "Observer", vector -> new ObserverElement(vector).add(new ObserverPhase())),
|
||||||
|
;
|
||||||
|
|
||||||
|
private Material material;
|
||||||
|
private BiFunction<Player, RayTraceUtils.RRayTraceResult, Vector> position;
|
||||||
|
private String name;
|
||||||
|
private Function<Vector, SimulatorElement<?>> elementFunction;
|
||||||
|
|
||||||
|
public CursorType switchType() {
|
||||||
|
if (this == TNT) {
|
||||||
|
return REDSTONE_BLOCK;
|
||||||
|
}
|
||||||
|
if (this == REDSTONE_BLOCK) {
|
||||||
|
return OBSERVER;
|
||||||
|
}
|
||||||
|
return TNT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
|
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
|
if (!ItemUtils.isItem(event.getItem(), "simulator")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
Simulator simulator = SimulatorStorage.getSimulator(player);
|
||||||
|
|
||||||
|
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR) {
|
||||||
|
if (simulator == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SimulatorExecutor.run(simulator);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RayTraceUtils.RRayTraceResult rayTraceResult = RayTraceUtils.traceREntity(player, player.getLocation(), SimulatorWatcher.getEntitiesOfSimulator(simulator));
|
||||||
|
if (simulator == null) {
|
||||||
|
if (rayTraceResult == null) {
|
||||||
|
SimulatorStorage.openSimulatorSelector(player);
|
||||||
|
} else {
|
||||||
|
SWAnvilInv anvilInv = new SWAnvilInv(player, "Name");
|
||||||
|
anvilInv.setCallback(s -> {
|
||||||
|
Simulator sim = SimulatorStorage.getSimulator(s);
|
||||||
|
if (sim != null) {
|
||||||
|
BauSystem.MESSAGE.send("SIMULATOR_NAME_ALREADY_EXISTS", player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!s.matches("[a-zA-Z_0-9-]+")) {
|
||||||
|
BauSystem.MESSAGE.send("SIMULATOR_NAME_INVALID", player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sim = new Simulator(s);
|
||||||
|
SimulatorStorage.addSimulator(s, sim);
|
||||||
|
createElement(player, rayTraceResult, sim);
|
||||||
|
SimulatorStorage.setSimulator(player, sim);
|
||||||
|
});
|
||||||
|
anvilInv.open();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rayTraceResult == null) {
|
||||||
|
new SimulatorGui(player, simulator).open();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rayTraceResult.getHitEntity() != null) {
|
||||||
|
REntity hitEntity = rayTraceResult.getHitEntity();
|
||||||
|
Vector vector = new Vector(hitEntity.getX(), hitEntity.getY(), hitEntity.getZ());
|
||||||
|
List<SimulatorElement<?>> elements = simulator.getGroups().stream().map(SimulatorGroup::getElements).flatMap(List::stream).filter(element -> {
|
||||||
|
return element.getWorldPos().distanceSquared(vector) < (1 / 16.0) * (1 / 16.0);
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
switch (elements.size()) {
|
||||||
|
case 0:
|
||||||
|
return;
|
||||||
|
case 1:
|
||||||
|
// Open single element present in Simulator
|
||||||
|
SimulatorElement<?> element = elements.get(0);
|
||||||
|
SimulatorGroup group1 = element.getGroup(simulator);
|
||||||
|
SimulatorBaseGui back = new SimulatorGui(player, simulator);
|
||||||
|
if (group1.getElements().size() > 1) {
|
||||||
|
back = new SimulatorGroupGui(player, simulator, group1, back);
|
||||||
|
}
|
||||||
|
element.open(player, simulator, group1, back);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
List<SimulatorGroup> parents = elements.stream().map(e -> e.getGroup(simulator)).distinct().collect(Collectors.toList());
|
||||||
|
if (parents.size() == 1) {
|
||||||
|
// Open multi element present in Simulator in existing group
|
||||||
|
SimulatorGui simulatorGui = new SimulatorGui(player, simulator);
|
||||||
|
new SimulatorGroupGui(player, simulator, parents.get(0), simulatorGui).open();
|
||||||
|
} else {
|
||||||
|
// Open multi element present in Simulator in implicit group
|
||||||
|
SimulatorGroup group2 = new SimulatorGroup();
|
||||||
|
group2.setMaterial(null);
|
||||||
|
group2.getElements().addAll(elements);
|
||||||
|
SimulatorGui simulatorGui = new SimulatorGui(player, simulator);
|
||||||
|
new SimulatorGroupGui(player, simulator, group2, simulatorGui).open();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add new Element to current simulator
|
||||||
|
createElement(player, rayTraceResult, simulator);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createElement(Player player, RayTraceUtils.RRayTraceResult rayTraceResult, Simulator simulator) {
|
||||||
|
CursorType type = cursorType.getOrDefault(player, CursorType.TNT);
|
||||||
|
Vector vector = type.position.apply(player, rayTraceResult);
|
||||||
|
if (type == CursorType.REDSTONE_BLOCK) {
|
||||||
|
vector.subtract(new Vector(0.5, 0, 0.5));
|
||||||
|
}
|
||||||
|
SimulatorElement<?> element = type.elementFunction.apply(vector);
|
||||||
|
SimulatorGroup group = new SimulatorGroup().add(element);
|
||||||
|
simulator.getGroups().add(group);
|
||||||
|
SimulatorGui simulatorGui = new SimulatorGui(player, simulator);
|
||||||
|
element.open(player, simulator, group, simulatorGui);
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
calcCursor(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is a part of the SteamWar software.
|
* This file is a part of the SteamWar software.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2022 SteamWar.de-Serverteam
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -19,106 +19,154 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.simulator;
|
package de.steamwar.bausystem.features.simulator;
|
||||||
|
|
||||||
|
import com.google.common.io.Files;
|
||||||
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.simulator.tnt.TNTElement;
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
||||||
|
import de.steamwar.bausystem.features.simulator.storage.SimFormatSimulatorLoader;
|
||||||
|
import de.steamwar.bausystem.features.simulator.storage.SimulatorFormatSimulatorLoader;
|
||||||
|
import de.steamwar.bausystem.features.simulator.storage.SimulatorSaver;
|
||||||
|
import de.steamwar.bausystem.features.simulator.storage.YAPIONFormatSimulatorLoader;
|
||||||
import de.steamwar.bausystem.utils.ItemUtils;
|
import de.steamwar.bausystem.utils.ItemUtils;
|
||||||
|
import de.steamwar.inventory.SWAnvilInv;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.api.Disable;
|
import de.steamwar.linkage.MinVersion;
|
||||||
import de.steamwar.linkage.api.Enable;
|
import de.steamwar.linkage.api.Enable;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import yapion.exceptions.YAPIONException;
|
|
||||||
import yapion.hierarchy.types.YAPIONArray;
|
|
||||||
import yapion.hierarchy.types.YAPIONObject;
|
|
||||||
import yapion.parser.YAPIONParser;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class SimulatorStorage implements Enable, Disable {
|
@MinVersion(19)
|
||||||
|
public class SimulatorStorage implements Enable {
|
||||||
public static final World WORLD = Bukkit.getWorlds().get(0);
|
|
||||||
private static final File simulatorsDir = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "simulators");
|
|
||||||
|
|
||||||
|
public static final File simulatorsDir = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "simulators");
|
||||||
|
private static Map<String, Simulator> simulatorMap = new HashMap<>();
|
||||||
private static NamespacedKey simulatorSelection = SWUtils.getNamespaceKey("simulator_selection");
|
private static NamespacedKey simulatorSelection = SWUtils.getNamespaceKey("simulator_selection");
|
||||||
|
|
||||||
private static Map<String, TNTSimulator> tntSimulators = new HashMap<>();
|
public static Simulator getSimulator(Player player) {
|
||||||
|
Simulator simulator = getSimulator(player.getInventory().getItemInMainHand());
|
||||||
public static void createNewSimulator(String name) {
|
if (simulator != null) return simulator;
|
||||||
tntSimulators.put(name, new TNTSimulator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Set<String> getSimulatorNames() {
|
|
||||||
return tntSimulators.keySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TNTSimulator getSimulator(String name) {
|
|
||||||
return tntSimulators.get(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TNTSimulator getSimulator(Player player) {
|
|
||||||
TNTSimulator current = getSimulator(player.getInventory().getItemInMainHand());
|
|
||||||
if (current != null) return current;
|
|
||||||
return getSimulator(player.getInventory().getItemInOffHand());
|
return getSimulator(player.getInventory().getItemInOffHand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TNTSimulator getSimulator(ItemStack itemStack) {
|
public static Simulator getSimulator(ItemStack itemStack) {
|
||||||
if (itemStack == null) {
|
if (!SimulatorCursor.isSimulatorItem(itemStack)) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (!ItemUtils.isItem(itemStack, "simulator")) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String selection = ItemUtils.getTag(itemStack, simulatorSelection);
|
String selection = ItemUtils.getTag(itemStack, simulatorSelection);
|
||||||
if (selection == null) {
|
if (selection == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return tntSimulators.get(selection);
|
return simulatorMap.get(selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setSimulator(Player player, ItemStack itemStack, TNTSimulator simulator) {
|
public static Simulator getSimulator(String name) {
|
||||||
for (Map.Entry<String, TNTSimulator> entry : tntSimulators.entrySet()) {
|
return simulatorMap.get(name);
|
||||||
if (entry.getValue() == simulator) {
|
}
|
||||||
ItemUtils.setTag(itemStack, simulatorSelection, entry.getKey());
|
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
public static void addSimulator(String name, Simulator simulator) {
|
||||||
itemMeta.setDisplayName(BauSystem.MESSAGE.parse("SIMULATOR_WAND_NAME_SELECTED", player, entry.getKey()));
|
simulatorMap.putIfAbsent(name, simulator);
|
||||||
itemStack.setItemMeta(itemMeta);
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
|
SimFormatSimulatorLoader simFormatSimulatorLoader = new SimFormatSimulatorLoader();
|
||||||
|
SimulatorFormatSimulatorLoader simulatorFormatSimulatorLoader = new SimulatorFormatSimulatorLoader();
|
||||||
|
YAPIONFormatSimulatorLoader yapionFormatSimulatorLoader = new YAPIONFormatSimulatorLoader();
|
||||||
|
|
||||||
|
File[] files = simulatorsDir.listFiles();
|
||||||
|
if (files == null) return;
|
||||||
|
for (File file : files) {
|
||||||
|
try {
|
||||||
|
List<Simulator> simulators = simFormatSimulatorLoader.load(file)
|
||||||
|
.orElse(null);
|
||||||
|
if (simulators != null) {
|
||||||
|
simulators.forEach(simulator -> {
|
||||||
|
simulatorMap.put(simulator.getName(), simulator);
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
List<Simulator> simulators = simulatorFormatSimulatorLoader.load(file)
|
||||||
|
.orElse(null);
|
||||||
|
if (simulators != null) {
|
||||||
|
simulators.forEach(simulator -> {
|
||||||
|
simulatorMap.put(simulator.getName(), simulator);
|
||||||
|
SimulatorSaver.saveSimulator(simulatorsDir, simulator);
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
List<Simulator> simulators = yapionFormatSimulatorLoader.load(file)
|
||||||
|
.orElse(null);
|
||||||
|
if (simulators != null) {
|
||||||
|
simulators.forEach(simulator -> {
|
||||||
|
simulatorMap.put(simulator.getName(), simulator);
|
||||||
|
SimulatorSaver.saveSimulator(simulatorsDir, simulator);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void openSimulatorSelector(Player player) {
|
||||||
|
SimulatorPageGui<Simulator> simulatorPageGui = new SimulatorPageGui<Simulator>(player, null, 6 * 9, new ArrayList<>(simulatorMap.values())) {
|
||||||
|
@Override
|
||||||
|
public String baseTitle() {
|
||||||
|
return "Simulators";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void headerAndFooter() {
|
||||||
|
inventory.setItem(49, new SWItem(Material.NAME_TAG, "§eCreate", clickType -> {
|
||||||
|
SWAnvilInv anvilInv = new SWAnvilInv(player, "Name");
|
||||||
|
anvilInv.setCallback(s -> {
|
||||||
|
Simulator sim = SimulatorStorage.getSimulator(s);
|
||||||
|
if (sim != null) {
|
||||||
|
BauSystem.MESSAGE.send("SIMULATOR_NAME_ALREADY_EXISTS", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
if (!s.matches("[a-zA-Z_0-9-]+")) {
|
||||||
}
|
BauSystem.MESSAGE.send("SIMULATOR_NAME_INVALID", player);
|
||||||
|
|
||||||
public static void delete(String name) {
|
|
||||||
TNTSimulator tntSimulator = tntSimulators.remove(name);
|
|
||||||
if (tntSimulator != null) {
|
|
||||||
tntSimulator.close();
|
|
||||||
}
|
|
||||||
new File(simulatorsDir, name + ".simulator").delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void copySimulator(TNTSimulator tntSimulator, String name) {
|
|
||||||
tntSimulators.put(name, new TNTSimulator(tntSimulator.toYAPION()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void removeSimulator(ItemStack itemStack) {
|
|
||||||
if (!ItemUtils.isItem(itemStack, "simulator")) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ItemUtils.setTag(itemStack, simulatorSelection, null);
|
sim = new Simulator(s);
|
||||||
|
SimulatorStorage.addSimulator(s, sim);
|
||||||
|
SimulatorStorage.setSimulator(player, sim);
|
||||||
|
});
|
||||||
|
anvilInv.open();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SWItem convert(Simulator simulator) {
|
||||||
|
return simulator.toItem(player, clickType -> {
|
||||||
|
setSimulator(player, simulator);
|
||||||
|
player.closeInventory();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
simulatorPageGui.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack getWand(Player p) {
|
public static ItemStack getWand(Player p) {
|
||||||
@ -130,68 +178,48 @@ public class SimulatorStorage implements Enable, Disable {
|
|||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public static void setSimulator(Player player, Simulator simulator) {
|
||||||
public void enable() {
|
ItemStack mainHand = player.getInventory().getItemInMainHand();
|
||||||
if (!simulatorsDir.exists()) {
|
ItemStack offHand = player.getInventory().getItemInOffHand();
|
||||||
simulatorsDir.mkdir();
|
ItemStack itemStack;
|
||||||
}
|
if (SimulatorCursor.isSimulatorItem(mainHand)) {
|
||||||
File[] files = simulatorsDir.listFiles();
|
itemStack = mainHand;
|
||||||
if (files == null) return;
|
} else if (SimulatorCursor.isSimulatorItem(offHand)) {
|
||||||
|
itemStack = offHand;
|
||||||
for (File file : files) {
|
|
||||||
YAPIONObject yapionObject;
|
|
||||||
try {
|
|
||||||
yapionObject = YAPIONParser.parse(file);
|
|
||||||
} catch (YAPIONException | IOException e) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (file.getName().endsWith(".yapion")) {
|
|
||||||
String name = file.getName().substring(0, file.getName().length() - 7);
|
|
||||||
try {
|
|
||||||
SteamwarUser steamwarUser = SteamwarUser.get(Integer.parseInt(name));
|
|
||||||
convert(file, steamwarUser);
|
|
||||||
} catch (Exception e) {
|
|
||||||
file.delete();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
String name = file.getName().substring(0, file.getName().length() - ".simulator".length());
|
itemStack = null;
|
||||||
tntSimulators.put(name, new TNTSimulator(yapionObject));
|
|
||||||
}
|
}
|
||||||
}
|
if (itemStack == null) {
|
||||||
}
|
|
||||||
|
|
||||||
private static void convert(File file, SteamwarUser steamwarUser) {
|
|
||||||
YAPIONObject yapionObject;
|
|
||||||
try {
|
|
||||||
yapionObject = YAPIONParser.parse(file);
|
|
||||||
} catch (YAPIONException | IOException e) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
file.delete();
|
ItemUtils.setTag(itemStack, simulatorSelection, simulator.getName());
|
||||||
} catch (Exception e) {
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
e.printStackTrace();
|
itemMeta.setDisplayName(BauSystem.MESSAGE.parse("SIMULATOR_WAND_NAME_SELECTED", player, simulator.getName()));
|
||||||
}
|
itemStack.setItemMeta(itemMeta);
|
||||||
for (String s : yapionObject.getKeys()) {
|
|
||||||
String newName = steamwarUser.getUserName() + (s.isEmpty() ? "" : "_" + s);
|
|
||||||
YAPIONArray content = yapionObject.getArray(s);
|
|
||||||
if (content.isEmpty()) continue;
|
|
||||||
TNTSimulator tntSimulator = new TNTSimulator();
|
|
||||||
for (YAPIONObject element : content.streamObject().collect(Collectors.toList())) {
|
|
||||||
tntSimulator.getTntElementList().add(new TNTElement(element, null, tntSimulator.getEntityServer()));
|
|
||||||
}
|
|
||||||
tntSimulators.put(newName, tntSimulator);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public static List<String> getSimulatorNames() {
|
||||||
public void disable() {
|
return new ArrayList<>(simulatorMap.keySet());
|
||||||
for (Map.Entry<String, TNTSimulator> entry : tntSimulators.entrySet()) {
|
}
|
||||||
|
|
||||||
|
public static void delete(Simulator simulator) {
|
||||||
|
simulatorMap.remove(simulator.getName());
|
||||||
|
new File(simulatorsDir, simulator.getName() + ".sim").delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean copy(Simulator simulator, String name) {
|
||||||
try {
|
try {
|
||||||
entry.getValue().toYAPION().toFile(new File(simulatorsDir, entry.getKey() + ".simulator"));
|
File file = new File(simulatorsDir, name + ".sim");
|
||||||
} catch (Exception e) {
|
Files.copy(new File(simulatorsDir, simulator.getName() + ".sim"), file);
|
||||||
e.printStackTrace();
|
new SimFormatSimulatorLoader().load(file).ifPresent(simulators -> {
|
||||||
}
|
simulators.forEach(sim -> {
|
||||||
|
simulatorMap.put(sim.getName(), sim);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
} catch (IOException e) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,129 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.features.simulator;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||||
|
import de.steamwar.bausystem.features.simulator.storage.SimulatorSaver;
|
||||||
|
import de.steamwar.bausystem.shared.Pair;
|
||||||
|
import de.steamwar.entity.REntity;
|
||||||
|
import de.steamwar.entity.REntityServer;
|
||||||
|
import de.steamwar.entity.RFallingBlockEntity;
|
||||||
|
import de.steamwar.linkage.Linked;
|
||||||
|
import de.steamwar.linkage.MinVersion;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@UtilityClass
|
||||||
|
public class SimulatorWatcher {
|
||||||
|
|
||||||
|
private final World WORLD = Bukkit.getWorlds().get(0);
|
||||||
|
private Map<Simulator, REntityServer> entityServers = new HashMap<>();
|
||||||
|
private Map<Player, Pair<Simulator, Runnable>> watchers = new HashMap<>();
|
||||||
|
|
||||||
|
public void watch(Player player, Simulator simulator, Runnable watcher) {
|
||||||
|
if (simulator == null || watcher == null) {
|
||||||
|
watchers.remove(player);
|
||||||
|
} else {
|
||||||
|
watchers.put(player, new Pair<>(simulator, watcher));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void update(Simulator simulator) {
|
||||||
|
REntityServer rEntityServer = entityServers.get(simulator);
|
||||||
|
if (rEntityServer != null) {
|
||||||
|
rEntityServer.getEntities().forEach(REntity::die);
|
||||||
|
createSim(rEntityServer, simulator);
|
||||||
|
}
|
||||||
|
|
||||||
|
new ArrayList<>(watchers.values()).forEach(simulatorRunnablePair -> {
|
||||||
|
if (simulatorRunnablePair.getKey() == simulator) {
|
||||||
|
simulatorRunnablePair.getValue().run();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
SimulatorSaver.saveSimulator(SimulatorStorage.simulatorsDir, simulator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Linked
|
||||||
|
@MinVersion(19)
|
||||||
|
public static class QuitListener implements Listener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
watchers.remove(event.getPlayer());
|
||||||
|
show(null, event.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private REntityServer createSim(REntityServer server, Simulator simulator) {
|
||||||
|
if (simulator == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Map<Vector, Set<Class<?>>> positionCache = new HashMap<>();
|
||||||
|
simulator.getGroups().stream().map(group -> group.getElements().stream().map(element -> new Pair<>(group, element)).collect(Collectors.toList())).flatMap(List::stream).forEach(pair -> {
|
||||||
|
SimulatorGroup group = pair.getKey();
|
||||||
|
SimulatorElement<?> element = pair.getValue();
|
||||||
|
|
||||||
|
boolean wasNotPresent = positionCache.computeIfAbsent(element.getPosition(), __ -> new HashSet<>())
|
||||||
|
.add(element.getClass());
|
||||||
|
if (!wasNotPresent) return;
|
||||||
|
Material material = group.isDisabled() || element.isDisabled() ? element.getWorldDisabledMaterial() : element.getWorldMaterial();
|
||||||
|
Location location = element.getWorldPos().toLocation(WORLD);
|
||||||
|
RFallingBlockEntity rFallingBlockEntity = new RFallingBlockEntity(server, location, material);
|
||||||
|
rFallingBlockEntity.setNoGravity(true);
|
||||||
|
});
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized boolean show(Simulator sim, Player player) {
|
||||||
|
AtomicBoolean removed = new AtomicBoolean();
|
||||||
|
entityServers.forEach((simulator, rEntityServer) -> {
|
||||||
|
if (rEntityServer == null) return;
|
||||||
|
if (rEntityServer.getPlayers().contains(player) && sim != simulator) {
|
||||||
|
rEntityServer.removePlayer(player);
|
||||||
|
removed.set(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (sim == null) return removed.get();
|
||||||
|
entityServers.computeIfAbsent(sim, __ -> createSim(new REntityServer(), sim)).addPlayer(player);
|
||||||
|
return removed.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized List<REntity> getEntitiesOfSimulator(Simulator simulator) {
|
||||||
|
REntityServer entityServer = entityServers.get(simulator);
|
||||||
|
if (entityServer == null) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return entityServer.getEntities();
|
||||||
|
}
|
||||||
|
}
|
@ -1,279 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.simulator;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
|
||||||
import de.steamwar.bausystem.configplayer.Config;
|
|
||||||
import de.steamwar.bausystem.features.simulator.gui.TNTElementGUI;
|
|
||||||
import de.steamwar.bausystem.features.simulator.gui.TNTSimulatorGui;
|
|
||||||
import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement;
|
|
||||||
import de.steamwar.bausystem.features.simulator.tnt.TNTElement;
|
|
||||||
import de.steamwar.bausystem.features.simulator.tnt.TNTGroup;
|
|
||||||
import de.steamwar.bausystem.features.tracer.Recorder;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
|
||||||
import de.steamwar.bausystem.shared.Pair;
|
|
||||||
import de.steamwar.bausystem.utils.RayTraceUtils;
|
|
||||||
import de.steamwar.entity.REntity;
|
|
||||||
import de.steamwar.entity.REntityServer;
|
|
||||||
import de.steamwar.linkage.LinkedInstance;
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import yapion.hierarchy.types.YAPIONArray;
|
|
||||||
import yapion.hierarchy.types.YAPIONObject;
|
|
||||||
import yapion.hierarchy.types.YAPIONType;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
public class TNTSimulator {
|
|
||||||
|
|
||||||
private Set<Player> players = new HashSet<>();
|
|
||||||
private REntityServer entityServer = new REntityServer();
|
|
||||||
|
|
||||||
private Material material = Material.TNT;
|
|
||||||
|
|
||||||
private List<SimulatorElement> tntElementList = new ArrayList<>();
|
|
||||||
|
|
||||||
@LinkedInstance
|
|
||||||
public Recorder traceRecorder;
|
|
||||||
|
|
||||||
private Region autoTraceRegion;
|
|
||||||
|
|
||||||
public TNTSimulator() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public TNTSimulator(YAPIONObject yapionObject) {
|
|
||||||
material = Material.valueOf(yapionObject.getStringOrDefault("material", Material.TNT.name()));
|
|
||||||
YAPIONArray yapionArray = yapionObject.getArrayOrDefault("tntElements", new YAPIONArray());
|
|
||||||
for (YAPIONObject element : yapionArray.streamObject().collect(Collectors.toList())) {
|
|
||||||
if (element.containsKey("elements", YAPIONType.ARRAY)) {
|
|
||||||
tntElementList.add(new TNTGroup(element, entityServer));
|
|
||||||
} else {
|
|
||||||
tntElementList.add(new TNTElement(element, null, entityServer));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public YAPIONObject toYAPION() {
|
|
||||||
YAPIONObject yapionObject = new YAPIONObject();
|
|
||||||
yapionObject.add("material", material.name());
|
|
||||||
YAPIONArray yapionArray = new YAPIONArray();
|
|
||||||
for (SimulatorElement element : tntElementList) {
|
|
||||||
yapionArray.add(element.toYAPION());
|
|
||||||
}
|
|
||||||
yapionObject.add("tntElements", yapionArray);
|
|
||||||
return yapionObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void close() {
|
|
||||||
entityServer.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void show(Player player) {
|
|
||||||
if (!players.contains(player)) {
|
|
||||||
entityServer.addPlayer(player);
|
|
||||||
players.add(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hide(Player player) {
|
|
||||||
if (players.contains(player)) {
|
|
||||||
entityServer.removePlayer(player);
|
|
||||||
players.remove(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _hide(Player player) {
|
|
||||||
players.remove(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<REntity> getEntities() {
|
|
||||||
return tntElementList.stream().flatMap(element -> element.getEntities().stream()).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SimulatorElement> getEntity(REntity entity) {
|
|
||||||
List<SimulatorElement> tntSpawns = new ArrayList<>();
|
|
||||||
for (SimulatorElement spawn : tntElementList) {
|
|
||||||
spawn.getEntity(tntSpawns, entity);
|
|
||||||
}
|
|
||||||
return tntSpawns;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clear() {
|
|
||||||
new ArrayList<>(tntElementList).forEach(this::remove);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void remove(SimulatorElement element) {
|
|
||||||
if (element instanceof TNTElement) {
|
|
||||||
TNTElement tntElement = (TNTElement) element;
|
|
||||||
if (tntElement.hasParent()) {
|
|
||||||
tntElement.getParent().remove(tntElement);
|
|
||||||
if (tntElement.getParent().getElements().isEmpty()) {
|
|
||||||
remove(tntElement.getParent());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
element.remove(tntElement);
|
|
||||||
}
|
|
||||||
} else if (element instanceof TNTGroup) {
|
|
||||||
TNTGroup tntGroup = (TNTGroup) element;
|
|
||||||
tntGroup.getElements().forEach(tntElement -> {
|
|
||||||
tntElement.remove(tntElement);
|
|
||||||
});
|
|
||||||
tntGroup.getElements().clear();
|
|
||||||
}
|
|
||||||
element.close();
|
|
||||||
tntElementList.remove(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void change() {
|
|
||||||
tntElementList.forEach(simulatorElement -> {
|
|
||||||
simulatorElement.change();
|
|
||||||
if (simulatorElement instanceof TNTGroup) {
|
|
||||||
((TNTGroup) simulatorElement).getElements().forEach(SimulatorElement::change);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void edit(Player player, RayTraceUtils.RRayTraceResult result) {
|
|
||||||
if (result == null) {
|
|
||||||
TNTSimulatorGui.open(player, this, null, this::getTntElementList, null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SimulatorCursor.show(player, this, result);
|
|
||||||
|
|
||||||
if (result.getHitEntity() != null) {
|
|
||||||
List<SimulatorElement> elements = getEntity(result.getHitEntity());
|
|
||||||
if (elements.isEmpty()) return;
|
|
||||||
|
|
||||||
if (elements.size() == 1) {
|
|
||||||
TNTElementGUI.open(player, (TNTElement) elements.get(0), null);
|
|
||||||
} else {
|
|
||||||
List<TNTGroup> tntGroups = tntElementList.stream().filter(TNTGroup.class::isInstance).map(TNTGroup.class::cast).collect(Collectors.toList());
|
|
||||||
List<SimulatorElement> newElementList = new ArrayList<>();
|
|
||||||
for (TNTGroup tntGroup : tntGroups) {
|
|
||||||
if (new HashSet<>(elements).containsAll(tntGroup.getElements())) {
|
|
||||||
newElementList.add(tntGroup);
|
|
||||||
elements.removeAll(tntGroup.getElements());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
newElementList.addAll(elements);
|
|
||||||
if (newElementList.size() == 1) {
|
|
||||||
SimulatorElement element = newElementList.get(0);
|
|
||||||
if (element instanceof TNTGroup) {
|
|
||||||
TNTGroup tntGroup = (TNTGroup) element;
|
|
||||||
TNTSimulatorGui.open(player, null, tntGroup, () -> {
|
|
||||||
List<SimulatorElement> elementList = new ArrayList<>();
|
|
||||||
elementList.addAll(tntGroup.getElements());
|
|
||||||
return elementList;
|
|
||||||
}, null);
|
|
||||||
} else {
|
|
||||||
TNTElementGUI.open(player, (TNTElement) elements.get(0), null);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
TNTSimulatorGui.open(player, null, null, () -> newElementList, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SimulatorStorage.getSimulator(player.getInventory().getItemInOffHand()) != null && result.getHitPosition().distanceSquared(player.getLocation().toVector()) < 25) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TNTElement tntElement = new TNTElement(SimulatorCursor.getPos(player, result), null, entityServer);
|
|
||||||
tntElementList.add(tntElement);
|
|
||||||
TNTElementGUI.open(player, tntElement, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void start(Player p) {
|
|
||||||
Region region = Region.getRegion(p.getLocation());
|
|
||||||
Map<Integer, Map<Integer, Set<Pair<Runnable, Integer>>>> result = new HashMap<>();
|
|
||||||
boolean regionFrozen = false;
|
|
||||||
for (SimulatorElement element : tntElementList) {
|
|
||||||
regionFrozen |= element.locations(result, region, p.getLocation());
|
|
||||||
}
|
|
||||||
if (regionFrozen) {
|
|
||||||
BauSystem.MESSAGE.send("SIMULATOR_REGION_FROZEN", p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
AtomicBoolean needsAutoTrace = new AtomicBoolean();
|
|
||||||
players.forEach(player -> {
|
|
||||||
boolean simulatorAutoTrace = Config.getInstance().get(player).getPlainValueOrDefault("simulatorAutoTrace", false);
|
|
||||||
if (simulatorAutoTrace) {
|
|
||||||
needsAutoTrace.set(true);
|
|
||||||
player.performCommand("trace show");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (needsAutoTrace.get()) {
|
|
||||||
traceRecorder.startRecording(region);
|
|
||||||
autoTraceRegion = region;
|
|
||||||
}
|
|
||||||
|
|
||||||
AtomicInteger maxTick = new AtomicInteger(0);
|
|
||||||
Map<Integer, List<List<Pair<Runnable, Integer>>>> toSpawn = new HashMap<>();
|
|
||||||
result.forEach((integer, integerSetMap) -> {
|
|
||||||
List<Pair<Integer, Set<Pair<Runnable, Integer>>>> internal = new ArrayList<>();
|
|
||||||
integerSetMap.forEach((integer1, pairs) -> {
|
|
||||||
internal.add(new Pair<>(integer1, pairs));
|
|
||||||
});
|
|
||||||
internal.sort(Comparator.comparingInt(Pair::getKey));
|
|
||||||
|
|
||||||
toSpawn.put(integer, internal.stream().map(Pair::getValue).map(ArrayList::new).peek(Collections::shuffle).collect(Collectors.toList()));
|
|
||||||
|
|
||||||
if (maxTick.get() < integer) {
|
|
||||||
maxTick.set(integer);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
AtomicInteger currentTick = new AtomicInteger(0);
|
|
||||||
BauSystem.runTaskTimer(BauSystem.getInstance(), bukkitTask -> {
|
|
||||||
int tick = currentTick.get();
|
|
||||||
if (tick > maxTick.get()) {
|
|
||||||
traceRecorder.stopRecording(autoTraceRegion);
|
|
||||||
autoTraceRegion = null;
|
|
||||||
bukkitTask.cancel();
|
|
||||||
}
|
|
||||||
currentTick.incrementAndGet();
|
|
||||||
|
|
||||||
List<List<Pair<Runnable, Integer>>> toSpawnInTick = toSpawn.get(tick);
|
|
||||||
if (toSpawnInTick == null) return;
|
|
||||||
toSpawnInTick.forEach(pairs -> {
|
|
||||||
AtomicBoolean hasSomeLeft = new AtomicBoolean(true);
|
|
||||||
while(hasSomeLeft.get()) {
|
|
||||||
hasSomeLeft.set(false);
|
|
||||||
pairs.forEach(pair -> {
|
|
||||||
if (pair.getValue() > 0) {
|
|
||||||
hasSomeLeft.set(true);
|
|
||||||
pair.getKey().run();
|
|
||||||
pair.setValue(pair.getValue() - 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, 1, 1);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,130 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.simulator;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.bausystem.features.simulator.gui.SimulatorSelectionGUI;
|
|
||||||
import de.steamwar.bausystem.utils.ItemUtils;
|
|
||||||
import de.steamwar.bausystem.utils.RayTraceUtils;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.*;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
|
||||||
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class TNTSimulatorListener implements Listener {
|
|
||||||
|
|
||||||
private boolean permissionCheck(Player player) {
|
|
||||||
if (!Permission.hasPermission(player, Permission.WORLD)) {
|
|
||||||
BauSystem.MESSAGE.send("SIMULATOR_NO_PERMS", player);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static RayTraceUtils.RRayTraceResult trace(Player player, Location to, TNTSimulator simulator) {
|
|
||||||
return RayTraceUtils.traceREntity(player, to, simulator.getEntities());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerMove(PlayerMoveEvent e) {
|
|
||||||
if (ItemUtils.isItem(e.getPlayer().getInventory().getItemInMainHand(), "simulator")) {
|
|
||||||
simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInMainHand, e.getTo());
|
|
||||||
} else {
|
|
||||||
SimulatorCursor.hide(e.getPlayer());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerItemHeld(PlayerItemHeldEvent e) {
|
|
||||||
simulatorShowHide(e.getPlayer(), i -> i.getItem(e.getPreviousSlot()), i -> i.getItem(e.getNewSlot()), e.getPlayer().getLocation());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent e) {
|
|
||||||
simulatorShowHide(e.getPlayer(), i -> e.getItemDrop().getItemStack(), i -> null, e.getPlayer().getLocation());
|
|
||||||
}
|
|
||||||
|
|
||||||
private TNTSimulator simulatorShowHide(Player player, Function<PlayerInventory, ItemStack> oldItemFunction, Function<PlayerInventory, ItemStack> newItemFunction, Location location) {
|
|
||||||
TNTSimulator oldSimulator = SimulatorStorage.getSimulator(oldItemFunction.apply(player.getInventory()));
|
|
||||||
SimulatorCursor.hide(player, oldSimulator);
|
|
||||||
|
|
||||||
TNTSimulator simulator = SimulatorStorage.getSimulator(newItemFunction.apply(player.getInventory()));
|
|
||||||
if (simulator == null) return null;
|
|
||||||
|
|
||||||
SimulatorCursor.show(player, simulator, trace(player, location, simulator));
|
|
||||||
return simulator;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
|
||||||
if (ItemUtils.isItem(e.getPlayer().getInventory().getItemInMainHand(), "simulator")) {
|
|
||||||
simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInMainHand, e.getPlayer().getLocation());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
|
||||||
SimulatorCursor.hide(event.getPlayer(), null);
|
|
||||||
SimulatorStorage.getSimulatorNames().forEach(s -> {
|
|
||||||
SimulatorStorage.getSimulator(s)._hide(event.getPlayer());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
|
||||||
if (!ItemUtils.isItem(event.getItem(), "simulator")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
if (!permissionCheck(event.getPlayer())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
TNTSimulator simulator = SimulatorStorage.getSimulator(event.getItem());
|
|
||||||
|
|
||||||
switch (event.getAction()) {
|
|
||||||
case LEFT_CLICK_BLOCK:
|
|
||||||
case LEFT_CLICK_AIR:
|
|
||||||
if (simulator == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
simulator.start(event.getPlayer());
|
|
||||||
break;
|
|
||||||
case RIGHT_CLICK_BLOCK:
|
|
||||||
case RIGHT_CLICK_AIR:
|
|
||||||
if (simulator == null) {
|
|
||||||
SimulatorSelectionGUI.open(event.getPlayer(), event.getItem());
|
|
||||||
} else {
|
|
||||||
simulator.edit(event.getPlayer(), trace(event.getPlayer(), event.getPlayer().getLocation(), simulator));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.features.simulator.data;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.simulator.execute.SimulatorAction;
|
||||||
|
import de.steamwar.inventory.InvCallback;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public final class Simulator {
|
||||||
|
private Material material = Material.BARREL;
|
||||||
|
private final String name;
|
||||||
|
private boolean autoTrace = false;
|
||||||
|
private final List<SimulatorGroup> groups = new ArrayList<>();
|
||||||
|
|
||||||
|
public void move(int x, int y, int z) {
|
||||||
|
groups.forEach(simulatorGroup -> {
|
||||||
|
simulatorGroup.move(x, y, z);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public SWItem toItem(Player player, InvCallback invCallback) {
|
||||||
|
return new SWItem(material, "§e" + name, invCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toSimulatorActions(BiConsumer<Integer, SimulatorAction> tickStart, BiConsumer<Integer, SimulatorAction> tickEnd) {
|
||||||
|
groups.forEach(simulatorGroup -> {
|
||||||
|
simulatorGroup.toSimulatorActions(tickStart, tickEnd);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public Simulator add(SimulatorGroup group) {
|
||||||
|
groups.add(group);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.features.simulator.data;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
public abstract class SimulatorBlockAlignedElement<T extends SimulatorPhase> extends SimulatorElement<T> {
|
||||||
|
|
||||||
|
protected SimulatorBlockAlignedElement(Material material, Vector position) {
|
||||||
|
super(material, position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final boolean canBeInGroup(SimulatorGroup simulatorGroup) {
|
||||||
|
return simulatorGroup.getElements().stream().allMatch(SimulatorBlockAlignedElement.class::isInstance);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.features.simulator.data;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.simulator.execute.SimulatorAction;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||||
|
import de.steamwar.inventory.InvCallback;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
import yapion.hierarchy.types.YAPIONObject;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public abstract class SimulatorElement<T extends SimulatorPhase> {
|
||||||
|
protected Material material;
|
||||||
|
protected final Vector position;
|
||||||
|
protected boolean disabled = false;
|
||||||
|
protected final List<T> phases = new ArrayList<>();
|
||||||
|
|
||||||
|
protected SimulatorElement(Material material, Vector position) {
|
||||||
|
this.material = material;
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimulatorElement<T> add(T setting) {
|
||||||
|
phases.add(setting);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sort() {
|
||||||
|
phases.sort(Comparator.comparingInt(SimulatorPhase::getTickOffset));
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract String getName(Player player);
|
||||||
|
|
||||||
|
public int getBaseTick() {
|
||||||
|
return phases.stream()
|
||||||
|
.mapToInt(value -> value.tickOffset)
|
||||||
|
.min()
|
||||||
|
.orElse(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void changeBaseTicks(int tick) {
|
||||||
|
phases.forEach(t -> {
|
||||||
|
t.tickOffset += tick;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void move(double x, double y, double z) {
|
||||||
|
position.setX(position.getX() + x);
|
||||||
|
position.setY(position.getY() + y);
|
||||||
|
position.setZ(position.getZ() + z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Material getWorldMaterial();
|
||||||
|
|
||||||
|
public abstract Material getWorldDisabledMaterial();
|
||||||
|
|
||||||
|
public abstract boolean canBeInGroup(SimulatorGroup simulatorGroup);
|
||||||
|
|
||||||
|
public Vector getWorldPos() {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SWItem toItem(Player player, InvCallback invCallback) {
|
||||||
|
List<String> lore = new ArrayList<>();
|
||||||
|
lore.add("§7Phase count§8:§e " + phases.size());
|
||||||
|
lore.add("§7Tick§8:§e " + getBaseTick());
|
||||||
|
lore.add("");
|
||||||
|
lore.add("§7X§8:§e " + position.getX());
|
||||||
|
lore.add("§7Y§8:§e " + position.getY());
|
||||||
|
lore.add("§7Z§8:§e " + position.getZ());
|
||||||
|
if (disabled) {
|
||||||
|
lore.add("");
|
||||||
|
lore.add("§cDisabled");
|
||||||
|
}
|
||||||
|
return new SWItem(material, "§e" + getName(player), lore, disabled, invCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toSimulatorActions(BiConsumer<Integer, SimulatorAction> tickStart, BiConsumer<Integer, SimulatorAction> tickEnd) {
|
||||||
|
if (disabled) return;
|
||||||
|
phases.forEach(phase -> {
|
||||||
|
phase.toSimulatorActions(position.clone(), tickStart, tickEnd);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void open(Player player, Simulator simulator, SimulatorGroup group, SimulatorBaseGui back);
|
||||||
|
|
||||||
|
public SimulatorGroup getGroup(Simulator simulator) {
|
||||||
|
return simulator.getGroups().stream()
|
||||||
|
.filter(simulatorGroup -> simulatorGroup.getElements().contains(this))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract String getType();
|
||||||
|
public void saveExtra(YAPIONObject elementObject) {}
|
||||||
|
public void loadExtra(YAPIONObject elementObject) {}
|
||||||
|
}
|
@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.features.simulator.data;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.simulator.execute.SimulatorAction;
|
||||||
|
import de.steamwar.inventory.InvCallback;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public final class SimulatorGroup {
|
||||||
|
private Material material = Material.CHEST;
|
||||||
|
private boolean disabled = false;
|
||||||
|
private final List<SimulatorElement<?>> elements = new ArrayList<>();
|
||||||
|
|
||||||
|
public SimulatorGroup add(SimulatorElement<?> element) {
|
||||||
|
if (!elements.contains(element)) {
|
||||||
|
elements.add(element);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sort() {
|
||||||
|
elements.sort(Comparator.comparingInt(SimulatorElement::getBaseTick));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBaseTick() {
|
||||||
|
return elements.stream()
|
||||||
|
.mapToInt(SimulatorElement::getBaseTick)
|
||||||
|
.min()
|
||||||
|
.orElse(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void changeBaseTicks(int tick) {
|
||||||
|
elements.forEach(simulatorElement -> {
|
||||||
|
simulatorElement.changeBaseTicks(tick);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void move(double x, double y, double z) {
|
||||||
|
elements.forEach(simulatorElement -> {
|
||||||
|
simulatorElement.move(x, y, z);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public SWItem toItem(Player player, InvCallback groupCallback, InvCallback itemCallback) {
|
||||||
|
if (elements.size() == 1) {
|
||||||
|
return elements.get(0).toItem(player, itemCallback);
|
||||||
|
} else {
|
||||||
|
List<String> lore = new ArrayList<>();
|
||||||
|
lore.add("§7Element count§8:§e " + elements.size());
|
||||||
|
lore.add("§7Tick§8:§e " + getBaseTick());
|
||||||
|
if (disabled) {
|
||||||
|
lore.add("");
|
||||||
|
lore.add("§cDisabled");
|
||||||
|
}
|
||||||
|
return new SWItem(material != null ? material : Material.ENDER_CHEST, "§eGroup", lore, disabled, groupCallback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toSimulatorActions(BiConsumer<Integer, SimulatorAction> tickStart, BiConsumer<Integer, SimulatorAction> tickEnd) {
|
||||||
|
if (disabled) return;
|
||||||
|
elements.forEach(simulatorElement -> {
|
||||||
|
simulatorElement.toSimulatorActions(tickStart, tickEnd);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.features.simulator.data;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.simulator.execute.SimulatorAction;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
import yapion.hierarchy.types.YAPIONObject;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public abstract class SimulatorPhase {
|
||||||
|
public static final int ORDER_LIMIT = 30;
|
||||||
|
|
||||||
|
protected int tickOffset = 0;
|
||||||
|
protected int lifetime = 80;
|
||||||
|
protected int order = 0;
|
||||||
|
|
||||||
|
public abstract void toSimulatorActions(Vector position, BiConsumer<Integer, SimulatorAction> tickStart, BiConsumer<Integer, SimulatorAction> tickEnd);
|
||||||
|
public void saveExtra(YAPIONObject phaseObject) {}
|
||||||
|
public void loadExtra(YAPIONObject phaseObject) {}
|
||||||
|
}
|
@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.features.simulator.data.observer;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorBlockAlignedElement;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorPhase;
|
||||||
|
import de.steamwar.bausystem.features.simulator.execute.SimulatorAction;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.SimulatorObserverGui;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
public final class ObserverElement extends SimulatorBlockAlignedElement<ObserverPhase> {
|
||||||
|
|
||||||
|
public ObserverElement(Vector position) {
|
||||||
|
super(Material.OBSERVER, position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName(Player player) {
|
||||||
|
return "Observer";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Material getWorldMaterial() {
|
||||||
|
return Material.OBSERVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Material getWorldDisabledMaterial() {
|
||||||
|
return Material.GRAY_STAINED_GLASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toSimulatorActions(BiConsumer<Integer, SimulatorAction> tickStart, BiConsumer<Integer, SimulatorAction> tickEnd) {
|
||||||
|
if (disabled) return;
|
||||||
|
phases.forEach(phase -> {
|
||||||
|
phase.toSimulatorActions(position.clone(), tickStart, tickEnd);
|
||||||
|
});
|
||||||
|
|
||||||
|
int end = phases.stream().mapToInt(SimulatorPhase::getTickOffset).max().orElse(0) + 4;
|
||||||
|
AtomicReference<BlockState> blockState = new AtomicReference<>();
|
||||||
|
tickStart.accept(0, new SimulatorAction(-100, 1) {
|
||||||
|
@Override
|
||||||
|
public void accept(World world) {
|
||||||
|
Block block = world.getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||||
|
blockState.set(block.getState());
|
||||||
|
block.setType(Material.OBSERVER, false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tickEnd.accept(end, new SimulatorAction(0, 1) {
|
||||||
|
@Override
|
||||||
|
public void accept(World world) {
|
||||||
|
BlockState oldState = blockState.get();
|
||||||
|
if (oldState != null) {
|
||||||
|
oldState.update(true, true);
|
||||||
|
} else {
|
||||||
|
Block block = world.getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||||
|
block.setType(Material.AIR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void open(Player player, Simulator simulator, SimulatorGroup group, SimulatorBaseGui back) {
|
||||||
|
new SimulatorObserverGui(player, simulator, group, this, back).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "Observer";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.features.simulator.data.observer;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorPhase;
|
||||||
|
import de.steamwar.bausystem.features.simulator.execute.SimulatorAction;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.block.data.type.Observer;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
import yapion.hierarchy.types.YAPIONObject;
|
||||||
|
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
public final class ObserverPhase extends SimulatorPhase {
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private BlockFace orientation = BlockFace.UP;
|
||||||
|
|
||||||
|
public ObserverPhase(int tickOffset) {
|
||||||
|
this.tickOffset = tickOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
this.lifetime = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toSimulatorActions(Vector position, BiConsumer<Integer, SimulatorAction> tickStart, BiConsumer<Integer, SimulatorAction> tickEnd) {
|
||||||
|
Observer observer = (Observer) Material.OBSERVER.createBlockData();
|
||||||
|
observer.setFacing(orientation.getOppositeFace());
|
||||||
|
observer.setPowered(true);
|
||||||
|
|
||||||
|
tickStart.accept(tickOffset, new SimulatorAction(order, 1) {
|
||||||
|
@Override
|
||||||
|
public void accept(World world) {
|
||||||
|
Block block = world.getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||||
|
Block updateBlock = block.getRelative(orientation);
|
||||||
|
BlockState state = updateBlock.getState();
|
||||||
|
updateBlock.setType(Material.SPONGE, true);
|
||||||
|
block.setBlockData(observer, true);
|
||||||
|
state.update(true, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveExtra(YAPIONObject phaseObject) {
|
||||||
|
phaseObject.add("orientation", orientation.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadExtra(YAPIONObject phaseObject) {
|
||||||
|
orientation = BlockFace.valueOf(phaseObject.getPlainValue("orientation"));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.features.simulator.data.redstone;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorBlockAlignedElement;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.SimulatorRedstoneGui;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
public final class RedstoneElement extends SimulatorBlockAlignedElement<RedstonePhase> {
|
||||||
|
|
||||||
|
public RedstoneElement(Vector position) {
|
||||||
|
super(Material.REDSTONE_BLOCK, position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName(Player player) {
|
||||||
|
return "Redstone";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Material getWorldMaterial() {
|
||||||
|
return Material.REDSTONE_BLOCK;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Material getWorldDisabledMaterial() {
|
||||||
|
return Material.WHITE_STAINED_GLASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vector getWorldPos() {
|
||||||
|
return position.clone().add(new Vector(0.5, 0, 0.5));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void open(Player player, Simulator simulator, SimulatorGroup group, SimulatorBaseGui back) {
|
||||||
|
new SimulatorRedstoneGui(player, simulator, group, this, back).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "Redstone";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.features.simulator.data.redstone;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorPhase;
|
||||||
|
import de.steamwar.bausystem.features.simulator.execute.SimulatorAction;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
public final class RedstonePhase extends SimulatorPhase {
|
||||||
|
|
||||||
|
public RedstonePhase(int tickOffset) {
|
||||||
|
this.tickOffset = tickOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
this.lifetime = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toSimulatorActions(Vector position, BiConsumer<Integer, SimulatorAction> tickStart, BiConsumer<Integer, SimulatorAction> tickEnd) {
|
||||||
|
AtomicReference<BlockState> blockState = new AtomicReference<>();
|
||||||
|
tickStart.accept(tickOffset, new SimulatorAction(order, 1) {
|
||||||
|
@Override
|
||||||
|
public void accept(World world) {
|
||||||
|
Block block = world.getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||||
|
blockState.set(block.getState());
|
||||||
|
block.setType(Material.REDSTONE_BLOCK);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tickStart.accept(tickOffset + lifetime, new SimulatorAction(ORDER_LIMIT + 1, 1) {
|
||||||
|
@Override
|
||||||
|
public void accept(World world) {
|
||||||
|
BlockState state = blockState.get();
|
||||||
|
if (state != null) {
|
||||||
|
state.update(true, true);
|
||||||
|
} else {
|
||||||
|
Block block = world.getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||||
|
block.setType(Material.AIR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.features.simulator.data.tnt;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.SimulatorTNTGui;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||||
|
import de.steamwar.inventory.InvCallback;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
public final class TNTElement extends SimulatorElement<TNTPhase> {
|
||||||
|
|
||||||
|
public TNTElement(Vector position) {
|
||||||
|
super(Material.TNT, position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName(Player player) {
|
||||||
|
return "TNT";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void move(double x, double y, double z) {
|
||||||
|
position.setX(position.getX() + x);
|
||||||
|
position.setY(position.getY() + y);
|
||||||
|
position.setZ(position.getZ() + z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void align(Vector offset) {
|
||||||
|
if (offset.getX() != 0) {
|
||||||
|
if (position.getX() - (int) position.getX() == 0.49) {
|
||||||
|
position.setX(position.getX() + 0.02);
|
||||||
|
}
|
||||||
|
if (position.getX() - (int) position.getX() == -0.49) {
|
||||||
|
position.setX(position.getX() - 0.02);
|
||||||
|
}
|
||||||
|
position.setX(position.getBlockX() + offset.getX());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (offset.getZ() != 0) {
|
||||||
|
if (position.getZ() - (int) position.getZ() == 0.49) {
|
||||||
|
position.setZ(position.getZ() + 0.02);
|
||||||
|
}
|
||||||
|
if (position.getZ() - (int) position.getZ() == -0.49) {
|
||||||
|
position.setZ(position.getZ() - 0.02);
|
||||||
|
}
|
||||||
|
position.setZ(position.getBlockZ() + offset.getZ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SWItem toItem(Player player, InvCallback invCallback) {
|
||||||
|
long sum = phases.stream().mapToInt(TNTPhase::getCount).sum();
|
||||||
|
SWItem swItem = super.toItem(player, invCallback);
|
||||||
|
swItem.getItemStack().setAmount((int) Math.min(64, Math.max(1, sum)));
|
||||||
|
swItem.setName("§e" + getName(player) + "§8:§7 " + sum);
|
||||||
|
return swItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Material getWorldMaterial() {
|
||||||
|
return Material.TNT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Material getWorldDisabledMaterial() {
|
||||||
|
return Material.RED_STAINED_GLASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canBeInGroup(SimulatorGroup simulatorGroup) {
|
||||||
|
return simulatorGroup.getElements().stream().allMatch(TNTElement.class::isInstance);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void open(Player player, Simulator simulator, SimulatorGroup group, SimulatorBaseGui back) {
|
||||||
|
new SimulatorTNTGui(player, simulator, this, group, back).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "TNT";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.features.simulator.data.tnt;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorPhase;
|
||||||
|
import de.steamwar.bausystem.features.simulator.execute.SimulatorAction;
|
||||||
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
|
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.TNTPrimed;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
import yapion.hierarchy.types.YAPIONObject;
|
||||||
|
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
public final class TNTPhase extends SimulatorPhase {
|
||||||
|
private int count = 1;
|
||||||
|
private boolean xJump = false;
|
||||||
|
private boolean yJump = false;
|
||||||
|
private boolean zJump = false;
|
||||||
|
|
||||||
|
public TNTPhase(int tickOffset) {
|
||||||
|
this.tickOffset = tickOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasJump() {
|
||||||
|
return xJump || yJump || zJump;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJump(boolean jump) {
|
||||||
|
xJump = jump;
|
||||||
|
yJump = jump;
|
||||||
|
zJump = jump;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toSimulatorActions(Vector position, BiConsumer<Integer, SimulatorAction> tickStart, BiConsumer<Integer, SimulatorAction> tickEnd) {
|
||||||
|
tickStart.accept(tickOffset, new SimulatorAction(order, count) {
|
||||||
|
@Override
|
||||||
|
public void accept(World world) {
|
||||||
|
Location location = position.toLocation(world);
|
||||||
|
if (Region.getRegion(location).get(Flag.FREEZE) == FreezeMode.ACTIVE) return;
|
||||||
|
TNTPrimed tnt = world.spawn(location, TNTPrimed.class);
|
||||||
|
if (!xJump) tnt.setVelocity(tnt.getVelocity().setX(0));
|
||||||
|
if (!yJump) tnt.setVelocity(tnt.getVelocity().setY(0));
|
||||||
|
if (!zJump) tnt.setVelocity(tnt.getVelocity().setZ(0));
|
||||||
|
tnt.setFuseTicks(lifetime);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tickEnd.accept(tickOffset + lifetime, new SimulatorAction(0, 1) {
|
||||||
|
@Override
|
||||||
|
public void accept(World world) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveExtra(YAPIONObject phaseObject) {
|
||||||
|
phaseObject.add("count", count);
|
||||||
|
phaseObject.add("xJump", xJump);
|
||||||
|
phaseObject.add("yJump", yJump);
|
||||||
|
phaseObject.add("zJump", zJump);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadExtra(YAPIONObject phaseObject) {
|
||||||
|
count = phaseObject.getPlainValue("count");
|
||||||
|
xJump = phaseObject.getPlainValue("xJump");
|
||||||
|
yJump = phaseObject.getPlainValue("yJump");
|
||||||
|
zJump = phaseObject.getPlainValue("zJump");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.features.simulator.execute;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public abstract class SimulatorAction implements Consumer<World> {
|
||||||
|
private int order;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private int count;
|
||||||
|
}
|
@ -0,0 +1,127 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.features.simulator.execute;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||||
|
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
||||||
|
import de.steamwar.bausystem.features.tracer.record.Recorder;
|
||||||
|
import de.steamwar.bausystem.features.tracer.record.SingleTraceRecorder;
|
||||||
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
import de.steamwar.bausystem.utils.TickEndEvent;
|
||||||
|
import de.steamwar.bausystem.utils.TickStartEvent;
|
||||||
|
import de.steamwar.linkage.Linked;
|
||||||
|
import de.steamwar.linkage.MinVersion;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
|
@Linked
|
||||||
|
@MinVersion(19)
|
||||||
|
public class SimulatorExecutor implements Listener {
|
||||||
|
|
||||||
|
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||||
|
private static Set<Simulator> currentlyRunning = new HashSet<>();
|
||||||
|
private static Map<Long, Map<Integer, List<SimulatorAction>>> tickStartActions = new HashMap<>();
|
||||||
|
private static Map<Long, List<SimulatorAction>> tickEndActions = new HashMap<>();
|
||||||
|
|
||||||
|
public static boolean run(Simulator simulator) {
|
||||||
|
if (currentlyRunning.contains(simulator)) return false;
|
||||||
|
currentlyRunning.add(simulator);
|
||||||
|
|
||||||
|
long currentTick = TPSUtils.currentRealTick.get();
|
||||||
|
AtomicLong lastTick = new AtomicLong();
|
||||||
|
simulator.toSimulatorActions((tickOffset, simulatorAction) -> {
|
||||||
|
lastTick.set(Math.max(lastTick.get(), tickOffset));
|
||||||
|
tickStartActions.computeIfAbsent(currentTick + tickOffset, __ -> new HashMap<>())
|
||||||
|
.computeIfAbsent(simulatorAction.getOrder(), __ -> new ArrayList<>())
|
||||||
|
.add(simulatorAction);
|
||||||
|
}, (tickOffset, simulatorAction) -> {
|
||||||
|
lastTick.set(Math.max(lastTick.get(), tickOffset));
|
||||||
|
tickEndActions.computeIfAbsent(currentTick + tickOffset, __ -> new ArrayList<>())
|
||||||
|
.add(simulatorAction);
|
||||||
|
});
|
||||||
|
|
||||||
|
tickEndActions.computeIfAbsent(currentTick + lastTick.get() + 4, __ -> new ArrayList<>())
|
||||||
|
.add(new SimulatorAction(0, 1) {
|
||||||
|
@Override
|
||||||
|
public void accept(World world) {
|
||||||
|
currentlyRunning.remove(simulator);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (simulator.isAutoTrace()) {
|
||||||
|
simulator.getGroups()
|
||||||
|
.stream()
|
||||||
|
.map(SimulatorGroup::getElements)
|
||||||
|
.flatMap(List::stream)
|
||||||
|
.map(SimulatorElement::getPosition)
|
||||||
|
.map(pos -> pos.toLocation(WORLD))
|
||||||
|
.map(Region::getRegion)
|
||||||
|
.distinct()
|
||||||
|
.forEach(region -> {
|
||||||
|
if (Recorder.INSTANCE.isDisabled(region)) {
|
||||||
|
Recorder.INSTANCE.set(region, new SingleTraceRecorder(region));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onTickStart(TickStartEvent event) {
|
||||||
|
long currentTick = TPSUtils.currentRealTick.get();
|
||||||
|
Map<Integer, List<SimulatorAction>> actionsToRun = tickStartActions.remove(currentTick);
|
||||||
|
if (actionsToRun == null) return;
|
||||||
|
|
||||||
|
List<Integer> keys = new ArrayList<>(actionsToRun.keySet());
|
||||||
|
keys.sort(null);
|
||||||
|
for (int actionKey : keys) {
|
||||||
|
runActions(actionsToRun.get(actionKey));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onTickEnd(TickEndEvent event) {
|
||||||
|
long currentTick = TPSUtils.currentRealTick.get() - 1;
|
||||||
|
List<SimulatorAction> actionsToRun = tickEndActions.remove(currentTick);
|
||||||
|
if (actionsToRun == null) return;
|
||||||
|
runActions(actionsToRun);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runActions(List<SimulatorAction> actionsToRun) {
|
||||||
|
while (!actionsToRun.isEmpty()) {
|
||||||
|
Collections.shuffle(actionsToRun);
|
||||||
|
for (int i = actionsToRun.size() - 1 ; i >= 0; i--) {
|
||||||
|
SimulatorAction action = actionsToRun.get(i);
|
||||||
|
action.accept(WORLD);
|
||||||
|
action.setCount(action.getCount() - 1);
|
||||||
|
if (action.getCount() == 0) {
|
||||||
|
actionsToRun.remove(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.simulator.gui;
|
|
||||||
|
|
||||||
import de.steamwar.inventory.SWItem;
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@UtilityClass
|
|
||||||
public class ItemUtils {
|
|
||||||
|
|
||||||
public static SWItem unique(SWItem swItem) {
|
|
||||||
ItemMeta itemMeta = swItem.getItemMeta();
|
|
||||||
itemMeta.getPersistentDataContainer().set(NamespacedKey.minecraft(UUID.randomUUID().toString()), PersistentDataType.INTEGER, 0);
|
|
||||||
swItem.setItemMeta(itemMeta);
|
|
||||||
return swItem;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.features.simulator.gui;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
||||||
|
import de.steamwar.inventory.InvCallback;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class SimulatorGroupChooserGui extends SimulatorPageGui<SimulatorGroup> {
|
||||||
|
|
||||||
|
private final SimulatorElement<?> subject;
|
||||||
|
private final SimulatorGroup parent;
|
||||||
|
private final SimulatorBaseGui back;
|
||||||
|
|
||||||
|
public SimulatorGroupChooserGui(Player player, Simulator simulator, SimulatorElement<?> subject, SimulatorGroup parent, SimulatorBaseGui back) {
|
||||||
|
super(player, simulator, 6 * 9, simulator.getGroups().stream().filter(e -> e != parent).filter(e -> subject.canBeInGroup(e)).collect(Collectors.toList()));
|
||||||
|
this.subject = subject;
|
||||||
|
this.parent = parent;
|
||||||
|
this.back = back;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void headerAndFooter() {
|
||||||
|
inventory.setItem(4, new SWItem(simulator.getMaterial(), "§e" + simulator.getName(), clickType -> {
|
||||||
|
}));
|
||||||
|
if (parent.getElements().size() != 1) {
|
||||||
|
inventory.setItem(49, new SWItem(Material.BARRIER, "§cRemove from Group", clickType -> {
|
||||||
|
SimulatorGroup newParent = new SimulatorGroup();
|
||||||
|
newParent.add(subject);
|
||||||
|
simulator.getGroups().add(newParent);
|
||||||
|
parent.getElements().remove(subject);
|
||||||
|
back.open();
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
if (parent.getElements().size() == 1) {
|
||||||
|
parent.setDisabled(false);
|
||||||
|
parent.setMaterial(Material.BARREL);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
inventory.addCloseCallback(clickType -> {
|
||||||
|
back.open();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String baseTitle() {
|
||||||
|
return "Choose Group";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SWItem convert(SimulatorGroup simulatorGroup) {
|
||||||
|
InvCallback invCallback = clickType -> {
|
||||||
|
simulatorGroup.add(subject);
|
||||||
|
parent.getElements().remove(subject);
|
||||||
|
if (parent.getElements().size() == 1) {
|
||||||
|
parent.setDisabled(false);
|
||||||
|
parent.setMaterial(Material.BARREL);
|
||||||
|
}
|
||||||
|
back.open();
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
};
|
||||||
|
return simulatorGroup.toItem(player, invCallback, invCallback);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.features.simulator.gui;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class SimulatorGroupGui extends SimulatorPageGui<SimulatorElement<?>> {
|
||||||
|
|
||||||
|
private SimulatorGroup simulatorGroup;
|
||||||
|
private final SimulatorBaseGui back;
|
||||||
|
|
||||||
|
public SimulatorGroupGui(Player player, Simulator simulator, SimulatorGroup simulatorGroup, SimulatorBaseGui back) {
|
||||||
|
super(player, simulator, 6 * 9, simulatorGroup.getElements());
|
||||||
|
this.simulatorGroup = simulatorGroup;
|
||||||
|
this.back = back;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String baseTitle() {
|
||||||
|
return "Group";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void headerAndFooter() {
|
||||||
|
if (simulatorGroup.getMaterial() == null) {
|
||||||
|
List<SimulatorGroup> parents = data.stream().map(e -> e.getGroup(simulator)).distinct().collect(Collectors.toList());
|
||||||
|
if (parents.size() == 1) {
|
||||||
|
simulatorGroup = parents.get(0);
|
||||||
|
data = simulatorGroup.getElements();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (simulatorGroup.getElements().removeIf(element -> element.getPhases().isEmpty())) {
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
}
|
||||||
|
if (simulatorGroup.getElements().size() < 2) {
|
||||||
|
back.open();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
simulatorGroup.sort();
|
||||||
|
|
||||||
|
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||||
|
back.open();
|
||||||
|
}));
|
||||||
|
|
||||||
|
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
||||||
|
simulatorGroup.getElements().clear();
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
}));
|
||||||
|
|
||||||
|
inventory.setItem(4, simulatorGroup.toItem(player, clickType -> {
|
||||||
|
if (simulatorGroup.getMaterial() == null) return;
|
||||||
|
new SimulatorMaterialGui(player, simulator, simulatorGroup::getMaterial, simulatorGroup::setMaterial, this).open();
|
||||||
|
}, clickType -> {
|
||||||
|
}));
|
||||||
|
|
||||||
|
inventory.setItem(48, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
||||||
|
new SimulatorGroupSettingsGui(player, simulator, simulatorGroup, this).open();
|
||||||
|
}));
|
||||||
|
boolean disabled = simulatorGroup.getMaterial() == null ? simulatorGroup.getElements().stream().allMatch(SimulatorElement::isDisabled) : simulatorGroup.isDisabled();
|
||||||
|
inventory.setItem(50, new SWItem(disabled ? Material.ENDER_PEARL : Material.ENDER_EYE, simulatorGroup.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
|
||||||
|
if (simulatorGroup.getMaterial() == null) {
|
||||||
|
simulatorGroup.getElements().forEach(simulatorElement -> {
|
||||||
|
simulatorElement.setDisabled(!disabled);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
simulatorGroup.setDisabled(!disabled);
|
||||||
|
}
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SWItem convert(SimulatorElement<?> element) {
|
||||||
|
return element.toItem(player, clickType -> {
|
||||||
|
element.open(player, simulator, simulatorGroup, this);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,173 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.features.simulator.gui;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
||||||
|
|
||||||
|
private final SimulatorGroup simulatorGroup;
|
||||||
|
private final SimulatorBaseGui back;
|
||||||
|
|
||||||
|
public SimulatorGroupSettingsGui(Player player, Simulator simulator, SimulatorGroup simulatorGroup, SimulatorBaseGui back) {
|
||||||
|
super(player, simulator, 5 * 9);
|
||||||
|
this.simulatorGroup = simulatorGroup;
|
||||||
|
this.back = back;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String title() {
|
||||||
|
return "Group";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void populate() {
|
||||||
|
if (simulatorGroup.getElements().size() < 2) {
|
||||||
|
back.open();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Back Arrow
|
||||||
|
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||||
|
back.open();
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Material Chooser
|
||||||
|
inventory.setItem(4, simulatorGroup.toItem(player, clickType -> {
|
||||||
|
if (simulatorGroup.getMaterial() == null) return;
|
||||||
|
new SimulatorMaterialGui(player, simulator, simulatorGroup::getMaterial, simulatorGroup::setMaterial, this).open();
|
||||||
|
}, clickType -> {
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Base Tick
|
||||||
|
int baseTicks = simulatorGroup.getBaseTick();
|
||||||
|
inventory.setItem(9, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||||
|
simulatorGroup.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
});
|
||||||
|
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
|
||||||
|
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
|
||||||
|
if (integer < 0) return false;
|
||||||
|
simulatorGroup.changeBaseTicks(integer - baseTicks);
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
return true;
|
||||||
|
}, this).setItem(Material.REPEATER).open();
|
||||||
|
});
|
||||||
|
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
|
||||||
|
inventory.setItem(18, baseTick);
|
||||||
|
inventory.setItem(27, SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||||
|
if (baseTicks - (clickType.isShiftClick() ? 5 : 1) < 0) {
|
||||||
|
simulatorGroup.changeBaseTicks(-baseTicks);
|
||||||
|
} else {
|
||||||
|
simulatorGroup.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
|
||||||
|
}
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
});
|
||||||
|
|
||||||
|
boolean allTNT = simulatorGroup.getElements().stream().allMatch(TNTElement.class::isInstance);
|
||||||
|
|
||||||
|
if (allTNT) {
|
||||||
|
// Subpixel Alignment
|
||||||
|
inventory.setItem(21, new SWItem(Material.SUNFLOWER, "§7Align§8: §eCenter", clickType -> {
|
||||||
|
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tnt -> {
|
||||||
|
tnt.align(new Vector(0.5, 0, 0.5));
|
||||||
|
});
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Z
|
||||||
|
inventory.setItem(20, new SWItem(Material.OAK_BUTTON, "§7Align§8: §eNegativ Z", clickType -> {
|
||||||
|
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tnt -> {
|
||||||
|
tnt.align(new Vector(0, 0, 0.49));
|
||||||
|
});
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
}));
|
||||||
|
|
||||||
|
inventory.setItem(22, new SWItem(Material.OAK_BUTTON, "§7Align§8: §ePositiv Z", clickType -> {
|
||||||
|
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tnt -> {
|
||||||
|
tnt.align(new Vector(0, 0, 0.51));
|
||||||
|
});
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
}));
|
||||||
|
|
||||||
|
// X
|
||||||
|
inventory.setItem(12, new SWItem(Material.STONE_BUTTON, "§7Align§8: §eNegativ X", clickType -> {
|
||||||
|
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tnt -> {
|
||||||
|
tnt.align(new Vector(0.49, 0, 0));
|
||||||
|
});
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
}));
|
||||||
|
|
||||||
|
inventory.setItem(30, new SWItem(Material.STONE_BUTTON, "§7Align§8: §ePositiv X", clickType -> {
|
||||||
|
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tnt -> {
|
||||||
|
tnt.align(new Vector(0.51, 0, 0));
|
||||||
|
});
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Pos X
|
||||||
|
inventory.setItem(15, SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
||||||
|
simulatorGroup.move(clickType.isShiftClick() ? (allTNT ? 0.0625 : 5) : 1, 0, 0);
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
});
|
||||||
|
inventory.setItem(24, new SWItem(Material.PAPER, "§eX", clickType -> {
|
||||||
|
}));
|
||||||
|
inventory.setItem(33, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||||
|
simulatorGroup.move(clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0, 0);
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
});
|
||||||
|
|
||||||
|
//Pos Y
|
||||||
|
inventory.setItem(16, SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
||||||
|
simulatorGroup.move(0, clickType.isShiftClick() ? (allTNT ? 0.0625 : 5) : 1, 0);
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
});
|
||||||
|
inventory.setItem(25, new SWItem(Material.PAPER, "§eY", clickType -> {
|
||||||
|
}));
|
||||||
|
inventory.setItem(34, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||||
|
simulatorGroup.move(0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0);
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
});
|
||||||
|
|
||||||
|
//Pos Z
|
||||||
|
inventory.setItem(17, SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
||||||
|
simulatorGroup.move(0, 0, clickType.isShiftClick() ? (allTNT ? 0.0625 : 5) : 1);
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
});
|
||||||
|
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ", clickType -> {
|
||||||
|
}));
|
||||||
|
inventory.setItem(35, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||||
|
simulatorGroup.move(0, 0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1);
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.features.simulator.gui;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class SimulatorGui extends SimulatorPageGui<SimulatorGroup> {
|
||||||
|
|
||||||
|
public SimulatorGui(Player player, Simulator simulator) {
|
||||||
|
super(player, simulator, 6 * 9, simulator.getGroups());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String baseTitle() {
|
||||||
|
return "Simulator - " + simulator.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void headerAndFooter() {
|
||||||
|
if (simulator.getGroups().removeIf(element -> element.getElements().isEmpty() || element.getElements().stream().allMatch(simulatorElement -> simulatorElement.getPhases().isEmpty()))) {
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
}
|
||||||
|
|
||||||
|
inventory.setItem(4, simulator.toItem(player, clickType -> {
|
||||||
|
new SimulatorMaterialGui(player, simulator, simulator::getMaterial, simulator::setMaterial, this).open();
|
||||||
|
}));
|
||||||
|
inventory.setItem(49, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
||||||
|
new SimulatorSettingsGui(player, simulator, this).open();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SWItem convert(SimulatorGroup simulatorGroup) {
|
||||||
|
return simulatorGroup.toItem(player, clickType -> {
|
||||||
|
new SimulatorGroupGui(player, simulator, simulatorGroup, this).open();
|
||||||
|
}, clickType -> {
|
||||||
|
SimulatorElement<?> element = simulatorGroup.getElements().get(0);
|
||||||
|
element.open(player, simulator, simulatorGroup, this);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.features.simulator.gui;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class SimulatorMaterialGui extends SimulatorPageGui<Material> {
|
||||||
|
|
||||||
|
private static final List<Material> MATERIALS = Arrays.stream(Material.values())
|
||||||
|
.filter(material -> !material.isAir())
|
||||||
|
.filter(material -> !material.isLegacy())
|
||||||
|
.filter(Material::isItem)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
private final Supplier<Material> currentMaterial;
|
||||||
|
private Material material;
|
||||||
|
private final Consumer<Material> change;
|
||||||
|
private final SimulatorBaseGui back;
|
||||||
|
|
||||||
|
public SimulatorMaterialGui(Player player, Simulator simulator, Supplier<Material> currentMaterial, Consumer<Material> change, SimulatorBaseGui back) {
|
||||||
|
super(player, simulator, 6 * 9, MATERIALS);
|
||||||
|
this.currentMaterial = currentMaterial;
|
||||||
|
this.change = change;
|
||||||
|
this.back = back;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String baseTitle() {
|
||||||
|
return "Material";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void headerAndFooter() {
|
||||||
|
material = currentMaterial.get();
|
||||||
|
inventory.setItem(4, new SWItem(material, "§eMaterial", clickType -> {
|
||||||
|
}));
|
||||||
|
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||||
|
back.open();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SWItem convert(Material material) {
|
||||||
|
return new SWItem(material, "§eNew Material", Arrays.asList(material == this.material ? "§eSelected" : "§eClick to select"), material == this.material, clickType -> {
|
||||||
|
change.accept(material);
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
In neuem Issue referenzieren
Einen Benutzer sperren