Skip to content

Commit

Permalink
Implemented support for RELATIONSHIP_ADD and RELATIONSHIP_REMOVE.
Browse files Browse the repository at this point in the history
Created FriendAdded, FriendRemoved, UserBlocked, UserUnblocked, FriendRequestSent, (FR)Canceled, (FR)Received, and (FR)Ignored events.
Reordered the events checked in ListenerAdapter to make Messages checked first for faster events for Messages.
  • Loading branch information
DV8FromTheWorld committed Oct 8, 2016
1 parent 15a216a commit bc0b8ef
Show file tree
Hide file tree
Showing 16 changed files with 627 additions and 38 deletions.
@@ -0,0 +1,34 @@
/*
* Copyright 2015-2016 Austin Keener & Michael Ritter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.dv8tion.jda.client.events.relationship;

import net.dv8tion.jda.client.entities.Friend;
import net.dv8tion.jda.client.entities.Relationship;
import net.dv8tion.jda.core.JDA;

public class FriendAddedEvent extends GenericRelationshipAddEvent
{
public FriendAddedEvent(JDA api, long responseNumber, Relationship relationship)
{
super(api, responseNumber, relationship);
}

public Friend getFriend()
{
return (Friend) relationship;
}
}
@@ -0,0 +1,34 @@
/*
* Copyright 2015-2016 Austin Keener & Michael Ritter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.dv8tion.jda.client.events.relationship;

import net.dv8tion.jda.client.entities.Friend;
import net.dv8tion.jda.client.entities.Relationship;
import net.dv8tion.jda.core.JDA;

public class FriendRemovedEvent extends GenericRelationshipRemoveEvent
{
public FriendRemovedEvent(JDA api, long responseNumber, Relationship relationship)
{
super(api, responseNumber, relationship);
}

public Friend getFriend()
{
return (Friend) relationship;
}
}
@@ -0,0 +1,34 @@
/*
* Copyright 2015-2016 Austin Keener & Michael Ritter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.dv8tion.jda.client.events.relationship;

import net.dv8tion.jda.client.entities.OutgoingFriendRequest;
import net.dv8tion.jda.client.entities.Relationship;
import net.dv8tion.jda.core.JDA;

public class FriendRequestCanceledEvent extends GenericRelationshipRemoveEvent
{
public FriendRequestCanceledEvent(JDA api, long responseNumber, Relationship relationship)
{
super(api, responseNumber, relationship);
}

public OutgoingFriendRequest getFriendRequest()
{
return (OutgoingFriendRequest) relationship;
}
}
@@ -0,0 +1,34 @@
/*
* Copyright 2015-2016 Austin Keener & Michael Ritter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.dv8tion.jda.client.events.relationship;

import net.dv8tion.jda.client.entities.IncomingFriendRequest;
import net.dv8tion.jda.client.entities.Relationship;
import net.dv8tion.jda.core.JDA;

public class FriendRequestIgnoredEvent extends GenericRelationshipRemoveEvent
{
public FriendRequestIgnoredEvent(JDA api, long responseNumber, Relationship relationship)
{
super(api, responseNumber, relationship);
}

public IncomingFriendRequest getFriendRequest()
{
return (IncomingFriendRequest) relationship;
}
}
@@ -0,0 +1,34 @@
/*
* Copyright 2015-2016 Austin Keener & Michael Ritter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.dv8tion.jda.client.events.relationship;

import net.dv8tion.jda.client.entities.IncomingFriendRequest;
import net.dv8tion.jda.client.entities.Relationship;
import net.dv8tion.jda.core.JDA;

public class FriendRequestReceivedEvent extends GenericRelationshipAddEvent
{
public FriendRequestReceivedEvent(JDA api, long responseNumber, Relationship relationship)
{
super(api, responseNumber, relationship);
}

public IncomingFriendRequest getFriendRequest()
{
return (IncomingFriendRequest) relationship;
}
}
@@ -0,0 +1,34 @@
/*
* Copyright 2015-2016 Austin Keener & Michael Ritter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.dv8tion.jda.client.events.relationship;

import net.dv8tion.jda.client.entities.OutgoingFriendRequest;
import net.dv8tion.jda.client.entities.Relationship;
import net.dv8tion.jda.core.JDA;

public class FriendRequestSentEvent extends GenericRelationshipAddEvent
{
public FriendRequestSentEvent(JDA api, long responseNumber, Relationship relationship)
{
super(api, responseNumber, relationship);
}

public OutgoingFriendRequest getFriendRequest()
{
return (OutgoingFriendRequest) relationship;
}
}
@@ -0,0 +1,28 @@
/*
* Copyright 2015-2016 Austin Keener & Michael Ritter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.dv8tion.jda.client.events.relationship;

import net.dv8tion.jda.client.entities.Relationship;
import net.dv8tion.jda.core.JDA;

public abstract class GenericRelationshipAddEvent extends GenericRelationshipEvent
{
public GenericRelationshipAddEvent(JDA api, long responseNumber, Relationship relationship)
{
super(api, responseNumber, relationship);
}
}
@@ -0,0 +1,49 @@
/*
* Copyright 2015-2016 Austin Keener & Michael Ritter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.dv8tion.jda.client.events.relationship;

import net.dv8tion.jda.client.entities.Relationship;
import net.dv8tion.jda.client.entities.RelationshipType;
import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.entities.User;
import net.dv8tion.jda.core.events.Event;

public abstract class GenericRelationshipEvent extends Event
{
protected final Relationship relationship;

public GenericRelationshipEvent(JDA api, long responseNumber, Relationship relationship)
{
super(api, responseNumber);
this.relationship = relationship;
}

public Relationship getRelationship()
{
return relationship;
}

public RelationshipType getRelationshipType()
{
return relationship.getType();
}

public User getUser()
{
return relationship.getUser();
}
}
@@ -0,0 +1,28 @@
/*
* Copyright 2015-2016 Austin Keener & Michael Ritter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.dv8tion.jda.client.events.relationship;

import net.dv8tion.jda.client.entities.Relationship;
import net.dv8tion.jda.core.JDA;

public abstract class GenericRelationshipRemoveEvent extends GenericRelationshipEvent
{
public GenericRelationshipRemoveEvent(JDA api, long responseNumber, Relationship relationship)
{
super(api, responseNumber, relationship);
}
}
@@ -0,0 +1,34 @@
/*
* Copyright 2015-2016 Austin Keener & Michael Ritter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.dv8tion.jda.client.events.relationship;

import net.dv8tion.jda.client.entities.BlockedUser;
import net.dv8tion.jda.client.entities.Relationship;
import net.dv8tion.jda.core.JDA;

public class UserBlockedEvent extends GenericRelationshipAddEvent
{
public UserBlockedEvent(JDA api, long responseNumber, Relationship relationship)
{
super(api, responseNumber, relationship);
}

public BlockedUser getBlockedUser()
{
return (BlockedUser) getBlockedUser();
}
}
@@ -0,0 +1,34 @@
/*
* Copyright 2015-2016 Austin Keener & Michael Ritter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.dv8tion.jda.client.events.relationship;

import net.dv8tion.jda.client.entities.BlockedUser;
import net.dv8tion.jda.client.entities.Relationship;
import net.dv8tion.jda.core.JDA;

public class UserUnblockedEvent extends GenericRelationshipRemoveEvent
{
public UserUnblockedEvent(JDA api, long responseNumber, Relationship relationship)
{
super(api, responseNumber, relationship);
}

public BlockedUser getPreviouslyBlockedUser()
{
return (BlockedUser) relationship;
}
}

0 comments on commit bc0b8ef

Please sign in to comment.