mirror of
https://github.com/ProjectSWGCore/Holocore.git
synced 2026-01-17 00:06:00 -05:00
Merge pull request #223 from Josh-Larson/quality_assurance
Implemented admin spawner command
This commit is contained in:
@@ -4,7 +4,7 @@ plugins {
|
||||
application
|
||||
idea
|
||||
java
|
||||
kotlin("jvm") version "1.3.70"
|
||||
kotlin("jvm") version "1.3.72"
|
||||
id("com.github.johnrengelman.shadow") version "5.2.0"
|
||||
id("org.javamodularity.moduleplugin") version "1.5.0"
|
||||
id("org.beryx.jlink") version "2.17.2"
|
||||
@@ -96,6 +96,12 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class).configure
|
||||
}
|
||||
}
|
||||
|
||||
tasks.create<JavaExec>("runDebug") {
|
||||
enableAssertions = true
|
||||
classpath = sourceSets.main.get().runtimeClasspath
|
||||
main = "com.projectswg.holocore.ProjectSWG"
|
||||
}
|
||||
|
||||
tasks.create<ShadowJar>("CreateConvertLoginJar") {
|
||||
archiveBaseName.set("ConvertLogin")
|
||||
archiveClassifier.set(null as String?)
|
||||
|
||||
Submodule pswgcommon updated: a467fa58c4...1c2b234908
@@ -26,21 +26,22 @@
|
||||
***********************************************************************************/
|
||||
package com.projectswg.holocore.intents.support.global.chat;
|
||||
|
||||
import com.projectswg.holocore.resources.support.global.chat.AdminChatRooms;
|
||||
import me.joshlarson.jlcommon.control.Intent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SystemChatRoomMessageIntent extends Intent {
|
||||
|
||||
private final String roomPath;
|
||||
private final AdminChatRooms roomPath;
|
||||
private final String message;
|
||||
|
||||
public SystemChatRoomMessageIntent(@NotNull String roomPath, @NotNull String message) {
|
||||
public SystemChatRoomMessageIntent(@NotNull AdminChatRooms roomPath, @NotNull String message) {
|
||||
this.roomPath = roomPath;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getRoomPath() {
|
||||
public AdminChatRooms getRoomPath() {
|
||||
return roomPath;
|
||||
}
|
||||
|
||||
@@ -49,7 +50,7 @@ public class SystemChatRoomMessageIntent extends Intent {
|
||||
return message;
|
||||
}
|
||||
|
||||
public static void broadcast(@NotNull String roomPath, @NotNull String message) {
|
||||
public static void broadcast(@NotNull AdminChatRooms roomPath, @NotNull String message) {
|
||||
new SystemChatRoomMessageIntent(roomPath, message).broadcast();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2020 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
* Our goal is to create an emulator which will provide a server for players to *
|
||||
* continue playing a game similar to the one they used to play. We are basing *
|
||||
* it on the final publish of the game prior to end-game events. *
|
||||
* *
|
||||
* This file is part of Holocore. *
|
||||
* *
|
||||
* --------------------------------------------------------------------------------*
|
||||
* *
|
||||
* Holocore 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. *
|
||||
* *
|
||||
* Holocore 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 Holocore. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************************/
|
||||
|
||||
package com.projectswg.holocore.resources.support.global.chat
|
||||
|
||||
import com.projectswg.holocore.ProjectSWG
|
||||
|
||||
enum class AdminChatRooms(val roomTitle: String, val roomPath: String) {
|
||||
SYSTEM_LOG("system log", "SWG." + ProjectSWG.getGalaxy().name + ".admin.SystemLog"),
|
||||
SPAWNER_LOG("spawner log", "SWG." + ProjectSWG.getGalaxy().name + ".admin.SpawnerLog")
|
||||
}
|
||||
@@ -303,7 +303,9 @@ public class ChatRoomHandler {
|
||||
}
|
||||
|
||||
private void createAdminChannels(ChatAvatar systemAvatar, String basePath) {
|
||||
createRoom(systemAvatar, false, false, ChatRoomService.LOG_ROOM_PATH, "server log", false);
|
||||
for (AdminChatRooms room : AdminChatRooms.values()) {
|
||||
createRoom(systemAvatar, false, false, room.getRoomPath(), room.getRoomTitle(), false);
|
||||
}
|
||||
}
|
||||
|
||||
public ChatRoom getRoomById(int roomId) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.projectswg.holocore.services.support.global;
|
||||
|
||||
import com.projectswg.holocore.services.support.global.admin.AdministrationManager;
|
||||
import com.projectswg.holocore.services.support.global.chat.ChatManager;
|
||||
import com.projectswg.holocore.services.support.global.commands.CommandManager;
|
||||
import com.projectswg.holocore.services.support.global.health.ServerHealthService;
|
||||
@@ -9,6 +10,8 @@ import me.joshlarson.jlcommon.control.Manager;
|
||||
import me.joshlarson.jlcommon.control.ManagerStructure;
|
||||
|
||||
@ManagerStructure(children = {
|
||||
AdministrationManager.class,
|
||||
|
||||
ChatManager.class,
|
||||
|
||||
CommandManager.class,
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2020 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
* Our goal is to create an emulator which will provide a server for players to *
|
||||
* continue playing a game similar to the one they used to play. We are basing *
|
||||
* it on the final publish of the game prior to end-game events. *
|
||||
* *
|
||||
* This file is part of Holocore. *
|
||||
* *
|
||||
* --------------------------------------------------------------------------------*
|
||||
* *
|
||||
* Holocore 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. *
|
||||
* *
|
||||
* Holocore 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 Holocore. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************************/
|
||||
|
||||
package com.projectswg.holocore.services.support.global.admin
|
||||
|
||||
import com.projectswg.common.data.CRC
|
||||
import com.projectswg.holocore.intents.support.global.chat.SystemChatRoomMessageIntent
|
||||
import com.projectswg.holocore.intents.support.global.command.ExecuteCommandIntent
|
||||
import com.projectswg.holocore.intents.support.objects.swg.ObjectCreatedIntent
|
||||
import com.projectswg.holocore.resources.support.global.chat.AdminChatRooms
|
||||
import com.projectswg.holocore.resources.support.npc.spawn.SpawnerType
|
||||
import com.projectswg.holocore.resources.support.objects.ObjectCreator
|
||||
import com.projectswg.holocore.resources.support.objects.swg.cell.CellObject
|
||||
import me.joshlarson.jlcommon.control.IntentHandler
|
||||
import me.joshlarson.jlcommon.control.Service
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
import kotlin.concurrent.withLock
|
||||
|
||||
class AdminSpawnerService : Service() {
|
||||
|
||||
private val outputFile = File("log/spawners.txt")
|
||||
private val outputStreamLock = ReentrantLock()
|
||||
|
||||
override fun start(): Boolean {
|
||||
outputFile.delete()
|
||||
outputFile.createNewFile()
|
||||
return true
|
||||
}
|
||||
|
||||
@IntentHandler
|
||||
private fun handleChatCommandIntent(eci: ExecuteCommandIntent) {
|
||||
if (eci.command.crc == COMMAND_CREATE_SPAWNING_ELEMENT) {
|
||||
val creature = eci.source
|
||||
val location = creature.location
|
||||
val building = creature.superParent?.buildoutTag ?: location.terrain.name.toLowerCase(Locale.US).substring(0, 3) + "_world"
|
||||
val cell = (creature.parent as? CellObject?)?.number ?: 0
|
||||
val args = eci.arguments.split(' ', limit = 2)
|
||||
val type = sanitizeSpawnerType(args.getOrElse(0) { "AREA" }.toUpperCase(Locale.US))
|
||||
val comment = args.getOrElse(1) { "NPC" }
|
||||
val actualYaw = location.yaw
|
||||
val soeYaw = if (actualYaw < 180) actualYaw else actualYaw - 360
|
||||
val output = String.format("%s\t%s\t%s\t%d\t%.1f\t%.1f\t%.1f\t%.0f\t%s%s", location.terrain, building, type, cell, location.x, location.y, location.z, soeYaw, comment, System.lineSeparator())
|
||||
outputStreamLock.withLock {
|
||||
outputFile.appendText(output)
|
||||
}
|
||||
val color = when(type) {
|
||||
"PATROL" -> "#000000"
|
||||
"WAYPOINT" -> "#0000FF"
|
||||
else -> "#FFFF00"
|
||||
}
|
||||
val egg = ObjectCreator.createObjectFromTemplate(when(type) {
|
||||
"PATROL" -> SpawnerType.PATROL.objectTemplate
|
||||
"WAYPOINT" -> "object/tangible/ground_spawning/patrol_waypoint.iff"
|
||||
else -> SpawnerType.AREA.objectTemplate
|
||||
})
|
||||
egg.moveToContainer(creature.parent, location)
|
||||
ObjectCreatedIntent.broadcast(egg)
|
||||
SystemChatRoomMessageIntent.broadcast(AdminChatRooms.SPAWNER_LOG, "${color}The spawner $type ($comment) has been created at your location")
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
private val COMMAND_CREATE_SPAWNING_ELEMENT = CRC.getCrc("createspawningelement")
|
||||
|
||||
private fun sanitizeSpawnerType(type: String): String {
|
||||
if (type == "AREA" || type == "PATROL" || type == "WAYPOINT")
|
||||
return type
|
||||
return "AREA"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/***********************************************************************************
|
||||
* Copyright (c) 2020 /// Project SWG /// www.projectswg.com *
|
||||
* *
|
||||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
|
||||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
|
||||
* Our goal is to create an emulator which will provide a server for players to *
|
||||
* continue playing a game similar to the one they used to play. We are basing *
|
||||
* it on the final publish of the game prior to end-game events. *
|
||||
* *
|
||||
* This file is part of Holocore. *
|
||||
* *
|
||||
* --------------------------------------------------------------------------------*
|
||||
* *
|
||||
* Holocore 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. *
|
||||
* *
|
||||
* Holocore 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 Holocore. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************************/
|
||||
|
||||
package com.projectswg.holocore.services.support.global.admin
|
||||
|
||||
import me.joshlarson.jlcommon.control.Manager
|
||||
import me.joshlarson.jlcommon.control.ManagerStructure
|
||||
|
||||
@ManagerStructure(children = [AdminSpawnerService::class])
|
||||
class AdministrationManager : Manager()
|
||||
@@ -67,7 +67,7 @@ public class ChatRoomService extends Service {
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
Log.addWrapper(new ChatRoomLogWrapper(ChatRoomService.LOG_ROOM_PATH));
|
||||
Log.addWrapper(new ChatRoomLogWrapper());
|
||||
|
||||
return super.start();
|
||||
}
|
||||
@@ -168,7 +168,7 @@ public class ChatRoomService extends Service {
|
||||
|
||||
@IntentHandler
|
||||
private void handleSystemChatRoomMessageIntent(SystemChatRoomMessageIntent intent) {
|
||||
chatRoomHandler.sendMessageToRoomFromSystem(intent.getRoomPath(), intent.getMessage(), new OutOfBandPackage());
|
||||
chatRoomHandler.sendMessageToRoomFromSystem(intent.getRoomPath().getRoomPath(), intent.getMessage(), new OutOfBandPackage());
|
||||
}
|
||||
|
||||
/* Chat Rooms */
|
||||
|
||||
@@ -27,11 +27,12 @@
|
||||
package com.projectswg.holocore.utilities
|
||||
|
||||
import com.projectswg.holocore.intents.support.global.chat.SystemChatRoomMessageIntent
|
||||
import com.projectswg.holocore.resources.support.global.chat.AdminChatRooms
|
||||
import me.joshlarson.jlcommon.control.IntentChain
|
||||
import me.joshlarson.jlcommon.log.Log
|
||||
import me.joshlarson.jlcommon.log.LogWrapper
|
||||
|
||||
class ChatRoomLogWrapper(private val roomPath: String) : LogWrapper {
|
||||
class ChatRoomLogWrapper : LogWrapper {
|
||||
|
||||
private val intentChain = IntentChain()
|
||||
|
||||
@@ -44,7 +45,7 @@ class ChatRoomLogWrapper(private val roomPath: String) : LogWrapper {
|
||||
Log.LogLevel.ERROR -> " \\#FF0000\\E: "+str.substringAfter(": ")
|
||||
Log.LogLevel.ASSERT -> " \\#FF00FF\\A: "+str.substringAfter(": ")
|
||||
}
|
||||
intentChain.broadcastAfter(SystemChatRoomMessageIntent(roomPath, message))
|
||||
intentChain.broadcastAfter(SystemChatRoomMessageIntent(AdminChatRooms.SYSTEM_LOG, message))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user