fix bug + add notification system to equipment too
This commit is contained in:
		
							parent
							
								
									2d76a9eac8
								
							
						
					
					
						commit
						2eaaca878e
					
				
					 4 changed files with 28 additions and 15 deletions
				
			
		|  | @ -6,18 +6,9 @@ | ||||||
|   <component name="ChangeListManager"> |   <component name="ChangeListManager"> | ||||||
|     <list default="true" id="9d5d9b6f-43c8-41a4-bb42-a66ffc96c9b0" name="Changes" comment=""> |     <list default="true" id="9d5d9b6f-43c8-41a4-bb42-a66ffc96c9b0" name="Changes" comment=""> | ||||||
|       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> |       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> | ||||||
|       <change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/EntityLibAPI.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/EntityLibAPI.java" afterDir="false" /> |  | ||||||
|       <change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/EntityMeta.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/EntityMeta.java" afterDir="false" /> |  | ||||||
|       <change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/MetaOffsetConverter.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/MetaOffsetConverter.java" afterDir="false" /> |  | ||||||
|       <change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/Metadata.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/Metadata.java" afterDir="false" /> |       <change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/Metadata.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/meta/Metadata.java" afterDir="false" /> | ||||||
|       <change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntity.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntity.java" afterDir="false" /> |       <change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntity.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntity.java" afterDir="false" /> | ||||||
|       <change beforePath="$PROJECT_DIR$/code-gen/src/main/java/me/tofaa/entitylib/codegen/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/code-gen/src/main/java/me/tofaa/entitylib/codegen/Main.java" afterDir="false" /> |       <change beforePath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntityEquipment.java" beforeDir="false" afterPath="$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntityEquipment.java" afterDir="false" /> | ||||||
|       <change beforePath="$PROJECT_DIR$/code-gen/src/main/resources/offset-calculator.json" beforeDir="false" afterPath="$PROJECT_DIR$/code-gen/src/main/resources/offset-calculator.json" afterDir="false" /> |  | ||||||
|       <change beforePath="$PROJECT_DIR$/common/src/main/java/me/tofaa/entitylib/common/AbstractEntityLibAPI.java" beforeDir="false" afterPath="$PROJECT_DIR$/common/src/main/java/me/tofaa/entitylib/common/AbstractEntityLibAPI.java" afterDir="false" /> |  | ||||||
|       <change beforePath="$PROJECT_DIR$/common/src/main/java/me/tofaa/entitylib/common/AbstractWorldWrapper.java" beforeDir="false" afterPath="$PROJECT_DIR$/common/src/main/java/me/tofaa/entitylib/common/AbstractWorldWrapper.java" afterDir="false" /> |  | ||||||
|       <change beforePath="$PROJECT_DIR$/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibPlatform.java" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibPlatform.java" afterDir="false" /> |  | ||||||
|       <change beforePath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/testentitylib/TestEntityLibPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/testentitylib/TestEntityLibPlugin.java" afterDir="false" /> |  | ||||||
|       <change beforePath="$PROJECT_DIR$/test-plugin/src/main/resources/plugin.yml" beforeDir="false" afterPath="$PROJECT_DIR$/test-plugin/src/main/resources/plugin.yml" afterDir="false" /> |  | ||||||
|     </list> |     </list> | ||||||
|     <option name="SHOW_DIALOG" value="false" /> |     <option name="SHOW_DIALOG" value="false" /> | ||||||
|     <option name="HIGHLIGHT_CONFLICTS" value="true" /> |     <option name="HIGHLIGHT_CONFLICTS" value="true" /> | ||||||
|  | @ -304,7 +295,9 @@ | ||||||
|       <workItem from="1706858181164" duration="925000" /> |       <workItem from="1706858181164" duration="925000" /> | ||||||
|       <workItem from="1707159905372" duration="3391000" /> |       <workItem from="1707159905372" duration="3391000" /> | ||||||
|       <workItem from="1707210065718" duration="4823000" /> |       <workItem from="1707210065718" duration="4823000" /> | ||||||
|       <workItem from="1707219870641" duration="4868000" /> |       <workItem from="1707219870641" duration="5522000" /> | ||||||
|  |       <workItem from="1707300688189" duration="1512000" /> | ||||||
|  |       <workItem from="1707381529971" duration="921000" /> | ||||||
|     </task> |     </task> | ||||||
|     <servers /> |     <servers /> | ||||||
|   </component> |   </component> | ||||||
|  |  | ||||||
|  | @ -83,7 +83,7 @@ public class Metadata { | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     public boolean isNotifyingChanges() { |     public boolean isNotifyingChanges() { | ||||||
|         return notifyChanges; |         return notifyChanges;  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @NotNull List<EntityData> getEntries() { |     @NotNull List<EntityData> getEntries() { | ||||||
|  |  | ||||||
|  | @ -327,7 +327,15 @@ public class WrapperEntity implements Tickable { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private static void sendPacket(UUID user, PacketWrapper<?> wrapper) { |     private static void sendPacket(UUID user, PacketWrapper<?> wrapper) { | ||||||
|         EntityLib.getApi().getPacketEvents().getProtocolManager().sendPacket(EntityLib.getApi().getPacketEvents().getProtocolManager().getChannel(user), wrapper); | 
 | ||||||
|  |         Object channel = EntityLib.getApi().getPacketEvents().getProtocolManager().getChannel(user); | ||||||
|  |         if (channel == null) { | ||||||
|  |             if (EntityLib.getApi().getSettings().isDebugMode()) { | ||||||
|  |                 EntityLib.getPlatform().getLogger().warning("Failed to send packet to " + user + " because the channel was null. They may be disconnected/not online."); | ||||||
|  |             } | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         EntityLib.getApi().getPacketEvents().getProtocolManager().sendPacket(channel, wrapper); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public boolean hasNoGravity() { |     public boolean hasNoGravity() { | ||||||
|  |  | ||||||
|  | @ -19,7 +19,7 @@ public class WrapperEntityEquipment { | ||||||
|     private static final EquipmentSlot[] EQUIPMENT_SLOTS = EquipmentSlot.values(); |     private static final EquipmentSlot[] EQUIPMENT_SLOTS = EquipmentSlot.values(); | ||||||
| 
 | 
 | ||||||
|     private final WrapperLivingEntity entity; |     private final WrapperLivingEntity entity; | ||||||
| 
 |     private boolean notifyChanges = true; | ||||||
| 
 | 
 | ||||||
|     // 0 = main hand, 1 = offhand, 2 = boots, 3 = leggings, 4 = chestplate, 5 = helmet |     // 0 = main hand, 1 = offhand, 2 = boots, 3 = leggings, 4 = chestplate, 5 = helmet | ||||||
|     private final ItemStack[] equipment = new ItemStack[6]; |     private final ItemStack[] equipment = new ItemStack[6]; | ||||||
|  | @ -113,7 +113,19 @@ public class WrapperEntityEquipment { | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     public void refresh() { |     public void refresh() { | ||||||
|         this.entity.sendPacketToViewers(createPacket()); |         if (notifyChanges) { | ||||||
|  |             this.entity.sendPacketToViewers(createPacket()); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public boolean isNotifyingChanges() { | ||||||
|  |         return notifyChanges; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setNotifyChanges(boolean notifyChanges) { | ||||||
|  |         this.notifyChanges = notifyChanges; | ||||||
|  |         if (notifyChanges) { | ||||||
|  |             refresh(); | ||||||
|  |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue