Sync with L2jServer HighFive Mar 25th 2015.
This commit is contained in:
@@ -22,9 +22,9 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -48,8 +48,8 @@ public class Forum
|
||||
public static final int CLANMEMBERONLY = 2;
|
||||
public static final int OWNERONLY = 3;
|
||||
|
||||
private final List<Forum> _children;
|
||||
private final Map<Integer, Topic> _topic;
|
||||
private final List<Forum> _children = new ArrayList<>();
|
||||
private final Map<Integer, Topic> _topic = new ConcurrentHashMap<>();
|
||||
private final int _forumId;
|
||||
private String _forumName;
|
||||
private int _forumType;
|
||||
@@ -68,8 +68,6 @@ public class Forum
|
||||
{
|
||||
_forumId = Forumid;
|
||||
_fParent = FParent;
|
||||
_children = new ArrayList<>();
|
||||
_topic = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,8 +86,6 @@ public class Forum
|
||||
_forumPerm = perm;
|
||||
_fParent = parent;
|
||||
_ownerID = OwnerID;
|
||||
_children = new ArrayList<>();
|
||||
_topic = new HashMap<>();
|
||||
parent._children.add(this);
|
||||
ForumsBBSManager.getInstance().addForum(this);
|
||||
_loaded = true;
|
||||
@@ -151,7 +147,7 @@ public class Forum
|
||||
{
|
||||
while (rs.next())
|
||||
{
|
||||
Forum f = new Forum(rs.getInt("forum_id"), this);
|
||||
final Forum f = new Forum(rs.getInt("forum_id"), this);
|
||||
_children.add(f);
|
||||
ForumsBBSManager.getInstance().addForum(f);
|
||||
}
|
||||
@@ -208,14 +204,7 @@ public class Forum
|
||||
public Forum getChildByName(String name)
|
||||
{
|
||||
vload();
|
||||
for (Forum f : _children)
|
||||
{
|
||||
if (f.getName().equals(name))
|
||||
{
|
||||
return f;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return _children.stream().filter(f -> f.getName().equals(name)).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -47,7 +47,7 @@ public class Post
|
||||
public String postTxt;
|
||||
}
|
||||
|
||||
private final List<CPost> _post;
|
||||
private final List<CPost> _post = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* @param _PostOwner
|
||||
@@ -59,8 +59,7 @@ public class Post
|
||||
*/
|
||||
public Post(String _PostOwner, int _PostOwnerID, long date, int tid, int _PostForumID, String txt)
|
||||
{
|
||||
_post = new ArrayList<>();
|
||||
CPost cp = new CPost();
|
||||
final CPost cp = new CPost();
|
||||
cp.postId = 0;
|
||||
cp.postOwner = _PostOwner;
|
||||
cp.postOwnerId = _PostOwnerID;
|
||||
@@ -73,6 +72,11 @@ public class Post
|
||||
|
||||
}
|
||||
|
||||
public Post(Topic t)
|
||||
{
|
||||
load(t);
|
||||
}
|
||||
|
||||
public void insertindb(CPost cp)
|
||||
{
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
|
||||
@@ -93,23 +97,9 @@ public class Post
|
||||
}
|
||||
}
|
||||
|
||||
public Post(Topic t)
|
||||
{
|
||||
_post = new ArrayList<>();
|
||||
load(t);
|
||||
}
|
||||
|
||||
public CPost getCPost(int id)
|
||||
{
|
||||
int i = 0;
|
||||
for (CPost cp : _post)
|
||||
{
|
||||
if (i++ == id)
|
||||
{
|
||||
return cp;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return _post.get(id);
|
||||
}
|
||||
|
||||
public void deleteme(Topic t)
|
||||
@@ -142,7 +132,7 @@ public class Post
|
||||
{
|
||||
while (rs.next())
|
||||
{
|
||||
CPost cp = new CPost();
|
||||
final CPost cp = new CPost();
|
||||
cp.postId = rs.getInt("post_id");
|
||||
cp.postOwner = rs.getString("post_owner_name");
|
||||
cp.postOwnerId = rs.getInt("post_ownerid");
|
||||
|
@@ -63,10 +63,7 @@ public class ForumsBBSManager extends BaseBBSManager
|
||||
*/
|
||||
public void initRoot()
|
||||
{
|
||||
for (Forum f : _table)
|
||||
{
|
||||
f.vload();
|
||||
}
|
||||
_table.forEach(f -> f.vload());
|
||||
_log.info("Loaded " + _table.size() + " forums. Last forum id used: " + _lastid);
|
||||
}
|
||||
|
||||
@@ -101,14 +98,7 @@ public class ForumsBBSManager extends BaseBBSManager
|
||||
*/
|
||||
public Forum getForumByName(String name)
|
||||
{
|
||||
for (Forum f : _table)
|
||||
{
|
||||
if (f.getName().equals(name))
|
||||
{
|
||||
return f;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return _table.stream().filter(f -> f.getName().equals(name)).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,14 +133,7 @@ public class ForumsBBSManager extends BaseBBSManager
|
||||
*/
|
||||
public Forum getForumByID(int idf)
|
||||
{
|
||||
for (Forum f : _table)
|
||||
{
|
||||
if (f.getID() == idf)
|
||||
{
|
||||
return f;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return _table.stream().filter(f -> f.getID() == idf).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -20,10 +20,10 @@ package com.l2jserver.gameserver.communitybbs.Manager;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.l2jserver.gameserver.communitybbs.BB.Forum;
|
||||
import com.l2jserver.gameserver.communitybbs.BB.Post;
|
||||
@@ -35,7 +35,7 @@ import com.l2jserver.util.StringUtil;
|
||||
|
||||
public class PostBBSManager extends BaseBBSManager
|
||||
{
|
||||
private final Map<Topic, Post> _postByTopic = new HashMap<>();
|
||||
private final Map<Topic, Post> _postByTopic = new ConcurrentHashMap<>();
|
||||
|
||||
public Post getGPosttByTopic(Topic t)
|
||||
{
|
||||
|
@@ -19,13 +19,13 @@
|
||||
package com.l2jserver.gameserver.communitybbs.Manager;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import com.l2jserver.gameserver.communitybbs.BB.Forum;
|
||||
import com.l2jserver.gameserver.communitybbs.BB.Post;
|
||||
@@ -37,13 +37,12 @@ import com.l2jserver.util.StringUtil;
|
||||
|
||||
public class TopicBBSManager extends BaseBBSManager
|
||||
{
|
||||
private final List<Topic> _table;
|
||||
private final Map<Forum, Integer> _maxId;
|
||||
private final List<Topic> _table = new CopyOnWriteArrayList<>();
|
||||
private final Map<Forum, Integer> _maxId = new HashMap<>();
|
||||
|
||||
protected TopicBBSManager()
|
||||
{
|
||||
_table = new ArrayList<>();
|
||||
_maxId = new ConcurrentHashMap<>();
|
||||
// Prevent external initialization.
|
||||
}
|
||||
|
||||
public void addTopic(Topic tt)
|
||||
|
Reference in New Issue
Block a user