Skip to content

Commit

Permalink
Implemented GUILD_ROLE_UPDATE along with all related events.
Browse files Browse the repository at this point in the history
  • Loading branch information
DV8FromTheWorld committed Oct 4, 2016
1 parent 0566b94 commit 03dda44
Show file tree
Hide file tree
Showing 12 changed files with 421 additions and 25 deletions.
Expand Up @@ -567,7 +567,7 @@ public Role createRole(JSONObject roleJson, String guildId)
.setRawPermissions(roleJson.getInt("permissions"))
.setManaged(roleJson.getBoolean("managed"))
.setHoisted(roleJson.getBoolean("hoist"))
.setColor(roleJson.has("color") ? new Color(roleJson.getInt("color")) : null)
.setColor(roleJson.getInt("color") != 0 ? new Color(roleJson.getInt("color")) : null)
.setMentionable(roleJson.has("mentionable") && roleJson.getBoolean("mentionable"));
}

Expand Down
Expand Up @@ -25,7 +25,7 @@ public abstract class GenericRoleEvent extends Event
{
protected final Role role;

protected GenericRoleEvent(JDA api, long responseNumber, Role role)
public GenericRoleEvent(JDA api, long responseNumber, Role role)
{
super(api, responseNumber);
this.role = role;
Expand Down
@@ -0,0 +1,29 @@
/*
* 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.core.events.role.update;

import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.entities.Role;
import net.dv8tion.jda.core.events.role.GenericRoleEvent;

public abstract class GenericRoleUpdateEvent extends GenericRoleEvent
{
public GenericRoleUpdateEvent(JDA api, long responseNumber, Role role)
{
super(api, responseNumber, role);
}
}
@@ -0,0 +1,38 @@
/*
* 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.core.events.role.update;

import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.entities.Role;

import java.awt.*;

public class RoleUpdateColorEvent extends GenericRoleUpdateEvent
{
private final Color oldColor;

public RoleUpdateColorEvent(JDA api, long responseNumber, Role role, Color oldColor)
{
super(api, responseNumber, role);
this.oldColor = oldColor;
}

public Color getOldColor()
{
return oldColor;
}
}
@@ -0,0 +1,36 @@
/*
* 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.core.events.role.update;

import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.entities.Role;

public class RoleUpdateHoistedEvent extends GenericRoleUpdateEvent
{
private final boolean wasHoisted;

public RoleUpdateHoistedEvent(JDA api, long responseNumber, Role role, boolean wasHoisted)
{
super(api, responseNumber, role);
this.wasHoisted = wasHoisted;
}

public boolean wasHoisted()
{
return wasHoisted;
}
}
@@ -0,0 +1,36 @@
/*
* 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.core.events.role.update;

import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.entities.Role;

public class RoleUpdateMentionableEvent extends GenericRoleUpdateEvent
{
private final boolean wasMentionable;

public RoleUpdateMentionableEvent(JDA api, long responseNumber, Role role, boolean wasMentionable)
{
super(api, responseNumber, role);
this.wasMentionable = wasMentionable;
}

public boolean wasMentionable()
{
return wasMentionable;
}
}
@@ -0,0 +1,36 @@
/*
* 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.core.events.role.update;

import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.entities.Role;

public class RoleUpdateNameEvent extends GenericRoleUpdateEvent
{
private final String oldName;

public RoleUpdateNameEvent(JDA api, long responseNumber, Role role, String oldName)
{
super(api, responseNumber, role);
this.oldName = oldName;
}

public String getOldName()
{
return oldName;
}
}
@@ -0,0 +1,46 @@
/*
* 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.core.events.role.update;

import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.Permission;
import net.dv8tion.jda.core.entities.Role;

import java.util.Collections;
import java.util.List;

public class RoleUpdatePermissionsEvent extends GenericRoleUpdateEvent
{
private final int oldPermissionsRaw;

public RoleUpdatePermissionsEvent(JDA api, long responseNumber, Role role, int oldPermissionsRaw)
{
super(api, responseNumber, role);
this.oldPermissionsRaw = oldPermissionsRaw;
}

public List<Permission> getOldPermissions()
{
return Collections.unmodifiableList(
Permission.getPermissions(oldPermissionsRaw));
}

public int getOldPermissionsRaw()
{
return oldPermissionsRaw;
}
}
@@ -0,0 +1,43 @@
/*
* 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.core.events.role.update;

import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.entities.Role;

public class RoleUpdatePositionEvent extends GenericRoleUpdateEvent
{
private final int oldPosition;
private final int oldPositionRaw;

public RoleUpdatePositionEvent(JDA api, long responseNumber, Role role, int oldPosition, int oldPositionRaw)
{
super(api, responseNumber, role);
this.oldPosition = oldPosition;
this.oldPositionRaw = oldPositionRaw;
}

public int getOldPosition()
{
return oldPosition;
}

public int getOldPositionRaw()
{
return oldPositionRaw;
}
}

0 comments on commit 03dda44

Please sign in to comment.