Skip to content

Commit

Permalink
Land manage pagination and 1.0.0 release!!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
jcdesimp committed Apr 20, 2014
1 parent 7564798 commit 1936f94
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 13 deletions.
3 changes: 3 additions & 0 deletions src/com/jcdesimp/landlord/Landlord.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ public void onEnable() {
if(getConfig().getBoolean("enabled-flags.openDoor")) {
flagManager.registerFlag(new OpenDoor());
}
//flagManager.registerFlag(new OpenDoorDUPE1());
//flagManager.registerFlag(new OpenDoorDUPE2());
//flagManager.registerFlag(new OpenDoorDUPE3());


}
Expand Down
47 changes: 37 additions & 10 deletions src/com/jcdesimp/landlord/landManagement/LandManagerView.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public class LandManagerView implements Listener {
private ArrayList<ItemStack[]> permCols = new ArrayList<ItemStack[]>();
private ArrayList<Integer> permSlots = new ArrayList<Integer>();
private int pageNum = 0;
private boolean isOpen = false;
private boolean isOpen = true;
private int numPages;

public LandManagerView(Player player, OwnedLand mLand) {
Landlord.getInstance().getServer().getPluginManager().registerEvents(this, Landlord.getInstance());
Expand All @@ -43,13 +44,14 @@ public LandManagerView(Player player, OwnedLand mLand) {
this.mLand = mLand;
this.perms = mLand.getLandPerms();
this.ui = Bukkit.createInventory(null, 36, "Land Manager");
int numPages = (int)ceil(permCols.size()/8);
if(numPages==0){
this.updateUIData();
this.numPages = (int)ceil(((double)permCols.size())/8.0);
if(numPages==1){
this.ui = Bukkit.createInventory(null, 27, "Land Manager");
}
this.updateUIData();
this.buildUI();

this.setToggles();
this.buildUI();



Expand Down Expand Up @@ -89,7 +91,7 @@ private void updateUIData(){
for(Map.Entry<String, Landflag> entry : Landlord.getInstance().getFlagManager().getRegisteredFlags().entrySet()){
Landflag l = entry.getValue();
permSlots.add(new Integer(l.getPermSlot()));
String[] loreData = l.getDescrition().split("\\|");
String[] loreData = l.getDescription().split("\\|");
String[] desc = colorLore(loreData);
ItemStack header = makeButton(ChatColor.YELLOW+l.getDisplayName(),desc,l.getHeaderItem());
ItemStack allState;
Expand Down Expand Up @@ -148,6 +150,16 @@ private void buildUI(){
new ItemStack(Material.SKULL_ITEM, 1, (short)2)));
ui.setItem(18,makeButton(ChatColor.YELLOW+"Friends", new String[]{ChatColor.RESET+"Permissions in this row apply to", ChatColor.RESET+"friends of this land."},
new ItemStack(Material.SKULL_ITEM, 1, (short)3)));
if(pageNum < numPages-1){
//35
ui.setItem(35,makeButton(ChatColor.YELLOW+"Next Page", new String[]{ChatColor.RESET+"View next page of options."},
new ItemStack(Material.PAPER)));
}
if(pageNum > 0){
//27
ui.setItem(27,makeButton(ChatColor.YELLOW+"Previous Page", new String[]{ChatColor.RESET+"View previous page of options."},
new ItemStack(Material.PAPER)));
}



Expand All @@ -157,10 +169,10 @@ private void buildUI(){

private void setToggles(){

int numPages = (int)ceil(permCols.size()/8);
int startIndex = pageNum*8;
int endIndex;
if(pageNum==numPages){
ui.clear();
if(pageNum==numPages-1){
endIndex = permCols.size();
} else {
endIndex = startIndex+8;
Expand All @@ -185,7 +197,7 @@ public void onInventoryClose(InventoryCloseEvent event){
//player.sendMessage(ChatColor.GREEN + "Closing: " + event.getInventory().getTitle() + " of type "+ event.getInventory().getType());
//player.sendMessage(ChatColor.GREEN + "Viewer:" +
//" " + event.getViewers().toString());
if(event.getInventory().getTitle().contains("Land Manager") && p.getName().equalsIgnoreCase(player.getName()) /*&& isOpen*/ ){
if(event.getInventory().getTitle().contains("Land Manager") && p.getName().equalsIgnoreCase(player.getName()) && isOpen ){


mLand.setPermissions(mLand.permsToString(perms));
Expand Down Expand Up @@ -222,7 +234,6 @@ public void clickButton(InventoryClickEvent event){
int col = slot%9;
//System.out.println("COL: "+col);

int numPages = (int)ceil(((double)permCols.size())/8.0);
//System.out.println("PAGES: "+pageNum);
int startIndex = pageNum*8;
int endIndex;
Expand All @@ -243,6 +254,22 @@ public void clickButton(InventoryClickEvent event){
}
updateUIData();
setToggles();
buildUI();
}

if(pageNum < numPages-1 && event.getRawSlot()==35){
//35
pageNum++;
updateUIData();
setToggles();
buildUI();
}
if(pageNum > 0 && event.getRawSlot()==27){
//27
pageNum--;
updateUIData();
setToggles();
buildUI();
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/com/jcdesimp/landlord/landManagement/Landflag.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public String getDisplayName() {
return displayName;
}

public String getDescrition() {
public String getDescription() {
return descrition;
}

Expand Down
2 changes: 1 addition & 1 deletion src/com/jcdesimp/landlord/persistantData/OwnedLand.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ private String[][] getDefaultPerms() {
ArrayList<String> friendsPerms = new ArrayList<String>();
guestPerms.add("1");
friendsPerms.add("1");
for(int i = 0; i<((Landlord)Landlord.getInstance()).getFlagManager().numStoredPerms(); i++){
for(int i = 0; i<(Landlord.getInstance()).getFlagManager().numStoredPerms(); i++){
guestPerms.add("0");
friendsPerms.add("1");
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Landlord
main: com.jcdesimp.landlord.Landlord
version: 0.6
version: 1.0.0
author: Jcdesimp
authors: []
website: http://dev.bukkit.org/bukkit-plugins/landlord/
Expand Down

0 comments on commit 1936f94

Please sign in to comment.