Fixed bug where disguise would be visible for a few seconds after teleporting.

This commit is contained in:
NavidK0 2015-08-12 16:21:08 -07:00
parent 41cfa8eeaa
commit a4a965d450
3 changed files with 18 additions and 260 deletions

22
.gitattributes vendored
View File

@ -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

226
.gitignore vendored
View File

@ -1,222 +1,4 @@
################# *
## Eclipse !src
################# !build.gradle
!settings.gradle
*.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/

View File

@ -38,7 +38,6 @@ import org.bukkit.scheduler.BukkitRunnable;
import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketContainer;
import org.bukkit.entity.Arrow;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
public class DisguiseListener implements Listener { 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 * Most likely faster if we don't bother doing checks if he sees a player disguise
* *
* @param event
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onMove(PlayerMoveEvent event) { public void onMove(PlayerMoveEvent event) {
@ -204,7 +202,7 @@ public class DisguiseListener implements Listener {
Entity entity = event.getRightClicked(); Entity entity = event.getRightClicked();
String entityName; String entityName;
if (entity instanceof Player && !disguiseClone.containsKey(p.getName())) { if (entity instanceof Player && !disguiseClone.containsKey(p.getName())) {
entityName = ((Player) entity).getName(); entityName = entity.getName();
} else { } else {
entityName = DisguiseType.getType(entity).toReadable(); entityName = DisguiseType.getType(entity).toReadable();
} }
@ -246,9 +244,9 @@ public class DisguiseListener implements Listener {
} else { } else {
if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise()) { if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise()) {
if (disguise.getWatcher() instanceof LivingWatcher) { if (disguise.getWatcher() instanceof LivingWatcher) {
((LivingWatcher) disguise.getWatcher()).setCustomName(((Player) entity).getDisplayName()); disguise.getWatcher().setCustomName(((Player) entity).getDisplayName());
if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) { 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())) { for (Disguise disguise : DisguiseAPI.getDisguises(event.getPlayer())) {
disguise.removeDisguise(); 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())) { for (Disguise disguise : DisguiseAPI.getDisguises(event.getPlayer())) {
disguise.removeDisguise(); 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
} }
} }