Skip to content

Commit

Permalink
Fix bug where switching was affecting non game worlds
Browse files Browse the repository at this point in the history
#21

Removed Pladdon. Made compatible with 1.16.2.
  • Loading branch information
tastybento committed Jun 27, 2021
1 parent 7cf1170 commit 934c063
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 39 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>16</java.version>
<java.version>8</java.version>
<!-- Non-minecraft related dependencies -->
<powermock.version>2.0.9</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.17-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>1.17.0-SNAPSHOT</bentobox.version>
<spigot.version>1.16.5-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>1.16.2</bentobox.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- Do not change unless you want different name for local builds. -->
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wasteofplastic.invswitcher.listeners;

import org.bukkit.World;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
Expand Down Expand Up @@ -34,22 +35,21 @@ public PlayerListener(InvSwitcher addon) {
*/
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled=true)
public void onWorldEnter(final PlayerChangedWorldEvent event) {
if (!Util.sameWorld(event.getPlayer().getWorld(), event.getFrom())
&& (addon.getWorlds().contains(event.getPlayer().getWorld())
|| addon.getWorlds().contains(event.getFrom()))) {
addon.getStore().getInventory(event.getPlayer(), event.getPlayer().getWorld());
}
}

/**
* Saves inventory
* @param event - event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onWorldExit(final PlayerChangedWorldEvent event) {
if (!Util.sameWorld(event.getPlayer().getWorld(), event.getFrom())) {
addon.getStore().storeInventory(event.getPlayer(), event.getFrom());
/*
* 0. From same world (e.g., nether/end) to same world.
* 1. From non-game world to non-game world
* 2. From non-game world to game world
* 3. From game world to non-game world
* 4. From game world to another game world
*
*/
World from = event.getFrom();
World to = event.getPlayer().getWorld();
if (Util.sameWorld(to, from) || (!addon.getWorlds().contains(from) && !addon.getWorlds().contains(to))) {
return;
}
addon.getStore().storeInventory(event.getPlayer(), from);
addon.getStore().getInventory(event.getPlayer(), to);
}


Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/addon.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: InvSwitcher
main: com.wasteofplastic.invswitcher.InvSwitcher
version: ${version}${build.number}
api-version: 1.14
api-version: 1.16

authors: tastybento

Expand Down
8 changes: 0 additions & 8 deletions src/main/resources/plugin.yml

This file was deleted.

0 comments on commit 934c063

Please sign in to comment.