mirror of
https://github.com/garbagemule/MobArena.git
synced 2025-01-30 04:01:38 +01:00
v0.94.4.69 - beginning of Class Limits feature [not working]
This commit is contained in:
parent
9f77f2f3de
commit
906fe93d6a
@ -1,7 +1,7 @@
|
|||||||
name: MobArena
|
name: MobArena
|
||||||
author: garbagemule
|
author: garbagemule
|
||||||
main: com.garbagemule.MobArena.MobArena
|
main: com.garbagemule.MobArena.MobArena
|
||||||
version: 0.94.4.68
|
version: 0.94.4.69
|
||||||
softdepend: [Spout,MultiVerse,XcraftGate,Towny,Heroes,MagicSpells,Vault]
|
softdepend: [Spout,MultiVerse,XcraftGate,Towny,Heroes,MagicSpells,Vault]
|
||||||
commands:
|
commands:
|
||||||
ma:
|
ma:
|
||||||
|
5
resources/res/class-limits.yml
Normal file
5
resources/res/class-limits.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Knight: -1
|
||||||
|
Tank: -1
|
||||||
|
Archer: -1
|
||||||
|
Chemist: -1
|
||||||
|
Oddjob: -1
|
@ -72,8 +72,9 @@ public class ArenaImpl implements Arena
|
|||||||
private Leaderboard leaderboard;
|
private Leaderboard leaderboard;
|
||||||
|
|
||||||
// Player stuff
|
// Player stuff
|
||||||
private InventoryManager inventoryManager;
|
private InventoryManager inventoryManager;
|
||||||
private RewardManager rewardManager;
|
private RewardManager rewardManager;
|
||||||
|
private ClassLimitManager limitManager;
|
||||||
private Map<Player,ArenaPlayer> arenaPlayerMap;
|
private Map<Player,ArenaPlayer> arenaPlayerMap;
|
||||||
private Map<Player,PlayerData> playerData = new HashMap<Player,PlayerData>();
|
private Map<Player,PlayerData> playerData = new HashMap<Player,PlayerData>();
|
||||||
|
|
||||||
@ -131,6 +132,7 @@ public class ArenaImpl implements Arena
|
|||||||
|
|
||||||
this.inventoryManager = new InventoryManager(this);
|
this.inventoryManager = new InventoryManager(this);
|
||||||
this.rewardManager = new RewardManager(this);
|
this.rewardManager = new RewardManager(this);
|
||||||
|
this.limitManager = new ClassLimitManager(this);
|
||||||
|
|
||||||
// Warps, points and locations
|
// Warps, points and locations
|
||||||
this.leaderboard = new Leaderboard(plugin, this, region.getLeaderboard());
|
this.leaderboard = new Leaderboard(plugin, this, region.getLeaderboard());
|
||||||
@ -383,6 +385,11 @@ public class ArenaImpl implements Arena
|
|||||||
return monsterManager;
|
return monsterManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClassLimitManager getClassLimitManager() {
|
||||||
|
return limitManager;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArenaLog getLog() {
|
public ArenaLog getLog() {
|
||||||
return log;
|
return log;
|
||||||
@ -432,6 +439,14 @@ public class ArenaImpl implements Arena
|
|||||||
|
|
||||||
// Teleport players, give full health, initialize map
|
// Teleport players, give full health, initialize map
|
||||||
for (Player p : arenaPlayers) {
|
for (Player p : arenaPlayers) {
|
||||||
|
// TODO figure out how people die in lobby and get sent to spectator area early
|
||||||
|
// Remove player from spec list to avoid invincibility issues
|
||||||
|
if (inSpec(p)) {
|
||||||
|
specPlayers.remove(p);
|
||||||
|
System.out.println("[MobArena] Player " + p.getName() + " joined the arena from the spec area!");
|
||||||
|
System.out.println("[MobArena] Invincibility glitch attempt stopped!");
|
||||||
|
}
|
||||||
|
|
||||||
p.teleport(region.getArenaWarp());
|
p.teleport(region.getArenaWarp());
|
||||||
//movePlayerToLocation(p, region.getArenaWarp());
|
//movePlayerToLocation(p, region.getArenaWarp());
|
||||||
setHealth(p, 20);
|
setHealth(p, 20);
|
||||||
|
@ -130,6 +130,17 @@ public class ArenaListener
|
|||||||
this.canShare = s.getBoolean("share-items-in-arena", true);
|
this.canShare = s.getBoolean("share-items-in-arena", true);
|
||||||
this.autoIgniteTNT = s.getBoolean("auto-ignite-tnt", false);
|
this.autoIgniteTNT = s.getBoolean("auto-ignite-tnt", false);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO: ClassLimitManager limits = arena.getClassLimitManager();
|
||||||
|
* For Each loop to go through each class
|
||||||
|
* Make sure each class is an actual class
|
||||||
|
*
|
||||||
|
* put this stuff in the limit manager
|
||||||
|
* Map<String, Integer> to house the class names and defined limit
|
||||||
|
* Map<String, Integer> to house the current amounts
|
||||||
|
* clearing methods for the current amounts when the arena starts
|
||||||
|
*/
|
||||||
|
|
||||||
this.allowMonsters = arena.getWorld().getAllowMonsters();
|
this.allowMonsters = arena.getWorld().getAllowMonsters();
|
||||||
|
|
||||||
this.banned = new HashSet<Player>();
|
this.banned = new HashSet<Player>();
|
||||||
@ -786,6 +797,17 @@ public class ArenaListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO put in class limit check (use ClassLimitManager)
|
||||||
|
* going to need to track how many pick what classes
|
||||||
|
* going to need to deny them if there is already too many of that class
|
||||||
|
* will need to display the new message for class limit exceeded - Msg.LOBBY_CLASS_FULL
|
||||||
|
*
|
||||||
|
* big todo: check if a player switches class. if the player already has a class, remove it, and add the new one
|
||||||
|
* will be "playerChangedClass(previous ArenaClass)" followed by "playerPickedClass(new ArenaClass)"
|
||||||
|
* however... if the previous and new classes are the same, ignore it completely, and let it move to delayAssignClass()
|
||||||
|
*/
|
||||||
|
|
||||||
// Delay the inventory stuff to ensure that right-clicking works.
|
// Delay the inventory stuff to ensure that right-clicking works.
|
||||||
delayAssignClass(p, className);
|
delayAssignClass(p, className);
|
||||||
}
|
}
|
||||||
|
81
src/com/garbagemule/MobArena/ClassLimitManager.java
Normal file
81
src/com/garbagemule/MobArena/ClassLimitManager.java
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
package com.garbagemule.MobArena;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import com.garbagemule.MobArena.framework.Arena;
|
||||||
|
import com.garbagemule.MobArena.util.config.ConfigSection;
|
||||||
|
|
||||||
|
public class ClassLimitManager
|
||||||
|
{
|
||||||
|
private HashMap<ArenaClass, Integer> classLimits, classesInUse;
|
||||||
|
private ConfigSection limits;
|
||||||
|
private MobArena plugin;
|
||||||
|
|
||||||
|
public ClassLimitManager(Arena arena) {
|
||||||
|
this.plugin = arena.getPlugin();
|
||||||
|
this.limits = new ConfigSection(plugin.getMAConfig(), "arenas." + arena.configName() + ".class-limits");
|
||||||
|
|
||||||
|
this.classLimits = new HashMap<ArenaClass, Integer>();
|
||||||
|
this.classesInUse = new HashMap<ArenaClass, Integer>();
|
||||||
|
|
||||||
|
loadLimitMap();
|
||||||
|
initInUseMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getClassLimit(ArenaClass ac) {
|
||||||
|
if (classLimits.get(ac) != null)
|
||||||
|
return classLimits.get(ac).intValue();
|
||||||
|
else
|
||||||
|
return addNewClass(ac);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getClassInUse(ArenaClass ac) {
|
||||||
|
if (classesInUse.get(ac) != null)
|
||||||
|
return classesInUse.get(ac).intValue();
|
||||||
|
else {
|
||||||
|
addNewClass(ac);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadLimitMap() {
|
||||||
|
for (ArenaClass ac : plugin.getArenaMaster().getClasses().values()) {
|
||||||
|
classLimits.put(ac, limits.getInt(ac.getName(), -1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initInUseMap() {
|
||||||
|
for (ArenaClass ac : plugin.getArenaMaster().getClasses().values()) {
|
||||||
|
classesInUse.put(ac, Integer.valueOf(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int addNewClass(ArenaClass ac) {
|
||||||
|
classLimits.put(ac, Integer.valueOf(-1));
|
||||||
|
classesInUse.put(ac, Integer.valueOf(0));
|
||||||
|
limits.set(ac.getName(), -1);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playerPickedClass(ArenaClass ac) {
|
||||||
|
classesInUse.put(ac, classesInUse.get(ac) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playerChangedClass(ArenaClass ac) {
|
||||||
|
classesInUse.put(ac, classesInUse.get(ac) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canPlayerJoinClass(ArenaClass ac) {
|
||||||
|
if (classLimits.get(ac).intValue() <= -1)
|
||||||
|
return true;
|
||||||
|
else if (classesInUse.get(ac).intValue() >= classLimits.get(ac).intValue())
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearClassesInUse() {
|
||||||
|
classesInUse.clear();
|
||||||
|
initInUseMap();
|
||||||
|
}
|
||||||
|
}
|
@ -247,6 +247,10 @@ public class MASpawnThread implements Runnable
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO remove debug message
|
||||||
|
Location l = p.getLocation();
|
||||||
|
System.out.println("Player: " + p.getName() + " found at location:" + l.getX() + ", " + l.getY() + ", " + l.getZ());
|
||||||
|
|
||||||
Messenger.tellPlayer(p, "Leaving so soon?");
|
Messenger.tellPlayer(p, "Leaving so soon?");
|
||||||
p.getInventory().clear();
|
p.getInventory().clear();
|
||||||
arena.playerLeave(p);
|
arena.playerLeave(p);
|
||||||
|
@ -46,6 +46,7 @@ public enum Msg
|
|||||||
LOBBY_DROP_ITEM("No sharing allowed at this time!", "Can't drop items here."),
|
LOBBY_DROP_ITEM("No sharing allowed at this time!", "Can't drop items here."),
|
||||||
LOBBY_PLAYER_READY("You have been flagged as ready!", "Flagged as ready!"),
|
LOBBY_PLAYER_READY("You have been flagged as ready!", "Flagged as ready!"),
|
||||||
LOBBY_PICK_CLASS("You must first pick a class!", "Pick a class first!"),
|
LOBBY_PICK_CLASS("You must first pick a class!", "Pick a class first!"),
|
||||||
|
LOBBY_CLASS_FULL("This class can no longer be selected, class limit reached!", "Class limit reached!"),
|
||||||
LOBBY_NOT_ENOUGH_PLAYERS("Not enough players to start. Need at least % players.", "Need more players."),
|
LOBBY_NOT_ENOUGH_PLAYERS("Not enough players to start. Need at least % players.", "Need more players."),
|
||||||
LOBBY_RIGHT_CLICK("Punch the sign. Don't right-click.", "Punch the sign."),
|
LOBBY_RIGHT_CLICK("Punch the sign. Don't right-click.", "Punch the sign."),
|
||||||
LOBBY_CLASS_PICKED("You have chosen % as your class!", "%"),
|
LOBBY_CLASS_PICKED("You have chosen % as your class!", "%"),
|
||||||
|
@ -13,6 +13,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import com.garbagemule.MobArena.ArenaClass;
|
import com.garbagemule.MobArena.ArenaClass;
|
||||||
import com.garbagemule.MobArena.ArenaListener;
|
import com.garbagemule.MobArena.ArenaListener;
|
||||||
import com.garbagemule.MobArena.ArenaPlayer;
|
import com.garbagemule.MobArena.ArenaPlayer;
|
||||||
|
import com.garbagemule.MobArena.ClassLimitManager;
|
||||||
import com.garbagemule.MobArena.MASpawnThread;
|
import com.garbagemule.MobArena.MASpawnThread;
|
||||||
import com.garbagemule.MobArena.MobArena;
|
import com.garbagemule.MobArena.MobArena;
|
||||||
import com.garbagemule.MobArena.MonsterManager;
|
import com.garbagemule.MobArena.MonsterManager;
|
||||||
@ -104,6 +105,8 @@ public interface Arena
|
|||||||
|
|
||||||
public MonsterManager getMonsterManager();
|
public MonsterManager getMonsterManager();
|
||||||
|
|
||||||
|
public ClassLimitManager getClassLimitManager();
|
||||||
|
|
||||||
public void revivePlayer(Player p);
|
public void revivePlayer(Player p);
|
||||||
|
|
||||||
public ArenaLog getLog();
|
public ArenaLog getLog();
|
||||||
|
Loading…
Reference in New Issue
Block a user