Added ingame rules confirmation screen
This commit is contained in:
@@ -84,11 +84,7 @@ public class Component {
|
||||
* @return {@code True} if the component can be closed.
|
||||
*/
|
||||
public boolean close(Player player) {
|
||||
InterfaceListeners.runClose(player,this);
|
||||
if (closeEvent != null && !closeEvent.close(player, this)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return (closeEvent == null || closeEvent.close(player, this)) && InterfaceListeners.runClose(player, this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,6 +12,8 @@ import core.net.packet.PacketRepository;
|
||||
import core.net.packet.context.InterfaceContext;
|
||||
import core.net.packet.out.Interface;
|
||||
import core.plugin.Plugin;
|
||||
import rs09.ServerConstants;
|
||||
import rs09.game.interaction.inter.RulesAndInfo;
|
||||
import rs09.game.system.SystemLogger;
|
||||
import rs09.game.world.GameWorld;
|
||||
import rs09.game.world.repository.Repository;
|
||||
@@ -144,6 +146,8 @@ public final class LoginConfiguration {
|
||||
player.getEmoteManager().unlock(Emotes.SAFETY_FIRST);
|
||||
}
|
||||
player.varpManager.sendAllVarps();
|
||||
if(ServerConstants.RULES_AND_INFO_ENABLED)
|
||||
RulesAndInfo.openFor(player);
|
||||
/*if (GameWorld.getSettings().isPvp()) {
|
||||
player.getPacketDispatch().sendString("", 226, 1);
|
||||
}*/
|
||||
|
||||
@@ -116,6 +116,9 @@ class ServerConstants {
|
||||
@JvmField
|
||||
var LOG_CUTSCENE = true
|
||||
|
||||
@JvmField
|
||||
var RULES_AND_INFO_ENABLED = true
|
||||
|
||||
//location names for the ::to command.
|
||||
val TELEPORT_DESTINATIONS = arrayOf(
|
||||
arrayOf(Location.create(2974, 4383, 2), "corp", "corporal", "corporeal"),
|
||||
@@ -203,4 +206,4 @@ class ServerConstants {
|
||||
@JvmField
|
||||
var DAILY_RESTART = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package rs09.game.content.activity.gnomecooking
|
||||
|
||||
const val GC_BASE_ATTRIBUTE = "gnome_cooking"
|
||||
const val GC_TUT_PROG = "tutorial:stage"
|
||||
const val GC_TUT_FIN = "tutorial:complete"
|
||||
const val GC_TUT_PROG = "gnome-cooking:tutorial:stage"
|
||||
const val GC_TUT_FIN = "gnome-cooking:tutorial:complete"
|
||||
const val GC_JOB_ORDINAL = "job:job_ordinal"
|
||||
const val GC_JOB_COMPLETE = "job:job_complete"
|
||||
const val GC_HARD_JOB = "job:hard_job"
|
||||
|
||||
@@ -16,6 +16,7 @@ import core.net.amsc.WorldCommunicator
|
||||
import core.plugin.Initializable
|
||||
import org.rs09.consts.Items
|
||||
import org.rs09.consts.NPCs
|
||||
import rs09.game.interaction.inter.RulesAndInfo
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.tools.END_DIALOGUE
|
||||
|
||||
@@ -147,7 +148,6 @@ class TutorialMagicTutorDialogue(player: Player? = null) : DialoguePlugin(player
|
||||
"at any time, look for a signpost or use the Lumbridge Home Port Spell."
|
||||
)
|
||||
stage = 12
|
||||
player.unlock()
|
||||
if(WorldCommunicator.isEnabled())
|
||||
MSPacketRepository.sendInfoUpdate(player)
|
||||
TutorialStage.removeHintIcon(player)
|
||||
@@ -158,12 +158,12 @@ class TutorialMagicTutorDialogue(player: Player? = null) : DialoguePlugin(player
|
||||
player.unhook(TutorialUseWithReceiver)
|
||||
player.unhook(TutorialInteractionReceiver)
|
||||
player.unhook(TutorialButtonReceiver)
|
||||
RulesAndInfo.openFor(player)
|
||||
}
|
||||
|
||||
12 -> {
|
||||
player.setAttribute("close_c_", true)
|
||||
end()
|
||||
sendMessage(player, "Welcome to ${GameWorld.settings!!.name}.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ object InterfaceListeners {
|
||||
|
||||
@JvmStatic
|
||||
fun runClose(player: Player,component: Component): Boolean{
|
||||
val method = getCloseListener(component.id) ?: return false
|
||||
val method = getCloseListener(component.id) ?: return true
|
||||
return method.invoke(player,component)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package rs09.game.interaction.inter
|
||||
|
||||
import api.*
|
||||
import core.game.node.entity.player.Player
|
||||
import core.tools.RandomFunction
|
||||
import rs09.game.interaction.InterfaceListener
|
||||
import rs09.game.system.SystemLogger
|
||||
|
||||
object RulesAndInfo {
|
||||
val RULES = arrayOf(
|
||||
"<col=ffffff>1. Be respectful to your fellow players.</col>",
|
||||
" -No harassment, etc.",
|
||||
" -Keep arguments private.",
|
||||
"<col=ffffff>2. Do not exploit bugs.</col>",
|
||||
" -Zero tolerance. Can result in account deletion.",
|
||||
" -If you discover a bug, report it on our Gitlab.",
|
||||
"<col=ffffff>3. Do not discuss or advertise other servers.</col>",
|
||||
" -Discussion of the live jagex games is fine.",
|
||||
" -Discussion of open source projects is fine.",
|
||||
"<col=ffffff>4. No use of any kind of automation tool.</col>",
|
||||
" -This includes autoclickers, autohotkey, etc.",
|
||||
" -Exception: 1-to-1 inputs, such as mousekeys."
|
||||
)
|
||||
val SEPARATOR = "<str> </str>"
|
||||
val INFO = arrayOf(
|
||||
"<col=6bcdfa>To join our Discord, type ::discord</col>"
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
fun openFor(player: Player)
|
||||
{
|
||||
if(getAttribute(player, "rules:confirmed", false) || !getAttribute(player, "tutorial:complete", false))
|
||||
return
|
||||
var ln = 1
|
||||
val pin = getAttribute(player, "rules:pin", RandomFunction.random(1000,9999))
|
||||
setAttribute(player, "/save:rules:pin", pin)
|
||||
for(line in INFO) setInterfaceText(player, INFO[ln - 1], 384, ln++)
|
||||
setInterfaceText(player, SEPARATOR, 384, ln++)
|
||||
val newIndex = ln
|
||||
for(line in RULES) setInterfaceText(player, RULES[ln - newIndex], 384, ln++)
|
||||
setInterfaceText(player, "<col=ffffff>If you agree to the above, type ::confirmrules $pin", 384, ln++)
|
||||
setInterfaceText(player, "", 384, ln)
|
||||
player.packetDispatch.sendInterfaceConfig(384, 17, true)
|
||||
openInterface(player, 384)
|
||||
player.lock()
|
||||
}
|
||||
}
|
||||
|
||||
class RulesListener : InterfaceListener()
|
||||
{
|
||||
override fun defineListeners() {
|
||||
onClose(384){player, _ ->
|
||||
if(!getAttribute(player, "rules:confirmed", false))
|
||||
runTask(player, 1) { RulesAndInfo.openFor(player); sendDialogue(player, "Please read the rules.") }
|
||||
return@onClose true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -526,6 +526,26 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
define("confirmrules", Command.Privilege.STANDARD) { player, args ->
|
||||
if(getAttribute(player,"rules:confirmed", false))
|
||||
reject(player, "You have already confirmed the rules.")
|
||||
if(args.size < 2)
|
||||
reject(player, "Usage: ::confirmrules PIN")
|
||||
val pin = args[1].toIntOrNull() ?: (-1).also{ reject(player, "Please enter a valid number.") }
|
||||
if(pin == getAttribute(player, "rules:pin", -1))
|
||||
{
|
||||
player.setAttribute("/save:rules:confirmed", true)
|
||||
player.interfaceManager.close()
|
||||
sendDialogue(player, "Thank you!")
|
||||
player.unlock()
|
||||
player.removeAttribute("rules:pin")
|
||||
}
|
||||
else
|
||||
{
|
||||
sendDialogue(player, "Wrong pin. Try again.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun showGeBotsearch(player: Player, searchTerm: String)
|
||||
|
||||
@@ -102,6 +102,7 @@ object ServerConfigParser {
|
||||
ServerConstants.GRAND_EXCHANGE_DATA_PATH = data.getPath("paths.eco_data")
|
||||
ServerConstants.CELEDT_DATA_PATH = data.getPath("paths.cele_drop_table_path")
|
||||
ServerConstants.SERVER_GE_NAME = data.getString("world.name_ge") ?: ServerConstants.SERVER_NAME
|
||||
ServerConstants.RULES_AND_INFO_ENABLED = data.getBoolean("world.show_rules", true)
|
||||
}
|
||||
|
||||
|
||||
@@ -147,4 +148,4 @@ object ServerConfigParser {
|
||||
|
||||
return pathProduct
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user