-
-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2449 from BentoBoxWorld/develop
Release 2.4.2
- Loading branch information
Showing
25 changed files
with
436 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/world/bentobox/bentobox/database/json/adapters/ProfessionTypeAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package world.bentobox.bentobox.database.json.adapters; | ||
|
||
import java.io.IOException; | ||
|
||
import org.bukkit.entity.Villager.Profession; | ||
|
||
import com.google.gson.TypeAdapter; | ||
import com.google.gson.stream.JsonReader; | ||
import com.google.gson.stream.JsonToken; | ||
import com.google.gson.stream.JsonWriter; | ||
|
||
public class ProfessionTypeAdapter extends TypeAdapter<Profession> { | ||
|
||
@Override | ||
public void write(JsonWriter out, Profession profession) throws IOException { | ||
out.value(profession.name()); | ||
} | ||
|
||
@Override | ||
public Profession read(JsonReader reader) throws IOException { | ||
if (reader.peek() == JsonToken.NULL) { | ||
reader.nextNull(); | ||
return null; | ||
} | ||
String id = reader.nextString(); | ||
try { | ||
return Profession.valueOf(id); | ||
} catch (Exception e) { | ||
// Do nothing | ||
} | ||
return Profession.NONE; | ||
|
||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/world/bentobox/bentobox/database/json/adapters/VillagerTypeAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package world.bentobox.bentobox.database.json.adapters; | ||
|
||
import java.io.IOException; | ||
|
||
import org.bukkit.entity.Villager; | ||
|
||
import com.google.gson.TypeAdapter; | ||
import com.google.gson.stream.JsonReader; | ||
import com.google.gson.stream.JsonToken; | ||
import com.google.gson.stream.JsonWriter; | ||
|
||
public class VillagerTypeAdapter extends TypeAdapter<Villager.Type> { | ||
|
||
@Override | ||
public void write(JsonWriter out, Villager.Type type) throws IOException { | ||
out.value(type.name()); | ||
} | ||
|
||
@Override | ||
public Villager.Type read(JsonReader reader) throws IOException { | ||
if (reader.peek() == JsonToken.NULL) { | ||
reader.nextNull(); | ||
return null; | ||
} | ||
String id = reader.nextString(); | ||
try { | ||
return Villager.Type.valueOf(id); | ||
} catch (Exception e) { | ||
// Do nothing | ||
} | ||
return Villager.Type.PLAINS; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/world/bentobox/bentobox/listeners/flags/protection/CandleListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package world.bentobox.bentobox.listeners.flags.protection; | ||
|
||
import org.bukkit.Tag; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.player.PlayerInteractEvent; | ||
|
||
import world.bentobox.bentobox.api.flags.FlagListener; | ||
import world.bentobox.bentobox.lists.Flags; | ||
|
||
/** | ||
* Protects candles | ||
* @author tastybento | ||
* @since 2.4.2 | ||
*/ | ||
public class CandleListener extends FlagListener { | ||
|
||
/** | ||
* Prevent dying signs. | ||
* @param e - event | ||
*/ | ||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) | ||
public void onCandleInteract(final PlayerInteractEvent e) { | ||
if (e.getClickedBlock() == null) { | ||
return; | ||
} | ||
|
||
if (Tag.CANDLES.isTagged(e.getClickedBlock().getType()) | ||
|| Tag.CANDLE_CAKES.isTagged(e.getClickedBlock().getType())) { | ||
this.checkIsland(e, e.getPlayer(), e.getClickedBlock().getLocation(), Flags.CANDLES); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.