Newbie Spellweaver
- Joined
- Jun 14, 2014
- Messages
- 6
- Reaction score
- 0
Hi Kevin I wanted to know how is moopledev rev 121 coming along?
Update: Added equipment checks when creating a new character.
Doing part by part. Minigames/interactions doesn't have a high priority for me. There is parts that are way more important for the gameplay.Idunno if you did or not, but you should redo the whole minigame/ interaction stuff
Doing part by part. Minigames/interactions doesn't have a high priority for me. There is parts that are way more important for the gameplay.
Update: Fixed UserHit, changed commands (no switch list, classes and a map now.)
Exactly, like this;means we register commands or?
Lol, I started to do it in my server yesterday hahaExactly, like this;You must be registered to see links
Exactly, like this;You must be registered to see links
By official server files do you mean the BMS v53 leak? Also what was wrong with the drops?
Where can i find some player commands / more gm commands for v120? maybe some fixes..
DROP TABLE IF EXISTS `moopledev`.`character_rights`;
CREATE TABLE `moopledev`.`character_rights` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`characterid` int(11) NOT NULL,
`command` varchar(45) DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
//Load Char rights (for commands)
ps = con.prepareStatement("SELECT * FROM character_rights WHERE characterid = ?");
ps.setInt(1, charid);
rs = ps.executeQuery();
while (rs.next()) {
ret.charRights.add(rs.getString("command"));
}
rs.close();
ps.close();
private List<String> charRights = new ArrayList<String>();
public boolean canExecuteCommand(String command) {
if(charRights.contains(command)) {
return true;
} else {
this.message("You can not use this command");
}
return false;
}
package client.command;
import client.MapleClient;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author BMS2
*/
public class CommandHandler {
public static Object executeCommand(String[] arrayCommand, MapleClient c) {
try {
String command = arrayCommand[0].toLowerCase();
String command2 = command.substring(0,1).toUpperCase() + command.substring(1);
Class<?> commandClass = Class.forName("client.command.handlers."+command2);
Object ins = commandClass.newInstance();
Method method = ins.getClass().getDeclaredMethod("executeCommand",String[].class,MapleClient.class);
method.invoke(ins,arrayCommand,c);
} catch (ClassNotFoundException | InstantiationException |SecurityException | InvocationTargetException | IllegalAccessException | NoSuchMethodException | IllegalArgumentException t) {
c.getPlayer().message("Unable to find this command");
}
return null;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package client.command.handlers;
import client.MapleCharacter;
import client.MapleClient;
import net.server.Server;
import net.server.channel.Channel;
import server.life.MapleLifeFactory;
import server.life.MapleMonster;
/**
*
* @author BMS2
*/
public final class Spawn {
private boolean isPlayerCommand = false; //Useless. Just to know if it is a player command;
public final boolean executeCommand(String[] sub, MapleClient c) {
/*System.out.println("executado");
return true;*/
MapleCharacter player = c.getPlayer();
Channel cserv = c.getChannelServer();
Server srv = Server.getInstance();
if(!player.canExecuteCommand(sub[0])) {
return false;
}
MapleMonster monster = MapleLifeFactory.getMonster(Integer.parseInt(sub[1]));
if (monster == null) {
return true;
}
if (sub.length > 2) {
for (int i = 0; i < Integer.parseInt(sub[2]); i++) {
player.getMap().spawnMonsterOnGroudBelow(MapleLifeFactory.getMonster(Integer.parseInt(sub[1])), player.getPosition());
}
} else {
player.getMap().spawnMonsterOnGroudBelow(MapleLifeFactory.getMonster(Integer.parseInt(sub[1])), player.getPosition());
}
return true;
}
}
if (heading == '/' || heading == '!' || heading == '@') {
String[] sp = s.split(" ");
sp[0] = sp[0].toLowerCase().substring(1);
if (!Commands.executePlayerCommand(c, sp, heading)) {
if (chr.isGM()) {
if (!Commands.executeGMCommand(c, sp, heading)) {
Commands.executeAdminCommand(c, sp, heading);
}
}
}
if (((heading == '/' || heading == '!') && chr.isGM()) || heading == '@') {
String[] sp = s.split(" ");
sp[0] = sp[0].toLowerCase().substring(1);
CommandHandler.executeCommand(sp, c);
I 'm going to post here a small release. It is the commands using reflection, and level-controlled by rights:
First of all in MYSQL run this code:
Code:DROP TABLE IF EXISTS `moopledev`.`character_rights`; CREATE TABLE `moopledev`.`character_rights` ( `id` int(11) NOT NULL AUTO_INCREMENT, `characterid` int(11) NOT NULL, `command` varchar(45) DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
then go to MapleCharacter.java and add this after a ps.close in loadCharFromDB method
Code://Load Char rights (for commands) ps = con.prepareStatement("SELECT * FROM character_rights WHERE characterid = ?"); ps.setInt(1, charid); rs = ps.executeQuery(); while (rs.next()) { ret.charRights.add(rs.getString("command")); } rs.close(); ps.close();
before "private MapleCharaceter() {" add:
Code:private List<String> charRights = new ArrayList<String>();
somewhere in MapleCharacter.java:
Code:public boolean canExecuteCommand(String command) { if(charRights.contains(command)) { return true; } else { this.message("You can not use this command"); } return false; }
Create a new class in client.command called CommandHandler.java
Code:package client.command; import client.MapleClient; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author BMS2 */ public class CommandHandler { public static Object executeCommand(String[] arrayCommand, MapleClient c) { try { String command = arrayCommand[0].toLowerCase(); String command2 = command.substring(0,1).toUpperCase() + command.substring(1); Class<?> commandClass = Class.forName("client.command.handlers."+command2); Object ins = commandClass.newInstance(); Method method = ins.getClass().getDeclaredMethod("executeCommand",String[].class,MapleClient.class); method.invoke(ins,arrayCommand,c); } catch (ClassNotFoundException | InstantiationException |SecurityException | InvocationTargetException | IllegalAccessException | NoSuchMethodException | IllegalArgumentException t) { c.getPlayer().message("Unable to find this command"); } return null; } }
Now create a new package called client.command.handlers and here you'll create all your classes corresponding to the command name (Starting with first letter uppercase)
example: Spawn.java
Code:/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package client.command.handlers; import client.MapleCharacter; import client.MapleClient; import net.server.Server; import net.server.channel.Channel; import server.life.MapleLifeFactory; import server.life.MapleMonster; /** * * @author BMS2 */ public final class Spawn { private boolean isPlayerCommand = false; //Useless. Just to know if it is a player command; public final boolean executeCommand(String[] sub, MapleClient c) { /*System.out.println("executado"); return true;*/ MapleCharacter player = c.getPlayer(); Channel cserv = c.getChannelServer(); Server srv = Server.getInstance(); if(!player.canExecuteCommand(sub[0])) { return false; } MapleMonster monster = MapleLifeFactory.getMonster(Integer.parseInt(sub[1])); if (monster == null) { return true; } if (sub.length > 2) { for (int i = 0; i < Integer.parseInt(sub[2]); i++) { player.getMap().spawnMonsterOnGroudBelow(MapleLifeFactory.getMonster(Integer.parseInt(sub[1])), player.getPosition()); } } else { player.getMap().spawnMonsterOnGroudBelow(MapleLifeFactory.getMonster(Integer.parseInt(sub[1])), player.getPosition()); } return true; } }
Just a few changes in GeneralchatHandler.java
Replace:
Code:if (heading == '/' || heading == '!' || heading == '@') { String[] sp = s.split(" "); sp[0] = sp[0].toLowerCase().substring(1); if (!Commands.executePlayerCommand(c, sp, heading)) { if (chr.isGM()) { if (!Commands.executeGMCommand(c, sp, heading)) { Commands.executeAdminCommand(c, sp, heading); } } }
with:
Code:if (((heading == '/' || heading == '!') && chr.isGM()) || heading == '@') { String[] sp = s.split(" "); sp[0] = sp[0].toLowerCase().substring(1); CommandHandler.executeCommand(sp, c);
If you want to give a GM rights to execute a command, you'll need to add the command to the database.
id |characterid |command
1 |30000 |spawn
2 |30000 |online
this is very simple to implement, and I think will be very helpful to set what each GM can do
Will add that, but not in rev 121.Is family working or you will add it?
Credits to DstroyerMS, DeadNetwork, Kurt and Revan for making this possible.