mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-07 19:40:23 +01:00
Merge branch 'refs/heads/groupmanager'
This commit is contained in:
commit
0ea41d9169
@ -108,4 +108,7 @@ v 1.9:
|
||||
- Better optimize assembling of a players permissions and allow the * node to populate all registered superperms.
|
||||
- Fixed text when adding a subgroup to not say the player was moved.
|
||||
- Update to new Bukkit Event system.
|
||||
- Update GroupManagerBridge for new event system.
|
||||
- Update GroupManagerBridge for new event system.
|
||||
- Fixed a random null error upon a player portaling.
|
||||
- Fixed infinite loop error on player join.
|
||||
- Optimized code to only update the player logging in instead of all players online.
|
@ -26,7 +26,6 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.anjocaido.groupmanager.dataholder.worlds.WorldsHolder;
|
||||
import org.anjocaido.groupmanager.events.GMWorldListener;
|
||||
import org.anjocaido.groupmanager.events.GroupManagerEvent;
|
||||
import org.anjocaido.groupmanager.utils.GMLoggerHandler;
|
||||
import org.anjocaido.groupmanager.utils.PermissionCheckResult;
|
||||
import org.anjocaido.groupmanager.utils.Tasks;
|
||||
|
@ -114,7 +114,7 @@ public class User extends DataUnit implements Cloneable {
|
||||
flagAsChanged();
|
||||
if (GroupManager.isLoaded())
|
||||
if (!GroupManager.BukkitPermissions.isPlayer_join())
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
GroupManager.BukkitPermissions.updatePlayer(getBukkitPlayer());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -131,7 +131,7 @@ public class User extends DataUnit implements Cloneable {
|
||||
flagAsChanged();
|
||||
if (GroupManager.isLoaded()) {
|
||||
if (!GroupManager.BukkitPermissions.isPlayer_join())
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
GroupManager.BukkitPermissions.updatePlayer(getBukkitPlayer());
|
||||
|
||||
// Do we notify of the group change?
|
||||
String defaultGroupName = getDataSource().getDefaultGroup().getName();
|
||||
@ -160,7 +160,7 @@ public class User extends DataUnit implements Cloneable {
|
||||
flagAsChanged();
|
||||
if (GroupManager.isLoaded()) {
|
||||
if (!GroupManager.BukkitPermissions.isPlayer_join())
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
GroupManager.BukkitPermissions.updatePlayer(getBukkitPlayer());
|
||||
GroupManagerEventHandler.callEvent(this, Action.USER_SUBGROUP_CHANGED);
|
||||
}
|
||||
}
|
||||
@ -183,7 +183,7 @@ public class User extends DataUnit implements Cloneable {
|
||||
flagAsChanged();
|
||||
if (GroupManager.isLoaded())
|
||||
if (!GroupManager.BukkitPermissions.isPlayer_join())
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
GroupManager.BukkitPermissions.updatePlayer(getBukkitPlayer());
|
||||
GroupManagerEventHandler.callEvent(this, Action.USER_SUBGROUP_CHANGED);
|
||||
return true;
|
||||
}
|
||||
@ -229,8 +229,8 @@ public class User extends DataUnit implements Cloneable {
|
||||
}
|
||||
flagAsChanged();
|
||||
if (GroupManager.isLoaded()) {
|
||||
if (!GroupManager.BukkitPermissions.isPlayer_join())
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
//if (!GroupManager.BukkitPermissions.isPlayer_join())
|
||||
// GroupManager.BukkitPermissions.updatePlayer(this.getName());
|
||||
GroupManagerEventHandler.callEvent(this, Action.USER_INFO_CHANGED);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
package org.anjocaido.groupmanager.events;
|
||||
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
import org.anjocaido.groupmanager.data.Group;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
|
||||
@ -8,7 +11,7 @@ import org.bukkit.event.HandlerList;
|
||||
* @author ElgarL
|
||||
*
|
||||
*/
|
||||
public class GMGroupEvent extends GroupManagerEvent {
|
||||
public class GMGroupEvent extends Event {
|
||||
|
||||
/**
|
||||
*
|
||||
@ -67,4 +70,16 @@ public class GMGroupEvent extends GroupManagerEvent {
|
||||
GROUP_ADDED,
|
||||
GROUP_REMOVED,
|
||||
}
|
||||
|
||||
public void schedule(final GMGroupEvent event) {
|
||||
|
||||
if (Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("GroupManager"), new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
}, 1) == -1)
|
||||
GroupManager.logger.warning("Could not schedule GM Event.");
|
||||
}
|
||||
}
|
@ -1,5 +1,8 @@
|
||||
package org.anjocaido.groupmanager.events;
|
||||
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
|
||||
@ -7,7 +10,7 @@ import org.bukkit.event.HandlerList;
|
||||
* @author ElgarL
|
||||
*
|
||||
*/
|
||||
public class GMSystemEvent extends GroupManagerEvent {
|
||||
public class GMSystemEvent extends Event {
|
||||
|
||||
/**
|
||||
*
|
||||
@ -44,4 +47,16 @@ public class GMSystemEvent extends GroupManagerEvent {
|
||||
DEFAULT_GROUP_CHANGED,
|
||||
VALIDATE_TOGGLE,
|
||||
}
|
||||
|
||||
public void schedule(final GMSystemEvent event) {
|
||||
|
||||
if (Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("GroupManager"), new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
}, 1) == -1)
|
||||
GroupManager.logger.warning("Could not schedule GM Event.");
|
||||
}
|
||||
}
|
@ -1,6 +1,9 @@
|
||||
package org.anjocaido.groupmanager.events;
|
||||
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
import org.anjocaido.groupmanager.data.User;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
|
||||
@ -8,7 +11,7 @@ import org.bukkit.event.HandlerList;
|
||||
* @author ElgarL
|
||||
*
|
||||
*/
|
||||
public class GMUserEvent extends GroupManagerEvent {
|
||||
public class GMUserEvent extends Event {
|
||||
|
||||
/**
|
||||
*
|
||||
@ -69,4 +72,16 @@ public class GMUserEvent extends GroupManagerEvent {
|
||||
USER_ADDED,
|
||||
USER_REMOVED,
|
||||
}
|
||||
|
||||
public void schedule(final GMUserEvent event) {
|
||||
|
||||
if (Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("GroupManager"), new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
}, 1) == -1)
|
||||
GroupManager.logger.warning("Could not schedule GM Event.");
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package org.anjocaido.groupmanager.events;
|
||||
|
||||
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
/**
|
||||
* @author ElgarL
|
||||
*
|
||||
*/
|
||||
public abstract class GroupManagerEvent extends Event {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 8790362185329926951L;
|
||||
|
||||
protected GroupManagerEvent(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers all GroupManager events for other plugins to see.
|
||||
* Schedules events for 1 tick later to allow GM to finish populating super perms.
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
public void schedule(final GroupManagerEvent event) {
|
||||
|
||||
if (Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("GroupManager"), new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
}, 1) == -1)
|
||||
GroupManager.logger.warning("Could not schedule GM Event.");
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -6,6 +6,8 @@ import org.anjocaido.groupmanager.data.User;
|
||||
|
||||
/**
|
||||
* @author ElgarL
|
||||
*
|
||||
* Handles all Event generation.
|
||||
*
|
||||
*/
|
||||
public class GroupManagerEventHandler {
|
||||
|
@ -122,7 +122,6 @@ public class BukkitPermissions {
|
||||
registeredPermissions = new LinkedList<Permission>(Bukkit.getPluginManager().getPermissions());
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void updatePermissions(Player player) {
|
||||
this.updatePermissions(player, null);
|
||||
@ -361,6 +360,14 @@ public class BukkitPermissions {
|
||||
updatePermissions(player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* force Bukkit to update this Players permissions.
|
||||
*/
|
||||
public void updatePlayer(Player player) {
|
||||
if (player != null)
|
||||
this.updatePermissions(player, null);
|
||||
}
|
||||
|
||||
protected class PlayerEvents implements Listener {
|
||||
|
||||
@ -370,7 +377,7 @@ public class BukkitPermissions {
|
||||
Player player = event.getPlayer();
|
||||
// force GM to create the player if they are not already listed.
|
||||
if (plugin.getWorldsHolder().getWorldData(player.getWorld().getName()).getUser(player.getName()) != null) {
|
||||
//setPlayer_join(false);
|
||||
setPlayer_join(false);
|
||||
updatePermissions(event.getPlayer());
|
||||
}
|
||||
setPlayer_join(false);
|
||||
@ -378,7 +385,7 @@ public class BukkitPermissions {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerPortal(PlayerPortalEvent event) { // will portal into another world
|
||||
if (event.getTo() != null && !event.getFrom().getWorld().equals(event.getTo().getWorld())) { // only if world actually changed
|
||||
if ((event.getTo() != null) && (!event.getFrom().getWorld().equals(event.getTo().getWorld()))) { // only if world actually changed
|
||||
updatePermissions(event.getPlayer(), event.getTo().getWorld().getName());
|
||||
}
|
||||
}
|
||||
@ -390,7 +397,7 @@ public class BukkitPermissions {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) { // can be teleported into another world
|
||||
if (event.getTo() != null && !event.getFrom().getWorld().equals(event.getTo().getWorld())) { // only if world actually changed
|
||||
if ((event.getTo() != null) && (!event.getFrom().getWorld().equals(event.getTo().getWorld()))) { // only if world actually changed
|
||||
updatePermissions(event.getPlayer(), event.getTo().getWorld().getName());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user