First Plugin - Code Review

Hello,

first sorry for my bad english.

I created my first plugin in JavaScript and wanted to ask if someone can review it so i can improve my code.

The Plugin shows a item name and icon in the top right corner (if someone collected a item or something).

You can call it via the plugin command "ItemInfo [itemId]".

Source Code: http://pastebin.com/ZhwAbkKk
The first thing I noticed is that you're replacing the Game_Interpreter.prototype.pluginCommand method, but you're not calling the old one inside it. This will break any other plugin that uses plugin commands.

You can do this to call the old one from inside the new:

Code:
var oldMethod = Game_Interpreter.prototype.pluginCommand;Game_Interpreter.prototype.pluginCommand = function(command, args) {  oldMethod.call(this, command, args);};
The first thing I noticed is that you're replacing the Game_Interpreter.prototype.pluginCommand method, but you're not calling the old one inside it. This will break any other plugin that uses plugin commands.
Thanks 🙂

I've forgotten it

EDIT:

the new source code (now with support for weapons and armors):

Code:
(function () {	var _currentWindow = null;		var Game_Interpreter_PluginCommand = Game_Interpreter.prototype.pluginCommand;	Game_Interpreter.prototype.pluginCommand = function (command, args) {		Game_Interpreter_PluginCommand.call(this, command, args);		if (command === "ItemInfo") {			if (args.length < 2) {				return;			}			if (_currentWindow === null) {				_currentWindow = new Window_Item_Info();				SceneManager._scene.addWindow(_currentWindow);			}						_currentWindow.open(args[0], args[1]);		}	};		function Window_Item_Info() {		this.initialize.apply(this, arguments);	}		Window_Item_Info.prototype = Object.create(Window_MapName.prototype);	Window_Item_Info.prototype.constructor = Window_Item_Info;		Window_Item_Info.prototype.initialize = function () {		Window_Base.prototype.initialize.call(this, Graphics.boxWidth - this.windowWidth(), 0, this.windowWidth(), this.windowHeight());		this.opacity = 0;		this.contentsOpacity = 0;		this._showCount = 0;		this._text = "";		this._iconIndex = 0;		this.refresh();	};		Window_Item_Info.prototype.refresh = function () {		this.contents.clear();		var width = this.contentsWidth();		this.drawBackground(0, 0, width, this.lineHeight());		this.drawIcon(this._iconIndex, 10, 2);		this.drawText(this._text, 50, 0, width, "left");	}		Window_Item_Info.prototype.open = function (type, itemId) {		var item = null;				switch (type) {			case "Weapon":				item = $dataWeapons[itemId];				break;			case "Armor":				item = $dataArmors[itemId];				break;			case "Item":			default:				item = $dataItems[itemId];				break;		}				this._text = item.name;		this._iconIndex = item.iconIndex;				Window_MapName.prototype.open.call(this);	}}());

Original thread: https://forums.rpgmakerweb.com/threads/first-plugin-code-review.46919/