You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

167 lines
5.4 KiB

11 years ago
/**
* Copyright (C) 2014-2017 Jessica James.
11 years ago
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
11 years ago
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
11 years ago
*
* Written by Jessica James <jessica.aj@outlook.com>
11 years ago
*/
#include "Jupiter/IRC_Client.h"
#include "RenX_PlayerInfo.h"
#include "RenX_Server.h"
#include "RenX_SetJoin.h"
using namespace Jupiter::literals;
11 years ago
void RenX_SetJoinPlugin::RenX_OnJoin(RenX::Server &server, const RenX::PlayerInfo &player)
11 years ago
{
if (player.uuid.isNotEmpty() && server.isMatchInProgress())
11 years ago
{
const Jupiter::ReadableString &setjoin = RenX_SetJoinPlugin::setjoin_file.get(player.uuid);
if (setjoin.isNotEmpty())
server.sendMessage(Jupiter::StringS::Format("[%.*s] %.*s", player.name.size(), player.name.ptr(), setjoin.size(), setjoin.ptr()));
11 years ago
}
}
// Plugin instantiation and entry point.
RenX_SetJoinPlugin pluginInstance;
11 years ago
// ViewJoin Game Command
void ViewJoinGameCommand::create()
{
this->addTrigger("viewjoin"_jrs);
this->addTrigger("vjoin"_jrs);
11 years ago
}
void ViewJoinGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player, const Jupiter::ReadableString &parameters)
{
if (player->uuid.isNotEmpty())
11 years ago
{
const Jupiter::ReadableString &setjoin = pluginInstance.setjoin_file.get(player->uuid);
if (setjoin.isNotEmpty())
source->sendMessage(*player, Jupiter::StringS::Format("[%.*s] %.*s", player->name.size(), player->name.ptr(), setjoin.size(), setjoin.ptr()));
else
source->sendMessage(*player, "Error: No setjoin found."_jrs);
11 years ago
}
else
source->sendMessage(*player, "Error: A setjoin message requires steam."_jrs);
11 years ago
}
const Jupiter::ReadableString &ViewJoinGameCommand::getHelp(const Jupiter::ReadableString &)
{
static STRING_LITERAL_AS_NAMED_REFERENCE(defaultHelp, "Displays your join message. Syntax: viewjoin");
11 years ago
return defaultHelp;
}
GAME_COMMAND_INIT(ViewJoinGameCommand)
// ShowJoin Game Command
void ShowJoinGameCommand::create()
{
this->addTrigger("showjoin"_jrs);
this->addTrigger("shjoin"_jrs);
}
void ShowJoinGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player, const Jupiter::ReadableString &parameters)
{
if (player->uuid.isNotEmpty())
{
const Jupiter::ReadableString &setjoin = pluginInstance.setjoin_file.get(player->uuid);
if (setjoin.isNotEmpty())
source->sendMessage(Jupiter::StringS::Format("[%.*s] %.*s", player->name.size(), player->name.ptr(), setjoin.size(), setjoin.ptr()));
else
source->sendMessage(*player, "Error: No setjoin found."_jrs);
}
else
source->sendMessage(*player, "Error: A setjoin message requires steam."_jrs);
}
const Jupiter::ReadableString &ShowJoinGameCommand::getHelp(const Jupiter::ReadableString &)
{
static STRING_LITERAL_AS_NAMED_REFERENCE(defaultHelp, "Displays your join message. Syntax: showjoin");
return defaultHelp;
}
GAME_COMMAND_INIT(ShowJoinGameCommand)
11 years ago
// DelJoin Game Command
void DelJoinGameCommand::create()
{
this->addTrigger("deljoin"_jrs);
this->addTrigger("remjoin"_jrs);
this->addTrigger("djoin"_jrs);
this->addTrigger("rjoin"_jrs);
11 years ago
}
void DelJoinGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player, const Jupiter::ReadableString &)
{
if (player->uuid.isNotEmpty())
11 years ago
{
if (pluginInstance.setjoin_file.remove(player->uuid))
source->sendMessage(*player, Jupiter::StringS::Format("%.*s, your join message has been removed.", player->name.size(), player->name.ptr()));
else
source->sendMessage(*player, "Error: Setjoin not found."_jrs);
11 years ago
}
else
source->sendMessage(*player, "Error: A setjoin message requires steam."_jrs);
11 years ago
}
const Jupiter::ReadableString &DelJoinGameCommand::getHelp(const Jupiter::ReadableString &)
{
static STRING_LITERAL_AS_NAMED_REFERENCE(defaultHelp, "Removes your automatic join message. Syntax: deljoin");
11 years ago
return defaultHelp;
}
GAME_COMMAND_INIT(DelJoinGameCommand)
// SetJoin Game Command
void SetJoinGameCommand::create()
{
this->addTrigger("setjoin"_jrs);
this->addTrigger("sjoin"_jrs);
11 years ago
}
void SetJoinGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player, const Jupiter::ReadableString &parameters)
{
if (player->uuid.isNotEmpty())
11 years ago
{
if (parameters.isNotEmpty())
11 years ago
{
pluginInstance.setjoin_file.set(player->uuid, parameters);
pluginInstance.setjoin_file.write();
source->sendMessage(*player, Jupiter::StringS::Format("%.*s, your join message is now: %.*s", player->name.size(), player->name.ptr(), parameters.size(), parameters.ptr()));
11 years ago
}
else DelJoinGameCommand_instance.trigger(source, player, parameters);
}
else source->sendMessage(*player, "Error: A setjoin message requires steam."_jrs);
11 years ago
}
const Jupiter::ReadableString &SetJoinGameCommand::getHelp(const Jupiter::ReadableString &)
{
static STRING_LITERAL_AS_NAMED_REFERENCE(defaultHelp, "Sets an automatic join message. Syntax: setjoin [message]");
11 years ago
return defaultHelp;
}
GAME_COMMAND_INIT(SetJoinGameCommand)
extern "C" __declspec(dllexport) Jupiter::Plugin *getPlugin()
{
return &pluginInstance;
}