refactor
This commit is contained in:
@@ -1,16 +1,33 @@
|
||||
package org.kareha.hareka.client.control;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.kareha.hareka.client.WorldSession;
|
||||
import org.kareha.hareka.client.chat.ChatEntity;
|
||||
import org.kareha.hareka.client.field.FieldEntity;
|
||||
import org.kareha.hareka.client.packet.CancelTokenPacket;
|
||||
import org.kareha.hareka.client.packet.ConsumeRoleTokenPacket;
|
||||
import org.kareha.hareka.client.packet.DefineRolePacket;
|
||||
import org.kareha.hareka.client.packet.DeleteRoleTokenPacket;
|
||||
import org.kareha.hareka.client.packet.InspectChatEntityPacket;
|
||||
import org.kareha.hareka.client.packet.InspectFieldEntityPacket;
|
||||
import org.kareha.hareka.client.packet.IssueInvitationTokenPacket;
|
||||
import org.kareha.hareka.client.packet.IssueRoleTokenPacket;
|
||||
import org.kareha.hareka.client.packet.RebootPacket;
|
||||
import org.kareha.hareka.client.packet.RequestMyRolesPacket;
|
||||
import org.kareha.hareka.client.packet.RequestRoleListPacket;
|
||||
import org.kareha.hareka.client.packet.RequestRoleTokenListPacket;
|
||||
import org.kareha.hareka.client.packet.RequestSettingsPacket;
|
||||
import org.kareha.hareka.client.packet.SavePacket;
|
||||
import org.kareha.hareka.client.packet.SetRescueMethodsEnabledPacket;
|
||||
import org.kareha.hareka.client.packet.SetUserRegistrationModePacket;
|
||||
import org.kareha.hareka.client.packet.ShutdownPacket;
|
||||
import org.kareha.hareka.client.packet.TokenPacket;
|
||||
import org.kareha.hareka.client.packet.UndefineRolePacket;
|
||||
import org.kareha.hareka.client.user.RoleToken;
|
||||
import org.kareha.hareka.user.Permission;
|
||||
import org.kareha.hareka.user.Role;
|
||||
import org.kareha.hareka.user.UserRegistrationMode;
|
||||
|
||||
public class AdminControl {
|
||||
|
||||
@@ -24,6 +41,22 @@ public class AdminControl {
|
||||
session.write(new InspectFieldEntityPacket(fieldEntity));
|
||||
}
|
||||
|
||||
public void consumeRoleToken(final byte[] token) {
|
||||
session.write(new ConsumeRoleTokenPacket(token));
|
||||
}
|
||||
|
||||
public void issueInvitationToken() {
|
||||
session.write(new IssueInvitationTokenPacket());
|
||||
}
|
||||
|
||||
public void requestRoleTokenList() {
|
||||
session.write(new RequestRoleTokenListPacket());
|
||||
}
|
||||
|
||||
public void requestSettings() {
|
||||
session.write(new RequestSettingsPacket());
|
||||
}
|
||||
|
||||
public void requestRoles() {
|
||||
session.write(new RequestRoleListPacket());
|
||||
session.write(new RequestMyRolesPacket());
|
||||
@@ -33,24 +66,60 @@ public class AdminControl {
|
||||
session.write(new ShutdownPacket());
|
||||
}
|
||||
|
||||
public void consumeRoleToken(final byte[] token) {
|
||||
session.write(new ConsumeRoleTokenPacket(token));
|
||||
public void reboot() {
|
||||
session.write(new RebootPacket());
|
||||
}
|
||||
|
||||
public void save() {
|
||||
session.write(new SavePacket());
|
||||
}
|
||||
|
||||
public void requestSettings() {
|
||||
session.write(new RequestSettingsPacket());
|
||||
public void inspect(final ChatEntity chatEntity) {
|
||||
session.write(new InspectChatEntityPacket(chatEntity));
|
||||
}
|
||||
|
||||
public void reboot() {
|
||||
session.write(new RebootPacket());
|
||||
public void cancelToken(final int handlerId) {
|
||||
session.write(new CancelTokenPacket(handlerId));
|
||||
}
|
||||
|
||||
public void requestRoleTokenList() {
|
||||
session.write(new RequestRoleTokenListPacket());
|
||||
public void token(final int handlerId, final byte[] token) {
|
||||
session.write(new TokenPacket(handlerId, token));
|
||||
}
|
||||
|
||||
public void undefineRole(final String roleId) {
|
||||
session.write(new UndefineRolePacket(roleId));
|
||||
}
|
||||
|
||||
public void defineRole(final Role role) {
|
||||
session.write(new DefineRolePacket(role));
|
||||
}
|
||||
|
||||
public Collection<Role> getRoles() {
|
||||
return session.getMirrors().getAdminMirror().getRoles();
|
||||
}
|
||||
|
||||
public void issueRoleToken(final String roleId) {
|
||||
session.write(new IssueRoleTokenPacket(roleId));
|
||||
}
|
||||
|
||||
public Role getHighestRole(final Permission permission) {
|
||||
return session.getMirrors().getAdminMirror().getRoleSet().getHighestRole(permission);
|
||||
}
|
||||
|
||||
public void deleteRoleToken(final long roleTokenId) {
|
||||
session.write(new DeleteRoleTokenPacket(roleTokenId));
|
||||
}
|
||||
|
||||
public Collection<RoleToken> getRoleTokens() {
|
||||
return session.getMirrors().getAdminMirror().getRoleTokens();
|
||||
}
|
||||
|
||||
public void setUserRegistrationMode(final UserRegistrationMode mode) {
|
||||
session.write(new SetUserRegistrationModePacket(mode));
|
||||
}
|
||||
|
||||
public void setRescueModeEnabled(final boolean enabled) {
|
||||
session.write(new SetRescueMethodsEnabledPacket(enabled));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
package org.kareha.hareka.client.control;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.kareha.hareka.LocalEntityId;
|
||||
import org.kareha.hareka.client.ResponseHandler;
|
||||
import org.kareha.hareka.client.WorldSession;
|
||||
import org.kareha.hareka.client.chat.ChatEntity;
|
||||
import org.kareha.hareka.client.field.FieldEntity;
|
||||
import org.kareha.hareka.client.field.PositionMemory;
|
||||
import org.kareha.hareka.client.mirror.ActiveSkillMirror;
|
||||
import org.kareha.hareka.client.packet.AutopilotPacket;
|
||||
import org.kareha.hareka.client.packet.CancelPowPacket;
|
||||
import org.kareha.hareka.client.packet.ChangeNamePacket;
|
||||
import org.kareha.hareka.client.packet.IssueInvitationTokenPacket;
|
||||
import org.kareha.hareka.client.packet.CommandPacket;
|
||||
import org.kareha.hareka.client.packet.DeleteItemPacket;
|
||||
import org.kareha.hareka.client.packet.DropItemPacket;
|
||||
import org.kareha.hareka.client.packet.GetPositionMemoryPacket;
|
||||
import org.kareha.hareka.client.packet.PowPacket;
|
||||
import org.kareha.hareka.client.packet.TeleportToCenterPacket;
|
||||
import org.kareha.hareka.client.packet.TeleportToPositionMemoryPacket;
|
||||
import org.kareha.hareka.field.Placement;
|
||||
import org.kareha.hareka.field.Vector;
|
||||
import org.kareha.hareka.game.Name;
|
||||
@@ -56,10 +68,6 @@ public class Control {
|
||||
session.writeLogoutCharacter(handler);
|
||||
}
|
||||
|
||||
public void issueInvitationToken() {
|
||||
session.write(new IssueInvitationTokenPacket());
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return session.getLocale().getLanguage();
|
||||
}
|
||||
@@ -72,4 +80,64 @@ public class Control {
|
||||
session.write(new ChangeNamePacket(language, name));
|
||||
}
|
||||
|
||||
public List<ActiveSkillMirror.Entry> getActiveSkillEntries() {
|
||||
return new ArrayList<>(session.getMirrors().getSkillMirror().getEntries());
|
||||
}
|
||||
|
||||
public void activateLocalChat() {
|
||||
session.getMirrors().getChatMirror().getLocalChatSession();
|
||||
}
|
||||
|
||||
public void removePrivateChatSession(final ChatEntity chatEntity) {
|
||||
session.getMirrors().getChatMirror().removePrivateChatSession(chatEntity);
|
||||
}
|
||||
|
||||
public ChatEntity getChatEntity() {
|
||||
return session.getMirrors().getSelfMirror().getChatEntity();
|
||||
}
|
||||
|
||||
public FieldEntity getFieldEntity(final ChatEntity chatEntity) {
|
||||
return session.getServer().getFieldEntity(chatEntity);
|
||||
}
|
||||
|
||||
public void command(final String[] args) {
|
||||
session.write(new CommandPacket(args));
|
||||
}
|
||||
|
||||
public void deleteItem(final LocalEntityId itemId, final long count) {
|
||||
session.write(new DeleteItemPacket(itemId, count));
|
||||
}
|
||||
|
||||
public void dropItem(final LocalEntityId itemId, final long count) {
|
||||
session.write(new DropItemPacket(itemId, count));
|
||||
}
|
||||
|
||||
public void getPositionMemory() {
|
||||
session.write(new GetPositionMemoryPacket());
|
||||
}
|
||||
|
||||
public void teleportToPositionMemory(final byte[] data) {
|
||||
session.write(new TeleportToPositionMemoryPacket(data));
|
||||
}
|
||||
|
||||
public PositionMemory removePositionMemory(final int index) {
|
||||
return session.getServer().removePositionMemory(index);
|
||||
}
|
||||
|
||||
public void addPositionMemory(final int index, final PositionMemory memory) {
|
||||
session.getServer().addPositionMemory(index, memory);
|
||||
}
|
||||
|
||||
public void pow(final int handlerId, final byte[] nonce) {
|
||||
session.write(new PowPacket(handlerId, nonce));
|
||||
}
|
||||
|
||||
public void cancelPow(final int handlerId) {
|
||||
session.write(new CancelPowPacket(handlerId));
|
||||
}
|
||||
|
||||
public ChatEntity getChatEntity(final FieldEntity fieldEntity) {
|
||||
return session.getServer().getChatEntity(fieldEntity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,27 @@
|
||||
package org.kareha.hareka.client.control;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.kareha.hareka.client.WorldSession;
|
||||
import org.kareha.hareka.client.packet.AddDownstairsPacket;
|
||||
import org.kareha.hareka.client.packet.AddGatePairPacket;
|
||||
import org.kareha.hareka.client.packet.AddUpstairsPacket;
|
||||
import org.kareha.hareka.client.packet.DrawLinePacket;
|
||||
import org.kareha.hareka.client.packet.DrawRingPacket;
|
||||
import org.kareha.hareka.client.packet.FillRangePacket;
|
||||
import org.kareha.hareka.client.packet.NewFieldPacket;
|
||||
import org.kareha.hareka.client.packet.ReduceToBackgroundTilesPacket;
|
||||
import org.kareha.hareka.client.packet.RemoveOrphansPacket;
|
||||
import org.kareha.hareka.client.packet.RemoveSpecialTilePacket;
|
||||
import org.kareha.hareka.client.packet.RequestRegionListPacket;
|
||||
import org.kareha.hareka.client.packet.SetDefaultTilePatternPacket;
|
||||
import org.kareha.hareka.client.packet.SetMarkPacket;
|
||||
import org.kareha.hareka.client.packet.SetRegionListPacket;
|
||||
import org.kareha.hareka.client.packet.TilePacket;
|
||||
import org.kareha.hareka.field.Region;
|
||||
import org.kareha.hareka.field.TilePattern;
|
||||
import org.kareha.hareka.field.TilePiece;
|
||||
import org.kareha.hareka.field.Vector;
|
||||
|
||||
public class EditControl {
|
||||
|
||||
@@ -56,4 +67,28 @@ public class EditControl {
|
||||
session.write(new AddDownstairsPacket());
|
||||
}
|
||||
|
||||
public void setDefaultTilePattern(final TilePattern tilePattern) {
|
||||
session.write(new SetDefaultTilePatternPacket(tilePattern));
|
||||
}
|
||||
|
||||
public void drawLine(final Vector a, final Vector b, final TilePattern tilePattern, final boolean force) {
|
||||
session.write(new DrawLinePacket(a, b, tilePattern, force));
|
||||
}
|
||||
|
||||
public void drawRing(final Vector center, final int size, final TilePattern tilePattern, final boolean force) {
|
||||
session.write(new DrawRingPacket(center, size, tilePattern, force));
|
||||
}
|
||||
|
||||
public void fillRange(final Vector center, final int size, final TilePattern tilePattern, final boolean force) {
|
||||
session.write(new FillRangePacket(center, size, tilePattern, force));
|
||||
}
|
||||
|
||||
public void requestRegionList() {
|
||||
session.write(new RequestRegionListPacket());
|
||||
}
|
||||
|
||||
public void setRegionList(final Collection<Region> regions) {
|
||||
session.write(new SetRegionListPacket(regions));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package org.kareha.hareka.client.control;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.kareha.hareka.LocalEntityId;
|
||||
import org.kareha.hareka.client.ConnectionSettings;
|
||||
import org.kareha.hareka.client.ResponseHandler;
|
||||
import org.kareha.hareka.client.WorldSession;
|
||||
import org.kareha.hareka.client.chat.ChatEntity;
|
||||
import org.kareha.hareka.client.field.FieldEntity;
|
||||
import org.kareha.hareka.client.field.PositionMemory;
|
||||
import org.kareha.hareka.client.server.Server;
|
||||
|
||||
public class UserControl {
|
||||
|
||||
private final WorldSession session;
|
||||
|
||||
public UserControl(final WorldSession session) {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
public Server getServer() {
|
||||
return session.getServer();
|
||||
}
|
||||
|
||||
public FieldEntity getFieldEntity(final ChatEntity chatEntity) {
|
||||
return session.getServer().getFieldEntity(chatEntity);
|
||||
}
|
||||
|
||||
public void newCharacter(final ResponseHandler handler) {
|
||||
session.writeNewCharacter(handler);
|
||||
}
|
||||
|
||||
public void loginUser(final ResponseHandler handler) {
|
||||
session.writeLoginUser(handler);
|
||||
}
|
||||
|
||||
public void loginCharacter(final LocalEntityId id, final ResponseHandler handler) {
|
||||
session.writeLoginCharacter(id, handler);
|
||||
}
|
||||
|
||||
public void deleteCharacter(final LocalEntityId id, final ResponseHandler handler) {
|
||||
session.writeDeleteCharacter(id, handler);
|
||||
}
|
||||
|
||||
public void logoutUser(final ResponseHandler handler) {
|
||||
session.writeLogoutUser(handler);
|
||||
}
|
||||
|
||||
public boolean peerKeyExists() {
|
||||
return session.getPeerKey() != null;
|
||||
}
|
||||
|
||||
public ConnectionSettings.Entry getConnection() {
|
||||
return session.getConnection();
|
||||
}
|
||||
|
||||
public Collection<PositionMemory> getPositionMemories() {
|
||||
return session.getServer().getPositionMemories();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package org.kareha.hareka.swingclient;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.kareha.hareka.client.WorldSession;
|
||||
import org.kareha.hareka.client.field.FieldEntity;
|
||||
import org.kareha.hareka.client.server.Server;
|
||||
|
||||
@@ -20,11 +19,10 @@ public class PersistentEntities {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
return null;
|
||||
}
|
||||
final Server server = session.getServer();
|
||||
final Server server = strap.userControl().getServer();
|
||||
if (server == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -207,7 +207,8 @@ public class Shortcuts {
|
||||
@Private
|
||||
final LocalEntityId id;
|
||||
|
||||
public ItemEntry(final boolean repeating, final boolean selfTargetting, final int keyCode, final LocalEntityId id) {
|
||||
public ItemEntry(final boolean repeating, final boolean selfTargetting, final int keyCode,
|
||||
final LocalEntityId id) {
|
||||
super(repeating, selfTargetting, keyCode);
|
||||
this.id = id;
|
||||
}
|
||||
@@ -411,12 +412,10 @@ public class Shortcuts {
|
||||
if (owner != null) {
|
||||
try {
|
||||
if (!load()) {
|
||||
final List<ActiveSkillMirror.Entry> skills = new ArrayList<>(
|
||||
strap.getSession().getMirrors().getSkillMirror().getEntries());
|
||||
final List<ActiveSkillMirror.Entry> skills = strap.control().getActiveSkillEntries();
|
||||
for (int i = 0; i <= 9; i++) {
|
||||
if (i < skills.size()) {
|
||||
map.put(i,
|
||||
new SkillEntry(true, false, getNumberKeyCode(i), skills.get(i).getType()));
|
||||
map.put(i, new SkillEntry(true, false, getNumberKeyCode(i), skills.get(i).getType()));
|
||||
} else {
|
||||
map.put(i, new BlankEntry(false, false, getNumberKeyCode(i)));
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.kareha.hareka.client.WorldSession;
|
||||
import org.kareha.hareka.client.control.AdminControl;
|
||||
import org.kareha.hareka.client.control.Control;
|
||||
import org.kareha.hareka.client.control.EditControl;
|
||||
import org.kareha.hareka.client.control.UserControl;
|
||||
import org.kareha.hareka.graphics.GraphicsLoader;
|
||||
import org.kareha.hareka.sound.SoundContext;
|
||||
import org.kareha.hareka.swingclient.gui.Gui;
|
||||
@@ -42,6 +43,8 @@ public class Strap implements ManuallyClosable {
|
||||
@GuardedBy("this")
|
||||
private WorldSession session;
|
||||
@GuardedBy("this")
|
||||
private UserControl userControl;
|
||||
@GuardedBy("this")
|
||||
private Control control;
|
||||
@GuardedBy("this")
|
||||
private EditControl editControl;
|
||||
@@ -159,17 +162,18 @@ public class Strap implements ManuallyClosable {
|
||||
return shortcuts;
|
||||
}
|
||||
|
||||
public synchronized WorldSession getSession() {
|
||||
return session;
|
||||
}
|
||||
|
||||
public synchronized void setSession(final WorldSession session) {
|
||||
this.session = session;
|
||||
this.userControl = new UserControl(session);
|
||||
this.control = new Control(session);
|
||||
this.editControl = new EditControl(session);
|
||||
this.adminControl = new AdminControl(session);
|
||||
}
|
||||
|
||||
public synchronized UserControl userControl() {
|
||||
return userControl;
|
||||
}
|
||||
|
||||
public synchronized Control control() {
|
||||
return control;
|
||||
}
|
||||
@@ -238,4 +242,9 @@ public class Strap implements ManuallyClosable {
|
||||
return scheduledExecutor;
|
||||
}
|
||||
|
||||
// XXX
|
||||
public void closeSession() {
|
||||
session.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,6 @@ import org.kareha.hareka.client.mirror.SelfMirror;
|
||||
import org.kareha.hareka.client.mirror.SystemMirror;
|
||||
import org.kareha.hareka.client.mirror.UserMirror;
|
||||
import org.kareha.hareka.client.mirror.UserMirror.CharacterEntry;
|
||||
import org.kareha.hareka.client.packet.AutopilotPacket;
|
||||
import org.kareha.hareka.client.user.RoleToken;
|
||||
import org.kareha.hareka.field.Placement;
|
||||
import org.kareha.hareka.field.Region;
|
||||
@@ -323,7 +322,7 @@ public final class SwingConnector {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
final View view = gui.getViewPane().getView();
|
||||
if (view != null) {
|
||||
final FieldEntity fieldEntity = strap.getSession().getServer()
|
||||
final FieldEntity fieldEntity = strap.userControl()
|
||||
.getFieldEntity(message.getSpeaker());
|
||||
if (fieldEntity != null) {
|
||||
view.updateEntityName(fieldEntity);
|
||||
@@ -409,7 +408,7 @@ public final class SwingConnector {
|
||||
public void fieldEntityPlaced(final Placement placement, final int motionWait) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
gui.getViewPane().getView().placeEntity(entity, placement, motionWait);
|
||||
if (entity == strap.getSession().getMirrors().getSelfMirror().getFieldEntity()) {
|
||||
if (entity == strap.control().getFieldEntity()) {
|
||||
gui.getViewPane().getView().walk(placement.getPosition());
|
||||
}
|
||||
});
|
||||
@@ -441,7 +440,7 @@ public final class SwingConnector {
|
||||
gui.getViewPane().setViewVisible(true);
|
||||
gui.getPositionMemoryFrame().initPositionMemories(fieldEntity);
|
||||
|
||||
strap.getSession().write(new AutopilotPacket(gui.getViewPane().isAutopilot()));
|
||||
strap.control().setAutopilot(gui.getViewPane().isAutopilot());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -453,7 +452,7 @@ public final class SwingConnector {
|
||||
@Override
|
||||
public void selfRefreshed() {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
final FieldEntity entity = strap.getSession().getMirrors().getSelfMirror().getFieldEntity();
|
||||
final FieldEntity entity = strap.control().getFieldEntity();
|
||||
if (entity != null) {
|
||||
strap.getShortcuts().setOwner(entity);
|
||||
}
|
||||
@@ -568,7 +567,7 @@ public final class SwingConnector {
|
||||
// nothing to do
|
||||
}
|
||||
};
|
||||
strap.getSession().writeLoginUser(responseHandler);
|
||||
strap.userControl().loginUser(responseHandler);
|
||||
}
|
||||
|
||||
@Private
|
||||
@@ -585,7 +584,7 @@ public final class SwingConnector {
|
||||
SwingUtilities.invokeLater(() -> gui.addMessage(message));
|
||||
}
|
||||
};
|
||||
strap.getSession().writeNewCharacter(responseHandler);
|
||||
strap.userControl().newCharacter(responseHandler);
|
||||
}
|
||||
|
||||
@Private
|
||||
@@ -603,13 +602,13 @@ public final class SwingConnector {
|
||||
@Override
|
||||
public void accepted(final String message) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
strap.getSession().getMirrors().getChatMirror().getLocalChatSession();
|
||||
strap.control().activateLocalChat();
|
||||
|
||||
gui.getViewPane().setEditMode(false);
|
||||
});
|
||||
}
|
||||
};
|
||||
strap.getSession().writeLoginCharacter(entry.getId(), responseHandler);
|
||||
strap.userControl().loginCharacter(entry.getId(), responseHandler);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class CharactersFrame extends JInternalFrame {
|
||||
});
|
||||
}
|
||||
};
|
||||
strap.getSession().writeNewCharacter(responseHandler);
|
||||
strap.userControl().newCharacter(responseHandler);
|
||||
});
|
||||
final JButton deleteButton = new JButton(bundle.getString(BundleKey.Delete.name()));
|
||||
deleteButton.addActionListener(e -> {
|
||||
@@ -96,11 +96,11 @@ public class CharactersFrame extends JInternalFrame {
|
||||
.invokeLater(() -> JOptionPane.showInternalMessageDialog(CharactersFrame.this, message));
|
||||
}
|
||||
};
|
||||
strap.getSession().writeDeleteCharacter(entry.getId(), responseHandler);
|
||||
strap.userControl().deleteCharacter(entry.getId(), responseHandler);
|
||||
});
|
||||
final JButton logoutButton = new JButton(bundle.getString(BundleKey.Logout.name()));
|
||||
logoutButton.addActionListener(e -> {
|
||||
strap.getSession().writeLogoutUser(new ResponseHandler() {
|
||||
strap.userControl().logoutUser(new ResponseHandler() {
|
||||
@Override
|
||||
public void rejected(final String message) {
|
||||
SwingUtilities
|
||||
@@ -210,7 +210,7 @@ public class CharactersFrame extends JInternalFrame {
|
||||
setVisible(false);
|
||||
// gui.getChatFrame().setVisible(true);
|
||||
// create local chat entry
|
||||
strap.getSession().getMirrors().getChatMirror().getLocalChatSession();
|
||||
strap.control().activateLocalChat();
|
||||
|
||||
gui.getViewPane().setEditMode(false);
|
||||
|
||||
@@ -218,7 +218,7 @@ public class CharactersFrame extends JInternalFrame {
|
||||
});
|
||||
}
|
||||
};
|
||||
strap.getSession().writeLoginCharacter(entry.getId(), responseHandler);
|
||||
strap.userControl().loginCharacter(entry.getId(), responseHandler);
|
||||
}
|
||||
|
||||
private class CharacterEntryItem extends JComponent implements LiveList.Selectable {
|
||||
|
||||
@@ -35,7 +35,6 @@ import org.kareha.hareka.client.chat.ChatSession;
|
||||
import org.kareha.hareka.client.chat.LocalChatSession;
|
||||
import org.kareha.hareka.client.chat.PrivateChatSession;
|
||||
import org.kareha.hareka.client.field.FieldEntity;
|
||||
import org.kareha.hareka.client.packet.InspectChatEntityPacket;
|
||||
import org.kareha.hareka.swingclient.Strap;
|
||||
import org.kareha.hareka.util.HtmlUtil;
|
||||
|
||||
@@ -83,7 +82,7 @@ public class ChatPanel extends JComponent {
|
||||
if (entity == null) {
|
||||
return;
|
||||
}
|
||||
strap.getSession().write(new InspectChatEntityPacket(entity));
|
||||
strap.adminControl().inspect(entity);
|
||||
// for (int i = 0; i < channelItems.getItemCount(); i++) {
|
||||
// final ChannelItem channelItem =
|
||||
// channelItems.getItemAt(i);
|
||||
@@ -121,7 +120,8 @@ public class ChatPanel extends JComponent {
|
||||
}
|
||||
});
|
||||
|
||||
scroll = new JScrollPane(pane, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
scroll = new JScrollPane(pane, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
|
||||
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
|
||||
channelItems = new JComboBox<>();
|
||||
|
||||
@@ -169,8 +169,7 @@ public class ChatPanel extends JComponent {
|
||||
return;
|
||||
}
|
||||
final PrivateChannelItem privateChannelItem = (PrivateChannelItem) channelItem;
|
||||
strap.getSession().getMirrors().getChatMirror()
|
||||
.removePrivateChatSession(privateChannelItem.getPeer());
|
||||
strap.control().removePrivateChatSession(privateChannelItem.getPeer());
|
||||
});
|
||||
popup.add(item);
|
||||
}
|
||||
@@ -247,10 +246,10 @@ public class ChatPanel extends JComponent {
|
||||
final Color color) {
|
||||
entityMap.put(entity.getLocalId(), entity);
|
||||
|
||||
final FieldEntity fieldEntity = strap.getSession().getServer().getFieldEntity(entity);
|
||||
final FieldEntity fieldEntity = strap.userControl().getFieldEntity(entity);
|
||||
final String nickname;
|
||||
if (fieldEntity != null) {
|
||||
nickname = strap.getSession().getServer().getFieldNickname(fieldEntity.getLocalId());
|
||||
nickname = strap.control().getNickname(fieldEntity.getLocalId());
|
||||
} else {
|
||||
nickname = null;
|
||||
}
|
||||
@@ -393,7 +392,7 @@ public class ChatPanel extends JComponent {
|
||||
@Override
|
||||
public void addChat(final ChatEntity speaker, final String content) {
|
||||
final String f;
|
||||
if (speaker.equals(strap.getSession().getMirrors().getSelfMirror().getChatEntity())) {
|
||||
if (speaker.equals(strap.control().getChatEntity())) {
|
||||
f = echoFormat;
|
||||
addLine(this, f, getSession().getPeer(), content, color);
|
||||
} else {
|
||||
|
||||
@@ -99,7 +99,7 @@ class ChatView {
|
||||
}
|
||||
|
||||
void add(final ChatEntity chatEntity, final String content) {
|
||||
final FieldEntity fieldEntity = strap.getSession().getServer().getFieldEntity(chatEntity);
|
||||
final FieldEntity fieldEntity = strap.control().getFieldEntity(chatEntity);
|
||||
if (fieldEntity == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,6 @@ import javax.swing.text.Style;
|
||||
import javax.swing.text.StyleConstants;
|
||||
import javax.swing.text.StyledDocument;
|
||||
|
||||
import org.kareha.hareka.client.WorldSession;
|
||||
import org.kareha.hareka.client.packet.CommandPacket;
|
||||
import org.kareha.hareka.logging.SimpleLogger;
|
||||
import org.kareha.hareka.swingclient.Strap;
|
||||
import org.kareha.hareka.util.CommandLineTokenizer;
|
||||
@@ -75,8 +73,7 @@ public class CommandFrame extends JInternalFrame {
|
||||
|
||||
final JTextField input = new JTextField();
|
||||
input.addActionListener(e -> {
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
JOptionPane.showMessageDialog(gui.getViewPane(), bundle.getString(BundleKey.NotConnected.name()));
|
||||
return;
|
||||
}
|
||||
@@ -85,7 +82,7 @@ public class CommandFrame extends JInternalFrame {
|
||||
addEcho(line);
|
||||
final CommandLineTokenizer t = new CommandLineTokenizer(line);
|
||||
final String[] args = t.getTokens();
|
||||
session.write(new CommandPacket(args));
|
||||
strap.control().command(args);
|
||||
});
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
@@ -14,8 +14,6 @@ import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
import org.kareha.hareka.client.WorldSession;
|
||||
import org.kareha.hareka.client.packet.SetDefaultTilePatternPacket;
|
||||
import org.kareha.hareka.field.OneUniformTilePattern;
|
||||
import org.kareha.hareka.field.SolidTilePattern;
|
||||
import org.kareha.hareka.field.Tile;
|
||||
@@ -95,8 +93,7 @@ public class DefaultTilePatternFrame extends JInternalFrame {
|
||||
final JPanel buttonPanel = new JPanel();
|
||||
final JButton okButton = new JButton(bundle.getString(BundleKey.Ok.name()));
|
||||
okButton.addActionListener(e -> {
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
JOptionPane.showInternalMessageDialog(this, bundle.getString(BundleKey.NotConnected.name()));
|
||||
return;
|
||||
}
|
||||
@@ -126,7 +123,7 @@ public class DefaultTilePatternFrame extends JInternalFrame {
|
||||
tilePattern = new OneUniformTilePattern(tileA, tileB, tileC);
|
||||
break;
|
||||
}
|
||||
session.write(new SetDefaultTilePatternPacket(tilePattern));
|
||||
strap.editControl().setDefaultTilePattern(tilePattern);
|
||||
setVisible(false);
|
||||
});
|
||||
buttonPanel.add(okButton);
|
||||
|
||||
@@ -15,9 +15,7 @@ import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
import org.kareha.hareka.client.WorldSession;
|
||||
import org.kareha.hareka.client.field.FieldEntity;
|
||||
import org.kareha.hareka.client.packet.DrawLinePacket;
|
||||
import org.kareha.hareka.field.OneUniformTilePattern;
|
||||
import org.kareha.hareka.field.Placement;
|
||||
import org.kareha.hareka.field.SolidTilePattern;
|
||||
@@ -58,11 +56,10 @@ public class DrawLineFrame extends JInternalFrame {
|
||||
final JTextField yFieldA = new JTextField("0", 6);
|
||||
positionPanelA.add(yFieldA);
|
||||
final Runnable currentPositionRunnableA = () -> {
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
return;
|
||||
}
|
||||
final FieldEntity entity = session.getMirrors().getSelfMirror().getFieldEntity();
|
||||
final FieldEntity entity = strap.control().getFieldEntity();
|
||||
if (entity == null) {
|
||||
return;
|
||||
}
|
||||
@@ -84,11 +81,10 @@ public class DrawLineFrame extends JInternalFrame {
|
||||
final JTextField yFieldB = new JTextField("0", 6);
|
||||
positionPanelB.add(yFieldB);
|
||||
final Runnable currentPositionRunnableB = () -> {
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
return;
|
||||
}
|
||||
final FieldEntity entity = session.getMirrors().getSelfMirror().getFieldEntity();
|
||||
final FieldEntity entity = strap.control().getFieldEntity();
|
||||
if (entity == null) {
|
||||
return;
|
||||
}
|
||||
@@ -180,8 +176,7 @@ public class DrawLineFrame extends JInternalFrame {
|
||||
final JPanel buttonPanel = new JPanel();
|
||||
final JButton drawButton = new JButton(bundle.getString(BundleKey.Draw.name()));
|
||||
drawButton.addActionListener(e -> {
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
JOptionPane.showInternalMessageDialog(this, bundle.getString(BundleKey.NotConnected.name()));
|
||||
return;
|
||||
}
|
||||
@@ -198,13 +193,12 @@ public class DrawLineFrame extends JInternalFrame {
|
||||
if (tilePattern == null) {
|
||||
return;
|
||||
}
|
||||
session.write(new DrawLinePacket(a, b, tilePattern, false));
|
||||
strap.editControl().drawLine(a, b, tilePattern, false);
|
||||
});
|
||||
buttonPanel.add(drawButton);
|
||||
final JButton forceDrawButton = new JButton(bundle.getString(BundleKey.ForceDraw.name()));
|
||||
forceDrawButton.addActionListener(e -> {
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
JOptionPane.showInternalMessageDialog(this, bundle.getString(BundleKey.NotConnected.name()));
|
||||
return;
|
||||
}
|
||||
@@ -221,7 +215,7 @@ public class DrawLineFrame extends JInternalFrame {
|
||||
if (tilePattern == null) {
|
||||
return;
|
||||
}
|
||||
session.write(new DrawLinePacket(a, b, tilePattern, true));
|
||||
strap.editControl().drawLine(a, b, tilePattern, true);
|
||||
});
|
||||
buttonPanel.add(forceDrawButton);
|
||||
|
||||
|
||||
@@ -15,10 +15,7 @@ import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
import org.kareha.hareka.client.WorldSession;
|
||||
import org.kareha.hareka.client.field.FieldEntity;
|
||||
import org.kareha.hareka.client.packet.DrawRingPacket;
|
||||
import org.kareha.hareka.client.packet.FillRangePacket;
|
||||
import org.kareha.hareka.field.OneUniformTilePattern;
|
||||
import org.kareha.hareka.field.Placement;
|
||||
import org.kareha.hareka.field.SolidTilePattern;
|
||||
@@ -59,11 +56,10 @@ public class FillRangeFrame extends JInternalFrame {
|
||||
final JTextField yField = new JTextField("0", 6);
|
||||
positionPanel.add(yField);
|
||||
final Runnable currentPositionRunnable = () -> {
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
return;
|
||||
}
|
||||
final FieldEntity entity = session.getMirrors().getSelfMirror().getFieldEntity();
|
||||
final FieldEntity entity = strap.control().getFieldEntity();
|
||||
if (entity == null) {
|
||||
return;
|
||||
}
|
||||
@@ -160,8 +156,7 @@ public class FillRangeFrame extends JInternalFrame {
|
||||
final JPanel fillButtonPanel = new JPanel();
|
||||
final JButton fillButton = new JButton(bundle.getString(BundleKey.Fill.name()));
|
||||
fillButton.addActionListener(e -> {
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
JOptionPane.showInternalMessageDialog(this, bundle.getString(BundleKey.NotConnected.name()));
|
||||
return;
|
||||
}
|
||||
@@ -178,13 +173,12 @@ public class FillRangeFrame extends JInternalFrame {
|
||||
if (tilePattern == null) {
|
||||
return;
|
||||
}
|
||||
session.write(new FillRangePacket(center, size, tilePattern, false));
|
||||
strap.editControl().fillRange(center, size, tilePattern, false);
|
||||
});
|
||||
fillButtonPanel.add(fillButton);
|
||||
final JButton forceFillButton = new JButton(bundle.getString(BundleKey.ForceFill.name()));
|
||||
forceFillButton.addActionListener(e -> {
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
JOptionPane.showInternalMessageDialog(this, bundle.getString(BundleKey.NotConnected.name()));
|
||||
return;
|
||||
}
|
||||
@@ -201,15 +195,14 @@ public class FillRangeFrame extends JInternalFrame {
|
||||
if (tilePattern == null) {
|
||||
return;
|
||||
}
|
||||
session.write(new FillRangePacket(center, size, tilePattern, true));
|
||||
strap.editControl().fillRange(center, size, tilePattern, true);
|
||||
});
|
||||
fillButtonPanel.add(forceFillButton);
|
||||
|
||||
final JPanel drawButtonPanel = new JPanel();
|
||||
final JButton drawButton = new JButton(bundle.getString(BundleKey.Draw.name()));
|
||||
drawButton.addActionListener(e -> {
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
JOptionPane.showInternalMessageDialog(this, bundle.getString(BundleKey.NotConnected.name()));
|
||||
return;
|
||||
}
|
||||
@@ -226,13 +219,12 @@ public class FillRangeFrame extends JInternalFrame {
|
||||
if (tilePattern == null) {
|
||||
return;
|
||||
}
|
||||
session.write(new DrawRingPacket(center, size, tilePattern, false));
|
||||
strap.editControl().drawRing(center, size, tilePattern, false);
|
||||
});
|
||||
drawButtonPanel.add(drawButton);
|
||||
final JButton forceDrawButton = new JButton(bundle.getString(BundleKey.ForceDraw.name()));
|
||||
forceDrawButton.addActionListener(e -> {
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
JOptionPane.showInternalMessageDialog(this, bundle.getString(BundleKey.NotConnected.name()));
|
||||
return;
|
||||
}
|
||||
@@ -249,7 +241,7 @@ public class FillRangeFrame extends JInternalFrame {
|
||||
if (tilePattern == null) {
|
||||
return;
|
||||
}
|
||||
session.write(new DrawRingPacket(center, size, tilePattern, true));
|
||||
strap.editControl().drawRing(center, size, tilePattern, true);
|
||||
});
|
||||
drawButtonPanel.add(forceDrawButton);
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@ import org.kareha.hareka.LocalEntityId;
|
||||
import org.kareha.hareka.LocalUserId;
|
||||
import org.kareha.hareka.ManuallyClosable;
|
||||
import org.kareha.hareka.annotation.ConfinedTo;
|
||||
import org.kareha.hareka.client.packet.CancelTokenPacket;
|
||||
import org.kareha.hareka.client.packet.TokenPacket;
|
||||
import org.kareha.hareka.swingclient.Strap;
|
||||
import org.kareha.hareka.swingclient.SwingClientUtil;
|
||||
|
||||
@@ -361,7 +359,7 @@ public class Gui implements ManuallyClosable {
|
||||
while (true) {
|
||||
final String input = SwingClientUtil.showInputWithPasteButtonDialog(getMainFrame(), message);
|
||||
if (input == null || input.isEmpty()) {
|
||||
strap.getSession().write(new CancelTokenPacket(handlerId));
|
||||
strap.adminControl().cancelToken(handlerId);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@@ -374,7 +372,7 @@ public class Gui implements ManuallyClosable {
|
||||
break;
|
||||
}
|
||||
}
|
||||
strap.getSession().write(new TokenPacket(handlerId, token));
|
||||
strap.adminControl().token(handlerId, token);
|
||||
}
|
||||
|
||||
public ServerSettingsFrame getServerSettingsFrame() {
|
||||
|
||||
@@ -20,8 +20,6 @@ import javax.swing.ToolTipManager;
|
||||
import javax.swing.TransferHandler;
|
||||
|
||||
import org.kareha.hareka.annotation.Private;
|
||||
import org.kareha.hareka.client.packet.DeleteItemPacket;
|
||||
import org.kareha.hareka.client.packet.DropItemPacket;
|
||||
import org.kareha.hareka.swingclient.Strap;
|
||||
import org.kareha.hareka.swingclient.SwingClientConstants;
|
||||
import org.kareha.hareka.ui.swing.SwingUtil;
|
||||
@@ -151,7 +149,7 @@ public class ItemButton extends JComponent {
|
||||
|
||||
strap.getGui().getViewPane().stopAutopilot();
|
||||
|
||||
strap.getSession().write(new DropItemPacket(value.getEntry().getId(), count));
|
||||
strap.control().dropItem(value.getEntry().getId(), count);
|
||||
}
|
||||
|
||||
public void deleteItem() {
|
||||
@@ -175,7 +173,7 @@ public class ItemButton extends JComponent {
|
||||
if (result != JOptionPane.YES_OPTION) {
|
||||
return;
|
||||
}
|
||||
strap.getSession().write(new DeleteItemPacket(value.getEntry().getId(), count));
|
||||
strap.control().deleteItem(value.getEntry().getId(), count);
|
||||
}
|
||||
|
||||
@Private
|
||||
|
||||
@@ -59,7 +59,7 @@ public class LoginFrame extends JInternalFrame {
|
||||
@Private
|
||||
void doLogin() {
|
||||
final Gui gui = strap.getGui();
|
||||
if (strap.getSession().getPeerKey() == null) {
|
||||
if (!strap.userControl().peerKeyExists()) {
|
||||
final ResourceBundle bundle = ResourceBundle.getBundle(LoginFrame.class.getName());
|
||||
JOptionPane.showMessageDialog(gui.getViewPane(), bundle.getString(BundleKey.WaitingForKeyExchange.name()));
|
||||
return;
|
||||
@@ -82,12 +82,13 @@ public class LoginFrame extends JInternalFrame {
|
||||
});
|
||||
}
|
||||
};
|
||||
strap.getSession().writeLoginUser(responseHandler);
|
||||
strap.userControl().loginUser(responseHandler);
|
||||
}
|
||||
|
||||
private void doDisconnect() {
|
||||
final Gui gui = strap.getGui();
|
||||
strap.getSession().close();
|
||||
// XXX
|
||||
strap.closeSession();
|
||||
gui.getViewPane().remove(this);
|
||||
dispose();
|
||||
gui.newConnectionFrame();
|
||||
|
||||
@@ -623,7 +623,7 @@ public class MainMenuBar extends JMenuBar {
|
||||
JOptionPane.showMessageDialog(gui.getViewPane(), bundle.getString(BundleKey.NotConnected.name()));
|
||||
return;
|
||||
}
|
||||
strap.control().issueInvitationToken();
|
||||
strap.adminControl().issueInvitationToken();
|
||||
});
|
||||
adminMenu.add(issueInvitationTokenItem);
|
||||
|
||||
@@ -817,7 +817,7 @@ public class MainMenuBar extends JMenuBar {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URI(strap.getSession().getConnection().getSite()));
|
||||
Desktop.getDesktop().browse(new URI(strap.userControl().getConnection().getSite()));
|
||||
} catch (final IOException | URISyntaxException ex) {
|
||||
JOptionPane.showMessageDialog(gui.getViewPane(), ex.getMessage());
|
||||
}
|
||||
|
||||
@@ -15,11 +15,8 @@ import javax.swing.JScrollPane;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
import org.kareha.hareka.client.WorldSession;
|
||||
import org.kareha.hareka.client.field.FieldEntity;
|
||||
import org.kareha.hareka.client.field.PositionMemory;
|
||||
import org.kareha.hareka.client.packet.GetPositionMemoryPacket;
|
||||
import org.kareha.hareka.client.packet.TeleportToPositionMemoryPacket;
|
||||
import org.kareha.hareka.swingclient.Strap;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@@ -55,11 +52,10 @@ public class PositionMemoryFrame extends JInternalFrame {
|
||||
final JPanel southPanel = new JPanel();
|
||||
final JButton memorizeButton = new JButton(bundle.getString(BundleKey.Memorize.name()));
|
||||
memorizeButton.addActionListener(e -> {
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
return;
|
||||
}
|
||||
session.write(new GetPositionMemoryPacket());
|
||||
strap.control().getPositionMemory();
|
||||
});
|
||||
southPanel.add(memorizeButton);
|
||||
final JButton teleportButton = new JButton(bundle.getString(BundleKey.Teleport.name()));
|
||||
@@ -69,11 +65,10 @@ public class PositionMemoryFrame extends JInternalFrame {
|
||||
return;
|
||||
}
|
||||
final PositionMemory memory = list.getModel().getElementAt(index);
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
return;
|
||||
}
|
||||
session.write(new TeleportToPositionMemoryPacket(memory.getData()));
|
||||
strap.control().teleportToPositionMemory(memory.getData());
|
||||
});
|
||||
southPanel.add(teleportButton);
|
||||
|
||||
@@ -88,12 +83,11 @@ public class PositionMemoryFrame extends JInternalFrame {
|
||||
if (index < 1) {
|
||||
return;
|
||||
}
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
return;
|
||||
}
|
||||
final PositionMemory memory = session.getServer().removePositionMemory(index);
|
||||
session.getServer().addPositionMemory(index - 1, memory);
|
||||
final PositionMemory memory = strap.control().removePositionMemory(index);
|
||||
strap.control().addPositionMemory(index - 1, memory);
|
||||
final PositionMemory memory2 = getModel().remove(index);
|
||||
getModel().add(index - 1, memory2);
|
||||
list.setSelectedIndex(index - 1);
|
||||
@@ -108,12 +102,11 @@ public class PositionMemoryFrame extends JInternalFrame {
|
||||
if (index >= list.getModel().getSize() - 1) {
|
||||
return;
|
||||
}
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
return;
|
||||
}
|
||||
final PositionMemory memory = session.getServer().removePositionMemory(index);
|
||||
session.getServer().addPositionMemory(index + 1, memory);
|
||||
final PositionMemory memory = strap.control().removePositionMemory(index);
|
||||
strap.control().addPositionMemory(index + 1, memory);
|
||||
final PositionMemory memory2 = getModel().remove(index);
|
||||
getModel().add(index + 1, memory2);
|
||||
list.setSelectedIndex(index + 1);
|
||||
@@ -125,8 +118,7 @@ public class PositionMemoryFrame extends JInternalFrame {
|
||||
if (index == -1) {
|
||||
return;
|
||||
}
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (strap.isConnected()) {
|
||||
return;
|
||||
}
|
||||
final int result = JOptionPane.showInternalConfirmDialog(this,
|
||||
@@ -134,7 +126,7 @@ public class PositionMemoryFrame extends JInternalFrame {
|
||||
if (result != JOptionPane.YES_OPTION) {
|
||||
return;
|
||||
}
|
||||
session.getServer().removePositionMemory(index);
|
||||
strap.control().removePositionMemory(index);
|
||||
getModel().remove(index);
|
||||
});
|
||||
buttonPanel.add(deleteButton);
|
||||
@@ -152,11 +144,10 @@ public class PositionMemoryFrame extends JInternalFrame {
|
||||
|
||||
public void initPositionMemories(final FieldEntity entity) {
|
||||
getModel().clear();
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
return;
|
||||
}
|
||||
for (final PositionMemory memory : session.getServer().getPositionMemories()) {
|
||||
for (final PositionMemory memory : strap.userControl().getPositionMemories()) {
|
||||
if (!memory.getEntityId().equals(entity.getLocalId())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,6 @@ import javax.swing.event.InternalFrameAdapter;
|
||||
import javax.swing.event.InternalFrameEvent;
|
||||
|
||||
import org.kareha.hareka.annotation.Private;
|
||||
import org.kareha.hareka.client.packet.CancelPowPacket;
|
||||
import org.kareha.hareka.client.packet.PowPacket;
|
||||
import org.kareha.hareka.pow.ProofOfWork;
|
||||
import org.kareha.hareka.swingclient.Strap;
|
||||
|
||||
@@ -119,9 +117,9 @@ public class PowFrame extends JInternalFrame {
|
||||
protected void done() {
|
||||
final Gui gui = strap.getGui();
|
||||
try {
|
||||
strap.getSession().write(new PowPacket(handlerId, get()));
|
||||
strap.control().pow(handlerId, get());
|
||||
} catch (final CancellationException e) {
|
||||
strap.getSession().write(new CancelPowPacket(handlerId));
|
||||
strap.control().cancelPow(handlerId);
|
||||
} catch (final InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
return;
|
||||
|
||||
@@ -24,10 +24,7 @@ import javax.swing.JTextField;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
import org.kareha.hareka.client.WorldSession;
|
||||
import org.kareha.hareka.client.field.FieldEntity;
|
||||
import org.kareha.hareka.client.packet.RequestRegionListPacket;
|
||||
import org.kareha.hareka.client.packet.SetRegionListPacket;
|
||||
import org.kareha.hareka.field.OneUniformTilePattern;
|
||||
import org.kareha.hareka.field.Placement;
|
||||
import org.kareha.hareka.field.Region;
|
||||
@@ -73,11 +70,10 @@ public class RegionsFrame extends JInternalFrame {
|
||||
final JTextField yField = new JTextField("0", 6);
|
||||
positionPanel.add(yField);
|
||||
final Runnable currentPositionRunnable = () -> {
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
return;
|
||||
}
|
||||
final FieldEntity entity = session.getMirrors().getSelfMirror().getFieldEntity();
|
||||
final FieldEntity entity = strap.control().getFieldEntity();
|
||||
if (entity == null) {
|
||||
return;
|
||||
}
|
||||
@@ -217,11 +213,10 @@ public class RegionsFrame extends JInternalFrame {
|
||||
final JPanel buttonPanel = new JPanel();
|
||||
final JButton loadButton = new JButton(bundle.getString(BundleKey.Load.name()));
|
||||
loadButton.addActionListener(e -> {
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
return;
|
||||
}
|
||||
session.write(new RequestRegionListPacket());
|
||||
strap.editControl().requestRegionList();
|
||||
});
|
||||
buttonPanel.add(loadButton);
|
||||
final JButton newButton = new JButton(bundle.getString(BundleKey.New.name()));
|
||||
@@ -272,11 +267,10 @@ public class RegionsFrame extends JInternalFrame {
|
||||
for (final Enumeration<Region> en = model.elements(); en.hasMoreElements();) {
|
||||
regions.add(en.nextElement());
|
||||
}
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
return;
|
||||
}
|
||||
session.write(new SetRegionListPacket(regions));
|
||||
strap.editControl().setRegionList(regions);
|
||||
});
|
||||
buttonPanel.add(saveButton);
|
||||
|
||||
|
||||
@@ -22,9 +22,6 @@ import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
import org.kareha.hareka.client.WorldSession;
|
||||
import org.kareha.hareka.client.packet.DefineRolePacket;
|
||||
import org.kareha.hareka.client.packet.UndefineRolePacket;
|
||||
import org.kareha.hareka.client.user.CustomRole;
|
||||
import org.kareha.hareka.swingclient.Strap;
|
||||
import org.kareha.hareka.user.Permission;
|
||||
@@ -141,12 +138,11 @@ public class RoleEditorFrame extends JInternalFrame {
|
||||
permissions.add(includedListModel.getElementAt(i));
|
||||
}
|
||||
final Role role = new CustomRole(roleId, rank, permissions);
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
JOptionPane.showInternalMessageDialog(this, bundle.getString(BundleKey.NotConnected.name()));
|
||||
return;
|
||||
}
|
||||
session.write(new DefineRolePacket(role));
|
||||
strap.adminControl().defineRole(role);
|
||||
});
|
||||
southPanel.add(applyButton);
|
||||
final JButton deleteButton = new JButton(bundle.getString(BundleKey.Delete.name()));
|
||||
@@ -160,12 +156,11 @@ public class RoleEditorFrame extends JInternalFrame {
|
||||
if (result != JOptionPane.YES_OPTION) {
|
||||
return;
|
||||
}
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
JOptionPane.showInternalMessageDialog(this, bundle.getString(BundleKey.NotConnected.name()));
|
||||
return;
|
||||
}
|
||||
session.write(new UndefineRolePacket(roleId));
|
||||
strap.adminControl().undefineRole(roleId);
|
||||
});
|
||||
southPanel.add(deleteButton);
|
||||
|
||||
@@ -188,11 +183,10 @@ public class RoleEditorFrame extends JInternalFrame {
|
||||
}
|
||||
|
||||
public void updateRoles() {
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
return;
|
||||
}
|
||||
final List<Role> roles = new ArrayList<>(session.getMirrors().getAdminMirror().getRoles());
|
||||
final List<Role> roles = new ArrayList<>(strap.adminControl().getRoles());
|
||||
roles.sort((a, b) -> {
|
||||
if (a.getRank() > b.getRank()) {
|
||||
return -1;
|
||||
|
||||
@@ -20,8 +20,6 @@ import javax.swing.JScrollPane;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
import org.kareha.hareka.client.WorldSession;
|
||||
import org.kareha.hareka.client.packet.IssueRoleTokenPacket;
|
||||
import org.kareha.hareka.swingclient.Strap;
|
||||
import org.kareha.hareka.user.Permission;
|
||||
import org.kareha.hareka.user.Role;
|
||||
@@ -76,12 +74,11 @@ public class RoleTokenIssueFrame extends JInternalFrame {
|
||||
return;
|
||||
}
|
||||
final Role role = roleComboBox.getItemAt(index);
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
JOptionPane.showInternalMessageDialog(this, bundle.getString(BundleKey.NotConnected.name()));
|
||||
return;
|
||||
}
|
||||
session.write(new IssueRoleTokenPacket(role.getId()));
|
||||
strap.adminControl().issueRoleToken(role.getId());
|
||||
setVisible(false);
|
||||
});
|
||||
southPanel.add(okButton);
|
||||
@@ -97,8 +94,7 @@ public class RoleTokenIssueFrame extends JInternalFrame {
|
||||
}
|
||||
|
||||
public void updateRoles() {
|
||||
final Role pr = strap.getSession().getMirrors().getAdminMirror().getRoleSet()
|
||||
.getHighestRole(Permission.ISSUE_ROLE_TOKENS);
|
||||
final Role pr = strap.adminControl().getHighestRole(Permission.ISSUE_ROLE_TOKENS);
|
||||
final int rank;
|
||||
if (pr == null) {
|
||||
rank = 0;
|
||||
@@ -106,7 +102,7 @@ public class RoleTokenIssueFrame extends JInternalFrame {
|
||||
rank = pr.getRank();
|
||||
}
|
||||
final List<Role> roles = new ArrayList<>();
|
||||
for (final Role role : strap.getSession().getMirrors().getAdminMirror().getRoles()) {
|
||||
for (final Role role : strap.adminControl().getRoles()) {
|
||||
if (role.getRank() < rank) {
|
||||
roles.add(role);
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@ import javax.swing.JScrollPane;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
import org.kareha.hareka.client.WorldSession;
|
||||
import org.kareha.hareka.client.packet.DeleteRoleTokenPacket;
|
||||
import org.kareha.hareka.client.user.RoleToken;
|
||||
import org.kareha.hareka.swingclient.Strap;
|
||||
|
||||
@@ -58,12 +56,11 @@ public class RoleTokenListFrame extends JInternalFrame {
|
||||
if (entry == null) {
|
||||
return;
|
||||
}
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
JOptionPane.showInternalMessageDialog(this, bundle.getString(BundleKey.NotConnected.name()));
|
||||
return;
|
||||
}
|
||||
session.write(new DeleteRoleTokenPacket(entry.getRoleToken().getId()));
|
||||
strap.adminControl().deleteRoleToken(entry.getRoleToken().getId());
|
||||
});
|
||||
southPanel.add(deleteButton);
|
||||
|
||||
@@ -74,12 +71,11 @@ public class RoleTokenListFrame extends JInternalFrame {
|
||||
}
|
||||
|
||||
public void updateRoleTokenList() {
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
return;
|
||||
}
|
||||
listModel.clear();
|
||||
for (final RoleToken token : session.getMirrors().getAdminMirror().getRoleTokens()) {
|
||||
for (final RoleToken token : strap.adminControl().getRoleTokens()) {
|
||||
listModel.addElement(new RoleTokenEntry(token));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,6 @@ import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
import org.kareha.hareka.client.WorldSession;
|
||||
import org.kareha.hareka.client.packet.SetRescueMethodsEnabledPacket;
|
||||
import org.kareha.hareka.client.packet.SetUserRegistrationModePacket;
|
||||
import org.kareha.hareka.swingclient.Strap;
|
||||
import org.kareha.hareka.user.UserRegistrationMode;
|
||||
|
||||
@@ -53,12 +50,11 @@ public class ServerSettingsFrame extends JInternalFrame {
|
||||
return;
|
||||
}
|
||||
final UserRegistrationMode mode = userRegistrationModeComboBox.getItemAt(index);
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
JOptionPane.showInternalMessageDialog(this, bundle.getString(BundleKey.NotConnected.name()));
|
||||
return;
|
||||
}
|
||||
session.write(new SetUserRegistrationModePacket(mode));
|
||||
strap.adminControl().setUserRegistrationMode(mode);
|
||||
});
|
||||
userRegistrationModePanel.add(userRegistrationModeComboBox);
|
||||
|
||||
@@ -70,12 +66,11 @@ public class ServerSettingsFrame extends JInternalFrame {
|
||||
return;
|
||||
}
|
||||
final boolean enabled = rescueMethodsEnabledCheckBox.isSelected();
|
||||
final WorldSession session = strap.getSession();
|
||||
if (session == null) {
|
||||
if (!strap.isConnected()) {
|
||||
JOptionPane.showInternalMessageDialog(this, bundle.getString(BundleKey.NotConnected.name()));
|
||||
return;
|
||||
}
|
||||
session.write(new SetRescueMethodsEnabledPacket(enabled));
|
||||
strap.adminControl().setRescueModeEnabled(enabled);
|
||||
});
|
||||
rescueMethodsEnabledPanel.add(rescueMethodsEnabledCheckBox);
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ public class View {
|
||||
viewTileField.animate(v);
|
||||
|
||||
final int motionWait;
|
||||
final FieldEntity entity = strap.getSession().getMirrors().getSelfMirror().getFieldEntity();
|
||||
final FieldEntity entity = strap.control().getFieldEntity();
|
||||
if (entity == null) {
|
||||
motionWait = SwingClientConstants.DEFAULT_MOTION_WAIT;
|
||||
} else {
|
||||
@@ -216,14 +216,14 @@ public class View {
|
||||
}
|
||||
|
||||
private void setModelName(final FieldEntity entity, final Model model) {
|
||||
final ChatEntity chatEntity = strap.getSession().getServer().getChatEntity(entity);
|
||||
final ChatEntity chatEntity = strap.control().getChatEntity(entity);
|
||||
final String alias;
|
||||
if (chatEntity != null) {
|
||||
alias = chatEntity.getAlias();
|
||||
} else {
|
||||
alias = null;
|
||||
}
|
||||
final String nickname = strap.getSession().getServer().getFieldNickname(entity.getLocalId());
|
||||
final String nickname = strap.control().getNickname(entity.getLocalId());
|
||||
final String name;
|
||||
if (alias != null && nickname != null) {
|
||||
if (alias.equals(nickname)) {
|
||||
|
||||
@@ -640,7 +640,7 @@ public class ViewPane extends JDesktopPane implements ManuallyClosable {
|
||||
default:
|
||||
break;
|
||||
case WALK: {
|
||||
final FieldEntity selfEntity = strap.getSession().getMirrors().getSelfMirror().getFieldEntity();
|
||||
final FieldEntity selfEntity = strap.control().getFieldEntity();
|
||||
if (selfEntity == null) {
|
||||
mode = MotionMode.STOP;
|
||||
break;
|
||||
@@ -658,7 +658,7 @@ public class ViewPane extends JDesktopPane implements ManuallyClosable {
|
||||
mode = MotionMode.STOP;
|
||||
break;
|
||||
}
|
||||
final FieldEntity selfEntity = strap.getSession().getMirrors().getSelfMirror().getFieldEntity();
|
||||
final FieldEntity selfEntity = strap.control().getFieldEntity();
|
||||
if (selfEntity == null) {
|
||||
mode = MotionMode.STOP;
|
||||
break;
|
||||
@@ -709,7 +709,7 @@ public class ViewPane extends JDesktopPane implements ManuallyClosable {
|
||||
if (!performed) {
|
||||
final Direction targetDirection = targetPosition.subtract(selfPosition).direction();
|
||||
final Vector position = selfPosition.neighbor(targetDirection);
|
||||
strap.getSession().getMirrors().getSelfMirror().move(position);
|
||||
strap.control().move(position);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user