geforkt von Mirrors/FastAsyncWorldEdit
Fix #826
Dieser Commit ist enthalten in:
Ursprung
4050cf238f
Commit
da8289f8ba
@ -21,6 +21,7 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.platform.SessionIdleEvent;
|
||||
@ -37,6 +38,7 @@ import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerCommandSendEvent;
|
||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.enginehub.piston.CommandManager;
|
||||
@ -68,10 +70,29 @@ public class WorldEditListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
// this will automatically refresh their session, we don't have to do anything
|
||||
WorldEdit.getInstance().getSessionManager().get(plugin.wrapPlayer(event.getPlayer()));
|
||||
//FAWE start - correctly handle refreshing LocalSession
|
||||
Player player = plugin.wrapPlayer(event.getPlayer());
|
||||
LocalSession session;
|
||||
if ((session = WorldEdit.getInstance().getSessionManager().getIfPresent(player)) == null) {
|
||||
session = WorldEdit.getInstance().getSessionManager().get(player);
|
||||
}
|
||||
session.loadDefaults(player, true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
if (!plugin.getInternalPlatform().isHookingEvents()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = plugin.wrapPlayer(event.getPlayer());
|
||||
LocalSession session;
|
||||
if ((session = WorldEdit.getInstance().getSessionManager().getIfPresent(player)) != null) {
|
||||
session.loadDefaults(player, true);
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerCommandSend(PlayerCommandSendEvent event) {
|
||||
InjectedValueStore store = MapBackedValueStore.create();
|
||||
|
@ -1071,10 +1071,26 @@ public class LocalSession implements TextureHolder {
|
||||
*/
|
||||
@Nullable
|
||||
@Deprecated
|
||||
public Tool getTool(ItemType item) {
|
||||
//FAWE start - refresh wand item if permissions change
|
||||
public Tool getTool(ItemType item, Player player) {
|
||||
Tool tool;
|
||||
synchronized (this.tools) {
|
||||
return tools.get(item.getInternalId());
|
||||
tool = tools.get(item.getInternalId());
|
||||
}
|
||||
if (tool == SelectionWand.INSTANCE && !SelectionWand.INSTANCE.canUse(player)) {
|
||||
tools.remove(wandItem.getInternalId());
|
||||
loadDefaults(player, true); // Permissions have changed so redo the player's current tools.
|
||||
return null;
|
||||
}
|
||||
if (tool != null) {
|
||||
return tool;
|
||||
} else if (item.getInternalId() == wandItem.getInternalId() && SelectionWand.INSTANCE.canUse(player)) {
|
||||
loadDefaults(player, true); // Permissions have changed so redo the player's current tools.
|
||||
return SelectionWand.INSTANCE;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
@ -1098,7 +1114,7 @@ public class LocalSession implements TextureHolder {
|
||||
return tool;
|
||||
}
|
||||
}
|
||||
return getTool(item.getType());
|
||||
return getTool(item.getType(), player);
|
||||
}
|
||||
|
||||
public void loadDefaults(Actor actor, boolean force) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren