Really Quick Factions Help

Discussion in 'Plugin Development' started by ZomBlade_Shadow, Feb 19, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    ZomBlade_Shadow

    Hey!
    FIRST OF ALL,don't mock me,i'm fairly new to coding,importing and all those things...

    I just need help,to actually START my huge project (huge for me)

    HOW can I get the current Factions Plugin, and modify it (like when you do /f show, change some stuff) and stuff like that.

    I've been looking everywhere but I'm so confused with the mcore importing,faction git and stuff..
    Github confuses me,can somebody PLEASE explain me how I could get the full project and modify it to my needs?
    Like how to import it exactly,what Library stuff I need to import, mcore,ect..

    THANK YOU SO MUCH if you help <3
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    Avygeil

    @ZomBlade_Shadow There is a "Download ZIP" button on Github. Since you didn't provide links, I don't really know what more to say. Import the project source in your IDE and modify that. But keep in mind that you'll have to update it yourself afterwards.

    Depending on what you want to do, many things can be done by just making a separate plugin and do your changes there. Again for more help you need to be more specific.
     
  4. Offline

    ZomBlade_Shadow

  5. Offline

    Ruptur

    @ZomBlade_Shadow
    On the Github page => Download zip [​IMG]

    In Eclispe => Once downloaded drag the files into eclispe

    Then ? => Modify and you are good to go
     
  6. Offline

    ZomBlade_Shadow

    THANK YOU ALL <33
    But don't I need mcore or anything?
    I'll import it too, just thanks <3

    Just one final question.
    If I ever want to modify a part of the Factions plugin,like if I want to modify the display of the /f show command,
    Do I edit the huge Factions source code,or do I make another plugin,that overrides the default factions plugin functionnalities?
    Thanks :)

    EDIT by Timtower: merged posts
     
    Last edited by a moderator: Feb 20, 2015
  7. Offline

    timtower Administrator Administrator Moderator

    @ZomBlade_Shadow It was the entire point of this thread to modify the source right?
     
  8. Offline

    ZomBlade_Shadow

    Yes,but i'm just asking,what if I just do a seperate plugin that overrides the default ones functions?
    I mean it's way less work + it's super hard to modify the source x)
    any ways around?
     
  9. Offline

    timtower Administrator Administrator Moderator

    @ZomBlade_Shadow Then you would need to override the entire /factions command stuff, and all of its aliases.
     
  10. Offline

    ZomBlade_Shadow

    ;o

    Ok,but I can't manage to find the 1.7 source code for factions
    there's only 1.6.x and 1.8.x
    Anywhere I can get it from?

    EDIT by Timtower: merged posts
     
    Last edited by a moderator: Feb 20, 2015
  11. Offline

    timtower Administrator Administrator Moderator

  12. Offline

    ZomBlade_Shadow

    Yes there is a 1.7 version of factions,but there is no Source Code,well,I can't find it..

    https://github.com/MassiveCraft/Factions

    EDIT by Timtower: merged posts
     
  13. It's really easy modify faction, to edit the /f show you have to edit the Engine .
     
  14. Offline

    ZomBlade_Shadow

    Can you please explain a bit,I know there's the Engine folder in Factions,I don't know what to modify and also I need it for my 1.7 server, and there are only Factions_master (1.8 i believe), Factions 1.8 and factions 1.6 source codes on github
    https://github.com/MassiveCraft/Factions
    Thanks :)
     
  15. Offline

    ZomBlade_Shadow

    Nvm,I decompiled the 1.7 version.
    Now I need some help :)
     
    Last edited: Feb 22, 2015
  16. You have to modify this on Faction/EngineMain.java
    Show Spoiler

    Code:java
    1.  
    2. @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
    3. public void onFactionShow(EventFactionsFactionShowAsync event)
    4. {
    5. final int tableCols = 4;
    6. final CommandSender sender = event.getSender();
    7. final MPlayer msender = event.getMSender();
    8. final Faction faction = event.getFaction();
    9. final boolean normal = faction.isNormal();
    10. final Map<String, PriorityLines> idPriorityLiness = event.getIdPriorityLiness();
    11. final boolean peaceful = faction.getFlag(MFlag.getFlagPeaceful());
    12. // ID
    13. //If the player is with the bypass on this will show faction id
    14. if (msender.isUsingAdminMode())
    15. {
    16. show(idPriorityLiness, Const.SHOW_ID_FACTION_ID, Const.SHOW_PRIORITY_FACTION_ID, "ID", faction.getId());
    17. }
    18. // DESCRIPTION
    19. //Show the description
    20. show(idPriorityLiness, Const.SHOW_ID_FACTION_DESCRIPTION, Const.SHOW_PRIORITY_FACTION_DESCRIPTION, "Description", faction.getDescription());
    21. // SECTION: NORMAL
    22. if (normal)
    23. {
    24. // AGE
    25. long ageMillis = faction.getCreatedAtMillis() - System.currentTimeMillis();
    26. LinkedHashMap<TimeUnit, Long> ageUnitcounts = TimeDiffUtil.limit(TimeDiffUtil.unitcounts(ageMillis, TimeUnit.getAllButMillis()), 3);
    27. String ageDesc = TimeDiffUtil.formatedVerboose(ageUnitcounts, "<i>");
    28. show(idPriorityLiness, Const.SHOW_ID_FACTION_AGE, Const.SHOW_PRIORITY_FACTION_AGE, "Age", ageDesc);
    29. // FLAGS
    30. // We display all editable and non default ones. The rest we skip.
    31. List<String> flagDescs = new LinkedList<String>();
    32. for (Entry<MFlag, Boolean> entry : faction.getFlags().entrySet())
    33. {
    34. final MFlag mflag = entry.getKey();
    35. if (mflag == null) continue;
    36. final Boolean value = entry.getValue();
    37. if (value == null) continue;
    38. if ( ! mflag.isInteresting(value)) continue;
    39. String flagDesc = Txt.parse(value ? "<g>" : "<b>") + mflag.getName();
    40. flagDescs.add(flagDesc);
    41. }
    42. String flagsDesc = Txt.parse("<silver><italic>default");
    43. if ( ! flagDescs.isEmpty())
    44. {
    45. flagsDesc = Txt.implode(flagDescs, Txt.parse(" <i>| "));
    46. }
    47. show(idPriorityLiness, Const.SHOW_ID_FACTION_FLAGS, Const.SHOW_PRIORITY_FACTION_FLAGS, "Flags", flagsDesc);
    48. // POWER
    49. //This show the power and if the faction hace power boost it show it
    50. double powerBoost = faction.getPowerBoost();
    51. String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? " (bonus: " : " (penalty: ") + powerBoost + ")";
    52. String powerDesc = Txt.parse("%d/%d/%d%s", faction.getLandCount(), faction.getPowerRounded(), faction.getPowerMaxRounded(), boost);
    53. show(idPriorityLiness, Const.SHOW_ID_FACTION_POWER, Const.SHOW_PRIORITY_FACTION_POWER, "Land / Power / Maxpower", powerDesc);
    54. // SECTION: ECON
    55. if (Econ.isEnabled())
    56. {
    57. // LANDVALUES
    58. List<String> landvalueLines = new LinkedList<String>();
    59. long landCount = faction.getLandCount();
    60. for (EventFactionsChunkChangeType type : EventFactionsChunkChangeType.values())
    61. {
    62. Double money = MConf.get().econChunkCost.get(type);
    63. if (money == null) continue;
    64. if (money == 0) continue;
    65. money *= landCount;
    66. String word = "Cost";
    67. if (money <= 0)
    68. {
    69. word = "Reward";
    70. money *= -1;
    71. }
    72. String key = Txt.parse("Total Land %s %s", type.toString().toLowerCase(), word);
    73. String value = Txt.parse("<h>%s", Money.format(money));
    74. String line = show(key, value);
    75. landvalueLines.add(line);
    76. }
    77. idPriorityLiness.put(Const.SHOW_ID_FACTION_LANDVALUES, new PriorityLines(Const.SHOW_PRIORITY_FACTION_LANDVALUES, landvalueLines));
    78. // BANK
    79. if (MConf.get().bankEnabled)
    80. {
    81. double bank = Money.get(faction);
    82. String bankDesc = Txt.parse("<h>%s", Money.format(bank, true));
    83. show(idPriorityLiness, Const.SHOW_ID_FACTION_BANK, Const.SHOW_PRIORITY_FACTION_BANK, "Bank", bankDesc);
    84. }
    85. }
    86. }
    87. // RELATIONS
    88. List<String> relationLines = new ArrayList<String>();
    89. String none = Txt.parse("<silver><italic>none");
    90. String everyone = MConf.get().colorTruce.toString() + Txt.parse("<italic>*EVERYONE*");
    91. Set<Rel> rels = EnumSet.of(Rel.TRUCE, Rel.ALLY, Rel.ENEMY);
    92. Map<Rel, List<String>> relNames = faction.getRelationNames(msender, rels, true);
    93. for (Entry<Rel, List<String>> entry : relNames.entrySet())
    94. {
    95. Rel rel = entry.getKey();
    96. List<String> names = entry.getValue();
    97. String header = Txt.parse("<a>Relation %s%s<a> (%d):", rel.getColor().toString(), Txt.getNicedEnum(rel), names.size());
    98. relationLines.add(header);
    99. if (rel == Rel.TRUCE && peaceful)
    100. {
    101. relationLines.add(everyone);
    102. }
    103. else
    104. {
    105. if (names.isEmpty())
    106. {
    107. relationLines.add(none);
    108. }
    109. else
    110. {
    111. relationLines.addAll(table(names, tableCols));
    112. }
    113. }
    114. }
    115. idPriorityLiness.put(Const.SHOW_ID_FACTION_RELATIONS, new PriorityLines(Const.SHOW_PRIORITY_FACTION_RELATIONS, relationLines));
    116. // FOLLOWERS
    117. List<String> followerLines = new ArrayList<String>();
    118. List<String> followerNamesOnline = new ArrayList<String>();
    119. List<String> followerNamesOffline = new ArrayList<String>();
    120. List<MPlayer> followers = faction.getMPlayers();
    121. Collections.sort(followers, PlayerRoleComparator.get());
    122. for (MPlayer follower : followers)
    123. {
    124. if (follower.isOnline() && Mixin.canSee(sender, follower.getId()))
    125. {
    126. followerNamesOnline.add(follower.getNameAndTitle(msender));
    127. }
    128. else if (normal)
    129. {
    130. // For the non-faction we skip the offline members since they are far to many (infinite almost)
    131. followerNamesOffline.add(follower.getNameAndTitle(msender));
    132. }
    133. }
    134. String headerOnline = Txt.parse("<a>Followers Online (%s):", followerNamesOnline.size());
    135. followerLines.add(headerOnline);
    136. if (followerNamesOnline.isEmpty())
    137. {
    138. followerLines.add(none);
    139. }
    140. else
    141. {
    142. followerLines.addAll(table(followerNamesOnline, tableCols));
    143. }
    144. if (normal)
    145. {
    146. String headerOffline = Txt.parse("<a>Followers Offline (%s):", followerNamesOffline.size());
    147. followerLines.add(headerOffline);
    148. if (followerNamesOffline.isEmpty())
    149. {
    150. followerLines.add(none);
    151. }
    152. else
    153. {
    154. followerLines.addAll(table(followerNamesOffline, tableCols));
    155. }
    156. }
    157. idPriorityLiness.put(Const.SHOW_ID_FACTION_FOLLOWERS, new PriorityLines(Const.SHOW_PRIORITY_FACTION_FOLLOWERS, followerLines));
    158. }
    159.  

     
Thread Status:
Not open for further replies.

Share This Page