Browse files

Added profile types to world groups.

  • Loading branch information...
1 parent 0a8ea9f commit 16fb0d9bfc5fe0a2c31606efb779ab6d2df36b84 @dumptruckman dumptruckman committed May 24, 2012
View
3 config.yml
@@ -7,6 +7,9 @@ groups:
- inventory
spawn:
world: world1
+ profiles:
+ - default_profile
+ - game_mode_profile
group2:
worlds:
- world2
View
26 src/main/java/com/onarandombox/multiverseinventories/DefaultWorldGroupProfile.java
@@ -3,6 +3,7 @@
import com.google.common.collect.Lists;
import com.onarandombox.multiverseinventories.api.Inventories;
import com.onarandombox.multiverseinventories.api.profile.ContainerType;
+import com.onarandombox.multiverseinventories.api.profile.ProfileType;
import com.onarandombox.multiverseinventories.api.profile.WorldGroupProfile;
import com.onarandombox.multiverseinventories.api.share.Sharable;
import com.onarandombox.multiverseinventories.api.share.Sharables;
@@ -16,6 +17,8 @@
import java.util.HashSet;
import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -31,6 +34,7 @@
private HashSet<String> worlds = new HashSet<String>();
private Shares shares = Sharables.noneOf();
private Shares negativeShares = Sharables.noneOf();
+ private Set<ProfileType> profileTypes = new LinkedHashSet<ProfileType>();
public DefaultWorldGroupProfile(Inventories inventories, String name) {
super(inventories, ContainerType.GROUP);
@@ -93,6 +97,18 @@ public DefaultWorldGroupProfile(Inventories inventories, String name,
Logging.warning("Spawn settings for group formatted incorrectly");
}
}
+ if (dataMap.containsKey("profiles")) {
+ Object profilesObj = dataMap.get("profiles");
+ if (!(profilesObj instanceof List)) {
+ Logging.warning("Profiles formatted incorrectly for group: " + name);
+ } else {
+ for (Object obj : ((List) profilesObj)) {
+ profileTypes.add(ProfileTypes.lookupType(obj.toString(), true));
+ }
+ }
+ } else {
+ profileTypes.add(ProfileTypes.DEFAULT);
+ }
/*
if (data.contains("blacklist")) {
@@ -120,6 +136,11 @@ public DefaultWorldGroupProfile(Inventories inventories, String name,
spawnProps.put("priority", this.getSpawnPriority().toString());
results.put("spawn", spawnProps);
}
+ List<String> profileTypeList = new LinkedList<String>();
+ for (ProfileType type : this.profileTypes) {
+ profileTypeList.add(type.getName());
+ }
+ results.put("profiles", profileTypeList);
/*
if (!this.getItemBlacklist().isEmpty()) {
@@ -304,6 +325,11 @@ public void setSpawnPriority(EventPriority priority) {
this.spawnPriority = priority;
}
+ @Override
+ public Set<ProfileType> getProfileTypes() {
+ return this.profileTypes;
+ }
+
/*
protected HashMap<String, ItemBlacklist> getItemBlacklist() {
return this.itemBlacklist;
View
9 src/main/java/com/onarandombox/multiverseinventories/InventoriesListener.java
@@ -19,6 +19,7 @@
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
+import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
@@ -112,6 +113,14 @@ public void playerJoin(PlayerJoinEvent event) {
}
}
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void playerGameModeChange(PlayerGameModeChangeEvent event) {
+ if (event.isCancelled()) {
+ return;
+ }
+
+ }
+
/**
* Called when a player changes worlds.
*
View
2 src/main/java/com/onarandombox/multiverseinventories/api/profile/WorldGroupProfile.java
@@ -138,6 +138,8 @@
*/
void setSpawnPriority(EventPriority priority);
+ Set<ProfileType> getProfileTypes();
+
// ItemBlacklist getItemBlacklist(String worldName);
}

0 comments on commit 16fb0d9

Please sign in to comment.