All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.theholywaffle.teamspeak3.api.event.BaseEvent Maven / Gradle / Ivy

There is a newer version: 1.3.1
Show newest version
package com.github.theholywaffle.teamspeak3.api.event;

/*
 * #%L
 * TeamSpeak 3 Java API
 * %%
 * Copyright (C) 2014 - 2015 Bert De Geyter
 * %%
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 * #L%
 */

import com.github.theholywaffle.teamspeak3.api.wrapper.Wrapper;

import java.util.Collections;
import java.util.Map;

public abstract class BaseEvent extends Wrapper implements TS3Event {

	protected BaseEvent(Map map) {
		super(Collections.unmodifiableMap(map));
	}

	/**
	 * Gets the ID of the client who caused this event to happen.
	 * 

* Because not all events are caused by clients, not all events have an invoker.
* Most importantly, client events (i.e. {@link ClientJoinEvent}, {@link ClientLeaveEvent} * {@link ClientMovedEvent}) do not have an invoker if a client joined, * quit or changed channels themselves. These values are only present if another client * caused the event to happen by moving, kicking or banning a client. *

* If the event response does not contain an invoker, this method will return {@code -1}. *

* * @return the client ID of the invoker or {@code -1} if the event does not contain an invoker */ public int getInvokerId() { return getInt("invokerid"); } /** * Gets the nickname of the client who caused this event to happen. *

* Because not all events are caused by clients, not all events have an invoker.
* Most importantly, client events (i.e. {@link ClientJoinEvent}, {@link ClientLeaveEvent} * {@link ClientMovedEvent}) do not have an invoker if a client joined, * quit or changed channels themselves. These values are only present if another client * caused the event to happen by moving, kicking or banning a client. *

* If the event response does not contain an invoker, this method will return an empty string. *

* * @return the nickname of the invoker or an empty string if the event does not contain an invoker */ public String getInvokerName() { return get("invokername"); } /** * Gets the unique identifier of the client who caused this event to happen. *

* Because not all events are caused by clients, not all events have an invoker.
* Most importantly, client events (i.e. {@link ClientJoinEvent}, {@link ClientLeaveEvent} * {@link ClientMovedEvent}) do not have an invoker if a client joined, * quit or changed channels themselves. These values are only present if another client * caused the event to happen by moving, kicking or banning a client. *

* If the event response does not contain an invoker, this method will return an empty string. *

* * @return the unique ID the invoker or an empty string if the event does not contain an invoker */ public String getInvokerUniqueId() { return get("invokeruid"); } /** * Gets the reason ID of the cause of this event. *

* Here's an incomplete list of known reason IDs: *

* * * * * * * * * * * * *
IDDescription
-1No reason present
0No external cause
1Client was moved (by other client / by creating a new channel)
3Client timed out
4Client kicked from a channel or channel deleted
5Client kicked from the server
6Client banned from the server
8Client left the server (no external cause)
10Virtual server or channel edited
11Server shut down
* * @return the reason ID for this event */ public int getReasonId() { return getInt("reasonid"); } /** * Gets the reason for this event. * This field is rarely present, even if the reason ID is non-zero. *

* In case of a client getting kicked or banned, this will return the user-provided reason. *

* * @return the reason for this event or an empty string if no reason message is present */ public String getReasonMessage() { return get("reasonmsg"); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy