mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-27 13:15:28 +01:00
Fixed indent and javadoc from previous commit
This commit is contained in:
parent
8ce47772c2
commit
b4fe70da0c
@ -77,7 +77,7 @@ public class Flag implements Comparable<Flag> {
|
|||||||
private Set<GameModeAddon> gameModes = new HashSet<>();
|
private Set<GameModeAddon> gameModes = new HashSet<>();
|
||||||
private final Addon addon;
|
private final Addon addon;
|
||||||
|
|
||||||
private Flag(Builder builder) {
|
private Flag(Builder builder) {
|
||||||
this.id = builder.id;
|
this.id = builder.id;
|
||||||
this.icon = builder.icon;
|
this.icon = builder.icon;
|
||||||
this.listener = builder.listener;
|
this.listener = builder.listener;
|
||||||
@ -171,14 +171,14 @@ public class Flag implements Comparable<Flag> {
|
|||||||
public boolean hasSubPanel() {
|
public boolean hasSubPanel() {
|
||||||
return subPanel;
|
return subPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the addon that made this flag
|
* Get the addon that made this flag
|
||||||
* @return the addon
|
* @return the addon
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public Addon getAddon() {
|
public Addon getAddon() {
|
||||||
return addon;
|
return addon;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@ -296,14 +296,14 @@ public class Flag implements Comparable<Flag> {
|
|||||||
}
|
}
|
||||||
Island island = plugin.getIslands().getIslandAt(user.getLocation()).orElse(plugin.getIslands().getIsland(user.getWorld(), user.getUniqueId()));
|
Island island = plugin.getIslands().getIslandAt(user.getLocation()).orElse(plugin.getIslands().getIsland(user.getWorld(), user.getUniqueId()));
|
||||||
switch(getType()) {
|
switch(getType()) {
|
||||||
case PROTECTION:
|
case PROTECTION:
|
||||||
return createProtectionFlag(plugin, user, island, pib).build();
|
return createProtectionFlag(plugin, user, island, pib).build();
|
||||||
case SETTING:
|
case SETTING:
|
||||||
return createSettingFlag(user, island, pib).build();
|
return createSettingFlag(user, island, pib).build();
|
||||||
case WORLD_SETTING:
|
case WORLD_SETTING:
|
||||||
return createWorldSettingFlag(user, pib).build();
|
return createWorldSettingFlag(user, pib).build();
|
||||||
default:
|
default:
|
||||||
return pib.build();
|
return pib.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,11 +345,11 @@ public class Flag implements Comparable<Flag> {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Flag [id=" + id + "]";
|
return "Flag [id=" + id + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Flag o) {
|
public int compareTo(Flag o) {
|
||||||
return getID().compareTo(o.getID());
|
return getID().compareTo(o.getID());
|
||||||
}
|
}
|
||||||
@ -381,7 +381,7 @@ public class Flag implements Comparable<Flag> {
|
|||||||
|
|
||||||
// GameModeAddon
|
// GameModeAddon
|
||||||
private GameModeAddon gameModeAddon;
|
private GameModeAddon gameModeAddon;
|
||||||
private Addon addon;
|
private Addon addon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builder for making flags
|
* Builder for making flags
|
||||||
@ -463,7 +463,7 @@ public class Flag implements Comparable<Flag> {
|
|||||||
this.gameModeAddon = gameModeAddon;
|
this.gameModeAddon = gameModeAddon;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The addon registering this flag. Ensure this is set to enable the addon to be reloaded.
|
* The addon registering this flag. Ensure this is set to enable the addon to be reloaded.
|
||||||
* @param addon
|
* @param addon
|
||||||
@ -471,8 +471,8 @@ public class Flag implements Comparable<Flag> {
|
|||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public Builder addon(Addon addon) {
|
public Builder addon(Addon addon) {
|
||||||
this.addon = addon;
|
this.addon = addon;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -483,18 +483,18 @@ public class Flag implements Comparable<Flag> {
|
|||||||
// If no clickHandler has been set, then apply default ones
|
// If no clickHandler has been set, then apply default ones
|
||||||
if (clickHandler == null) {
|
if (clickHandler == null) {
|
||||||
switch (type){
|
switch (type){
|
||||||
case PROTECTION:
|
case PROTECTION:
|
||||||
clickHandler = new CycleClick(id);
|
clickHandler = new CycleClick(id);
|
||||||
break;
|
break;
|
||||||
case SETTING:
|
case SETTING:
|
||||||
clickHandler = new IslandToggleClick(id);
|
clickHandler = new IslandToggleClick(id);
|
||||||
break;
|
break;
|
||||||
case WORLD_SETTING:
|
case WORLD_SETTING:
|
||||||
clickHandler = new WorldToggleClick(id);
|
clickHandler = new WorldToggleClick(id);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
clickHandler = new CycleClick(id);
|
clickHandler = new CycleClick(id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,22 +1,21 @@
|
|||||||
package world.bentobox.bentobox.managers;
|
package world.bentobox.bentobox.managers;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.eclipse.jdt.annotation.NonNull;
|
import org.eclipse.jdt.annotation.NonNull;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
import world.bentobox.bentobox.BentoBox;
|
import world.bentobox.bentobox.BentoBox;
|
||||||
import world.bentobox.bentobox.api.addons.Addon;
|
import world.bentobox.bentobox.api.addons.Addon;
|
||||||
import world.bentobox.bentobox.api.flags.Flag;
|
import world.bentobox.bentobox.api.flags.Flag;
|
||||||
import world.bentobox.bentobox.lists.Flags;
|
import world.bentobox.bentobox.lists.Flags;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Poslovitch
|
* @author Poslovitch
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
@ -42,17 +41,18 @@ public class FlagsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a new flag.
|
* Registers a new flag.
|
||||||
|
* Consider using {@link #registerFlag(Addon, Flag)} instead if your flag declares a listener.
|
||||||
* @param flag flag to be registered
|
* @param flag flag to be registered
|
||||||
* @return true if successfully registered, false if not, e.g., because one with the same ID already exists
|
* @return true if successfully registered, false if not, e.g., because one with the same ID already exists
|
||||||
* @see Consider using {@link #registerFlag(Addon, Flag)} instead if your flag declares a listener
|
* @see #registerFlag(Addon, Flag)
|
||||||
*/
|
*/
|
||||||
public boolean registerFlag(@NonNull Flag flag) {
|
public boolean registerFlag(@NonNull Flag flag) {
|
||||||
return registerFlag(null, flag);
|
return registerFlag(null, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a new flag.
|
* Registers a new flag.
|
||||||
* @param addon - addon that is registering this flag
|
* @param addon - addon that is registering this flag
|
||||||
* @param flag flag to be registered
|
* @param flag flag to be registered
|
||||||
* @return true if successfully registered, false if not, e.g., because one with the same ID already exists
|
* @return true if successfully registered, false if not, e.g., because one with the same ID already exists
|
||||||
@ -70,7 +70,7 @@ public class FlagsManager {
|
|||||||
flag.getListener().ifPresent(this::registerListener);
|
flag.getListener().ifPresent(this::registerListener);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register any unregistered listeners.
|
* Register any unregistered listeners.
|
||||||
* This helps to make sure each flag listener is correctly loaded.
|
* This helps to make sure each flag listener is correctly loaded.
|
||||||
@ -110,17 +110,17 @@ public class FlagsManager {
|
|||||||
return flags.keySet().stream().filter(flag -> flag.getID().equals(id)).findFirst();
|
return flags.keySet().stream().filter(flag -> flag.getID().equals(id)).findFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregister flags for addon
|
* Unregister flags for addon
|
||||||
* @param addon - addon
|
* @param addon - addon
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public void unregister(@NonNull Addon addon) {
|
public void unregister(@NonNull Addon addon) {
|
||||||
// Unregister listeners
|
// Unregister listeners
|
||||||
flags.entrySet().stream().filter(e -> addon.equals(e.getValue())).map(Map.Entry::getKey)
|
flags.entrySet().stream().filter(e -> addon.equals(e.getValue())).map(Map.Entry::getKey)
|
||||||
.forEach(f -> f.getListener().ifPresent(HandlerList::unregisterAll));
|
.forEach(f -> f.getListener().ifPresent(HandlerList::unregisterAll));
|
||||||
// Remove flags
|
// Remove flags
|
||||||
flags.values().removeIf(addon::equals);
|
flags.values().removeIf(addon::equals);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user