Merge branch '7-onsupportuserwarnedevent' into 'master'

Resolve "OnSupportUserWarnedEvent"

Closes #7

See merge request morningstar/Arcturus-Community!2
This commit is contained in:
Beny 2019-05-04 00:38:07 -04:00
commit 0c61542a25
7 changed files with 95 additions and 29 deletions

View File

@ -467,23 +467,23 @@ public class ModToolManager
public void alert(Habbo moderator, Habbo target, String message) public void alert(Habbo moderator, Habbo target, String message)
{ {
if(moderator.hasPermission(Permission.ACC_SUPPORTTOOL)) alert(moderator, target, message, SupportUserAlertedReason.ALERT);
{ }
SupportUserAlertedEvent alertedEvent = new SupportUserAlertedEvent(moderator, target, message);
if (Emulator.getPluginManager().fireEvent(alertedEvent).isCancelled())
{
return;
}
if(target != null) public void alert(Habbo moderator, Habbo target, String message, SupportUserAlertedReason reason)
{ {
alertedEvent.target.getClient().sendResponse(new ModToolIssueHandledComposer(alertedEvent.message)); if(!moderator.hasPermission(Permission.ACC_SUPPORTTOOL)) {
}
}
else
{
Emulator.getGameEnvironment().getModToolManager().quickTicket(moderator, "Scripter", Emulator.getTexts().getValue("scripter.warning.modtools.alert").replace("%username%", moderator.getHabboInfo().getUsername()).replace("%message%", message)); Emulator.getGameEnvironment().getModToolManager().quickTicket(moderator, "Scripter", Emulator.getTexts().getValue("scripter.warning.modtools.alert").replace("%username%", moderator.getHabboInfo().getUsername()).replace("%message%", message));
return;
} }
SupportUserAlertedEvent alertedEvent = new SupportUserAlertedEvent(moderator, target, message, reason);
if (Emulator.getPluginManager().fireEvent(alertedEvent).isCancelled())
return;
if(target != null)
alertedEvent.target.getClient().sendResponse(new ModToolIssueHandledComposer(alertedEvent.message));
} }
public void kick(Habbo moderator, Habbo target, String message) public void kick(Habbo moderator, Habbo target, String message)
@ -494,7 +494,7 @@ public class ModToolManager
{ {
Emulator.getGameEnvironment().getRoomManager().leaveRoom(target, target.getHabboInfo().getCurrentRoom()); Emulator.getGameEnvironment().getRoomManager().leaveRoom(target, target.getHabboInfo().getCurrentRoom());
} }
this.alert(moderator, target, message); this.alert(moderator, target, message, SupportUserAlertedReason.KICKED);
} }
} }

View File

@ -465,7 +465,7 @@ public class PacketManager
this.registerHandler(Incoming.ModToolCloseTicketEvent, ModToolCloseTicketEvent.class); this.registerHandler(Incoming.ModToolCloseTicketEvent, ModToolCloseTicketEvent.class);
this.registerHandler(Incoming.ModToolReleaseTicketEvent, ModToolReleaseTicketEvent.class); this.registerHandler(Incoming.ModToolReleaseTicketEvent, ModToolReleaseTicketEvent.class);
this.registerHandler(Incoming.ModToolAlertEvent, ModToolAlertEvent.class); this.registerHandler(Incoming.ModToolAlertEvent, ModToolAlertEvent.class);
this.registerHandler(Incoming.ModToolWarnEvent, ModToolAlertEvent.class); this.registerHandler(Incoming.ModToolWarnEvent, ModToolWarnEvent.class);
this.registerHandler(Incoming.ModToolKickEvent, ModToolKickEvent.class); this.registerHandler(Incoming.ModToolKickEvent, ModToolKickEvent.class);
this.registerHandler(Incoming.ModToolRoomAlertEvent, ModToolRoomAlertEvent.class); this.registerHandler(Incoming.ModToolRoomAlertEvent, ModToolRoomAlertEvent.class);
this.registerHandler(Incoming.ModToolChangeRoomSettingsEvent, ModToolChangeRoomSettingsEvent.class); this.registerHandler(Incoming.ModToolChangeRoomSettingsEvent, ModToolChangeRoomSettingsEvent.class);

View File

@ -1,24 +1,34 @@
package com.eu.habbo.messages.incoming.ambassadors; package com.eu.habbo.messages.incoming.ambassadors;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
import com.eu.habbo.plugin.events.support.SupportUserAlertedEvent;
import com.eu.habbo.plugin.events.support.SupportUserAlertedReason;
public class AmbassadorAlertCommandEvent extends MessageHandler public class AmbassadorAlertCommandEvent extends MessageHandler
{ {
@Override @Override
public void handle() throws Exception public void handle() throws Exception
{ {
if(this.client.getHabbo().hasPermission("acc_ambassador")) if(!this.client.getHabbo().hasPermission("acc_ambassador")) {
{ Emulator.getGameEnvironment().getModToolManager().quickTicket(client.getHabbo(), "Scripter", Emulator.getTexts().getValue("scripter.warning.modtools.alert").replace("%username%", client.getHabbo().getHabboInfo().getUsername()).replace("%message%", "${notification.ambassador.alert.warning.message}"));
int userId = this.packet.readInt(); return;
Habbo habbo = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(userId);
if(habbo != null)
{
habbo.getClient().sendResponse(new BubbleAlertComposer("ambassador.alert.warning"));
}
} }
int userId = this.packet.readInt();
Habbo habbo = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(userId);
if(habbo == null)
return;
SupportUserAlertedEvent alertedEvent = new SupportUserAlertedEvent(client.getHabbo(), habbo, "${notification.ambassador.alert.warning.message}", SupportUserAlertedReason.AMBASSADOR);
if (Emulator.getPluginManager().fireEvent(alertedEvent).isCancelled())
return;
habbo.getClient().sendResponse(new BubbleAlertComposer("ambassador.alert.warning"));
} }
} }

View File

@ -2,7 +2,9 @@ package com.eu.habbo.messages.incoming.modtool;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.plugin.events.support.SupportUserAlertedReason;
public class ModToolAlertEvent extends MessageHandler public class ModToolAlertEvent extends MessageHandler
{ {
@ -11,7 +13,10 @@ public class ModToolAlertEvent extends MessageHandler
{ {
if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL))
{ {
Emulator.getGameEnvironment().getModToolManager().alert(this.client.getHabbo(), Emulator.getGameEnvironment().getHabboManager().getHabbo(this.packet.readInt()), this.packet.readString()); Habbo alertedUser = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.packet.readInt());
if(alertedUser != null)
Emulator.getGameEnvironment().getModToolManager().alert(this.client.getHabbo(), alertedUser, this.packet.readString(), SupportUserAlertedReason.ALERT);
} }
else else
{ {

View File

@ -0,0 +1,26 @@
package com.eu.habbo.messages.incoming.modtool;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.plugin.events.support.SupportUserAlertedReason;
public class ModToolWarnEvent extends MessageHandler
{
@Override
public void handle() throws Exception
{
if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL))
{
Habbo alertedUser = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.packet.readInt());
if(alertedUser != null)
Emulator.getGameEnvironment().getModToolManager().alert(this.client.getHabbo(), alertedUser, this.packet.readString(), SupportUserAlertedReason.CAUTION);
}
else
{
Emulator.getGameEnvironment().getModToolManager().quickTicket(this.client.getHabbo(), "Scripter", Emulator.getTexts().getValue("scripter.warning.modtools.kick").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()));
}
}
}

View File

@ -7,15 +7,16 @@ public class SupportUserAlertedEvent extends SupportEvent
public Habbo target; public Habbo target;
public String message; public String message;
public SupportUserAlertedReason reason;
public SupportUserAlertedEvent(Habbo moderator, Habbo target, String message) public SupportUserAlertedEvent(Habbo moderator, Habbo target, String message, SupportUserAlertedReason reason)
{ {
super(moderator); super(moderator);
this.message = message; this.message = message;
this.target = target; this.target = target;
this.reason = reason;
} }
} }

View File

@ -0,0 +1,24 @@
package com.eu.habbo.plugin.events.support;
public enum SupportUserAlertedReason {
ALERT(0),
CAUTION(1),
KICKED(2),
AMBASSADOR(3);
private final int code;
SupportUserAlertedReason(int code)
{
this.code = code;
}
public int getCode()
{
return this.code;
}
}