Simplified the visibility mixin for now.

This commit is contained in:
Olof Larsson 2013-06-11 07:21:11 +02:00
parent 746ce7fb55
commit 226fcfe32f
5 changed files with 21 additions and 79 deletions

View File

@ -92,7 +92,7 @@ public class InternalListener implements Listener
{
if (!senderId.toLowerCase().startsWith(tokenlc)) continue;
if (current.contains(senderId)) continue;
if (!Mixin.isVisible(watcher, senderId)) continue;
if (!Mixin.canSee(watcher, senderId)) continue;
event.getTabCompletions().add(senderId);
}

View File

@ -47,7 +47,7 @@ public class BukkitGlueCommand extends Command
for (String senderId : Mixin.getOnlineSenderIds())
{
if (!senderId.toLowerCase().startsWith(tokenlc)) continue;
if (!Mixin.isVisible(sender, senderId)) continue;
if (!Mixin.canSee(sender, senderId)) continue;
ret.add(senderId);
}

View File

@ -210,38 +210,21 @@ public class Mixin
// STATIC EXPOSE: VISIBILITY
// -------------------------------------------- //
public static boolean isVisible(String watcherId, String watcheeId)
public static boolean canSee(String watcherId, String watcheeId)
{
return getVisibilityMixin().isVisible(watcherId, watcheeId);
return getVisibilityMixin().canSee(watcherId, watcheeId);
}
public static boolean isVisible(CommandSender watcher, String watcheeId)
public static boolean canSee(CommandSender watcher, String watcheeId)
{
return getVisibilityMixin().isVisible(watcher, watcheeId);
return getVisibilityMixin().canSee(watcher, watcheeId);
}
public static boolean isVisible(String watcherId, CommandSender watchee)
public static boolean canSee(String watcherId, CommandSender watchee)
{
return getVisibilityMixin().isVisible(watcherId, watchee);
return getVisibilityMixin().canSee(watcherId, watchee);
}
public static boolean isVisible(CommandSender watcher, CommandSender watchee)
public static boolean canSee(CommandSender watcher, CommandSender watchee)
{
return getVisibilityMixin().isVisible(watcher, watchee);
}
public static void setVisible(String watcherId, String watcheeId, boolean visible)
{
getVisibilityMixin().setVisible(watcherId, watcheeId, visible);
}
public static void setVisible(CommandSender watcher, String watcheeId, boolean visible)
{
getVisibilityMixin().setVisible(watcher, watcheeId, visible);
}
public static void setVisible(String watcherId, CommandSender watchee, boolean visible)
{
getVisibilityMixin().setVisible(watcherId, watchee, visible);
}
public static void setVisible(CommandSender watcher, CommandSender watchee, boolean visible)
{
getVisibilityMixin().setVisible(watcher, watchee, visible);
return getVisibilityMixin().canSee(watcher, watchee);
}
// -------------------------------------------- //

View File

@ -4,13 +4,8 @@ import org.bukkit.command.CommandSender;
public interface VisibilityMixin
{
public boolean isVisible(String watcherId, String watcheeId);
public boolean isVisible(CommandSender watcher, String watcheeId);
public boolean isVisible(String watcherId, CommandSender watchee);
public boolean isVisible(CommandSender watcher, CommandSender watchee);
public void setVisible(String watcherId, String watcheeId, boolean visible);
public void setVisible(CommandSender watcher, String watcheeId, boolean visible);
public void setVisible(String watcherId, CommandSender watchee, boolean visible);
public void setVisible(CommandSender watcher, CommandSender watchee, boolean visible);
public boolean canSee(String watcherId, String watcheeId);
public boolean canSee(CommandSender watcher, String watcheeId);
public boolean canSee(String watcherId, CommandSender watchee);
public boolean canSee(CommandSender watcher, CommandSender watchee);
}

View File

@ -19,25 +19,25 @@ public class VisibilityMixinDefault extends VisibilityMixinAbstract
// -------------------------------------------- //
@Override
public boolean isVisible(String watcherId, String watcheeId)
public boolean canSee(String watcherId, String watcheeId)
{
return this.isVisible(SenderUtil.getSender(watcherId), SenderUtil.getSender(watcheeId));
return this.canSee(SenderUtil.getSender(watcherId), SenderUtil.getSender(watcheeId));
}
@Override
public boolean isVisible(CommandSender watcher, String watcheeId)
public boolean canSee(CommandSender watcher, String watcheeId)
{
return this.isVisible(watcher, SenderUtil.getSender(watcheeId));
return this.canSee(watcher, SenderUtil.getSender(watcheeId));
}
@Override
public boolean isVisible(String watcherId, CommandSender watchee)
public boolean canSee(String watcherId, CommandSender watchee)
{
return this.isVisible(SenderUtil.getSender(watcherId), watchee);
return this.canSee(SenderUtil.getSender(watcherId), watchee);
}
@Override
public boolean isVisible(CommandSender watcher, CommandSender watchee)
public boolean canSee(CommandSender watcher, CommandSender watchee)
{
Player pwatcher = SenderUtil.getAsPlayer(watcher);
Player pwatchee = SenderUtil.getAsPlayer(watchee);
@ -48,40 +48,4 @@ public class VisibilityMixinDefault extends VisibilityMixinAbstract
return pwatcher.canSee(pwatchee);
}
@Override
public void setVisible(String watcherId, String watcheeId, boolean visible)
{
this.setVisible(SenderUtil.getSender(watcherId), SenderUtil.getSender(watcheeId), visible);
}
@Override
public void setVisible(CommandSender watcher, String watcheeId, boolean visible)
{
this.setVisible(watcher, SenderUtil.getSender(watcheeId), visible);
}
@Override
public void setVisible(String watcherId, CommandSender watchee, boolean visible)
{
this.setVisible(SenderUtil.getSender(watcherId), watchee, visible);
}
@Override
public void setVisible(CommandSender watcher, CommandSender watchee, boolean visible)
{
Player pwatcher = SenderUtil.getAsPlayer(watcher);
Player pwatchee = SenderUtil.getAsPlayer(watchee);
if (pwatcher == null) return;
if (pwatchee == null) return;
if (visible)
{
pwatcher.showPlayer(pwatchee);
}
else
{
pwatcher.hidePlayer(pwatchee);
}
}
}