From a4a965d45012e5bcb6c8fab8f0d8cd7640f7836a Mon Sep 17 00:00:00 2001 From: NavidK0 Date: Wed, 12 Aug 2015 16:21:08 -0700 Subject: [PATCH] Fixed bug where disguise would be visible for a few seconds after teleporting. --- .gitattributes | 22 -- .gitignore | 226 +----------------- .../disguise/DisguiseListener.java | 30 ++- 3 files changed, 18 insertions(+), 260 deletions(-) delete mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 412eeda7..00000000 --- a/.gitattributes +++ /dev/null @@ -1,22 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto - -# Custom for Visual Studio -*.cs diff=csharp -*.sln merge=union -*.csproj merge=union -*.vbproj merge=union -*.fsproj merge=union -*.dbproj merge=union - -# Standard to msysgit -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore index bb9a1af5..87aa62d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,222 +1,4 @@ -################# -## Eclipse -################# - -*.pydevproject -.project -.metadata -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.classpath -.settings/ -.loadpath -target/ -build -libs -dist -.gradle -gradle.properties - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# CDT-specific -.cproject - -# PDT-specific -.buildpath - - -################# -## Visual Studio -################# - -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.sln.docstates - -# Build results - -[Dd]ebug/ -[Rr]elease/ -x64/ -build/ -[Bb]in/ -[Oo]bj/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -*_i.c -*_p.c -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.log -*.scc - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -*.ncrunch* -.*crunch*.local.xml - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.Publish.xml -*.pubxml - -# NuGet Packages Directory -## TODO: If you have NuGet Package Restore enabled, uncomment the next line -#packages/ - -# Windows Azure Build Output -csx -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Others -sql/ -*.Cache -ClientBin/ -[Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.[Pp]ublish.xml -*.pfx -*.publishsettings - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -App_Data/*.mdf -App_Data/*.ldf - -############# -## Windows detritus -############# - -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Mac crap -.DS_Store - - -############# -## Python -############# - -*.py[co] - -# Packages -*.egg -*.egg-info -dist/ -build/ -eggs/ -parts/ -var/ -sdist/ -develop-eggs/ -.installed.cfg - -# Installer logs -pip-log.txt - -# Unit test / coverage reports -.coverage -.tox - -#Translations -*.mo - -#Mr Developer -.mr.developer.cfg -/.nb-gradle/private/ \ No newline at end of file +* +!src +!build.gradle +!settings.gradle \ No newline at end of file diff --git a/src/main/java/me/libraryaddict/disguise/DisguiseListener.java b/src/main/java/me/libraryaddict/disguise/DisguiseListener.java index d095e518..ddba863d 100644 --- a/src/main/java/me/libraryaddict/disguise/DisguiseListener.java +++ b/src/main/java/me/libraryaddict/disguise/DisguiseListener.java @@ -38,7 +38,6 @@ import org.bukkit.scheduler.BukkitRunnable; import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.events.PacketContainer; -import org.bukkit.entity.Arrow; import org.bukkit.scheduler.BukkitTask; public class DisguiseListener implements Listener { @@ -163,7 +162,6 @@ public class DisguiseListener implements Listener { /** * Most likely faster if we don't bother doing checks if he sees a player disguise * - * @param event */ @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onMove(PlayerMoveEvent event) { @@ -204,7 +202,7 @@ public class DisguiseListener implements Listener { Entity entity = event.getRightClicked(); String entityName; if (entity instanceof Player && !disguiseClone.containsKey(p.getName())) { - entityName = ((Player) entity).getName(); + entityName = entity.getName(); } else { entityName = DisguiseType.getType(entity).toReadable(); } @@ -246,9 +244,9 @@ public class DisguiseListener implements Listener { } else { if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise()) { if (disguise.getWatcher() instanceof LivingWatcher) { - ((LivingWatcher) disguise.getWatcher()).setCustomName(((Player) entity).getDisplayName()); + disguise.getWatcher().setCustomName(((Player) entity).getDisplayName()); if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) { - ((LivingWatcher) disguise.getWatcher()).setCustomNameVisible(true); + disguise.getWatcher().setCustomNameVisible(true); } } } @@ -327,17 +325,6 @@ public class DisguiseListener implements Listener { for (Disguise disguise : DisguiseAPI.getDisguises(event.getPlayer())) { disguise.removeDisguise(); } - } else { - //Stupid hack to fix worldswitch invisibility bug - final boolean viewSelfToggled = DisguiseAPI.isViewSelfToggled(event.getPlayer()); - final Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer()); - disguise.setViewSelfDisguise(!viewSelfToggled); - Bukkit.getScheduler().runTaskLater(plugin, new Runnable() { - @Override - public void run() { - disguise.setViewSelfDisguise(viewSelfToggled); - } - }, 20L); //I wish I could use lambdas here, so badly } } @@ -377,6 +364,17 @@ public class DisguiseListener implements Listener { for (Disguise disguise : DisguiseAPI.getDisguises(event.getPlayer())) { disguise.removeDisguise(); } + } else { + //Stupid hack to fix worldswitch invisibility bug + final boolean viewSelfToggled = DisguiseAPI.isViewSelfToggled(event.getPlayer()); + final Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer()); + disguise.setViewSelfDisguise(!viewSelfToggled); + Bukkit.getScheduler().runTaskLater(plugin, new Runnable() { + @Override + public void run() { + disguise.setViewSelfDisguise(viewSelfToggled); + } + }, 4L); //I wish I could use lambdas here, so badly } }